akhauriyash/Code-Regression huggingface dataset:
/* 実行時間1s制限の場合
  10^6 1,000,000   : 余裕をもって間に合う
  10^7 10,000,000  : おそらく間に合う
  10^8 100,000,000 : 非常にシンプルな処理でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        if (n%i) continue;
        res.emplace_back(i, 0);     // 割り切れたら
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

const ll INF = LONG_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int h, n;
    cin >> h >> n;

    vector<int> a(n);

    rep(i, n) {
        cin >> a[i];
    }

    rep(i, n) {
        h -= a[i];
        if (h <= 0) {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";


    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 640
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        // Your code here!
        int N = int.Parse(Console.ReadLine());
        int[] h = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int count = 0;
        for(int i = 0; i < 10000; i++)//水やりの回数
        {
            int l = -2;
            int r = -1;
            for(int j = 0; j < h.Length; j++)//lを決定する
            {
                
                if(h[j] > 0) //数が残っていたら
                {
                    l = j;
                    break;
                }
                
                
            }
            if(l == -2)//lが定まらないとき
            {
                Console.WriteLine(count);
                return;
            }
            
            for(int k = l; k < h.Length; k++)//rを決定する
            {
                if(k == h.Length - 1)
                {
                    r = h.Length -1;
                    break;
                }
                if(h[k] == 0)
                {
                    r = k - 1;
                    break;
                }
            }
            
            //Console.WriteLine("l = " + l);
            //Console.WriteLine("r = " + r);
            
            for(int m = l; m <= r; m++)//水やりの処理
            {
                h[m]--;
                
            }
            count++;
            
        }
        
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const ll INF = 1e+18;

int main(){
    int N,K;
    cin >> N >> K;
    vector<ll> x(N);
    rep(i,N) cin >> x[i];
    ll ans=INF;
    ll dist;
    rep(i,N-K+1){
        if(x[i+K-1]<=0) dist=abs(x[i]);
        else if(x[i]<0) dist=min(abs(x[i])+abs(x[i+K-1]-x[i]),abs(x[i+K-1])+abs(x[i+K-1]-x[i]));
        else dist=x[i+K-1];
        ans=min(dist,ans);
    }

    cout << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pdbs;
using namespace std;

// typedef tree<int, null_type, less<int>, rb_tree_tag,  
//             tree_order_statistics_node_update>  
//     ordered_set;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#define citc(tc) int tc; cin>>tc; while(tc--) 
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinll2(l, z) ll l, z; cin>>l>>z;
#define cinll3(l, z, x) ll l, z, x; cin>>l>>z>>x;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define resize_vec(a) a.resize(unique(a.begin(), a.end()) - a.begin());
#define ms(dp, x) memset(dp, x, sf(dp))


// const long long MAX_SIZE = 1000000; 
// vector<long long >isprime(MAX_SIZE , true); 
// vector<long long >prime; 
// vector<long long >SPF(MAX_SIZE); 
  
// // function generate all prime number less then N in O(n) 
// void manipulated_seive(ll N) 
// { 
//     isprime[0] = isprime[1] = false ;  
//     for (ll i=2; i<N ; i++) 
//     {  
//         if (isprime[i]) 
//         { 
//             prime.push_back(i); 
//             SPF[i] = i; 
//         } 
//         for (ll j=0;j < prime.size() && i*prime[j] < N && prime[j] <= SPF[i];j++) 
//         { 
//             isprime[i*prime[j]]=false; 
//             SPF[i*prime[j]] = prime[j] ; 
//         } 
//     } 
// } 


ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
bool sortinrev(const pair<int,int> &a, const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 

void solve()
{
	ll s, w;
	cin>>s>>w;
	if(s > w)
		cout<<"safe\n";
	else
		cout<<"unsafe\n";

}
int main()
{
	fastio();
	// citc(tc)
		solve();
}


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

const int p = 1001;

vector<int> fib;

void makeFib(){
    fib.push_back(2); fib.push_back(3);
    for(int i=2; i <= 1010; i++){
        fib.push_back((fib[i-1]+fib[i-2])%p);
    }
}

int main(){
    int n, m;
    makeFib();
    while(cin >> n >> m){
        int count = 0;
        vector<int> v;
        for(int i=0; i < n; i++) v.push_back(fib[i]);
        sort(v.begin(), v.end());
        for(int i=1; i < v.size(); i++) if(m <= v[i]-v[i-1]) count++;
        cout << count+1 << endl;
    }
}

Measured memory_bytes: 1232
# 問題文をよく読んで、制約をヒントに答えを導かないといけない問題

s = input()
K = int(input())

result = []

len_s = len(s)
for i in range(len_s):
  for j in range(min(len_s, 5)):
    if s[i:i+j+1]:
      result.append(s[i:i+j+1])

ans = []
for res in sorted(result):
  if not res in ans:
    ans.append(res)
    if len(ans) == K:
      print(ans[K-1])
      exit()

Measured memory_bytes: 4580
#include <bits/stdc++.h>
#define int long long

using namespace std;

const int O = 1e6 + 5;

main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, a, b; cin >> n >> a >> b;
    int Ans = 1LL * n / (a + b) * a;
    int Sodu = n % (a + b);
    if (Sodu >= a){
        cout << Ans + a;
        return 0;
    }
    cout << Ans + Sodu;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}


int main() {
	int n, m;
	cin >> n >> m;
	int c = 0;
	vector<int> list;
	rep(i, n) {
		int a;
		cin >> a;
		list.push_back(a);
	}
	int sum = SUM(list);
	rep(i, n) {
		int a = list[i];
		if (a * 4 * m >= sum){
			c++;
		}
	}
	if (c >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}



Measured memory_bytes: 256
local n, m = io.read("*n", "*n")
local a = {}
for i = 1, 9 do a[i] = false end
local num_to_line = {2, 5, 5, 4, 5, 6, 3, 7, 6}
local topval = {0, 0, 0, 0, 0, 0, 0}
for i = 1, m do
  local tmp = io.read("*n")
  a[tmp] = true
  local line = num_to_line[tmp]
  topval[line] = math.max(topval[line], tmp)
end
local r = {}
local ins = table.insert
if a[1] then
  if n % 2 == 1 then
    local tmp = {7, 5, 3, 2, 8}
    for i = 1, 5 do
      if a[tmp[i]] then
        ins(r, tmp[i])
        n = n - num_to_line[tmp[i]]
        break
      end
    end
  end
  for i = 1, n / 2 do ins(r, 1) end
elseif a[7] then
  if n % 3 == 1 then
    if a[4] then ins(r, 4) n = n - 4
    elseif a[8] then ins(r, 8) n = n - 7
    else ins(r, topval[5]) ins(r, topval[5]) n = n - 10
    end
  elseif n % 3 == 2 then
    if 0 < topval[5] then ins(r, topval[5]) n = n - 5
    elseif a[4] then ins(r, 4) ins(r, 4) n = n - 8
    else ins(r, 8) ins(r, 8) n = n - 14
    end
  end
  for i = 1, n / 3 do ins(r, 7) end
elseif a[4] then
  if n % 4 == 1 then
    if 0 < topval[5] then ins(r, topval[5]) n = n - 5
    elseif 0 < topval[6] then ins(r, topval[6]) ins(r, 8) n = n - 13
    else ins(r, 8) ins(r, 8) ins(r, 8) n = n - 21
    end
  elseif n % 4 == 2 then
    if 0 < topval[6] then ins(r, topval[6]) n = n - 6
    elseif 0 < topval[5] then ins(r, topval[5]) ins(r, topval[5]) n = n - 10
    else ins(r, 8) ins(r, 8) n = n - 14
    end
  elseif n % 4 == 3 then
    if a[9] and 0 < topval[5] then ins(r, 9) ins(r, topval[5]) n = n - 11
    elseif a[8] then ins(r, 8) n = n - 7
    elseif a[6] then ins(r, 6) ins(r, topval[5]) n = n - 11
    else ins(r, topval[5]) ins(r, topval[5]) ins(r, topval[5]) n = n - 15
    end
  end
  for i = 1, n / 4 do ins(r, 4) end
elseif 0 < topval[5] then
  if n % 5 == 1 then
    if 0 < topval[6] then ins(r, topval[6]) n = n - 6
    else ins(r, 8) ins(r, 8) ins(r, 8) n = n - 21
    end
  elseif n % 5 == 2 then
    if a[9] then ins(r, 9) ins(r, 9) n = n - 12
    elseif a[8] then ins(r, 8) n = n - 7
    else ins(r, 6) ins(r, 6) n = n - 12
    end
  elseif n % 5 == 3 then
    if 0 < topval[6] and a[8] then ins(r, topval[6]) ins(r, 8) n = n - 13
    elseif 0 < topval[6] then ins(r, topval[6]) ins(r, topval[6]) ins(r, topval[6]) n = n - 18
    else ins(r, 8) ins(r, 8) ins(r, 8) ins(r, 8) n = n - 28
    end
  elseif n % 5 == 4 then
    if a[9] then
      for i = 1, 4 do ins(r, 9) end
      n = n - 24
    elseif a[8] then ins(r, 8) ins(r, 8) n = n - 14
    else
      for i = 1, 4 do ins(r, 6) end
      n = n - 24
    end
  end
  for i = 1, n / 5 do ins(r, topval[5]) end
elseif 0 < topval[6] then
  for i = 1, n % 6 do ins(r, 8) end
  n = n - 7 * (n % 6)
  for i = 1, n / 6 do ins(r, topval[6]) end
else
  for i = 1, n / 7 do ins(r, 8) end
end
table.sort(r, function(a, b) return a > b end)
print(table.concat(r, ""))


Measured memory_bytes: 264
#include<stdio.h>

int main(){
	int ri[100],a,b,c,x,n,f,i,j,r;
	
	while(0<=scanf("%d%d%d%d%d",&n,&a,&b,&c,&x)){
		if(n==0)break;
		
		for(i=0;i<n;i++){
			scanf("%d",&ri[i]);
		}
		
		r=0;
		f=0;
		while(f<=10000){
			if(x==ri[r]){
				++r;
				if(r==n)break;
			}
			++f;
			x=(a*x+b)%c;

		}
		
		if(f>10000){
			printf("-1\n");
		}else{
			printf("%d\n",f);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int prime[50000];
int n;
int main()
{
  int i,j,count;
  for(i=2;i<25002;i++)
    {
      if(prime[i]==1)
        continue;
      for(j=i+i;j<50000;j+=i)
        prime[j]=1;
    }

  for(;scanf("%d",&n),n;)
    {
      count=0;
      for(i=2;i<=n/2;i++)
        {
          for(j=i;i+j<=n;j++)
            {
              if(i+j==n && prime[i]==0 &&prime[j]==0)
                {
                  count++;
                }
            }
        }
      printf("%d\n",count);
    }
exit(0);
}

Measured memory_bytes: 792
/*  ex9_1
    pptenshi  */

