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

class Program
{
    static void Main()
    {
        while (true)
        {
            short[] l = Console.ReadLine().Split(' ').Select(short.Parse).ToArray();
            int c = 0, n = l[0], x = l[1];

            if (l[0] + l[1] == 0) break;

            for (int i = 1; i <= n; i++)
                for (int j = i + 1; j <= n; j++)
                    for (int k = j + 1; k <= n; k++)
                        if (i + j + k == x)
                            c++;

            Console.WriteLine(c);
        }
    }
}

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

int main() {
  vector<int> num(3);
  for(int i=0;i<3;i++){
    cin >> num.at(i);
  }
  int k;
  cin >> k;
  
  sort(num.begin(),num.end());
  int sum = num.at(0) + num.at(1);
  for(int i=0;i<k;i++){
    num.back() *= 2;
  }
  
  cout << sum + num.back() << endl;
  
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a, b; cin>>x>>a>>b;
    if(abs(x-a) <= abs(x-b)){
        cout<<"A"<<endl;
    }else{
        cout<<"B"<<endl;
    }
}


Measured memory_bytes: 256
import re
 
def main():
    S = input()
    N = len(S) + 1
 
    ans = 0
    s_list = re.split("><", S)
    nelem = len(s_list)
    for i in range(nelem):
        elem = s_list[i]
        ln = elem.count(">") + 1
        rn = elem.count("<") + 1
        if i == 0:
            rn -= 1
        if i == nelem - 1:
            ln -= 1
        nmax = max([ln, rn])
        nmin = min([ln, rn])
        ans += (0 + nmax) * (nmax + 1) / 2
        ans += (0 + nmin - 1) * (nmin) / 2
    print(int(ans))
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 8988
n = int(input())
a = list(map(int,input().split()))
a = sorted(a, reverse = True)

ai = a[0] / 2
aj = 0
comb = 10 ** 10
for i in range(n):
    temp = abs(a[i] - ai)
    if comb >= temp:
        comb = temp
        aj = a[i]
print(a[0], aj)

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

int main()
{
    int N, M, X, Y;
    vector<int> x, y;
    cin >>
        N >> M >> X >> Y;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
    }
    x.push_back(X);

    for (int i = 0; i < M; i++)
    {
        int tmp;
        cin >> tmp;
        y.push_back(tmp);
    }
    y.push_back(Y);

    if (*max_element(x.begin(), x.end()) < *min_element(y.begin(), y.end()))
    {
        cout << "No War";
    }
    else
    {
        cout << "War";
    };
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


// ABC070B - Two Switches
int main(){
  int A, B, C, D; // 0 <= N <= 100
  cin >> A >> B >> C>> D;

  int cnt = 0;
  for (int i = 0; i <= 100; ++i) {
    if (i >= A && i < B && i >= C && i < D) {
      ++cnt;
    }
  }

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



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    int D, T, S;
    cin >> D >> T >> S;
    if (S * T >= D)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

signed main()
{

    solve();

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll A[200010];
map<ll,ll> cnt;
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>A[i];
        cnt[A[i]]++;
    }
    ll ans=0;
    for(auto p:cnt){
        ans+=p.second*(p.second-1)/2;
    }
    for(ll i=0;i<N;i++){
        cout<<ans-(cnt[A[i]]-1)<<endl;
    }

    return 0;
}

Measured memory_bytes: 13108
// ARC091
// D - Remainder Reminder

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

