akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
using namespace std;

int main(void){
  int x,y;
  cin >> x >> y;
  set<int> a;
  a.insert(1);
  a.insert(3);
  a.insert(5);
  a.insert(7);
  a.insert(8);
  a.insert(10);
  a.insert(12);
  
  set<int> b;
  b.insert(4);
  b.insert(6);
  b.insert(9);
  b.insert(11);
  
  if(a.find(x) != a.end() && a.find(y) != a.end()){
    cout << "Yes" << endl;
  }else if(b.find(x) != b.end() && b.find(y) != b.end()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
int powm(int base,int exp,int mod=MOD) {int ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	//bigger number on right side
	int ans=0;
	int count=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]==count)
		{
			count++;
			ans++;
		}
	}
	if(ans == 0)
		cout<<"-1"<<endl;
	else
		cout<<n-ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

using namespace std;

int main(void){

	char S[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

	string L;
	cin >> L;
	for(int i = 0; i < L.size(); i++){
		for(int j = 0; j < 26; j++){
			if(L[i] == S[j]){
				if(j < 3){
					cout << S[j - 3 + 26];
				}else{
					cout << S[j-3];
				}
			}
		}
	}
	cout << endl;
}

Measured memory_bytes: 1176
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	int N;
	int d[64];
	uint64_t sum = 0;
	int i, j;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &d[i]) != 1) return 1;
	}

	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			sum += d[i] * d[j];
		}
	}

	printf("%" PRIu64 "\n", sum);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    cout.precision(17);
    int N, A;
    cin >> N;
    double ans = 0.;
    for(int i = 0;i < N;i++){
        cin >> A;
        ans += 1. / A;
    }
    cout <<  1. / ans << "\n";
}


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

using namespace std;

int main(void) {
  int a, b; cin >> a >> b;
  if (a < b) {
    for (int i = 0; i < b; i++) cout << a;
  } else {
    for (int i = 0; i < a; i++) cout << b;
  } cout << endl;

  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d %d", $taka_hp, $taka_at, $aoki_hp, $aoki_at);
while($aoki_hp > 0 || $taka_hp > 0){
    $aoki_hp -= $taka_at;
    // echo $aoki_hp . "\n";
    if($aoki_hp <= 0){
        echo "Yes";
        return;
    }
    $taka_hp -= $aoki_at;
    // echo $taka_hp . "\n";
    if($taka_hp <= 0){
        echo "No";
        return;
    }
}
?>

Measured memory_bytes: 16148
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

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

   vector<ll> A(N), B(M);

   cin >> A.at(0);
   rep(i, 1, N) {
     ll tmp; cin >> tmp;
     A.at(i) = A.at(i - 1) + tmp;
   }

   cin >> B.at(0);
   rep(i, 1, M) {
     ll tmp; cin >> tmp;
     B.at(i) = B.at(i - 1) + tmp;
   }

   ll ans = 0;

   rep(i, 0, N + 1) {
     ll tmp_K = K, book = 0;
     if (i > 0 && A.at(i - 1) > tmp_K) continue;
     else if (i > 0) {
       book = i;
       tmp_K -= A.at(i - 1);
     }

     auto itr = upper_bound(B.begin(), B.end(), tmp_K);
     book += itr - B.begin();
     ans = max(ans, book);
   }

   cout << ans << endl;
 }


Measured memory_bytes: 6424
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

struct BIT{
private:
    vector<ll> a;
    int n;
public:
    BIT(int sz){
        n=sz;
        a.resize(sz+1);
    }
    ll sum(int i){
        ll res=0;
        while(i>0){
            res+=a[i];
            i-=i&-i;
        }
        return res;
    }
    ll sum(int i,int j){
        return sum(j)-sum(i-1);
    }
    void add(int i,ll x){
        while(i<=n){
            a[i]+=x;
            i+=i&-i;
        }
    }
};