#include<stdio.h>
#include<stdlib.h>
#define SIZE 11

typedef struct stack {
    char elem;
    struct stack *next;
}stack;


void push(stack **first, char elem)  {
    stack *new = calloc(1, sizeof(stack));
    if (new == NULL) exit(1);

    new->elem = elem;
    new->next = *first;
    *first = new;
}


char pop(stack **first) {
    char elem;
    stack *tmp = *first;

    // 要素がない場合は'2'を返す
    if (tmp == NULL) {
        return '2'; 
    }

    elem = tmp->elem;
    *first = tmp->next;
    free(tmp);
    return elem;
}


// 出力
void print_string(stack *first) {
    stack *stack_prt = NULL;
    char elem;

    // stack_ptrに入れなおして出力
    while ((elem = pop(&first)) != '2') {
        push(&stack_prt, elem);
    }
    while ((elem = pop(&stack_prt)) != '2') {
        putchar(elem);
    }
    putchar('\n');
}


int main(void) {
    char string[SIZE];      // s
    char *p_str;   // sのポインタ
    stack *first = NULL;    // 最初

    // input
    scanf("%s", string);
    p_str = string;

    
    while(*p_str) {
        switch (*p_str)
        {
        case '0': case '1':
            push(&first, *p_str);
            break;
        case 'B':
            pop(&first);
            break;
        }
        p_str++;
    }


    // output
    print_string(first);


    return 0;
}

