akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
#include <stack>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

class Graph{
public:

Graph(long long int o_size){
    graph_size=o_size;
    node.resize(graph_size,0);
    edge.resize(graph_size);
}

long long int add_edge(long long int a,long long int b){
    edge[a].push_back(b);
    edge[b].push_back(a);
        
    return a+b;
}

long long int node_add(long long int i,long long int a){
    node[i]+=a;
    return node[i];
}

void dfs(long long int start){
    vector<bool> checked(graph_size,false);
    stack<long long int> st;
    st.push(start);
    while(st.size()){
        long long int where = st.top();
        //cout << "Unko" << endl;
        st.pop();
        checked[where] = true;

        node[where]++;
        
        
        
        //cout << where << endl;
        for(auto x:edge[where]){
            if(checked[x]==false){
                st.push( x);
               
            }
        }
        
    }

}

void print(long long int n){
REP(i,n){
    if(node[i]==0){
        cout << "NO" << endl;
        return;
    }
}
cout << "YES" << endl;
}


private:
vector<vector<long long int>> edge;
vector<long long int> node;
long long int graph_size;

};

int main(){

    long long int n,m,tmpa,tmpb;
    cin>>n>>m;
    Graph graph(n+m);
    REP(i,n){

        scanf("%lld",&tmpa);
        REP(j,tmpa){
            scanf("%lld", &tmpb);
            graph.add_edge(i,n+tmpb-1);
        }
    }

    graph.dfs(0);
    graph.print(n);

    return 0;
}


Measured memory_bytes: 11252
import java.util.*

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
//    val p = mutableListOf<Int>()
//    val s = mutableListOf<Int>()
    val c = Array(n) {0}
    val w = Array(n) {0}
    (1..m).forEach {
        val i = sc.nextInt()
        //p.add(sc.nextInt())
        if (sc.next() == "WA") {
            if (c[i - 1] == 0) {
                w[i - 1] += 1
            }
        } else {
            c[i - 1] = 1
        }
    }
    (0 until n).forEach {
        w[it] *= c[it]
    }
    print("${c.sum()} ${w.sum()}")
}


Measured memory_bytes: 72848
n, m = map(int, input().split())

g = [[i] for i in range(n)]

for _ in range(m):
    u, v = map(lambda x: int(x) - 1, input().split())
    g[u].append(v)
    g[v].append(u)

q = int(input())
c = [None] * q
dp = [[-1 for j in range(n)] for i in range(11)]
for i in range(q):
    v, d, c[i] = map(int, input().split())
    dp[d][v - 1] = i
 
for i in reversed(range(1, 11)):
    dp[i - 1] = [max(dp[i - 1][u], max(dp[i][v] for v in g[u])) for u in range(n)]

for i in range(n):
    if dp[0][i] == -1:
        print('0')
    else:
        print(c[dp[0][i]])

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

int main() {
  string A, B, C;
  int a, b;
  cin >> A >> B >> a >> b >> C;
  if (A==C) cout << a-1 << " " << b;
  else cout << a << " " << b-1;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
L=max(a)+1
b=[0]*L

for i in a:
    b[i]+=1

ans=0

if L<=2:
    print(sum(b))
else:    
    for p in range(L-2):
        ans = max(ans,b[p]+b[p+1]+b[p+2])

    print(ans)


Measured memory_bytes: 14008
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int m= sc.nextInt();
int f= sc.nextInt();
int r= sc.nextInt();

if (m == -1 && f == -1 && r==-1) break;

if(m==-1||f==-1)System.out.println("F");
else if(m+f>=80)System.out.println("A");
else if(m+f>=65)System.out.println("B");
else if(m+f>=50)System.out.println("C");
else if(m+f>=30){
    if(r>=50)System.out.println("C");
    else System.out.println("D");
}
else System.out.println("F");
}
}
}




Measured memory_bytes: 26212
import Data.Sequence((|>),(<|),ViewR(..))
import qualified Data.Sequence as Sq
import Data.Map ((!))
import qualified Data.Map as M
import Data.Bool

main=readLn>>=print.solve

