akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e5;
int aa[N+2],dp[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,k;cin>>n>>k;
  for(int i=1;i<=n;i++)
    cin>>aa[i];
  for(int i=2;i<=n;i++)
  {
    dp[i]=2e9;
    for(int j=1;j<=k;j++)
    {
      if(i-j<=0)continue;
      dp[i]=min(dp[i],dp[i-j]+abs(aa[i]-aa[i-j]));
    }
  }
  cout<<dp[n]<<endl;
  return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;
int a[100050];
int s[100050];
int gg[100050];

typedef long long LL;
const int N = 100055;
LL fac[N];

void init(LL p = mod)
{
    LL i;
    fac[0] =1;
    for(i =1; i <= 100050; i++)
        fac[i] = fac[i-1]*i % p;
}

LL exp_mod(LL a, LL b, LL p)
{
    LL tmp = a % p, ans =1;
    while(b)
    {
        if(b & 1)  ans = ans * tmp % p;
        tmp = tmp*tmp % p;
        b >>=1;
    }
    return  ans;
}

LL C(LL n, LL m, LL p)
{
    if(m > n)
        return 0;
    return  fac[n]*exp_mod(fac[m]*fac[n-m], p-2, p) % p;//逆元
}

LL Lucas(LL n, LL m, LL p)
{
    if(m ==0)
        return 1;
    return  (C(n%p, m%p, p)*Lucas(n/p, m/p, p))%p;
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int c = 0;
    init();
    for(int i = 1; i <= n + 1; ++i)
    {
        cin >> a[i];
        s[a[i]]++;
        if(s[a[i]] == 2) c = i;
        else gg[a[i]] = i;
    }
    int x = gg[a[c]] + n - c;
    cout << n << endl;
    for(int i = 2; i<=n;++i)
    {
        long long ans = Lucas(n + 1, i , mod);
        ans = ((ans - Lucas(x , i - 1, mod))% mod + mod) % mod;
        cout << ans << endl;
    }
    cout << "1" << endl;
    return 0;
}

Measured memory_bytes: 3200
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define int long long
    # define mo 1000000007
    using namespace std;
    #define goku ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    signed main()
    {
        goku
      int n,m;
      cin>>n>>m;
      map<int,int> mp,mp1;
      int c1=0,c2=0;
      for(int i=0;i<m;i++)
      {
          int x;
          cin>>x;
          string s;
          cin>>s;
          if(mp[x]==0&&s=="WA")
            mp1[x]++;
          if(mp[x]==0&&s=="AC")
            c1++,mp[x]=1;;
      }
      for(auto ii:mp1)
      {
          if(mp[ii.first]==1)
            c2+=ii.second;
      }
      cout<<c1<<" "<<c2;
        return 0;
    }


Measured memory_bytes: 8064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const int MOD = 1000000007;

int main(){
  int N;  cin >> N;
  int maxDigit = to_string(N).length();
  int ans = maxDigit&1? N - pow(10, maxDigit-1)+1 : 0;
  for(int i=1; i<maxDigit; i+=2){
    ans += pow(10, i) - pow(10, i-1);
  }
  cout << ans << endl;
  return 0;
}


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

#define Flash ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define F first
#define S second
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define sz size()
#define mp make_pair
#define y1 asdf
#define rc(x) return cout << x, 0

const long long MXN = 2e3 + 1;
const long long MNN = 1e5 + 1;
const long long MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const long long OO = 1e9 + 500;

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

string s;
ll cnt;

void input(){

    cin >> s;

}

int main() {
    //freopen("output.txt", "r", stdin);
    input();
    stack <int> st;
    for(int i = 0; i < s.sz; i ++){
        if (s[i] == 'S') {
            st.push(1);
        }
        else {
            if (st.empty()) {
                st.push(2);
                continue;
            }
            if (st.top () == 1) st.pop ();
            else st.push(2);
        }
    }cout << st.sz;
    EX;
}


Measured memory_bytes: 1284
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int x= sc.nextInt();
		
		if(x%10==9||90<=x) {
		System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	}
}


Measured memory_bytes: 20948
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
//#include <iomanip.h>
#include <limits.h>
//#include <strstrea.h>
//#include <fstream.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
//#define int64 long long
#define INF  0x3f3f3f3f

using namespace std;

