akhauriyash/Code-Regression huggingface dataset:
h,w=map(int,input().split())
l = [input() for i in range(h)]
a = "."*(w+2)
ans="Yes"
for _ in range(h):
  l[_]="."+l[_]+"."
l.append(a)
l.insert(0,a)
for i in range(1,h+1):
  for j in range(1,w+1):
    if l[i][j]=="#" and l[i-1][j]=="." and l[i][j-1]=="." and l[i+1][j]=="." and l[i][j+1]==".":
      ans="No"
print(ans)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int n,a,b,train,taxi;
    cin>>n>>a>>b;
    train = (n*a);
    taxi = b;
    if(train<taxi)
        cout<<train<<endl;
    else if(train>taxi)
        cout<<taxi<<endl;
    else
        cout<<taxi<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
		long te = 0;
      	for(int i = 0;i<=num;i++){
          if(!(i%3==0) && !(i%5==0)){
             te += i;
          }
        }
      	System.out.println(te);
    }
}

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

int main(){
    int N,r=1,f;
    ll x,y,ss=1;
    cin >> N ;
    vector<vector<ll>> vv(N,vector<ll> (2));
    vector<char> vec(31);

    for (int i=0;i<N;++i){
        cin >> vv[i][0] >> vv[i][1];
        if (i==0){
            f=(abs(vv[i][0])+abs(vv[i][1]))%2;}
        if (f!=(abs(vv[i][0])+abs(vv[i][1]))%2){
            cout << -1 << endl;
            return 0;
        }
    }

    for (int i=0;i<N;++i){
        x=vv[i][0];y=vv[i][1];
        if (i==0){
            f=(abs(x)+abs(y))%2;

            if (f==0){
            x+=1;
            cout << 32 << endl << 1;
            for (int nn=0;nn<31;nn++){
                cout << " " << ss;
                ss *= 2;
                }
        }
            else {
                cout << 31 << endl;
                for (int nn=0;nn<31;nn++){
                    cout << ss << " ";
                    ss *= 2;
                    }
                }
        cout << endl;    
        }


        else {
            if (f==0)x+=1;
        }
        
        ll u=x+y,v=x-y;
        for(int k=30;k>=0;--k){
            if (u>=0 && v<=0){
                vec[k] = 'U';
                u -= pow(2,k);
                v += pow(2,k);
            }
            else if (u<=0 && v<=0){
                vec[k] = 'L';
                u += pow(2,k);
                v += pow(2,k);
            }
            else if (u<=0 && v>=0){
                vec[k] = 'D';
                u += pow(2,k);
                v -= pow(2,k);
            }
            else if (u>0 && v>0){
                vec[k] = 'R';
                u -= pow(2,k);
                v -= pow(2,k);
            }
            // cout << k << " " << u << " " << v << endl;
        }
        if (f==0)cout << 'L';
        for (int j=0;j<31;j++) {
            cout << vec[j];
            }
        cout << endl;
    }
}
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 4e3 + 13;

