akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

int now[16]={0,1,3,6,10,15,21,28,36,45,55,66,78,91};
bool isp[1000000];
int prime[1000000];

void init()
{
	memset(isp,true,sizeof(isp));
	isp[1]=false; isp[0]=false; int k=0;
	for(int i=2;i<=1000000;i++)
	{
		if(isp[i]) 
		prime[++k]=i;
		for(int j=1;j<=k && i*prime[j]<=1000000;j++)
		{
			isp[i*prime[j]]=false;	
			if(i%prime[j]==0) break;		
		}
	}
}

int main()
{
	ios::sync_with_stdio(false);
	ll n,k,ans=0,w;
	cin>>n;
	init();
	for(int i=1;i<=78498;i++)
	{
		w=0;
		while(n%prime[i]==0)
		{
			n/=prime[i];
			w++;
		}
		ans+=(upper_bound(now+1,now+14,w)-now-1);
	}
	if(n!=1) ans++;
	cout<<ans;
	return 0;
}




Measured memory_bytes: 4940
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
typedef long l;
typedef long long ll;
typedef unsigned long long ull;

#define pii pair<int,int>
#define pil pair<int,long>
#define pli pair<long,int>
#define pll pair<long,long>

#define vi vector<int>
#define vii vector<pii>
#define vs vector<string>
#define vl vector<long>

#define lp(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define loopd(i,a,n) for(i=a;i>n;i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define MAX 1000000007
        
vi jump; 
vi arr;

void dp(int i){
  if(i>=0){
    int a = jump[i+1] + abs(arr[i+1] - arr[i]);
    int b = jump[i+2] + abs(arr[i+2] - arr[i]);
    jump[i] = min(a,b);
    dp(i-1);
  }
}  

int main(){
  int n,i,j,k,m;
  cin>>n;
  arr.resize(n);
  jump.resize(n);
  lp(i,n)
    cin>>arr[i];
  jump[n-1]=0;
  jump[n-2]=abs(arr[n-2]-arr[n-1]);
  if(n>=3)	dp(n-3); 
  cout<<jump[0];
  return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
import bisect

def solve():
  s = input().strip()
  t = input().strip()
  query = [[] for _ in range(26)]
  n = len(s)
  for i in range(n):
    alphabet = ord(s[i])-97
    query[alphabet].append(i+1)

  
  place = -1
  loops = 0
  for j in t:
    tmp = ord(j)-97
    if len(query[tmp]) == 0:
      print(-1)
      exit()
    else:      
      nextplace = bisect.bisect_right(query[tmp],place)
      if nextplace == len(query[tmp]):
        loops += 1
        place = query[tmp][0]
      else:
        place = query[tmp][nextplace]

  print(loops*n +place)
solve()

Measured memory_bytes: 7668
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}


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

using str = string;
using ss = stringstream;

str m[60];

pair<int,int> dir[8]=
{
    {-1,-1},
    { 0,-1},
    { 1,-1},
    {-1, 0},
    { 1, 0},
    {-1, 1},
    { 0, 1},
    { 1, 1}
};

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

    int h,w;cin>>h>>w;

    ss maketop;
    for(int i=0;i<w+2;i++)maketop<<'.';

    str top=maketop.str();

    m[0]=top;

    for(int i=1;i<=h;i++)
    {
        str mid;
        cin>>mid;
        ss makemid;
        makemid<<'.'<<mid<<'.';
        m[i]=makemid.str();
    }

    m[h+1]=top;

    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)
    {
        if(m[i][j]=='#')continue;
        int cnt=0;
        for(int k=0;k<8;k++)if(m[i+dir[k].second][j+dir[k].first]=='#')cnt++;

        m[i][j]=cnt+'0';
    }

    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cout<<m[i][j];
        }
        cout<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3584
import java.lang.Math.*

class position(x:Double,y:Double)
{
    public var x:Double = x
    public var y:Double = y
}
var n:Int = 0
var startP:position = position(0.0,0.0)
var endP:position=position(100.0,0.0)