int main(){
    ll n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    ll s[n+1];
    s[0]=0;
    ll lb=0,ub=inf;
    while(ub-lb>1){
        ll x=(ub+lb)/2;
        rep(i,n){
            if(a[i]<=x)s[i+1]=1;
            else s[i+1]=-1;
            s[i+1]+=s[i];
        }
        pair<int,int> p[n+1];
        rep(i,n+1){
            p[i]=make_pair(s[i],-i);
        }
        sort(p,p+n+1);
        BIT bit(n+1);
        ll cnt=0;
        rep(i,n+1){
            int it=-p[i].second;
            cnt+=bit.sum(it);
            bit.add(it+1,1);
        }
        if(cnt<n*(n+1)/4+1)lb=x;
        else ub=x;
    }
    cout<<ub<<endl;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<iterator>
#include<set>

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

using namespace std;
int main()
{
long long int b;
cin>>b;
if(b%1000==0)
    cout<<"0";
else
    cout<<1000-b%1000;

}


Measured memory_bytes: 3644
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	long T;
	cin >> T;
	
	long bef=0;
	long ans=0;
	rep(i,0,n){
		long t;
		cin >> t;
		if(bef+T <= t)
			ans+=T;
		else
			ans+=t-bef;

		bef=t;
	}
	ans += T;
	P(ans);
	ret 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	vector<int>V(N);
	vector<int>Y(N);
	for (int i = 0; i < N; ++i) {
		cin >> V[i];
		Y[i] = V[i];
	}
	sort(V.begin(), V.end());
	for (int i = 0; i < N; ++i) {
		if (Y[i] == V[N / 2]) {
			cout << V[N / 2 - 1] << endl;
		}
		else if (Y[i] == V[N / 2 - 1]) {
			cout << V[N / 2] << endl;
		}
		else if (Y[i] < V[N/2 - 1]) {
			cout << V[N / 2] << endl;
		}
		else {
			cout << V[N / 2 - 1] << endl;
		}

	}
    return 0;
}

Measured memory_bytes: 3712
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3648
n, m = map(int, input().split())
ne = []
for i in range(n):
    ne.append(list(map(int, input().split())))
    
ne.sort(key=lambda x: x[0])

ans = 0

for i in range(n):
    if ne[i][1] >= m:
        ans += m * ne[i][0]
        break
    else:
        ans += ne[i][0] * ne[i][1]
        m -= ne[i][1]
        
print(ans)

Measured memory_bytes: 29028
N=int(input())
x=0
for i in range(N):
    D = list(map(int,input().split()))
    if D[0]==D[1]:
        x=x+1
        if x>=3:
            break
    elif D[0]!=D[1]:
        x=0
if x>=3:
    print("Yes")
elif x<3:
    print("No")

Measured memory_bytes: 9048
def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    MAXA = max(A)
    prev = 0
    ans = 0
    for a in A:
        if prev < a:
            diff = a - prev
            ans += diff
        prev = a
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;

long long gcd(long long m, long long n) {
    return n != 0 ? gcd(n, m % n) : m;
}

