akhauriyash/Code-Regression huggingface dataset:
/**
 *   created: 23 May 2019  19:00:07
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) (c).begin,(c).end()
#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		vector< double > v(n);
		rep(i,0,n)
			cin>>v[i];
		vector< vector<double> > mem(n, vector<double>(n+1,0.0));
		mem[0][0] = 1-v[0];
		mem[0][1] = v[0];
		rep(i,1,n){
			mem[i][0] = mem[i-1][0]*(1-v[i]);

			// trace3(mem[i][0],mem[i-1][0],(1-v[i]));
			rep(j,1,n+1){
				if(j>i+1)
					break;
				mem[i][j] = mem[i-1][j-1]*v[i];
				// if(mem[i-1][j]>0)
					mem[i][j] += mem[i-1][j]*(1-v[i]);
			}
		}
		double res = 0.0;
		for(int j=n/2+1;j<=n;j++)
			res+=mem[n-1][j];
		printf("%.10lf",res);
		// cout<<endl;
		// rep(i,0,n+1){
		// 	rep(j,0,n)
		// 		printf("%.10lf ",mem[j][i]);
		// 	cout<<endl;
		// }
	}
  return 0;
}


Measured memory_bytes: 70784
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (s,) = input!(String);

    println!("{}", &s[0..3]);
}

fn main() {
    solve();
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define MAXNUM 222222
typedef long long ll;
char s[MAXNUM];
int main()
{
    scanf("%s",s);
    int ssize=strlen(s);
    int bef=0;ll res=0;
    for(int i=ssize-1;i>=0;i--)
    {
        if(bef&&s[i]=='C'&&s[i+1]=='B')bef++;
        else if(s[i]=='B'&&s[i+1]=='C')bef++;
        else if(s[i]=='A'&&s[i+1]=='B'&&bef)res+=bef+1,s[i]=s[i+1];
        else bef=0;
    }
    printf("%lld\n",res/2);
}

Measured memory_bytes: 384
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <functional>
#include <string>
#include <sstream>
#include <limits.h>
#include <bitset>  // std::bitset<N>

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    string S[H];
    for(int i = 0;i <H; i++){
      cin >> S[i];
    }
    int mat[H][W];
    int mat2[H][W];
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        mat[i][j] = 0;
        mat2[i][j] = 0;
      }
    }
    for(int i = 0; i < H; i++){
      for(int k = 0; k < W; k++){
        if(S[i][k] == '#'){
          continue;
        }else{
          int tmp = 0;
          int startK = k;
          int endK = k;
          while(k < W && S[i][k] != '#'){
            tmp++;
            endK = k;
            k++;
          }
          for(int t = startK; t <= endK; t++){
            mat[i][t] = tmp;
          }
        }
      }
    }
    for(int i = 0; i < W; i++){
      for(int k = 0; k < H; k++){
        if(S[k][i] == '#'){
          continue;
        }else{
          int tmp = 0;
          int startK = k;
          int endK = k;
          while(k < H && S[k][i] != '#'){
            tmp++;
            endK = k;
            k++;
          }
          for(int t = startK; t <= endK; t++){
            mat2[t][i] = tmp;
          }
        }
      }
    }
    int max = -1;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        mat[i][j] = mat[i][j] + mat2[i][j] -1;
        if(mat[i][j] > max){
          max = mat[i][j];
        }
      }
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 35840
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static ArrayList<Integer>[] edge;
	static long mod=1000000007;
	static long[][] dp;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		edge=new ArrayList[n];
		dp=new long[n][2];
		for(int i=0; i<n; i++){
			Arrays.fill(dp[i],1);
		}
		for(int i=0; i<n; i++){
			edge[i]=new ArrayList<>();
		}
		for(int i=1; i<n; i++){
			int x=sc.nextInt()-1;
			int y=sc.nextInt()-1;
			edge[x].add(y);
			edge[y].add(x);
		}
		dfs(0,0);
		System.out.println((dp[0][0]+dp[0][1])%mod);
	}
	static void dfs(int now,int from){
		for(int i:edge[now]){
			if(i!=from){
				dfs(i,now);
				dp[now][0]=(dp[now][0]*(dp[i][0]+dp[i][1]))%mod;
				dp[now][1]=dp[now][1]*dp[i][0]%mod;
			}
		}
	}
}

Measured memory_bytes: 120132
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0,d=0, x = 0, y = 0, z = 0,n=0,m=0, maxy = 0, mini = 9999, counter = 0, s = 0, endp = 0, checker = 0;
long long int one = 0, two = 0, four = 0;
std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001],sec[100001],pointx[100001],pointy[100001];
long long int iremono2[100001],check[100001];
std::vector<long long int>kinds{}, ans{}, kaku{};
char moji, moji2;
bool okada = false, okada2 = false;
std::string output, output2, input,input2;
char rev[100001];
unsigned long long int kakunou2[101][101] = {};
unsigned long long int M, A, R, C, H;

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

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

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}
int main()
{
	cin >> a;
	rep(i, a) {
		cin >> b;
		kaku.push_back(b);
	}
	std::sort(kaku.begin(), kaku.end());
	kaku.push_back(0);
	for (int i = 1; i <= a; i++) {
		if (kaku[i] != kaku[i - 1]) {
			counter++;
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def solve(N, K, Q, A):
    solved = [0] * N
    for a in A:
        solved[a] += 1

    def qualified(n):
        return Q - n < K

    return [qualified(n) for n in solved]


def main():
    N, K, Q = [int(e) for e in inp().split()]
    A = [int(input()) - 1 for _ in  range(Q)]

    ans = solve(N, K, Q, A)
    for a in ans:
        print('Yes' if a else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 58200
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 数値の入力
        //        int s = sc.nextInt();
        // 文字の入力
        String str = sc.next();
        boolean flg =false;
        if (str.contains("A")) {
            if (str.contains("B")) {
            	flg = true;
            }
        }
        
        if(flg) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }
    }
}


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

int main(){
  int A,B,C;
  
  cin >> A >> B >> C;
  
  if(A*B*C == 5*5*7 && A+B+C == 5+5+7){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
// DPL_2_A
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int n,hen;
int inf=pow(10,9);
vector<vector<int>> dist(15,vector<int>(15,inf));
vector<vector<int>> dp(1<<15,vector<int>(15,-1)); 

int dfs(int S,int now,int count){ //Sは訪れたことのある頂点の記録、nowは現在地点、countは訪れた頂点数
    if(dp[S][now]!=-1) return dp[S][now]; //記録済み
    if(count==n && now==0) return dp[S][now]=0; //ゴール
    int ans=inf; //記録の候補のスタートはinf
    for(int next=0;next<n;next++){
        if(!(S>>next&1)){ //まだnextを訪問していない
            if(next==0){
                if(count!=n-1) continue; //次に0を訪問できるのは、既にn-1地点訪問してるときのみ
            }
            if(dist[now][next]!=inf) ans=min(ans,dfs(S|1<<next,next,count+1)+dist[now][next]); //now→nextにいけないときはスルー
        }
    }
    dp[S][now]=ans;
    return ans;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    cin>>n>>hen;
    rep(i,hen){
        int s,t,d;
        cin>>s>>t>>d;
        dist[s][t]=d;
    }
    int ans=dfs(0,0,0);
    if(ans==inf) cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}


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

constexpr int X = 100;

void solve() {
    int x;
    std::cin >> x;

    std::vector<bool> used(X + 2, false);
    int n;
    std::cin >> n;
    while (n--) {
        int p;
        std::cin >> p;
        used[p] = true;
    }

    int ans = 0;
    for (int p = 1; p <= X + 1; ++p) {
        if (used[p]) continue;
        if (std::abs(x - p) < std::abs(x - ans)) {
            ans = p;
        }
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
ll gcd(ll A,ll B){
  if(A<B){
    swap(A,B);
  }
  ll r = A%B;
  while(r!=0){
    A = B;
    B = r;
    r = A%B;
  }
  return B;
}
ll lcm(ll A,ll B){
  ll p = A*B/gcd(A,B);
  return p;
}
  
    

int main(){
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  ll ans = (B-A)+1 - ((B/C)-((A-1)/C)) - ((B/D)-((A-1)/D)) + ((B/lcm(C,D))-((A-1)/lcm(C,D)));
  //cout << B-A << " " << ((B/C)-((A-1)/C)) << " " << ((B/D)-((A-1)/D)) << " " << ((B/lcm(C,D))-((A-1)/lcm(C,D))) << endl;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;vector<vector<int> >a(11,vector<int>(331));void r(int n,int u,int s,int d){a[n][s]++;for(int i=0;i<10;i++)if(!(u>>i&1))r(n+1,u^1<<i,s+d*i,d+1);}main(){r(0,0,0,1);for(int n,s;cin>>n>>s;)cout<<a[n][s]<<endl;}

Measured memory_bytes: 804
#import numpy as np
#import math
#from decimal import *
#from numba import njit
from bisect import bisect_left

#@njit
def main():
    N = int(input())
    a = list(map(int, input().split()))
    edges = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u,v = map(int, input().split())
        edges[u] += v,
        edges[v] += u,

    ans = [0]*(N+1)
    lastLis = []
    visited = [False]*(N+1)
    parent = {}
    n = 1
    stack = []
    while True:
        #print(n, lastLis, stack)
        if not visited[n]:
            if len(lastLis) == 0 or a[n-1] > lastLis[-1]:
                lastLis.append(a[n-1])
                stack += (len(lastLis)-1, -1),
            else:
                index = bisect_left(lastLis, a[n-1])
                stack += (index, lastLis[index]),
                lastLis[index] = a[n-1]
            ans[n] = len(lastLis)
            visited[n] = True
        hasNext = False
        for d in edges[n]:
            if not visited[d]:
                parent[d] = n
                n = d
                hasNext = True
        if not hasNext:
            if n == 1:
                n = 0
                break
            n = parent[n]
            # 巻き戻し
            index, value = stack.pop(len(stack)-1)
            if value < 0:
                lastLis.pop(index)
            else:
                lastLis[index] = value

    for i in range(1, len(ans)):
        print(ans[i])




main()


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



struct P
{
    int x,y,z;

    bool operator<(const P &a)const{

        if(x!=a.x) return x>a.x;
        return y>a.y;
    }

};

vector<int> v[111111],v1[111111];

//bitset<4001000> b;
int i,n,d,m,k,a,b,c;

int o[111311];
int l[111111];
int j[111111];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000009,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[111111];
stack<int> s;
//set<int> se;
//priority_queue<int> q;
queue<int> q;
//string r,r1;
char r[1111];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;


//deque<int> de;
//srand((int)time(NULL));




bool as(P a,P b)
{
    //if(a.x!=b.x)
    //   return a.x>b.x;
    //return a.y<b.y;
    return a.x+a.y>b.x+b.y;

}

int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<a+b;t++)
    {
        scanf("%d %d",&n,&m);
        v[n].push_back(m);
        v1[m].push_back(n);
    }
    for(int t=1;t<=a;t++)
    if(v1[t].size()==0) n=t;
    q.push(n);
    for(;q.size();q.pop())
    {
        for(int h=0;h<v1[q.front()].size();h++)
        if(l[q.front()]<l[v1[q.front()][h]]+1)
        {
            l[q.front()]=l[v1[q.front()][h]]+1;
            o[q.front()]=v1[q.front()][h];
        }
        for(int h=0;h<v[q.front()].size();h++)
        {
            j[v[q.front()][h]]++;
            if(j[v[q.front()][h]]==v1[v[q.front()][h]].size())
            {
                q.push(v[q.front()][h]);
            }
        }
    }
    for(int t=1;t<=a;t++)
        printf("%d\n",o[t]);
}





Measured memory_bytes: 13568
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
using namespace std;
using ulong = unsigned long;
using ll = long long;
const int M = 1e9 + 7;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0){
		cout << 0 << endl;
	}else{
		cout << min({1ll * a * b, 1ll * b * c, 1ll * c * a}) << endl;
	}

	return 0;
}



Measured memory_bytes: 504
from collections import defaultdict
import numpy as np

if __name__ == '__main__':
    N = int(input())
    L = list(map(int,input().split()))
    L1 = []
    L2 = []
    L.sort()
    L.append(1000000000000)
    c = L[0]
    acc = 0
    for l in L:
        if l != c:
            L1.append(c)
            c = l
            L2.append(acc)
            acc = 1
        else:
            acc += 1

    L3 = list(zip(L1, L2))


    accum = 0

    for i,(i1,i2) in enumerate(L3):
        for j,(j1,j2) in enumerate(L3):
            #print(f"i {i} j {j} i1 {i1} j1 {j1} i2 {i2} j2 {j2}")
            if i >= j:
                continue

            #print(L3)
            lis = list(filter(lambda elem : (i1 + j1 > elem[0]) and (i1 < elem[0]) and (j1 < elem[0]), L3))
            #print(i1, j1)
            #print(i2, j2)
            #print(lis)
            #print("")
            if lis != []:
                accum += i2*j2*np.sum(list(elem[1] for elem in lis))

    print(int(accum))


Measured memory_bytes: 26908
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
using namespace std;
#define MOD (ll)(1e9 + 7);

ll modpow(ll a, int n)
{
    if (n == 0)
        return 1;
    ll prev = modpow(a, n / 2);
    if (n % 2 == 0)
    {
        return (prev * prev) % MOD;
    }
    else
    {
        return (prev * prev * a) % MOD;
    }
}

ll calc(string &s)
{
    if (s == "0")
    {
        return 1ll;
    }
    if (s == "1")
    {
        return 3ll;
    }
    if (s[0] == '0')
    {
        s.erase(s.begin());
        return calc(s);
    }
    else
    {
        s.erase(s.begin());
        int n = s.size();
        return (modpow(3, n) + 2 * calc(s)) % MOD;
    }
}

int main()
{
    string s;
    cin >> s;
    cout << calc(s) << endl;
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<string>

int main()
{
	std::string str;

	std::cin >> str;

	size_t strL = str.length();

	for(size_t i=0; i<strL; ++i)
	{
		std::cout << str[strL-1-i];
	}
	std::cout << '\n';

}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
long long i[1111][1111];
lol u[111111];
lol ii[121111];
bool o;
bool ans[5];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h=0,j=0,can;
  string s;
  cin >>a>>b;
  if(a+b==2) cout <<"1\n";
  else{
    if(a>2&&b>2) d=(a-2)*(b-2);
    if(a==1) d+=b-2;
    if(b==1) d+=a-2;
    cout <<d<<'\n';
  }
  return (0);
}


Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-} 
import qualified Data.Text as T
import qualified Data.Text.IO as I

comb :: Int -> Int
comb n = n*(n-1) `div` 2

main :: IO ()
main = do
  line <- I.getLine
  let tokens = T.splitOn " " line
  let nums = map (read . T.unpack) tokens
  let ans = (comb (nums !! 0)) + (comb (nums !! 1))
  print ans

Measured memory_bytes: 508
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long ll;
using namespace std;

int main() {
    int N, K; cin >> N >> K;
    
    ll q = (ll)N/K;
    ll q2 = (ll)(N+K/2)/K;
    
    if(K%2) cout << q*q*q << endl;
    else cout << q*q*q+q2*q2*q2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(a>b)
{
printf("a > b\n");
}
if(a==b)
{
printf("a == b\n");
}
if(a<b)
{
printf("a < b\n");
}
return 0;
}

Measured memory_bytes: 2540
import sys

n, b, *l = map(int, sys.stdin.read().split())

def main():
    d = 0
    for i in range(n):
        d += l[i]
        if d > b:
            return i + 1
    return n + 1

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 2940
#include<stdio.h>

int main(){
  int S,h,m,s;
  scanf("%d",&S);
    h = S / 3600;
    m = (S % 3600) / 60;
    s = (S % 3600) % 60;
  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
	string str;
	cin >> str;
	long long ans = 0, tmp = 0;
	size_t pos = str.find('W');
	while (pos != string::npos)
	{
		ans += pos - tmp;
		tmp++;
		pos = str.find('W', pos + 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import sys
import math

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


inf = float("inf")


def main():
    d, g = MI()
    pc = [LI() for _ in range(d)]

    ans = inf
    for bit in range(1 << d):
        c = 0
        score = 0
        for i in range(d):
            if bit & (1 << i):
                c += pc[i][0]
                score += pc[i][0] * 100 * (i + 1) + pc[i][1]

        if score >= g:
            ans = min(ans, c)
        else:
            for i in reversed(range(d)):
                if bit & (1 << i):
                    continue
                res = math.ceil((g - score) / (100 * (i + 1)))
                if res < pc[i][0]:
                    ans = min(ans, c + res)
                break

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> a(n);
    cin >> a;
    sort(all(a));
    int ans = accumulate(a.begin(), a.begin() + n - 1, 0);
    ans += a[n - 1] / 2;
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

bool comp(int a, int b) {
    return abs(a) > abs(b);
}

const int MOD = 1e9 + 7;
const double EPS = 1e-9;

bool can(int a, int b, int k) {
    if (b % 2) {
        b--;
    }
    if (k % 2) {
        return a + b >= k && a > 0;
    } else {
        return a + b >= k;
    }
}

int n, k;
vector<int> arr;
vector<double> pa;
vector<double> pb;
vector<int> ra;
vector<int> rb;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k;
    arr.resize(n);
    int a = 0;
    int b = 0;
    int z = 0;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        if (arr[i] > 0) {
            a++;
        } else if (arr[i] < 0) {
            b++;
        } else {
            z++;
        }
    }
    sort(arr.begin(), arr.end(), comp);
    if (can(a, b, k)) {
        pa.push_back(0);
        pb.push_back(0);
        ra.push_back(1);
        rb.push_back(1);
        for (int x : arr) {
            if (x > 0) {
                pa.push_back(pa.back() + log(x));
                ra.push_back((ra.back() * x) % MOD);
            } else if (x < 0) {
                pb.push_back(pb.back() + log(-x));
                rb.push_back((rb.back() * -x) % MOD);
            }
        }
        double fin = -1;
        int ans = INT_MIN;
        for (int i = 0; i <= k; i += 2) {
            if (i < pb.size() && k - i < pa.size()) {
                if (pb[i] + pa[k - i] > fin) {
                    fin = pb[i] + pa[k - i];
                    ans = (rb[i] * ra[k - i]) % MOD;
                }
            }
        }
        cout << ans << '\n';
    } else if (z > 0) {
        cout << 0 << '\n';
    } else {
        int res = 1;
        for (int i = n - 1; i >= n - k; i--) {
            res = (((res * arr[i]) % MOD) + MOD) % MOD;
        }
        cout << res << '\n';
    }

    fflush(stdout);
    return 0;
}


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

int main(){
	int n,q,c,t,x;
	cin>>n>>q;
	priority_queue<int> pq[1005];
	for(int i=0;i<q;i++){
		cin>>c;
		switch(c){
			case 0:
				cin>>t>>x;
				pq[t].push(x);
				break;
			case 1:
				cin>>t;
				if(!pq[t].empty()) cout<<pq[t].top()<<endl;
				break;
			case 2:
				cin>>t;
				if(!pq[t].empty()) pq[t].pop();
		}
	}
	return 0;
}


Measured memory_bytes: 4088
program lower
  implicit none
  integer :: n, h(100001) = 0, i = 1, j = 1, m = 0
  read(*,*) n
  read(*,*) h(1:n)
  h(n+1) = 2e9
  do while (i <= n)
    if (h(i) < h(i+1)) then
      m = max(m,i-j)
      j = i+1
    end if
    i = i+1
  end do
  write(*,'(i0)') m
end program lower

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


int main()
{
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n)
    cin >> p[i];
  int ans = 0;
  for (int i=1; i<n-1; i++)
    if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1]))
      ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,k = gets.chomp.split(" ").map(&:to_i)
v = gets.chomp.split(" ").map(&:to_i)
max = 0
for a in 0..k
  for b in 0..k-a
    values = []
    left = 0
    right = n
    cnt = 0
    a.times do
      if left < n
        left += 1
        values << v[left-1]
        cnt += 1
      end
    end
    b.times do
      if right > left
        right -= 1
        values << v[right]
        cnt += 1
      end
    end
    rest = k-cnt
    values = values.sort
    rest.times do |i|
      if i+1 <= values.length
        values[i] = 0 if values[i] < 0
      end
    end
    if values.length != 0
      max = [max, values.inject(:+)].max
    end
  end
end
puts max

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

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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<int> a(n);
    for(auto &x:a)cin >> x;

    sort(a.begin(),a.end(),greater<int>());

    int alice=0,bob=0;
    for(int i=0;i<n;i++){
        if(i%2==0)alice+=a[i];
        else bob+=a[i];
    }

    cout << alice-bob << endl;

    return 0;
}


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

#define rep(i, s, t) for (int i = s; i < int(t); ++i)

#define sc	scanf
#define pr	printf
#define ff	first
#define ss	second
#define mp	make_pair
#define pb	push_back
#define eb	emplace_back
#define range(c)	c.begin(), c.end()
#define lowbit(x)	((x) & -(x))
#define pop_count	__builtin_popcount
#define pop_count_64	__builtin_popcountll
#define tail_count	__builtin_ctz
#define tail_count_64	__builtin_ctzll
#define lead_count	__builtin_clz
#define lead_count_64	__builtin_clzll

#define TEMP template<typename
#define CONST(type) constexpr type const

TEMP... Ts> struct is_con { static CONST(bool) value = false; };
TEMP... Ts> struct is_con<vector<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<list<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<deque<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<map<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_map<Ts...>> { static CONST(bool) value = true; };

TEMP T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> const& p) { return os << "<" << p.ff << "," << p.ss << ">"; }
TEMP T> typename enable_if<is_con<T>::value, ostream>::type& operator<<(ostream& os, T const& c) {
	os << "{";
	bool first = true;
	for (auto const& x : c) {
		if (first) first = false;
		else os << ",";
		os << " " << x;
	}
	return os << " }";
}

TEMP T, typename... Ts> void dbg(T h, Ts... t) { cerr << " " << h; dbg<Ts...>(t...); }
template<> void dbg<int>(int x) { cerr << endl; }

#ifdef LOCAL
#define debug(...) cerr << "[ "#__VA_ARGS__" ] :", dbg(__VA_ARGS__, 0)
#else
#define debug(...) 0
#endif

TEMP T, typename U> using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
TEMP T> using ordered_set = ordered_map<T, null_type>;

typedef long long i64;
typedef decimal::decimal128 i99;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<i64> vl;

TEMP T> T& minn(T& lhs, T const& rhs) { return lhs = min(lhs, rhs); }
TEMP T> T& maxx(T& lhs, T const& rhs) { return lhs = max(lhs, rhs); }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	cout << (1'000'000 - n) % 1000 << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  int ans=0;
  for(int i=1;i*i<=m;++i){
    if(m%i==0){
      if(n<=(m/i)){ans=max(ans,i);}
      if(n<=(i))ans=max(ans,m/i);
    }
  }
  cout<<ans<<"\n";
}


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

int main(void){
	char pattern;
	int n, rank;
	bool card[4][13];
	
	for(int i = 0; i < 4; ++i){
		for(int j = 0; j < 13; ++j){
			card[i][j] = false;
		}	
	}
	
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> pattern >> rank;
		if(pattern == 'S'){
			card[0][rank-1] = true;
		} else if(pattern == 'H'){
			card[1][rank-1] = true;
		} else if(pattern == 'C'){
			card[2][rank-1] = true;
		} else if(pattern == 'D'){
			card[3][rank-1] = true;
		}
	}
	
	for(int i = 0; i < 4; ++i){
		for(int j = 0; j < 13; ++j){
			if(i == 0 && card[i][j] == false){
				printf("S %d\n", j + 1);
			} else if(i == 1 && card[i][j] == false){
				printf("H %d\n", j + 1);
			} else if(i == 2 && card[i][j] == false){
				printf("C %d\n", j + 1);
			} else if(i == 3 && card[i][j] == false){
				printf("D %d\n", j + 1);
			}
		}	
	}
	return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    int H, W, K; cin >> H >> W >> K;
    vector<string> C(H); for (auto &c : C) cin >> c;
    int ans = 0;
    for (int row = 0; row < (1 << H); row++) {
        for (int col = 0; col < (1 << W); col++) {
            int cnt = 0;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if (C[i][j] == '#' && ((row >> i) & 1) && ((col >> j) & 1)) {
                        cnt++;
                    }
                }
            }
            ans += cnt == K;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	H, W := nextInt(), nextInt()
	grid := make([][]byte, H)
	for i := 0; i < H; i++ {
		grid[i] = []byte(next())
	}

	dp := make([][]int, H)
	for i := 0; i < H; i++ {
		dp[i] = make([]int, W)
	}

	if grid[0][0] == '#' {
		dp[0][0] = 1
	}
	for x := 1; x < W; x++ {
		if grid[0][x] == grid[0][x-1] {
			dp[0][x] = dp[0][x-1]
		} else {
			dp[0][x] = dp[0][x-1] + 1
		}
	}
	for y := 1; y < H; y++ {
		if grid[y][0] == grid[y-1][0] {
			dp[y][0] = dp[y-1][0]
		} else {
			dp[y][0] = dp[y-1][0] + 1
		}
	}

	for y := 1; y < H; y++ {
		for x := 1; x < W; x++ {
			fromLeft := dp[y][x-1]
			if grid[y][x] != grid[y][x-1] {
				fromLeft++
			}

			fromUp := dp[y-1][x]
			if grid[y][x] != grid[y-1][x] {
				fromUp++
			}

			dp[y][x] = Min(fromLeft, fromUp)
		}
	}

	fmt.Println((1 + dp[H-1][W-1]) / 2)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
//cout << fixed << setprecision(12);
ll n;
cin>>n;
if(n%1000==0){
cout << 0 << endl;}
else{
ll a = n/1000;
cout << (a+1)*1000-n << endl;}}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define lli long long int
#define llu long long unsigned int
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FOR(i,s,e) for(i=s; i<e; i++)
#define mod 1000000007
#define F first
#define S second
#define plli pair<lli,lli>
#define pqlli priority_queue<lli>
#define test(t) cin>>t; while(t--)
using namespace std;

lli power(lli a, lli b, lli M = mod)
{
	lli result = 1;
    for (;;)
    {
        if (b & 1)
            result = (result*a)%M;
        b >>= 1;
        if (!b)
            break;
        a = (a*a)%M;
    }
    return result;
}
map<lli,lli> dis;

void bfs(vector<vector<lli> > &g, lli start, lli n)
{
	queue<plli> q;
	q.push(mp(start, 0));
	int mark[n+1];
	memset(mark, 0, sizeof(mark));
	mark[start] = 1;
	while(!q.empty())
	{
		lli temp = q.front().first;
		lli c = q.front().second;
		q.pop();
		for(auto i : g[temp])
		if(mark[i] == 0)
		q.push(mp(i, c+1)), dis[c+1]++, mark[i] = 1;
	}
}

int main()
{
	IOS;
	lli n,x,y;
	string s;
	cin>>s;
	if((s[2]==s[3]) && (s[4]==s[5]))
	cout<<"Yes\n";
	else
	cout<<"No\n";
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    static int W,H,x,y,r;
  
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      W = sc.nextInt();    
      H = sc.nextInt();    
      x = sc.nextInt();
      y = sc.nextInt();    
      r = sc.nextInt();
      //左にはみ出す場合
      if (x<r) {
        System.out.println("No");
        //右にはみ出す場合
        } else if (W<x+r) {
          System.out.println("No");
        //下にはみ出す場合
        } else if (y-r<0) {
          System.out.println("No");
        //上にはみ出す場合
        } else if (y+r>H) {
          System.out.println("No");
      } else {
        System.out.println("Yes");
      }
    }
}


Measured memory_bytes: 26304
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=a*c;
    ll y=a*d;
    ll z=b*c;
    ll w=b*d;
    cout<<max(x,max(y,max(z,w)))<<endl;;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    string N;
    cin >> N;
    const int MEM = 1114514;
    int dp[MEM][2];
    REP(i,MEM){
        REP(j,2){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=N[0]-'0';
    dp[0][1]=11-(N[0]-'0');
    
    REP(i,N.size()-1){
        dp[i+1][0]=min(dp[i+1][0],dp[i][0]+N[i+1]-'0');
        dp[i+1][0]=min(dp[i+1][0],dp[i][1]+N[i+1]-'0');
        
        dp[i+1][1]=min(dp[i+1][1],dp[i][0]+11-(N[i+1]-'0'));
        dp[i+1][1]=min(dp[i+1][1],dp[i][1]+9-(N[i+1]-'0'));
    }
    cout << min(dp[N.size()-1][0],dp[N.size()-1][1]) << endl;
    return 0;
}



Measured memory_bytes: 18820
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int a,b,q;
  cin>>a>>b>>q;
  llong s[a];
  llong t[b];
  REP(i,a){
    cin>>s[i];
  }
  REP(i,b){
    cin>>t[i];
  }
  llong x[q];
  vector<llong> VQ;
  REP(i,q){
    llong temp;
    cin>>temp;
    x[i] = temp;
    VQ.pb(temp);
  }
  VSORT(VQ);


  map<llong,llong> ans;

  llong LS,LT,RS,RT;
  LS = 0;
  RS = 1;
  LT = 0;
  RT = 1;

  REP(i,VQ.size()){
    llong start = VQ[i];
    while(s[RS]<start && RS<a-1){
      RS++;
      LS++;
    }
    while(t[RT]<start && RT<b-1){
      RT++;
      LT++;
    }
    llong mini = (llong)INF * (llong)1000;
    llong dLS,dRS,dLT,dRT;
    bool LSOK,RSOK,LTOK,RTOK;
    LSOK = true;
    RSOK = true;
    LTOK = true;
    RTOK = true;
    if(start<s[0])LSOK = false;
    if(start>=s[a-1])RSOK = false;
    if(start<t[0])LTOK = false;
    if(start>=t[b-1])RTOK = false;

    dLS = abs(start - s[LS]);
    dRS = abs(s[RS] - start);
    dLT = abs(start - t[LT]);
    dRT = abs(t[RT] - start);

    if(!LSOK)dRS = abs(start - s[0]);
    if(!LTOK)dRT = abs(start - t[0]);
    if(!RSOK)dLS = abs(start - s[a-1]);
    if(!RTOK)dLT = abs(start - t[b-1]);
    //cout<<dLS<<"   "<<dRS<<"   "<<dLT<<"   "<<dRT<<endl;
    if(LSOK==true&&LTOK==true)mini = min(mini,max(dLS,dLT));
    if(RSOK==true&&RTOK==true)mini = min(mini,max(dRS,dRT));
    if(LSOK==true&&RTOK==true)mini = min(mini,dLS+dRT + min(dLS,dRT));
    if(LTOK==true&&RSOK==true)mini = min(mini,dLT+dRS + min(dLT,dRS));


    ans[start] = mini;
  }

 REP(i,q){
    cout<<ans[x[i]]<<endl;
 }

  return 0;
}

Measured memory_bytes: 10740
from collections import defaultdict

n=int(input())
d=defaultdict(list)

for i in range(n):
    a=int(input())

    for _ in range(a):
        x,y = map(int,input().split())
        d[i].append((x-1,y))

res=0
for i in range(1<<n):
    bf=False
    for j in range(n):

        if (i>>j)&1 == 1:
            for x,y in d[j]:
                if (i>>x)&1 != y: 
                    bf=True
                    break
            if bf:break 

    if not bf:
        count=0
        for m in range(n):
            if (i & (1 << m)) : count+=1
            res=max(res,count)
        # res=max(res,bin(i).count("1"))

print(res)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl
#define INF 2000000000

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> cost(n);
    vector<int> dp(n, INF);
    rep(i,n) cin >> cost.at(i);
    dp.at(0) = 0;
    rep(i,n) {
        rep(j,k) {
            if (i < j+1) break;
            dp.at(i) = min(dp.at(i-j-1)+abs(cost.at(i)-cost.at(i-j-1)), dp.at(i));
        }
    }
    ct(dp.at(n-1));
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

func exec(r io.Reader) string {
	sc := bufio.NewScanner(r)
	sc.Scan()
	sc.Scan()
	in := strings.Split(sc.Text(), " ")
	list := make([]int, len(in))
	for i, n := range in {
		list[i], _ = strconv.Atoi(n)
	}
	sort.Sort(sort.IntSlice(list))
	max := list[len(list)-1]
	c := 0
	for _, n := range list[:len(list)-1] {
		c += n
	}
	if max < c {
		return "Yes"
	} else {
		return "No"
	}
}

func main() {
	fmt.Println(exec(os.Stdin))
}

Measured memory_bytes: 640
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;
public class Main {
	public static void main (String[] args) {
	     Scanner s=new Scanner(System.in);
    int k=s.nextInt();
    //String ss=s.next();
    long sum=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int j1=1;j1<=k;j1++){
                sum+=gcd(gcd(i,j),j1);
            }
        }
        
    }
    //if(ss.contains("7"))
    System.out.println(sum);
    
	}
	public static int gcd(int a, int b) 
    { 
        if (a == 0) 
            return b; 
          
        return gcd(b%a, a); 
    }
}

Measured memory_bytes: 35816
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    string S;
    cin >> S;
    ll N = len(S);
    vector<ll> ans(N, 0);

    ll tp = 0;
    rep(i,N){
        if(S[i] == 'R'){
            ++tp;
            if(S[i + 1] == 'L'){
                ans[i] = tp;
                tp = 0;
            }
        }
    }
    tp = 0;
    rrep(i, N){
        if(S[i] == 'L'){
            ++tp;
            if(S[i - 1] == 'R'){
                ans[i] = tp;
                tp = 0;
            }
        }
    }

    rep(i, N - 1){
        ll x = ans[i], y = ans[i + 1];
        if(S[i] == 'R' and S[i+1] == 'L'){
            ans[i] = devc(x, 2) + y / 2;
            ans[i + 1] = x + y - ans[i];
        }
    }

    rep(i, N) cout << ans[i] << " ";
    print("");

    return 0;
}

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

int main() {
    int n; string s; cin >> n >> s;
    int a[n];
    for(int i = 0; i < n; i++) a[i] = (s[i] == 'W' ? 0 : 1);
    int lz = (a[0] == 1), rz = 0, lo = (a[0] == 0), ro = 0;
    for(int i = 2; i < n; i++) {
        rz += (a[i] == 1);
        ro += (a[i] == 0);
    }

    int res = rz;
    for(int i = 1; i < n; i++) {

        if(i != 1) {
            if(a[i] == 1) rz--;
            else ro--;
        }

        res = min(rz + lo, res);

        if(a[i] == 1) lz++;
        else lo++;
    }
    cout << res << endl;
    return 0;
}


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

typedef long long ll;
const ll mod=1e9+7;
const ll N=1e6+1;
const ll INF=1e10;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<n;i++){
		for(int j=2;j*j<=i;j++){
			if(i%j==0) ans+=1+(j*j!=i);
		}
		ans+=1+(i!=1);
	}
	cout<<ans;
}	  


Measured memory_bytes: 3648