akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,f[3009],dp[3009][3009],xar[3009],i,j,mod=998244353,zx,xc,pas;
int main(){
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>a>>b;
    for(i=1; i<=a; i++) cin>>f[i];
    xar[0]=1;
    for(i=1; i<=3002; i++){
        xar[i]=xar[i-1]*2;
        xar[i]%=mod;
    }
    for(i=1; i<=a; i++){
        for(j=1; j<f[i]; j++){
            dp[i][j]=dp[i-1][j]*2;
            dp[i][j]%=mod;
        }
        j=f[i];
        dp[i][j]=dp[i-1][j]*2+xar[i-1];
        dp[i][j]%=mod;
        for(j=f[i]+1; j<=b; j++){
            dp[i][j]=dp[i-1][j]*2+dp[i-1][j-f[i]];
            dp[i][j]%=mod;
        }
    }
    cout<<dp[a][b];
    return 0;
}

Measured memory_bytes: 74176
n = int(input())
*L, =map(int, input().split())
x = 0
ans = 0
min_L = min(L)
max_L = max(L)
for i in range(min_L,max_L):
    x = sum([((L[j])-i)**2 for j in range(len(L))])
    if i == min(L):
        ans = x
    if x - ans < 0:
        ans = x
print(ans)

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 a,b;
    cin >> a >> b;
    if(a >= 13){
        ANS(b);
    }else if(a >= 6){
        ANS(b/2);
    }else{
        ANS(0);
    }
    return 0;
}

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

using namespace std;

#define int long long