long long lcm(long long m, long long n) {
    // If both m and n are large numbers, the result is overflow without parentheses.
    return m * (n / gcd(m, n));
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> p;
    int a, b;
    REP(i, n) {
        cin >> a >> b;
        p.emplace_back(a, b);
    }
    sort(ALL(p), [](auto p1, auto p2){return p1.second < p2.second;});

    int u = 0;
    for (const auto q : p) {
        u += q.first;
        if (u > q.second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b!=c) cout<<"Yes"<<endl;
    else if(a==c && b!=c) cout<<"Yes"<<endl;
    else if(b==c && a!=c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

f xs = 31 : g 31 (cycle xs)
  where
    g 1 _ = [0]
    g n (y:ys) = (n-y):(n-5):g (n-5) ys

main = getInt >>= flip when (getInts >>= mapM_ print . f >> main) . (/=0)

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
-- templete



Measured memory_bytes: 4092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	string n;
	cin >> n;
	for (int i = 0; i < n.length(); i++) {
		if (n[i] == '1') n[i] = '9';
		else if (n[i] == '9') n[i] = '1';
	}
	cout << n << endl;

	return 0;
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
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; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vint x(n),y(n);
    map<pint,ll> m;
    map<ll, vint> X,Y;
    rep(i,n){
        cin>>x[i]>>y[i];
        x[i]--; y[i]--;
        m[mp(x[i], y[i])] = i;
        X[x[i]].push_back(y[i]);
        Y[y[i]].push_back(x[i]);
    }
    UnionFind uf(n);
    for(auto p:X){
        for(auto e:p.second){
            uf.unite(m[mp(p.first, p.second.front())], m[mp(p.first, e)]);
        }
    }
    for(auto p:Y){
        for(auto e:p.second){
            uf.unite(m[mp(p.second.front(), p.first)], m[mp(e, p.first)]);
        }
    }
    set<ll> used;
    map<ll, set<ll>> cntX, cntY;
    ll ans = 0;
    rep(i,n){
        cntX[uf.find(i)].insert(x[i]);
        cntY[uf.find(i)].insert(y[i]);
    }
    rep(i,n){
        if(used.count(uf.find(i))) continue;
        used.insert(uf.find(i));
        ans += cntX[uf.find(i)].size()*cntY[uf.find(i)].size() - uf.size(i);
    }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 24576
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
    int a,b;
    char cup[4],abc[2][3]={{'A','B','C'},{'1','0','0'}};
    while(scanf("%s",cup)!=EOF){
        for(int i=0;i<3;i++){
            if(abc[0][i]==cup[0]) a=i;
            if(abc[0][i]==cup[2]) b=i;
        }
        swap(abc[1][a],abc[1][b]);
    }
    for(int i=0;i<3;i++){
        if(abc[1][i]=='1'){
            printf("%c\n",abc[0][i]);
        }
    }
    return 0;
}

Measured memory_bytes: 1136
s = input()
s_up = int(s[0] + s[1])
s_down = int(s[2] + s[3])

if 0 < s_up <= 12 and 0 < s_down <= 12:
    print("AMBIGUOUS")
elif 0 < s_down <= 12:
    print("YYMM")
elif 0 < s_up<= 12:
    print("MMYY")
else:
    print("NA")

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

int main() {
	while(1){
		long n; cin >> n ; if(n==-1) break;
		string str="";
		if(!n) str="0";
		while(n){
			char ch='0';
			ch+=n%4;
			str+=ch;
			n/=4;
		}
		for(int i=str.size()-1;i>=0;i--) cout << str[i] ;
		cout << '\n' ;
	}
}

Measured memory_bytes: 1184
n, m, k = map(int, input().split())
aes = list(map(int, input().split()))
bs = list(map(int, input().split()))
r_aes = [0]*n
for i in range(1,n):
    aes[i] += aes[i-1]
for i in range(1,m):
    bs[i] += bs[i-1]
cnt_a = 0
for i in range(n):
    if aes[i] > k:
        break
    cnt_a += 1
cnt_b = 0
res = cnt_a
#cnt = 5
while True:
    #print("cnt_a: "+str(cnt_a))
    #print("cnt_b: " + str(cnt_b))
    if cnt_b >= m or bs[cnt_b] > k:
        break
    if cnt_a >= 1 and k-aes[cnt_a-1]>=bs[cnt_b]:
        cnt_b += 1
        res = max(res,cnt_a+cnt_b)
        continue
    if cnt_a < 1 and k>=bs[cnt_b]:
        cnt_b += 1
        res = max(res,cnt_b)
        continue
    cnt_a -= 1
    if cnt_a < -1:
        break
    #if cnt<= 0:
        #break
print(res)

Measured memory_bytes: 40416
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    s = SI()

    r, t = 0, 0
    for i in range(len(s)):
        if i % 2:
            if s[i] == '0':
                r += 1
            else:
                t += 1
        else:
            if s[i] == '0':
                t += 1
            else:
                r += 1

    return min(r, t)


print(main())


Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int main() {
	int n;
	int max = 0;
	int m = 0;
	int hantei;
	int bhantei;
	cin >> n;
	char s[101];
	for (int i = 0; i < n; i++)cin >> s[i];
	for (int i = 1; i < n; i++) { //切断部位
		for (int j = 0; j < i; j++) { //ここから一文字目からの判定
			hantei = 0;
			bhantei = 0;
			for (int k = i; k < n; k++) {
				if (s[j] == s[k])hantei++;
			}
			for (int k = j - 1; k >= 0; k--) {
				if (s[j] == s[k])bhantei++;
			}
			if (hantei > 0 && bhantei == 0)m++;
		}
		if (max <= m)max = m;
		m = 0;
	}

	cout << max;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;
#define lowbit(x) ((x)&(-x))
#define pi acos(-1.0)
#define eps 1e-8
#define LL long long
#define INF 0x3f3f3f3f
inline int Scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
#define MOD 1000000007
#define MX 1005
//Code
int n;

int main()
{
    scanf("%d",&n);
    int yu=0;
    int two=0;
    int bu=0;
    for (int i=1;i<=n;i++)
    {
        int x=Scan();
        if (x%4==0) yu++;
        else if (x%2==0) two++;
        else bu++;
    }
    int ok=1;

    if (two) yu--;
    if (bu>yu+1)
        ok=0;
    if (ok) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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


int main() {
  ll x, y;
  cin >> x >> y;
  ll result;
  
  if (x == y) {
    result = 0;
  } else if (x == 0) {
    if (0 < y) {
      result = abs(y);
    } else {
      result = abs(y) + 1;
    }
  } else if (y == 0) {
    if (0 < x) {
      result = 1 + abs(x);
    } else {
      result = abs(x);
    }
  } else if (0 < x && 0 < y) {
    if (x < y) {
      result = y - x;
    } else {
      result = 1 + x - y + 1;
    }
  } else if (0 < x && y < 0) {
    if (abs(x) < abs(y)) {
      result = abs(y) - abs(x) + 1;
    } else {
      result = 1 + abs(x) - abs(y);
    }
  } else if (x < 0 && 0 < y) {
    if (abs(x) < abs(y)) {
      result = 1 + abs(y) - abs(x);
    } else {
      result = abs(x) - abs(y) + 1;
    }
  } else if (x < 0 && y < 0) {
    if (abs(x) < abs(y)) {
      result = 1 + abs(y) - abs(x) + 1;
    } else {
      result = abs(x) - abs(y);
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin >> n;
    cout << (n-1)*n/2 << endl;
}

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

int main() {
  string s;
  cin >> s;
  
  int x = s.size()-2;
  cout << s[0] + to_string(x) + s[s.size()-1] << endl;
  return 0;
}

Measured memory_bytes: 3696
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut seq = vec![(0, 0); n];
    let mut lseq = vec![(0, 0); n];
    let mut rseq = vec![(0, 0); n];
    for i in 0..n {
        let l = read::<i64>();
        let r = read::<i64>();
        seq[i] = (l, r);
        lseq[i] = (l, i);
        rseq[i] = (r, i);
    }
    lseq.sort();
    lseq.reverse();
    rseq.sort();
    let mut ans = 0;
    for iter in 0..2 {
        let mut pos = 0;
        let mut sum = 0;
        let mut used = vec![false; n];
        let mut l = 0;
        let mut r = 0;
        for i in 0..n {
            let mut index = 0;
            if i % 2 == iter {
                while used[lseq[l].1] {
                    l += 1;
                }
                index = lseq[l].1;
            } else {
                while used[rseq[r].1] {
                    r += 1;
                }
                index = rseq[r].1;
            }
            if pos < seq[index].0 {
                sum += (seq[index].0 - pos).abs();
                pos = seq[index].0;
            } else if seq[index].1 < pos {
                sum += (seq[index].1 - pos).abs();
                pos = seq[index].1;
            }
            used[index] = true;
            // println!("{} {} {:?} {}", pos, index, seq[index], sum);
        }
        sum += pos.abs();
        ans = std::cmp::max(ans, sum);
    }
    println!("{}", ans);
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)

/* memo
int no[tate][yoko]
*/

int main() {
    int K;
    char S[101] = {};
    cin >> K;
    cin >> S;
    int i;
    for (i = 0; i < K; i++) {
        if (S[i] == '\0') {
            cout << endl;
            return 0;
        }
        cout << S[i];
    }

    if (i != strlen(S)) {
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define BIGINF (int) 4e18 + 7
#define MOD7 1000000007
#define MOD9 1e9 + 9
#define INF  (int)2e9 + 7
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
typedef long long ll;
typedef long double ld;
typedef string str;
typedef double d;
typedef unsigned u;
typedef unsigned long long ull;

int main () {
    //freopen("inputf.txt", "r", stdin);
    //freopen("outputf.txt", "w", stdout);
    int n, x, k;
    SCD(n);
    SCD(k);
    vector<int> v;
    for (int i = 0; i < n; i++) {
    	SCD(x);
    	v.push_back(x);
    }
    int dp[100005];
    memset(dp, INF, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]);
    	for (int j = 2; j <= k; j++) {
            if (i - j >= 0) {
                dp[i] = min(dp[i],
                            dp[i - j] + abs(v[i] - v[i - j]));
            }
            else break;
        }
    }
    printf("%d", dp[n - 1]);


    return 0;
}



Measured memory_bytes: 1144
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K; cin >> N >> K;
  ll ans = 0;
  if(K == 0) {
      cout << N * N << endl;
      return 0;
  }
  rep1(b, N) {
    if(b <= K) continue;
    else {
      ans += (b - K) * (N / b) + (N % b >= K  ? (N % b) - K + 1 : 0);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=3;i<=n;i++){
    if(i%3==0||i%10==3||(i/10)%10==3||(i/100)%10==3||(i/1000)%10==3||(i/10000)%10==3)
      cout<<" "<<i;
  }
  cout<<endl;
  return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> ans(N);
  for(int i=0;i<M *2;i++){
    int a;
    cin >> a;
    a--;        //i-1
    ans.at(a) += 1;
  }
  for(int i = 0;i<N; i++){
    cout<<ans.at(i)<<endl;
  }    
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int,input().split()))
Ans = []
Ans.append(B[0])
if N > 2:
  for i in range(1,N-1):
    Ans.append(min(B[i-1],B[i]))
Ans.append(B[-1])
print(sum(Ans))

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int N, K, h;
	int count;
	
	cin >> N >> K;
	
	for (int i = 0; i < N; i++) {
		cin >> h;
		if (h >= K) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
	
}

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

if n > 1:
    for i in reversed(range(n-1)) :
        if list[i+1] - list[i] < - 1:
            print("No")
            break
        elif  list[i+1] - list[i] == - 1:
            list[i] -= 1
        elif i == 0:
            print("Yes")
        else:
            continue
else:
    print("Yes")

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
#define FILEIN freopen("input.txt", "r", stdin)

#define ll long long
#define endl "\n"

int main(){
	// FILEIN;
	string s;
	cin>>s;
	for(int i = 0; i<s.size(); i++){
		cout<<"x";
	}
	cout<<endl;
}

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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] ans = new string[4]{"Christmas Eve Eve Eve","Christmas Eve Eve","Christmas Eve","Christmas"};
            Console.WriteLine(ans[N-22]);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<functional>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int i = 1;
  while(i <= n) {
    int cou = 0;
    erep(j, 1, i) {
      if(i % j == 0) cou++;
    }
    if(cou == 8) ans++;
    i += 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   long long int t,n,m,k;
   vector<long long int> v,v1,v2;
   vector< pair <long long int,long long int> >p,p1,p2;
   set<long long int> st;
   priority_queue<long long int> pq;
   priority_queue< long long int,vector<long long int>,greater<long long int> > lpq;
   string s;
   cin>>n>>k;
   m=n/k;
   n=n-(m*k);
   st.insert(n);
   lpq.push(n);
   n=abs(n-k);
   while(st.find(n)==st.end())
   {
      st.insert(n);
      lpq.push(n);
      n=abs(n-k);
   }
   cout<<lpq.top();
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.14159265359
#define all(v) v.begin(),v.end()
#define vil vector<long int>
#define vi vector<int> 
#define pb(x) push_back(x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define INF 1000000007 
#define MOD 998244353
void solve(ll t){
    int n;
    cin>>n;
    vi a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(a[1]-a[0]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i-2]),dp[i-2]+abs(a[i-1]-a[i-3]));
    }
    cout<<dp[n]<<endl;
    return;
   
}
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
ll t;
t=1;
//cin>>t;
while(t--){
   solve(t);
return 0;
}
}

