akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[17];
  ll num;
  for(ll i=0;i<17;i++){
    a[i]=n%10;
    n/=10;
    if(n==0){
      num=i;
      break;
    }
  }
  
      
        a[num]--;
  ll c=0;
  for(ll i=0;i<num;i++){
    if(a[i]!=9){
      c=1;
      break;
    }
  }
  if(c==0)a[num]++;
        
        
      
   
 
  
  
  
  cout<<9*num+a[num]<<endl;
}
  

Measured memory_bytes: 256
#include <iostream>

#define ll long long
using namespace std;

const ll M = 998244353;
const ll N = (ll)(1e7+5);

ll fac[N];
ll ifac[N];

ll pow(ll b, ll p) {
  if (!p) return 1;
  if (p%2) return (b*pow(b,p-1))% M;
  ll a = pow(b, p/2);
  return (a*a)%M;
}

void work() {
  fac[0] = 1;
  for (ll i = 1; i < N; i++) {
    fac[i] = (fac[i-1] * i) % M;
  }
  ifac[N-1] = pow(fac[N-1], M-2);
  for (ll i = N-2; i >= 0; i--) {
    ifac[i] = (ifac[i+1] * (i+1)) % M;
  }
}

ll nCk(ll n, ll k) {
  return (((fac[n]*ifac[k]) % M) * ifac[n-k]) % M;
}


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

  ll ret = 0;
  for (ll i = n/2 + 1; i <= n; i++) {
    ret = (ret + 2*nCk(n, i) * pow(2, n-i)) % M;
  }
  ret = (pow(3, n) - ret + M) % M;
  cout << ret << endl;
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int a[50],b[50],c[50];
int n,ma,mb;
int dp[50][405][405];
int f(int i,int j,int k){
    if(i == n){
        if(ma * k == mb * j && j != 0 && k != 0){
            return 0;
        }
        return 1e9;
    }
    if(dp[i][j][k] != -1)return dp[i][j][k];
    int &ans = dp[i][j][k];
    ans = 1e9;
    ans = min(ans,f(i + 1,j,k));
    ans = min(ans,f(i + 1,j + a[i],k + b[i]) + c[i]);
    return ans;

}
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    fast;
    cls(dp,-1);
    cin >> n >> ma >> mb;
    fore(i,0,n)
        cin >> a[i] >> b[i] >> c[i];
    int ans = f(0,0,0);
    if(ans > 1e5)
        cout << "-1\n";
    else
        cout << ans << '\n';
    return 0;   
}

Measured memory_bytes: 32256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 1000000000000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

int start,x;
int ans=0;
int p[60];
int num(int level){
	if(level==1) return 5;
	int ans=2*num(level-1)+3;
	return ans;
}
int saiki(int level,int layer){
	if(level==1){
		if(layer>=5) return 3 ;
		else return layer-1;
	}
	int n=num(level);
	int m=(n-2+1)/2;
	int ret=0;
	if(layer==m+1) ret=saiki(level-1, m-2)+1;
	else if(layer<m+1){ 
		if(layer==1) ret=0;
		else ret=saiki(level-1, layer-1);
	}else{ 
		int w=layer-m-1;
		ret=saiki(level-1, w)+1;
		ret+=p[level-1];
	}
	return ret;
}

signed main(){
	cin>>start>>x;
	p[0]=1;
	for(int i=1; i<=55; i++){
		p[i]=p[i-1]*2+1;
	}
	cout<<saiki(start, x)<<en;
}