void solve() {
    int k;
    cin >> k;
    queue <int> q;
    for (int i = 1; i <= 9; ++i) q.push(i);
    int id = 0;
    while (true) {
        int val = q.front();
        q.pop();
        ++id;
        //cout << val << ' ';
        if (id == k) {
            cout << val;
            return;
        }
        int l = val % 10;
        if (l >= 1) q.push(val * 10 + l - 1);
        q.push(val * 10 + l);
        if (l < 9) q.push(val * 10 + l + 1);
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){

    long long n;
    cin >> n;
    vector<long long> a(n+1);
    vector<long long> b(n);
    
    for(int i=0; i<n+1; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];

    long long result = 0;
    for(int i=0; i<n; i++) {
        long long diff = b[i] - a[i];
        if(diff > 0) {
            result += a[i];
            a[i] = 0;
            if(a[i+1] - diff > 0) {
                result += diff;
                a[i+1] -= diff;
            }
            else {
                result += a[i+1];
                a[i+1] = 0;
            }
        }
        else {
            result += b[i];
            a[i] = 0;
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef int32_t i32;

#define int long long
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define forf(i,a,b) for(int i=a;i<b;i++)

#define INF 1e17+4
#define MINF 
#define MAX_INT 100000
#define MOD 1000000007
ll mod(ll n) { n %= MOD; if (n < 0) return n + MOD; else return n;}
// vector<int> adj[1000002];
// int vis[1000002],dep[1000002],siz[1000002];

// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

// bool sortfunc(const pair<int,int> &a, const pair<int,int> &b) 
// { 
//     return ;


void solve()
{
    int n;cin>>n;
    int d=n%10;
    if(d==2 || d==4 || d==5 || d==7 || d==9)
        cout<<"hon";
    else if(d==0 || d==1 || d==6 || d==8)
        cout<<"pon";
    else
        cout<<"bon";
}

signed main()
{
    FAST;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}














Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009];
int main()
{
    ll a,b,c,i,j,k,z;
    string s,d;
    char x;
    cin>>x;
    z=(x-'a')+2;
    printf("%c",z+96);
}


Measured memory_bytes: 256
gets;
s = gets.chomp;
t = [];
ans = 0;

[*'0'..'9'].each do |i|
  [*'0'..'9'].each do |j|
    [*'0'..'9'].each do |k|
      t << [i,j,k];
    end
  end
end

t.each do |v|
  x = s.index(v[0], 0);
  y = s.index(v[1], x + 1) if x;
  z = s.index(v[2], y + 1) if y;

  ans += 1 if x && y && z;
end

puts ans;


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef int64_t ll;

int main(){
  ll t;
  cin>>t;
  for(int i=0;i<t;i++){
    ll n,m,a,b;
    cin>>n>>m>>a>>b;
    cout<<atcoder::floor_sum(n,m,a,b)<<endl;
  }
}


Measured memory_bytes: 3660
#include <iostream>
//#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int N,i,j,k;
	cin >> N;
	vector<int>a(N);
	long long ans = 0;
	for (i = 0; i < N; i++) {
		cin >> a[i];
	}

	sort(a.begin(),a.end());

	for (i = 0; i < N - 2; i++) {
		for (j = i + 1; j < N - 1; j++) {
			for (k = j + 1; k < N; k++) {
				if (a[k] >= a[i] + a[j]) break;
				ans++;
			}
		}
	}
	cout << ans << endl;
}


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

using namespace std;
using namespace __gnu_pbds;

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

#define mod         1000000007
#define pi          3.1415926535898
#define eps         1e-9


#define fast       ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define vt vector
#define ar array
#define fs          first
#define sc          second
#define pb         push_back
#define sp          printf(" ")
#define nl          '\n'
#define all(a) a.begin(),a.end()
#define unique(c) (c).resize(unique(all(c)) - (c).begin())
#define sz(x) (int)(x).size()
#define revsort(x) sort(all(x));reverse(all(x))

#define set0(a)     memset(a,0,sizeof(a))
#define setneg(a)   memset(a,-1,sizeof(a))
#define setinf(a)   memset(a,126,sizeof(a))

#define REP(i,start,end) for (int i = start; i <=end; i++)
#define RREP(i,end,start) for (int i=end; i>=start ;i--)
#define EACH(x, a) for (auto& x: a)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef vector<double> vd;
typedef vector<vector<LL> > matrix;
typedef vector<vector<int> > graph;
LL INF=1e9;


 
template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}

LL powm(LL x, LL y,LL m)
{
    if(y==0)
        return 1;
    if(y==1)
        return x%m;
    if(y&1)
        return (x*(powm((x*x)%m,y/2,m)))%m;
    return powm((x*x)%m,y/2,m)%m;
}

LL inv(LL x, LL m)
{
    return powm(x,m-2,m);
}

int add(int var1, int var2){
    return (((((LL)(var1)) % mod + (LL)(var2)) % mod) + mod) % mod;
}


int mul(int var1, int var2){
    return (((LL)(var1)) % mod * (LL)(var2)) % mod;
}

void solve()
{
    int h,w,m;
    read(h,w,m);
    vi row(h,0), col(w,0);
    map<pii,int> mp;

    REP(i,1,m)
    {
        int x,y;
        read(x,y);
        x--;y--;
        row[x]++;
        col[y]++;
        mp[{x,y}]++;
    }
    int rmax=*max_element(all(row));
    int cmax=*max_element(all(col));

    int ans=rmax+cmax-1;
    vi rx,cx;
    REP(i,0,h-1) if(row[i]==rmax) rx.pb(i);
    REP(i,0,w-1) if(col[i]==cmax) cx.pb(i);

    for(auto i: rx) for(auto j: cx)
    {
        if(mp[{i,j}]==0) 
        {
            cout<<ans+1<<nl;
            return;
        }
    }
    cout<<ans<<nl;
}
int main()
{
    fast;
        solve();
}


Measured memory_bytes: 28424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a, b;
ll h[1000];

int main() {
	cin >> a >> b;
	h[0] = 1;
	FOR(i, 2, 1000) {
		h[i - 1] = h[i - 2] + i;
	}
	FOR(i, 1, 999) {
		if (a < h[i] && b < h[i + 1]) {
			if (h[i] - a == h[i + 1] - b) {
				cout << h[i] - a << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n;
  string s,list="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  while(cin >>n && n){
    vector < int > key(n);
    for(int i=0;i<n;i++) cin >> key[i];
    cin >> s;
    for(int i=0;i<s.size();i++) cout << list[(list.find(s[i])-key[i%n]+52)%52];
    cout << endl;
  }
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];


  
  
  vector<ll> m(n);

  ll pl = 0;
  ll mi = 0;
  rep(i, n){
    if(i%2 == 0) pl += a[i];
    else         mi += a[i];
  }

  rep(i, n){
    m[i] = abs(pl-mi);
    swap(pl, mi);
    pl += 2*a[i];
  }
  
  string pt = "";
  rep(i, n) cout << pt << m[i], pt = " ";
  cout << endl;



  return 0;
}


Measured memory_bytes: 2944
use std::io;
use std::str::FromStr;

fn main() {
    let nmq: Vec<i32> = reads();
    let (n,m,q) = (nmq[0], nmq[1], nmq[2]);
    let mut acc : Vec<Vec<i32>> = vec![vec![0; (nmq[0]+10) as usize]; (nmq[0]+10) as usize];
    for _ in 0..m {
        let xs : Vec<usize> = reads();
        acc[xs[0]-1][xs[1]] += 1;
    }

    for b in 0..n {
        for e in b+1..n+1 {
            acc[b as usize][e as usize] += acc[b as usize][(e-1) as usize];
        }
    }

    for e in 1..n+1 {
        for ib in 0..e {
            acc[(e-ib-1) as usize][e as usize] += acc[(e-ib) as usize][e as usize];
        }
    }

    for _ in 0..q {
        let xs : Vec<usize> = reads();
        println!("{}", acc[xs[0]-1][xs[1]]);
    }
}



#[allow(dead_code)]
fn getline() -> String {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().to_string()
}

#[allow(dead_code)]
fn read<T>() -> T where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn reads<T>() -> Vec<T> where T : FromStr {
    let mut ln = String::new();
    io::stdin().read_line(&mut ln).ok();
    ln.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}



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

int n;

int ans;

int main(void) {
  // Here your code !

  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    if (i % 2 == 0) continue;
    int cnt = 0;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) cnt += 1;
    }
    if (cnt == 8) ans += 1;
  }

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
-- well, gcd is defined in GHC.Real and is imported in Prelude.
gcd' :: Integral a => a -> a -> a
gcd' x y = if x >= y then gcd'' x y
                     else gcd'' y x where
                         gcd'' a 0 = a
                         gcd'' a b = gcd' b (a`mod`b)

