akhauriyash/Code-Regression huggingface dataset:
// Marcin Knapik
#include<bits/stdc++.h>

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

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< pair<int, int> , null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)
#define losuj_real(a, b) uniform_real_distribution<long double>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second
 
template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }
  
const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll N = 1e6+7;
const ll T = 1<<20;
const ll BIG_INF = 1e18 + 7;

ll n, m, k, q;

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

    cin >> n;

    vi tab(n);
    for(auto&u:tab)
    	cin >> u;

  	vi dp(n);
  	dp[0] = 0;
  	dp[1] = abs(tab[0] - tab[1]);

  	for(int i = 2; i < n; i++)
  		dp[i] = min(dp[i-1] + abs(tab[i] - tab[i-1]), dp[i-2] + abs(tab[i] - tab[i-2]));

  	cout << dp[n-1] << '\n';
}

Measured memory_bytes: 1024
#include <stdio.h>
#define INF 10000000;

int H, W, c;
char s[110][110] = {};
int d[110][110] = {};
int dx[2] = { 0,1 }, dy[2] = { 1,0 };

int MIN(int a, int b) { return a < b ? a : b; }

int main() {
	scanf("%d %d", &H, &W);
	for (int i = 0; i < H; i++) scanf("%s", s[i]);
	for (int i = 0; i < H; i++)for (int j = 0; j < W; j++)d[i][j] = INF;
	if (s[0][0] == '#')d[0][0] = 1;
	else d[0][0] = 0;
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) for (int k = 0; k < 2; k++) {
		int ny = i + dy[k], nx = j + dx[k];
		if (s[ny][nx] == 0)continue;
		c = 0;
		if (s[i][j] == '.' && s[ny][nx] == '#') c = 1;
		d[ny][nx] = MIN(d[ny][nx], d[i][j] + c);
	}
	printf("%d", d[H - 1][W - 1]);
	return 0;
}

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

using namespace std;

int main(){
    int a, b, c, d, e, f;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    e = a < c ? c : a;
    f = b < d ? b : d;
    cout << (e < f ? f - e : 0) << endl;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}