Measured memory_bytes: 1648
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int mod=1e9+7;
const int maxn=1e5+7;
ll fac[maxn];
int main()
{
    fac[0]=1;
    for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
    int n,m;
    cin>>n>>m;
    if(n>m) swap(n,m);
    if(m>n+1) cout<<0<<'\n';
    else{
        ll ans;
        if(m==n+1) ans=fac[n]*fac[m]%mod;
        else ans=2*fac[n]*fac[m]%mod;
        cout<<ans<<'\n';
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int k, t;
    cin >> k >> t;
    int a[t];
    for (int i = 0; i < t; i++) {
        cin >> a[i];
    }

    int m = 0;
    for (int i = 0; i < t; i++) {
        m = max(m, a[i]);
    }

    cout << max(0, m - 1 - (k - m)) << endl;;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,i,j,g;
    cin>>a>>b>>c>>d;
    i=max(a,c);
    j=min(b,d);
    if(i>j){
        cout<<0<<endl;
        return 0;
    }
    else{
        g=abs(i-j);
    }
    cout<<g<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int m, d;
    cin >> m >> d;
    int cnt = 0;
    for( int i = 1; i <= m; ++i ) {
        for( int j = 1; j <= d; ++j ) {
            int t = j / 10;
            int o = j % 10;
            if( t < 2 || o < 2 ) continue;
            if( t * o == i ) ++cnt;

        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
ll mo=1000000007;
int main() 
{ 
	ll t1=1;
	//cin>>t1;
	while(t1)
	{
		ll x,n;
		cin>>x>>n;
		ll arr2[101];
		for(ll i=0;i<101;i++)arr2[i]=0;
		ll arr1[n];
		for(ll i=0;i<n;i++)
		{
			cin>>arr1[i];
			arr2[arr1[i]]=1;
		}
		ll ans1=-1;
		for(ll i=x;i>0;i--)
		{
			if(arr2[i]==0)
			{
              ans1=i;
              break;
			}
		}

		ll ans2=-1;
		for(ll i=x+1;i<2*x;i++)
		{
			if(i>100 || arr2[i]==0)
			{
              ans2=i;
              break;
			}
		}
        
        if(ans1==-1 && ans2==-1)cout<<"0"<<endl;
		else
		{
			ll ans=min(abs(x-ans1),abs(x-ans2));
		    if(x-ans1==x-ans2)cout<<ans1<<endl;
		else
		{
			if(ans==x-ans1)cout<<ans1<<endl;
			else cout<<ans2<<endl;
		}
	    }
		t1--;
    }
    return 0; 
}

Measured memory_bytes: 3640
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e6+10;
const int E = 1e6+10;  
ll d,m;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	printf("%d %d %d",c,a,b);
}

Measured memory_bytes: 256
# coding: utf-8

# In[5]:

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))


# In[6]:

base = A[0]
counter = 1
for i in range(1, N):
    if A[i] >= base:
        counter += 1
        base = A[i]
print(counter)


# In[ ]:





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

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second
#define xmax(x,y) ((x) = max((x),(y)))
#define xmin(x,y) ((x) = min((x),(y)))
#define all(x) (x).begin(),(x).end()
#define mem(x) memset(x , 0 , sizeof(x))
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define FP(a , b , c)  for(ll (a) = (b) ; (a) < (c) ; (a++));
#define FM(a , b , c)  for(ll (a) = (b) ; (a) >= (c) ; (a--));
#define connect(a , b , c) a[b].pb(c) , a[c].pb(b)

typedef long long int ll;
typedef unsigned long long int ull;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector <ll> vl;
typedef vector <int> vi;
typedef vector <string> vs;

const ll Maxn3 = 1e3 + 10;
const ll Maxn4 = 1e4 + 10;
const ll Maxn5 = 1e5 + 10;
const ll Maxn6 = 1e6 + 10;
const ll Maxn7 = 1e7 + 10;
const ll Maxn8 = 1e8 + 10;
const ll Maxn9 = 1e9 + 10;
const ll Maxn18 = 1e18 + 10;
const ll Mod1 = 1e7 + 7;
const ll Mod2 = 1e9 + 7;
const ll LLMax = LLONG_MAX;
const ll LLMin  = LLONG_MIN;
const ll INTMax = INT_MAX;
const ll INTMin  = INT_MIN;

ll mn = LLMax , mx = LLMin;

ll res[Maxn6] , a[Maxn3][Maxn3];
pll s[Maxn6];
int main()
{_
    ll h,w,d,l,r;cin>>h>>w>>d;
    for(ll i = 0 ; i < h ; i++)
        for(ll j = 0 ; j < w ; j++)
            {
            cin>>a[i][j];
            s[a[i][j]]=mp(i,j);
        }
    ll q;cin>>q;
    for(ll i = d + 1 ; i < h * w + 1 ; i++)
        res[i]=res[i-d]+abs(s[i].F-s[i-d].F)+abs(s[i].S-s[i-d].S);
    for(ll i = 0 ; i < q ; i++)
    {
        cin>>l>>r;
        cout<<res[r]-res[l]<<'\n';
    }
    return 0;
}
///SAliB


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

bool num[4][14];
const char str[] = {'S', 'H', 'C', 'D'};

int main()
{
    int iNum = 0;
    char cType = 0;
    int iTypeNum = 0;
    
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 14; j++)
        {
            num[i][j] = false;
        }
    }
    
    cin >> iNum;
    
    for (int i = 0; i < iNum; i++)
    {
        cin >> cType >> iTypeNum;
        if ('S' == cType)
        {
            num[0][iTypeNum] = true;
        }
        else if ('H' == cType)
        {
            num[1][iTypeNum] = true;
        }
        else if ('C' == cType)
        {
            num[2][iTypeNum] = true;
        }
        else if ('D' == cType)
        {
            num[3][iTypeNum] = true;
        }
    }
    
    for (int i = 0; i < 4; i++)
    {
        for (int j = 1; j < 14; j++)
        {
            if (false == num[i][j])
            {
                cout << str[i] << " " << j << endl;
            }
        }
    }
    
    return 0;
}



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