main = getLine >>= print . (\[x,y] -> gcd' x y) . map read . words

Measured memory_bytes: 3692
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

#define ll long long
#define VEC2(type, name, dim0, dim1, init_val) vector<vector<type>> name(dim0, vector<type>(dim1, init_val))
#define IN(type, name) type name; cin >> name
#define IN_V(type, name, size) vector<type> name(size); for(auto& x: name) cin >> x
#define IN_VPair(type1, type2, name, size) vector<pair<type1, type2>> name(size); for(auto& x: name) cin >> x.first >> x.second
#define IN_VW(type, name, size) vector<type> name(size); for(auto& x: name)

#define REP(name, start, end) for(ll name = (start); (name) < (end); ++(name))
#define REPR(name, end, start) for(ll name = (start - 1); (name) >= (end); --(name))
#define ALL(iterable) (iterable).begin(), (iterable).end()

template<typename _T> void OutIter(_T beg, _T end, string separator = " ", bool eol = true) {
	cout << *beg;
	for (auto it = beg + 1; it != end; ++it) {
		cout << separator << *it;
	}
	if(eol)cout << endl;
}

int main()
{
	cout << fixed << setprecision(6);
	IN(ll, a);
	IN(ll, b);
	cout << (int)ceil(1.0 * (b - 1) / (a - 1)) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main (String[] args)
    {
        int h, w, i;
        String[] sh = new String[1000];
        String[] sw = new String[1000];
        Scanner sc = new Scanner(System.in);

        try
        {
            for (i = 0; true; i++)
            {
                sh[i] = sc.next();
                sw[i] = sc.next();
                if (sw[i].equals("0") && sh[i].equals("0")) break;
            }

            sc.close();

            int I = i;

            for (i = 0; i < I; i++)
            {
                h = Integer.parseInt(sh[i]);
                w = Integer.parseInt(sw[i]);

                for (int j = 1; j <= h; j++)
                {
                    for (int k = 1; k <= w; k++)
                    {
                        if ((j + k) % 2 == 0) System.out.print("#");
                        if ((j + k) % 2 == 1) System.out.print(".");
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
        catch (NumberFormatException e)
        {
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 35008
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

class Combination {
    private:
    vector<int> x, y;
    
    int modpow(int x, int n, int mod = (int)1e9 + 7) {
        int ret = 1;
        while (n > 0) {
            if ((n & 1)) {
                ret = ret * x % mod;
            }
            x = x * x % mod;
            n >>= 1;
        }
        return ret;
    }
    
    public:
    Combination(int n) {
        x.resize(n+1);
        y.resize(n+1);        
        x[0]=y[0]=1;
        for (int i = 1; i <= n; i++) {
            x[i]=(x[i-1]*i)%mod;
            y[i]=modpow(x[i],mod-2);
        }
    }
    
    int get(int n, int r) {
        if (n < r) return 0;
        return x[n] * y[n - r] % mod * y[r] % mod;
    }
    
};

void run(){
    int n,m,k;
    cin>>n>>m>>k;
    Combination comb(n*m);
 int ans=0;
rep(i,n)ans=(ans+i*(n-i)%mod*m%mod*m%mod)%mod;
rep(i,m)ans=(ans+i*(m-i)%mod*n%mod*n%mod)%mod;
ans=ans*comb.get(n*m-2,k-2)%mod;
cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
int zero() { return 0; }
int gcd(int a, int b) {
	if (a < b) return gcd(b, a);
	if (b == 0) return a;
	int r = a % b;
	return gcd(b, r);
}
int ord(int a,int p) {
	if (a%p != 0) return 0;
	return 1 + ord(a / p,p);
}
int rui(int a, int n) {
	if (n == 0) {
		return 1;
	}
	return a * rui(a, n - 1);
}
signed main() {
	int n, m;
	cin >> n >> m;
	vvel sum(m, vel(n + 1, 0));
	vel ko(m, 0);
	for (int i = 1; i <= n; i++) {
		int x; cin >> x;
		x--;
		ko[x]++;
		for (int j = 0; j < m; j++) {
			sum[j][i] = sum[j][i - 1];
		}
		sum[x][i]++;
	}
	vel ru(m + 1, 1);
	for (int i = 0; i < m; i++) {
		ru[i + 1] = ru[i] * 2;
	}
	int rui = ru[m];
	vel dp(rui, 0);
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < rui; j++) {
			int dj = j;
			int pot = 0;
			int kin = 0;
			vel bi(m, 0);
			for (int in = 0; in < m; in++) {
				bi[in] = dj % 2;
				kin += bi[in];
				pot += bi[in] * ko[in];
				dj = dj / 2;
			}
			if (kin == i) {
				for (int k = 0; k < m; k++) {
					if (bi[k] == 0) {
						mmax(dp[j + ru[k]], dp[j] + sum[k][pot + ko[k]] - sum[k][pot]);
					}
				}
			}
		}
	}
	cout << n-dp[rui - 1] << endl;
	return 0;
}



Measured memory_bytes: 26760
/*
    Author : DemonStar
*/

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx2,tune=native")

#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;
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pi pair<int, int>
#define pl pair<long long, long long>
#define pld pair<long double, long double>
#define endl '\n'
#define loop(i, n) for (ll i = 0; i < n; i++)
#define rep(i, begin, end) for (__typeof(begin) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define all(x) x.begin(), x.end()
#define vl vector<ll>
#define vi vector<int>
#define ml map<ll, ll>
#define vpl vector<pair<ll, ll>>
const ll mod = 1e9 + 7;

template <typename T, typename TT>
ostream &operator<<(ostream &os, const pair<T, TT> &t)
{
    return os << t.first << " " << t.second;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &t)
{
    for (auto &i : t)
        os << i << " ";
    return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (T &t : v)
        is >> t;
    return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, vector<pair<T1, T2>> &v)
{
    for (pair<T1, T2> &t : v)
        is >> t.first >> t.second;
    return is;
}

int main()
{
    fast;
    int n, w;
    cin >> n >> w;
    vpl v(n);
    cin >> v;
    vl dp(w + 1, 0);
    dp[0] = 0;
    loop(i, n)
    {
        for (int j = w; j >= 0; j--)
            if (j - v[i].first >= 0)
                dp[j] = max(dp[j], dp[j - v[i].first] + v[i].second);
    }
    cout << *max_element(all(dp)) << endl;

#ifdef LOCAL
    cerr
        << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for ( int i = 0; i < (n); ++i )
using namespace std;
using ll = long long int;
const long long int INF = 1001001001001001LL;
const int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;


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

    int N, W;
    cin >> N >> W;
    vector<int> w(N);
    vector<ll> v(N);
    rep(i, N) cin >> w[i] >> v[i];
    
    vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0LL));
    
    rep(i, N) {
        rep(j, W+1) {
            int nj = j - w[i];
            if( nj >= 0 ) dp[i+1][j] = max( dp[i][j], dp[i][nj] + v[i] );
            else dp[i+1][j] = dp[i][j];
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 80256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class point {
public:
	int num;
	int block;
	point() :num(0), block(2) {}
};
int main() {
	int X, Y;
	while (cin >> X >> Y&&X != 0) {
		vector<vector<point> > map(X + 2, vector<point>(Y + 2));
		for (int y = 1; y <= Y; ++y) {
			for (int x = 1; x <= X; ++x) {
				cin >> map[x][y].block;
			}
		}
		for (int i = 1; i <= X; ++i) {
			if (map[i][1].block == 0) {
				map[i][1].num = 1;
			}
		}
		for (int y = 1; y <= Y; ++y) {
			for (int x = 1; x <= X; ++x) {
				if (map[x][y].block == 2) {
					int dy = min(Y + 1, y + 2);
					if (map[x][dy].block != 1) {
						map[x][dy].num += map[x][y].num;
					}
				}
				else if (map[x][y].block == 0) {
					for (int k = -1; k <= 1; ++k) {
						int dx = x + k;
						int dy = y + 1;
						if (map[dx][dy].block == 0) {
							map[dx][dy].num += map[x][y].num;
						}
						else if (map[dx][dy].block == 2 && k == 0) {
							map[dx][dy].num += map[x][y].num;
						}
					}
				}
			}
		}
		int ans = 0;
		for (int x = 1; x <= X; ++x) {
			ans += map[x][Y + 1].num;
		}
		cout << ans << endl;
	}
	return 0;
}

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

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod  998244353
#define pi 2*acos(0)
#define pb push_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long double ld;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int r;cin>>r;cout<<r*r;
	return 0;
}


Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}

inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong

int n;
int Mod = 0;
int main() {
	cin >> n;
	int tmp = 1;
	for (int i = 1; i <= 2500000; i++) {
		Mod = (Mod + 7 * tmp % n) % n;
		tmp = tmp * 10 % n;
		if (Mod == 0) {
			cout << i; return 0;
		}
	}
	cout << -1;
}


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

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


Measured memory_bytes: 1408
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
map<int,int> mpp,vis;
string s;
vector<int> v;

main(void){
	scanf("%lld",&n);
	FOR{
		scanf("%lld",&a[i]);
		mpp[a[i]]++;
	}
	FOR{
		if(vis[a[i]]==0)cev+=mpp[a[i]]*(mpp[a[i]]-1)/2;
		vis[a[i]]=1;
	}
	FOR{
		cev-=mpp[a[i]]*(mpp[a[i]]-1)/2;
		mpp[a[i]]--;
		cev+=mpp[a[i]]*(mpp[a[i]]-1)/2;
		printf("%lld\n",cev);
		cev-=mpp[a[i]]*(mpp[a[i]]-1)/2;
		mpp[a[i]]++;
		cev+=mpp[a[i]]*(mpp[a[i]]-1)/2;
	}
	return 0;
}



Measured memory_bytes: 18944
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int n;

    int cnt = 0;

    cin >> n;

    vector<int> p(n);

    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    for (int i = 1; i < n - 1; i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
            cnt++;
            continue;
        }
        if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
            cnt++;
            continue;
        }
    }

    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){

int count_1=0,count_0=0;
int ans=0;
int buff;
while ((buff=getchar()) != EOF)
{
  if (buff=='0'){
    count_0++;
  }else if (buff=='1')
  {
    count_1++;
  }
}

if (count_1>0&&count_0>0)
{
  if (count_1>=count_0)
  {
    ans += count_0;
  }else
  {
    ans += count_1;
  }
}

printf("%d",ans*2);

return 0;

}

Measured memory_bytes: 1596
def pow(x, n , mod):
    res = 1
    while n > 0:
        if  bin(n & 1) == bin(1) :
            res = res * x % mod
        x = x*x % mod
        n = n >>1
    return res   

def combination(n,a):
    x = 1
    for i in range(a):
        x = x * (n-i) % mod
    y = 1
    for i in range(a):
        y = y * (a-i) % mod
    y = pow(y, mod-2, mod)
    return (x*y % mod)

x, y = map(int, input().split())
mod = 10**9 + 7
if ((x+y) % 3) != 0:
    print(0)
else:
    m = (2*x-y)//3
    n = x - 2*m
    if m < 0 or n < 0:
        print(0)
    else:
        ans = combination(n+m,n)
        print(ans)



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005]={0};
int main()
{
    int n,k;
    cin>>n>>k;
    int s=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(b[a[i]]==0)
            s++;
        b[a[i]]++;
    }
    if(s<=k)
    {
        puts("0");
        return 0;
    }
    sort(b,b+200001);
    int i=0;
    while(b[i]==0)
        i++;
    int sum=0;
    for(int j=1;j<=s-k;j++)
        sum=sum+b[i++];
    cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

ll search(ll n)
{
    ll sum = 0;
    for (ll i = 1; i <= n; i++)
    {
        sum += i;
        if (sum >= n)
        {
            return i;
        }
    }
}

vector<ll> ans;

void dfs(ll n)
{
    if (n == 1 || n == 2)
    {
        ans.push_back(n);
        return;
    }
    ll mx = search(n);
    ll next = n - mx;
    ans.push_back(mx);
    dfs(next);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    dfs(n);
    for (auto a : ans)
    {
        cout << a << endl;
    }
}

Measured memory_bytes: 640
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

# n=int(input())
# a=list(map(int,input().split()))
# q=int(input())
# bc=[list(map(int,input().split())) for i in range(q)]

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
n = int(readline())
a = tuple(map(int, readline().split()))
q = int(readline())
m = map(int, read().split())

lst=[0]*(10**5+1)
ans=0
for i in range(n):
    lst[a[i]]+=1
    ans+=a[i]
# print(ans)

for b, c in zip(m, m):
    bcnt=lst[b]
    ans+=(c-b)*bcnt
    lst[c]+=bcnt
    lst[b]=0
    print(ans)


Measured memory_bytes: 111080
n = int(input())
a = list(map(int,input().split()))
x = a[0]
y = 1
ans = 0
for i in range(1,n):
    if a[i] == x:
        y += 1
    else:
        ans += y // 2
        x = a[i]
        y = 1
print(ans + y // 2)

Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define M 1000000007
#define reg register
#define maxn 201
using namespace std;
int n, a[maxn], f[maxn][maxn][maxn], ans;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n * 2 - 1; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n * 2);
	f[n][1][0] = 1;
	for(int i = n - 1; i >= 1; i--){
		int pl = (a[i] != a[i + 1]), pr = (a[2 * n - i] != a[2 * n - i - 1]);
		for(int j = 0; j <= 2 * n - 1; j++)
			for(int k = 0; k + j <= 2 * n - 1; k++){
					if(!f[i + 1][j][k]) continue;
					for(int L = 1; L <= j + pl; L++) (f[i][j + pl - L + 1][k + pr + (L > 1)] += f[i + 1][j][k]) %= M;
					for(int R = 1; R <= k + pr; R++) (f[i][j + pl + 1][	k + pr - R] += f[i + 1][j][k]) %= M; 
				}
			}
	for(int i = 0; i <= 2 * n - 1; i++)
		for(int j = 0; j <= 2 * n - 1; j++) (ans += f[1][i][j]) %= M;
	cout << ans << endl;
}

Measured memory_bytes: 7296
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,a[100007] = { 0 };
	int i,j;
	int cnt = 0;
	scanf("%d",&n);
	for (int i = 1; i <= n; ++i)	scanf("%d",&a[i]);
	for (int i = 1; i <= n; ++i)
	{
		j = a[i];
		if(i == a[j] && j == a[i])	++cnt;
	}
	printf("%d\n", cnt / 2);
	return 0;
}