fun main(args: Array<String>) {
    n = readLine()!!.toInt()
    println(startP.x.toString() + " " + startP.y.toString())
    koch(n,startP,endP)
    println(endP.x.toString() + " " + endP.y.toString())
}
private fun koch(d:Int,p1:position,p2:position)
{
    if (d==0) return
    var s:position = position(0.0,0.0)
    var t:position= position(0.0,0.0)
    var u:position= position(0.0,0.0)
    var th:Double = PI * 60.0 / 180.0

    s.x = (2 * p1.x+ p2.x) / 3
    s.y = (2 * p1.y + p2.y)/ 3
    t.x = (p1.x + 2 * p2.x) / 3
    t.y = (p1.y + 2 * p2.y) / 3
    u.x = (t.x- s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x
    u.y = (t.x- s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y
    koch(d-1,p1,s)
    println(s.x.toString() + " " + s.y.toString())
    koch(d-1,s,u)
    println(u.x.toString() + " " + u.y.toString())
    koch(d-1,u,t)
    println(t.x.toString() + " " + t.y.toString())
    koch(d-1,t,p2)
}


Measured memory_bytes: 34248
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;

int main(){
	string s;
	cin >> s;
	int n = s.size();
	int cnt = 0;
	LL ans = 0;
	for(int i = n-1;i >= 0;i--){
		if(s[i] == 'C'){
			if(i >= 1 && s[i-1] == 'B'){
				cnt++;
				i--;
			}
			else 	cnt = 0;
		}else if(s[i] == 'A'){
			ans += cnt;
		}else{
			cnt = 0;
		}
	}
	cout << ans << endl;
}

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

int main(){
  int N,M;long K;cin>>N>>M>>K;
  vector<long> A(N+1,0),B(M+1,0);
  for(int i=1;i<=N;i++){
    long W;cin>>W;
    A.at(i)=W+A.at(i-1);
  }
  for(int i=1;i<=M;i++){
    long W;cin>>W;
    B.at(i)=W+B.at(i-1);
  }
  int left=-1;
  int right=N+M+1;
  while(left<right){
    int X=(left+right)/2;
    int ableA=min(N,X);
    int ableB=min(M,X);
    bool can=false;
    if(N>=M){
      for(int i=X-ableB;i<=ableA;i++){
        long time=A.at(i)+B.at(X-i);
        if(time<=K){
          can=true;
          break;
        }
      }
    }
    else{
      for(int i=X-ableA;i<=ableB;i++){
        long time=B.at(i)+A.at(X-i);
        if(time<=K){
          can=true;
          break;
        }
      }
    }
    if(can) left=X+1;
    else right=X;
  }
  cout<<max(left-1,0)<<endl;
}


Measured memory_bytes: 6416
from bisect import*
b=bisect_left
n,q,*t=map(int,open(0).read().split())
p=t[-q:]
*a,=o=[-1]*q
for x,t,s in sorted(zip(*[iter(t[~q::-1])]*3)):
 l,r=b(p,s-x),b(p,t-x)
 while l<r:
  if~o[l]:l=o[l]
  else:a[l],o[l]=x,r;l+=1
print(*a)

Measured memory_bytes: 99288
S = input()
ans = [0]*len(S)
tmp = []
cnt = 1;

for i in range(len(S)-1):
  if(S[i] == S[i+1]):
    cnt += 1
  else:
    tmp.append(cnt)
    cnt = 1
tmp.append(cnt)

cnt = 0
for i in range(len(tmp)-1):
  cnt += tmp[i]
  if(i % 2 == 0):
    if((tmp[i] - tmp[i+1])%2 == 0):
      ans[cnt-1] = int((tmp[i]+tmp[i+1])/2)
      ans[cnt] = int((tmp[i]+tmp[i+1])/2)
    else:
      if(min(tmp[i], tmp[i+1]) % 2):
        if(tmp[i] > tmp[i+1]):
          ans[cnt-1] = int((tmp[i] + tmp[i+1]-1)/2)
          ans[cnt] = int((tmp[i]+tmp[i+1]+1)/2)
        else:
          ans[cnt-1] = int((tmp[i] + tmp[i+1]+1)/2)
          ans[cnt] = int((tmp[i]+tmp[i+1]-1)/2)
      else:
        if(tmp[i] > tmp[i+1]):
          ans[cnt-1] = int((tmp[i] + tmp[i+1]+1)/2)
          ans[cnt] = int((tmp[i]+tmp[i+1]-1)/2)
        else:
          ans[cnt-1] = int((tmp[i] + tmp[i+1]-1)/2)
          ans[cnt] = int((tmp[i]+tmp[i+1]+1)/2)
        
print(*ans)

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

int main() {
    int h,w;
    cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            string s;
            cin >> s;
            if(s=="snuke"){
                cout << (char)(j+65) << i+1 << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const MAX = 210000
const MOD = 1000000007

var fac, finv, inv [MAX]int64

func COMinit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := int64(2); i < MAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

func COM(n, k int64) int64 {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func main() {
	sc.Split(bufio.ScanWords)

	N, K := int64(nextInt()), int64(nextInt())
	COMinit()

	for k := int64(1); k <= K; k++ {
		fmt.Println(COM(N-K+1, k) * COM(K-1, k-1) % MOD)
	}

}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<char> S(N);
  int R = 0;
  int G = 0;
  int B = 0;
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
    if (S.at(i) == 'R') {
      R++;
    } else if (S.at(i) == 'G') {
      G++;
    } else {
      B++;
    }
  }
  
  long Ans = 0;
  char key;
  int sR,sG,sB;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'R') {
      R--;
    } else if (S.at(i) == 'G') {
      G--;
    } else {
      B--;
    }
    sR = R; sG = G; sB = B;
    for (int j = i+1; j < N; j++) {
      if (S.at(i) == S.at(j)) {
          continue;
      }
      if (S.at(j) == 'R') {
      sR--;
      } else if (S.at(j) == 'G') {
      sG--;
      } else {
      sB--;
      }
      if ((S.at(i) == 'R' && S.at(j) == 'G') ||
          (S.at(i) == 'G' && S.at(j) == 'R')) {
        key = 'B';
        Ans += sB;
      } else if ((S.at(i) == 'R' && S.at(j) == 'B') ||
                 (S.at(i) == 'B' && S.at(j) == 'R')) {
        key = 'G';
        Ans += sG;
      } else {
        key = 'R';
        Ans += sR;
      }
      if (2 * j - i < N && S.at(2 * j - i) == key) {
        Ans--;
      }
    }
  }
  cout << Ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
 using namespace std;
int main(){
  string N;
  cin >> N;
  for (int i = 0; i < 3; i++) {
    if (N[i] == '1') {
      N[i] = '9';
    }else if(N[i] == '9') {
      N[i] = '1';
    }
  }
    cout << N << "\n";
}


Measured memory_bytes: 256
def dfs(n, s, min):
  if min > s:
    return 0
  if min == 10:
    return 0
  if n == 1:
    if min <= s and s < 10:
      return 1
    else:
      return 0
  else:
    sum = 0
    for i in range(min, 10):
      sum += dfs(n - 1, s - i, i + 1)
    return sum
  
while True:
  n, s = map(int, input().split())
  if n + s == 0:
    break
  print(dfs(n, s, 0))


Measured memory_bytes: 5596
unittest
{
	assert( [ "2 2", "1 3", "3 1" ].parse.expand.solve == 3 );
	assert( [ "2 2", "1 1", "1 1" ].parse.expand.solve == 6 );
	assert( [ "4 4", "3 4 5 6", "3 4 5 6" ].parse.expand.solve == 16 );
	assert( [ "10 9", "9 6 5 7 5 9 8 5 6 7", "8 6 8 5 5 7 9 9 7" ].parse.expand.solve == 191 );
	assert( [ "20 20", "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1" ].parse.expand.solve == 846527861 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	input.popFront;
	auto ss = input.front.split.to!( long[] );
	input.popFront;
	auto ts = input.front.split.to!( long[] );
	return tuple( ss, ts );
}

auto solve( long[] ss, long[] ts )
{
	// dp[ si ][ ti ] = s[ 0 .. si ] と t[ 0 .. ti ] の共通部分列の数
	auto dp = new long[][]( 1 + ss.length, 1 + ts.length );
	for( auto si = 0L; si < ss.length; si++ )
	{
		for( auto ti = 0L; ti < ts.length; ti++ )
		{
			dp[ si + 1 ][ ti + 1 ] = dp[ si ][ ti + 1 ].addMod( dp[ si + 1 ][ ti ] );
			if( ss[ si ] != ts[ ti ] ) dp[ si + 1 ][ ti + 1 ] = dp[ si + 1 ][ ti + 1 ].subMod( dp[ si ][ ti ] );		// 文字が一致しない場合
			else                       dp[ si + 1 ][ ti + 1 ] = dp[ si + 1 ][ ti + 1 ].addMod( 1 );						// 文字が一致する場合
		}
	}
	return dp[ $ - 1 ][ $ - 1 ].addMod( 1 );
}

// 足し算
auto addMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + y ) % MOD;
}

// 引き算
auto subMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + MOD - y ) % MOD;
}