Measured memory_bytes: 3928
N_max = 2*(10**5)
N = int(input())

A = list(map(int, input().split()))

array = sorted(A)
quantity_of_num = [0]*(N_max + 1) # kという値がquantity_of_num[k]個あることを示す
type_index = list() # 文字の種類を昇順で記録していく配列。　len(type_index)が文字の種類数

count = 1 # 各文字が何個あるかの記録作業
for i in range(N-1):
    if array[i] == array[i+1]:
        count += 1
    else:
        type_index.append(array[i])
        quantity_of_num[array[i]] = count

        count = 1
type_index.append(array[i+1])
quantity_of_num[array[i+1]] = count

# type_index と　quantity_of_num の印字用
# for i in range(len(type_index)):
#     print(type_index[i], end="")
# print()
# for i in range(len(type_index)):
#     print(quantity_of_num[type_index[i]], end="")
# print()

total = 0 #k番目を除外せずに同じ数字の取り方が何通りあるかを検証
for i in range(len(type_index)):
        quantity = quantity_of_num[type_index[i]]
        # total の計算の挙動確認用
        # print("i = ", i, "quantitiy = ", quantity, "sum = ", quantity*(quantity - 1) // 2)
        total += quantity*(quantity - 1) // 2

for k in range(N):

    # k番目の数字から選んでいた部分を修正すれば良い
    # A[k] がk番目の数字
    quantity = quantity_of_num[A[k]]
    ans = total - ( quantity*(quantity-1) // 2) + ( (quantity-1)*(quantity-2) // 2)
    
    print(ans)



    

Measured memory_bytes: 26140
/**
 *    AUTHOR:    crypter472                    
 *   CREATED:   26.04.2020 01:13:56  
**/
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define lb(container, val)      lower_bound(all((container)), val) - (container).begin()
#define ub(container, val)      upper_bound(all((container)), val) - (container).begin()
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define FILL(x, val)            memset(x, val, sizeof(x))
#define sz(container)           ((int) (container).size())
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (long long) 1000000007
#define inf                     INT_MAX
#define INF                     LLONG_MAX

using namespace std;

#ifdef LOCAL_DEFINE
    #include "../../DEBUG.hpp"
#endif

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
long long MAX() {return LLONG_MIN;}
long long MIN() {return LLONG_MAX;}
template<typename T, typename... Args>
T MAX(T a, Args... args) {return max(a, MAX(args...));}
template<typename T, typename... Args>
T MIN(T a, Args... args) {return min(a, MIN(args...));}

typedef long long ll; 
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;

int main(void) {    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in1", "r", stdin);
#endif
    
    int n;
    cin >> n;
    vll arr(n), dp(n);
    forn(i, n) cin >> arr[i];
    dp[0] = 0;
    dp[1] = abs(arr[0] - arr[1]);
    fore(i, 2, n - 1, 1) {
        dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
    }
    cout << dp[n - 1] << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << '\n';
#endif
    return 0;
}

Measured memory_bytes: 1792
def main():
    N = int(input())
    dict = {}
    result = 0
    for i in range(N):
        s = "".join(sorted(input()))
        if s in dict:
            result += dict[s]
            dict[s] = dict[s] + 1
        else:
            dict[s] = 1
    print(result)


if __name__ == '__main__':
    main()

Measured memory_bytes: 17852
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
    int n;
	
    cin >> n;
    cin.ignore();
    for (int i = 0; i < n; i++){
		string str;
		int pos = 0;
        getline(cin, str);
        while (1){
            pos = str.find("Hoshino", pos);
            if (pos == -1)  break;
            str[pos + 6] = 'a';
        }
        cout << str << endl;
    }
    return (0);
}