Measured memory_bytes: 512
from collections import deque

k = int(input())

if 1 <= k and k <= 9:
    print(k)
    exit()

d = deque([i for i in range(1, 10)])
k -= 9
while k > 0:
    num = d.popleft()
    if num % 10 != 0:
        new = 10*num + (num%10) - 1
        d.append(new)
        k -= 1
        if k == 0: break
    new = 10*num + (num%10)
    d.append(new)
    k -= 1
    if k == 0: break
    if num % 10 != 9:
        new = 10*num + (num%10) + 1
        d.append(new)
        k -= 1
        if k == 0: break

print(new)

Measured memory_bytes: 6096
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int s, s_1, s_2;
string ans;

int main() {
    scanf("%d", &s);
    s_1 = s / 100;
    s_2 = s % 100;

    if ( 0 < s_1 and s_1 < 13 ) {
        if ( 0 < s_2 and s_2 < 13 ) {
            ans = "AMBIGUOUS";
        } else {
            ans = "MMYY";
        }
    } else if ( 0 < s_2 and s_2 < 13 ) {
        ans = "YYMM";
    } else {
        ans = "NA";
    }

    printf("%s\n", ans.c_str());
    return 0;
}


Measured memory_bytes: 256
#cited from hahho
from itertools import accumulate