int N, K;

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

    ll ans = 0;
    for (int b = K + 1; b <= N; b++) {
        ans += 1LL * N / b * (b - K);
        ans += max(0LL, N - (1LL * N / b * b + K - 1));
    }
    if (K == 0) {
        ans -= N;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void outputArray(int* arr, int& s){
	int i;
	for(i=0;i<s;i++){
		cout << arr[i];
		if(i!=s-1){cout << ' ';}
		else      {cout << endl;}
	}
}

int main(){
	int n, i, j, min_value, min_pos, value_holder, count_swipes = 0;
	cin >> n;
	int a[n];
	for(i=0;i<n;i++){cin >> a[i];}

	//selection sort
	for(i=0;i<n-1;i++){
		min_value = a[i];
		min_pos = i;

		for(j=i;j<n;j++){
			if(min_value>a[j]){
				min_value = a[j];
				min_pos = j;
			}
		}

		if(min_pos!=i){
			value_holder = a[i];
			a[i] = a[min_pos];
			a[min_pos] = value_holder;
			count_swipes++;
		}

	}
	outputArray(a, n);
	cout << count_swipes << endl;

}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

int V,E;
int w[112345];
int s[112345],t[112345];

int uni[1000010];
void init(int V){
  for(int i=0;i<V;i++){
    uni[i]=-1;
  }
}
int root(int a){
  if(uni[a] < 0)return a;
  else return uni[a] = root(uni[a]);
}
bool unite(int a,int b){
  a = root(a);
  b = root(b);
  if(a==b) return false;
  if(uni[a] > uni[b]) swap(a,b);
  uni[a]+=uni[b];
  uni[b]=a;
}

bool same(int a,int b){
  return root(a)==root(b);
}

const int MAX_E = 1123456; //辺の最大数
struct edge{
  int u, v, cost;
  edge(int u,int v,int cost){
    this->u=u;
    this->v=v;
    this->cost = cost;
  }
};
vector<edge> es;
//----------クラスカル法------------
bool comp(const edge& e1, const edge& e2) {
  return e1.cost < e2.cost;
}
int kruskal() {
  sort(es.begin(), es.end(), comp); // edge.costの小さい順 Eは変数
  init(V); // Union-Findの初期化 Vは頂点数
  int res = 0;
  for (int i = 0; i < es.size(); i++) {
    edge e = es[i];
    if (!same(e.u, e.v)) {
      unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}



pair<int,int> x[112345],y[112345];
int main(){
  int N;
  cin>>N;
  V=3*N;
  rep(i,N){
    cin>>x[i].first>>y[i].first;
    x[i].second=i;
    y[i].second=i+N;
  }
  dump('a');


  rep(i,N){
    es.push_back(edge{x[i].second,y[i].second,0});
  }
  dump('b');

  sort(x,x+N);
  sort(y,y+N);
  dump('a');
  rep(i,N-1){
    es.push_back(edge{x[i+1].second,x[i].second,x[i+1].first-x[i].first});
  }

  rep(i,N-1){
    es.push_back(edge{y[i+1].second,y[i].second,y[i+1].first-y[i].first});
  }
  dump('c');


  int ans=kruskal();
  cout<<ans<<endl;
}


Measured memory_bytes: 10096
from sys import stdin
N,k1,k2=[int(x) for x in stdin.readline().rstrip().split()]
a = []
for i in range(N):
    a.append([int(x) for x in stdin.readline().rstrip().split()])
cnt=0
for i in a:
    tmp1=i[0]-k1
    tmp2=i[1]-k2
    if tmp1>=0 and tmp2>=0:
        cnt+=1
print(cnt)

Measured memory_bytes: 3188
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    var result = 1
    var c = s[0]

    for (i in 0 until n) {
        if (s[i] != c) {
            c = s[i]
            result += 1
        }
    }

    println(result)
}

Measured memory_bytes: 34396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,C,A;
  cin >> N >> M >> C;
  int B[M];
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    int s = 0;
    for(int j=0;j<M;j++){
      cin >> A;
      s = s+A*B[j];
    }
    if(s + C >0) ans++;
  }
  cout << ans << endl;
  return 0 ;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    bool reverse = false;
    int n;
    cin >> n;
    int a[200050];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    if(n == 1){
        cout << a[1] << endl;
        return 0;
    }
    for(int i = n; i >= 1; i -= 2){
        cout << a[i] << " ";
    }
    for(int i = n % 2 + 1; i <= n; i += 2){
        cout << a[i];
        if(i >= (n - 1)){
            cout << endl;
        } else {
            cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
vector<int> primes(100001,1);

void prime()
{
    primes[1]=0;
    int fac=2;
    for (int i=2*fac;i<100001;i+=fac)
    {
        primes[i]=0;
    }
    fac++;
    while (fac<100001)
    {
        if (primes[fac]==1)
        {
            for (int i=2*fac;i<100001;i+=fac)
            {
                primes[i]=0;
            }
        }
        fac+=2;
    }
}

int main()
{
    prime();
    int Q;cin >> Q;
    int l,r;
    vector<int> likenum(100001,0);
    for (int i=3;i<100001;i+=2)
    {
        if (primes[i] && primes[(i+1)/2])
        {
            likenum[i]=1+likenum[i-2];
        }
        else likenum[i]=likenum[i-2];
        //cout << likenum[i] << endl;
    }
    for (int i=0;i<Q;i++)
    {
        cin >> l >> r;
        if (primes[l] && primes[(l+1)/2]) cout << likenum[r]-likenum[l]+1 << endl;
        else cout << likenum[r]-likenum[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
n, m = map(int, input().split())
ps, ss = list(), list()
for i in range(m):
    p, s = input().split()
    p = int(p) - 1
    ps.append(p)
    ss.append(s)


num = [0 for i in range(n)]
correct, penalty = 0, 0

for i in range(m):
    p, s = ps[i], ss[i]
    if num[p] == -1:
        continue

    num[p] += 1
    if s == 'AC':
        correct += 1
        penalty += (num[p] - 1)
        num[p] = -1

print(correct, penalty)        


Measured memory_bytes: 14188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define N 100000
int n = N;
int dp_a[N], dp_b[N], dp_c[N];
vector<int> a(n), b(n), c(n);

// i >= 1
void natsu(int i){
    dp_a[i] = a.at(i) + max(dp_b[i-1],dp_c[i-1]);
    dp_b[i] = b.at(i) + max(dp_a[i-1],dp_c[i-1]);
    dp_c[i] = c.at(i) + max(dp_a[i-1], dp_b[i-1]);
}

int main(){
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }
    for (int i = 0; i < n; i++)
    {
        if (i == 0) {
             dp_a[0] = a.at(0),dp_b[0] = b.at(0);dp_c[0] = c.at(0);
        }
        else natsu(i);
    }
    cout << max(dp_a[n-1], max(dp_b[n-1], dp_c[n-1])) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
 int n;
 cin >> n;
 ll ans=0;
 for(int i=1;i<=n;i++){
  int m=i;
  int cnt=0;
  while(m){
   m/=10;
   cnt++;
  }
  ans+=(cnt&1);
 }
 cout << ans << endl;
 return 0;
}

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

int main() {
  int x; cin >> x;
  int ans = 1;
  int xn = x/100;
  if (xn < 20 && x%100 > xn*5) ans = 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
K = int(input())
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51] 
print(nums[K - 1])


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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    priority_queue<double> que;
    for(int i = 0; i<n; i++){
        double a;
        cin>>a;
        que.push(-a);
    }
    for(int i =1;i<n;i++){
        double x,y;
        x = que.top(); que.pop();
        y = que.top(); que.pop();
        double z = (x+y)/2;
        que.push(z);
    }
    double ans = 0.0;
    while(!que.empty()){
        ans = que.top();
        que.pop();
    }
    ans = -ans;
    cout<< fixed << setprecision(10) << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

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

/*
法 1e9+7(1000000007) の下での2項係数(combination)
*/
var n int64 = 2000 + 1
var mod int64 = 1000000007
var fac = make([]int64, n+1)
var inv = make([]int64, n+1)
var finv = make([]int64, n+1)

func initComb() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	var i int64
	for i = 2; i < n; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func comb(n, k int) int64 {
	if n < k || n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % mod) % mod
}

func main() {
	n := readInt()
	k := readInt()

	initComb()
	for i := 1; i <= k; i++ {
		ans := comb(n-k+1, i) * comb(k-1, i-1)
		fmt.Println(ans % mod)
	}
}


Measured memory_bytes: 640
#[allow(unused_imports)]
use std::io::{self, BufRead};
#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::slice::*;
#[allow(unused_imports)]
use std::string::*;
#[allow(unused_imports)]
use std::mem::swap;

#[allow(dead_code)]
fn readln_to_vec<T>(buf: &mut BufRead) -> Vec<T> 
where T: std::str::FromStr,
      <T as std::str::FromStr>::Err: std::fmt::Debug
{
    let mut s = String::new();
    buf.read_line(&mut s).unwrap();
    s.split(" ")
        .map(|x| x.trim())
        .filter(|x| !x.is_empty())
        .filter_map(|x| x.parse().ok())
        .collect()
}

#[allow(dead_code)]
fn readln_to<T>(buf: &mut BufRead) -> T
where T: std::str::FromStr + std::clone::Clone,
      <T as std::str::FromStr>::Err: std::fmt::Debug
{
    readln_to_vec::<T>(buf)[0].clone()
}

#[allow(unused_macros)]
macro_rules! readln_to_tuple {
    (
        $bufRead: expr, ( $( $t: ty ),* )
    ) => (
        {
            let buf: &mut BufRead = $bufRead;
            let ln = readln_to_vec::<String>(buf);
            let mut i = ln.into_iter();
            ( $( i.next().unwrap().parse::<$t>().unwrap() ),* )
        }
        )
}


fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    let stdin = &mut stdin;

    let (n, x) = readln_to_tuple!(stdin, (usize, usize));
    if x == 1 || x == 2*n-1{
        println!("No");
    } else {
        println!("Yes");
        for i in 0..2*n-1 {
            println!("{}", ((i + 2*n-1 + (x - n))%(2*n-1)) + 1);
        }
    }
}



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

int main() {
    int a,b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+3;
int INIT[maxn];
int main(){
	int n,k,q,a;
	cin>>n>>k>>q;
	for(int i=0;i<q;i++){
		cin>>a;
		INIT[a]++;
	}
	for(int i=1;i<n+1;i++)
	{
		if(k>q-INIT[i]){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std; const int N=500010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,X,res,ans;
int a[N];
signed main()
{
    n=read(), X=read();
    for(ri int i=1;i<=n;i++) a[i]=read(), res+=a[i];
    sort(a+1,a+1+n);
    while(res+a[1]<=X) res+=a[1], ans++;
    printf("%lld\n",ans+n);
    return 0;
}

Measured memory_bytes: 3780
# coding: utf-8

n = int(input())
h = list(map(int, input().split()))

ans = 0

for i in range(n):
    ok = True
    for j in range(0, i):
        if h[j] > h[i]:
            ok = False
            break
    if ok:
        ans += 1

print(ans)


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

double afive[7] = {35.5, 37.5, 40, 43, 50, 55, 70};
double athou[7] = {71, 77, 83, 89, 105, 116, 148};
string grade[8] = {"AAA", "AA", "A", "B", "C", "D", "E", "NA"};

int main() {
    vector<double> five(7), thou(7);
    for (int i = 0; i < 7; ++i) {
        five[i] = afive[i];
        thou[i] = athou[i];
    }
    
    double a, b;
    while (cin >> a >> b) {
        int da = upper_bound(five.begin(), five.end(), a) - five.begin();
        int db = upper_bound(thou.begin(), thou.end(), b) - thou.begin();
        int res = max(da, db);
        cout << grade[res] << endl;
    }
}


Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+9;
int n,a[MAX];
vector<int> g[MAX],h[MAX];
int dfs(int v,int p=-1)
{
	for (auto u:g[v])
		if (u!=p)
			h[v].push_back(dfs(u,v));
	sort(h[v].begin(),h[v].end(),greater<int>());
	int mx=0;
	for (int i=0;i<h[v].size();i++) mx=max(mx,h[v][i]+i+1);
	return mx;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for (int i=1;i<n;i++)
	{
		cin>>a[i],a[i]--;
		g[a[i]].push_back(i);
	}
	cout<<dfs(0)<<endl;
	return 0;
}

Measured memory_bytes: 19456
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    ll prev_a, prev_b;
    cin >> prev_a >> prev_b;
    ll ans = prev_a + prev_b;
    rep(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        ll m = max((prev_a + a - 1) / a, (prev_b + b - 1) / b);
        a *= m, b *= m;

        ans = a + b;
        prev_a = a, prev_b = b;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

int main()
{
    string S;
    cin >> S;

    bool over = false;
    int count[99999] = {0};
    for(int i = 0; i < S.size(); i++)
    {
        if (++count[S[i]] > 1)
        {
            over = true;
        }
    }
    if (over)
    {
        cout << "no" << endl;
    }
    else
    {
        cout << "yes" << endl;
    }
    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n,m,i;
    string s;
    cin>>n>>s>>m;
    for(i=0;i<n;i++){
        if(s[i]==s[m-1])
            cout<<s[i];
        else cout<<"*";
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_X = 100, MAX_Y = 100;
char field[MAX_X+5][MAX_Y+5];

int size_x, size_y;

int dfs(int x, int y, char fruit) {
    // check size_x and size_y
    if(x < 0 || x >= size_x || y < 0 || y >= size_y) return 0;

    // check whether the first visit or not
    if(field[x][y] == '.') return 0;

    // check whether same fruit or not
    if(field[x][y] == fruit) {
        field[x][y] = '.';
        dfs(x+1, y, fruit);
        dfs(x, y+1, fruit);
        dfs(x-1, y, fruit);
        dfs(x, y-1, fruit);
    }

    return 0;
}

int solve(int size_x, int size_y) {
    // input
    for(int i = 0; i < size_x; i++) {
        cin >> field[i];
    }

    // Depth-First Search
    int ans = 0;
    for(int i = 0; i < size_x; i++) {
        for(int j = 0; j < size_y; j++) {
            char fruit = field[i][j];
            if(fruit != '.') {
                dfs(i, j, fruit);
                ans++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

int main() {
    while(true) {
        // solve for each data set
        cin >> size_x >> size_y;
        if(size_x == 0 && size_y == 0) break;
        solve(size_x, size_y);
    }
    return 0;
}

Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int n;
    cin>>n;
    ll a[200010];
    ll ma=0;int idx;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(ma<a[i]){
            ma=a[i];
            idx=i;
        }
    }
    ll mi=INF;
    int ans;
    for(int i=0;i<n;i++){
        if(i==idx)continue;
        ll sa=abs((ma/2)-a[i]);
        if(mi>sa){  
            ans=i;
            mi=sa;
        }
    }
    cout<<a[idx]<<" "<<a[ans]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int n,s=0,t=0,x;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];

        t=t+(a[i]*a[i]);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
           s=s+(a[i]*a[j]);
        }
    }
     x=(s-t)/2;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    char ex = '0';
    for(int i = 0; i < n; i++){
        if(ex == s[i]) continue;
        ex = s[i];
        ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;

namespace kyoupuro
{
    class MainClass
    {
        public static void Main()
        {
            MainClass mainClass = new MainClass();
            mainClass.Start();
        }

        public void Start()
        {
            string line = Console.ReadLine();

            switch(line) {
                case "A":
                    Console.WriteLine("T");
                    break;
                case "T":
                    Console.WriteLine("A");
                    break;
                case "C":
                    Console.WriteLine("G");
                    break;
                default:
                    Console.WriteLine("C");
                    break;
            }
        }

        List<List<int>> IntInit()
        {
            int maxindex = int.Parse(Console.ReadLine());

            List<List<int>> array = new List<List<int>>();

            for (int i = 0; i < maxindex; i++)
            {
                array.Add(new List<int>(
                Console.ReadLine().Split(' ').Select(int.Parse)));
            }

            return array;
        }
    }
}




Measured memory_bytes: 11092
### main

loop do
  n, k = gets.strip.split(' ').map{|s| s.to_i}
  break if (n | k) == 0

  as = []
  white = false

  k.times do
    ci = gets.strip.to_i - 1

    if ci < 0
      white = true
    else
      c0 = c1 = ci
      if ci > 0 && ! as[ci - 1].nil?
        c0 = as[ci - 1][0]
      end
      if ci < n - 1 && ! as[ci + 1].nil?
        c1 = as[ci + 1][1]
      end

      as[c0] = as[c1] = [c0, c1]
    end
  end
  #p as

  rs = []
  ci = 0

  while ci < n
    if ! as[ci].nil?
      rs << as[ci]
      ci = as[ci][1]
    end
    ci += 1
  end
  #p rs
  #p white

  prvr = nil
  max_seq = 0

  for r in rs
    c0, c1 = r
    seq = c1 - c0 + 1

    if white
      if c0 > 0 || c1 < n - 1
        seq += 1
        if ! prvr.nil? && prvr[1] == c0 - 2
          seq += prvr[1] - prvr[0] + 1
        end
      end
    end

    max_seq = seq if max_seq < seq

    prvr = r
  end

  puts max_seq
end

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

int main() {
	string s; cin >> s;
	bool dic[26];
	for (int i = 0; i < 26; i++) {
		dic[i] = false;
	}

	for (int i = 0; i < s.length(); i++) {
		dic[s[i] - 'a'] = true;
	}
	
	for (int i = 0; i < 26; i++) {
		if (!dic[i]) {
			cout << char(i + 'a') << endl;
			return 0;
		}
	}

	cout << "None" << endl;

	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int G[110][110] = { 0 };
int color[110] = { 0 };

int DFStack[110];
int sp = 0;

int ans[110][2] = { 0 };

void Push(int p) {
	DFStack[sp] = p;
	sp++;
}

int Pop(void) {
	if (sp == 0)return -1;
	sp--;
	return DFStack[sp];
}


int main() {
	int N;
	int k, v;
	int pos, search_point;
	int cnt = 1;
	int fin = 0;
	scanf("%d", &N);
	for (int u = 1; u <= N; u++) {
		scanf("%d", &k);
		scanf("%d", &k);
		for (int i = 0; i < k; i++) {
			scanf("%d", &v);
			G[u][v] = 1;
		}
	}
	while (1) {
		for (int i = 1; i <= N; i++) {
			if (ans[i][0] == 0) {
				Push(i); break;
			}
			else if (i == N)fin = 1;
		}
		while (sp != 0) {
			pos = Pop();
			if (color[pos] == 0) {
				color[pos] = 1;
				ans[pos][0] = cnt;
				cnt++;
			}
			search_point = 1;
			while ((G[pos][search_point] == 0 || color[search_point] != 0) && search_point <= N)search_point++;
			if (search_point == N + 1) {
				color[pos] = 2;
				ans[pos][1] = cnt;
				cnt++;
			}
			else {
				Push(pos);
				Push(search_point);
			}
		}
		if (fin)break;
	}

	for (int i = 1; i <= N; i++) {
		printf("%d %d %d\n", i, ans[i][0], ans[i][1]);
	}

	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

bool isRunrun(int t) {
	int k = t;
	int before;
	int current = k%10;
	if(k < 10) return true;
		while(k >= 10) {
			before = current;
			k /= 10;
			current = k%10;
			if(abs(current-before) > 1) return false;
		}
		return true;
}
int main() {
	int k;
	cin >> k;
	queue<ll> q;
	for(int i=1; i<=9; i++) q.push(i);
	ll count=0;
	ll t;
	while(count < k) {
		t=q.front();
		q.pop();
		count++;
		if(t % 10 == 0) {
			q.push(t*10);
			q.push(t*10+1);
		}
		else if(t % 10 == 9) {
			q.push(t*10+8);
			q.push(t*10+9);
		}
		else {
			q.push(t*10 + (t%10-1));
			q.push(t*10+t%10);
			q.push(t*10+t%10+1);
		}
	}
	cout << t << endl;

  return 0;
}


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

//long long
using ll = long long;

// pair<int, int>
using PII = pair<int, int>;

//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;

//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

// a = max(a, b), a = min(a, b)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

int main(){
    int N;
    cin >> N;
    int R;
    cin >> R;
    int ans;
    if(10 <= N) ans = R;
    else ans = R + (100 * (10 - N));
    print(ans); 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,pa[maxn],sz[maxn];
vector<pair<int,int>> b;
pair<long long,int> a[maxn];
vector<int> g[maxn];
vector<long long> ch;
long long sum;
void dfs(int nod,int dep){
    sum+=dep;
    for(int i:g[nod]){
        dfs(i,dep+1);
    }
    return;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i].first);
        a[i].second=i;
    }
    for(int i=1;i<=n;i++){
    sz[i]=1;
    }
    sort(a+1,a+1+n);
    for(int i=n;i>1;i--){
        long long tar=a[i].first+2*sz[a[i].second]-n;
        int l=1,r=i-1,mid,ans;
        while(l<=r){
            mid=(l+r)>>1;
            if(a[mid].first<=tar){
                ans=mid;
                l=mid+1;
            }
            else{
                r=mid-1;
            }
        }
        if(a[ans].first!=tar){
            return !printf("-1");
        }
        pa[a[i].second]=a[ans].second;
        b.push_back(make_pair(a[ans].second,a[i].second));
        sz[a[ans].second]+=(sz[a[i].second]);
        g[a[ans].second].push_back(a[i].second);
    }
    dfs(a[1].second,0);
    if(sum!=a[1].first)return !printf("-1");
    assert((int)b.size()==n-1);
    for(auto i:b){
        printf("%d %d\n",i.first,i.second);
    }
}


Measured memory_bytes: 11508
#include "bits/stdc++.h"
using namespace std;

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

    if (a < b) {
        if (a + W < b) {
            cout << b - (a + W) << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
    else {
        if (b + W < a) {
            cout << a - (b + W) << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

int main()
{
	long n;
	cin >> n;
	long a[n];
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	long min = 1000000,max = -1000000;
	long sum = 0;
	
	for(int i = 0;i < n;i++){
		if(min > a[i]) min = a[i];
		if(max < a[i]) max = a[i];
		sum += a[i];
	}
	
	cout << min << " " << max << " " << sum << endl;
	return 0;
}

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

int main(){
  int X,K,i;
  cin >> K >> X ;

  i=X-(K-1) ;

  if(i<-10000){
    i = -10000 ;
  }

  while(i<=X+(K-1)){
    cout << i << " " ;
    i++ ;
    if(i>10000) break;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
#define _cos(xxxx) cos(xxxx*acos(-1)/180)
#define _sin(xxxx) sin(xxxx*acos(-1)/180)
#define _tan(xxxx) tan(xxxx*acos(-1)/180)
#define PE cout<<fixed
 
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
 
const ld pi=acos(-1);

ll n,i,a[500009],res;

int main() {
    IO;
    cin>>n;
    for (i=1;i<=n;i++) {
        cin>>a[i];
    }
    for (i=1;i<=n;i++) {
        res+=max(i-i,a[i-1]-a[i]);
        a[i]=max(a[i],a[i-1]);
    }
    cout<<res<<'\n';
}
    

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

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

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;


void solve(){
    int n;
    cin >> n;
    vc a(n);
    fr(0,n) cin >> a[i];
    int r = 0;
    rep(i,0,n) {

        if(a[i]=='R') r++;
        else continue;
    }
    int ans = 0;
    fr(0,r){

        if(a[i]=='W') ans++;

    }
    cout << ans;
    line
    return;
}
int main(){
	fast
	int t=1;
	//cin >> t;
	while(t--){
             solve();
    }

	R 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
ll n, w;
ll wt[200015];
ll val[200015];
ll dp[105][200015];
ll knap(ll w, ll it)
{
	if (w == 0 or it < 0)
		return 0;
	if (dp[it][w] != -1)
		return dp[it][w];
	if (wt[it] > w)
		return dp[it][w] = knap(w, it - 1);
	else
		return dp[it][w] = max(val[it] + knap(w - wt[it], it - 1), knap(w, it - 1));
}
void solve()
{
	cin >> n >> w;
	fo(i, n)cin >> wt[i] >> val[i];
	//fo(i, n)cin >> wt[i];
	memset(dp, -1, sizeof(dp));
	knap(w, n - 1);
	cout << dp[n - 1][w] << "\n";


}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using st = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll = V<pll>;
using vst = V<st>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define sub(a,b) substr(a,b)


int main(){
  ll n,x;
  cin>>n>>x;
  vll v(n);
  vll ans(n);
  FOR(i,0,n){
    cin>>v[i];
    v[i]=max(v[i]-x,-v[i]+x);
    if(i==0){
      ans[0]=v[0];
    }
    else{
      ans[i]=gcd(ans[i-1],v[i]);
    }
  }
  co(ans[n-1]);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int d;
  vector<int> num(N);
  for(int i=0; i<N; i++){
    cin >> d;
    num.at(i)=d;
  }
  //降順
  int temp;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      if(num.at(i)<=num.at(j)){
        temp=num.at(i);
        num.at(i)=num.at(j);
        num.at(j)=temp;
      }
    }
  }
  //出力
  int count=1;
  for(int i=0; i<N-1; i++){
    if(num.at(i)==num.at(i+1)){
      continue;
    }
    count++;
  }
  cout << count << endl;
}

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

using namespace std;

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

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

	int n;
	cin >> n;

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

		rep(j, a){
			int x, y;
			cin >> x >> y;
			x--;
			info[i].push_back((pii){x, y});
		}
	}

	int ans = 0;
	// ビットが1⇒正直者
	for(int i = 0; i < (1 << n); i++){
		int t = __builtin_popcount(i);
		bool ok = true;

		// 発言チェック
		// cout << "bit " << i << endl;
		for(int j = 0; j < n; j++){
			// 不親切な人の発言は気にしない
			if((i >> j) % 2 == 0) continue;

			// 親切な人の発言内容チェック
			// cout << "check " << j << endl;
			vector<pii> v = info[j];
			int m = v.size();
			for(int k = 0; k < m; k++){
				int x = v[k].first;
				int y = v[k].second;

				// 親切な人の発言と実態が異なればアウト
				// cout << "check " << x << " of " << j << " is ";
				int act = (i >> x) & 1;
				int said = y;

				// cout << act << " " << said << endl;
				if(act != said){
					ok = false;
					break;
				}
			}
			if(!ok) break;
		}
		if(ok){
			// cout << "ans may change to " << t << endl;
			ans = max(ans, t);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n;
	cin >> n;
	vector<ll> v(n);
	map<ll, ll> mp;
	for (auto &i : v)
		{
			cin >> i;
			mp[i]++;
		}
	ll sum = 0;
	for (auto i : mp)
		{
			sum += ((i.second * (i.second - 1)) / 2);
		}
	for (auto i : v)
		{
			if (mp[i] > 1)
				cout << sum - (mp[i] - 1) << endl;
			else cout << sum << endl;
		}
}

Measured memory_bytes: 11136
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    
    scanf("%d%d", &a, &b);
    
    rep(i, fmax(a, b)){
        printf("%d", (int)fmin(a, b));
    }
    
    return 0;
}



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

int main(){

  string s[10000];
  int n,x,y,k,ans;

  while(cin >> n, n){

    for(int i=0;i<n;i++) cin >> s[i];
    k = 0;

    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	ans = 0;
	for(x=i,y=j;y<n;y++){
	  if(s[x][y] != '1') break;
	  ans++;
	  k = max(k,ans);
	}

	ans = 0;
	for(x=i,y=j;x>=0;x--){
	  if(s[x][y] != '1') break;
	  ans++;
	  k = max(k,ans);
	}

	x = i;
	y = j;
       	ans = 0;
	while(x >= 0 && y < n){
	  if(s[x][y] != '1') break;
	  ans++;
	  x--;
	  y++;
	  k = max(k,ans);
	}

	x = i;
	y = j;
	ans = 0;
	while(x >= 0 && y >= 0){
	  if(s[x][y] != '1') break;
	  ans++;
	  x--;
	  y--;
	  k = max(k,ans);
	}

      }
    }

    cout << k << endl;
  }
}

Measured memory_bytes: 1368
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <vector>
using namespace std;

struct pond {
    int startPos;
    int volume;
};

int main() {
    string st;
    getline(cin, st);
    
    stack<pond> pds;
    stack<int> s;
    
    for(int i = 0; i < st.length(); i++){
        if(st[i] == '\\'){
            s.push(i);
        }else if(st[i] == '/' && s.size()){
            pond pd;
            pd.startPos = s.top(); s.pop();
            pd.volume = i - pd.startPos;
            while(pds.size() && pds.top().startPos > pd.startPos){
                pd.volume += pds.top().volume;
                pds.pop();
            }
            pds.push(pd);
        }
    }
    int tot = 0;
    vector<int> pVs;
    while(pds.size()){
        tot += pds.top().volume;
        pVs.push_back(pds.top().volume);
        pds.pop();
    }
    pVs.push_back((int)pVs.size());
    reverse(pVs.begin(), pVs.end());
    cout << tot << endl;
    for(int i = 0; i < pVs.size(); i++){
        cout << pVs[i] << (i+1 == pVs.size() ? '\n' : ' ');
    }
    return 0;
}

Measured memory_bytes: 1308
import java.util.Arrays;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int q = sc.nextInt();

    int[] ps = new int[n];
    Arrays.fill(ps, k);

    for (int i = 0; i < q; i++) {
      int p = sc.nextInt();
      ps[p - 1]++;
    }

    for (int p : ps) {
      if (p - q > 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,a[5],b[5]={0},m=infll,i;
	cin>>n;
	for (i=0;i<5;i++){
		cin>>a[i];
		m=min(a[i],m);
	}
	if (n%m==0){
		cout<<5+n/m-1;
	}
	else {
		cout<<5+n/m;
	}
	return 0;
}

Measured memory_bytes: 256