akhauriyash/Code-Regression huggingface dataset:
import os
import sys
import numpy as np

def solve(A, N):
    mod = 10**9+7
    C = [0] * 60
    for a in A:
        for i in range(60):
            if a>>i&1:
                C[i] += 1
    ans = 0
    for i, c in enumerate(C):
        ans += (1<<i) % mod * c % mod * (N-c) % mod
    return ans % mod

# >>> numba compile >>>
numba_config = [
    [solve, "i8(i8[:],i8)"],
]
if sys.argv[-1] == "ONLINE_JUDGE":
    from numba import njit
    from numba.pycc import CC
    cc = CC("my_module")
    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature)(func)
        cc.export(func.__name__, signature)(func)
    cc.compile()
    exit()
elif os.name == "posix":
    exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
else:
    from numba import njit
    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature, cache=True)(func)
    print("compiled!", file=sys.stderr)
# <<< numba compile <<<

N = int(input())
A = np.array(input().split(), dtype=np.int64)
print(solve(A, N))


Measured memory_bytes: 82760
import java.util.*

fun main(atgs: Array<String>) {
    val n = readLine()!!.toInt()
    val list = ArrayList<Pair<Int, Int>>()
    repeat(n) {
        val (x, y) = readLine()!!.split(" ").map{ it.toInt() }
        list.add(x to y)
    }

    var r = 0.0
    for (a in 0 until n) {
        for (b in a+1 until n) {
            val m = (list[a].first - list[b].first) * (list[a].first - list[b].first) +
                    (list[a].second - list[b].second) * (list[a].second - list[b].second);
            r += Math.sqrt((m.toDouble()))
        }
    }
    val ans = 2*r/n;
    println(ans)
}

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

int main() {
  int R;
  cin >> R;
  if (R<1200) {
    cout << "ABC" << endl;
  }else if (R < 2800) {
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAX_N = 100005;
const int K = 26;

string s, t;
int n, m;
int cntS[K], cntT[K];
string dS;
int nextPos[2 * MAX_N][K];

int main()
{
	ios::sync_with_stdio(false);
	cin >> s >> t;
	n = (int)s.length();
	m = (int)t.length();
	for (int i = 0; i < n; i++)
		cntS[s[i] - 'a']++;
	for (int i = 0; i < m; i++)
		cntT[t[i] - 'a']++;

	for (int i = 0; i < K; i++)
		if (cntT[i] != 0 && cntS[i] == 0)
		{
			cout << "-1" << endl;
			return 0;
		}

	dS = s + s;
	for (int i = 0; i < K; i++)
		nextPos[2 * n - 1][i] = 2 * n;
	for (int i = 2 * n - 2; i >= 0; i--)
	{
		for (int j = 0; j < K; j++)
			nextPos[i][j] = nextPos[i + 1][j];
		nextPos[i][dS[i + 1] - 'a'] = i + 1;
	}

	ll result = 0;
	int currPos = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == t[0])
		{
			result = i;
			currPos = i;
			break;
		}
	for (int i = 1; i < m; i++)
	{
		int j = nextPos[currPos][t[i] - 'a'];
		result += j - currPos;
		currPos = j;
		if (currPos >= n)
			currPos -= n;
	}
	cout << (result + 1) << endl;
}

Measured memory_bytes: 21072
N = int(input())
W = [input() for _ in range(N)]
if len(set(W)) != N:
  print('No')
  exit()
else:
  w = W.pop(0)
  r = w[-1]
  for w in W:
    if r == w[0]:
      r = w[-1]
    else:
      print('No')
      exit()

print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<ll> sum(n-1);
    ll tmp = 0;
    ll ans = 0;
    if(a[0] > x) {
        ans += a[0]-x;
        a[0] = x;
    }
    rep(i, 0, n-1) {
        sum[i] = a[i]+a[i+1];
        //cout << sum[i] << " " << ans  << endl;
        if(sum[i] > x) {
            a[i+1] -= (sum[i]-x);
            ans += (sum[i]-x);
        }
        tmp = max(sum[i], tmp);
    }
    if(tmp <= x) {
        cout << 0 << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}   

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i,N) cin >> a[i];
    int ans = 0;
    Rep(i, 1,N+1){
        if((i&1)&&(a[i-1]&1)) ans++;
    }
    pr(ans);
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
int a[114514],b[114514];
signed main(){
	ic(x) ic(y) ic(z)
	cout<<min({x,y,z})<<" "<<x+y+z-min({x,y,z})-max({x,y,z})<<" "<<max({x,y,z})<<endl;
}



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