Measured memory_bytes: 1208
let readCharArray _ = stdin.ReadLine().ToCharArray()

let rec solve count list =
    match list with
    | [] -> count
    | [ _ ] -> count
    | x :: [ y ] -> if x = y then count else count + 1
    | x :: y :: xx -> if x = y then solve (count) (y :: xx) else solve (count + 1) (y :: xx)

stdin.ReadLine()
|> readCharArray
|> Array.toList
|> solve 1
|> printfn "%d"


Measured memory_bytes: 41516
#include<iostream>
using namespace std;
int main(){
  int n,m,c;
  int b[20]={};
  int a[20][20]={};
  cin >> n >> m >> c;
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  for(int k=0;k<n;k++){
    for(int i=0;i<m;i++){
      cin >> a[k][i];
    }
  }
  int l=0;
  int x=0;
  for(int k=0;k<n;k++){
    for(int i=0;i<m;i++){
        for(int u=0;u<m;u++){
            l=l+a[k][u]*b[u]; 
        }
      
    }
    if(l/m+c>0){
        x++;
    }
      l=0;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
const li inf = 1 << 60;

void _main(int tc) {
  li n, W;
  cin >> n >> W;
  vector<int> w(n), v(n);
  rep(i, n) { cin >> w[i] >> v[i]; }

  // ********* Recursive ************
  // vector<vector<li>> mem(n, vector<li>(W + 1, -1));
  // function<li(int, int)> F = [&](int i, int k) -> li {
  //   if (i == n) return 0;
  //   if (mem[i][k] != -1) return mem[i][k];
  //   if (k - w[i] >= 0) mem[i][k] = v[i] + F(i + 1, k - w[i]);
  //   mem[i][k] = max(mem[i][k], F(i + 1, k));
  //   return mem[i][k];
  // };
  // cout << F(0, W) << endl;
  // ********* End Recursive ************

  vector<vector<li>> mem(n + 1, vector<li>(W + 1, 0));
  rrep(i, n) {
    rrep(k, W + 1) {
      if (k - w[i] >= 0)
        mem[i][k] = max(v[i] + mem[i + 1][k - w[i]], mem[i + 1][k]);
      else
        mem[i][k] = mem[i + 1][k];
    }
  }
  cout << mem[0][W] << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0);
  return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

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

using namespace std;
const int N = 1000000 + 77;
long long A , B , C , k;
int main(){
	cin >> A >> B >> C >> k;
	if(k & 1){
		cout << B - A;
	}
	else{
		cout << A - B;
	}
 	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

int main(){
    int n, q;
    while(scanf("%d%d", &n, &q) && n){
        string s[n];
        int e[n], w[n];
        rep(i, n) cin >> s[i] >> e[i] >> w[i];
        int idx[n];
        rep(i, n) idx[i] = i;
        sort(idx, idx+n, [&](const int &a, const int &b){return w[a] < w[b];});
        while(q--){
            int x;
            scanf("%d", &x);
            auto it = lower_bound(idx, idx+n, x, [&](const int &a, int x){return w[a] < x;});
            if(it == idx+n) puts("Unknown");
            else{
                int i = *it;
                if(w[i]-x < e[i]) cout << s[i] << " " << e[i] - (w[i]-x) << "\n";
                else puts("Unknown");
            }
        }
    }
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> graph(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> graph[i][j];
        }
    }

    vector<vector<bool>> noneed(n, vector<bool>(n));
    bool possible = true;
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (k == i || i == j || j == k)continue;
                if (graph[i][j] > graph[i][k] + graph[k][j])possible = false;
                else if (graph[i][j] == graph[i][k] + graph[k][j])noneed[i][j] = true;
            }
        }
    }

    long long ret = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (!noneed[i][j])ret += graph[i][j];
    cout << (possible ? ret / 2 : -1) << endl;
    return 0;
}