solve :: Int -> Int
solve k = go (M.fromList$(1,1):zip(0:[2..k-1])(repeat 100)) (Sq.fromList[1]) ! 0
  where
  go :: M.Map Int Int -> Sq.Seq Int -> M.Map Int Int
  go map seq
   | seq == Sq.empty = map
   | otherwise = go newMap newSeq
    where
    newMap = doif (M.insert p0 len) update0 $ doif (M.insert p1 (len+1)) update1 map
    newSeq = doif (|> p0) update0 $ doif (p1 <|) update1 seq'
    (update0,update1) = (eval 0 p0, eval 1 p1)
    eval d p = (len+d) < map!p
    len = map!n
    (seq' :> n) = Sq.viewr seq
    (p0,p1) = (n*10`mod`k, (n+1)`mod`k)
    doif = bool id


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

typedef long long ll;
typedef unsigned long long ull;

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

  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
  }

  vector<vector<ll>> dp(n, vector<ll>(3, INT64_MAX));
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for (ll i = 1; i < n; ++i) {
    dp[i][0] = max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
    dp[i][1] = max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
    dp[i][2] = max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);
  }

  cout << max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]) << endl;

  return 0;
}

Measured memory_bytes: 8064
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll X, K, D;
    in3(X, K, D);

    X = abs(X);

    ll L = X / D;

    if (L >= K)
    {
        X -= K * D;
    }
    else
    {
        X -= L * D;
        K -= L;

        if (K % 2 == 1) X = abs(X - D);
    }

    outl(X);

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

template <class T, class U>
ll euclid_gcd(T a, U b){
    if(a < b)return euclid_gcd(b,a);
    ll r;
    while((r = a%b)){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll a,b; cin >> a >> b;
    ll g = euclid_gcd(a,b);
    cout << (a/g) * (b/g) * g << endl;
}

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

typedef long long int ll;

const int MX = 1e5+7;

vector<int> g[MX];
void eadd(int u, int v)
{
  g[u].push_back(v);
  g[v].push_back(u);
}

ll mod, dp[MX], ans[MX], magic[MX];

void dfsDp(int u=1, int p=-1)
{
  dp[u] = 1;
  for(int v: g[u]) if(v != p)
  {
    dfsDp(v, u);
    dp[u] = dp[u] * (dp[v] + 1) % mod;
  }
}

void dfsAns(int u=1, int p = -1)
{
  ans[u] = dp[u] * magic[u] % mod;
  //~ cerr << "magic[" << u << "] = " << magic[u] << endl;
  
  ll cur = 1ll;
  for(int v: g[u]) if(v != p) 
  {
    magic[v] = cur;
    cur = cur * (dp[v] + 1) % mod;
  }
  cur = 1ll;
  for(int j=g[u].size()-1;j>=0;--j) if(g[u][j] != p) 
  {
    int v = g[u][j];
    magic[v] = magic[v] * cur % mod;
    cur = cur * (dp[v] + 1) % mod;
  }
  
  for(int v: g[u]) if(v != p) magic[v] = (magic[v] * magic[u] % mod + 1) % mod;
  
  //~ cerr << "magic[" << u << "] = " << magic[u] << endl;
  
  for(int v: g[u]) if(v != p) dfsAns(v, u);
}

int main()
{
  int n;
  scanf("%d%lld", &n, &mod);
  
  for(int i=1;i<n;++i)
  {
    int x, y;
    scanf("%d%d", &x, &y);
    eadd(x, y);
  }
  
  magic[1] = 1;
  dfsDp();
  dfsAns();
  
  for(int i=1;i<=n;++i) printf("%lld\n", ans[i]);
  //~ for(int i=1;i<=n;++i) printf("%d: %lld\n", i, magic[i]);
  
  return 0;
}


Measured memory_bytes: 13440
#include<cstdio>
#include<cmath>

int main(){
    double r;
    scanf("%lf",&r);

    double area = M_PI * r * r;
    double circumference = 2.0 * M_PI * r;

    printf("%.5f %.5f\n",area,circumference);
    return 0;
} 


Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define ll long long 
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define endl "\n"
#define dd double
const int INF = INT_MAX;
#define all(x) x.begin(),x.end()
#define mod 1000000007
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c,d;
    cin>>a>>b>>c>>d;
    int flg=0;
    while(a>0)
    {
    c= c-b;
    a = a-d;
    if(c<=0)
    {
        cout<<"Yes"<<endl;
        flg++;
        break;
    }
    }
    if(flg==0)
    {
         cout<<"No"<<endl;
    }

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> A(26,50);//aの出現回数=A[0]…zの出現回数=A[25]とする
    rep(i,n){
        string S;
        cin>>S;
        vector<int> B(26,0);
        for(auto c:S) B[c-'a']++;//Sを1文字ずつカウントする
        rep(i,26) A[i]=min(A[i],B[i]);//各文字の出現回数をAに入れる
    }
    rep(i,26){
        rep(j,A[i]){
            cout<<(char)(i+'a');//a~zをA[i]回出力
        }
    }
    cout<<endl;
}