N,M,K = map(int,input().split())
A, B = [0], [0]
A.extend(list(accumulate(map(int,input().split()))))
B.extend(list(accumulate(map(int,input().split()))))

def it():
    j = M
    for i ,a in enumerate(A):
        while j >= 0 and a + B[j] > K:
            j -= 1
        if j >= 0:
            yield i + j
            
print(max(it()))

Measured memory_bytes: 48424
from collections import defaultdict

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

nl = [[] for _ in range(N + 1)]
for a, b in [tuple(map(int, input().split())) for _ in range(N - 1)]:
    nl[a].append(b)
    nl[b].append(a)
nl[0].append(1)

val = defaultdict(int)
for p, x in [tuple(map(int, input().split())) for _ in range(Q)]:
    val[p] += x

ans = [0 for _ in range(N + 1)]

stack = list()
stack.append((0, -1, 0))
while len(stack) > 0:
    v, p, cnt = stack.pop()
    cnt += val[v]
    ans[v] = cnt
    for next_v in nl[v]:
        if next_v != p:
            stack.append((next_v, v, cnt))

print(' '.join([str(a) for a in ans[1:]]))


Measured memory_bytes: 94224
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').mapIndexed { i, s -> s.toLong() - (i + 1) }.sorted()
    println(f(xs, xs[n / 2]))
}