Measured memory_bytes: 768
import numpy as np
def main():
    from collections import Counter
    n = int(input())
    a = tuple(map(int, input().split()))
    ans = 0
    c = Counter(a)
    for i in range(n):
        ans += c[i+1]*(c[i+1]-1)//2
    for j in range(n):
        print(ans - c[a[j]] + 1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 34168
N,M = map(int,input().split())
x = set()
y = set()

for m in range(M):
  a,b = map(int,input().split())
  if a==1:
    x.add(b)
  if b==N:
    y.add(a)

if x&y:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

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

using namespace std;

constexpr int inf=1e8;

int main(){
    // input graph
    int n,m;
    cin>>n>>m;
    vector<vector<int>>dist(n,vector<int>(n,inf));
    for(int i=0;i<m;++i){
        int u,v;
        cin>>u>>v;
        cin>>dist[u][v];
    }
    vector<int>f(n);
    for(int i=0;i<n;++i){
        cin>>f[i];
    }
    int T_max;
    cin>>T_max;

    //warshall-floyd
    for(int k=0;k<n;++k){
        for(int i=0;i<n;++i){
            for(int j=0;j<n;++j){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }

    double E_shop=0;
    vector<int>order(T_max);
    vector<bool>order_list(T_max);
    for(int i=0;i<T_max;++i){
        int n_order;
        cin>>n_order;
        for(int j=0;j<n_order;++j){
            int id,dst;
            cin>>id>>dst;
            order[id]=dst;
        }
        // shop-enelgy の更新
        // E_shop
        // to do
        int n_put;
        cin>>n_put;
        if(n_put){
            E_shop=0;
            for(int j=0;j<n_put;++j){
                int put_id;
                cin>>put_id;
                order_list[put_id]=true;
            }
            // target の更新
            // 
            // to do
        }

        // 行動決め(本質)
        //
        cout<<-1<<endl;
        //
        // to do

        string judge;
        cin>>judge;
        if(judge=="NG")return 0;
        int n_achieve;
        cin>>n_achieve;
        for(int j=0;j<n_achieve;++j){
            int achieve_id;
            cin>>achieve_id;
            if(order_list[achieve_id]){
                order_list[achieve_id]=false;
                // target の更新
                // 
                // to do
            }
        }
    }
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int h,w;
bool inside(int x, int y){
   return x >= 1 && x <= h && y >= 1 && y <= w;
}

int32_t main(){
   fast;
   cin >> h >> w;

   int A[2], B[2];
   cin >> A[0] >> A[1];
   cin >> B[0] >> B[1];

   char s[h+1][w+1];
   f(i,1,h+1) f(j,1,w+1) cin >> s[i][j];

   int d[h+1][w+1];
   f(i,0,h+1) f(j,0,w+1) d[i][j] = inf;

   set<pair<int, pii>> q;
   q.insert({0, {A[0], A[1]}});
   d[A[0]][A[1]] = 0;

   while(!q.empty()){
      auto p = *q.begin();
      q.erase(p);

      int x = p.S.F;
      int y = p.S.S;

      if(inside(x+1, y) && s[x+1][y] == '.'){
         if(d[x][y] < d[x+1][y]){
            if(q.find({d[x+1][y], {x+1, y}}) != q.end())
               q.erase({d[x+1][y], {x+1, y}});
            d[x+1][y] = d[x][y];
            q.insert({d[x+1][y], {x+1, y}});
         }
      }

      if(inside(x-1, y) && s[x-1][y] == '.'){
         if(d[x][y] < d[x-1][y]){
            if(q.find({d[x-1][y], {x-1, y}}) != q.end())
               q.erase({d[x-1][y], {x-1, y}});
            d[x-1][y] = d[x][y];
            q.insert({d[x-1][y], {x-1, y}});
         }
      }

      if(inside(x, y+1) && s[x][y+1] == '.'){
         if(d[x][y] < d[x][y+1]){
            if(q.find({d[x][y+1], {x, y+1}}) != q.end())
               q.erase({d[x][y+1], {x, y+1}});
            d[x][y+1] = d[x][y];
            q.insert({d[x][y+1], {x, y+1}});
         }
      }

      if(inside(x, y-1) && s[x][y-1] == '.'){
         if(d[x][y] < d[x][y-1]){
            if(q.find({d[x][y-1], {x, y-1}}) != q.end())
               q.erase({d[x][y-1], {x, y-1}});
            d[x][y-1] = d[x][y];
            q.insert({d[x][y-1], {x, y-1}});
         }
      }

      for(int i=x-2 ; i<=x+2 ; i++){
         for(int j=y-2 ; j<=y+2 ; j++){
            if(inside(i, j) && s[i][j] == '.'){
               if(d[x][y] + 1 < d[i][j]){
                  if(q.find({d[i][j], {i, j}}) != q.end())
                     q.erase({d[i][j], {i, j}});
                  d[i][j] = d[x][y] + 1;
                  q.insert({d[i][j], {i, j}});
               }
            }
         }
      }
   }

   int ans = d[B[0]][B[1]];
   if(ans > 1e7) ans = -1;
   cout << ans << "\n";
}


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

using namespace std;

int main() {
    string O, E;
    cin >> O >> E;

    for (int i = 0; i < (O + E).size(); i++) {
        if (i % 2) cout << E[i / 2];
        else cout << O[i / 2];
    }
    cout << '\n';

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

ll n, m;
vl ad[100001];
ll vis[100001];
ll dp[100001];

void dfs(ll a)
{
	vis[a] = 1;
	ll i;
	fr(i,0,ad[a].size())
		if(!vis[ad[a][i]])
			dfs(ad[a][i]);
	ll mx = 0;
	fr(i,0,ad[a].size())
		mx = max(mx,dp[ad[a][i]]);
	if(ad[a].size() > 0)
		dp[a] = max(1+mx, dp[a]);
}

int main()
{
	FAST;
	ll i,j;
	cin >> n >> m;
	fr(i,0,m)
	{
		ll t1,t2;
		cin >> t1 >> t2;
		ad[t1].pb(t2);
	}
	fr(i,1,n+1)
	{
		if(!vis[i])
			dfs(i);
	}
	ll m = 0;
	fr(i,1,n+1)
		m = max(m, dp[i]);
	cout << m;	
}


Measured memory_bytes: 9344
#include <iostream>

using namespace std;
using ll = long long;
ll MAX = 1e18;

ll a[100000];

int main() {
    int n;
    cin >> n;
    ll res = 1;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << "0\n";
            return 0;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (a[i] > MAX / res) {
            cout << "-1\n";
            return 0;
        }
        res *= a[i];
    }
    cout << res << '\n';
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.9f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

int n, a, b;
ll ps[51][51];
vl v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 0, 51){
    ps[i][0] = 1;
    FOR(j, 1, i+1) ps[i][j] = ps[i-1][j] + ps[i-1][j-1];
  }
  cin >> n >> a >> b;
  FOR(i, 0, n){
    ll _v;
    cin >> _v;
    v.pb(_v);
  }
  sort(rng(v));
  int i=n-a, j=n-a;
  for(; i >= 0; i--)if(v[i] != v[n-a]) break;
  for(; j < n; j++)if(v[j] != v[n-a]) break;
  ll ans = 0;
  if(j == n){
    FOR(k, a, b+1) ans += ps[j-i-1][k];
  }else{
    ans = ps[j-i-1][j-n+a];
  }
  ll su = 0;
  FORR(k, n-1, n-a) su += (double)v[k];
  dout(((double)su)/a);
  printf("%lld\n",ans);
  return 0;
}

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define BR "\n"

int main() {
  int X;
  cin >> X;
  
  int ans = 1;
  rep(i, 2, sqrt(X) + 1) {
    rep(j, 2, 10) {
      if (pow(i, j) > 1000) break;
      if (pow(i, j) <= X) ans = max(ans, (int) pow(i, j));
    }
  }
  cout << ans << BR;
  return 0;
}


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

#define rep(i,a,b)                for(ll i=a;i<b;i++)
#define re(i,b)                for(ll i=0;i<b;i++)
#define repr(i,n)                for(ll i=n-1;i>=0;i--)
#define ll long long
#define ld long double
#define llu long long unsigned
#define pll std::pair<ll, ll> 
#define ppll std::pair<ll, pll>
#define vll std::vector<ll> 
#define vpll std::vector<pll> 
#define vppll std::vector<ppll> 
#define mll std::unordered_map<ll, ll> 
#define mpll std::unordered_map<pll, ll>
#define mppll std::unordered_map<ppll, ll>
#define sll std::set<ll>
#define ff first
#define ss second
#define msll std::multiset<ll>
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define srt(x) sort(all(x))
#define rsrt(x) sort(allr(x))
#define eb emplace_back
#define pb push_back
#define s(yy) ll yy;cin>>yy
#define mod 1000000007
#define maxlong 1e18+5
#define len length()
#define sz size()


/*#################################################### 
#                                                    #
#                     @author                        #
#                  Parth Lathiya                     #
#      https://www.cse.iitb.ac.in/~parthiitb/        #
#                                                    #
####################################################*/

ll n,a,b,c;
ll dpp[4123];

ll dp(ll k)
{
    

    if(k<0)
        return -10000000000000;
    if(dpp[k]!=-1)
        return dpp[k];
    if(k==0)
        return dpp[k]=0;
    return dpp[k]=1+max(dp(k-a),max(dp(k-b),dp(k-c)));
    // return 1+   
}

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef PARTH_LATHIYA_HOME

        freopen("C_in.txt","r",stdin);
    
        ll ttt,bkkk;
        cin>>ttt;
        bkkk=ttt;
        while(ttt--) {
            cout<<"Testcase - "<<bkkk-ttt<<"\n";
    #endif

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

    s(t);
    ll l;
    ll ans=0;
    mll m;
    while(t--)
    {
    	cin>>l;
    	m[l]++;
    }
    for(auto a:m)
    {
    	if(a.ss&1)ans++;
    }
    cout<<ans;


//--------------------------------------------------------------------------------------
    
    #ifdef PARTH_LATHIYA_HOME
        cout<<"\n"; }
    #endif

    return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a, b;
    cin >> n;
    vector<lli> va, vb;

    for (lli i = 0; i < n; i++) {
        cin >> a;
        va.pb(a);
    }
    for (lli i = 0; i < n; i++) {
        cin >> a;
        vb.pb(a);
    }

    vector<lli> mp(n + 2, 0);
    vector<stack<lli>> st(n + 2);
    set<lli> store;

    for (lli i = 0; i < n; i++) {
        if (va[i] == vb[i]) {
            store.insert(va[i]);
            mp[va[i]]++;
            st[va[i]].push(i);
        }
    }

    while (store.size() >= 2) {
        auto it = store.begin();
        a = *it;
        it++;
        b = *it;
        lli mn = min(mp[a], mp[b]);
        mp[a] -= mn;
        mp[b] -= mn;

        while (mn > 0) {
            lli ind1 = st[a].top();
            lli ind2 = st[b].top();
            st[a].pop();
            st[b].pop();
            vb[ind1] = b;
            vb[ind2] = a;
            mn--;
        }

        if (mp[a] == 0) {
            store.erase(store.find(a));
        }
        if (mp[b] == 0) {
            store.erase(store.find(b));
        }
    }

    lli cnt = 0, val;
    for (lli i = 0; i < n; i++) {
        if (va[i] == vb[i]) {
            cnt++;
            val = va[i];
        }
    }

    for (lli i = 0; i < n; i++) {
        if (cnt == 0) {
            break;
        }
        if (va[i] != val && vb[i] != val) {
            lli ind = st[val].top();
            st[val].pop();
            lli tmp = vb[i];
            vb[i] = val;
            vb[ind] = tmp;
            cnt--;
        }
    }

    if (cnt == 0) {
        cout << "Yes" << endl;
        for (lli i = 0; i < n; i++) {
            cout << vb[i] << " ";
        }
        cout << endl;
    } else {
        cout << "No" << endl;
    }
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 151740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >>N;
  vector<int>A(N+1),num(N+1);
  
  for(int i=1;i<N+1;i++){
    cin>>A.at(i);
    num.at(i)=i;
  }
  int count=0;
  for(int i=1;i<N+1;i++){
      if(A.at(A.at(i))==i){
        count++;
      }
  }
  cout<<count/2<<endl;
  return 0;
}

Measured memory_bytes: 1024
class Combination:                                      # 計算量は O(n_max + log(mod))
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):                     # 階乗(= n_max !)の逆元を生成
            f = f * i % mod                             # 動的計画法による階乗の高速計算
            fac.append(f)                               # fac は階乗のリスト
        f = pow(f, mod-2, mod)                          # 階乗から階乗の逆元を計算。フェルマーの小定理より、　a^-1 = a^(p-2) (mod p) if p = prime number and p and a are coprime
                                                        # python の pow 関数は自動的に mod の下での高速累乗を行ってくれる
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):                   # 上記の階乗の逆元から階乗の逆元のリストを生成（＝ facinv ）
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()


    def __call__(self, n, r):  # self.C と同じ
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def H(self, n, r):                                  # (箱区別:〇　ボール区別:×　空箱:〇)　重複組み合わせ nHm
        if (n == 0 and r > 0) or r < 0: return 0
        return self.fac[n+r-1] * self.facinv[r] % self.mod * self.facinv[n-1] % self.mod