Measured memory_bytes: 34172
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
	double N,K;
	cin >> N >> K;
	double prob_sum = 0;
	for(double n = 1 ; n <= N; n++){
		if(n >= K){
			prob_sum++;
			continue;
		}
		double coin_win = ceil(log(ceil((double)K/n))/log(2));
		prob_sum += (double)pow(2, -coin_win);
	}
	prob_sum = prob_sum/(double)N;
	cout << setprecision(13)<< prob_sum << endl;
	return 0;
		
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
    {
        cout<<s<<"es";
    }
    else
    {
        cout<<s<<"s";
    }
}



Measured memory_bytes: 3624
import random

D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]

plus=0
minus=0
data=[[1 for i in range(D)] for j in range(26)]
ans=[0]*D
for i in range(D):
    t=random.randint(1,26)
    ans[i]=t
    plus+=s[i][t-1]
    if i!=0:
        for j in range(26):
            data[j][i]=data[j][i-1]+1
    data[t-1][i]=0
    minus+=sum(c[j]*data[j][i] for j in range(26))

eval=plus-minus
count=150000
while count:
    d=random.randint(1,D)
    q=random.randint(1,26)
    if ans[d-1]==q:
        continue
    testplus=plus+s[d-1][q-1]-s[d-1][ans[d-1]-1]
    testminus=minus
    pre=ans[d-1]
    #print("pre",pre)

    day=0
    for j in range(d-1,D):
        if data[q-1][j]!=0:
            if j==d-1:
                testminus+=day*c[q-1]-data[q-1][d-1]*c[q-1]
            else:
                testminus+=(day+1-data[q-1][j])*c[q-1]
                day+=1
        else:
            break

    day=0
    for j in range(d-1,D):
        if j==d-1:
            if j==0:
                day=1
                testminus+=c[pre-1]*day
            else:
                day=1+data[pre-1][j-1]
                testminus+=c[pre-1]*day
        elif data[pre-1][j]!=0:
            testminus+=(day+1-data[pre-1][j])*c[pre-1]
            day+=1
        else:
            break

    if testplus-testminus>eval:
        eval=testplus-testminus
        plus=testplus
        minus=testminus
        ans[d-1]=q
        for j in range(d-1,D):
            if data[q-1][j]!=0:
                if j==d-1:
                    data[q-1][d-1]=0
                else:
                    data[q-1][j]=data[q-1][j-1]+1
            else:
                break

        for j in range(d-1,D):
            if j==d-1:
                if j==0:
                    data[pre-1][j]=1
                else:
                    data[pre-1][j]=1+data[pre-1][j-1]
            elif data[pre-1][j]!=0:
                data[pre-1][j]=data[pre-1][j-1]+1
            else:
                break
    count-=1