Measured memory_bytes: 3604
module Main where

toInt :: String -> Int
toInt s = read s :: Int

strToIntList :: String -> [Int]
strToIntList = map toInt . words

getIntList :: IO [Int]
getIntList = getLine >>= return . strToIntList

main :: IO ()
main = do
  getLine 
  ab <- getIntList
  print . truncate . logBase 2 . fromIntegral $ foldl gcd 0 ab

Measured memory_bytes: 1020
def dig(u, edges, visited, reachable)
  if visited[u]
    return reachable[u]
  end
  visited[u] = 1
  reachable[u] = edges.size == 0 ? false : edges[u].keys.any?{ |v| dig(v, edges, visited, reachable) }
end

N,M = gets.split.map &:to_i
edges = (0..N).map{ {} }
infty = 0
M.times{
  a,b,c = gets.split.map &:to_i
  edges[a][b] = -c
  infty += c.abs
}

reachable = Array.new(N+1,false)
reachable[N] = true
visited = { N => 1 }
dig(1, edges, visited, reachable)

usable_edges = edges.map{ |es|
  h = {} 
  es.each{ |v,c|
    h[v] = c if reachable[v]
  }
  h
}

vs = (0..N).map{ { distance: infty, predecessor: nil } }
vs[1][:distance] = 0
M.times{
  usable_edges.each_with_index{ |h,u|
    h.each{ |v,c|
      if vs[v][:distance] > vs[u][:distance] + c
        vs[v][:distance] = vs[u][:distance] + c
        vs[v][:predecessor] = u
      end
    }
  }
}

usable_edges.each_with_index{ |h,u|
  h.each{ |v,c|
    if vs[u][:distance] + c < vs[v][:distance]
      puts "inf"; exit
    end
  }
}

p -vs[N][:distance]



Measured memory_bytes: 6524
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    bool ans = b-a == c-b;

    cout << (ans? "YES" : "NO") << endl;
}

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

typedef long long int64;
#define REP(i, n) for(int64 i=0;i<(int64)(n);i++)
#define REPD(i, n) for(int64 i=(int64)(n)-1;i>=0;i--)
#define FOR(i, a, b) for(int64 i=(a);i<=(b);i++)
#define FORD(i, a, b) for(int64 i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int64)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define GSORT(x) sort(ALL(x), greater<int64>());
#define SUM(x) accumulate(ALL(A), 0);

template<class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

using namespace std;