int main(){

    int a, b;
    cin >> a >> b;

    string nums = to_string(a) + to_string(b);
    int num = stoi(nums);
    int sq = sqrt(num);
    if(num == sq * sq) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();

        System.out.println(solve());
    }

    static String solve() {
        return N % S(N) == 0 ? "Yes" : "No";
    }

    static int S( int n ) {
        String s = Integer.toString(n);
        int ret = 0;
        for (int i = 0; i < s.length(); i++) {
            ret += Integer.parseInt("" + s.charAt(i));
        }
        return ret;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }






int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    int n;
    cin >> n;
    vector<vector<pii> > v(n);
    
    rep(i, n) {
        int a;
        cin >> a;
        rep(j, a) {
            int x, y;
            cin >> x >> y;
            x--;
            v[i].eb(pii(x, y));
        }
    }
    // rep(i, n) { cout << i << endl; rep(j, sz(v[i])) cout << v[i][j].F << " " << v[i][j].S << endl; }
    
    int ans = 0;
    rep(i, 1 << n) {
        int table[20] = {0};
        rep(j, n) {
            if (i & (1 << j)) { // 正直
                table[j] = 1;
            }
        }
        int flg = 0;
        rep(j, n) {
            if (i & (1 << j)) { // 正直
                rep(k, sz(v[j])) {
                    if (v[j][k].S == 0) {
                        if (table[v[j][k].F] == 1) flg = 1;
                    } else {
                        if (table[v[j][k].F] == 0) flg = 1;
                    }
                }
            } 
        }
        if (flg == 0) chmax(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main()
{
  int a[4][3][10] = {0}, n, b, f, r, v;

  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    a[b - 1][f - 1][r - 1] += v;
  }
  for (int i = 0; i < 4; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 10; k++)
      {
        printf(" %d", a[i][j][k]);
      }
      printf("\n");
    }
    if (i < 3)
      printf("####################\n");
  }

  return 0;
}


Measured memory_bytes: 2728
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  ll d, n;
  cin>>d>>n;
  cout.precision(10);
  cout<<pow(100, d)*n+((n==100)?1*pow(100, d):0)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n;
    cin >> n;
    string ans = "No";
    if(n % 10 == 7){
        ans = "Yes";
    }
    n /= 10;
    if(n % 10 == 7){
        ans = "Yes";
    }
    n /= 10;
    if(n % 10 == 7){
        ans = "Yes";
    }

    cout << ans << endl;


    

}

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	if( ((a+b)%3==0) || a%3==0 || b%3==0){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define pos first
#define index second
#define mp make_pair
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=2e5+10;
const int maxm=1e2+10;
const int mod=1e9+7;
int n;
char op[10];
int init()
{
    int k=10;
    for(int i=1;i<=9;i++)
    {
        printf("? %lld\n",k);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='N')
            return i;
        k=k*10;
    }
    k=9;
    for(int i=1;i<=9;i++)
    {
        printf("? %lld\n",k);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='Y')
            return i;
        k=k*10+9;
    }
    return 10;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int len=init();
    if(len==10)
    {
        printf("! %d\n",(int)1e9);
        return 0;
    }
    int ans=0;
    for(int i=1;i<len;i++)
    {
        int l=0,r=9,t=0;
        while(l<=r)
        {
            int mid=(l+r)/2;
            printf("? %d\n",ans*10+mid);
            fflush(stdout);
            scanf("%s",op);
            if(op[0]=='Y')
            {
                t=max(t,mid);
                l=mid+1;
            }
            else
                r=mid-1;
        }
        ans=ans*10+t;
    }
    for(int i=(len==1?1:0);i<=9;i++)
    {
        printf("? %lld\n",((ll)ans*10+i)*10);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='Y')
        {
            ans=ans*10+i;
            break;
        }
    }
    printf("! %d\n",ans);
    return 0;
}


Measured memory_bytes: 596
#include <bits/stdc++.h>
#ifdef __mr__
    #include "prettyprint.hpp"
#else
    #define endl                    '\n'