int main(){
	
	int n;
	cin >> n;
	int A[3][10],B[3][10],C[3][10],D[3][10];
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 10;j++){
			A[i][j] = B[i][j] = C[i][j] = D[i][j] = 0;
		}
	}
	for(int i = 0;i < n;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		if(a == 1) A[b-1][c-1] += d;
		else if(a == 2) B[b-1][c-1] += d;
		else if(a == 3) C[b-1][c-1] += d;
		else if(a == 4) D[b-1][c-1] += d;
	}
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 10;j++){
			cout << " " << A[i][j];
		}
		cout << endl;
	}
	cout << "####################\n";
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 10;j++){
			cout << " " << B[i][j];
		}
		cout << endl;
	}
	cout << "####################\n";
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 10;j++){
			cout << " " << C[i][j];
		}
		cout << endl;
	}
	cout << "####################\n";
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 10;j++){
			cout << " " << D[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        double[]p=new double[6],q=new double[6];
        for(int i=0;i<6;++i)p[i]=sc.nextDouble()/100.0;
        for(int i=0;i<6;++i)q[i]=sc.nextDouble()/100.0;
        double a=0.0,b=1.0;
        for(int i=0;i<70;++i){
            double c=(2.0*a+b)/3.0;
            double d=(a+2.0*b)/3.0;
            double fc=0.0,fd=0.0;
            for(int j=0;j<6;++j){
                fc+=Math.max(c*p[j],(1.0-c)*q[j]);
                fd+=Math.max(d*p[j],(1.0-d)*q[j]);
            }
            if(fc>fd)
                a=c;
            else
                b=d;
        }
        double o=0.0;
        for(int i=0;i<6;++i)o+=Math.max(a*p[i],(1.0-a)*q[i]);
        out.println(o);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll n,m,ans=0,c=1;
    cin>>n>>m;
    while(m>c){
        ans++;
        c--;
        c+=n;
    }
    cout<<ans el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!



Measured memory_bytes: 3628
import fractions

def main():
	t = int(input())
	qs = [list(map(int, input().split())) for _ in range(t)]
	for q in qs:
		sub(q)

def sub(q):
	a, b, c, d = q
	if d - b < 0:
		print("No")
		return
	
	if a - b < 0:
		print("No")
		return

	if b > c:
		gcd_bd = fractions.gcd(d, b)
		i = - 10
		while True:
			if 0 < gcd_bd * i + (a - c) % gcd_bd < b - c:
				print("No")
				return
			elif gcd_bd * i + (a - c) % gcd_bd >= b - c:
				print("Yes")
				return
			i += 1
				
	print("Yes")
	return
	
if __name__ == '__main__':
	main()


Measured memory_bytes: 5596
import java.util.Map;
import java.util.Scanner;

public class Main {

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        Scanner sc = new Scanner(System.in);

        String c1 = nextString(sc);
        String c2 = nextString(sc);
        
        char[] c1a = c1.toCharArray();
        char[] c2a = c2.toCharArray();
        
        if (c1a[0] == c2a[2] && c1a[1] == c2a[1] && c1a[2] == c2a[0]) {
            out("YES");
        } else {
            out("NO");
        }

    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt(Scanner sc) {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString(Scanner sc) {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(Scanner sc, int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt(sc);
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }

    public static void putCountMap(Map<Integer, Integer> map, int value) {
        if (map.containsKey(value)) {
            map.put(value, map.get(value) + 1);
        } else {
            map.put(value, 1);
        }
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(void)
{
  int n=0;
  int i=0;
  float x;
  float sum=0;
  char u;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%f %c%*s",&x,&u);
    if(u=='J')
    {
      sum+=x;
    }
    else
    {
      sum+=x*380000;
    }

  }
  printf("%f",sum);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int a[105][105], b[105 * 105],c[105*105];
int x, y, z;
int main()
{
	cin >> x >> y;
	cin >> z;
	int n = 0;
	int flag=1,sum=0;
	
	for (int i = 0; i < z; i++)
		cin >> b[i];	
	for (int i = 0; i < z; i++)
	{	
		for (int j = 0; j < b[i]; j++)
		{
			c[sum] = flag;
			sum++;
		}
		flag++;
	}
	for (int i = 0; i < x; i++)
	{
		
		if (i%2==1)
		{
			for (int j = y-1; j >= 0; j--)
			{
				a[i][j] = c[n];
				n++;
			}
		}
		else if(i%2==0)
		{
			for (int j = 0; j <y; j++)
			{
				a[i][j] = c[n];
				n++;
			}
		}
	}
	for (int i = 0; i < x; i++)
	{
		for (int j = 0; j < y; j++)
		{
			cout<<a[i][j]<<" ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
//Code by muq
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#define ll long long
#define inf 2147483647
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define repp(i,a,b,c) for(int i=a;i<=b;i+=c)
#define reph(i,a,b) for(i=a;i<=b;++i)
#define reg(i,head,d,a) for(int i=head[d];i;i=a[i].next)
#define rap(i,a,b) for(int i=a;i>=b;--i)
#define me(a,b) memset(a,b,sizeof(a));
#define poi(lx,ly,rx,ry) ((lx>rx or ly>ry)?0:(ice[rx][ry] + ice[lx-1][ly-1] - ice[rx][ly-1] - ice[lx-1][ry]))

int n, m, sx, sy;
int ice[45][45], ans = inf, f[45][45][45][45];
char temp;

using namespace std;

int main(void) {
	ios::sync_with_stdio(0);

	cin >> n >> m;
	me(f, 0x7f);
	f[1][1][n][m] = 0;
	rep(i, 1, n) {
		rep(j, 1, m) {
			cin >> temp;
			if (temp == 'P')
				sx = i, sy = j;
			ice[i][j] = ice[i - 1][j] + ice[i][j - 1] - ice[i - 1][j - 1] + ((temp == '#') ? 1 : 0);
		}
	}
	rep(i, 1, sx) {
		rep(j, 1, sy) {
			rap(o, n, sx) {
				rap(p, m, sy) {
					ans = min(ans, f[i][j][o][p]+min(min(poi(i,j,sx,sy),poi(i,sy,sx,p)),min(poi(sx,j,o,sy),poi(sx,sy,o,p))));
					rep(s, i, o) {
						rep(t, j, p) {
							if (sx <= s and sy <= t)
                				f[i][j][s][t]=min(f[i][j][s][t],f[i][j][o][p]+poi(i,t+1,s,p)+poi(s+1,j,o,t));
            				if (sx <= s and sy >= t)
            				    f[i][t][s][p]=min(f[i][t][s][p],f[i][j][o][p]+poi(i,j,s,t-1)+poi(s+1,t,o,p));
            				if (sx >= s and sy >= t)
            				    f[s][t][o][p]=min(f[s][t][o][p],f[i][j][o][p]+poi(i,t,s-1,p)+poi(s,j,o,t-1));
            				if (sx >= s and sy <= t)
            				    f[s][j][o][t]=min(f[s][j][o][t],f[i][j][o][p]+poi(i,j,s-1,t)+poi(s,t+1,o,p));
						}
					}
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16256
dics={
    0:'pon',
    1:'pon',
    2:'hon',
    3:'bon',
    4:'hon',
    5:'hon',
    6:'pon',
    7:'hon',
    8:'pon',
    9:'hon'
}
N=input()
print(dics[int(N[len(N)-1])])

Measured memory_bytes: 9180
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    const int XMAX = 50;
    int N, A;  cin >> N >> A;
    vi X(N + 1, 0); 
    int xMax = 0;
    FOR(i, 1, N + 1) {
        cin >> X[i];
        xMax = max(xMax, X[i]);
    }

    auto dp = vector<vvl>(N + MGN, vvl(N + MGN, vl(XMAX*N + MGN, 0)));
    // dp[i][j][k] : The number of ways to choose
    //   j cards whose sum is k from X[0]..X[i]					

    dp[0][0][0] = 1;
    FOR(i, 1, N + 1) dp[i][0][0] = 1;

    FOR(i, 1, N + 1) {
        FOR(j, 1, i + 1) {
            FOR(k, 0, xMax*N + 1) {
                if (k >= X[i]) {
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - X[i]];
                } else {
                    dp[i][j][k] = dp[i - 1][j][k];
                }
            }
        }
    }

    ll ans = 0;
    FOR(j, 1, N + 1) ans += dp[N][j][A*j];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 67456
import math


def get_num():
    return int(input())


n = get_num()
max_digit = math.floor(math.log10(n))
cnt = 0
for i in range(0, max_digit, 2):
    cnt += (10 ** (i + 1) - 10 ** i)

if max_digit % 2 == 0:
    cnt += (n - 10 ** max_digit + 1)

print(cnt)

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

int main() {
    string s;
    cin >> s;
    ll A = 0, B = 0, bnum = 0;
    rep(i, s.size()) {
        if (s[i] == 'B') {
            bnum++;
            A += i;
        }
    }
    rep(i, bnum) {
        B += (s.size()-1-i);
    }
    cout << B-A << endl;
}


Measured memory_bytes: 640
while True:

    n,k = map(int,input().split())
    if n==0 and k==0 :
        break
    x=[int(input()) for _ in range(n)]
    y=sum(x[0:k])
    z=[y]
    for i in range(k,n):
        y=y+x[i]-x[i-k]
        z.append(y)
    print(max(z))



Measured memory_bytes: 11708
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::cmp::max;

fn main() {
    let nw: Vec<usize> = read_vec();
    let n = nw[0];
    let maxw = nw[1];
    let vw: Vec<Vec<u32>> = read_vec2(n);

    let mut dp: Vec<Vec<u32>> = vec![vec![0; maxw + 1]; n + 1];

    for i in 1..n + 1 {
        let v = vw[i - 1][0];
        let w = vw[i - 1][1] as usize;
        for j in 0..w {
            dp[i][j] = dp[i - 1][j];
        }
        for j in w..maxw + 1 {
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v);
        }
    }

    println!("{}", dp[n][maxw]);
}



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

using namespace std;

int main(){
  int ans;
  for(int i =1; i<=5;i++){
  int a;
    cin >> a;
  if(a==0){
    cout << i << endl;
  }
  }
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n;
vector<int> lis[100100];

int dfs(int here, int p) {
	int res = 0;
	for (auto &there : lis[here]) {
		if (there==p) continue;
		res ^= dfs(there,here);
	}
	return res+(p!=-1);
}

int main() {
	int i;

	scanf("%d",&n);
	for (i=0;i<n-1;i++) {
		int a, b;
		scanf("%d%d",&a,&b);--a;--b;
		lis[a].push_back(b);
		lis[b].push_back(a);
	}
	if (dfs(0,-1)) printf("Alice\n");
	else printf("Bob\n");

    return 0;
}


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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

i64 extgcd(i64 a, i64 b, i64 &x, i64 &y) {
    i64 d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

i64 multi_inv(i64 a, i64 md) {
    i64 x, y;
    extgcd(md, a, x, y);
    return (y > 0 ? y : md + y);
}

int main(){
    i64 n;
    cin >> n;
    vector<i64> v;
    for(int i=0;i<n;++i){
        i64 x;
        cin >> x;
        v.push_back(x);
    }

    vector<i64> inv_sum(n+1);
    inv_sum[1] = 1;
    for(i64 i=2;i<=n;++i){
        inv_sum[i] = inv_sum[i-1] + multi_inv(i, MOD);
        inv_sum[i] %= MOD;
    }

    i64 ans = 0;
    for(i64 i=1;i<n;++i){
        i64 tmp = v[i] - v[i-1];
        tmp = (tmp * inv_sum[i]) % MOD;
        ans = (ans + tmp) % MOD;
    }

    for(i64 i=2;i<n;++i){
        ans *= i;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1908
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
	int N, M, X, Y;

	cin >> N >> M >> X >> Y;

	vector<int>x(N);
	vector<int>y(M);
	int temp = 0;

	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> y[i];
	}

	sort(x.begin(), x.end(),greater<int>());
	sort(y.begin(), y.end());

	bool flag = true;

	if (X >= Y) {
		flag = false;
	}
	if (x[0] >= y[0]) {
		flag = false;
	}
	if (X >= y[0] || x[0] >= Y) {
		flag = false;
	}

	if (flag == true) {
		cout << "No War";
	}
	else {
		cout << "War";
	}


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.begin(), v.end(), greater<ll>()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;
using namespace std;
int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22)
        cout << "bust";
    else
        cout << "win";
}


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

using namespace std;

#define N 1
string x;
int cnt, n;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> x;
    n = x.length();
    cnt = n;
    for (int i = 0; i < n - 1; i++)
        if (x[i] != x[i + 1])
            cnt = min(cnt, max(i + 1, n - 1 - i));
    cout << cnt << endl;
    return 0;
}


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

string rotate(string S){
  return S.substr(1)+S[0];
}

int main(){
  string S,T;
  cin >> S >> T;
  int N=S.length();
  for (int i = 0; i < N; i++) {
    if(S==T){
      cout << "Yes" << endl;
      return 0;
    }
    S=rotate(S);
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
while 1:
    n,r=map(int,input().split())
    if n+r==0:
        break
    x=list(range(n,0,-1))
    for i in range(r):
        p,c=map(int,input().split())
        y1=x[0:p-1]
        y2=x[p-1:p-1+c]
        y3=x[p-1+c:n]
        x=y2+y1+y3
    print (x[0])

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

    int N = Integer.parseInt(sc.nextLine());
    String T_txt = sc.nextLine();
    String[] T = T_txt.split(" ");
    int M = Integer.parseInt(sc.nextLine());
  	List<Integer> ansList = new ArrayList<Integer>();
    for (int cnt = 0; cnt < M; cnt ++) {
      String P_X_txt = sc.nextLine();
      String[] P_X = P_X_txt.split(" ");

      int sum = 0;
      for (int T_cnt = 0; T_cnt < T.length; T_cnt ++) {
        if (T_cnt + 1 == Integer.parseInt(P_X[0])) {
          sum += Integer.parseInt(P_X[1]);
          continue;
        }
        sum += Integer.parseInt(T[T_cnt]);
      }
      ansList.add(sum);
    }

    for (int ans : ansList) {
      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 21972
H,W = map(int, input().split())
s = [list(input()) for _ in range(H)]

bom = []
for i in range(H):
    for j in range(W):
        if s[i][j] == ".": s[i][j] = 0
        else: bom.append([i,j])

for i in range(len(bom)):
    h,w = bom[i][0], bom[i][1]
    for x,y in ([1,0], [-1,0], [0,1], [0,-1], [1,1], [-1,-1], [1,-1], [-1,1]):
        new_h, new_w =  h+x, w+y
        if new_h<0 or new_h>=H or new_w<0 or new_w>=W: continue
        if s[new_h][new_w] != "#":
            s[new_h][new_w] += 1
for ans in s:
    print("".join(list(map(str, ans))))

Measured memory_bytes: 9188
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  cout << min(K, N) * X + max(0, N - K) * Y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n,m;cin>>n>>m;
    vector<int>h(n);
    vector<bool>flag(n,true);
 
    for(int i=0;i<n;i++){
      cin>>h[i];
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        if(h[a]>=h[b]){
          flag[b]=false;
        }
        if(h[a]<=h[b]){
          flag[a]=false;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
      ans+=flag[i];
    } 
    cout<<ans<<endl;
}

Measured memory_bytes: 3800