void Main() {
	int64 N;
	//cin >> N;
	N = 3;
	vector<int64> A(N, 0);
	for (int64 i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(ALL(A));
	REP(i, N) {
		cout << A[i];
		if (i != N - 1)
			cout << " ";
	}
	cout << endl;
	return;
}

int main() {
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}



Measured memory_bytes: 3236
row = input().split()
N = int(row[0])
A = int(row[1])
B = int(row[2])
ans = 0
for i in reversed(range(A,N+1)):
    temp = i
    order = []
    for j in reversed(range(0, 5)):
        order.append(int(temp / (10**j)))
        temp = temp - int(temp / (10**j))*10**j
    if A <= sum(order) <= B:
        ans += i
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

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

  std::vector<int> s1;
  std::vector<int> s2;

  int x = 0;
  while (8 * x < 100 * A)
    x += 1;
  while (8 * x < 100 * A + 100) {
    s1.push_back(x);
    x += 1;
  }

  x = 0;
  while (10 * x < 100 * B)
    x += 1;
  while (10 * x < 100 * B + 100) {
    s2.push_back(x);
    x += 1;
  }

  // std::cout << "s1: " << s1 << std::endl;
  // std::cout << "s2: " << s2 << std::endl;


  int res = -1;
  bool found = false;
  for (auto v1 : s1) {
    for (auto v2 : s2) {
      if (v1 == v2) {
        res = v1;
        found = true;
        break;
      }
    }
    if (found)
      break;
  }

  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    ll n;

    cin >> n;

    n--;

    ll ans = (n*(n+1))/2LL;

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#16:50
n,m = map(int,input().split())
a = []
for _ in range(m):
  x,y = list(map(int,input().split()))
  x -= 1
  y -= 1
  a.append([x,y])
a.reverse()
scr = n * (n-1) // 2
pre = [-1 for _ in range(n)]
cnt = [1 for _ in range(n)]
ans = []
for i in range(m):
  ans.append(scr)
  X,Y = a[i]
  while pre[X] != -1:
    X = pre[X]
  while pre[Y] != -1:
    Y = pre[Y]
  x,y = min(X,Y), max(X,Y)
  if x != y:
    scr -= cnt[x] * cnt[y]
    pre[y] = x
    cnt[x] = cnt[x] + cnt[y]
  #print(pre)
  #print(cnt)
ans.reverse()
for z in ans:
  print(z)

Measured memory_bytes: 26796
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VI x(3);
    REP(i,3) cin >> x[i];
    VI a(n);
    REP(i,n) a[i] = in();
    int ans = 1e9;
    REP(mask,1<<(2*n)){
        int tmp = 0;
        VI s(3);
        int m = mask;
        REP(i,n){
            int x = (m & 3);
            m >>= 2;
            if (x == 0) continue;
            x--;
            if (s[x] > 0) tmp += 10;
            s[x] += a[i];
        }
        REP(i,3){
            if (s[i] == 0) tmp = 1e9;
            tmp += abs(x[i] - s[i]);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//Rr+Gg+Bb==Nなる非負整数(r, g, b)の組を求める。
#include <bits/stdc++.h>
using namespace std;
int main()  {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int ans = 0;
for (int i = 0; i <= 3000; i++)  {
  for (int j = 0; j <=3000; j++)  {
    int s = N - i*R - j*G;
    if( s>=0 && s<= 3000 && s%B==0) ++ans;
    }
  }

cout << ans << endl;

}

Measured memory_bytes: 256
gets
l=gets.split.map{|c|[c.to_i]}
i=0
l.sort.map{|a|a[0]=i+=1}
b=[s=0]*(1+r=l.size)
l.reverse_each{|n,|i=n;(s+=b[i];i&=i-1)while i>0;(b[n]+=1;n+=n&-n)until n>r}
p s

Measured memory_bytes: 32616
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

string A[] = {
    "dreamer",
    "eraser",
    "dream",
    "erase"
};
string s;
int dp[100000];

int f(int i)
{
    if (i == s.size())
        return 1;

    int& sol = dp[i];
    if (sol != -1)
        return sol;

    sol = 0;
    for (int j = 0; j < 4; ++j)
        if (s.substr(i, A[j].size()) == A[j])
            sol = max(sol, f(i + A[j].size()));
    return sol;
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    memset(dp, -1, sizeof dp);
    cout << (f(0) ? "YES" : "NO");
}


Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
int main()
{
	ll k,i,j,ii,sum=0;
	scanf("%lld",&k);
	for(i=1;i<=k;i++)for(j=1;j<=k;j++)for(ii=1;ii<=k;ii++)
	{
		sum=sum+__gcd(__gcd(i,j),ii);
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 3812
def phi(n):
    r = n
    i = 2
    while i*i <= n:
        if n%i==0:
            r -= r/i
            while n%i==0:
                n /= i
        i += 1
    if n>1: r-= r/n
    return r

n = int(input())
print(int(phi(n)))

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


int main (){

    long long int a,b,x,ans;
    cin >> a >> b >> x;
    
    ans = b / x;
    ans -= a / x;
    if(a % x == 0) {
        ans++;
    }
    
    cout << ans << endl;
    return 0;
}



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

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

  int min = 1E9;
  while(N-- > 0){
    int A;
    cin >> A;
    int c=0;
    while(A % 2 == 0){
      A /= 2;
      c++;
    }
    if(c < min) min = c;
  }
  cout << min << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define ull unsigned long long
#define vc vector
#define SQ(j) (j)*(j)
#define x first
#define y second
//
//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pdd pair<dbl,dbl>
#define sz(xxx) ((int)(xxx.size()))
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

//#define printf(...) (0)
#define db(x) if(DEBUG) {cout << #x << " = " << x << endl;}
#define dbCont(x) if(DEBUG) {cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;}

using namespace std;

template<class K, class V>
ostream &operator<<(ostream &out, pair<K, V> &elem) {
    out << "{" << elem.first << "," << elem.second << "}";
    return out;
}

// 4:13

int DEBUG = 0;

using namespace std;

const int N = 100 * 1000 + 5;
const ll MOD = 1000 * 1000 * 1000 + 7;

ll f(ll x){
    if(x == 1) return 1;
    if(x == 0) return 0;
    return 2*f(x/2);
}

int main() {

    ll x;
    cin >> x;

    cout << 2*f(x)-1 << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
#define ll long long int
using namespace std;

void solve();

int main() {

   solve();

   return 0;
}

void solve() {

   ll a,b;

   cin >> a >> b;

   cout << a*b << ' ' << 2*(a+b) << endl;

}

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

int main()
{
	string line;
	while(cin >> line)
	{
		if(line.size()%2==1)
		{
			cout << "NA" << endl;
			continue;
		}

		string str;
		for(int i=0; i<line.size(); i+=2)
		{
			if('1'<=line[i  ] && line[i  ]<='6'
			&& '1'<=line[i+1] && line[i+1]<='5')
			{
				     if(line[i]=='6' && line[i+1]=='2') str+='.';
				else if(line[i]=='6' && line[i+1]=='3') str+='?';
				else if(line[i]=='6' && line[i+1]=='4') str+='!';
				else if(line[i]=='6' && line[i+1]=='5') str+=' ';
				else str+=(line[i]-'1')*5+(line[i+1]-'1')+'a';
			}
			else
			{
				str = "NA";
				break;
			}
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
 long long n;
 scanf("%lld",&n);
 long long a[n],ans=1,i;
 for(i=0;i<n;i++){
  scanf(" %lld",&a[i]);
  if(a[i]==0){
    puts("0");
    return 0;
  }
 }
 for(i=0;i<n;i++){
  if(1000000000000000000/a[i]<ans){
    puts("-1");
    return 0;
  }
  ans*=a[i];
 }
 printf("%lld\n",ans);
return 0;}

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

using namespace std;

#define int long long

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie();
   
    int t, n;

    int fintime;

    int ans = 0;

    cin >> n >> t;

    int in;

    int before = 0;

    cin >> before;

    for (int i = 0; i < n-1; ++i)
    {
        cin >> in;

        ans += std::min(t, in - before);

        before = in;
    }
    ans += t;

    cout << ans << endl;

    return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef STOP_DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

template <typename T> lint gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> lint lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> bool chmax(T &a, const T& b) {if (a < b) {a = b;return true;}return false; }
template <typename T> bool chmin(T &a, const T& b) {if (a > b) {a = b;return true;}return false; }
struct IoSetup{
    IoSetup(){
      ios::sync_with_stdio(false);
      cin.tie(0);
      cout << fixed << setprecision(20);
      cerr << fixed << setprecision(20);
    }
} IoSetup;

int main() {
  int n, k; cin >> n >> k;
  if (k == 1) cout << 0 << '\n';
  else cout << max(n - k, 0) << '\n';
}



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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string s; cin >> s;
  cout<<s[0]<<s.size()-2<<s.back()<<endl;

  return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    long long x = A[0];
    for(int i=1; i<N; ++i) x += A[i] * (i % 2 ? -1 : 1);
    x /= 2;
    cout << 2 * x << endl;
    for(int i=0; i+1<N; ++i) {
        x = A[i] - x;
        cout << 2 * x << endl;
    }
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define print(x) cout << x << endl;
using namespace std;
typedef long long ll;

int main()
{
    int n, m, c;
    cin >> n >> m >> c;

    int b[m];
    rep(i, m) {
        cin >> b[i];
    }

    int res = 0;
    rep(i, n) {
        int sum = 0;
        rep(j, m) {
            int a;
            cin >> a;
            sum += a * b[j];
        }
        sum += c;
        if (sum > 0) ++res;
    }

    cout << res << endl;

    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int[] NY = ReadLineParseIntArray();
        int N = NY[0];
        int Y = NY[1];

        for(int i = 0; i <= Y / 10000; i++)
        {
            for(int j = 0; j <= Y / 5000; j++)
            {
                int k = (Y - 10000 * i - 5000 * j) / 1000;
                if (k >= 0 && N == k + i + j)
                {
                    WriteLine($"{i} {j} {k}");
                    return;
                }
            }
        }
        WriteLine("-1 -1 -1");
    }
      static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

int main(void){
  int graph[101][101],cpy[101][101],n,m,a,b,c;

  while(cin >> n >> m,n|m){

    for(int i=0;i<=n;i++){
      for(int j=0;j<=n;j++){
	graph[i][j]=cpy[i][j]=10000000;
      }
      graph[i][i]=0;
    }

    for(int i=0;i<m;i++){
      cin >> a >> b >> c;
      graph[a][b]=graph[b][a]=cpy[a][b]=cpy[b][a]=c;
    }

    for(int k=0;k<=n;k++)
      for(int i=0;i<=n;i++)
	for(int j=0;j<=n;j++)
	  graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][k]+graph[k][j]);
    
    int ans=INT_MAX;
    for(int k=0;k<=n;k++)
      for(int i=0;i<=n;i++)
	if(cpy[i][k]<10000000)
	  for(int j=0;j<=n;j++)
	    if(cpy[k][j]<10000000)
	      ans=min(ans,graph[1][i]+graph[j][n]);

    cout << ans << endl;
  }
}

Measured memory_bytes: 944
n = int(input())
AB = [[int(i) for i in input().split()] for i in range(n)]

acc = 0
for i in range(n - 1, -1, -1):
    tmp = AB[i][0] % AB[i][1]
    if tmp == 0:
        x = tmp
    else:
        x = AB[i][1] - tmp
    acc += x
    if i > 0:
        AB[i - 1][0] += acc
    #print(AB, x, acc)
        
print(acc)

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	char x,y; cin>>x>>y;
	if(x==y) {
		cout << '=' << endl;
		return 0;
	}
	cout << (x>y ? '>' : '<') << endl;
	return 0;
}


Measured memory_bytes: 256
s = input()

ss = s[::-1]
n = len(s)
s1 = s[0:int((n-1)/2)]
ss1 = s1[::-1]
s2 = s[int((n+3)/2-1):n]
ss2 = s2[::-1]

if s==ss and s1==ss1 and s2==ss2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();


		for(int i = 0; i < n; i++) {
			System.out.print(s.substring(i, i+1));
			System.out.print(t.substring(i, i+1));
		}
		System.out.print("\n");

		sc.close();

	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  int L;
  cin >> N >> L;
  vector<int> taste;
  vector<int> taste_abs;
  for(int i=0;i<N;i++){
    taste.push_back(L+(i+1)-1);
    taste_abs.push_back(abs(L+(i+1)-1));
  }
  auto min = *min_element(taste_abs.begin(),taste_abs.end());
  int sum=0;
  for(int i=0;i<N;i++){
    if(taste_abs.at(i)==min)continue;
    sum += taste.at(i);
  }
  cout << sum << endl;
}
  

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

using namespace std;
using LL = long long;
using P = pair<double,int>;

int main(){
	int N, K;
	cin >> N >> K;
	vector<double> A(N);
	rep(i,N) cin >> A[i];
	LL sum=0;
	rep(i,N) sum+=A[i];
	vector<P> A_cut(N);
	int res=0;
	rep(i,N){
		double cut=A[i]/sum;
		int cut_num=K*cut+1;
		res+=cut_num-1;
		A_cut[i]=P(A[i]/cut_num,cut_num);
	}
	sort(A_cut.begin(),A_cut.end(),greater<>());
	rep(i,K-res){
		double length=A_cut[i].first;
		int num=A_cut[i].second;
		length*=num;
		length/=num+1;
		A_cut[i]=P(length,num+1);
	}
	sort(A_cut.begin(),A_cut.end(),greater<>());
	int ans=ceil(A_cut[0].first);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8088
#include <stdio.h>

int main(void) {
int w,h,x,y,r;
 scanf("%5d",&w);
 scanf("%5d",&h);
 scanf("%5d",&x);
 scanf("%5d",&y);
 scanf("%5d",&r);
 if(w>=x+r&&h>=y+r&&x+r>0&&y+r>0){
  printf("Yes\n");
 }
  else {
  printf("No\n");
 }
}


Measured memory_bytes: 2684
use std::cmp::max;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let l: u64 = sc.read();
    let n: usize = sc.read();
    let x: Vec<u64> = sc.vec(n);
    let ans1 = solve(&x, l);
    let x = x.into_iter().rev().map(|x| l - x).collect();
    let ans2 = solve(&x, l);
    println!("{}", max(ans1, ans2));
}

fn solve(x: &Vec<u64>, l: u64) -> u64 {
    let n = x.len();
    let mut right_sum = vec![0; n + 1];
    for i in 0..n {
        right_sum[i + 1] = right_sum[i] + x[i];
    }

    let mut left_sum = vec![0; n + 1];
    for i in 0..n {
        left_sum[i + 1] = left_sum[i] + (l - x[n - 1 - i]);
    }

    let mut ans = x[n - 1];
    for first_count in 0..n {
        let remain = n - first_count;
        let left_remain = (remain + 1) / 2;
        let right_remain = remain - left_remain;
        let sum = right_sum[right_remain + first_count]
            - if first_count > 0 {
                right_sum[first_count - 1]
            } else {
                0
            }
            + left_sum[left_remain];
        let sum = sum * 2
            - if left_remain > right_remain {
                l - x[n - left_remain]
            } else {
                x[right_remain + first_count - 1]
            };
        ans = max(ans, sum);
    }
    ans
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

const int N = 100, V = 100;

typedef long long ll;

int f[N * V], n;

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  f[0] = true;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    for (int j = 10000 - x; j >= 0; --j)
      f[j + x] |= f[j];
  }
  int ans = 0;
  for (int i = 10000; i >= 0; --i)
    if (i % 10 != 0 && f[i]) {
      ans = i;
      break;
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*
* @Author: Nazrul Islam
* @Date:   2020-09-19 12:28:42
* @Last Modified by:   Nazrul Islam
* @Last Modified time: 2020-09-19 12:29:57
*/

#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll; 
typedef double dd;
typedef vector<int> vi;
typedef vector<char> vc;
typedef list<int> li;
typedef set<int> si;
typedef map<int,int> mp;
#define pb push_back
#define pf push_front
#define mk make_pair
#define sc scanf
#define pr printf
#define pi acos(-1.0)
#define endl '\n'
// char s[200009];
// char st[200009];
// int a[600][600];
// int b[29][10];
// int a[200009];
// int c[200009];
void solve()
{
	ll n, m, i, j, k, l;
	ll  a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*c, max(a*d, max(b*c, b*d))) << endl; 
}
int main()
{
	IO;
	int t; 
	t = 1;
	// cin >> t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3600
'use strict';

function main(input) {
  let inputs = input.split('\n').map(num => parseInt(num, 10));
  inputs.shift();
  let uniq_diameter = inputs.filter((num, i) => inputs.indexOf(num) === i);
  console.log(uniq_diameter.length);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

import math

#x=int(min(n-b+1,b))

#if n==b:
#  print('1')
#  for i in range(b-1):
#    print('0')
#else:
#for i in range(1,x+1):
for i in range(1,b+1):
	if i-1 > n-b:
	# 境界を i-1 個作らなければならないが、赤いボールの数 n-k よりもこれが多いと条件を満たす置き方は存在しない
		print(0)
 	#if n-b+1<i or b-1<i-1:
		#break
	else:
		y=math.factorial(n-b+1)//(math.factorial(n-b+1-i)*math.factorial(i))
		z=math.factorial(b-1)//(math.factorial(b-i)*math.factorial(i-1))
		res=int(y*z%(1000000000+7))
		print(res)


#from math import factorial
 
#N, K= map(int, input().split())
 
#def ncr(n, r):
#    return factorial(n) // (factorial(r) * factorial(n - r)) 
 
#for i in range(1, K+1):
#    if i <= N-K+1:
#        print(ncr(K-1, i-1) * ncr(N-K+1, i) % (10**9 + 7))
#    else:
#        print(0)

Measured memory_bytes: 3316
using System;

namespace AtCoderABC052B
{
    class Program
    {
        static void Main()
        {
            int X = int.Parse(Console.ReadLine());
            if(X == 3 || X == 7 || X == 5){
                Console.WriteLine("YES");
            }else{
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector




signed solve()
{
    int l,r;
    cin>>l>>r;
    if(r-l>2100)
    {
        cout<<0;
    }
    else
    {
        int ans = MOD*MOD;
        forn(i,l,r)forn(j,i+1,r)ans = min(ans,(i*j)%2019);
        cout<<ans;
    }
    
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }



    return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	int n;
	int a[100010];
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int a1 = 1;
	for (int j = 1; j < n * 2; j++) {
		a1 = a[a1];
		if (a1 == 2) {
			cout << j << endl;
			return 0;
		}
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 640
N = gets.to_i
S = gets.chomp.chars

ans = Array.new(N+2)
4.times{|n|
  (ans[0] = true; ans[1] = true) if n == 0
  (ans[0] = true; ans[1] = false) if n == 1
  (ans[0] = false; ans[1] = true) if n == 2
  (ans[0] = false; ans[1] = false) if n == 3
  S.each_with_index{|s, i|
    ans[i+2] = ans[i] if s == 'o' && ans[i+1]
    ans[i+2] = !ans[i] if s == 'o' && !ans[i+1]
    ans[i+2] = !ans[i] if s == 'x' && ans[i+1]
    ans[i+2] = ans[i] if s == 'x' && !ans[i+1]
  }
  if ans[1] == ans[-1] && ans[0] == ans[-2] then
    ans.shift
    ans.pop
    puts ans.map{|b| b ? 'S':'W'}.join
    break
  end
}

puts -1 if ans.size > N


Measured memory_bytes: 13052
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0641?year=2018

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    int x = ((n + a - 1) / a) * b;
    int y = ((n + c - 1) / c) * d;
    cout << min(x, y) << endl;
    return 0;
}

/*
 *
 */


Measured memory_bytes: 3104
import itertools
import math

N,D=map(int,input().split())
x=[[] for _ in range(N)]

for i in range(N):
    x[i]=list(map(int,input().split()))
        
def calc_dd(a,b):
    dd=0
    for i in range(D):
        dd+=(x[a][i]-x[b][i])**2
    return dd

def judge(dd):
    rdd=int(math.sqrt(dd))
    if rdd*rdd==dd:
        return True
    return False

    
        
ans=0        
for c in itertools.combinations(range(N),2):
    if judge(calc_dd(c[0],c[1])):
        ans+=1
print(ans)

Measured memory_bytes: 38384
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
count = 0
c1 = 0
c2 = 1
for i in range(N):
    if A[i] + A[i+1] <= B[i]:
        count += A[i] + A[i+1] 
        A[i] = 0
        A[i+1] = 0
        ##print(count)
    elif A[i] <= B[i]:
        count += B[i]
        B[i] = B[i] - A[i]
        A[i] = 0
        A[i+1] = A[i+1] - B[i]
        ##print(count)
    else:
        count += B[i]
        A[i] = A[i] - B[i]
##print(A)
print(count)


Measured memory_bytes: 19004
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	string s; cin >> s;
	int w = count(all(s), '.');
	int b = 0;
	int ans = w;
	rep(i, 0, N) {
		if (s[i] == '.')
			w--;
		else
			b++;
		chmin(ans, b + w);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    if (n + 1 < a + b || a * b < n) {
        cout << -1 << '\n';
        return 0;
    }
    vector<int> c(b, 1);
    c[0] = a;
    int sum = a + b - 1;
    for (int i = 1; i < b; i++) {
        if (sum < n) {
            c[i] += min(a - 1, n - sum);
            sum += c[i] - 1;
        }
    }
    vector<int> ans(n);
    int mx = n, pos = 0;
    for (int i = 0; i < b; i++) {
        for (int j = 0; j < c[i]; j++) {
            ans[pos + j] = mx - c[i] + 1 + j;
        }
        mx -= c[i];
        pos += c[i];
    }
    for (int i : ans) {
        cout << i << " ";
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3968