akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_C&lang=jp
"""
import sys
input = sys.stdin.readline


def solve_knapsack(weight, items):
    dp = [[0]*(weight+1) for _ in range(len(items))]
    for i, item in enumerate(items[1:]):
        for w in range(1, weight+1):
            if item[1] <= w:
                dp[i+1][w] = max((item[0] + dp[i][w-item[1]]),  dp[i][w], (item[0] + dp[i+1][w-item[1]]))
            else:
                dp[i+1][w] = dp[i][w]
    return dp[-1][-1]


def main(args):
    N, W = map(int, input().split())
    items = [[]]
    for _ in range(N):
        items.append([int(x) for x in input().strip().split()])
    result = solve_knapsack(W, items)
    print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

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

vector<long long int>v;
long long int dp[100005];
long long int inf=10000000000;
int main()
{
    long long int j,n,i,a,k;
    cin >> n >> k;
    for(i=0; i<n; i++)
    {
        cin >> a;
        v.push_back(a);
        dp[i]=inf;
        dp[i+1]=inf;
    }
    dp[0]=0;
    for(i=0; i<n; i++)
    {
        long long int fo=inf;
        for(j=1; j<=k; j++)
        {
            if(i+j<n)
            {
               dp[i+j]=min((abs(v[i]-v[i+j])+dp[i]),dp[i+j]);
               //fo=min(fo,dp[i+j]);
            }
        }
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 4992
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long[] nums = new long[4];
		for(int i = 0; i < 4; i++) {
			nums[i] = scanner.nextInt();
		}
		long result = nums[0] * nums[2];
		if(result < nums[0]*nums[3])result = nums[0]*nums[3];
		if(result < nums[1]*nums[2])result = nums[1]*nums[2];
		if(result < nums[1]*nums[3])result = nums[1]*nums[3];
		System.out.println(result);
		scanner.close();
	}
}

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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
int main() {
  int n;cin>>n;
  int ans=0;
  cout << (n*n)<< endl;
}

Measured memory_bytes: 256
while 1:
 a=[list(map(int,input()))for _ in[0]*8]
 y=[sum(r)for r in a]
 x=[sum(c)for c in zip(*a)]
 print('B'if 4 in x else'C'if 4 in y else'DF'[a[y.index(1)][x.index(2)]]if 1 in y else'GE'[a[y.index(2)][x.index(1)]]if 1 in x else'A')
 try:input()
 except:break


Measured memory_bytes: 5608
def riffle(deck)
    a=[]
    a = deck[0,deck.size/2]
    b=[]
    b = deck-a
    c = Array.new
    (a.size*2).times{|i|
      c<<(i%2==0 ? a.shift : b.shift)
    }
  c
  end

  def cut(deck,k)
    (deck-deck[0,k])+deck[0,k]
  end
n = gets.to_i
m = gets.to_i
deck = (1..2*n).to_a

m.times do
  k = gets.to_i
  if k==0 then  deck=riffle(deck) else deck=cut(deck,k) end
end

deck.each{|x|
  puts x
}

Measured memory_bytes: 6868
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<functional>
#include<algorithm>
#include<bitset>
#include<utility>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;
#define ll long long
map<ll,ll>m;
int ans=0;
int n;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		ll a;
		cin>>a;
		m[a]++;
	}
	for(map<ll,ll>::iterator it=m.begin();it!=m.end();it++)
		if(it->second>it->first)
			ans+=abs(it->second-it->first);
		else if(it->second<it->first)
			ans+=it->second;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6272
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[n + 1];
        for (int i = 0; i < m; i++) {
            a[scanner.nextInt() - 1]++;
            a[scanner.nextInt()]--;
        }

        Arrays.parallelPrefix(a, Integer::sum);
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (a[i] == m) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 65436
/// hi_im_manh :D
#include <bits/stdc++.h>
#define reset(a,n) memset(a,0,(n+1)*sizeof(int))
#define endl "\n"
#define llmin LLONG_MIN
#define llmax LLONG_MAX
#define intmax INT_MAX
#define intmin INT_MIN
#define ll long long
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define duckman "TASK"

#define input freopen(duckman".inp", "r", stdin);
#define output freopen(duckman".out", "w", stdout);

#define nmax 22000
using namespace std;


int main()
{
    fast;
//    input;
//    output;

    ll n, p;
    string s;
    cin >> n >> p >> s;
    ll ans = 0;
    if (p == 2) {
        for (ll i = 0; i < n; ++i) {
            if (!((s[i]-'0')&1)) {
                ans += i+1;
            }
        }
    }
    else if (p == 5) {
        for (ll i = 0; i < n; ++i) {
            if (s[i] == '0' || s[i] == '5') {
                ans += i+1;
            }
        }
    }
    else {
        ll a[p] = {0};
        a[0] = 1;
        ll num = 0, tens = 1;
        for (ll i = n-1; ~i; --i) {
            num = (num+(s[i]-'0')*tens)%p;
            ans += a[num]++;
            tens = (tens*10)%p;
        }
    }
    cout << ans;
    return 0;
}
/*

*/


Measured memory_bytes: 720
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  ll N; scanf("%lld", &N);

  if (N % 2 != 0){
    printf("0\n");
    return 0;
  }

  ll five = 5, ans = 0;
  while (N >= five){
    ans += N / five / 2;
    five *= 5;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
A = [int(input()) for i in range(M)]
mod = 10**9 +7

dp = [-1] * (N+1)
for i in range(M):
    dp[A[i]] = 0

dp[0] = 1
if dp[1] == -1:
    dp[1] = dp[0]
for i in range(2, N+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-1] + dp[i-2]

ans = dp[N] % mod
print(ans)

Measured memory_bytes: 460020
<?php

$alphabet = array_combine(range('a', 'z'), array_fill(0, 26, 0));
// $alphabet -> $key=a~z, $val=0~0

while (($line = trim(fgets(STDIN))) !== '') {
    $line = strtolower($line);
    $len = strlen($line);

    for ($i = 0; $i < $len; $i++) {
        $c = $line[$i]; //$c -> 英文の小文字のi番目＝結果的に全番

//        英文の存在するアルファベットのところに数値を足していく処理
        if (isset($alphabet[$c])) {
            $alphabet[$c]++; //$key=a~zはそのままに、$valに加算されていく
        }
    }
}

foreach ($alphabet as $key => $val) {
    printf("%s : %d\n", $key, $val);
}

?>


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

int main(void) {
  long long X;
  cin >> X;
  long long ans = 0;
  ans += X / 500 * 1000;
  X %= 500;
  ans += X / 5 * 5;
  cout << ans << endl;
  return 0;
}

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

int main(){
    int N;
    int d[110];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> d[i];
    }

    int num[110]={0}; //バケット

    for (int i = 0; i<N; i++){
        num[d[i]]++;
    }

    int ans = 0;
    for (int i = 1; i <= 100; i++){
        if(num[i]>0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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;

int main(){
    Init();
    ll h, w; cin >> h >> w;
    // 文字列群中の各文字の出現回数をカウント
    map<char, ll> cnt;
    rep(i, h){
        string s; cin >> s;
        ll n = s.size();
        rep(j, n) cnt[s[j]]++;
    }

    vi com(5, 0);
    for(auto &num: cnt){
        // 4個対がいくつつくれるか。
        com[4] += num.second/4;
        // 余りが0,1,2,3の数も覚えておく
        com[num.second%4]++;
    }
    // 3個のあまりは2個対と1個に分ける
    com[2] += com[3], com[1] += com[3];

    bool ans = false;
    // hもwも偶数の場合, h*w/4個の4個対が必要
    if(h%2 == 0 && w%2 == 0){
        com[4] == h*w/4 ? ans = true : false;
    }
    else{
        // hが偶数でwが奇数
        if(h%2 == 0 && w%2 != 0){
            ll req = h*(w-1)/4;
            if(com[4] >= req){
                com[4] -= req;
                com[2] += (com[4]*2);
                h/2 == com[2] ? ans = true : false;
            }
            else{
                ans = false;
            }
        }
        // hが奇数でwが偶数
        else if(h%2 != 0 && w%2 == 0){
            ll req = (h-1)*w/4;
            if(com[4] >= req){
                com[4] -= req;
                com[2] += (com[4]*2);
                w/2 == com[2] ? ans = true : false;
            }
            else{
                ans = false;
            }
        }
        // どっちも奇数
        else{
            ll req = (h-1)*(w-1)/4;
            if(com[4] >= req){
                com[4] -= req;
                com[2] += (com[4]*2);
                req = (h-1)/2 + (w-1)/2;
                req == com[2] && com[1] == 1 ? ans = true : false;
            }
            else{
                ans = false;
            }
        }
    }
    ans ? Yes() : No();
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<stack>
#include<cstring>
#include<unordered_map>
#include<cmath>
#include<climits>
using namespace std;

template<typename T>
istream& operator>>(istream& in, vector<T> &a) {for(auto &i : a) {in >> i; } return in; } 
template<typename T>
ostream& operator<<(ostream& out, vector<T> &a) {for(auto &i : a) {out << i << ' '; } out << '\n'; return out; }

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif



bool isVowel(char c)
{
	if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
	{
		return true;
	}
	return false;
}
int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input/input.txt", "r", stdin);
		freopen("input/output.txt", "w", stdout);
	#endif
	long long int n;
	cin >> n;
	long long int cnt = 0;
	for(long long int i = 1; i < n; i++)
	{
		long long int ans = n / i;
		if(ans*i == n) ans--;
		cnt += ans;
		// cout << i << ' ' << ans << '\n';
	}
	cout << cnt << '\n';
}


Measured memory_bytes: 3636
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;

int main() {
	bool n = false, S = false, w = false, e = false;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'N')n = true;
		if (s[i] == 'S')S = true;
		if (s[i] == 'W')w = true;
		if (s[i] == 'E')e = true;
	}
	if ((n&&S&&w&&e) || (n&&S&&!w&&!e) || (w&&e&&!n&&!S))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  const int inf = 1e9;
  V<> dp(n + 1, inf);
  dp[0] = -1;
  for (int i = 0; i < n; i++) *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
  cout << lower_bound(dp.begin(), dp.end(), inf) - dp.begin() - 1 << '\n';
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
    	ll h1, m1, h2, m2, k;
    	cin >> h1 >> m1 >> h2 >> m2 >> k;
    	ll ans = h1 * 60 + m1 - h2  * 60 - m2;
    	ans = -ans;
    	ans -= k;
    	cout << ans;
}

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

using namespace std;

int main(){

    int N, M, X, status = 0, Ncost = 0, Zcost = 0, pos;

    cin >> N >> M >> X;

    int arr[N] = {0};
    int arr1[M];

    for(int i = 0; i < M; i++){
        cin >> arr1[i];
        arr[arr1[i] - 1] = 1;
    }

//    for(int i = 0; i < N; i++){
//        cout << arr[i] << " ";
//    }
//    cout << endl;
//    cout << "-------Ncost---------" << endl;
    for(int i = X-1; i < N; i++){
//        cout << arr[i] << endl;
        if(arr[i] == 1){
            Ncost++;
        }
    }
//    cout << "-------Zcost---------" << endl;
    for(int i = X-1; i >= 0; i--){
//        cout << arr[i] << endl;
        if(arr[i] == 1){
            Zcost++;
        }
    }

//    cout << "----------------" << endl;
//    cout << Zcost << endl;
//    cout << Ncost << endl;

    if(Zcost >= Ncost){
        cout << Ncost << endl;
    }
    else{
        cout << Zcost << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
int N,A,B;

double factorial(double k){
    double sum = 1;
    for (int i = 1; i <= k; ++i) sum *= i;
    return sum;
}

int main(void){
    cin>>N>>A>>B;
    vector<ll> v(N);
    FOR(i, 0, N) cin>>v[i];
    sort(v.rbegin(), v.rend());
    double ave;//平均値
    double sum = 0;//合計
    double maxAve = -999;//平均値の最大
    double vmin = v[0];//使わなきゃいけない最小値
    int usevmin = 0;//使わなきゃいけない最小値の個数
    int num = 0;
    FOR(i, 0, N){
        sum += v[i];
        ave = sum/(i+1);
        if(i+1>A && v[0]!=v[i]) break;
        if(vmin == v[i]) usevmin++;
        else{
            vmin = v[i];
            usevmin = 1;
        }
        maxAve = ave;
        num = i+1;
    }
    if(usevmin>=A){
        printf("%.06lf\n", maxAve);
        double ans = 0;
        FOR(i, A, B+1){
            if(i>usevmin) break;
            ans += double(factorial(usevmin) / (factorial(usevmin-i) * factorial(i)));
        }
        printf("%.0lf\n", ans);
        return 0;
    }
    double vmin_n = 0;//使われる数の最小値の個数
    FOR(i, 0, N) if(vmin==v[i]) vmin_n++;
    //vim_n C usevmin
    //cout << usevmin << vmin_n << endl;
    printf("%.06lf\n", maxAve);
    printf("%.0lf\n",double(factorial(vmin_n)/(factorial(vmin_n-usevmin)*factorial(usevmin))));
}

Measured memory_bytes: 256
function Main(input){
  const values = input.trim().split(' ');
  const A = BigInt(values[0]);
  const B = BigInt(values[1].replace('.',''));
  let result = String(A*B/100n);
  console.log(result);
}

//固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29596
N = int(input())


if N % 2 == 0:
    lst = [i+1 for i in range(N)]
    keyvalue = N+1

    ansedge = []

    conn = [ [False]*N for _ in range(N)]

    for i in range(1,N+1):
        for j in range(i+1,N+1):
            if j != i and j != keyvalue-i: #and not conn[i][j]:
                ansedge.append( (i, j) )
                # conn[i][j] = True
                # conn[j][i] = True
    print(len(ansedge))
    for e in ansedge:
        print(*e)
    
    exit()
else:
    lst = [i+1 for i in range(N)]
    keyvalue = N

    ansedge = []
    for i in range(1,N):
        for j in range(i+1,N):
            if j != i and j != keyvalue-i: 
                ansedge.append( (i, j) )
        ansedge.append ( (N, i)  )

    print(len(ansedge))
    for e in ansedge:
        print(*e)


Measured memory_bytes: 44912
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int res = 0;
    for(int i = a/10000; i <= b/10000 + 1; i ++){
                        // show('\n')
        // show(i)
        for (int j = 0; j <= 9; j++){
            // show(j)
            for (int k = 0; k <= 9; k++){
                // show(k) show('a')
                int che = 10001*i + 1010*j + 100 * k;
                if (a <= che && che <= b){
                    // show(che);
                    res++;
                }
            }
        }
    }
    cout << res;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  int t[n];
  int sum = 0;
  for(int i = 0; i < n; i++) {
    cin>>t[i];
    sum+=t[i];
  }
 int m;
 cin>>m;
 int ans[m];
 for(int i = 0; i < m; i++){
   int p,x;
   cin>>p>>x;
   ans[i]=sum-t[p-1]+x;
 }
 for(int i = 0; i < m; i++) cout<<ans[i]<<endl;
return 0;
}


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

int T[1000000][26],X[1000000],i,j,x,p,k,z;
string S[200000];

void f(int p,int j){
	if(--j)f(T[p][S[i][j]],j);
	x|=1<<S[i][j];
	for(k=26;k--;){
		z-=x>>k&X[T[p][k]];
	}
}

main(){
	for(cin>>z;cin>>S[i];i+=X[p]=1){
		for(p=0,j=S[i].size();j--;){
			k=S[i][j]-=97;
			p=T[p][k]=T[p][k]?:++x;
		}
	}
	for(;i--;){
		f(x=0,S[i].size());
	}
	cout<<-z;
}


Measured memory_bytes: 156396
//Maximum Profit
#include <iostream>

using namespace std;

int main()
{
    int num;
    cin>>num;
    int array[200001];

    for(int i=0; i<num; ++i)
    {
        cin>>array[i];
    }

    int minNum, maxNum;
    minNum=array[0];
    maxNum=-2000000000;
    for(int i=1; i<num; ++i)
    {
        maxNum=((array[i]-minNum)>maxNum)?array[i]-minNum:maxNum;
        minNum=(array[i]<minNum)?array[i]:minNum;
    }

    cout<<maxNum<<endl;
    return 0;
}



Measured memory_bytes: 3876
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s,t string
	fmt.Scan(&s,&t)
	ss := strings.Split(s,"")
	ts := strings.Split(t,"")

	count := 0
	if ss[0] == ts[0] {
		count++
	}

	if ss[1] == ts[1] {
		count++
	}

	if ss[2] == ts[2] {
		count++
	}
	fmt.Println(count)
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var a = ReadLineIntSpilit();
            var Re = Math.Min(a[0]*a[1], a[2]);

            Console.WriteLine(Re);
            ReadLine();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

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

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

    int k, n, max=0;
    cin >> k >> n;
    int *A =new int[n];
    cin >> A[0];
    for(int i=1;i<n;i++){
        cin >> A[i];
        if(A[i]-A[i-1] > max) max = A[i]-A[i-1];
    }
    if(k-A[n-1]+A[0] > max) max = k-A[n-1]+A[0];

    cout << k-max;

return 0;
}


Measured memory_bytes: 1024
#include <cstdlib>
#include <iostream>


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

  std::string odd, equal, total;
  std::cin >> odd;
  std::cin >> equal;
  if(odd.length()==equal.length()){
    for(int i = 0; i < odd.length(); i++){
      total += odd[i];
      total += equal[i];
    }
  }
  else
  {
    for(int i = 0; i < odd.length()-1; i++){
      total += odd[i];
      total += equal[i];
    }
    total += odd[odd.length()-1];
  }
  std::cout << total << std::endl;
  return EXIT_SUCCESS;
}


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a + b == c + d){
    cout << "Balanced" <<endl;
  }
  else if(a + b >= c + d){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
N , K = map(int, input().split())
A = list(map(int, input().split()))

whole = 0
right = 0
whole_list = []
right_list = []

for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            whole += 1
            if i < j:
                right += 1
    else:
        whole_list.append(whole)
        whole = 0
        right_list.append(right)
        right = 0

mod = 10 ** 9 + 7
ans = sum(right_list) * K
ans += sum(whole_list) * (K - 1) * K // 2

print(ans % mod)

Measured memory_bytes: 3188
from collections import deque

N = int(input())
A = list([int(x) for x in input().split()])

A.sort(reverse=True)

comfort = 0
comfort_list = deque()

for a in A:
    if len(comfort_list) == 0:
        comfort_list.append(a)
    else:
        max_comfort = comfort_list.popleft()
        comfort += max_comfort
        comfort_list.append(min(a, max_comfort))
        comfort_list.append(min(a, max_comfort))

print(comfort)


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

using namespace std;

int main()
{
    #ifdef HOME
    freopen("input.txt", "rt", stdin);
    #endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector <long long> a(n);
    map <long long, int> sticks;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        sticks[a[i]]++;
    }
    set <pair<long long, int>> s;
    for (int i = 0; i < n; i++){
        s.insert({a[i], sticks[a[i]]});
    }
    long long sq = 0;
    set <pair<long long, int>> :: iterator beg_it = s.end();
    beg_it--;
    set <pair<long long, int>> :: iterator end_it = s.begin();
    end_it--;
    int k = 0;
    long long alt_sq = 0;
    int id = 0;
    for (int id = 0; id < s.size(); id++){
        set <pair<long long, int>> :: iterator it = beg_it;
        if (it->second >= 4)
            alt_sq = max(alt_sq, it->first * it->first);
        if (it->second >= 2){
            k++;
            if (k == 2)
                sq *= it->first;
            else
                sq = it->first;
        }
        if (k == 2)
            break;
        beg_it--;
    }
    if (k != 2)
        sq = 0;
    cout << max(alt_sq, sq);
    return 0;
}


Measured memory_bytes: 13568
using System;
using System.Text;

namespace AGC006B{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var X = sr.Next<int>();
            var size = 2 * N - 1;

            if(X == 1 || X == size){
                Console.WriteLine("No");
                return;
            }

            Console.WriteLine("Yes");
            var sb = new StringBuilder();
            if(X < N){
                for(var i = X + N; i <= size; i++){
                    sb.AppendLine(i.ToString());
                }
                for(var i = 1; i < X + N; i++){
                    sb.AppendLine(i.ToString());
                }
            }
            if(X == N){
                for(var i = 1; i <= size; i++){
                    sb.AppendLine(i.ToString());
                }
            }
            if(X > N){
                for(var i = X - N + 1; i <= size; i++){
                    sb.AppendLine(i.ToString());
                }
                for(var i = 1; i <= X - N; i++){
                    sb.AppendLine(i.ToString());
                }
            }
            Console.Write(sb);
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 13272
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let atoi c = Char.code c - Char.code '0'

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let (a,b,h,m) = scan "%f %f %f %f" Tuple4.make

let () =
  let theta = Float.abs 2.0*.Float.pi *. ((h +. m /. 60.0) /. 12.0  -. m /. 60.0) in
  Printf.printf "%.10f\n" @@ Float.sqrt @@ a*.a +. b*.b -. 2.0*.a*.b*.cos theta


Measured memory_bytes: 5788
x=input().split()
a,b=int(x[0]),int(x[1])
while True:
    if a==0 and b==0:
        break
    elif a>b:
        print("%d %d"%(b,a))
    elif a<=b:
        print("%d %d"%(a,b))
    x=input().split()
    a,b=int(x[0]),int(x[1]) 


Measured memory_bytes: 5612
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let x: u64 = read_as_vec()[0];

    for i in 1..((x as f64).sqrt().ceil() as u64+1)*2{
        if i*(i+1)/2 >= x{
            println!("{}", i);
            return;
        }
    }
}


Measured memory_bytes: 4352
i = int(input())
fizz=[]
for x in range(1, i+1):
  if x % 3 ==0 and x%5==0:
    continue
  elif x % 3==0:
    continue
  elif x%5==0:
    continue 
  else:
    fizz.append(x)
print(sum(fizz))

Measured memory_bytes: 30020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	int answer = t;
	for(int i = 1; i < n; ++i){
		answer += min(t, a[i] - a[i - 1]);
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
int main() {
	string x;
	int N=0;
	while (cin >> x) {
		if (x == "0") {
			break;
		}
		for (int i = 0; i<x.size(); i++) {
			N += x[i] - '0';
		}
		cout << N << endl;
		N = 0;
	}
}

Measured memory_bytes: 1188
def mi():return map(int,input().split())
n,m=mi()
sc=[]
for i in range(m):
  s,c=mi()
  sc+=(s,c),
  
for i in range(0,999+1):
  h=str(i)
  if len(h)==n:
    if all([h[s-1]==str(c) for s,c in sc]):
      print(i)
      exit()
print(-1)    

Measured memory_bytes: 3064
def int_multiple():
    return  [int(c) for c in input().split()]

def int_single():
    return int(input())

def str_multiple():
    return [c for c in input().split()]

def str_single():
    return input()

# start


n = int_single()

h = int_multiple()

pno = False
curr_max = h[0] - 1
for i in range(1, n):
    if (h[i] < curr_max):
        pno = True
        break
    else:
        curr_max = max(h[i]-1, curr_max)

if pno:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

bool is_prime(int num){
    for(int i = 2; i * i <= num; i++){
        if (num % i == 0) return false;
    }
    return true;
}

int main(void){
    int X; cin >> X;
    
    int p = X;
    while(!is_prime(p)) p++;
    
    cout << p << endl;
}


Measured memory_bytes: 256
# Double Helix

b = input()

def getAns(b) :
    if 'A' == b :
        return "T"
    elif 'T' == b :
        return "A"
    elif 'C' == b :
        return "G"
    elif 'G' == b :
        return "C"
    else :
        return ""

print(getAns(b))

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const int inf = 1e9;
int main(){
	lli n,k;
	cin >> n >> k;
	vector<vector<int>> dbl(64, vector<int>(n));
	for(int i=0; i<n; i++){
		cin >> dbl[0][i];
		dbl[0][i]--;
	}
	for(int i=1; i<64; i++){
		for(int j=0; j<n; j++){
			dbl[i][j] = dbl[i-1][dbl[i-1][j]];
		}
	}

	int ans = 0;
	for(int i=63; i>=0; i--){
		if(k>>i&1){
			ans = dbl[i][ans];
		}
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 54180
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true){
			int number = Integer.parseInt(br.readLine());

			if (number == 0)
				return;
			int a_player = 0;
			int b_player = 0;

			for (int i = 0; i < number; i++){
				String input[] = br.readLine().split(" ");
				int a = Integer.parseInt(input[0]);
				int b = Integer.parseInt(input[1]);

				if (a == b){
					a_player += a;
					b_player += b;
				}
				else if (a < b) {
					b_player += a + b;
				}
				else {
					a_player += a + b; 
				}
			}

			System.out.println(a_player + " " + b_player);
		}
	}
}

Measured memory_bytes: 34164
#include<iostream>
#include<stdio.h>
#include<fstream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<set>
#include<string>
#include<queue>
#include<map>
#include<iomanip>
#include<cassert>
#include<complex>
#include<functional>
#include<list>
#include<cmath>
#include<stack>
#include<assert.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define F first
#define S second
using namespace std;
LL t[55],p[55];
LL n,k;
LL ans;
void dfs(LL x,LL m){
  if(m==0)
    return;
  if(x==0){
  	ans++;
  	return;
  }
  if(m>=t[x]-1){
  	ans+=p[x];
  	return;
  }
  if(m>=t[x-1]+2){
  	ans+=p[x-1]+1;
  	dfs(x-1,m-t[x-1]-2);
  }
  else
    dfs(x-1,m-1);
}
int main(){
  cin>>n>>k;
  t[0]=1;
  p[0]=1;
  for(LL i=1;i<=n;i++){
  	t[i]=2*t[i-1]+3;
  	p[i]=2*p[i-1]+1;
  }
  dfs(n,k);
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
l.sort()
lcount=[]
count=0
now=l[0]
for i in range(n):
  if now==l[i]:
    count+=1
  else:
    lcount.append([count,now])
    count=1
    now=l[i]
lcount.append([count,now])
if len(lcount)==1:
  print(n)
elif len(lcount)==2:
  l1=lcount[0][0]
  l2=lcount[1][0]
  if lcount[1][1]-lcount[0][1]==1:
    print(l1+l2)
  else:
    print(max(l1,l2))
else:
  count=0
  for i in range(1,len(lcount)-1):
    scount=0
    scount+=lcount[i][0]
    if lcount[i][1]-lcount[i-1][1]==1:
      scount+=lcount[i-1][0]
    if lcount[i][1]-lcount[i+1][1]==-1:
      scount+=lcount[i+1][0]
    if scount>count:
      count=scount
  count1=lcount[0][0]
  if lcount[1][1]-lcount[0][1]==1:
    count1+=lcount[1][0]
  count2=lcount[-1][0]
  if lcount[-2][1]-lcount[-1][1]==-1:
    count2+=lcount[-2][0]
  print(max(count,count1,count2))


Measured memory_bytes: 14004
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    ll n,d,a;
    cin >> n >> d >> a;
    d *= 2;
    vector<P> xh(n);
    rep(i,n) cin >> xh[i].fi >> xh[i].se;
    queue<P> bombZone;
    SORT(xh);
    ll ans = 0;
    ll totalDamage = 0;
    rep(i,n){

        
        ll h = xh[i].se;
        ll x = xh[i].fi;
        while(bombZone.size() && bombZone.front().fi < x){
            totalDamage -= bombZone.front().se;
            bombZone.pop();
        }
        h -= totalDamage;
        
        if (h>0){
            ll count = (h+a-1)/a;
            ans += count;
            totalDamage += a*count;
            bombZone.push(mp(x+d,a*count));
        }
    }
    cout << ans;
    
    
}


Measured memory_bytes: 4992
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max(a, b) * 2 - 1 + (a == b) << '\n';
}


Measured memory_bytes: 888
N = input()
K = int(input())
m = len(N)
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp[0][0][0] = 1

for i in range(1, m + 1):
    l = int(N[i - 1])
    for k in range(K + 1):
        dp[i][1][k] += dp[i - 1][1][k]
        if l != 0:
            dp[i][1][k] += dp[i - 1][0][k]
        else:
            dp[i][0][k] += dp[i - 1][0][k]
        if k - 1 >= 0:
            dp[i][1][k] += 9 * dp[i - 1][1][k - 1]
            if l != 0:
                dp[i][0][k] += dp[i - 1][0][k - 1]
                dp[i][1][k] += (l - 1) * dp[i - 1][0][k - 1]

print(dp[m][0][K] + dp[m][1][K])

Measured memory_bytes: 3064
#include<iostream>

int main(){
    int N, K;
    std::cin >> N >> K;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        int h;
        std::cin >> h;
        if(h >= K) cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
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 main():
    N = int(input())
    A = read_list()
    res = 10 ** 20
    
    for i in range(2):
        tmp = 0
        t = 0
        s = (-1) ** i
        for a in A:
            t += a
            if  t * s >= 0:
                tmp += abs(t) + 1
                t = -s
            s = -s
        res = min(res, tmp)
    print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 88436
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
	public static void main(String[] args)throws IOException {
		FastReader sc = new FastReader();
		PrintWriter pw = new PrintWriter(System.out);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		System.out.println(Math.max(a * c, Math.max(a * d, Math.max(b * c, b * d))));



	}
}





class FastReader {
	BufferedReader br;
	StringTokenizer st;

	public FastReader() {
		br = new BufferedReader(new
		                        InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException  e) {
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> ans(N, 0);
    for (int i = 0; i < M; i++){
        int a,b;
        cin >> a >> b;
        ans.at(a-1)++;
        ans.at(b-1)++;
    }
    for (int i = 0; i < N; i++){
        cout << ans.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        string A,B,C;
        cin >> A>>B>>C;

        
                cout <<'A'<<B[0]<<'C' << endl;
     

        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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 {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return 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 {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////


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

	vector<ll>a(n + 1,0);
	repn(i, n) {
		cin >> a[i];
		a[i]--;
	}

	vector<ll> d(n + 1, 0);
	repn(i,n) {
		if (a[i - 1] <= a[i]) { d[i] = d[i - 1] + (a[i] - a[i - 1]); }
		else { d[i] = d[i - 1] + (m + a[i] - a[i - 1]); }
	}

	vector<ll> sa(m, 0);
	repn(i, n-1) {
		sa[(a[i+1]+1) % m] += (d[i + 1] - d[i]);
	}
	vector<ll> ans(m);

	rep(i, m) {
		ll guru = (d[n] + m - i) / m - (d[1] + m - i) / m;

		//cout << i << " " << sa[i] << " " << guru << endl;
		sa[i] -= guru;
	}

	
	repn(i, n - 1) {
		if (a[i + 1] >= a[i]) { ans[0] += a[i + 1] - a[i]; }
		else { ans[0] += a[i + 1]; }
	}

	//cout << ans[0] << endl;

	for (ll i = 1; i < m; i++) {
		ans[i] = ans[i - 1] + sa[i];
		//cout << ans[i] << endl;
	}
	rep(i, m) {
		ans[i] += (d[n] + m - i) / m - (d[1] + m - i) / m;
		//cout << ans[i] << endl;
	}

	ll mn = INF;
	rep(i, m) mn = min(mn, ans[i]);

	cout << mn << endl;
	
	
	
	system("PAUSE");
}


Measured memory_bytes: 3576