private fun f(xs: List<Long>, b: Long): Long {
    return xs.map { Math.abs(it - b) }.sum()
}

Measured memory_bytes: 78936
N,M = map(int,input().split())

line = []
for i in range(N):
    a,b = map(int,input().split())
    line.append((a,b,a*b))

line.sort()
ans = 0
for l in line:
    if M == 0:
        break
    a = l[0]
    b = l[1]
    if b<=M:
        ans += a*b
        M -= b
    else:
        ans += a*M
        break
print(ans)


Measured memory_bytes: 20988
N = int(input())
h = list(map(int, input().split()))

dp = [10 ** 9 for i in range(N + 2)]
dp[0] = 0
for i in range(N):
    if i + 1 < N:
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    if i + 2 < N:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))

print(dp[N - 1])


Measured memory_bytes: 13976
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  ll x;
  cin >> x;

  ll c = x / 100;

  ll ans = 0;
  if(100 * c <= x && x <= 105 * c) ans = 1;

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){
    int n;cin>>n;
    int ans = 1;
    int i = 1;
    while(n-pow(2,i)>=0){
        i++;
    }
    i--;
    cout<<pow(2,i);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<climits>
#include<set>
#include<utility>
using namespace std;
typedef long long int ll;
 
int main(){

	int n, a[100000], x[100010]={0}, ans=-1;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<n; i++){
		for(int j=-1; j<=1; j++){
			x[a[i]+j+1]++;
		}
	}
	for(int i=0; i<100010; i++){
		ans=max(ans, x[i]);
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	int a[3];
	scanf("%d %d %d", &a[0], &a[1], &a[2]);
	sort(a, a + 3);
	if(a[0] != a[1]) printf("%d\n", a[0]);
	else printf("%d\n", a[2]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<v> vv;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define yes cout << "Yes\n";
#define no cout << "No\n";
#define yesno(f) \
    if (f)       \
        yes else no;
#define noo \
    { no return; }
#define round(x, y) ((2 * x + y) / (2 * y))
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define sq(x) ((x) * (x))
 
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
 
template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
    vector<T> a = vector<T>(n + oneIndexed);
 
    for (ll i = 0; i < n; i++) {
        T p;
        cin >> p;
        a[i + oneIndexed] = p;
    }
 
    return move(a);
}
 
template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
    if (end == -1)
        end = sz(a) - 1;
    for (ll i = begin; i <= end; i++) {
        cout << a[i] << " ";
    }
    cout << endl;
}
 
void solve() {
ll h,k;
cin >> h>>k;
v data=ga(k);
ll sum=0;
for (ll i=0;i<k;i++)
{
    sum+=data[i];
}
yesno(sum>=h);
}
 
int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("file", "r", stdin);
    // freopen("file", "w", stdout);

    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

int gcd(int a, int b) {
	while(b) {
		a %= b;
		int t=a; a=b; b=t;
	}
	return a;
}
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", gcd(a, b));
	return 0;
}