def prime_factors(n):       # 戻り値はiterable type
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i             # whileループを進めるごとにイテレータに値を貯め続ける
    if n > 1:
        yield n

from collections import Counter
MOD = 10**9 + 7
N, M = map(int, input().split())
C = Combination(10**6)
A = list(prime_factors(M))
B = Counter(A)
res = 1
for value in B.values():
    res *= C.H(N,value)%MOD
print(res%MOD)

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

class Program
{

    public static void Main( )
    {
        // どこまで調べるか
        int N = 1000;

        int X = int.Parse( Console.ReadLine( ) );
        var power5s = new Dictionary<int, long>( );
        power5s[ 0 ] = 0;
        for ( int i = 1; i <= N; i++ )
        {
            long power5 = 1l * i * i * i * i * i;
            power5s[ i ] = power5;
            power5s[ -i ] = -power5;
        }

        for ( int i = -N; i <= N; i++ )
        {
            long a = power5s[ i ];
            int left = -N - 1;
            int right = N + 1;
            while ( right - left > 1 )
            {
                int mid = ( left + right ) / 2;
                long value = power5s[ mid ];
                if ( value >= a - X ) right = mid;
                else left = mid;
            }


            if ( left == -N - 1 | right == N + 1 )
            {
                continue;
            }

            long b = power5s[ right ];
            if ( a - b == X )
            {
                Console.WriteLine( $"{i} {right}" );
                break;
            }
        }
    }
}