Measured memory_bytes: 640
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN3(a,b,c);
  OUT(min({a+b,a+c,b+c}));
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Ord
main = readLn >>= flip replicateM getLine >>= putStrLn . solve . fmap sort

solve :: [String] -> String
solve xs
    | any null xs = []
    | b = m : solve ys
    | otherwise = solve ys
    where
        m = head $ minimumBy (comparing head) xs
        (ys, b) = foldr ff ([], True) xs
        ff x (acc, c)
            | head x == m = (tail x : acc, c)
            | otherwise = (x : acc, False)


Measured memory_bytes: 1148
#ABC153D
import sys
h = int(sys.stdin.readline())

#累積 敵の数
cnt = 0
#現在の敵の数
n = 1
while n>0:
    cnt+= n
    #print(cnt)
    if h>1:
        h = h//2
        n = 2*n
    elif h==1:
        n=0
    

print(cnt)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;
const int max_n = 1e6 + 5;
int deg[25];

int main() {
	make3(k, a, b);
	if (b <= a+2 || k <= a - 1) {
		printf("%d\n", k + 1);
	} else {
		k-= a-1;
		lint mam = a;
		int dupa = k/2;
		int kupa = k%2;
		mam += kupa;
		mam += (dupa * 1LL * (b-a));
		printf("%lld\n", mam);
	}
}




Measured memory_bytes: 256