Measured memory_bytes: 2756
import java.util.*;

public class Main {
	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
	    long N = sc.nextLong(); long K = sc.nextLong(); long sum = 0;      
	      
	    if (K == 0){System.out.println(N*N); System.exit(0);}	      
	    for (int i=1; i<=N; i++) // b
	    	sum += (N/i) * Math.max(0, i-K)  + Math.max(0, (N%i)-K+1);
	    System.out.println(sum); sc.close();
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<cstring>
#define Black 1
#define White 2
#define Double 3
using namespace std;

char map[50][50];
int acs[50][50]={0};
int w,h;
int dxy[4][2]={{1,0},{0,1},{-1,0},{0,-1}};

void dfs(int y,int x,int type){
  if(0<=y && y<h && 0<=x && x<w){
    if(map[y][x]=='.' && (acs[y][x]&type)!=type){
      acs[y][x]+=type;
      for(int k=0;k<4;k++){
	dfs(y+dxy[k][1],x+dxy[k][0],type);
      }
    }
  }
}

int main(){
  while(cin>>w>>h,w){
    memset(map,'.',sizeof(map));
    memset(acs,0,sizeof(acs));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>map[i][j];
	if(map[i][j]!='.') acs[i][j]=Double;
      }
    }
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(map[i][j]=='B'){
	  //	  acs[i][j]=Double;
	  for(int k=0;k<4;k++){
	    dfs(i+dxy[k][1],j+dxy[k][0],Black);
	  }
	}else if(map[i][j]=='W'){
	  //acs[i][j]=Double;
	  for(int k=0;k<4;k++){
	    dfs(i+dxy[k][1],j+dxy[k][0],White);
	  }
	}
      }
    }
    int black=0;
    int white=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(acs[i][j]==Black){
	  black++;
	}else if(acs[i][j]==White){
	  white++;
	}
      }
    }
    cout<<black<<" "<<white<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