Measured memory_bytes: 27752
#include <bits/stdc++.h>
using namespace std;
int i,n;
int main()
{
	cin>>n;
	for(i=1;i<=7;i++)
	{
		if(pow(2,i)>n)
		{
			cout<<pow(2,i-1);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

int len=0,ans=0;
char S[101];
char T[101];
// fgets(S,sizeof(S),stdin);
scanf("%s",S);
scanf("%s",T);
for (int i = 0; i < 101; i++){
  len++;
  if (S[i]=='\0'){
    len--;
    break;
  }
}
int i = len-1;
while (i>=0)
{
  int k=0,match=0;
  for (int j = 0; j < len; j++){
    k = i+j;
    if (k >= len){ k-=len;}
    if(T[j]==S[k]){
      match++;
    }else{
      break;
    }
  }
  if(match == len) ans=1;
  i--;
}

ans > 0 ? puts("Yes"):puts("No");

return 0;

}

Measured memory_bytes: 1624
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<long long int>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

bool relation[1000][1000];
int twod[1001][1001];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char rev[100001];


int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int N, M;//はんい
int bfs() {
	queue<pair<int, int>> que;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			twod[i][j] = INF;
		}
	}
	que.push(pair<int, int>(sx, sy));
	twod[sx][sy] = 1;
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		if (p.first == gy && p.second == gx) {
			break;
		}
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (1 <= nx && nx <= N && 1 <= ny && ny <= M && maze[nx][ny] != '#'&&twod[nx][ny] == INF) {
				que.push(pair<int, int>(nx, ny));
				twod[nx][ny] = twod[p.first][p.second] + 1;
			}
		}
	}
	return twod[gy][gx];
}
vector <int> g[100100];
int main()
{
	cin >> N >> M;
	std::vector<int> v;
	for (int i = 1; i <= N; i++) {
		v.push_back(i);
	}
	rep(i, 100) {
		rep(j, 100) {
			relation[i][j] = false;
		}
	}
	rep(i, M) {
		cin >> a >> b;
		relation[a][b] = true;
		relation[b][a] = true;
	}
	do {
		if (v[0] != 1) {
			break;
		}
		else {
			okada = true;
		}
		for (int i = 0; i < N - 1; i++) {
			if (relation[v[i]][v[i + 1]]&&okada) {

			}
			else {
				okada = false;
			}
		}
		if (okada) {
			counter++;
		}

	} while (next_permutation(v.begin(), v.end()));
	cout << counter << endl;
}