int main() {
  int n, w, h;
  cin >> n;
  cin >> w;
  cin >> h;

  cout << (n - w + 1) * (n - h + 1) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in(), k = in();
	ll p = [n]() {ll ans = 1; REP(i, n)ans *= 2; return ans; }();
	ll ans = INFLL;
	REP(i, p) {
		ll icp = i, tmp = 1;
		REP(j, n) {
			if (icp % 2 == 0)tmp *= 2;
			else tmp += k;
			icp >>= 1;
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import math

def main():
    a, b = input().split()
    a = int(a)
    if not '.' in b:
        b = int(b) * 100
    elif b[-2] == '.':
        b = int(b.replace('.','') + '0')
    else:
        b = int(b.replace('.',''))

    ans = a * b
    ans = str(ans)[:-2]
    
    print(ans if ans else 0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9136
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

char S[55][55];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i,55)rep(j,55) S[i][j] = '.';

    ll H,W; cin >> H >> W;
    
    rep(i,H){
        string inp; cin >> inp;
        rep(j, W){
            S[i][j] = inp[j];
        }
    }
    
    rep(i,H)rep(j,W){
        bool flag = false;
        if(S[i][j] == '.') continue;
        if(S[i][j] == '#'){
            if(i >= 1) {
                if(S[i-1][j] == '#') flag = true;
            }
            if(j >= 1){
                if(S[i][j-1] == '#') flag = true;
            }
            if(S[i+1][j] == '#') flag = true;
            if(S[i][j+1] == '#') flag = true;
        }
        if(flag == false) {cout <<"No" << endl; return 0;}
    }
    cout <<"Yes" << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
char C;
int main()
{
	cin>>C;
	if((C=='a')||(C=='e')||(C=='i')||(C=='o')||(C=='u'))
	{
		cout<<"vowel"<<endl;
		return 0;
	}
	else
	{
		cout<<"consonant"<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;


void findzero() {
    int ret = 1;
    for (int i = 2; 2*i/2 == i; i *= 10) {
        cout << "? " << i << endl;
        string s;
        cin >> s;
        if (s == "Y") {
            break;
        }
        else ret *= 10;
    }
    cout << "! " << ret << endl;
}
int findbase() {
    for (int i = 100000000; i >= 1; i /= 10) {
        cout << "? " << i << endl;
        string s;
        cin >> s;
        if (s == "Y") {
            return i;
        }
    }
}
void search(LL base) {
    LL left = base;
    LL right = base * 10 - 1;
    while (left < right) {
        LL mid = (left+right) >> 1;
        cout << "? " << mid*10 << endl;
        string s;
        cin >> s;
        if (s == "Y") {
            right = mid;
        }
        else {
            left = mid + 1;
        }
    }
    cout << "! " << left << endl;
}

int main() {
    cout << "? " << 1000000000 << endl;
    string s;
    cin >> s;
    if (s == "Y") {
        findzero();
    }
    else {
        int base = findbase();
        search(base);
    }
    return 0;
}

Measured memory_bytes: 596
N=int(input())
B=list(map(int, input().split())) 
ans=[max(B)]*N
for i in range(N-1):
    if ans[i]>B[i]:
        ans[i]=B[i]
    if ans[i+1]>B[i]:
        ans[i+1]=B[i]
print(sum(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        a[x]++;
    }
    sort(a, a + 200005);
    int ans = 0;
    for(int i = 0; i < 200005 - k; i++){
        ans += a[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int H;
int s[16][8];

int main(){
  while(cin >> H && H){
    rep(i,H) rep(j,5) cin >> s[i][j];
    int res = 0;
    int f = 1;
    while(f){
      f = 0;
      rep(i,H){
	int *n = &s[i][0];
	if(n[0]&&n[0]==n[1]&&n[1]==n[2]&&n[2]==n[3]&&n[3]==n[4]){
	  res += n[0]*5;
	  n[0]=n[1]=n[2]=n[3]=n[4]=0;
	  f = 1;
	}else if(n[0]&&n[0]==n[1]&&n[1]==n[2]&&n[2]==n[3]){
	  res += n[0]*4;
	  n[0]=n[1]=n[2]=n[3]=0;
	  f = 1;
	}else if(n[1]&&n[1]==n[2]&&n[2]==n[3]&&n[3]==n[4]){
	  res += n[1]*4;
	  n[1]=n[2]=n[3]=n[4]=0;
	  f = 1;
	}else if(n[0]&&n[0]==n[1]&&n[1]==n[2]){
	  res += n[0]*3;
	  n[0]=n[1]=n[2]=0;
	  f = 1;
	}else if(n[1]&&n[1]==n[2]&&n[2]==n[3]){
	  res += n[1]*3;
	  n[1]=n[2]=n[3]=0;
	  f = 1;
	}else if(n[2]&&n[2]==n[3]&&n[3]==n[4]){
	  res += n[2]*3;
	  n[2]=n[3]=n[4]=0;
	  f = 1;
	}
      }

      for(int i=H-1;i>=0;i--) rep(j,5){
	  if(s[i][j]) continue;
	  for(int k=i-1;k>=0;k--){
	    if(!s[k][j]) continue;
	    s[i][j] = s[k][j];
	    s[k][j] = 0;
	    break;
	  }
	}
    }    
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str;
    int num, h;
    cin >> str;

    while(str!="-"){
        cin >> num;
        for(int i=0; i<num; i++){
            cin >> h;
            str+=str.substr(0,h);
            str=str.erase(0,h);
        }
        cout << str << endl;
        cin >> str;
    }
}


Measured memory_bytes: 3172
K, X = map(int, input().split())

if X + K > 1000000:
    ans = range(X - K + 1, 1000001)
    print(*ans)
elif X - K < -1000000:
    ans = range(-1000000, X + K)
    print(*ans)
else:
    ans = range(X - K + 1, X + K)
    print(*ans)


Measured memory_bytes: 3060
from collections import deque

h,w = map(int,input().split())
maze = [list(input()) for _ in range(h)]

def dfs():
    ope = [[201]*w for _ in range(h)]
    if maze[0][0] == '.':
        ope[0][0] = 0
    else:
        ope[0][0] = 1

    que = deque([])
    que.append((0,0))

    dx = [0,1]
    dy = [1,0]

    while que:
        (x,y) = que.popleft()
        for i in range(2):
            nx = x + dx[i]
            ny = y + dy[i]
            t = ope[x][y]
            if nx < h and ny < w:
                if ope[nx][ny] == 201:
                    que.append((nx,ny))
                if maze[x][y] == '.' and maze[nx][ny] == '#':
                    ope[nx][ny] = min(ope[nx][ny],t + 1)
                else:
                    ope[nx][ny] = min(ope[nx][ny],t)
    return ope[h-1][w-1]
print(dfs())


Measured memory_bytes: 3436
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e,f,g,h;
    cin >>a>>b>>c>>d;
    cin >>e>>f>>g>>h;
    int t=a+b+c+d;
    int s=e+f+g+h;
    if(s>t){
        cout<<s;
    }
    else{
        cout<<t;
    }
    cout<<endl;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000000
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pi 3.14159
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return power(a*a,n/2);
  else
    return a*power(a*a,n/2);    
}
vector<bool> mark;
void seive(ll N){
    mark.resize(N+1);
  for(ll i=2;i*i<=N;i++){
    if(!mark[i]){
       for(ll j=i*i;j<=N;j+=i){
         mark[j]=1;
       }
      }
  }
}
int main(){
FASTIO
ll x;
cin>>x;
ll x1=100;
int l=0;
while(x1<x){
  x1=(x1/100)+x1;
  l++;
}
cout<<l;
return 0;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int L, R;

int main() {
    cin >> L >> R;

    if (R - L >= 2018) {
        cout << 0 << endl;
        return 0;
    }

    L %= 2019;
    R %= 2019;

    if (L > R) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 10000;
    for (int i = L; i < R; i++) {
        for (int j = i + 1; j <= R; j++) {
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

P = sorted(P)
c1 = bisect.bisect(P, A)
c2 = bisect.bisect(P, B) - c1
c3 = N - c1 - c2
print(min(c1, c2, c3))


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

int main()
{
    int N;
    cin >> N;
    int n[4] = {
        (N / 1000) % 10,
        (N / 100) % 10,
        (N / 10) % 10,
        (N / 1) % 10,
    };

    string op[2] = {"-", "+"};
    for (int i = 0; i < 8; i++)
    {
        bitset<8> b(i);
        int ans = n[0];
        for (int j = 0; j < 3; j++)
        {
            if (b[j])
            {
                ans += n[j + 1];
            }
            else
            {
                ans -= n[j + 1];
            }
        }

        if (ans == 7)
        {
            cout << n[0];
            for (int j = 0; j < 3; j++)
            {
                cout << op[b[j]] << n[j + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 int main() {
   int N, maxA = 0, max2A = 0, count = 0;
   cin >> N;

   vector<int> A(N), As(N);
   rep(i, N) {
     cin >> A.at(i);
     As.at(i) = A.at(i);
   }
   sort(As.begin(), As.end());
   rep(i, N) {
     if (A.at(i) != As.at(N - 1)) cout << As.at(N - 1) << endl;
     else cout << As.at(N - 2) << endl;
   }
 }


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

long long solve(long long N) {
    if (N % 2 == 1) return 0;

    long long res = 0;
    N /= 2;
    while (N) {
        res += N / 5;
        N /= 5;
    }
    return res;
}

int main() {
    long long N; 
    cin >> N;
    cout << solve(N) << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {

	int n, h[100], sum = 0, j = 0, k[100] = {},s = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (;;) {
		int kai = 0;
		for (int i = 0;i < n; i++) {
			if (j == 0 && h[i] > k[i]) {
				s = i;
				j = 1;
			}
			if (j == 1 && h[i] <= k[i]) {
				for (int j = s; j <= i; j++) {
					k[j]++;
				}
				kai++;
				sum++;
				j = 0;
				s = 0;
			}
			if (j == 1 && i == n - 1) {
				for (int j = s; j <= i; j++) {
					k[j]++;
				}
				kai++;
				sum++;
				j = 0;
				s = 0;
			}
		}

		if (kai == 0) {
			cout << sum << endl;
			break;
		}

	}
	return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
ans1,ans2=0,0
if (a-b)%2==0:print((b-a)//2)
else:
    ans1+=a
    tmpa=1
    tmpb=b-a
    ans1+=(tmpb-tmpa)//2

    ans2+=(n-b+1)
    tmpb=n
    tmpa=a+n-b
    ans2+=(tmpb-tmpa)//2
    print(min(ans1,ans2))

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

#define PI 3.141592653589793

int main(void) {
	int flg=0;
	int x, y;

	scanf("%d%d", &x, &y);

	for (int i = 1; i <= x; i++)
	{
		if ((i * 2) + ((x - i) * 4) == y)
		{
			flg = 1;
		}
		if ((i * 4) + ((x - i) * 2) == y)
		{
			flg = 1;
		}
	}
	if (flg == 0)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int ans=0;
int n;
int f(int n){
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(n%i==0) cnt++;
    }
    return cnt;
}
void Solve(){    
    cin>>n;
    for(int i=1;i<=n;i+=2){
        if(f(i)==8){
            ans++;
        }
    }
    cout<<ans<<endl;
}
int main(){
    Solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[] array = new int[6];
		for (int i = 0; i < array.length; i++) {
			array[i] = scan.nextInt();
		}
		String order = scan.next();
		scan.close();
		Dice dice = new Dice(array);
		array = dice.roll(order);
		dice.setNum(array);
		System.out.println(dice.getNumber(0));
	}
}
	

class Dice {
	int[] num = new int[6];
	Dice() {
	}

	Dice(int[] array) {
		for (int i = 0; i < array.length; i++) {
			this.num[i] = array[i];
		}
	}
	
	public void setNum(int[] array) {
		for (int i = 0; i < array.length; i++) {
			this.num[i] = array[i];
		}
	}
	
	public int[] getNum() {
		return this.num;
	}
	
	public int getNumber(int i) {
		return this.num[i];
	}
	
	// ??????????????¢??????????????????
	public int[] roll(String order) {
		int now_1 = 0;	int now_2 = 1;	int now_3 = 2;	int tmp;
		int[] array = getNum();
		char[] check = {'N', 'E', 'S', 'W'};
		for (int i = 0; i < order.length(); i++) {
			for (int j = 0; j < check.length; j++) {
				if (order.charAt(i) == check[j]) {
					switch (j + 1) {
						case 1:
							tmp = now_1;
							now_1 = now_2;
							now_2 = 5 - tmp;
							break;
						case 2:
							tmp = now_1;
							now_1 = 5 - now_3;
							now_3 = tmp;
							break;
						case 3:
							tmp = now_1;
							now_1 = 5 - now_2;
							now_2 = tmp;
							break;
						case 4:
							tmp = now_1;
							now_1 = now_3;
							now_3 = 5 - tmp;
							break;
					}
				}
			}
		}
		int[] cp_array = new int[array.length];
		cp_array[0] = array[now_1]; cp_array[1] = array[now_2];
		cp_array[2] = array[now_3]; cp_array[3] = array[5 - now_3];
		cp_array[4] = array[5 - now_1]; cp_array[5] = array[5 -now_2];
		return cp_array;
	}
}

Measured memory_bytes: 26312
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def pm(X):
    res = {}
    for i in range(2, int(X ** 0.5) + 1):
        if X % i == 0:
            res[i] = 0
            while X % i == 0:
                X //= i
                res[i] += 1
    if X > 1:
        res[X] = 1
    return res


def solve():
    N = Scanner.int()
    M = defaultdict(int)
    for i in range(2, N + 1):
        d = pm(i)
        for k, v in d.items():
            M[k] += v

    ans = 0
    for r in range(2, N + 1):
        for p in range(2, N+1):
            for q in range(p + 1, N + 1):
                if p == r:
                    continue
                if q == r:
                    continue
                if M[r] >= 2 and M[p] >= 4 and M[q] >= 4:
                    ans += 1

    for p in range(2, N + 1):
        if M[p] >= 74:
            ans += 1

    for p in range(2, N + 1):
        for q in range(2, N+1):
            if p == q:
                continue
            if M[p] >= 14 and M[q] >= 4:
                ans += 1
            if M[p] >= 24 and M[q] >= 2:
                ans += 1
    print(ans)


def main():
    # sys.stdin = open("sample.txt")
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 61932
var
  s:ansistring;
  t,len,ans,wei:int64;
function get1(x,y:int64):int64;
begin
        //y=head
  exit((x-1)*9+y);
end;
function get2_1(x:int64):int64;
begin
  exit((x-2)*(x-1) div 2*81);
end;
function get2_2(x,y:int64):int64;
begin
  exit((x-1)*y*9);
end;
function get3(x:int64):int64;
begin
  exit((x-3)*(x-2)*(x-1) div 6*729);
end;
function get2(len:int64;s:string):int64;
var
  anss:int64;
begin
    anss:=get2_1(len)+get2_2(len,ord(s[1])-49);
    wei:=2;
    while (s[wei]='0') and (wei<len) do inc(wei);
    anss:=anss+get1(len-wei+1,ord(s[wei])-48);
    exit(anss);
end;
begin
  readln(s);
  len:=length(s);
  readln(t);
  if (len<t) then begin
  writeln(0);
  exit;
  end;
  if (t=1) then
  begin
    writeln(get1(len,ord(s[1])-48));
  end else if (t=2) then begin
    writeln(get2(len,s));
  end else begin
    wei:=2;
     while (s[wei]='0') and (wei<len) do inc(wei);
    ans:=get2(len-wei+1,copy(s,wei,len));
    ans:=ans+(len-1)*(len-2) div 2*81*(ord(s[1])-49)+get3(len);
    writeln(ans);
  end;
end.


Measured memory_bytes: 128
#include<iostream>
using namespace std;
template<typename T>
T extgcd(T a,T b,T&x,T&y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	T q=a/b;
	T g=extgcd(b,a-q*b,y,x);
	y-=q*x;
	return g;
}
main()
{
	long a,b;cin>>a>>b;
	long x,y;
	extgcd(a,b,x,y);
	cout<<x<<" "<<y<<endl;
}


Measured memory_bytes: 3084
n = int(input())
p_list = [int(i) for i in input().rstrip().split(' ')]

cnt = 0

for i in range(1, len(p_list) -1):
  check_list = [p_list[i-1], p_list[i], p_list[i+1]]
  check_p = p_list[i]
  check_list.sort()
  if check_list[1] == check_p:
    cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef bool boolean;

const int N = 2e5 + 5;

#define pii pair<int, int>

int n, m;
pii seg[N];
int uf[N];
priority_queue<int, vector<int>, greater<int>> Q;
int find(int x) {
	return uf[x] == x ? x : (uf[x] = find(uf[x]));	
}
void unit(int x, int y) {
	x = find(x), y = find(y);
	if (x > y)
		swap(x, y);
	if (x ^ y)
		uf[x] = y;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, l, r; i <= n; i++) {
		scanf("%d%d", &l, &r);
		seg[i] = pii(l, r);
	}
	sort(seg + 1, seg + n + 1);
	uf[0] = 1;
	for (int i = 1; i <= m + 1; i++) {
		uf[i] = i;
	}
	pii *p = seg + 1, *_p = seg + n + 1;
	int ans = 0;
	for (int i = 0; i <= m; i++) {
		if (i && find(i) == i) {
			Q.push(0);
		} else if (i) {
			Q.push(i);
		}
		while (p != _p && p->first == i) {
			int R = p->second;
			boolean suc = false;
			if (!Q.empty()) {
				int tp = Q.top();
				if (tp < R) {
					int p = find(tp);
					if (p <= m) {
						unit(p, p + 1);
						Q.pop();
						Q.push(R);
						ans++;
						suc = true;
					}
				}
			}
			if (!suc) {
				int p = find(R);
				if (p <= m) {
					unit(p, p + 1);
					ans++;
					suc = true;
				}
			}
			p++;
		}
	}
	printf("%d\n", n - ans);
	return 0;
}

Measured memory_bytes: 6520
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,m = map(int,readline().split())

#最も大きなunionの大きさが答え
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#xが属するグループの要素全てを返す
def members(x):
    root = find(x)
    return [i for i in range(n) if find(i) == root]

#全ての根の要素をlistで返す(一個下の関数で使う)
def roots():
    return [i for i,x in enumerate(par) if x < 0]

#グループ数を返す
def group_count():
    return len(roots())

#根をkey,そのグループに含まれる要素をvalueとして全てを辞書型で返す
def all_group_members():
    return {r: members(r) for r in roots()}

#初期化
#根なら-size,子なら親の頂点
par = [-1]*n

AB = []
for i in range(m):
    a,b = map(int,readline().split())
    a,b = a-1,b-1
    unite(a,b)

ans = 0
for i in par:
    if i < 0:
        ans = max(ans,-i)
print(ans)


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll H;
int N;

int main(){
    cin >> H >> N;
    FOR(i,1,N+1)
    {
        int a;
        cin >> a;
        H-=a;
        if(H <= 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int n,q;
vector<ll> c,ans;
vector<vector<int> > node;

void dfs(int st, int cnt) {
	ans[st] = cnt;
	for(int i=0;i<node[st].size();i++) {
		dfs(node[st][i], cnt+c[node[st][i]]);
	}
}

int main(){
	cin >> n >> q;
	c = vector<ll>(n,0);
	node = vector<vector<int> >(n);
	for(int i=0;i<n-1;i++) {
		int a,b;
		cin >> a >> b;
		a--,b--;
		node[a].push_back(b);
	}
	ans = vector<ll>(n,0);
	for(int i=0;i<q;i++)
	{
		int p,x;
		cin >> p >> x;
		p--;
		c[p] += x;
		
	}
	dfs(0, c[0]);
	for(int i=0;i<n;i++)
	{
		if(i!=0) cout << " ";
		cout << ans[i];
	}
	cout << endl;
}

Measured memory_bytes: 22656
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String S = in.readLine();
		int count = 0;
		if (S.charAt(0) == 'R' && S.charAt(1) == 'R' && S.charAt(2) == 'R') {
			count = 3;
		} else if (S.charAt(0) == 'R' && S.charAt(1) == 'R') {
			count = 2;
		} else if (S.charAt(1) == 'R' && S.charAt(2) == 'R') {
			count = 2;
		} else {
			for (int i = 0; i < S.length(); ++i) {
				if (S.charAt(i) == 'R') {
					count = 1;
				}
			}
		}
		System.out.println(count);
	}

	void calc() {
	}

	void showResult() {
	}
}

Measured memory_bytes: 25328
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  long double a,b,c;
  cin>>a>>b>>c;
  if((c-a-b)>2*sqrt(a*b))
  {
    cout<<"Yes";
  }
  else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
4 100000
100000 100000 100000 100000
)");
#define cin input
#endif

int main()
{
	int n, k;
	cin >> n >> k;

	ll mod = 1000000007;

	ll dp[102400] = {};
	ll ps[102400];
	dp[0] = 1;

	REP (i, n)
	{
		int a;
		cin >> a;

		ps[0] = 0;
		REP (j, 102400 - 1)
			ps[j + 1] = ps[j] + dp[j];

		REP (j, 102400)
			dp[j] = (ps[j + 1] - ps[max(j - a, 0)]) % mod;
	}

	cout << dp[k] << endl;

	return 0;
}


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

int main() {
    ll N, x;
    cin >> N >> x;
    vector<int>a(N);
    for (int i = 0; i < N; ++i) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        x -= a[i];
        if(x >= 0) ans++;
    }
    if(x > 0) ans--;
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

int main(){
    int n, k;
    cin >> n >> k;

    vector<vector<vector<long long int>>> dp(n+1, vector<vector<long long int>>(n+1, vector<long long int>(k+2*n+2)));
    dp[0][0][0] = 1;
    for(int i=0; i<n; i++){
        for(int j=0; j<=i; j++){
            for(int odd=0; odd<=k; odd++){

                // 1st pattern : connect
                dp[i+1][j][odd+j*2] += dp[i][j][odd];
                dp[i+1][j][odd+j*2] %= MOD;

                // 2nd pattern : reserve both
                dp[i+1][j+1][odd+(j+1)*2] += dp[i][j][odd];
                dp[i+1][j+1][odd+(j+1)*2] %= MOD;

                // 3rd pattern : reserve one side, use the other side
                dp[i+1][j][odd+j*2] += dp[i][j][odd] * j * 2;
                dp[i+1][j][odd+j*2] %= MOD;

                // 4th pattern : use both sides
                if(j >= 1){
                    dp[i+1][j-1][odd+(j-1)*2] += dp[i][j][odd] * j * j;
                    dp[i+1][j-1][odd+(j-1)*2] %= MOD;
                }
            }
        }
    }
    cout << dp[n][0][k] << endl;
    return 0;
}

Measured memory_bytes: 57196
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
happiness=[LI() for i in range(n)]
dp=[[0]*3 for i in range(n)]
dp[0]=happiness[0]
for i in range(n-1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            dp[i+1][j]=max(dp[i+1][j],dp[i][k]+happiness[i+1][j])
print(max(dp[-1]))
            

    
    



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

int main() {
  int x, y;
  cin >> x;
  for (int i = 10; ; i *= 10){
    y += ( x % i - y ) / ( i / 10 );
    if (x < i)
      break;
  }
  if (x % y == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }
    vector<int> dp(n);
    rep(i, n)
    {
        if (i == 0) {
            dp[i] = 0;
        } else if (i == 1) {
            dp[i] = abs(h[i] - h[i - 1]);
        } else {
            dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b,c,d;
	string s;
	cin>>n>>a>>b>>c>>d>>s;
	a--; b--; c--; d--;

	deque<ll> rock;
	range(i,a,max(c,d))if(s[i]=='#')rock.push_back(i);

	rep(i,rock.size()-1){
		if(rock[i+1]-rock[i]==1){
			puta("No");
			return 0;
		}
	}

	if(c<d){
		puta("Yes");
	}else{
		rock.push_front(b-2);
		rock.push_back(d+2);
		rep(i,rock.size()-1){
			if(rock[i]<b-2 || rock[i+1]>d+2)continue;
			if(rock[i+1]-rock[i]>3){
				puta("Yes");
				return 0;
			}
		}
		puta("No");
	}
	
	return 0;
}

Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; 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 ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;cin >> x;
    FOR(i,1,1000){
        if(360*i%x==0){
            cout << 360*i/x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M; cin >> N >> M; 
	long long X[100010], Y[100010]; 
	for(int i = 0; i < N; i++) cin >> X[i]; 
	for(int j = 0; j < M; j++) cin >> Y[j]; 
	long long sumX = 0; long long sumY = 0; 
	long long P = 1000000007; 
	for(int i = 1; i < N; i++){
		long long cnt = (long long) i * (N - i) % P; 
		sumX += cnt * (X[i] - X[i-1]) % P; 
		sumX %= P; 
	}
	for(int i = 1; i < M; i++){
		long long cnt = (long long) i * (M - i) % P; 
		sumY += cnt * (Y[i] - Y[i-1]) % P; 
		sumY %= P; 
	}
	cout << sumX * sumY % P << endl; 
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,n,minn=500,ans=0;
	bool ok=true;
	cin>>n>>l;
	for(int i=0;i<n;i++)
	{
		if(abs(i+l)<=minn)
		{
		  minn=abs(i+l);
		  if(i+l<0)
		    ok=false;
		  else
		    ok=true;
	    }
		ans+=i+l;
	}
	if(ok==false)
	  minn=0-minn;
	cout<<ans-minn;
	return 0;
}


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

int main() {
	
	int n;
	ll k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	vector<int> f(n);
	rep(i, n) cin >> f[i];
	sort(all(f), greater<int>());
	
	ll l = -1, r = 1e12;
	while(l + 1 < r){
		ll c = (l + r) / 2;
		bool ok = [&]{
			ll s = 0;
			rep(i, n){
				s += max(0LL, a[i] - c / f[i]);
			}
			return s <= k;
		}();
		if(ok) r = c;
		else l = c;
	}
	
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 1792
def main():
    from functools import reduce

    def gcd(a, b):
        return a if b == 0 else gcd(b, a % b)

    N = int(input())
    *a, = map(int, input().split())

    g = reduce(gcd, a)
    print(g)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

int main(){
    int n,q;
    cin>>n>>q;
    queue<string> a;
    queue<int> b;
    string pname[500000];
    int ptime[500000];
    for(int i=0;i<n;i++){
        cin>>pname[i]>>ptime[i];
        a.push(pname[i]);
        b.push(ptime[i]);
    }
    
    int count=0;
    string x;
    int y;
    while(a.size()!=0){
        if(b.front()<=q){
            count+=b.front();
            cout<<a.front()<<" "<<count<<endl;
            a.pop();
            b.pop();
        }
        else{
            b.front()-=q;
            count+=q;
            x=a.front();
            y=b.front();
            a.pop();
            b.pop();
            a.push(x);
            b.push(y);
            
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 9916
#include<bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define hell 1000000007
#define hell1 1000000006
#define pb push_back
#define x first
#define y second
#define MAXL 100005
#define pll pair<ll,ll>
using namespace std;
//vector<ll>prime(15000002,0);
ll mM(ll a,ll b,ll mod){ll res = 0;a %= mod;while(b){if (b & 1)res = (res + a) % mod;a = (2 * a) % mod;b >>= 1;}return res;}
ll fpow(ll x,ll y,ll p){x=x%p;ll res=1;while(y){if(y&1)res=(res*x)%p;res%=p;if(res<0)res=(res+p)%p;y=y>>1;x=(x*x)%p;if(x<0)x=(x+p)%p;x%=p;}return res;}
ll inv(ll n,ll p){return fpow(n,p-2,p);}
ll modmul(ll x,ll y){return (x*y)%hell;}
ll modadd(ll x,ll y){if(x>=hell)x-=hell;if(y>=hell)y-=hell;ll temp=x+y;if(temp>=hell)temp-=hell;if(temp<0)temp = temp+hell;return temp;}
/*void sieve(){
	prime[1] = 1;
	for(ll i=2;i<=15000000;i++)
		if(!prime[i])
			for(ll j=i;j<=15000000;j+=i)
				if(!prime[j])
					prime[j] = i;
}*/
int main(){
	ios
	ll t = 1;
	//cin >> t;
	//sieve();
	while(t--)
	{
		ll n,W;
		cin >> n >> W;
		vector< pll >a(n);
		for(int i=0;i<n;i++)
			cin >> a[i].x >> a[i].y;
		ll V = 0;
		for(int i=0;i<n;i++)
			V+=a[i].y;
		ll dp[n+1][V+1];
		for(int i=0;i<=n;i++)
			dp[i][0] = INT_MAX;
		for(int i=0;i<=V;i++)
			dp[0][i] = INT_MAX;
		dp[0][0] = 0;
		for(int i=1;i<=n;i++)
			for(int j=0;j<=V;j++)
			{
				if(j<a[i-1].y)
					dp[i][j] = dp[i-1][j];
				else
					dp[i][j] = min(dp[i-1][j],dp[i-1][j-a[i-1].y] + a[i-1].x);
			}
		ll ans = 0;
		//for(int i=1;i<=V;i++)
		//	cout << dp[n][i] << " ";
		//cout << "\n";
		for(ll i=1;i<=V;i++)
			if(dp[n][i]<=W)
				ans = max(ans,i);
		cout << ans << "\n";
	}
}


Measured memory_bytes: 79232
#include <iostream>

using namespace std;

int main()
{
  int n,min = 10000000;

  cin >> n;

  for(int i = 1;i < n;i++){
    int a,b;
    int ca = 0,cb = 0;
    a = i;
    b = n - i;

    while(a){
      ca += a % 10;
      a /= 10;
    }

    while(b){
      cb += b % 10;
      b /= 10;
    }

    if(min > ca + cb)
      min = ca + cb;

  }

  cout << min << endl;

  return 0;
}
      


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

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> t(n+1),x(n+1),y(n+1);
	for(int i = 1; i <= n; i++)std::cin >> t[i] >> x[i] >> y[i];
	bool res = true;
	for(int i = 1; i <= n; i++){
		int time = t[i] - t[i-1];
		int flag = std::abs(x[i] - x[i-1]) + std::abs(y[i] - y[i-1]);
		bool f = true;
		if(time < flag)f = false;
		if(flag % 2 != time % 2)f = false;
		res = f;
	}
	std::cout << (res ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long 
int32_t main()
{
   int n; cin>>n;
   int s=0,c=0,mn=-1;
   while(n--){
        int t; cin>>t;
        if(t<0){
            c++;
            t*=-1;
        }
        if(mn==-1)
            mn=t;
            else
            mn=min(mn,t);
         s+=t;
   }
   //cout<<mn<<" "<<s<<endl;
   if(c&1){
       s-=2*mn;
   } 
   cout<<s;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define debug int debug = 0;
#define RREP(i,a) for(int i=a-1;i>=0;i--)
#define rrep(i,a,b) for(int i=a-1;i>=b;i--)
#define printall(n,array) {for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<int, Pi> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int main() {
    int c[3][3];
    int tmp[3][3];
    REP(y, 3){
        REP(x, 3){
            cin >> c[y][x];
            tmp[y][x] = c[y][x];
        }
    }
    int min_, a_min[3], b_min[3];
    int a[3], b[3];
    REP(i, 3){
        a[i] = 0;
        b[i] = 0;
    }
    REP(q,6) {
        VE m;
        REP(i, 3) {
            a_min[i] = min({tmp[i][0], tmp[i][1], tmp[i][2]});
            b_min[i] = min({tmp[0][i], tmp[1][i], tmp[2][i]});
            m.push_back(a_min[i]);
            m.push_back(b_min[i]);
        }
        sort(m.begin(), m.end());
        REP(i, 6) {
            if (m[i]) {
                min_ = m[i];
            }
        }
        debug;
        REP(i, 3) {
            if (min_ == a_min[i]) {
                a[i] = min_;
                REP(j, 3) {
                    tmp[i][j] -= min_;
                }
                break;
            } else if (min_ == b_min[i]) {
                b[i] = min_;
                REP(j, 3) {
                    tmp[j][i] -= min_;
                }
                break;
            }
        }
    }

    bool f = true;
    REP(y, 3)REP(x, 3){
        if(a[y] + b[x] != c[y][x]){
            f = false;
        }
    }
    if(f){
        print("Yes");
    }else{
        print("No");
    }
}

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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int n;
  cin >> n;
  int l[n];
  for (int& i : l)
    cin >> i;

  int count = 0;
  for (int i = 0; i < n; i++) {
    int a = l[i];
    for (int j = i + 1; j < n; j++) {
      int b = l[j];
      if (a == b)
        continue;
      for (int k = j + 1; k < n; k++) {
        int c = l[k];
        if (a == c || b == c)
          continue;
        if (a + b <= c || b + c <= a || c + a <= b)
          continue;
        count++;
      }
    }
  }

  cout << count;
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  // }

  return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
long long int gcd(long long int a,long long int b){
	if(a<b){
		long long int k=b;
		b=a;
		a=k;
	}
	if(a%b==0)return b;
	else return gcd(b,a%b);
}
long long int lcm(long long int a,long long int b){
	return a/gcd(a,b)*b;
}
int main(){
	long long int n;
	scanf("%lld",&n);
	long long int t[n]={};
	long long int ans=1;
	for(long long int i=0;i<n;i++){
		scanf("%lld",&t[i]);
		ans=lcm(ans,t[i]);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
// B - Papers, Please

using namespace std;

int main() {
    int N,i,A;

    scanf("%d",&N);
    for (i = 0;i < N;i++) {
        scanf("%d",&A);
        if (A % 2 == 0) {
            if (A % 3 != 0 && A % 5 != 0)
                break;
        }
    }

    if (i < N)
        printf("DENIED\n");
    else
        printf("APPROVED\n");

    return 0;
}


Measured memory_bytes: 128