#endif
#define len(x)                      (uint)(x).size()
#define int                         int32_t
#define uint                        uint32_t
#define ulong                       uint64_t
#define long                        int64_t
#define maxof(x)                    numeric_limits<x>::max()
#define minof(x)                    numeric_limits<x>::min()
#define uset                        unordered_set
#define umap                        unordered_map
using namespace std;
const uint mod7 = uint(1000000007);
const uint mod9 = uint(1000000009);
const int inf31 = maxof(int);
const uint inf32 = maxof(uint);
const long inf63 = maxof(long);
const ulong inf64 = maxof(ulong);


int main(int argc, char const *argv[]) {
    #ifndef __mr__
        ios::sync_with_stdio(0);cin.tie(0);
    #endif
    long ai, ao, at, aj, al, as, az;
    cin >> ai >> ao >> at >> aj >> al >> as >> az;
    switch (ai % 2 + aj % 2 + al % 2) {
        case 0:
        case 3:
            cout << ao + ai + aj + al << endl;
            break;
        case 1:
            cout << ao + ai + aj + al - 1 << endl;
            break;
        case 2:
            if (ai > 0 && aj > 0 && al > 0)
                cout << ao + ai + aj + al - 1 << endl;
            else
                cout << ao + ai + aj + al - 2 << endl;
            break;
    }
    return 0;
}


Measured memory_bytes: 256
//52
#include<iostream>

using namespace std;

long long gcd(long long a,long long b){
  return (b==0)?a:gcd(b,a%b);
}

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