import math
a,b,h,m=getNM()
pi=math.pi
thetah=pi/6*h+pi/30/12*m
thetam=pi/30*m

l=math.sqrt((a**2+b**2)-2*a*b*math.cos(thetah-thetam))
l2=math.sqrt((a**2+b**2)-2*a*b*math.cos(thetah-thetam))
print(l)

Measured memory_bytes: 9396
program bomber
  implicit none
  integer :: h, w, m, nx, ny, mx = 0, my = 0, d, i
  integer, dimension(300000) :: x = 0, y = 0, cx = 0, cy = 0
  read(*,*) h, w, m
  do i = 1, m
    read(*,*) x(i), y(i)
    cx(x(i)) = cx(x(i)) + 1
    cy(y(i)) = cy(y(i)) + 1
  end do
  nx = maxval(cx(1:h))
  ny = maxval(cy(1:w))
  do i = 1, h
    if (cx(i) == nx) mx = mx + 1
  end do
  do i = 1, w
    if (cy(i) == ny) my = my + 1
  end do
  d = mx * my
  do i = 1, m
    if (cx(x(i)) == nx .and. cy(y(i)) == ny) d = d - 1
  end do
  write(*,'(i0)') nx + ny - merge(1, 0, d == 0)
end program bomber

Measured memory_bytes: 7580
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
bool check=false;


int main(void){
    string S,T;
    long A,B;
    string U;
    cin>>S>>T>>A>>B>>U;
    cout<<A-(S==U)<<" "<<B-(T==U)<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <string.h>
#include <vector>

using namespace std;
int main() {
    int T, X;
    cin >> T >> X;
    double ans = (double)T / X;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for a in A:
        while True:
            if a % 2 == 1:
                break
            a /= 2
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70588
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(int argc, char const *argv[])
{
	char ymd1[10];
	char *ymd2 = "2019/04/30";
	scanf("%s",ymd1);
	if(strcmp(ymd1,ymd2) <= 0)	printf("Heisei\n");
	else printf("TBD\n");

	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
 
int main(){
	int H, W;
	char S[26][26][6];
	int i, j;
	scanf("%d %d", &H, &W);
	for (i = 0; i < H; i++)
		for (j = 0; j < W; j++){
			scanf("%s", S[i][j]);
			if (!strcmp(S[i][j], "snuke")){
				printf("%c%d\n", 'A' + j, i + 1);
				return 0;
			}
        }
	return -1;
}

Measured memory_bytes: 128