#print(eval)
for i in range(D):
    print(ans[i])


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

using namespace std;
#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;

LL get(string s){
    int sz = s.size();
    int cnt = 0;
    LL ans = 0;
    for(int i = sz-1; i >= 0; --i){
        if(s[i] == '0') ++cnt;
        else ans += cnt;
    }
    return ans;
}

int main(int argc, char const *argv[]){
	//freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    string t = "";
    cin >> s;
    int sz = s.size();
    for(int i = 0; i < sz; ++i){
        if(s[i] == 'A') t += '1';
        else if(s[i] == 'B' && (i+1 < sz && s[i+1] == 'C')) {t += '0'; ++i;}
        else t += '#';
    }
    LL ans = 0;
    sz = t.size();
    for(int i = 0; i < sz; ++i){
        if(t[i] == '#') continue;
        string x = "";
        while(i < sz && t[i] != '#'){
            x += t[i];
            ++i;
        }
        ans += get(x);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1044
#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);

  int count = 1;
  int ans = 0;
  int i, j;
  for(i=1; i<=N; i++){
    count = 1;
    j = i;
    while((j = j/10) != 0)
      count++;
    if(count%2 == 1)
      ans++;
  }

  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 128
#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 a,b;
    cin >> a >> b;
    int ans=0;
    while (ans*(a-1)+1<b){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut memo = vec![false; 100005];
    memo[0] = true;
    for &x in [100, 101, 102, 103, 104, 105].iter() {
        for i in 0..100005 {
            if memo[i] && i + x < 100005 {
                memo[i + x] = true;
            }
        }
    }
    if memo[n] {
        put!(1);
    } else {
        put!(0);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

const int MOD = 1e9 + 7;

int main(){
	
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	
	long long n, m;
	cin >> n >> m;
	
	if(n >= m/2LL)
		cout << m/2LL << "\n";
	else
		cout << n + (m - n*2LL)/4LL << "\n";
		
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define lPair pair<ll,ll>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int N,M,C; cin >> N >> M >> C;
    int B[22];
    for(int i = 0; i < M; i++) cin >> B[i];
    int A[22][22];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    int tmp = 0;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        tmp = 0;
        for(int j = 0; j < M; j++){
            tmp += A[i][j]*B[j];
        }
        tmp += C;
        if(tmp > 0) cnt++;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int H, W;
  cin >> H >> W;
  string s[50+1];
  rep(i, H) cin >> s[i];
  rep(i, H){
    rep(j, W){
      if(s[i][j] == '#'){
        int cnt = 0;
        if(i-1 >= 0 && s[i-1][j] == '#') cnt++;
        if(i+1 < H && s[i+1][j] == '#') cnt++;
        if(j-1 >= 0 && s[i][j-1] == '#') cnt++;
        if(j+1 < W && s[i][j+1] == '#') cnt++;
        if(cnt == 0){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int haku,ki,sai,en,sum=0;
  scanf("%d",&haku);
  scanf("%d",&ki);
  scanf("%d",&sai);
  scanf("%d",&en);
  for(int i=1;i<=haku;i++){
    if(i<=ki){
      sum+=sai;
    }else{
      sum+=en;
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};



int main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string s,t;
    cin >> s >> t;
    int n = sz(s), m = sz(t);
    vector<vector<int>> is(26);
    rep(i,n) is[s[i] - 'a'].push_back(i);
    rep(i,n) is[s[i] - 'a'].push_back(i+n);
    ll ans = 0;
    int p = 0;
    rep(i,m){
        int c = t[i] - 'a';
        if(sz(is[c]) == 0){
            print("-1");
            return 0;
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p)+1;
        if(p >= n){
            p -= n;
            ans += n;
        }
    }
    ans += p;
    print(ans);
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
  FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   ll arr[n];
   ll mini = 0;
   rep(n)
        cin>>arr[i], mini = max(mini,arr[i]);
   
   if(k == 0)
   {
       cout<<mini;
       return 0;
   }
   
   ll start = 1;
   ll end = mini;
   ll ans;
   while(end>=start)
   {
       ll mid = (start + end)/2;
       ll moves = 0;
       rep(n)
           moves+=((arr[i]+mid-1)/mid - 1);
       
       if(moves>k)
           start = mid+1;
       else
       {
           ans = mid;
           end = mid - 1;
       }
   }
   
   cout<<ans;
   
   return 0;        
}  
  
          
   

Measured memory_bytes: 5128
#include <iostream>  
#include <string>  
#include <vector>  
#include <algorithm> 
using namespace std; 
int main(){
	int x=0,y,z=0,w;
	char c;
	cin>>y;
	while(y--){
		cin>>c;
		if(c=='D')x--;
		else x++,z=max(z,x);
	}
	cout<<z<<endl;
	return 0;
}

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

int main(void)
{
  int a,b;
  cin >> a >> b;
  if(a == b){cout << "Draw";}
  else if(a == 1){cout << "Alice";}
  else if(b == 1){cout << "Bob";}
  else if(a < b){cout << "Bob";}
  else{cout << "Alice";}
  return 0;
}

Measured memory_bytes: 256
/*
ID: 5ak0
PROG:
LANG: C++11
*/

#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mpr make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9 + 7;

int f(int a, int b){
    return (a <= b ? b - a : INF);
}

int main(){
    #ifndef SAKO
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    #endif // SAKO
    ios_base::sync_with_stdio(0);

    int a, b;
    cin >> a >> b;
    cout << min(f(a, b), min(f(-a, -b) + 1, min(f(-a, b), f(a, -b))) + 1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

/* 基本要素 */
typedef complex<double> Point;
typedef pair<Point, Point> Line;
typedef vector<Point> VP;
const double EPS = 1e-7; // 許容誤差^2
const double INF = 1e9;
#define X real()
#define Y imag()
// #define LE(n,m) ((n) < (m) + EPS)
#define LE(n,m) ((n) - (m) < EPS)
// #define GE(n,m) ((n) + EPS > (m))
#define GE(n,m) (EPS > (m) - (n))
#define EQ(n,m) (abs((n)-(m)) < EPS)

// 内積　dot(a,b) = |a||b|cosθ
double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

// 外積　cross(a,b) = |a||b|sinθ
double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

// 点の進行方向
int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}

// 線分と線分
bool isecSS(Point a1, Point a2, Point b1, Point b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
  ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

// 線分と点
bool isecSP(Point a1, Point a2, Point b) {
  return !ccw(a1, a2, b);
}

// 点pの直線aへの射影点を返す
Point proj(Point a1, Point a2, Point p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

double distSP(Point a1, Point a2, Point p) {
  Point r = proj(a1, a2, p);
  if (isecSP(a1, a2, r)) return abs(r-p);
  //= !ccw(a1, a2, r)
  return min(abs(a1-p), abs(a2-p));
}

double distSS(Point a1, Point a2, Point b1, Point b2) {
  if (isecSS(a1, a2, b1, b2)) return 0;
  return min(min(distSP(a1, a2, b1), distSP(a1, a2, b2)),
   min(distSP(b1, b2, a1), distSP(b1, b2, a2)));
}

const double pi = acos(-1);

int main(){
    int n,s,t;
    while(cin >>n >>s >>t,n){

        vector<VP> star(n);
        rep(i,n){
            double x,y,a,r;
            cin >>x >>y >>a >>r;

            Point c(x,y);

            star[i] = VP(5);
            rep(j,5){
                star[i][j] = c + polar(r,pi/2 + (a+72*2*j)*2*pi/360);
            }
        }

        auto dist_star = [&](VP a, VP b){
            double ret = INF;
            rep(i,5)rep(j,5){
                ret = min(ret, distSS(a[i],a[(i+1)%5],b[j],b[(j+1)%5]));
            }
            return ret;
        };

        vector<vector<double>> d(n,vector<double>(n,INF));
        rep(i,n) d[i][i] = 0;
        rep(i,n)rep(j,i){
            d[i][j] = d[j][i]= dist_star(star[i],star[j]);
        }

        rep(k,n)rep(i,n)rep(j,n) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        printf("%.10f\n", d[s-1][t-1]);
    }
    return 0;
}



Measured memory_bytes: 3728
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    long double A, B, N; cin >> A >> B >> N;
    if(N<B){
        cout << floor(A*(N/B));
    }else{
        cout << floor(A*((B-1)/B));
    }
}
    


Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define N1 100005
#define N2 200005
#define endl "\n"
#define mod 1000000007
#define vll vector<ll>
#define pb push_back
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)

int check(string s1,string s2)
{
    for(int i=0;i<s1.length();i++)
    {
        if(s1[i]!=s2[s2.length()-i-1])
        return 0;
    }
    return 1;
}

int checkp(string s)
{
    int i=0,j=s.length()-1;
    while(i<j)
    {
        if(s[i]!=s[j]) return 0;
        i++;j--;
    }
    return 1;
}

int main()
{
    ll n,a[N1];
    cin>>n;
    for1(i,n)
    cin>>a[i];

    ll dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n];
}


Measured memory_bytes: 1792
N = int(input())
H = list(map(int, input().split()))

i, j = 0, 1
count = 0
ans = 0
while j < N:
  if H[i] >= H[j]:
    count += 1
    i += 1
    j += 1
  else:
    ans = max(ans, count)
    count = 0
    i = j
    j += 1
ans = max(ans, count)
print(ans)

Measured memory_bytes: 20452
#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
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int x;
    cin >> x;
    vector<bool> dp(x + 1, false);
    dp[0] = true;
    rep(i, 6)
    {
        rep(j, x + 1)
        {
            if (j + 100 + i > x)
            {
                break;
            }
            if (dp[j] == true)
            {
                dp[j + 100 + i] = true;
            }
        }
    }
    if (dp[x] == true)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


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

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

signed main(){

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

  ll cnt = 0;
  rep(i,n)if(a[i]<0)cnt++;

  for(auto&ai:a)ai=abs(ai);
  sort(begin(a),end(a));
  ll ans = accumulate(begin(a)+(cnt&1),end(a),(cnt&1?a[0]*-1ll:0ll));
  cout<<(ans)<<endl;

}

Measured memory_bytes: 4052
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define REP(i,n) for(i=0;i<n;i++)
#define ll long long

int main(void){
    int i;
    char s[3];
    REP(i,3){
        scanf("%c",&s[i]);
    }
    
    int ctr=0;
    if(s[0]=='1') ctr++;
    if(s[1]=='1') ctr++;
    if(s[2]=='1') ctr++;

    printf("%d",ctr);
    
    return 0;
}

Measured memory_bytes: 128
// finish date: 2019/11/24

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1000000007;
const long long INFll = 100000000000000000;


int main() {
    int N, K;
    cin >> N >> K;
    vi A(N);
    rep(i, N) {
        cin >> A[i];
        A[i] -= 1;
        A[i] %= K;
    }
    vi cum(N, 0);
    rep(i, N) {
        cum[i] = A[i] % K;
        if (i != 0) cum[i] = (cum[i] + cum[i - 1]) % K;
    }


    ll ans = 0;
    map<int, int> cnt;
    rep(i, min(K - 1, N)) {
//        cum[i] = (K - cum[i]) % K;
        cnt[cum[i]]++;
    }
    ans += cnt[0];

//    int focus = 0;
    FOR(i, K - 1, N + K - 1) {
        cnt[cum[i - K + 1]]--;
        if (i < N) cnt[cum[i]]++;
        ans += cnt[(cum[i - K + 1]) % K];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, L, R, X, Y;
//string S, T;

signed main(){
  int r, g ,b;
  cin >> r >> g >> b >> N;
  int ans = 0;
  int i = 0;
  int j = 0;
  while (i*r<=N){
    j = 0;
    while (i*r+j*g<=N){
      if((N-i*r-j*g)%b == 0) ans++;
      j++;
    }
    i++;
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3544
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    string s;
    int ans=0;
    cin>>s;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-i-1]){
            ans++;
        }
        else{

        }
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val nxt = nextIntList()

    val min = Math.ceil((nxt[0]/nxt[1]).toDouble()).toInt()
    val c = nxt[0]%nxt[1]

    println(min*nxt[2] + if(c == 0)0 else nxt[2])

}
fun next() = readLine()!!
fun nextIntList() = next().split(" ").map{ it.toInt() }

Measured memory_bytes: 36400
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int mex=100001;
#define ll long long 
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int> 
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++)

int main()
{
   string s;
   cin>>s;
   int q;
   cin>>q;
   deque<char> dq;
   fo(i,0,sz(s))
   dq.pb(s[i]);
   vector<pair<pair<char,int>,int> > v,v2;
   int r=0;
  // fo(i,0,sz(dq)) cout<<dq.front();
   while(q--)
   {
       int t;
       cin>>t;
       if(t==1) r++;
       else 
       {
           int f;
           char c;
           cin>>f>>c;
           if(f==1) v.pb({{c,r},1});
           else v.pb({{c,r},2});
       }
   }
   
   fo(i,0,sz(v))
   {
       int r1=v[i].fi.se;
       int d=v[i].se;
       if(r1%2==0)
       {
           if(d==1) dq.push_front(v[i].fi.fi);
           else dq.push_back(v[i].fi.fi);
       }
       else 
       {
           if(d==1) dq.pb(v[i].fi.fi);
           else dq.push_front(v[i].fi.fi);
       }
   }
  
   if(r%2)
   {
       int j=sz(dq);
       fo(i,0,j)
       {cout<<dq.back();
       dq.pop_back();
       }
   }
   else
   {
      // cout<<sz(dq)<<endl;
      int j=sz(dq);
       fo(i,0,j)
       {
           cout<<dq.front();
       dq.pop_front();
       }
   }
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<intt>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
intt gcd(intt a, intt b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
intt bpow(intt a,intt b) 
{
  intt res = 1;
  while (b > 0) {
    if (b & 1)res = res * a;
      a = a * a;
      b >>= 1;
  }
  return res;
}
intt fact(intt n) { 
   if ((n==0)||(n==1))
      return 1; 
   else
      return n*fact(n-1);
}

void go()
{
#ifndef ONLINE_JUDGE
  freopen("IN.txt","r",stdin);
  freopen("OUT.txt","w",stdout);
  #endif
}
struct Node{
        int par;
        int rank;
    };
vector<Node> dsu;
int find(int a){
        if(dsu[a].par==a)
            return a;
        return dsu[a].par=find(dsu[a].par);
}

void dsu_union(int a,int b){
        if(dsu[a].rank>dsu[b].rank){
            dsu[b].par=a;
            dsu[a].rank+=dsu[b].rank;
        }
        else if(dsu[b].rank>dsu[a].rank){
            dsu[a].par=b;
            dsu[b].rank+=dsu[a].rank;
        }
        else{
            dsu[a].par=b;
            dsu[b].rank+=dsu[a].rank;
        }
}


int main(){
	go();
	fast_io
	intt a,b,c,d;
	cin>>a>>b>>c>>d;
	intt ans =-1e18;
	ans=max(a*d,ans);
	ans=max(a*c,ans);
	ans=max(b*d,ans);
	ans=max(b*c,ans);
	cout << ans <<'\n';
}


/*
*/


















Measured memory_bytes: 3648
# D - Brick Break
N = int(input())
Alist = list(map(int, input().split()))
if min(Alist) != 1:
    print(-1)
else:
    max_num = 1
    i = 0
    while i < N:
        a = Alist[i]
        if a == max_num:
            max_num += 1
        i += 1
    print(N - max_num + 1)

Measured memory_bytes: 24744
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		//数取得
		int K = sc.nextInt();
		String S = sc.next();
		sc.close();

		if(S.length() <= K) {
			System.out.println(S);
		}else {
			String answer = S.substring(0, K);
			System.out.println(answer + "...");
		}
	}

}


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

int main () {
	int a, b;
	cin >>a>>b;
	if(a==13 and b==1) {
		cout<<"Bob"<<endl;
}	else if(a==1 and b==13) {
		cout<<"Alice"<<endl;
}	else if(a > b) {
		cout<<"Alice"<<endl;
}	else if(a==b) {
		cout<<"Draw"<<endl;
}	else if(a<b) {
		cout<<"Bob"<<endl;
}
	
}

Measured memory_bytes: 256
function myOut(text){console.log(text);}//standard output
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var left = parseInt(input.slice(0,2));
  var right = parseInt(input.slice(2,4));
  //しらみつぶしで
  if(left == 0){
     if(right == 0){
        console.log("NA");
     }else if(right >= 1 && right < 13){
        console.log("YYMM");
     }else{
        console.log("NA");
     }
  }else if(left >= 1 && left < 13){
     if(right == 0){
        console.log("MMYY");
     }else if(right >= 1 && right < 13){
        console.log("AMBIGUOUS");
     }else{
        console.log("MMYY");
     }    
  }else{
     if(right == 0){
        console.log("NA");
     }else if(right >= 1 && right < 13){
        console.log("YYMM");
     }else{
        console.log("NA");
     }      
  }
}

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


Measured memory_bytes: 21064
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a;

int main(){
	cin>>n;
	a=vi(n);
	ll S=0;
	for(auto &i:a){
		cin>>i;
		S+=i;
	}
	ll res=INF,T=0;
	for(int i=0;i<n-1;i++){
		S-=a[i];
		T+=a[i];
		res=min(res,abs(S-T));
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1024
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons;
  
  int n, h; rd(n, h);
  alias T=Tuple!(int, "a", int, "b");
  auto ys=new T[](n);
  foreach(i; 0..n) rd(ys[i].a, ys[i].b);

  sort!((l, r)=>(l.a==r.a ? l.b>r.b : l.a>r.a))(ys);
  auto zs=new int[](n);
  foreach(i; 0..n) zs[i]=ys[i].b;
  sort!"a>b"(zs);
  int cnt=0;
  foreach(z; zs){
    if(ys[0].a<=z){
      cnt++;
      if((h-=z)<=0){writeln(cnt); return;}
    }
  }

  writeln(cnt+((h+ys[0].a-1)/ys[0].a));
}
void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) write(e, " ");
  writeln();
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    map<int32,int32> m;
    REP(i,n){
        int32 a;
        cin >> a;
        m[a]++;
    }
    int32 ans = 0;
    for(pii p : m){
        if(p.first > p.second){
            ans += p.second;
        }else{
            ans += p.second - p.first;
        }
    }
    ANS(ans);
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	vector<int>ans;
	while (1) {
		int n;
		int p[100];
		int p_min = 1000;
		int p_max = 0;
		int sum = 0;
		cin >> n;
		if (n == 0) {
			break;
		}
		rep(i, n) {
			cin >> p[i];
			p_min = min(p_min, p[i]);
			p_max = max(p_max, p[i]);
			sum += p[i];
		}
		sum = sum - p_min - p_max;
		sum /= (n - 2);
		ans.push_back(sum);
	}
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}

	return 0;
}

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

int main() {
  int n; cin >> n;
  bool answer = false;
  
  for (int i = 0; i <= n / 4; i++) {
    for (int j = 0; j <= n / 7; j++) {
      if (i * 4 + j * 7 == n) answer = true;
    }
  }
  
  if (answer) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }
    sort(a.begin(), a.end());
    vector<ll> sum(n);
    sum[0] = a[0];

    repd(i, 1, n) { sum[i] = sum[i - 1] + a[i]; }

    ll ans = 1;
    rep(i, n - 1) {
        if (sum[i] * 2 < a[i + 1]) {
            ans = 1;
        } else {
            ans++;
        }
        // cout << i << ":" << ans << endl;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int N;
	cin>>N;
	ll ans=1;
	FDS(i,N){
		ans*=(i+1);
		ans%=1000000007;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  sort(begin(s), end(s));
  if(s=="abc")
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        string s;
        cin>>s;
        cout<<s<<endl<<s<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
# coding:utf-8

import sys

input = sys.stdin.readline


def inpl(): return list(map(int, input().split()))


A, B, C = inpl()

ans = 0
if A == B == C and A % 2 == 0:
    ans = -1
else:
    while not (A % 2 or B % 2 or C % 2):
        ha, hb, hc = A // 2, B // 2, C // 2
        A, B, C = hb + hc, ha + hc, ha + hb
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
const int maxn = 300300;
int occ[maxn];
int main(){
    int n;
    cin >> n;
    map<int,int> o;
    for(int e = 0; e < n; e++){
        int x; cin >> x;
        o[x]++;
    }
    int ans = 0;
    for(auto & it : o){
        if(it.second >= it.first) ans += it.second - it.first;
        else ans += it.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[101];
	cin>>a;
	int bj=0;
	for(int i=0;i<strlen(a);i++)
	{
		if(a[i]=='C') bj=1;
		if(bj==1&&a[i]=='F') bj=2;
	}
	if(bj==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
	return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
elif H % 2 == 0 or W % 2 == 0:
    print(H * W // 2)
else:
    print((H - 1) * (W - 1) // 2 + (H - 1) // 2 + (W - 1) // 2 + 1)

Measured memory_bytes: 3060