int main(){
  for(;;){
    long long ans=1;
    for(long long i=0;i<3;i++){
      long long a,m;
      cin>>a>>m;
      if(a==0&&m==0)return 0;
      long long i,p=1;
      for(i=1;;i++){
	p=(p*a)%m;
	if(p==1)break;
      }
      ans=lcm(ans,i);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 864
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;

string str;
long long int n,k,m,sum,res=1,a,b;
pair<long long int,long long int>pa[200000];


//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
	long long int tmp;
	long long int r;
	if (b > a) {
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0) {


		a = b;
		b = r;
		r = a % b;

	}
	return b;
}
//素数判定　素数ならそのまま返す　合成数なら０を返す。
long long int sosu(long long int n) {
	for (long long int i = 2; i*i <= n; i++) {
		if (n%i == 0) { return 0; }
	}
	return n;
}
long long int GCD;
int main() {
	cout << fixed << setprecision(10);
	cin>>a>>b;
	GCD=gcd(a,b);
	
	//cout<<GCD<<endl;
	for(long long int i=2;i*i<=GCD;i++){
		if(sosu(i)==i&&GCD%i==0){
			res++;
			while(GCD%i==0)GCD/=i;
		}else{
			continue;
		}
	}
	if(GCD!=1){res++;}
	cout<<res<<endl;
} 


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug(Head head,Tail... tail){
    cerr<<" "<<to_string(head);
    debug(tail...);
}

int main(){
    int N=get_int();
    int c=0;
    FOR(i,N){
        int l,r;
        cin>>l>>r;
        c+=(r-l+1);
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class TreesAndBrackets
{
    public:
string check(string t1, string t2)
{

}
};
int main()
{

int a;
while(cin>>a){
int A[100005]={};
for(int i=0;i<a;i++)
    cin>>A[i];

sort(A,A+a);
int ans1=A[a-1];
int tmp=(ans1+1)/2;
int minr=inf;
int ans2=0;

for(int i=0;i<a;i++){
    int now=abs(A[i]-tmp);
    if(now<minr){
        ans2=A[i];
        minr=now;
    }
}

cout<<ans1<<" "<<ans2<<endl;




}
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, A, B;
int H[100005];

int solve(int t) {
    int ans = 0;
    REP(i, N) {
        int hp = H[i] - B * t;
        if (hp <= 0) continue;
        ans += hp / (A - B);
        if (hp % (A - B) != 0) ans++;
    }
    return ans <= t;
}

signed main() {
    cin >> N >> A >> B;
    REP(i, N) cin >> H[i];
    int left = 0;
    int right = 2000000000;
    while (right - left > 1) {
        int mid = (right + left) / 2;
        if (solve(mid))
            right = mid;
        else
            left = mid;
    }
    cout << right << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
#include <functional>

#define MOD (1000000007)

using namespace std;

typedef long long ll;
typedef pair<ll, ll> tup;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];


ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<ll,ll> prime;//素因数分解でそれぞれの素数がいくつ出てきたかを保存するmap

//O(√n)
//整列済み(mapはkeyで自動で整列される)
void prime_factorize(ll n){
    if(n<=1) return;
    ll l=sqrt(n);
   for(ll i=2;i<=(ll)(l);i++) { //
        if(n%i==0){
        prime_factorize(i);prime_factorize(ll(n/i));return;
        }
    }
    //mapでは存在しないkeyの場合も自動で構築される
    prime[n]++;return;
}


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

    vector<ll> A(N);
    for(ll i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());    

    ll ret = 0;
    ll sum = 0;
    for(ll i = 0; i < N; i++) {
        //cout << sum << "," << A[i] << "," << ret << endl;
        if(2 * sum >= A[i] || sum == 0) {
            ret++;
        } else {
            //sum = 0;
            ret = 1;
        }
        sum += A[i];
    }

    cout << ret << endl;

    return 0;    
}



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

int main() {
  int N,M;
  cin>>N;
  vector<string> vn(N);
  rep(i,N){
    cin>>vn.at(i);
  }
  cin>>M;
  vector<string> vm(M);
  rep(i,M){
    cin>>vm.at(i);
  }
  vector<int>vans(N);
  int n=0;
  rep(i,N){
    rep(j,N){
      if(vn.at(i)==vn.at(j)){
        vans.at(i)++;
      }
    }
    rep(j,M){
      if(vn.at(i)==vm.at(j)){
        vans.at(i)--;
      }
    }
    if(n<vans.at(i)){
      n=vans.at(i);
    }
  }
  cout<<n<<endl;
}

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

int main() {
	int n,m;
	vector< int >c, dp;
	
	cin >> n >> m;
	c.resize(m);
	dp.resize(n+1);
	
	for(int i=0;i<m;++i)cin >> c[i];
	
	dp[0] = 0;
	for(int i=1;i<=n;++i){
		int min = -1;
		for(int j=0;j<m;++j){
			if(i - c[j] >= 0){
				if(min == -1 || min > dp[i - c[j]] )min = dp[i - c[j]];
			}
		}
		dp[i] = min + 1;
	}
	cout << dp[n] << endl;
	
	return 0;
}

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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記
  if((c == 'a')||(c == 'i')||(c == 'u')||(c == 'e')||(c == 'o')){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main()
{
    priority_queue<int> Q;
    int a;
    string hoge;
    while (cin >> hoge) {
        if (hoge == "insert") {
            cin >> a;
            Q.push(a);
        } else if (hoge == "extract") {
            cout << Q.top() << endl;
            Q.pop();
        } else {
            break;
        }
    }
}


Measured memory_bytes: 6988
<?php
fscanf(STDIN, "%d %d", $n, $m);
$h = explode(' ', trim(fgets(STDIN)));

for ($i = 1; $i <= $m; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);

    $terrace[$a][] = $b;
    $terrace[$b][] = $a;
}

$count = 0;

for ($i = 1; $i <= $n; $i++) {
    if (!isset($terrace[$i])) {
        $count++;
        continue;
    }

    $max = [];

    foreach ($terrace[$i] as $t) {
        $max[] = $h[($t - 1)];
    }

    if (max($max) < $h[($i - 1)]) {
        $count++;
    }
}

echo "{$count}\n";


Measured memory_bytes: 58152
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	long long int A, B, K;
	cin >> A >> B >> K;
	if (B - A + 1 <= 2 * K) {
		for (long long int i = A; i <= B; i++) {
			cout << i << endl;
		}
	}
	else {
		for (long long int i = A; i < A + K; i++) {
			cout << i << endl;
		}
		for (long long int i = B - K + 1; i <= B; i++) {
			cout << i << endl;
		}
	}
	//system("pause");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
    long int N, A, B;
    cin >> N >> A >> B;

    long int ans = (N / (A + B)) * A;
    if( N%(A+B) < A){
        ans = ans + N % (A + B);
    }else{
        ans = ans + A;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                          \
  cout << #v << "=(" << v[0];                              \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; } \
  cout << ")" << endl;
#define mdebug(m)                                                           \
  cout << #m << "=" << endl;                                                \
  REP(i_debug, m.size())                                                    \
  {                                                                         \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; } \
    cout << endl;                                                           \
  }
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T>
void readv(vector<T> &a)
{
  REP(i, a.size())
  cin >> a[i];
}
void readv_m1(vector<int> &a)
{
  REP(i, a.size())
  {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

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

  vec f(N + 1, 0);
  FOR(x, 1, 105)
  {
    FOR(y, 1, 105)
    {
      FOR(z, 1, 105)
      {
        ll currentval = x * x + y * y + z * z + x * y + y * z + z * x;
        if (currentval <= N)
          f[currentval] += 1;
      }
    }
  }
  FOR(i, 1, N + 1)
  {
    cout << f[i] << endl;
  }
  return 0;
}

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


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 100100100100100100;
const int mod = 1e9;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }
vector<int> cs(vector<int> arr){vector<int> tmp;if(arr.size() == 0) return tmp;tmp.push_back(arr[0]);rep(i,1,arr.size()){tmp.push_back(tmp.back() + arr[i]);}return tmp;}



/* main */



signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);



 
    string s = raw_input();

    if(s.size() == 2){
        print(s);
    }else{
        reverse(all(s));
        print(s);
    }

    
   
    













}






    










    




    










Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace C_MSOL2020
{
    class MainClass
    {

        static int[] s;
        static long[] a;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            a = Array.ConvertAll(ReadLine().Split().ToArray(), long.Parse);
            int k = s[1];
            int n = s[0];

            for(int i = k;i<n;i++){
                if(a[i]>a[i-k]){
                    WriteLine("Yes");
                }else{
                    WriteLine("No");
                }
            }
        }

        public static int LowerBound<T>(T[] a, T v)
        {
            return LowerBound(a, v, Comparer<T>.Default);
        }

        public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res == -1) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
        public static int UpperBound<T>(T[] a, T v)
        {
            return UpperBound(a, v, Comparer<T>.Default);
        }

        public static int UpperBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res <= 0) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }
    }
}


