akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace A
{
	class Program
	{
		static void Main()
		{
			var N = int.Parse(Console.ReadLine());

			var H = new List<int>();
			var line = Console.ReadLine();
			var lineSplited = line.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
			foreach (var token in lineSplited) {
				H.Add(int.Parse(token));
			}

			var dp = new DP(N, H);
			Console.WriteLine(dp.getCost(N - 1));
		}
	}

	class DP
	{
		int N;
		List<int> H;
		List<int> table;

		public DP(int N, List<int> H)
		{
			this.N = N;
			this.H = H;

			table = new List<int>();
			for (int i = 0; i < N; i++) {
				table.Add(int.MaxValue);
			}

			table[0] = 0;
		}

		public int getCost(int i)
		{
			if (i == 1) return table[1] = table[0] + Math.Abs(H[1] - H[0]);

			if (table[i] < int.MaxValue) return table[i];
			
			int cost1, cost2;

			if (table[i - 1] < int.MaxValue)
				cost1 = table[i - 1] + Math.Abs(H[i] - H[i - 1]);
			else
				cost1 = getCost(i - 1) + Math.Abs(H[i] - H[i - 1]);

			if (table[i - 2] < int.MaxValue)
				cost2 = table[i - 2] + Math.Abs(H[i] - H[i - 2]);
			else
				cost2 = getCost(i - 2) + Math.Abs(H[i] - H[i - 2]);

			if (cost1 < cost2) return table[i] = cost1;
			return table[i] = cost2;
		}
	}
}


Measured memory_bytes: 24544
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define mod 1000000007

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    return (x * powll(y,mod-2)) % mod;
}

ll dp[41][1<<17];