Measured memory_bytes: 8448
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class mainClass
{
	static Scanner sc;
	public static void Main(string[] args)
	{
		pre();
		while (solve()) {}
	}
	static void pre()
	{
		sc = new Scanner();
		primes = eratosthenes(100010);
		return;
	}
	static List<int> primes;
	static bool solve()
	{
		bool defret = true;
		var mab = sc.nextIntArray();
		if (mab.All((arg) => arg == 0)) return false;
		int m = mab[0], a = mab[1], b = mab[2];
		int ansh = 0, answ = 0, mulmax = 0;
		for (int i = 0; i < primes.Count; i++)
		{
			if (primes[i] * primes[i] > m) break;
			for (int j = i; j < primes.Count; j++)
			{
				if (primes[i] * primes[j] > m) break;
				if ((double)a / (double)b > (double)primes[i] / (double)primes[j]) continue;
				int buf = primes[i] * primes[j];
				if (buf > mulmax)
				{
					mulmax = buf;
					ansh = primes[i];
					answ = primes[j];
				}
			}
		}
		Console.WriteLine("{0} {1}", ansh, answ);
		return defret;
	}
	static List<int> eratosthenes(int n)
	{
		bool[] isPrime = new bool[n + 1];
		for (int i = 0; i < isPrime.Length; i++)
		{
			isPrime[i] = true;
		}
		isPrime[0] = false; isPrime[1] = false;
		List<int> res = new List<int>();
		for (int i = 2; i <= n; i++)
		{
			if (!isPrime[i]) continue;
			res.Add(i);
			for (int j = i * 2; j <= n; j += i)
			{
				isPrime[j] = false;
			}
		}
		return res;
	}
}