Measured memory_bytes: 48712
#include <iostream>
#include <algorithm>
#define N 110
#define INF 1000000;

int main(){
  int A[N][N];
  int n;
  std::cin >> n;

  //Initialization
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      if( i==j ){ A[i][i] =0; }
      else A[i][j] = INF;
    }
  }

  //Input
  int u, k, v, c;
  for(int i=0; i<n; i++){
    std::cin >> u >> k;
    for(int j=0; j<k; j++){
      std::cin >> v >> c;
      A[u][v] = c;
    }
  }

  for(int k=0; k<n; k++){
    for(int i=0; i<n; i++){
      for(int j=0; j<n; j++){
        A[i][j] = std::min( A[i][j], A[i][k]+A[k][j] );
      }
    }
  }

  for(int i=0; i<n; i++){
    std::cout << i << " " << A[0][i] << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <random>



#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

template <class T> inline bool chmax(T& a, T b){
    if(a < b){a = b; return true;}
    return false;
}
template <class T> inline bool chmin(T& a, T b){
    if(a > b){a = b; return true;}
    return false;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


constexpr int inf = 1e9;

class SolveDreamer{
private:
    const int n, m;
    std::vector<std::vector<int>> A;
public:
    SolveDreamer(int nn, int mm): n(nn), m(mm){
        A.resize(n, std::vector<int>(m));
    }
    std::vector<int>& operator [](int k){ return A[k]; }
    int solve(){
        std::vector<bool> B(m, false);
        std::vector<int> Ptr(n, 0);
        std::vector<int> Counter(m);
        int res = inf;
        REP(_, m){
            REP(i, n) while(Ptr[i] < m and B[ A[i][Ptr[i]] ] ) Ptr[i]++;
            std::fill(Counter.begin(), Counter.end(), 0);
            REP(i, n) Counter[A[i][Ptr[i]]]++;
            int mx = -1, argmx;
            REP(i, m) if(mx < Counter[i]){
                mx = Counter[i];
                argmx = i;
            }
            chmin(res, mx);
            B[argmx] = true;
        }
        return res;
    }
};


int main(void){
    int n, m; scanf("%d%d", &n, &m);
    SolveDreamer Solve(n, m);
    REP(i, n) REP(j, m) {scanf("%d", &Solve[i][j]); Solve[i][j]--;}

    printf("%d\n", Solve.solve());
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    auto D = InputVec(N);
    vector<ll> depthCount(N);
    for (int i = 0; i < D.size(); ++i) {
        depthCount[D[i]]++;
    }
    ll maxD = 0;
    for (ll i = 0; i < depthCount.size(); ++i) {
        if(depthCount[i] != 0){
            maxD = max(maxD,i);
        }
    }
    if(D[0] != 0 || depthCount[0] != 1){
        cout << 0 << endl;
        return 0;
    }
    ll count = 1;
    ll MOD = 998244353;
    for (int i = 1; i <= maxD; ++i) {
        for (int j = 0; j < depthCount[i]; ++j) {
            count *= depthCount[i-1];
            count %= MOD;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define sl set<ll>
#define vs vector<string>
#define vl vector<ll>
#define vi vector<int>
#define vpl vector<pair<ll,ll>>
#define pb push_back
#define PI 3.14159265358979323846
#define ll long long
#define ld long double
#define endl "\n"
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repp(i,a,b) for (ll i = (a); i >= (b); i--)
#define rop(i,a,b)  for(ll i=(a); i>(b); i--)
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define tt long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e5+100;


int main()
{
string a,b;
cin>>a>>b;
ll n=a.length();
ll x=0;
for(ll i=0;i<n;i++)
{
    if(a[i]!=b[i])x++;
}
cout<<x<<endl;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using Pii = std::pair<int, int>;

int main(int argc, char *argv[])
{
    int N, A, B, C;
    std::cin >> N >> A >> B >> C;

    std::vector<int> l(N, 0);
    for (int i = 0; i < N; i++) {
        std::cin >> l[i];
    }

    int ans = INF;
    for (int i = 0; i < std::pow(4, N); i++) {
        int cost = 0;
        std::vector<int> a(3, 0);
        std::vector<int> count(3, 0);
        for (int j = 0; j < N; j++) {
            int tmp = i;

            for (int k = 0; k < j; k++) {
                tmp /= 4;
            }
            tmp %= 4;

            if (tmp == 1) {
                a[0] += l[j];
                count[0]++;
            } else if (tmp == 2) {
                a[1] += l[j];
                count[1]++;
            } else if (tmp == 3) {
                a[2] += l[j];
                count[2]++;
            }
        }

        cost += std::abs(A - a[0]);
        cost += std::abs(B - a[1]);
        cost += std::abs(C - a[2]);

        if (count[0] == 0 || count[1] == 0 || count[2] == 0) {
            continue;
        }

        for (int j = 0; j < 3; j++) {
            cost += 10*(count[j]-1);
        }

        ans = std::min(ans, cost);
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cstdio>
using namespace std;
int main(){
	double x1,x2,y1,y2,ans1;
	cin>>x1>>y1>>x2>>y2;
		ans1=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		printf("%.9f\n",ans1);
	return 0;
}

Measured memory_bytes: 3280
import java.util.*;
import java.io.*;
class Main 
{
    public static void main (String[] args)throws IOException 
    {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt();
        int w = in.nextInt();
        int max = Math.max(w, h);
        int n = in.nextInt();
        int x = (int)Math.ceil((double)n / max);
        System.out.println(x);
    }
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

typedef long long LL;
static LL INF = (1LL<<62);

LL N, W;
vector<LL> VV;
vector<LL> VW;
map<pair<LL, LL>, LL> M;

LL val(LL i, LL w){
	auto p = make_pair(i, w);
	if(M.count(p) != 0){
		return M[p];
	}
	LL ret;
	if(i == 0){
		if(VW[0] <= w){
			ret = VV[0];
		}
		else{
			ret = 0;
		}
		M[make_pair(i, w)] = ret;
		return ret;
	}
	if(VW[i] > w){
		ret = val(i-1, w);
	}
	else{
		ret = max(val(i-1, w-VW[i]) + VV[i], val(i-1, w));
	}
	M[make_pair(i, w)] = ret;
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> W;
	for(int i=0; i<N; i++){
		LL w, v;
		cin >> w >> v;
		VV.push_back(v);
		VW.push_back(w);
	}
	printf("%lld\n", val(N-1, W));
	return 0;
}


Measured memory_bytes: 9708
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[3001][3001]={0};

int lcs(string a, string b, int m, int n) {
        // int m =a.length(), n=b.length();
        // int dp[1005][1005]={0};
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                if(i==0 || j==0) dp[i][j] = 0;
                
                else if(a[i-1]==b[j-1]) dp[i][j] = 1 + dp[i-1][j-1];
                
                else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
        
        return dp[m][n];
}
int main() {
    string a,b;
    cin>>a>>b;
    int m=a.length(), n=b.length();
    int res = lcs(a,b,m,n);
    // for(int i=0;i<=m;i++){ for(int j=0;j<=n;j++){ cout<<dp[i][j]<<" ";}cout<<endl;}
    string ans="";
    int i=m,j=n;
    while(i>0 && j>0){
        if(dp[i][j] != dp[i-1][j] && dp[i][j] != dp[i][j-1]){
                ans+=a[i-1]; i-=1; j-=1;
            }
        else if(dp[i][j] == dp[i-1][j]){
            i-=1;
        }
        else if(dp[i][j] == dp[i][j-1]){
            j-=1;
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
    // for(int i=m;i>0;i--){ 
    //     for(int j=n;j>0;j--){
            
    //     }
    //     cout<<endl;
    // }
    // return dp[m][n];
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
int main(){
    ll N,K,P,Q=0;
    cin>>N>>K;
    P=N/K;
    if(K%2==0){
        Q=N/(K/2)-P;
    }
    cout<<P*P*P+Q*Q*Q<<endl;
}

Measured memory_bytes: 256
*w=z=[]
s=(2-x=y=gets.to_i)**2
$<.map{f,t=_1.split.map &:to_i
x,y,z,w=y,x,w,z if f>1
z[x-=1]=y-2while x>t
s-=z[t]
x,y,z,w=y,x,w,z if f>1}
p s

Measured memory_bytes: 32328
#include <iostream>

using namespace std;

const int FACE = 6;
int main()
{
    int a[FACE];
    for(int i = 0; i < FACE; i++)
    {
        cin >> a[i];
    }
    string command;
    cin >> command;
    for(int i = 0; i < command.length(); i++)
    {
        int temp;
        switch(command[i])
        {
            case 'N':
                 temp = a[0];
                 a[0] = a[1];
                 a[1] = a[5];
                 a[5] = a[4];
                 a[4] = temp;
                 break;
            case 'E':
                 temp = a[0];
                 a[0] = a[3];
                 a[3] = a[5];
                 a[5] = a[2];
                 a[2] = temp;
                 break;
            case 'W': 
                 temp = a[0];
                 a[0] = a[2];
                 a[2] = a[5];
                 a[5] = a[3];
                 a[3] = temp;
                 break;
            case 'S':
                 temp = a[0];
                 a[0] = a[4];
                 a[4] = a[5];
                 a[5] = a[1];
                 a[1] = temp;
                 break;
        }
    }
    cout << a[0] << endl;
    return 0;
}




Measured memory_bytes: 3180
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

constexpr long long INF64 = 1e18;
 
using Weight=long long;

using Array=vector<Weight>;
using Matrix=vector<Array>;

struct flow{
    int n;
    Matrix g;
    vector<int> itr,level;

    flow(int n):n(n){g.assign(n,Array(n,0));}

    void add_edge(int from,int to,Weight cap){
        g[from][to]+=cap;
    }

    void bfs(int s){
        level.assign(n,-1);
        queue<int>q;
        level[s]=0;
        q.push(s);
        while(!q.empty()){
            int u=q.front();q.pop();
            for(int v=0;v<n;++v){
                if(g[u][v]>0 && level[v]<0){
                    level[v]=level[u]+1;
                    q.push(v);
                }
            }
        }
    }

    Weight dfs(int u,int t,Weight f){
        if(u==t)return f;
        for(int &i=itr[u];i<n;++i){
            if(g[u][i]>0 && level[u]<level[i]){
                Weight d=dfs(i,t,min(f,g[u][i]));
                if(d>0){
                    g[u][i]-=d;
                    g[i][u]+=d;
                    return d;
                }
            }
        }
        return 0;
    }

    Weight dinic(int s,int t){
        Weight ret=0,f;
        while(bfs(s),level[t]>=0){
            itr.assign(n,0);
            while((f=dfs(s,t,INF64))>0)ret+=f;
        }
        return ret;
    }
};

//a,bのGCD
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

    ll n,a,b;cin>>n>>a>>b;
    ll res=0,t;
    for(int i=0;i<n;i++){
        cin>>t;
        if(t<a || b<=t) res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b,c,d;cin >> n >> a >> b >> c >> d;
  ll diff = b-a;
  bool ans = false;
  REP(i,n){
    ll ma = i*d - (n-1-i) * c;
    ll mi = i*c - (n-1-i) * d;
    if(mi<= diff && diff <= ma){
      ans = true;
    }
  }
  if(ans){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}




Measured memory_bytes: 256