int main(void){
    int n, x, y, z;
    cin >> n >> x >> y >> z;
    int m = x + y + z;

    ll xyz = (1<<(x+y+z-1)) + (1<<(y+z-1)) + (1<<(z-1));

    dp[0][0] = 1;
    REP(i,n) REP(mask,1<<m){
        FOR(k,1,10){
            int next = (mask << k) + (1 << (k-1));
            next &= (1<<m) - 1;
            if ((next & xyz) == xyz) continue;
            dp[i+1][next] = (dp[i+1][next] + dp[i][mask]) % mod; 
        }
    }
    ll ans = 0;
    REP(mask,1<<m) ans = (ans + dp[n][mask]) % mod;
    ans = (powll(10,n) - ans + mod) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 41216
#include<iostream>
char a[16], b[16] = {'C', 'O', 'D', 'E', 'F', 'E', 'S', 'T', 'I', 'V', 'A', 'L', '2', '0', '1', '6'};//直接字符数组走一波，后面比较方便
int ans;
int main(void){
    std::cin >> a;
    for(int i = 0; i < 16; i ++){
        if(a[i] != b[i]) ans++;
    }
    std::cout << ans << "\r\n";  
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n=inp()
    s=list(input())
    for i in range(len(s)):
        s[i]=int(s[i])
    dic1=defaultdict(int)
    dic2=defaultdict(int)
    cnt1=0
    cnt=[0 for _ in range(10)]
    for i in range(n-2):
        if dic1[s[i]]==0:
            dic1[s[i]]=1
        for j in range(10):
            if dic1[j]==1:
                if dic2[j*10+s[i+1]]==0:
                    cnt1+=1
                    dic2[j*10+s[i+1]]=1
        cnt[s[i+2]]=cnt1
    print(sum(cnt))



if __name__ == "__main__":
    main()

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

int main() {
  char c;
  cin >> c;
  if (islower(c)) cout << "a" << endl;
  else cout << "A" << endl;
  return 0;
}

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

int main(){
  long long N;
  long long count=1;//1番目は絶対満たすかつ条件の例外
  bool seikou=true;
  long long min;
  cin>>N;
  vector<long long>suzi(N);
  
  for(long long i=0;i<N;i++){
    cin>>suzi.at(i);
  }
  min=suzi.at(0);
 for(long long i=0;i<N;i++){
   if(min>suzi.at(i)){
     min=suzi.at(i);
   }
   else{
     seikou=false;
   }
   if(seikou==true){
     count++;
   }
   else{
     seikou=true;
   }
 }
    cout<<count<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  long long int N;
  long long int A;
  long long int B;
  long long int sum = 0;
  long long int num = 0;
  cin>>N;
  cin>>A;
  cin>>B;
  num = N % (A + B);
  sum += ((N / (A + B)) * A) + (min(num,A));
  cout<<sum<<'\n';
}


Measured memory_bytes: 3648
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)
i = 1
basic = arr[0]
sum = 0
while i < n
  if basic > arr[i] # 2 1
    sum += basic-arr[i]
  else # 2 5
    basic = arr[i]
  end
  i += 1
end
puts sum

Measured memory_bytes: 30176
#include <algorithm>
#include <iostream>
using namespace std;
static const int MAX = 200000;

int data[MAX + 1];
int head = 0;

void push(int num) {
  data[head] = num;
  head++;
}

int pop() {
  head--;
  return data[head];
}

int main() {
  int a, b;
  char ch[100];
  while (cin >> ch) {
    switch (ch[0]) {
    case '+':
      a = pop();
      b = pop();
      push(b + a);
      break;
    case '-':
      a = pop();
      b = pop();
      push(b - a);
      break;
    case '*':
      a = pop();
      b = pop();
      push(b * a);
      break;
    default:
      push(atoi(ch));
      break;
    }
  }
  cout << data[0] << endl;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int n;
int l=1;

set<int> st;

int main(){
  scanf("%d",&n);
  while(n--){
    int x;
    scanf("%d",&x);
    if(st.count(0)>0){
      printf("No\n");
      continue;
    }
    
    while(st.count(l)>0)l++;

    if(x<l-1 || (x==l-1 && (int)st.size()>l-1 ) ){
      printf("No\n");
      continue;
    }

    printf("Yes\n");
    while(st.count(x)>0){
      st.erase(x);
      x--;
    }
    st.insert(x);
  }
  return 0;
}

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

int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  for(int i=0;i<2;i++) {
    if (s[i]!=s[i+1]) {
      cout << "Yes" <<endl;
      return 0;
    }
  }
  cout << "No" <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
/*vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
int modInverse(int n){ 
return p(n, MOD-2); 
}  
int nCrModPFermat(int n, int r){   
    if(r == 0)  return 1; 
    return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
} 
*/
signed main(){
    fast();
    int n, e;
    cin >> n >> e;
    vector<vector<int>> adj(n+1);
    for(int i=0, u, v; i<e; i++){
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    vector<int> d(n+1, -1);
    vector<bool> vis(n+1, 0);
    int s = 1;
    queue<int> q;
    d[s] = 0;
    q.push(s);
    while(!q.empty()){
        int u = q.front();
        q.pop();
        vis[u] = 1;
        for(auto v: adj[u]){
            if(!vis[v]){
                q.push(v);
                d[v] = d[u]+1;
                vis[v] = 1;
            }
        }
    }
    for(int i=1; i<=n; i++){
        if(d[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }
    vector<int> ans;
    for(int i=2; i<=n; i++){
        for(auto j: adj[i]){
            if(d[j]+1 == d[i]){
                ans.pb(j);
                break;
            }
        }
    }
    cout << "Yes" << endl;
    for(auto i: ans)    cout << i << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rrep(i, n, s) for (Int i = n - 1; i >= s; i--)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

template<typename T>
class SegmentTree {
private:
    Int n;
    vector<T> node;
    T ident;
    T f(T x, T y) {
        return min(x, y);
    }
public:
    SegmentTree(vector<T> in, T identity_element) : n(in.size()), ident(identity_element) {
        node.resize(n * 2);
        rep(i, 0, n) node[n + i] = in[i];
        rrep(i, n, 1) node[i] = f(node[i<<1|0], node[i<<1|1]);
    }
    void update(Int i, T value) {
        i += n;
        node[i] = value;
        while (i > 1) {
            i >>= 1;
            node[i] = f(node[i<<1|0], node[i<<1|1]);
        }
    }
    T query(Int l, Int r) {
        T ret = ident;
        l += n, r += n;
        while (l < r) {
            if (l & 1) ret = f(ret, node[l++]);
            if (r & 1) ret = f(ret, node[--r]);
            l >>= 1, r >>= 1;
        }
        return ret;
    }
};

int main() {
    Int n, q;
    cin >> n >> q;
    vector<Int> a(n, (1LL<<31) - 1);
    SegmentTree<Int> seg(a, (1LL<<31) - 1);
    vector<Int> res;
    rep(i, 0, q) {
        Int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            seg.update(x, y);
        }
        if (c == 1) {
            res.push_back(seg.query(x, y + 1));
        }
    }
    rep(i, 0, res.size()) dump(res[i]);
    return 0;
}


Measured memory_bytes: 6088
use std::iter::Iterator;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n:usize,
        m:usize,
        a:[i32;n],
    }
    let mut a = a;
    a.sort();
    a.reverse();
    let mut standard: f32 = (a.iter().fold(0, |sum, a| sum + a) as f32);
    standard /= (4 * m) as f32;
    let mut flag = true;
    for i in 0..m {
        if (a[i] as f32) < standard {
            flag = false;
        }
    }
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> fie(h);
  for (int i=0; i<h; ++i) cin >> fie.at(i);
  
  vector<vector<int>> cost(h, vector<int>(w, 1e9));
  if (fie.at(0).at(0) == '.') cost.at(0).at(0) = 0;
  else cost.at(0).at(0) = 1;
  for (int i=0; i<h; ++i) {
    for (int j=0; j<w; ++j) {
      if (i > 0) {
        if (fie.at(i-1).at(j) == '.' && fie.at(i).at(j) == '#') cost.at(i).at(j) = min(cost.at(i).at(j), cost.at(i-1).at(j) + 1);
        else cost.at(i).at(j) = min(cost.at(i).at(j), cost.at(i-1).at(j));
      } 
      if (j > 0) {
        if (fie.at(i).at(j-1) == '.' && fie.at(i).at(j) == '#') cost.at(i).at(j) = min(cost.at(i).at(j), cost.at(i).at(j-1) + 1);
        else cost.at(i).at(j) = min(cost.at(i).at(j), cost.at(i).at(j-1));
      }
    }
  }
  
  cout << cost.at(h-1).at(w-1) << endl;
  return 0;
}


Measured memory_bytes: 256
import Data.List (foldl')

main = do
  _ <- getLine
  a <- map read . words <$> getLine

  let l = binarySearch ((>=2) . foo a) 0 (10^18)
  let r = binarySearch ((>=3) . foo a) 0 (10^18)

  if l < r then putStrLn $ show l ++ " " ++ show (r - 1)
           else print (-1)

foo :: [Int] -> Int -> Int
foo a x = foldl' (\a b -> a `div` b * b) x a

binarySearch :: (Int -> Bool) -> Int -> Int -> Int
binarySearch f l r
  | r - l == 1 = r
  | otherwise = let m = div (l + r) 2
                in if f m then binarySearch f l m
                          else binarySearch f m r



Measured memory_bytes: 36220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define int long long
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const int mod = 1000000007;
int rnd(int x){return mrand()%x;}
int pb(int a,int b) {int res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a*=a;a%=mod;}return res;}
int a[26];
int b[26];
signed main(){
	string s;
	string t;
	cin>>s>>t;
	int l=s.length();
	for(int i=0;i<l;i++)a[s[i]-'a']++;
	for(int i=0;i<l;i++)b[t[i]-'a']++;
	sort(a,a+26);
	sort(b,b+26);
	for(int i=0;i<26;i++)if(a[i]!=b[i]){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n,a,b,h;
    vector<int> monster,v;
    cin>>n>>a>>b;
    a = a-b;
    for(int i = 0; i < n; i++){
        cin>>h;
        monster.push_back(h);
    }
    long long int L=0, R=10000000000000000, M;
    while(R-L>1){
        M = (L+R)/2;
        for(int i = 0; i < n; i++){
            if(monster[i]/b+(monster[i]%b==0? 0:1) > M)  v.push_back(monster[i]-b*M);
        }
        for(int i = 0; i < v.size(); i++){
            M -= (v[i]/a+(v[i]%a==0? 0:1));
        }
        if(M>=0)  R=(L+R)/2;
        else  L=(R+L)/2;
        v.clear();
    }
    cout<<R<<'\n';
}

Measured memory_bytes: 1400
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked

int inp() {
	int x = 0, f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

ll inp_ll() {
	ll x = 0; int f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

template<class T>
bool read(T &x)
{
	x = 0;
	char ch = getchar();
	if (ch == EOF) return 0;
	for(; !isdigit(ch); )
	{
		ch = getchar();
		if (ch == EOF) return 0;
	}
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return 1;
}

template<class T>
void write(T x)
{
	static char s[22];
	static char *it = s+20;
	static char *end = s+20;
	if (!x)
		*-- it = '0';
	while (x)
	{
		*-- it = x%10+'0';
		x /= 10;
	}
	for (; it < end; ++ it)
		putchar(*it);
}

template<class T>
void writeln(T x)
{
	write(x);
	putchar('\n');
}

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

int n;
int a[MAXN], b[MAXN];

int main()
{
	
	n = inp();
	for (int i = 1; i <= n; ++ i)
		a[i] = inp();
	for (int i = n; i >= 1; -- i)
	{
		int cur = 0;
		for (int j = i; j <= n; j += i)
			cur ^= b[j];
		b[i] = cur^a[i];
	}
	vector<int> ret;
	for (int i = 1; i <= n; ++ i)
		if (b[i]) ret.push_back(i);
	printf("%d\n", ret.size());
	for (int i = 0; i < ret.size(); ++ i)
	{
		if (i) putchar(' ');
		printf("%d", ret[i]);
	}
	puts("");
	
	return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long int
#define pi 3.1415926536
using namespace std;

void solve()
{ll t,n,m,x,y,z,d,p=0,b=0,q,l=INT_MAX,k,mini=0,prev;
  cin>>n>>m;
  vector<ll> val(n+1),wt(n+1);
  for(ll i=1;i<=n;i++)
  {
  	cin>>wt[i]>>val[i];
  	b+=val[i];
  }
  vector<vector<ll> > v(n+1,vector<ll>(b+1,INT_MAX));
  for(ll i=0;i<=n;i++)
   v[i][0]=0;
  for(ll i=1;i<=n;i++)
  {
  	for(ll j=1;j<=b;j++)
  	{
  		v[i][j] = v[i-1][j];
  		if(val[i]<=j)
  		v[i][j]=min(v[i][j],v[i-1][j-val[i]] + wt[i]);
  		
	}
  }
  ll ans =0;
  for(ll i=0;i<=b;i++)
  {
  	if(ans < i and v[n][i] <= m )
  		ans = i;
  }
  
  cout << ans;
  
}

int main()
{

ll t=1;

while(t--)
{solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 80256
N = int(input())
A = tuple(map(int,input().split()))
from collections import defaultdict
dp_non = defaultdict(lambda: -2**60)
dp_take = defaultdict(lambda: -2**60)
dp_non[(0,0)] = 0
for i,x in enumerate(A,1):
    j = (i-1)//2
    for n in (j,j+1):
        dp_non[(i,n)] = max(dp_non[(i-1,n)],dp_take[(i-1,n)])
        dp_take[(i,n)] = dp_non[(i-1,n-1)]+x
print(max(dp_non[N,N//2],dp_take[(N,N//2)]))

Measured memory_bytes: 182204
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef list<int> li;

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL)


const int INF=INT_MAX;
const ld PI=acos(-1);//3.1415926535897932384626433
const ld E=2.71828183;
const int MOD=1e9+7;

struct segment_tree{

    vector<ull>tree;
    int size;
    ll DEF;
    void init(int n){
        size=1;
        DEF=INF;
        while(size<n)size*=2;
        tree=vector<ull>(2*size,0);
    }

    ull merge(ull a,ull b){return a|b;}
    bool search(ull x,int l,int r){
        int m=(l+r)/2;
        if(size<=l || size<=r || l>r) return false;
        if(tree[m]==x)
            return true;
        else if(tree[m]>x)
            return search(x,l,m);
        else
            return search(x,m,r);
    }
    bool search(ull x){
        return search(x,0,size);
    }
    void set(int i,int x,ull v,int lx, int rx){
        if(rx-lx==1){
            tree[x]=v;
            return;
        }
        int m=(rx+lx)/2;
        if(i<m){
            set(i,2*x+1,v,lx,m);
        }
        else{
            set(i,2*x+2,v,m,rx);
        }
        tree[x]=merge(tree[2*x+1],tree[2*x+2]);
    }
    void set(int i,ull v){
        set(i,0,v,0,size);
    }
    ull sum(int l,int r,int x,int lx,int rx){
        if(r<=lx || rx<=l) return 0;//change
        else if(l<=lx && rx<=r)return tree[x];
        int m=(lx+rx)/2;
        return merge(sum(l,r,2*x+1,lx,m),sum(l,r,2*x+2,m,rx));
    }
    ull sum(int l,int r){
        return sum(l,r,0,0,size);
    }
    void print(){
        for(int i=0; i<tree.size(); i++)
            cout << to_string(tree[i]) << " ";
        cout << "\n";
    }
};


ll gcd(ll a,ll b){ return (a%b==0? b: gcd(b,a%b)) ;}
ld log (ld a,ld b){return log(b)/log(a);}
ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}

ll power(ll base, ll exp,ll M=LLONG_MAX){//(base^exp)%M
    ll res=1;
    while(exp){
        if(exp%2==1)res=((res%M)*(base%M))%M;
        base=((base%M)*(base%M))%M;
        exp/=2;
    }
    return res;
}

void solve();
int main(){
    FAST;
    int t=1;
    //  cin >> t;

    while(t--)
        solve();
    return 0;
}

void solve(){
    int n;
    cin >> n;
    if(30<=n)out("Yes")
    else out("No")
}

Measured memory_bytes: 3624
#include<stdio.h>

main()
{
  int count,i,line1[100000],line2[50000],num1,num2;
  int left,right,mid;
  scanf("%d",&num1);

  for(i=0;i<num1;i++)
    {
      scanf("%d",&line1[i]);
    }

  scanf("%d",&num2);

  for(i=0;i<num2;i++)
    {
      scanf("%d",&line2[i]);
    }
  
  count = 0; 
  for(i=0;i<num2;i++)
    {
      
      left = 0;
      right = num1;

      while(left<right)
	{

	  mid = (left + right)/2;
	  if(line2[i] == line1[mid]){
	    count++;
	    
	    break;
	  }
	  else if(line2[i]>line1[mid])left = mid + 1;
	  else if(line2[i]<line1[mid])right = mid;
	  
	}
    }
  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
constexpr int MAX = 100100;
constexpr int MOD = 1e9+7;
template<int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod-p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = (int)(1LL*x*p.x%mod); return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) { t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }
        return ModInt(u);
    }
    ModInt pow(int e){
        long long a = 1, p = x;
        while(e > 0) {
            if(e%2 == 0) {p = (p*p) % mod; e /= 2;}
            else {a = (a*p) % mod; e--;}
        }
        return ModInt(a);
    }
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

struct Combination {
    vector<ModInt<MOD>> fact;
    Combination(int n) : fact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; i++) {
            fact[i] = (fact[i-1] * i);
        }
    }
    ModInt<MOD> operator() (int n, int r) {
        if (r < 0 || r > n) return 0;
        return fact[n]/(fact[n-r]*fact[r]);
    }
};

int main() {
    using mint = ModInt<MOD>;
    Combination com(MAX);
    int n, m;
    cin >> n >> m;
    vector<long long> lx(n), ly(m);
    for (auto& e : lx) cin >> e;
    for (auto& e : ly) cin >> e;
    
    vector<long long> x, y;
    for (int i = 0; i+1 < n; i++) x.push_back(abs(lx[i] - lx[i+1]));
    for (int i = 0; i+1 < m; i++) y.push_back(abs(ly[i] - ly[i+1]));
    
    mint sx = 0, ans = 0;
    for (long long i = 0; i < n-1; i++) {
        mint res = ((i+1) * (n-(i+1)));
        sx += (res * x[i]);
    }
    
    for (long long i = 0; i < m-1; i++) {
        mint res = ((i+1) * (m-(i+1)));
        res *= y[i];
        ans += (res * sx);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int M, D; cin >> M >> D;
	int ans = 0;
	rep(i, 1, M + 1) {
		rep(j, 1, D + 1) {
			int d1 = j / 10, d2 = j % 10;
			if (d1 >= 2 && d2 >= 2 && d1 * d2 == i)++ans;
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

//?????????????????¨??????
//left-child right-sibling representation
struct node{
    int parent;
    int left;
    int right;
};

node T[MAX];
int depth[MAX];
int n;

void print(int u){
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].parent<<", ";
    cout<<"depth = "<<depth[u]<<", ";

    if(T[u].parent == NIL)
        cout<<"root, ";
    else if(T[u].left == NIL)
        cout<<"leaf, ";
    else
        cout<<"internal node, ";

    cout<<"[";

    for(int i=0,c=T[u].left;c!=NIL;i++,c=T[c].right){
        if(i)
            cout<<", ";
        cout<<c;
    }
    cout<<"]"<<endl;
}

// ????????°?±???±???
void rec(int u,int p){
    depth[u]=p;
    //?????§???????????????????????±???
    if(T[u].right!=NIL)
        rec(T[u].right,p);
    //????????§??????????????±?????????????????±?????±???+1
    if(T[u].left!=NIL)
        rec(T[u].left,p+1);
}

int main(){
    int degree;
    int nodeID;
    int childNode;
    int lastChildNode;
    int root;
    cin>>n;
    for(int i=0;i<n;i++)
        T[i].parent=T[i].left=T[i].right=NIL;
    for(int i=0;i<n;i++){
        cin>>nodeID>>degree;
        for(int j=0;j<degree;j++){
            cin>>childNode;
            if(j==0)
                T[nodeID].left=childNode;
            else
                T[lastChildNode].right=childNode;
            lastChildNode=childNode;
            T[childNode].parent=nodeID;
        }
    }
    //?????°?????????
    for(int i=0;i<n;i++)
        if(T[i].parent==NIL)
            root=i;
    //????????±???
    rec(root,0);
    //print
    for(int i=0;i<n;i++)
        print(i);
}

Measured memory_bytes: 7784
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){
    
    int n; cin >> n;
    int d;
    if(n % 2 == 0) d = n + 1;
    else d = n;
    vector<vector<int> > G(n + 1);
    int m = 0;
    for(int i = 1; i <= n; i++){
        if(i == d){
            for(int j = i + 1; j < n; j++){
                G[i].push_back(j);
                m++;
            }
        }else{
            int dame = d - i;
            for(int j = i + 1; j <= n; j++){
                if(j == dame) continue;
                G[i].push_back(j);
                m++;
            }
        }
    }

    cout << m << endl;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < (int)G[i].size(); j++){
            cout << i << " " << G[i][j] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
    var n int
    a := make([]float64, 10004)
    for {
        fmt.Scan(&n)
        if n == 0 { break }

        ave_num := 0.0
        for i := 0; i < n; i++ {
            fmt.Scan(&a[i])
            ave_num += a[i]
        }
        ave_num /= float64(n)
        cnt := 0
        for i := 0; i < n; i++ {
            if a[i] <= ave_num {
                cnt++
            }
        }
        fmt.Println(cnt)
    }
}



Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
const int INF = 1e9;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

vector<int> to[200005];
vector<int> ans;
void dfs(int v,int p=-1){
    for(int u:to[v]){
        if(u==p)
            continue;
        ans[u] += ans[v];
        dfs(u, v);
    }
}

int main()
{
    int n, q;
    cin >> n>> q;
    int a,b;
    rep(i, n-1)
    {
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    int p,x;
    ans.resize(n);
    rep(i, q)
    {
        cin >> p >> x;
        --p;
        ans[p] += x;
    }
    dfs(0);
    rep(i, n){
        cout<< ans[i] << endl;
    }
    return 0;
}

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

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; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

ll path[55][55];
graph g;
ll edge[55][55];

void dfs(int s,int from,int to){
  if(from!=-1) path[s][to] = path[s][from] + (1LL<<edge[from][to]);
  for(auto x:g[to]){
    if(path[s][x]!=-1) continue;
    dfs(s,to,x);
  }
}

int main() {
  ll N;
  cin>>N;
  g.resize(N);
  rep(i,55){
    rep(j,55) path[i][j] = edge[i][j] = -1;
  }
  rep(i,N-1){
    ll a,b;
    cin>>a>>b;
    a--;
    b--;
    edge[a][b] = edge[b][a] = i;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  rep(i,N){
    path[i][i] = 0;
  }
  rep(i,N){
    dfs(i,-1,i);
  }
  ll M;
  cin>>M;
  vector<P> q(M);
  rep(i,M){
    cin>>q[i].first>>q[i].second;
    q[i].first--;
    q[i].second--;
  }
  ll ans = 0;
  for(ll i = 0; i<(1LL<<M); i++){
    ll t = 0LL;
    rep(j,M) {
      if(i&(1LL<<j)) t|=path[q[j].first][q[j].second];
    }
    ll cnt = __builtin_popcountll(t);
    if(__builtin_popcountll(i)%2==0){
      ans += 1LL<<(N-1-cnt);
    }
    else ans -= 1LL<<(N-1-cnt);
  }
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int main() {
	LL n, m;
	cin >> n >> m;
	cout << abs(n * m - (2 * n + 2 * m - 4)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m,k;
P farm[15];

int func(int v,int rest,int used){
	if(v==n || used==k)return rest;
	int res=max(rest,func(v+1,rest,used));
	int add=min(farm[v].second,rest)*farm[v].first;
	return max(res,func(v+1,rest-min(farm[v].second,rest),used+1)+add);
}

int main(void){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++){
		scanf("%d",&farm[i].first);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&farm[i].second);
	}
	sort(farm,farm+n,greater<P>());
	printf("%d\n",func(0,m,0));
	return 0;
}

Measured memory_bytes: 1192
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long int;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> temp(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
        temp[i] = p[i];
    }
    sort(temp.begin(), temp.end());
    int count = 0;
    for(int i = 0; i < n; i++)
    {
        if(p[i] != temp[i]) count++;
    }
    if(count <= 2)
    {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
  int n,q;
  int S[10000], T[500];
  int cnt=0;
  int i,j;
  int si;
  scanf("%d", &n );
  
  for (i=0 ; i<n; i++ ) {
    scanf("%d", &S[i] );
    
  }
  
  scanf("%d", &q );
  for (i=0 ; i<q; i++ ) {
    scanf("%d", &T[i] );
  }
 
  si=0;
  for(i=0; i<q; i++){
    for(j=si; j<n ; j++){
      
      if(S[j]==T[i]){
        cnt++;
        break;
      }
    }
  }
  printf("%d\n", cnt );
  return 0;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x;cin>>x;
  cout<<(ll)(x/500)*1000+(x%500)/5*5<<endl;
  return 0;
}


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

int main() {
  int a,b;
  int value=0;
  cin >> a;
  map<string,int> mp;
  for(int i=0;i<a;i++){
    string t;  cin >>t;
    mp[t]++;
  }
  cin >>b;
  for(int i=0;i<b;i++){
    string t; cin >>t;
    mp[t]--;
  }
  for(auto t:mp){
    value =max(value,t.second);
  }
  cout <<value <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);//高速化、endlは使わない

  long a, b, x;

  cin >> a >> b >> x;

  if (a > 0)  cout << b/x - (a-1)/x << "\n";
  else cout << b/x+1 << "\n";
}


Measured memory_bytes: 256
import heapq

r = []
l = []
lsum = 0
rsum = 0
y = 0
cnt = 0
Q = int(input())
for _ in range(Q):
    row = input()
    if row == '2':
        x = -heapq.heappop(l)
        print(x, y + rsum - lsum + (cnt%2)*x)
        heapq.heappush(l,-x)
    else:
        row = list(map(int, row.split()))
        a = row[1]
        y += row[2]
        if cnt % 2 == 0:
            heapq.heappush(r,a)
            rsum += a
            _a = heapq.heappop(r)
            rsum -= _a
            heapq.heappush(l,-_a)
            lsum += _a
        else:
            heapq.heappush(l,-a)
            lsum += a
            _a = -heapq.heappop(l)
            lsum -= _a
            heapq.heappush(r,_a)
            rsum += _a
        cnt += 1


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

int main()
{
	queue<string> namee;
	queue<int> timee;
	int n,q,sum=0;
	string a;
	int b;
	
	cin>>n>>q;
	for(int i=0;i<n;i++){
		cin>>a;
		scanf("%d",&b);
	//	cout<<"@"<<a<<" "<<b<<endl; 
		namee.push(a);
		timee.push(b);
	} 
	
	while(!namee.empty()){
		int c=timee.front();
		string d=namee.front();
		if(c<=q){
			//cout<<"@"<<endl;
			sum+=c;
			cout<<d<<" "<<sum<<endl;
			namee.pop();
			timee.pop();
			//cout<<sum<<endl;
		}else{
			//cout<<"#"<<endl;
			namee.pop();
			namee.push(d);
			sum+=q;
			//cout<<sum<<endl;
			c=c-q;
			timee.pop();
			timee.push(c);
		}
	}
	
	return 0;
}


Measured memory_bytes: 5812
#include <bits/stdc++.h>
using namespace std;
class UnionFind {
	vector<int> data;
	int root(int a) {
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}
public:
	UnionFind(int n) : data(n, -1) {}
	bool Find(int a, int b) {
		return root(a) == root(b);
	}
	void Union(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) return;
		if (data[a] < data[b]) {
			data[a] += data[b];
			data[b] = a;
		}
		else {
			data[b] += data[a];
			data[a] = b;
		}
	}
	int Size(int a) {
		return -data[root(a)];
	}
};


int main()
{
	int n;
	string word;
	while (cin >> n, n) {
		int cnt = 0;
		vector<int> s(26), e(26), used(26);
		UnionFind uf(26);
		while (n--) {
			cin >> word;
			int f = word.front() - 'a', b = word.back() - 'a';
			s[f]++;
			e[b]++;
			uf.Union(f, b);
			if (!used[f]) {
				cnt++;
				used[f] = 1;
			}
			if (!used[b]) {
				cnt++;
				used[b] = 1;
			}
		}
		bool res = true;
		for (int i = 0; i < 26; i++) {
			if (s[i] != e[i]) {
				res = false;
				break;
			}
		}
		cout << (res && uf.Size(word.front() - 'a') == cnt ? "OK" : "NG") << endl;
	}
	return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};



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

  int n;
  cin >> n;
  if(65 <= n && n <= 90) puts("1");
  else if(97 <= n && n <= 122) puts("2");
  else puts("0");
  return 0;
}



Measured memory_bytes: 3124
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
int ans;
int n;
int s;
void dfs(int now,int now2,int sum){
  if(sum==s and now==n) ans++;
  if(now==n or now2==10 or sum>s) return ;
  dfs(now,now2+1,sum);
  dfs(now+1,now2+1,sum+now2); 
}
int main(){
  for(;;){
    ans=0;
    cin>>n;
    cin>>s;
    if(n==0 and s==0)
      break;
    dfs(0,0,0);
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s == "abc") yn;
  return 0;
}

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

using namespace std;

int main() {
	
	string a;
	getline(cin,a);
	
	for(int i = 0; i < a.size(); ++i){
		if(a[i] >= 'a' && a[i] <= 'z')a[i] = toupper(a[i]);
		else if(a[i] >= 'A' && a[i] <= 'Z')a[i] = tolower(a[i]);
	}
	
	cout<<a<<'\n';
	
}


Measured memory_bytes: 3132
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn = 100000;
queue<int> q, sf;
vector<vector<int>> vr(maxn);
bool used[maxn];
int n;
int pre[maxn];

void road(int s = 0) {
	fill(used, used + n, false);
	used[0] = true;
	pre[0] = -1;
	q.push(s);
	bool key = false;
	//点を詰めて、そこからのばす
	while (!key) {          //点n-1を含むまで続ける
		int v = q.front(); q.pop();
		for (int i = 0; i < vr[v].size(); i++) {
			if (!used[vr[v][i]]) {   //行先の頂点は未使用
				used[vr[v][i]] = true;
				q.push(vr[v][i]);  //点vからのびる点を詰める
				pre[vr[v][i]] = v;  //詰められた点は点vから伸びている
				if (vr[v][i] == n - 1) {  //のびた点がn-1の時に終わり
					key = true;
					break;
				}
			}
		}
	}

	return;
}

int main() {

	cin >> n;

	rep(i, n - 1) {
		int a, b; cin >> a >> b;
		a--; b--;
		vr[a].push_back(b);  //頂点aは頂点bへの道をもつ、その逆も
		vr[b].push_back(a);
	}

	//頂点0から頂点n-1への頂点の個数を数える(頂点0,n-1も含める)
		//0からn-1への道順
	road();
	//0からn-1にc個の点があるかを調べる
	int c = 0, s = n - 1;
	while (pre[s] != -1) {
		c++;
		s = pre[s];
	}
	c++;

	//Snukeは0からn-1のうち最後からc(下で更新)個の点を塗る

	if (c % 2 == 0) {
		c = c / 2;
	}
	else {
		c = (c - 1) / 2;
	}

	//後ろからc個をsfにつめる
	s = n - 1;
	int att;
	fill(used, used + n, false);
	used[n - 1] = true;
	for (int i = 0; i < c; i++) {
		sf.push(s);
		used[s] = true;
		s = pre[s];
		if (i == c - 1)att = s;
	}
	//後ろから詰めた点から派生する点はSnukeが塗る 得点sp
	//点attはフェネックが塗るから含んではいけない
	used[att] = true;
	int sp = 0;
	while (sf.size()) {
		int v = sf.front(); sf.pop(); sp++;
		for (int i = 0; i < vr[v].size(); i++) {
			if (!used[vr[v][i]]) {
				used[vr[v][i]] = true;
				sf.push(vr[v][i]);
			}
		}
	}

	if (sp < n - sp) {
		cout << "Fennec" << endl;
	}
	else {
		cout << "Snuke" << endl;
	}


	return 0;
}


Measured memory_bytes: 6400
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val p = readLine()!!.replace(" ", "").toInt()
    val q = readLine()!!.replace(" ", "").toInt()

    var pPos = 0
    var qPos = 0

    val a = IntArray(N)
    var cnt = 0
    fun create(n:Int, ary: List<Int>) {
        ary.forEach {
            a[n] = it
            if (n+1 == N) {
                val i = a.joinToString ("" ).toInt()
                cnt++
                if (i == p) pPos = cnt
                if (i == q) qPos = cnt
            } else {
                create(n + 1, ary.minus(it))
            }
        }
    }

    val all = mutableListOf<Int>()
    repeat(N) {
        all.add(it+1)
    }
    create(0, all)

    println(Math.abs(pPos - qPos))
}


Measured memory_bytes: 44716
#include <iostream>
#include <stack>

int main(){
	std::stack<int> railroad;
	
	int incar; 
	while(std::cin >> incar){
		if(incar != 0){
			// in
			railroad.push(incar);
		}else{
			// out
			std::cout << railroad.top() << std::endl;
			railroad.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[]a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		int cnt = 0;
		int[]b = new int[N + 1];
		for(int i = 0; i < N; i++) {
			if(a[i] > N) {
				cnt++;
			}else {
				b[a[i]]++;
			}
		}
		for(int i = 1; i <= N; i++) {
			if(b[i] >= i) {
				cnt += b[i] - i;
			}else {
				cnt += b[i];
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 51424
#include <bits/stdc++.h>
using namespace std;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long n,t;
  cin >> n >> t;
  vector<long> a(n);
  rep(i,n) cin >> a.at(i);
  vector<long> maxi(n);
  maxi.at(n-1) = a.at(n-1);
  for(int i=n-2;i>=0;i--){
    maxi.at(i) = max(maxi.at(i+1),a.at(i));
  }
  long dmax = 0;
  long cnt = 0;
  rep(i,n-1){
    long d = maxi.at(i+1)-a.at(i);
    if(d > dmax){
      dmax = d;
      cnt = 1;
    }else if(d == dmax) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 1920
#include<stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n,i,j,a;
  
  scanf("%d",&n);
  
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  
  for(i=1;i<=n;i++)scanf("%d",&A[i]);

  for(i=0;i<=VMAX;i++)C[i]=0;
  for(j=1;j<=n;j++)C[A[j]]++;
  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n;i++)printf("%d ",B[i]);
  printf("%d",B[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 9652