public class Scanner
{
	public Scanner() { }
	public string next()
	{
		return Console.ReadLine();
	}
	public int nextInt()
	{
		return int.Parse(next());
	}
	public double nextDouble()
	{
		return double.Parse(next());
	}
	public long nextLong()
	{
		return long.Parse(next());
	}
	public string[] nextArray()
	{
		return next().Split(' ');
	}
	public int[] nextIntArray()
	{
		return Array.ConvertAll(nextArray(), e => int.Parse(e));
	}
	public long[] nextLongArray()
	{
		return Array.ConvertAll(nextArray(), e => long.Parse(e));
	}
	public double[] nextDoubleArray()
	{
		return Array.ConvertAll(nextArray(), e => double.Parse(e));
	}
}

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

int main(){
    int N;  cin >> N;
    string A, B, C; cin >> A >> B >> C;
    int ans = 0;
    for(int i=0; i<N; i++){
        if(A[i]==B[i] && B[i] == C[i]) continue;
        else if(A[i]==B[i] || B[i]==C[i] || C[i]==A[i]) ans+=1;
        else ans+=2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 200000;

int n, c, a[N], b[N];

long long dp[1000][1000];
long long P[1000][1000];

long long pw(long long a, long long b)
{
	if (b == 0)
		return 1;
	if (b % 2)
		return a*pw(a, b - 1) % bs;
	return pw(a*a%bs, b / 2);
}

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin >> n >> c;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++)
	{
		cin >> b[i];
	}

	dp[0][0] = 1;

	for (int i = 1; i <= 400; i++)
	{
		for (int j = 0; j <= 400; j++)
		{
			if (j == 0)
				P[i][j] = 1;
			else
				P[i][j] = P[i][j - 1] * i%bs;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int ad = 0; ad <= c; ad++)
		{
			long long val = 0;
			for (int j = a[i + 1]; j <= b[i + 1]; j++)
			{
				val += P[j][ad];// pw(j, ad);
				val %= bs;
			}
			for (int sum = 0; sum <= c; sum++)
			{
				dp[i + 1][sum + ad] += dp[i][sum] * val%bs;
				dp[i + 1][sum + ad] %= bs;
			}
		}
	}

	cout << dp[n][c] << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 6272
use std::io::Read;

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

fn main() {
    let n: u32 = read();
    println!("{}", n.pow(3));
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li x[111];
li y[111];

int main() {
    li n, m;
    cin >> n >> m >> x[0] >> y[0];
    li mx = x[0];
    rin{
        cin >> x[i + 1];
        mx = max(mx, x[i + 1]);
    }
    li my = y[0];
    rep(j, m) {
        cin >> y[j + 1];
        my = min(my, y[j + 1]);
    }
    cout << (mx < my ? "No War" : "War") << endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        N: i64,
    }

    let mut q: Vec<i64> = Vec::new();
    q.push(357);
    q.push(375);
    q.push(537);
    q.push(573);
    q.push(735);
    q.push(753);

    for digit in 4..=9 {
        // 3^digit通り
        let mut stack: Vec<Vec<char>> = Vec::new();
        stack.push(vec!['3']);
        stack.push(vec!['5']);
        stack.push(vec!['7']);
        while !stack.is_empty() {
            let state = stack.pop().unwrap();

            if state.len() == digit {
                let mut contains_three = false;
                let mut contains_five = false;
                let mut contains_seven = false;

                for i in 0..digit {
                    if state[i] == '3' {
                        contains_three = true;
                    }
                    if state[i] == '5' {
                        contains_five = true;
                    }
                    if state[i] == '7' {
                        contains_seven = true;
                    }
                }

                if contains_three && contains_five && contains_seven {
                    // OK
                    let num_s: String = state.iter().collect();
                    let num: i64 = num_s.parse().unwrap();
                    q.push(num);
                }
            } else {
                let mut s3 = state.clone();
                s3.push('3');
                stack.push(s3);

                let mut s5 = state.clone();
                s5.push('5');
                stack.push(s5);

                let mut s7 = state.clone();
                s7.push('7');
                stack.push(s7);
            }
        }
    }

    q.sort();

    let mut ans = 0;
    for &i in q.iter() {
        if i <= N {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2328
#include <stdio.h>

int main(){
    int q;
    scanf("%d", &q);
    for (int n=0; n<q; n++) {
        char x[1010], y[1010];
        int lenx, leny;
        scanf("%s%n", x, &lenx);
        scanf("%s%n", y, &leny);
      	lenx--; leny--; // 改行文字分
        int dp[lenx + 1][leny + 1];
        // init
        for (int i=0; i<lenx+1; i++) dp[i][0]=0;
        for (int j=0; j<leny+1; j++) dp[0][j]=0;
        // dp
        for (int i=0; i<lenx; i++) {
            for (int j=0; j<leny; j++) {
                if (x[i]==y[j]) dp[i+1][j+1]=dp[i][j]+1;
                else dp[i+1][j+1]=(dp[i+1][j]>dp[i][j+1])?dp[i+1][j]:dp[i][j+1];
            }
        }
        printf("%d\n", dp[lenx][leny]);
    }
    return 0;
}


Measured memory_bytes: 5644
<?php
  fscanf(STDIN,"%d",$n);
  for($i=0;$i<$n;$i++){
    fscanf(STDIN,"%s %d",$s,$p);
    $a[]=array($s, -$p, $i);
  }
  sort($a);
  for($i=0;$i<$n;$i++)
    echo $a[$i][2]+1 ."\n";


Measured memory_bytes: 4604
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {

    zeus();

    int n; cin >> n;

    int a[n + 1];

    forn(i, 1, n + 1) {
        cin >> a[i];
    }
    int count = 0;

    forn(i, 1, n + 1) {
        if (i % 2 == 1 && a[i] % 2 == 1) {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3652
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long K = sc.nextInt();
        long sum = 0;
        for (long i = Math.min(K, N + 1); i <= N + 1; i++) {
            long start = (0 + i - 1) * i / 2;
            long end = (N + N - i + 1) * i / 2;
            sum += (end - start + 1);

        }
        System.out.println(sum % 1000000007);
    }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  
  vector<int> d(k);
  vector<int> ansv(n,1);
  for(int i = 0; i < k; i++){
    cin >> d.at(i);
    vector<int> a(d.at(i));
    for(int j = 0; j < d.at(i); j++){
      cin >> a.at(j);
    }
    
    for(int j = 0; j < d.at(i); j++){
      ansv.at(a.at(j)-1) = 0;
    }
  }
  int ans = 0;
  
  for(int i = 0; i < n; i++){
    ans += ansv.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
S=input()
N=len(S)
n=N-1

ans=0
for b in range(2**n):
    pre=0
    for i in range(n):
        if b>>i&1==1:
            s=S[pre:i+1]
            ans+=int(s)
            pre=i+1
    ans+=int(S[pre:])
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>


int main(){
int n;
int l[1000],r[1000];
int i;
int count=0;

scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d%d",&l[n],&r[n]);
count+=r[n]-l[n]+1;
}
printf("%d",count);
    return(0);
}

Measured memory_bytes: 128
#include <iostream>
 
using namespace std;
 
int main()
{
	int N;
	cin >> N;
 
	float total = 0;
	for(int i=0;i<N;i++){
		float a;
		cin >> a;
		total += (1.0 / a);
	}
 
	cout << 1.0 / total << endl;
 
}
 

Measured memory_bytes: 3788
from collections import deque

S = deque(input())
q = int(input())
Q = [list(map(str, input().split())) for _ in range(q)]

flip = False

for qi in Q:
    if int(qi[0]) == 1:
      flip = not flip
    else:
      f = int(qi[1]) 
      c = qi[2]
      if flip:
        f = 3-f    
      if f == 1:
        S.appendleft(c)
      else:
        S.append(c)

if flip:
    S.reverse()
print(''.join(S))

Measured memory_bytes: 44532
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        long a = readLong(), b = readLong(), c = readLong(), d = readLong();
        long ac = a * c, ad = a * d, bc = b * c, bd = b * d;
        System.out.print(Math.max(Math.max(ac, ad), Math.max(bc, bd)));
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32348
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const int MOD = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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






int n;

void input(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    
    cin >> n;
     
}

 

void solve(){
    
    if(n%2==0) cout << n/2 - 1 << endl;
    else cout << n/2 << endl;
    
}





signed main() {
    
    input();
    solve();
    return 0;
}



Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

ll g(ll C,ll D){
  ll X,tmp,r;
  X = C*D ;
 
  /* 自然数 a > b を確認・入替 */
  if(C<D){
    tmp = C;
    C = D;
    D = tmp;
  }
  ll c=C;
  ll d=D;
  /* ユークリッドの互除法 */
  r = C % D;
  while(r!=0){
    C = D;
    D = r;
    r = C % D;
  }
  
  ll lcm=X/D;
  return lcm;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  ll ans=0;
  ll lcm =g(C,D);

  ll numb=B/C+B/D-B/lcm;
  ll numa=(A-1)/C+(A-1)/D-(A-1)/lcm;
  cout<<B-numb-A+numa+1<<endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define exf(x)	 for(auto&& tmp : x) { cout << tmp << endl; }	// 拡張for
#define PI 3.14159265358979323846264338327950288
const int MOD{ int(1e9 + 7) };	// = 1000000007
const int inf{ 2100000000 };	// = 2100000000 (MAX:2147483647)
typedef long long ll;
using namespace std;

// -------------------------------------------------- //
// ------------------ ここから本編 ------------------ //
// -------------------------------------------------- //

// ------------------ ベクター合計 ------------------ //

int sumVec(vector<int> v) {
	int sum = 0;
	for (size_t i = 0; i < v.size(); i++) sum += v[i];
	return sum;
}


int main(void) {

	int N; cin >> N;
	vector<int> B(N - 1); rep(i, N - 1) cin >> B[i];
	vector<int> ans(N - 1, 0);
	ans[0]++;
	ans[N - 2]++;

	rep(i, N - 1) {
		if (i == 0) continue;
		if (B[i - 1] < B[i]) ans[i - 1]++;
		else ans[i]++;
	}
	
	ll X = 0;
	rep(i, N - 1) X += ans[i] * B[i];
	
	cout << X << endl;
	return 0;
}


Measured memory_bytes: 3600