const int maxn = 1e5 + 5;
int n;
ll a[maxn];
ll sum = 0;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%I64d", a + i);
        sum += a[i];
    }
    bool flag = true;
    if (sum % ((ll)n * ((ll)(n + 1)) / 2) != 0) flag = false;
    if (flag) {
        ll d = sum / ((ll)n * ((ll)(n + 1)) / 2);
        ll ad = d % n;
        ll tmp;
        for (int i = 2; i < n && flag; i++) {
            tmp = a[i] -   a[i - 1];
            if (tmp > d) {
                flag = false;
                break;
            }
            while (tmp < 0) tmp += n;
            tmp %= n;
            if (tmp == ad) continue;
            else {
                flag = false;
                break;
            }
        }
    }
    if (flag) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 1152
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s,t;
    cin>>s>>t;
    
    reverse(all(t));
    if(s==t){
        cout1("YES")
    }else{
        cout1("NO")
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

//verified
class date{
public:
    int y,m,d;
    
    date(int _y=0, int _m=0, int _d=0):y(_y),m(_m),d(_d){};
    
    bool isLeap(){ return y%400==0||(y%4==0&&y%100); }
    
    date operator + (const int day)const{
        int days_of_month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
        date t = *this;
        t.d+=day;
        if(  days_of_month[t.m]+(t.isLeap()&&t.m==2) >= t.d  )return date(t.y,t.m,t.d);
        int dom;
        while(  (dom = days_of_month[t.m]+(t.isLeap()&&t.m==2)) < t.d  ){
            t.d -= dom;
            if(t.m==12) t.y++,t.m=1;
            else        t.m++;
        }
        return t;
    }
    
    bool operator > (const date &date)const{
        int ymd1[] = {y,m,d};
        int ymd2[] = {date.y,date.m,date.m};
        rep(i,3){
            if(ymd1[i]>ymd2[i])return true;
            if(ymd1[i]<ymd2[i])return false;
        }
        return false;
    }
    
    bool operator == (const date &date)const{ return (y==date.y && m==date.m && d==date.d); }
    bool operator != (const date &date)const{ return !(*this==date); }
    bool operator <  (const date &date)const{ return ( !(*this>date) && !(*this==date) ); }
};



int main(){
    while(1){
        date ymd[2];
        rep(i,2)cin>>ymd[i].y>>ymd[i].m>>ymd[i].d;
        if(ymd[0].y==-1)break;
        if(ymd[0]>ymd[1])swap(ymd[0],ymd[1]);
        
        int c=0;
        while(ymd[0]!=ymd[1]){
            c++;
            ymd[0] = ymd[0]+1;
        }
        cout<<c<<endl;
    }
    
}

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

#define ll long long

using namespace std;

int main()
{

    ll a,v,b,w,t,x,y;

    cin>>a>>v>>b>>w>>t;


    if(abs(a-b)<=(v-w)*t)
    {
            cout<<"YES\n";
    }

    else
        {

                cout<<"NO\n";
        }


    return 0;

}


Measured memory_bytes: 3536
using System;
using System.Linq;

class Program {
    private static int Main() {
        var W = Console.ReadLine();
        W = W.ToLower();

        int count = 0;

        bool isEnd = false;
        while( !isEnd ) {
            var input = Console.ReadLine();
            isEnd = input.EndsWith( "END_OF_TEXT" );

            input = input.ToLower();

            var values = input.Split( ' ' );
            count += values.Count( _ => _ == W );
        }

        Console.WriteLine( count );

        return 0;
    }
}

Measured memory_bytes: 20884
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 10;

string s;

signed main()
{
	cin>>s;
	bool f=false;
	rep(i,3)if (s[i]=='7')f=true;
	cout<<(f?"Yes":"No")<<endl;
}




Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
	int i, j;
	int data[10];

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

	for (i = 0; i < 10; i++) {
		for (j = i+1; j < 10; j++) {
			if (data[i] < data[j]) {
				int tmp = data[i];
				data[i] = data[j];
				data[j] = tmp;
			}
		}
	}
	for (i = 0; i < 3; i++) {
		printf("%d\n", data[i]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <queue>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int n, a[100100]; 

long long calc() {
    int i = 0, j = n-1;
    deque<int> q;
    for (int k = 0; k < n; k++) {
        int x;
        if (k % 4 == 0 || k % 4 == 3) x = a[i++];
        else x = a[j--];
        if (k % 2 == 0) q.push_front(x);
        else q.push_back(x);
    }

    // for (int x : q) cerr << x << ' '; cerr << endl;
    long long ans = 0;
    for (int i = 0; i < n-1; i++) {
        int x = q.front();
        q.pop_front();
        int y = q.front();
        ans += abs(x-y);
    }
    return ans;
}

int main(int argc, char** argv) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    long long ans;
    sort(a, a+n);
    ans = calc();
    sort(a, a+n, greater<int>());
    ans = max(ans, calc());
    cout << ans << endl;
}


Measured memory_bytes: 1024
n=int(input())

print(0)
zero=input()
if zero=="Vacant":exit()

left,right=0,n
while left<right:
    mid=(left+right)//2
    print(mid)
    ans=input()
    if ans=="Vacant":exit()

    if (ans==zero and mid%2==1) or (ans!=zero and mid%2==0):right=mid+1
    else:left=mid

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

int main() {
  int h, n;
  scanf("%d %d", &h, &n);
  
  vector<int> f(h, -1);
  f[0] = 0;
  int ans = -1;
  for (int i = 0; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    
    for (int j = 0; j < h; j++)
      if (f[j] > -1) {
        int t = j + a;
        if (t < h) {
          if (f[t] == -1 || f[j] + b < f[t])
            f[t] = f[j] + b;
        }
        else {
          if (ans > -1) {
            if (f[j] + b < ans)
              ans = f[j] + b;
          }
          else
            ans = f[j] + b;
        }
      }
  }

  printf("%d\n", ans);

  return 0;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    int x,y;
    cin>>x>>y;
    int a1,b1,c1;
    cin>>a1>>b1>>c1;
    vector<int>a,b,c;
    ffor(i,0,a1)
    {
        int x;
        cin>>x;
        a.pb(x);
    }
    ffor(i,0,b1)
    {
        int x;
        cin>>x;
        b.pb(x);
    }
    ffor(i,0,c1)
    {
        int x;
        cin>>x;
        c.pb(x);
    }
    sort(all(a),greater<int>());
    sort(all(b),greater<int>());
    sort(all(c),greater<int>());
    vector<ll> v;
    ffor(i,0,x) v.pb(a[i]);
    ffor(i,0,y) v.pb(b[i]);
    for(auto i:c) v.pb(i);
    sort(all(v)); reverse(all(v));
    ll ans=0;
    ffor(i,0,x+y) ans+=v[i];
    cout<<ans;
    
    return 0;
}



Measured memory_bytes: 7536
import bisect
N = int(input())
# サイズが下の方が大きくないとダメtop<mid<bottom
tops = sorted(list(map(int, input().split(" "))))
mids = list(map(int, input().split(" ")))
bottoms = sorted(list(map(int, input().split(" "))))
# print(tops)
# print(mids)
# print(bottoms)


# def left_binary_search(check_list, num, left, right):
#     if left > right:
#         return left
#     mid = (left + right) // 2
#     if check_list[mid] >= num:
#         return left_binary_search(check_list, num, left, mid - 1)
#     else:
#         return left_binary_search(check_list, num, mid + 1, right)


# def right_binary_search(check_list, num, left, right):
#     if left > right:
#         return left
#     mid = (left + right) // 2
#     if check_list[mid] > num:
#         return right_binary_search(check_list, num, left, mid - 1)
#     else:
#         return right_binary_search(check_list, num, mid + 1, right)


total_count = 0
for mid in mids:
    # bottom_start_index = right_binary_search(bottoms, mid, 0, N - 1)
    bottom_start_index = bisect.bisect_right(bottoms, mid)
    # top_end_index = left_binary_search(tops, mid, 0, N - 1)
    top_end_index = bisect.bisect_left(tops, mid)
    total_count += ((N - bottom_start_index) * top_end_index)
print(total_count)


Measured memory_bytes: 107868
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

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

struct book {
    ll na=Inf,nb=Inf,nt=Inf;
};
int main() {
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    rep(i,n) cin >> a[i+1];
    rep(i,m) cin >> b[i+1];
    vector<ll> as, bs;
    as.push_back(0);
    bs.push_back(0);
    rep(i,n) as.push_back(as.back() + a[i+1]);
    rep(i,m) bs.push_back(bs.back() + b[i+1]);
    ll ans=0;
    rep(i,n+1) {
        if (as[i] > k)
            break;
        updatemax<ll>(ans, i + upper_bound(bs.begin(), bs.end(), k-as[i]) - bs.begin()-1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10656
program face_produces_unhappiness
  implicit none
  integer :: n, k, nl = 0, nr = 0, sl = 0, sr = 0, i = 1, j = 1
  character(100000) :: s
  read(*,*) n, k
  read(*,*) s
  do while (i <= n)
    do while (s(j:j) == s(i:i))
      j = j+1
    end do
    if (s(i:i) == "L") then
      nl = nl+1
      sl = sl+j-i
    else
      nr = nr+1
      sr = sr+j-i
    end if
    i = j
  end do
  if (nl <= k .or. nr <= k) then
    write(*,'(i0)') n-1
  else
    write(*,'(i0)') sl-nl+sr-nr+2*k
  end if
end program face_produces_unhappiness

Measured memory_bytes: 828
/*
https://open.spotify.com/track/1nEjpWJlqcOsf2ZaRQ3XdW?si=w4JqYIANSL2OFpe68ZaBdQ

In the particularly cold night
Perhaps you couldn’t sleep well
In the bright morning woken up from sleep
You are full of darkness
You, who were so worried for some reason that you
Hugged me tightly and asked for my love

You broke and ruined my everything
My daily life and even my people yeah
I resent you all day
But to leave you I oh I

Don’t worry babe
I love you babe
I’ll be by your side
Maybe

Maybe

Looks about to collapse but remains
And the cycle continues unsteadily
I’m about to give up but when I see you I Oh I

No babe
I love you babe
I’ll hold your hand
Maybe

Maybe
I’ll be by your side
Maybe
I’ll trust you

Stay with me, stay with me
So you won’t think of anything
I’ll stay here pretending to be reluctant
So hold me back
Maybe

Maybe
I will be by your side
Maybe
I’ll trust you

Maybe

*/

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define for1(i, a, b) for(i = a; i <= b; ++i)
#define for0(i, a, b) for(i = a; i < b; ++i)
#define forw1(i, a, b) for(i = a; i >= b; --i)
#define forw0(i, a, b) for(i = a - 1; i >= b; --i)
#define fora(v, a) for(auto v : a)
#define bp __builtin_popcount
#define bpll __builtin_popcountll

using namespace std;
using cd = complex<double>;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<cd> vcd;
typedef vector<ii> vii;
typedef vector<vector<int> > vvi;

const int modd1 = 1e9 + 7, modd2 = 998244353, maxn = 2010, K = 26, inf = 1e9, infll = 1e18;
const double pi = acos(-1);
bitset<maxn * maxn> dp(1);
int n, a[maxn];

void solve(){
    int i, j, k, l, r; cin >> n;
    int s = 0;
    for0(i, 0, n){
    	cin >> a[i]; s += a[i];
	}
	for0(i, 0, n){
		dp |= (dp << a[i]);
	}
	for1(i, (s + 1) / 2, s){
		if(dp.test(i)){
			cout << i; break;
		}
	}
}

signed main() {
    //freopen(".INP", "r", stdin); 
    //freopen(".OUT", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
}


Measured memory_bytes: 5144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
const ll M = 1e9+7;
const int MN = 100100;
vl fac;
unordered_map<ll,ll> dp;
inline ll mul(ll a, ll b) {return (a*b)%M;}
ll bp(ll b, ll p) {
	ll ac = 1;
	while(p) {
		if(p&1) {
			ac = mul(ac,b);
		}
		b = mul(b,b);
		p >>= 1;
	}
	return ac;
}
ll n,k;
ll ds(ll v) {
	if(dp.find(v) != dp.end()) {return dp[v];}
	ll tot = bp(k,(v+1)/2);
	for(int i=0;i<fac.size();i++) {
		if(fac[i] >= v) break;
		if(!(v%fac[i])) {
				tot -= ds(fac[i]);
		}
	}
	tot = ((tot%M)+M)%M;
	return dp[v] = tot;
}
const ll H = 500000004;
int main() {
	scanf("%lld %lld",&n,&k);
	for(int i=1;i*i<=n;i++) {
		if(!(n%i)) {fac.push_back(i);
			if(i != n/i) {
			fac.push_back(n/i);}}
	}
	sort(fac.begin(),fac.end());
	ll res = 0;
	for(int i=0;i<fac.size();i++) {
		if(fac[i]&1) {
			res += ds(fac[i])*fac[i];
		} else {
			res += ((ds(fac[i])*H)%M)*fac[i];
		}
		//printf("oof %d = %lld\n",fac[i],ds(fac[i]));
		res %= M;
	}
	res = ((res%M)+M)%M;
	printf("%lld\n",res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, max ;  
  int min = 1000000000;
  cin >> n;
  for(int i = 0; i < n ; i++){
    int a ;
    cin >> a ;
    if( a < min){
      min = a;
    }
    if( a > max){
      max = a;
    }
  }
  cout << max - min << endl;
    
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def vacation():
    n = int(input())
    dp = [[]]*n
    for i in range(n):
        a, b, c = map(int, input().split())
        if i == 0:
            dp[i] = [a, b, c]
        else:
            dp[i] = [a + max(dp[i-1][1], dp[i-1][2]), b + max(dp[i-1][0], dp[i-1][2]), c + max(dp[i-1][0], dp[i-1][1])]
    print(max(dp[-1]))


if __name__ == '__main__':
    vacation()


Measured memory_bytes: 22772
#include <iostream>
#include <string>
#include <queue>
// #include <pair>
#include <bits/stdc++.h>

using namespace std;

int main(void){

	queue<pair<int,string> > process;

	string tempname;
	int total=0,n,q,temptime;
	cin >> n;
	cin >> q;
	for(int i=0;i<n;i++){
		cin >> tempname;
		cin >> temptime;
		process.push(make_pair(temptime,tempname));
	}

	while(!process.empty()){
		if(process.front().first<=q){
			total += process.front().first;
			cout << process.front().second << " " << total << endl;
		}else{
			process.push(make_pair(process.front().first - q,process.front().second));
		total+=q;
		}
			process.pop();


	}
	return 0;
}

Measured memory_bytes: 6348
#include <stdio.h>
#define SIZ 1400
int m[SIZ][SIZ];
char z[9999999];
int get(){
	static int input_count=0;
	int r=0;
	for(;'0'<=z[input_count]&&z[input_count]<='9';)r=r*10+z[input_count++]-'0';
	input_count++;
	return r;
}
int main(){
	fread(z,1,sizeof(z),stdin);
	int i,j,k,y=get(),x=get(),r,M=0;
	for(j=0;j<y;j++)for(r=i=0;i<x;m[j][i]=r,i++){
		int t=get();
		r=t==0?r+1:0;
	}
	for(r=i=0;i<x;i++)for(j=0;j<y;j++)for(M=x,k=j;k<y;k++){
		if(M>m[k][i])M=m[k][i];
		int z=k-j+1;
		if(M<z)break;
		if(r<z)r=z;
	}
	printf("%d\n",r*r);
	return 0;
}

Measured memory_bytes: 13824
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0

for i in range(len(B)):
    if (A[i] - B[i] == 0) or  (A[i] - B[i] > 0):
        ans = ans + (B[i])
    elif (A[i] - B[i] < 0):
        if (A[i] + A[i+1] <= B[i]):
            ans = ans + (A[i] + A[i+1])
            A[i] = 0
            A[i+1] = 0 
        else:
            RestHP = B[i] - A[i]
            A[i+1] = max(0,(A[i+1] - RestHP))
            ans = ans + B[i]
print(ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

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

    int n;
    cin >> n;
    int F[n+1][11];
    rep(i, n)rep(j, 10) cin >> F[i][j];
    ll P[n+1][11];
    rep(i, n)rep(j, 11) cin >> P[i][j];

    int ttmp[n+1];
    ll ans = 0;
    for(int bit=1; bit < (1<<10); bit++){
        ll tmp = 0;
        fill(ttmp, ttmp+n, 0);
        rep(i, n)rep(j, 10) if((bit & 1<<j) and F[i][j] == 1) ttmp[i]++;
        rep(i, n) tmp += P[i][ttmp[i]];
        if(ans == 0 and tmp != 0){
            ans = tmp;
        }else{
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long

int main() {
  int a , b , c , d ;
  cin >> a >> b >> c >> d;
  
  if(min(b,d) - max(a,c) > 0)
    cout << min(b,d) - max(a,c) ;
  
  else 
    cout << 0;
  


}


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

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

    int count = 0;
    for (int i = A; i < B + 1; i++) {
        string n = to_string(i);
        if (n[0] == n[4] && n[1] == n[3]) {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
//
//  Road2Master.cpp
//  Road2Master
//
//  Created by Rakhman Abdirashov on 12/14/19.
//  Copyright © 2019 Rakhman Abdirashov. All rights reserved.
//
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
 
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer {cout << "NO"; exit(0);}
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)
 
const long long MXN = 2e5 + 10;
const long long MNN = 1e4 + 520;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9;
 
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;

llong n, c, a[MXN], dp[MXN], sz;
pair<llong, llong> kek[MXN];

long double inter(llong a, llong b, llong a1, llong b1){
    return 1.0 * (b - b1) / (a1 - a);
}

long double inter(pair<llong, llong> a, pair<llong, llong> b){
    return inter(a.F, a.S, b.F, b.S);
}

void insert(llong a, llong b){
    while(sz > 1 && inter(a, b, kek[sz - 1].F, kek[sz - 1].S) < inter(kek[sz - 1].F, kek[sz - 1].S, kek[sz].F, kek[sz].S)){
        sz--;
    }
    kek[++sz] = {a, b};
}

llong calc(long double pos){
    llong l = 1, r = sz;
    while(r - l > 1){
        llong m = (l + r) / 2;
        if(inter(kek[m].F, kek[m].S, kek[m - 1].F, kek[m - 1].S) >= pos){
            r = m;
        }else{
            l = m;
        }
    }
    if(inter(kek[l].F, kek[l].S, kek[l - 1].F, kek[l - 1].S) >= pos){
        return kek[l - 1].S + kek[l - 1].F * pos;
    }
    if(inter(kek[r].F, kek[r].S, kek[r - 1].F, kek[r - 1].S) < pos){
        return kek[r].S + kek[r].F * pos;
    }
    return kek[l].S + kek[l].F * pos;
    
}

int main(){
    ios;
    cin >> n >> c;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        dp[i] = INF;
    }
    dp[1] = 0;
    insert(-2 * a[1], a[1] * a[1]);
    for(int i = 2; i <= n; i++){
        dp[i] = calc(a[i]) + c + a[i] * a[i];
        insert(-2 * a[i], dp[i] + a[i] * a[i]);
    }
    cout << dp[n];
}
/*
 dp[5]
 */


Measured memory_bytes: 6528
type
  arr=array[0..200000]of int64;
var
   a,b,c,num,sum:arr;
   i:longint;
   n:longint;
   ans:int64;
   last:longint;
procedure qs(l,r:longint;var a:arr);
var i,j:longint;
    m,t:int64;
begin
  i:=l;
  j:=r;
  m:=a[(l+r)>>1];
  repeat
    while a[i]<m do inc(i);
    while a[j]>m do dec(j);
    if i<=j then
    begin
      t:=a[i];a[i]:=a[j];a[j]:=t;
      inc(i);
      dec(j);
    end;
  until i>j;
  if l<j then qs(l,j,a);
  if i<r then qs(i,r,a);
end;
begin
  read(n);
  for i:=1 to n do
  read(a[i]);
  for i:=1 to n do
  read(b[i]);
  for i:=1 to n do
  read(c[i]);
  qs(1,n,a);
  qs(1,n,b);
  qs(1,n,c);
  last:=1;
  for i:=1 to n do
  begin
    while true do
    begin
      if b[i]<c[last] then
      begin
        num[i]:=n-last+1;
        break;
      end else
      begin
        if last=n+1 then break else inc(last);
      end;
    end;
  end;
  for i:=n downto 1 do
  sum[i]:=sum[i+1]+num[i];
  last:=1;
  for i:=1 to n do
  begin
    while true do
    begin
      if a[i]<b[last] then
      begin
        inc(ans,sum[last]);
        break;
      end else
      begin
        if last=n+1 then break else inc(last);
      end;
    end;
  end;
  writeln(ans);
end.


Measured memory_bytes: 6144
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    s = input()

    lefte= [0] * n
    leftw = [0] * n
    righte = [0] * n
    rightw = [0] * n




    for i in range(n):
        lefte[i] = lefte[i-1] + (s[i] == 'E') if i>=1 else int(s[i] == 'E')
        leftw[i] = leftw[i-1] + (s[i] == 'W') if i>=1 else int(s[i] == 'W')

    for i in range(n-1, -1, -1):
        righte[i] = righte[i+1] + (s[i] == 'E') if i<n-1 else int(s[i] == 'E')
        rightw[i] = rightw[i+1] + (s[i] == 'W') if i<n-1 else int(s[i] == 'W')

    ans = n
    for i in range(n):
        if s[i] == 'E':
            ans = min(ans, leftw[i] + righte[i]-1)
        if s[i] == 'W':
            ans = min(ans, righte[i]+ leftw[i]-1)

    print(ans)


solve()


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

int main() {
	int n = 0;
	int k = 0;
	int sum = 0;

	std::cin >> n;
	std::cin >> k;

	std::vector<int> x(n, 0);

	for (int i = 0; i < n; i++) {
		std::cin >> x.at(i);
	}

	for (int i = 0; i < n; i++) {
		if (x.at(i) <= (k/2) ) {
			sum += x.at(i);
		}
		else {
			sum += k - x.at(i);
		}
	}

	sum = sum * 2;

	std::cout << sum;

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
vs = gets.split(' ').map{|n| n.to_f}.sort
s = 0
vs.each_with_index{|v, i|
  if i == vs.length - 1
    puts v
  else
    vs[i + 1] = (v + vs[i + 1]) / 2
  end
}

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cmath>

using namespace std;

int a[100009];

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int max = a[0];
	for (int i = 1; i < n; i++)
	{
		if (max < a[i])
			max = a[i];
	}

	int t = max / 2;

	int r = 0;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == max)
			continue;
		if (abs(r - t) > abs(a[i] - t))
		{
			r = a[i];
		}
	}

	cout << max << " " << r << endl;

	return 0;
}

Measured memory_bytes: 640
import re
while 1:
	n,m = map(int,raw_input().split())
	if n == m == 0: break
	R = []
	for i in range(n):
		p,s,d = raw_input().replace("?","[0-9]").split()
		r = re.compile(s+d)
		R.append([r,(1 if p[0] == "p" else 0)])
	ans = []
	for i in range(m):
		s,d,name = raw_input().split()
		for r,p in R[::-1]:
			if r.search(s+d):
				if p:ans.append([s,d,name])
				break
	print len(ans)
	for s,d,name in ans:
		print s,d,name

Measured memory_bytes: 5264
#include<iostream>
#include<cstring>
#include<string>
#include<string.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes";
	}
	else 
	{
		cout<<"No";
	}
	return 0;
} 

Measured memory_bytes: 256
def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end
require "prime"
def jo(n,d)
  return 1 if(n == 0)
  return d if(n == 1)
  return (jo(n/2,d)**2 * jo(n-n/2*2,d))%@r
end

@r = 10**9 + 7
@t = na(10**6)
def kaijo2(l,m,n)
  max = [l,m].max
  min = [l,m].min
  ans = 1
  ans2 = 1
  ind2 = 0
  (1..n).each do |i|
    if(i > max)
      ans *= i
    end
    if i <= min
      ans2 *= i
    end
    ans %= @r
    ans2 %= @r
  end
  return (ans * jo(@r-2,ans2))%@r
end

x,y = inp
kaisu1 = nil
kaisu2 = nil

eve_f = 0
if(x%2 == 1)
  x -= 1
  y -= 2
  eve_f = 1
end


#全部2からの差
max_sa = 2*x - y

if(max_sa % 3 != 0)
  puts 0
  exit
end

kaisu2 = max_sa/3
kaisu1 = (x-kaisu2*2)
if(max_sa < 0)
      puts 0
      exit
end
if(kaisu1 < -1)
      puts 0
      exit
end
p kaijo2(kaisu1+eve_f,kaisu2,kaisu1+kaisu2+eve_f)


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, k;

int ceil(int a, int b){
	if(a == 0) return 0;
	return a % b == 0 ? a / b: a / b + 1;
}

int x(int d){
	int cnt = 0;
	while(d > 0){
		cnt++;
		d -= k-1;
	}
	return cnt;
}

int y(int d){
	int cnt  = 0;
	while(d < n-1){
		cnt++;
		d += k-1;
	}
	return cnt;
}

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

	cin >> n >> k;

	if(k == n) {
		cout << 1 << endl;
		return 0;
	}else if(k == 2) {
		cout << n - 1 << endl;
		return 0;
	}

	int a[n];
	rep(i, n) cin >> a[i];

	int p;
	rep(i, n){
		if(a[i] == 1){
			 p = i;
			 break;
		}
	}

	int ans = n;
	rep(i, k){
		ans = min(ans, x(p-k+1+i) + y(p+i) + 1);
	}

	cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
    int n;
    int flag=0;
    scanf("%d",&n);
    int x[201];
    int i,k;
  int count=0;

    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    while(1){
    for(i=0;i<n;i++){
        if(x[i]%2==1){
            flag=1;
        }
    }
    if(flag==1) break;
    for(i=0;i<n;i++){
        x[i]/=2;
    }
    count++;
    }
  printf("%d",count);
}

Measured memory_bytes: 128
import sys
# 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
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

inf = 10**17
mod = 10**9 + 7

s = input()
t = input()

cnt = 0
for i in range(len(s)):
    if s[i] != t[i]:
        cnt += 1

print(cnt)


Measured memory_bytes: 73024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

vector<int> z_algorithm(const string &s) {
    int n = s.size();
    vector<int> prefix(n);
    for(int i = 1, j = 0; i < n; i++) {
        if ((i + prefix[i - j]) < (j + prefix[j])) {
            prefix[i] = prefix[i - j];
        }
        else {
            int k = max(0, j + prefix[j] - i);
            while(((i + k) < n) && (s[k] == s[i + k])) k++;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = n;
    return prefix;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    rep(i, n) {
        auto lcp = z_algorithm(s.substr(i));
        rep(j, n - i) {
            chmax(ans, min(j, (ll)lcp[j]));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

int N;
int P[MAX], used[MAX];

int solve(){
	priority_queue<pair<int,int>, vector<pair<int,int>>,greater<pair<int,int>>> Q;
	
	Q.push(make_pair(0,0));
	
	while(!Q.empty()){
		pair<int,int> p = Q.top(); Q.pop();
		
		if(used[p.second]) continue;
		used[p.second] = true;
		
		if(p.second == N-1) return p.first;
		
		if(P[p.second] == 0){
			for(int i = 1; i <= 6; i++){
				Q.push(make_pair(p.first+1,min(N-1,p.second+i)));
			}
		} else {
			Q.push(make_pair(p.first,p.second + P[p.second]));
		}
	}
	
	return -1;
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>P[i];
	}
	
	cout<<solve()<<endl;
	
	return 0;
}


Measured memory_bytes: 4796
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

ll func(){
    vector<ll> A(2);
    vector<ll> B(2);
    foreach(i,A)i=in();
    foreach(i,B)i=in();
    ll res = -INFLL;
    foreach(i,A){
        foreach(j,B){
            chmax(res,i*j);
        }
    }
    return res;
}

int main(){
    cout << func() << endl;
  return 0;
}


Measured memory_bytes: 3704
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007


int main() {
	int n;
	bool flag = true;
	int cnt = 0;

	cin >> n;
	VI a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	while (flag) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) {
				a[i] /= 2;
			} else {
				flag = false;
			}
		}

		if (flag) {
			cnt++;
		} else {
			break;
		}
	}

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


Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

vi V(5);
int K;

signed main(){

    in(V,K);
    rep(i,5){
        REP(j,i+1,5){
            if(V[j]-V[i]>K){
                out(":(");
                return 0;
            }
        }
    }
    out("Yay!");

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){

	int n,k,x,y;
	cin >> n;
	cin >> k;
	cin >> x;
	cin >> y;

	if( k > n ) cout << n*x << endl;
	else cout << k*x + (n-k)*y << endl;

	return 0;
}

Measured memory_bytes: 256
def insertionSort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1], A[j] = A[j], A[j+1]
            j -= 1
        print(' '.join(map(str, A)))


N = int(input())
A = list(map(int, input().split()))
print(' '.join(map(str, A)))
insertionSort(A, N)



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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec(N);
  
  for (int i = 0; i < N; i++)
    cin >> vec.at(i);
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int sum = 0;
  for (int i = 0; i < K; i++)
    sum += vec.at(i);
  
  cout << sum << endl;
}

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

int main(){
    int M1,D1,M2,D2;
    cin >> M1 >> D1;
    cin >> M2 >> D2;

    if (M1 == M2) cout << 0 << endl;
    if (M1 == M2 -1) cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int N;
int Side[3];

int main()
{
	scanf("%d",&N);
	for(int i= 0;i<N;i++)
	{
		for(int j=0;j<3;j++)
		{
			scanf("%d",&Side[j]);
		}
		sort(Side,Side+3);
		if(Side[2]*Side[2]==Side[1]*Side[1]+Side[0]*Side[0])printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

#define R (long long)(1e9 + 7)
#define INF (long long)(1e16L + 5)
#define ll long long
#define grid vector<vector<ll>>

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << '\n';
    return 0;
}

Measured memory_bytes: 3580
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        int L,R,d;
        int kosuu = 0;
        Scanner scan = new Scanner(System.in);
        L = scan.nextInt();
        R = scan.nextInt();
        d = scan.nextInt();
        if(!(L<=100) || !(R<=100 && L<=R) || !(d<=100)) System.out.print("値を範囲に抑えてね");
        for(int i = L;i<R+1;i++){
            if(i%d==0)kosuu++;
        }
        System.out.print(kosuu);
    }
}

Measured memory_bytes: 35736
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;


void solve(){
    int n;
    string s;
    cin>>n>>s;
    set<int>t;
    ll ans=0;
    rep(i,n){
        if(!t.count(s[i]-'0')){
            t.emplace(s[i]-'0');
            map<char,int>mp;
            vector<int>v;
            for(int j=i+1;j<n;++j){
                v.pb(s[j]-'0');
            }
            set<int>sss,st;
            rep(k,v.size()){
                if(st.count(v[k]))continue;
                st.emplace(v[k]);
                for(int g=k+1;g<v.size();++g){
                    sss.emplace(10*v[k]+v[g]);
                }
            }
            //for(auto x:sss)cout<<x.first<<x.second<<endl;
            ans+=sss.size();
        }
    }
    cout<<ans<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 636