signed main()
{
#ifdef home
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#else
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> in(n);
    int mx = 0;
    map<int, int> uwu;
    for (int i = 0; i < n; i++)
    {
        cin >> in[i];
        mx = max(mx, in[i]);
        uwu[in[i]]++;
    }
    int mn = (mx + 1) / 2;
    if (mx & 1)
    {
        if (uwu[mn] < 2)
        {
            cout << "Impossible";
            return 0;
        }
        uwu[mn] -= 2;
    }
    else
    {
        if (uwu[mn] < 1)
        {
            cout << "Impossible";
            return 0;
        }
        uwu[mn]--;
    }
    for (int i = mn + 1; i <= mx; i++)
    {
        if (uwu[i] < 2)
        {
            cout << "Impossible";
            return 0;
        }
        uwu[i] -= 2;
    }
    for (auto i : uwu)
    {
        if (!i.second)
            continue;
        if (i.first <= mn)
        {
            cout << "Impossible" << '\n';
            return 0;
        }
    }
    cout << "Possible";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
 
int main(int argc, const char * argv[]) {
    
    ll N,K; cin >> N >> K;
    vector<ll> p(N);
    for(ll i=0;i<N;i++){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    
    ll sum=0;
    for(ll i=0;i<K;i++){
        sum += p[i];
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 6244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000009
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int main()
{
    	int n;
    	cin >> n;
    	int b[n - 1];
    	int a[n];
    	for(int i = 0 ; i < n - 1 ; i++){
    		cin >> b[i];
    	}
    	a[0] = b[0];
    	for(int i = 1 ; i < n - 1 ; i++){
    		a[i] = min(b[i] , b[i - 1]);
    	}
    	a[n - 1] = b[n - 2];
    	ll sum = 0;
    	for(int i = 0 ; i < n ; i++)
    		sum += a[i];
    	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string n;
  cin >> n;
  rep(i,3){
    if(n[i]=='1'){
      n[i] = '9';
    }
    else{
      n[i] = '1';
    }
  }
  print(n);
}

Measured memory_bytes: 256
import scala.annotation.tailrec

/**
 * Created by akito on 6/5/16.
 */
object Main {
  def main(args: Array[String]): Unit = {
    val n = io.StdIn.readLine().toInt

    def calc(p: ((Double, Double), (Double, Double))) = {
      val (p1, p2) = (p._1, p._2)
      val s = ((2 * p1._1 + p2._1) / 3, (2 * p1._2 + p2._2) / 3)
      val t = ((p1._1 + 2 * p2._1) / 3, (p1._2 + 2 * p2._2) / 3)
      val u = (s._1 + (t._1 - s._1) * Math.cos(Math.toRadians(60)) - (t._2 - s._2) * Math.sin(Math.toRadians(60)),
        s._2 + (t._1 - s._1) * Math.sin(Math.toRadians(60)) + (t._2 - s._2) * Math.cos(Math.toRadians(60)))
      Seq((p1, s),(s, u), (u, t), (t, p2))
    }

    @tailrec
    def kochCurve(n: Int, acc: Seq[((Double, Double), (Double, Double))]): Unit = {
      n match {
        case 0 =>
          acc.map(p => Seq(p._1, p._2)).flatten.distinct.foreach(t => println(s"${t._1} ${t._2}"))
        case _ =>
          kochCurve(n - 1, acc.map(calc).flatten)
      }
    }
    kochCurve(n, Seq(((0.0, 0.0), (100.0, 0.0))))
  }
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    vec<ll> a(n);
    REP(i, n) { cin >> a[i]; }

    priority_queue<ll> que;
    ll mi = INF;
    REP(i, n) {
        que.push(a[i]);
        chmin(mi, a[i]);
    }

    ll con = 0;
    while(que.top() >= mi + n) {
        ll ma = que.top();
        que.pop();
        ll t = (ma - mi + 1) / (n + 1);
        ma -= t * (n + 1);
        con += t;
        chmin(mi, ma);
        que.push(ma);
    }

    ll ans = con;

    ll ma = que.top();
    ll d = max(0LL, ma + con - 2 * n + 1);
    ans += d * n;

    priority_queue<ll> que2;
    while(que.size()) {
        que2.push(que.top() + con - d);
        que.pop();
    }

    ll con2 = 0;
    while(que2.top() + con2 >= n) {
        ll b = que2.top();
        que2.pop();
        if(b + con2 >= n) {
            b -= n + 1;
            con2++;
        }
        que2.push(b);
    }
    ans += con2;
    cout << ans << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int mod = 1e9 + 7;
int n;
string o;
int dp[3005][3005];

int add(int a, int b)
{
  return (a + b) % mod;
}

int solve(int s, int b)
{
  if(s < 0 || b < 0)
    return 0;
  if(!s && !b)
    return 1;
  int &ans = dp[s][b];
  if(ans != -1)
    return ans;
  int idx = n - (s + b) - 1;
  if(o[idx] == '<')
    return ans = add(solve(s, b - 1), solve(s + 1, b - 1));
  else
    return ans = add(solve(s - 1, b), solve(s - 1, b + 1));
}

int main()
{
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> o;
  memset(dp, -1, sizeof(dp));
  int ans = 0;
  for(int i = 1; i <= n; i++)
    ans = add(ans, solve(i - 1, n - i));
  cout << ans;
  return 0;
}


Measured memory_bytes: 246400
#include <iostream>

using namespace std;

int main(){
  string str1, str2;cin>>str1>>str2;
  string ans = "NO";
  if(str1[0]==str2[2] && str1[1]==str2[1] && str1[2]==str2[0]){
    ans = "YES";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

void ABC157A()
{
	int N;
	cin >> N;
	int x = N / 2 + N % 2;
	cout << x << endl;
}
int main()
{
	ABC157A();
	return 0;
}

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

#define fi first
#define se second
#define SZ(x) (int)x.size()
#define ll long long
#define MP make_pair
#define pb push_back
#define pq priority_queue
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define debug(x) cerr<<#x<<"="<<x<<'\n'
#define rep(i,a,b) for (int i=a;i<(b);i++)

int n,m;
vector <ll> a,b;

int main(){
	cin>>n>>m;
	ll ans=1;
	rep(i,0,n) {
		ll x;
		cin>>x;
		ans=ans*abs(x)%mod;
		if (x>0) a.pb(x);
		if (x<0) b.pb(-x);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	if (SZ(a)+SZ(b)<m) {
		cout<<0;
		return 0;
	}
	ll l=max(0,m-SZ(a)),r=min(m,SZ(b));
	if (l==r&&l%2==1) {
		if (SZ(a)+SZ(b)!=n) {
			cout<<0;
			return 0;
		}
		ll ans=1;
		rep(i,0,SZ(b)) a.pb(b[i]);
		sort(a.begin(),a.end());
		rep(i,0,m) ans=ans*a[i]%mod;
		if (ans==0) cout<<0;
		else cout<<mod-ans;
		return 0;
	}
	ans=1;
	int cur1=SZ(a)-1,cur2=SZ(b)-1;
	if (m%2==1) ans=ans*a[cur1--]%mod;
	rep(i,0,m/2) {
		if (cur2<1) ans=ans*a[cur1]%mod*a[cur1-1]%mod,cur1-=2;
		else if (cur1<1) ans=ans*b[cur2]%mod*b[cur2-1]%mod,cur2-=2;
		else if (a[cur1-1]*a[cur1]>b[cur2-1]*b[cur2]) {
			ans=ans*a[cur1-1]%mod*a[cur1]%mod;
			cur1-=2;
		}
		else {
			ans=ans*b[cur2-1]%mod*b[cur2]%mod;
			cur2-=2;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6080
def max_sum(n,k):
    sum = 0
    for i in range(n-k+1,n+1):
        sum += i
    return sum
N,K = map(int,input().split(" "))
sum = 0
mod_num = 1000000007
for i in range(K,N+2):
    max = i*(2*N-i+1)//2
    min = i*(i-1)//2
    sum += max-min+1
    sum %= mod_num

print(sum)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int a, b, c;
    cin >> a >> b >> c; 
    if(a == b && a == c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
    int a,b;
    cin >> a >> b;
    if(a + b >= 10){
        cout << "error" << endl;
    }else{
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N=gets.strip.to_i
a=gets.strip.split.map(&:to_i)

a.sort!
rui=[]
rui[0]=0
(0..N-1).each do |i|
  rui<<rui[i]+a[i]
end

arr=Array.new(N, true)
(0..N-2).each do |i|
  if rui[i+1]*2 < a[i+1]
    arr[i]=false
  end
end

ans=0
(0..N-1).reverse_each do |i|
  if !arr[i]
    break
  else
    ans+=1
  end
end

puts ans

Measured memory_bytes: 12672
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define ll long long
int main(){
    int n,k;
    cin >> n >> k;
    vector<double> p(n);
    vector<double> ex(n);
    rep(i,n){
        cin>>p.at(i);
        ex.at(i)=(p.at(i)+1)/2;
    }
    double sum=0;
    rep(i,k){
        sum+=ex.at(i);
    }
    double slide_sum=sum;
    rep(i,n-k){
        slide_sum=slide_sum-ex.at(i)+ex.at(i+k);
        sum=max(sum,slide_sum);
    }
    cout<<fixed<<setprecision(10)<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
//#include <random>
#include <map>
//#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <time.h>
//#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
//#include <type_traits>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
double pi = 3.141592653589793;
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

int main() {
	rep(i, 5) {
		int x;
		cin >> x;
		if (x == 0) {
			cout << i + 1 << endl;
		}
	}

}






Measured memory_bytes: 3512
sx, sy, tx, ty = map(int, input().split())
distance_x, distance_y = tx-sx, ty-sy
x_now, y_now = sx, sy
up, down, right, left = 'U', 'D', 'R', 'L'

#path1
print(up*distance_y+""+right*distance_x,end="")
#path2
print(down*distance_y+""+left*distance_x,end="")
#path3
print("L"+""+up*(distance_y+1)+""+right*(distance_x+1)+""+"D",end="")
#path4
print("R"+""+down*(distance_y+1)+""+left*(distance_x+1)+""+"U")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,data;
    cin >> A >> B >> C;
    data = A;
    A = B;
    B = data;
    
    data = A;
    A = C;
    C = data;
    std::cout << A << " " << B << " " << C <<" " << std::endl;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
	int n;
	string s;
	int x = 0;
	int max = 0;

	cin >> n >> s;

	for (int i = 0; i < n; ++i)
	{
		if (s[i] == 'I')
		{
			x++;
		} else {
			x--;
		}
		if (x > max)
		{
			max = x;
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    map<ll, ll> m;
    rep(i, n) { cin >> a[i]; m[a[i]]++; }
    sort(RALL(a)); // 降順にソート
    ll one = -1, two = -1, cnt = 0;
    rep(i, n) {
        if (m[a[i]] > 1) {
            if (one == -1) { one = a[i]; cnt++; m[a[i]] -= 2;}
            else if (two == -1) { two = a[i]; cnt++; break; }
        } else continue;
    }
    (cnt == 2) ? cout << one * two << endl : cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1000005
#define quick_pow_mod 1000000007
#define PII pair<int,int>
const int factor_N = 10000005;
const int tree_arr_N = 1000005;
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-') f = -1;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
	return x * f;
}
int n;
int main() {
	n = read();
	vector<int>a(n+1, 0);
	for_int(i, 1, n) a[i] = read();
	int ans = 0;
	sort(a.begin(), a.end());
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
			if (a[i] != a[j]) {
				for (int k = j + 1; k <= n; ++k)
					if (a[j] != a[k] && a[i] + a[j] > a[k]) ans++;
			}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
N = int(input())
h = list(map(int, input().split()))
cost = [0 for _ in range(len(h))]
for i in range(1, len(h)):
    if i == 1:
        cost[i] = abs(h[i] - h[i-1])
        continue
    cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]))
print(cost[-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,l = 0,r = 0;
    cin >> n;
    int w[n],a = 0,b = n - 1;
    rep(i, n)cin >> w[i];
    rep(i, n){
        if (l + w[a] > r + w[b]) {
            r += w[b];
            --b;
        }else{
            l += w[a];
            ++a;
        }
    }
    cout << abs(r - l) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int s, h, m;
    
    cin >> s ;
    h = s / 3600;
    s = s - (h * 3600);
    m = s/60;
    s =s-(m*60);
    
    
    cout << h << ":" << m << ":" << s <<
endl;   

    return 0;
}
    
    


Measured memory_bytes: 3108
n=int(input())
ans=['AC x ','WA x ','TLE x ','RE x ']
arr=[0]*4
for i in range(n):
  s=str(input())
  if s=='AC':
    arr[0]+=1
  elif s=='WA':
    arr[1]+=1
  elif s=='TLE':
    arr[2]+=1
  else:
    arr[3]+=1
for k in range(4):
  print(ans[k]+str(arr[k]))

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

using namespace std;

using ll = long long;

int dp[100001][3];
int days[100000][3];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> days[i][0] >> days[i][1] >> days[i][2];
  }
  for (int i = 1; i <= n; ++i) {
    dp[i][0] =
        max(dp[i - 1][1] + days[i - 1][1], dp[i - 1][2] + days[i - 1][2]);
    dp[i][1] =
        max(dp[i - 1][0] + days[i - 1][0], dp[i - 1][2] + days[i - 1][2]);
    dp[i][2] =
        max(dp[i - 1][1] + days[i - 1][1], dp[i - 1][0] + days[i - 1][0]);
  }
  cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

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

MAX = 2 * 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1

# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1

# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1

for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

# Factorial for large
facl = [0] * (MAX + 1)
facl[0] = N
for i in range(1, MAX + 1):
    facl[i] = facl[i - 1] * (N - i) % MOD

# Solution
ans = pow(2, N, MOD) - 1
ans -= facl[A - 1] * finv[A] % MOD
ans %= MOD
ans -= facl[B - 1] * finv[B] % MOD
ans %= MOD
print(ans)


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

void solve(){
    int n;
    map<char,int> mp;
    cin>>n;
    rep(i,0,n){
        char ch;
        cin>>ch;
        mp[ch]++;
    }
    if(mp.size()==3) cout<<"Three";
    else cout<<"Four";
}

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

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

int main(void)
{
	string s;
	cin >> s;
	int k;
	cin >> k;
	int n = (int)s.length();
	vec<int> a(n);
	rep(i, n) a[i] = ((int)'z' - (int)s[i] + 1) % 26;

	rep(i, n - 1) {
		if (k >= a[i]) {
			s[i] = 'a';
			k -= a[i];
		}
	}
	s[n - 1] = (char)((k + (int)s[n - 1] - (int)'a') % 26 + (int)'a');
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    set<ll>s;
    ll flag=0;
    for(ll i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        if(s.find(a)!=s.end())
        {
            flag=1;
        }
        s.insert(a);
    }
    if(flag)
        cout<<"NO";
    else
        cout<<"YES";
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int S[] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
    int x,y; cin >> x >> y;
    if(S[x]==S[y]) pr("Yes");
    else pr("No");

    
}



Measured memory_bytes: 256
#include <stdio.h>

int     main(void)
{
    int d;
    int t;
    int s;

    scanf("%d %d %d", &d, &t, &s);

    if (d > t * s)
    {
        printf("%s\n", "No");
    }
    else if (d <= t * s)
    {
        printf("%s\n", "Yes");
    }
}

Measured memory_bytes: 1660
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	string s;
	cin >> s;
	int ans = 10000;
	repz(i, s.size() - 2) {
		int temp = stoi(s.substr(i, 3));
		temp = abs(temp - 753);
		if (temp < ans)ans = temp;
	}

	cout << ans << endl;

	system("pause");
	return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
using namespace std ;
int main()
{
    int n,d[100001],temp;
    cin>>n;
    int i;
    for(i=0;i<n;i++)
    {
        cin>>d[i];
    }
    sort(d,d+n);
    temp=d[n/2]-d[(n/2)-1];
    cout<<temp;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define PI 3.14159265359
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pai;
typedef pair<ll, ll> pal;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

ll test[300][300];
ll dist[300][300];
ll flag[300][300];

void warshall_floyd(int n) {
	for (int k = 0; k < n; k++){      
    	for (int i = 0; i < n; i++) {    
      		for (int j = 0; j < n; j++) { 
      			if (i != k && k != j && dist[i][k] + dist[k][j] == dist[i][j]) flag[i][j] = true;
        		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      		}
    	}
  	}
  	return;
}

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cin >> test[i][j];
			dist[i][j] = test[i][j];
		}
	}
	warshall_floyd(n);

	ll ans = 0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (dist[i][j] != test[i][j]){
				cout << -1 << endl;
				return 0;
			}
			if (!flag[i][j]) ans += dist[i][j];
		}
	}
	cout << ans/2 << endl;
	return 0;
}






Measured memory_bytes: 5704
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (int i = 0; i < (n); ++i)	
//setprecision(16)

int max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n;
	cin >> n;
	int res = 0;
	rep(i, n + 1) {
		int k = i;
		int d = 0;
		while (k) k /= 10, d ^= 1;
		res += d;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int n;
vint a, b, c;
int ma, mb;
int inf = 1000000;
vector<vector<vint>> d;

int dp(int pos, int na, int nb){
	if(pos == n){
		if(na > 0 && (double)na/ma == (double)nb/mb){
			return 0;
		}else{
			return inf;
		}
	}
	if(d[pos][na][nb]!=2*inf)return d[pos][na][nb];
	int ret = inf;
	chmin(ret, c[pos]+dp(pos+1, na+a[pos], nb+b[pos]));
	chmin(ret, dp(pos+1, na, nb));
	return d[pos][na][nb]=ret;
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
	cin>>n>>ma>>mb;
	a = vint(n);
	b = vint(n);
	c = vint(n);
	//d.assign(n, vector<vint>(n*10+1, vint(n*10+1, inf)));
	d = vector<vector<vint>>(n, vector<vint>(n*10+1, vint(n*10+1, 2*inf)));
	rep(i, n){
		cin>>a[i]>>b[i]>>c[i];
	}
	int ans = dp(0, 0, 0);

	if(ans < inf)cout << dp(0, 0, 0) << endl;
	else cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 26624
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

long long dp[200100];

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

    cout <<N-i+1 << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    int ret=0;
    int c=1<<29;
    rep(j,29){
        ret*=2;
        rep(i,n)if(a[i]>=c)a[i]-=c;
        rep(i,n)if(b[i]>=c)b[i]-=c;
        c>>=1;
        sort(a,a+n);
        ll cnt=0;
        rep(i,n){
            if(b[i]>=c){
                cnt+=lower_bound(a,a+n,2*c-b[i])-a;
                cnt+=n;
                cnt-=lower_bound(a,a+n,3*c-b[i])-a;
            }
            else {
                cnt+=lower_bound(a,a+n,2*c-b[i])-a;
                cnt-=lower_bound(a,a+n,c-b[i])-a;
            }
        }
        if(cnt&1)ret++;
    }
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 1792
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def main():
    N = input().strip()
    if N[-1] in ("2", "4", "5", "7", "9"):
        print("hon")
    elif N[-1] in ("0", "1", "6", "8"):
        print("pon")
    else:
        print("bon")



if __name__ == "__main__":
    main()



Measured memory_bytes: 9740
from enum import Enum
import sys
import math

# 0:上側 1:南 2:東 3:西 4:北 5:下側

class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.pattern = 'NNNNENNNENNNWNNNWNNNENNN'
        self.ret = 0
        
    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
        
    def roll(self, loc):
        for i in range(6):
            self.work[i] = self.number[i]
        
        if loc == 'E':
            self.setNumber(self.work[3], self.work[1], self.work[0], self.work[5], self.work[4], self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1], self.work[5], self.work[2], self.work[3], self.work[0], self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4], self.work[0], self.work[2], self.work[3], self.work[5], self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2], self.work[1], self.work[5], self.work[0], self.work[4], self.work[3])

    def match(self, Std):
        for i in range(6):
            self.work[i] = self.number[i]
        
        for i in range(len(self.pattern)):
            self.roll(self.pattern[i])
            if self.number == Std:
                self.ret = 1
                break
                
    def get_ret(self):
        return self.ret

total = 0
n = int(input())
dice = [''] * n

for i in range(n):
    table = list(map(int, input().split()))
    dice[i] = Dice()
    dice[i].setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

for i in range(1, n):
    dice[i].match(dice[0].number)

for i in range(1, n):
    total += int(dice[i].ret)

if total > 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 5e18;

void solve()
  {
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int ans = max({a*c,a*d,b*c,b*d}); 
   cout<<ans;
  }
int32_t main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
  /* int t;
   cin>>t;
   while(t--)*/
     solve();
  //cerr<<END<<1.0*clock();
  return 0;
} 

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

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

int main() {
	int h, w; scanf("%d%d", &h, &w);
	int store[h][w]{0};
	forn(i, h) {
		char c[w]; scanf("%s", c);
		forn(j, w) {
			if(c[j] == '#')
				store[i][j] = 1;
			else
				store[i][j] = 0;
		}
	}
	int leftdp[h][w]{0};
	forn(i, h) {
		int total = 0;
		forn(j, w) {
			if(store[i][j] == 0) {
				leftdp[i][j] = total;
				total++;
			} else { total = 0; }
		}
	}
	int rightdp[h][w]{0};
	forn(i, h) {
		int total = 0;
		ford(j, w) {
			if(store[i][j] == 0) {
				rightdp[i][j] = total;
				total++;
			} else {total = 0;}
		}
	}
	int downdp[h][w]{0};
	forn(j, w) {
		int total = 0;
		forn(i, h) {
			if(store[i][j] == 0) {
				downdp[i][j] = total;
				total++;
			} else {total = 0;}
		}
	}
	int updp[h][w]{0};
	forn(j, w) {
		int total = 0;
		ford(i, h) {
			if(store[i][j] == 0) {
				updp[i][j] = total;
				total++;
			} else {total = 0;}
		}
	}
	int max = 0;
	forn(i, h) {
		forn(j, w) {
			if(store[i][j] == 0) {
				int ne = leftdp[i][j] + rightdp[i][j] + downdp[i][j] + updp[i][j] + 1;
				uax(max, ne);
			} 
		}
	}
	printf("%d", max);	 
	return 0;
}

Measured memory_bytes: 78336
#include<iostream>

using namespace std;

int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int d(char c){
	switch(c){
	case 'N':return 0;
	case 'E':return 1;
	case 'S':return 2;
	case 'W':return 3;
	}
	return -1;
}

int main(){
	int n;
	while(cin>>n &&n){
		int ma[21][21];
		fill((int*)ma,(int*)ma+21*21,0);
		for(int i=0;i<n;i++){
			int x,y;
			cin>>x>>y;
			ma[y][x]=1;
		}
		int m;
		int ans=0;
		cin>>m;
		int nx=10;
		int ny=10;
		for(int i=0;i<m;i++){
			char c;
			int v;
			cin>>c>>v;
			while(v>0){
				v--;

				nx+=dx[d(c)];
				ny+=dy[d(c)];
				if(ma[ny][nx]==1){
					ma[ny][nx]=0;
					ans++;
				}
			}
			
		}
		if(ans==n)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<int,int> ,null_type,less<pair<int,int>>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
typedef long long ll;
const int N = 1e5+10 , OO = 0x3f3f3f3f , mod = 1e9 + 7;

#define PI acos(-1) 
#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(vec) for(auto &x : vec) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
 
int a,b,c,k;

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

  scanf("%d %d %d %d", &a , &b , &c , &k);
  ll sum = 0; 
  if(a >= k)
    printf("%d\n", k);
  else{
    sum = a; 
    k -= a;
    if(b >= k)
      printf("%lld\n", sum);
    else{
      k -= b;
      sum -= min(c , k);
      printf("%lld\n", sum);
    }
  }
  

  return 0;
}

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


int main() {
    int k; string s;
    cin >> k;
    cin >> s;
    if (s.size() > k) {
        cout << s.erase(k)+"..." << endl;
    }
    else {
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s, t;
  cin >> s >> t;
  rep(i, 0, s.size()) {
    if (s[i] != t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, N) for (int i = 0; i < (int)N; i++)

int group(int i) {
  if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12) return 0;
  if(i == 4 || i == 6 || i == 9 || i == 11) return 1;
  if(i == 2) return 3;
}
int main () {
  int x, y;
  cin >> x >> y;
  cout << (group(x) == group(y) ? "Yes" : "No") << endl;
  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  string s, t; cin >> s >> t;
  for(int i = 0; i < n+1; i++) {
    if(s.substr(i) == t.substr(0, n-i)) {
      cout << n+i << endl;
      return 0;
    }
  }

  return 0;
}


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

int main() {
    int n; cin >> n;
    bool flag = false;
    for(int i = 0; i < n; i++) {
        char s; cin >> s;
        if(s == 'Y') flag = true;
    }
    if(flag) cout << "Four" << endl;
    else cout << "Three" << endl;
}


Measured memory_bytes: 256
//This problem occured in CF too , 652F
//
//In the name of Allah
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define X first
#define Y second
#define pb push_back
using namespace std;
pii a[300300];
ll c[300300],ans[300300];
bool b[300300];
int main()
{
    ll n,m,t;
    cin>>n>>m>>t;
    for(ll i=0;i<n;i++)
    {
        int cc; 
        cin>>a[i].X>>cc;
        a[i].Y=i;
        c[i]=a[i].X;
        b[i]=(cc==1);
    }
    sort(a,a+n);
    ll k=0;
    vector<ll> v;
    for(ll i=0;i<n;i++)
        if(b[i])
            v.pb((c[i]+t)%m),k+=(c[i]+t)/m;
        else
            v.pb(((c[i]-t)%m+m)%m),k+=(c[i]>t?(c[i]-t)/m:(c[i]-t-m+1)/m);
    sort(v.begin(),v.end());
    k=(k%n+n)%n;
    for(ll i=0;i<n;i++)
        ans[a[i].Y]=v[(i+k)%n]+1;
    for(ll i=0;i<n;i++)
        cout<<ans[i]-1<<'\n';
    return 0;
}

Measured memory_bytes: 9076