akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int n; cin >> n;
  vl a(n); rep(i, n) cin >> a[i];
  vl s(n+1); rep(i, n) s[i+1] = s[i] + a[i];

  ll ans = INF;
  rep(i, n){
    chmin(ans, abs(s[i+1] - (s[n] - s[i+1]) ) );
  }

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


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int mod = 1e9 + 7;
int d;
string s;
int dp[10005][105][2];

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

int solve(int idx, int rem, bool smaller)
{
  if(idx == s.size())
    return rem == 0;
  int &ans = dp[idx][rem][smaller];
  if(ans != -1)
    return ans;
  ans = 0;
  if(smaller)
  {
      for(int digit = 0; digit < 10; digit++)
        ans = add(ans, solve(idx + 1, (rem + digit) % d, 1));
      return ans;
  }
  else
  {
    for(int digit = 0; digit <= s[idx] - '0'; digit++)
    {
      if(digit < s[idx] - '0')
        ans = add(ans, solve(idx + 1, (rem + digit) % d, 1));
      else
        ans = add(ans, solve(idx + 1, (rem + digit) % d, 0));
    }
    return ans;
  }
}

int main()
{
    cin >> s >> d;
    memset(dp, -1, sizeof(dp));
    cout << add(solve(0, 0, 0), -1);
}


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

int main(){
  // 入力
  int N;
  cin >> N;
  
  int num = N;
  int divisor = 0;
  
  while(num){
    divisor += num % 10;
    num /= 10;
  }
  //cout << "divisor: " << divisor << ", N: "  << N << endl;
  
  if (divisor != 0 && N % divisor == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int H, N;
    cin >> H >> N;
    int A, sum = 0;
    Fp(i, 0, N){
        cin >> A;
        sum += A;
    }
    if(sum >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = A+B;
    
    if (C%2==0) {
      System.out.println(C/2);
    }else{
      System.out.println("IMPOSSIBLE");
    }
  }
}

Measured memory_bytes: 21972
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ha = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var mod = ha[0] % ha[1];
            var div = ha[0] / ha[1];
            Console.WriteLine(mod > 0 ? div + 1 : div);
        }
    }
}


Measured memory_bytes: 13396
#include <cstdio>
#include <string>
#include <stack>

int main() {
  char buf[131072];
  scanf("%s", buf);
  std::string S = buf;

  int res = 0;
  std::stack<char> st;
  for (char c: S) {
    if (st.empty()) {
      st.push(c);
    } else if (st.top() != c) {
      st.pop();
      res += 2;
    } else {
      st.push(c);
    }
  }
  printf("%d\n", res);
}


Measured memory_bytes: 1144
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main{
	static int n;
	static int[][]M;	// 隣接行列
	static int[]color;	// 頂点の訪問状況
	static int[]d;		// d[v]: vを最初に訪問した発見時刻
	static int[]f;		// f[v]: vの隣接リストを調べ終えた完了時刻
	static int tt = 0;		// 時刻
	static int nt[];	// nt[u]: uに隣接する頂点
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		n = scan.nextInt();
		M = new int[n][n];
		color = new int[n];
		d = new int[n];
		f = new int[n];
		nt = new int[n];
		for(int i = 0; i < n; i++) {
			int u = scan.nextInt() - 1;
			int k = scan.nextInt();
			for(int j = 0; j < k; j++) {
				M[u][scan.nextInt() - 1] = 1;
			}
		}
		scan.close();

		dfs();
	}
	// uに隣接するvを番号順に取得
	static int next(int u) {
		for(int v = nt[u]; v < n; v++) {
			nt[u] = v + 1;
			if(M[u][v] == 1) return v;
		}
		return -1;
	}
	// スタックを用いた深さ優先探索
	static void dfsVisit(int r) {
		Arrays.fill(nt, 0);
		Deque<Integer> stack = new ArrayDeque<Integer>();
		stack.push(r);
		color[r] = 1;
		d[r] = ++tt;

		while(!stack.isEmpty()) {
			int u = stack.peek();
			int v = next(u);
			if(v != -1) {
				if(color[v] == 0) {
					color[v] = 1;
					d[v] = ++tt;
					stack.push(v);
				}
			}else {
				stack.pop();
				color[u] = 2;
				f[u] = ++tt;
			}
		}
	}
	static void dfs() {
		// 未訪問のuを始点として深さ優先探索
		for(int u = 0; u < n; u++) {
			if(color[u] == 0) {
				dfsVisit(u);
			}
		}
		for(int i = 0; i < n; i++) {
			int u = i + 1;
			System.out.println(u + " " + d[i] + " " + f[i]);
		}
	}
}


Measured memory_bytes: 28328
a,b,c,x,y=map(int,input().split())
ans=0
if a+b>c*2:
    z=min(x,y)
    ans+=z*c*2
    x-=z
    y-=z

if a>c*2:
    ans+=x*c*2
    x=0
    y=max(0,y-x)
if b>c*2:
    ans+=y*c*2
    y=0
    x=max(0,x-y)
ans+=x*a
ans+=y*b


print(ans)


Measured memory_bytes: 38384
#include <stdio.h>

int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if(a == b + c){
        printf("Yes\n");
    }else if(b == c + a){
        printf("Yes\n");
    }else if(c == a + b){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

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

int main(){
  
  int w, h, base = 0;
  char mas[1111][1111], flag[2][2];
  string joi = "JOI";

  cin >> h >> w;
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++) cin >> mas[i][j];
  
  for(int i = 0; i < 2; i++)
    for(int j = 0; j < 2; j++) cin >> flag[i][j];
  
  for(int i = 0; i < h-1; i++){
    for(int j = 0; j < w-1; j++){
      for(int k = 0; k < 2; k++){
        for(int l = 0; l < 2; l++){
          if(mas[i + k][j + l] != flag[k][l]) goto next;
        }
      }
      base++;
    next:;
    }
  }

  int res = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      int base2 = 0;
      for(int l = max(0, i - 1); l <= i; l++){
        for(int m = max(0, j - 1); m <= j; m++){
          for(int x = 0; x < 2; x++){
            for(int y = 0; y < 2; y++){
              if(mas[l + x][m + y] != flag[x][y]) goto next2;
            }
          }
          base2++;
        next2:;
        }
      }
  
      for(int k = 0; k < 3; k++){
        char change = joi[k];
        swap(change, mas[i][j]);
        int sum1 = 0;
        for(int l = max(0, i - 1); l <= i; l++){
          for(int m = max(0, j - 1); m <= j; m++){
            for(int x = 0; x < 2; x++){
              for(int y = 0; y < 2; y++){
                if(mas[l + x][m + y] != flag[x][y]) goto next3;
              }
            }
            sum1++;
          next3:;
          }
        }
        res = max(res, base + (sum1 - base2));
        mas[i][j] = change;
      }
    }
  } 
  cout << res << endl;
  
}

Measured memory_bytes: 2296
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

int makerect(int h, int w){
    for ( int i = 0; i < h; i++ ){
        for ( int j = 0; j < w; j++ ){
            cout << "#";
        }
        cout << endl;
    }
    return 0;
}

int main(){
    int a, c, d;
    a = 0, c = 1, d = 1;
    while ( c > 0 || d > 0 ){
        cin >> c >> d;
        if ( c > 0 || d > 0 ){
            makerect(c,d);
            cout << endl;
        }
       
    }
    
    return 0;
    
}



Measured memory_bytes: 3096
#![allow(unused)]

#[allow(unused_imports)]
use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::*;
use collections::{HashMap, HashSet};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let n = parse_line::<usize>();
    let spot_pos = {
        let mut v = Vec::with_capacity(n + 2);
        v.push(0);
        v.append(&mut parse_vec::<i32>());
        v.push(0);
        v
    };

    let sum = spot_pos
        .windows(2)
        .map(|path| (path[0] - path[1]).abs())
        .sum::<i32>();

    for path in spot_pos.windows(3) {
        if (path[0] <= path[1] && path[1] <= path[2]) || (path[2] <= path[1] && path[1] <= path[0])
        {
            println!("{}", sum);
        } else {
            let new_sum = sum - 2 * cmp::min((path[0] - path[1]).abs(), (path[1] - path[2]).abs());
            println!("{}", new_sum);
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


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

#define X first
#define Y second
#define pb push_back

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    cout << (a >= n % 500 ? "Yes" : "No");
    return 0;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const ll  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

/*vll adj[MAXN];ll visit[MAXN]={};
ll dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k,d,w,summ;
string s,t;
vll a,b;

// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN(ll _) {
	cin >> n >> m >> k;
	if(n <= m*k) {
		cout<<"Yes\n";
	}
	else {
		cout<<"No\n";
	}
}

int main() {
	fastio;randomINT;
	//freopen("out_hc.txt","w+",stdout);
	//cin>>T;
	for(ll i=1;i<=T;i++) {
		MAIN(i);
	}
	return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

map<ll, ll> prime_factor(ll n) {
    map<ll, ll> ret;
    ll m = n;
    for (ll i = 2; i*i <= m; ++i) {
        while (n%i == 0 && n > 1) {
            ret[i]++;
            n/=i;
        }
    }
    if (n != 1) ret[n]++;
    return ret;
}

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) return b;
    gcd(b, a%b);
}

int main(int argc, char const *argv[]) {
    ll a,b; cin>>a>>b;
    map<ll, ll> mp = prime_factor(gcd(a,b));
    cout << mp.size()+1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c=a+b;
	int d=a-b;
	int e=a*b;
	if((c>=d)&&(c>=e)){
		cout<<c;
	}
	if((d>c)&&(d>=e)){
		cout<<d;
	}
	if((e>c)&&(e>d)){
		cout<<e;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int par[100];

int root(int x){
    if(par[x] == x){
        return x;
    } else {
        return par[x] = root(par[x]);
    }
}

bool same(int x, int y){
    return root(x) == root(y);
}

bool all_united(int num){
    REP(i, num-1){
        if(!same(i, i+1)){
            return false;
        }
    }
    return true;
}

void unite(int x, int y){
    x = root(x);
    y = root(y);
    if(x==y){
        return;
    } else {
        par[x] = y;
    }
}

int letter[50][50];

bool completed(int num){
    REP(i, num){
        REP(j, num){
            if(letter[i][j] == 0){
                break;
            } else if(j==num-1){
                return true;
            }
        }
    }
    return false;
}

int main(){
    while(1){
        int num;
        cin >> num;

        if(num==0) break;

        int cal[num][31];
        REP(i, num){
            REP(j, 31){
                cal[i][j] = 0;
            }
        }

        REP(i, num){
            int dnum;
            cin >> dnum;
            REP(j, dnum){
                int date;
                cin >> date;
                cal[i][date] = 1;
            }
        }

        /*
        REP(i, num){
            REP(j, 10){
                cout << cal[i][j];
            }
            cout << endl;
        }
        */

        REP(i, num){
            REP(j, num){
                letter[i][j] = 0;
            }
        }

        int today[num];
        int output = -1;
        REP(j, 31){
            REP(i, num){
                today[i] = 0;
            }
            REP(i, num){
                if(cal[i][j] == 1){
                    today[i] = 1;
                    REP(k, num){
                        if(letter[i][k]==1){
                            today[k] = 1;
                        }
                    }
                }
            }
            REP(i, num){
                if(cal[i][j] ==1){
                    REP(k, num){
                        if(today[k]==1){
                            letter[i][k] = 1;
                        }
                    }
                }
            }

            /*
            cout << j << endl;
            REP(l, num){
                REP(m, num){
                    cout << letter[l][m] << " ";
                }
                cout << endl;
            }
            */

            if(completed(num)){
                output = j;
                break;
            }
        }
        cout << output << endl;
    }
}

Measured memory_bytes: 3088
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func main() {
	n, _ := strconv.Atoi(input())
	s := input()

	ans := 1
	current := s[0]
	for i := 1; i < n; i++ {
		if s[i] != current {
			current = s[i]
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 896
#include<cstdio>
const int N=50+10;
int a[N],n,ok;
bool check()
{
	for(int i=1;i<=n;i++)
		if(a[i]!=i)return 0;
	return 1;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(check())
	{
		puts("YES");
		return 0;
	}
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			a[i]^=a[j]^=a[i]^=a[j];
			if(check())
			{
				puts("YES");
				return 0;
			}
			a[i]^=a[j]^=a[i]^=a[j];
		}
	puts("NO");
	return 0;
}


Measured memory_bytes: 128
def gcd(n, m):
  if m == 0:
    return n
  return gcd(m, n%m)

N, X = map(int, input().split())
x = list(map(int, input().split()))

x_ = [abs(X - i) for i in x]
x_.sort(reverse=True)
D = x_[0]
for i in range(1, N):
  D = gcd(D, x_[i])
print(D)


Measured memory_bytes: 14224
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    string s = "";
    cin >> s;
    ll ans = 0;
    int to = 0;
    for (int i=0; i<s.size(); i++) {
        if (s.at(i) == 'W') {
            ans += i - to;
            to++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
/*
** Author: wkwkwill (Willy I. K.)
** 2020/09/06
*/
using namespace std;
using ll = long long int;

ll BIG = 1e18 + 1;
ll MOD = 998244353;

void solve();

ll fastpow(ll x, ll y, ll n = BIG) 
{
    x %= n;
    ll ans = 1;
    while (y > 0) 
    {
        if (y & 1) ans = (ans * x) % n;
        x = (x * x) % n;
        y >>= 1;
    }
    return ans;
}

bool sortPairSecond(pair<ll, ll> &a, pair<ll, ll> &b)
{
    return a.second < b.second;
}

bool sortPairFirst(pair<int, int> &a, pair<int, int> &b)
{
    if (a.first == b.first) return a.second < b.second;
    return a.first < b.first;
}

bool sortPairFirstDec(pair<int, int> &a, pair<int, int> &b)
{
    if (a.first == b.first) return a.second < b.second;
    return a.first > b.first;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
	return 0;
}
  
ll fact(ll n) 
{ 
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = (res * i) % MOD; 
    return res; 
} 
  
ll Combin(ll n, ll r) 
{ 
    return fact(n) / ((fact(r) * fact(n - r)) % MOD); 
} 

void solve()
{
    int x;
    cin >> x;
    x == 0 ? cout << 1 << '\n' : cout << 0 << '\n';
}

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

int main(){
  double n,t,a,ans;
  cin >> n >> t >> a;
  double c = 10000;
  for(int i=0;i<n;i++){
    double b;cin >> b;
    c = min(c,abs(a-t+0.006*b));
    if(c==abs(a-t+0.006*b)) ans = i+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//�]���؂�グ�� =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
  //string t; cin>>t;
  string u;
  u.push_back(s[0]);
  u.push_back(s[1]);
 int a=stoi(u);
  u="";
  u.push_back(s[2]);
  u.push_back(s[3]);
  int b=stoi(u);
  if(b>0 && b<=12 && a>0 && a<=12) cout<<("AMBIGUOUS");
  else if(a>0 && a<=12) cout<<"MMYY";
  else if(b>0 && b<=12) cout<<"YYMM";
  else cout<<"NA";
	cout<<endl;
 // cout<<"a: "<<a<<" b: "<<b<<endl;
	return 0;
}

Measured memory_bytes: 3596
def factorize(n):
    '''
    素因数分解をする。
    タプルの配列にしようと思ったけど、逐次割り算する過程で次数を増やせないじゃん。
    二重配列?
    dictにしよう。
    '''
    if n == 1:
        raise('n >= 2')
    
    factor = {}
    div = 2
    while True:
        if div * div > n:
            factor[n] = factor.get(n, 0) + 1
            return factor

        if n % div == 0:
            n //= div
            factor[div] = factor.get(div, 0) + 1
        else:
            div += 1




n, m = list(map(int, input().split()))

if m == 1:
    print(1)
    exit()

factor = factorize(m)


max_len = n + 100  # 適宜変更する
mod = 10**9 + 7


def modinv(x):
    '''
    xの逆元を求める。フェルマーの小定理より、 x の逆元は x ^ (mod - 2) に等しい。計算時間はO(log(mod))程度。
    Python標準のpowは割った余りを出すことも可能。
    '''
    return pow(x, mod-2, mod)


# 二項係数の左側の数字の最大値を max_len　とする。nとかだと他の変数と被りそうなので。
# factori_table = [1, 1, 2, 6, 24, 120, ...] 要は factori_table[n] = n!
# 計算時間はO(max_len * log(mod))
modinv_table = [-1] * (max_len + 1)
modinv_table[0] = None  # 万が一使っていたときにできるだけ早期に原因特定できるようにしたいので、Noneにしておく。
factori_table = [1] * (max_len + 1)
factori_inv_table = [1] * (max_len + 1)
for i in range(1, max_len + 1):
    factori_table[i] = factori_table[i-1] * (i) % mod

modinv_table[1] = 1
for i in range(2, max_len + 1):
    modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod
    factori_inv_table[i] = factori_inv_table[i-1] * modinv_table[i] % mod


def binomial_coefficients(n, k):
    '''
    n! / (k! * (n-k)! )
    0 <= k <= nを満たさないときは変な値を返してしまうので、先にNoneを返すことにする。
    場合によっては0のほうが適切かもしれない。
    '''
    if not 0 <= k <= n:
        return None
    return (factori_table[n] * factori_inv_table[k] * factori_inv_table[n-k]) % mod


ans = 1
mod = 10**9 + 7
for prime, power in factor.items():
    # ans *= n H power = n+power-1 C power 
    ans *= binomial_coefficients(n+power-1, power)
    ans %= mod

print(ans)


Measured memory_bytes: 20752
N = int(input())
S_dir = {}
max_count = 1
for _ in range(N):
    S = input()
    if S in S_dir:
        S_dir[S] += 1
        max_count = max(max_count, S_dir[S])
    else:
        S_dir[S] = 1

for s in sorted([k for k, v in S_dir.items() if v == max_count]):
    print(s)

Measured memory_bytes: 33116
n,k=map(int,input().split())
p=list(map(int,input().split()))

kitai=[]
for i in p:
  kitai.append((i+1)/2)

ans=sum(kitai[0:k])
temp=ans


for i in range(0,n-k):
  temp+=kitai[k+i]-kitai[i]
  ans=max(ans,temp)
print(ans)

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n;
    cin >> n;
    map <int,int> mp;
    int ans = 0;

    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        mp[x]++;
    }

    for(auto i : mp){
        if(i.second%2!=0){
            ans++;
        }
    }

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

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define N 105
using namespace std;
int n,s,a[N],ans;
int read()
{
	int x=0;char ch=getchar();
	while(ch>'9'||ch<'0')ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}
int main()
{
	n=read();s=read();
	for(int i=1;i<=n;++i) a[i]=read();
	sort(a+1,a+n+1);
	for(int i=1;i<=n-1;++i)
	{
		if(s>=a[i]) s-=a[i],++ans;
		else break;
	}
	if(s==a[n]) ++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

x,k,d=map(int, input().split())
aaa=abs(x//d)
if aaa>=k:
    print(min(abs(x-k*d),abs(x+k*d)))
    sys.exit()
else:
    if (k-aaa)%2==0:
        print(min(abs(x-(aaa)*d),abs(x+(aaa)*d)))
        sys.exit()
    else:
        print(min([abs(x-(aaa+1)*d),abs(x+(aaa+1)*d),abs(x-(aaa-1)*d),abs(x+(aaa-1)*d)]))

Measured memory_bytes: 9216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int dist = Integer.parseInt(tmpArray[0]);
			int est = Integer.parseInt(tmpArray[1]);
			
			if(dist == 0 && est == 0){
				break;
			}
			
			double diff = Integer.MAX_VALUE;
			for(int x = 0; x <= dist ; x++){
				double cost = Math.sqrt(x*x + (dist-x)*(dist-x));
//				System.out.println(cost);
				if(diff > Math.abs(est - cost)){
					diff = Math.abs(est - cost);
				}
			}
			
			System.out.println(diff);
		}
	}

}

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

accumulated_sums = []
tmp = 0
for a in A:
    tmp += a
    accumulated_sums.append(tmp)

min_cost = 2020202020
for ac_s in accumulated_sums:
    cur_cost = abs(accumulated_sums[-1] - 2 * ac_s)
    min_cost = min(min_cost, cur_cost)

print(min_cost)

Measured memory_bytes: 27756
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int i;
  string s;
  cin >> s;
  for (i=0;i<s.size();i++){
    if (i%2==1 && s[i]=='R') break;
    if (i%2==0 && s[i]=='L') break;
  }
  if (i==s.size()) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a, b, i, count;

	scanf("%d %d", &a, &b);
	count = 0;
	for(i=a; i<=b; i++){
		if(i%10 == i/10000%10){
			if(i/10%10 == i/1000%10){
				count++;
			}
		}
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define Q int tc; scanf("%d",&tc); for(int test=1;test<=tc;test++)
typedef long long int ll;
#define pi pair<int,int>
int main()
{
  int x,y;
  cin>>x>>y;
  if(y<2*x || y>4*x)  cout<<"No";
  else{
    if(y%2==0)   cout<<"Yes";
    else         cout<<"No";
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

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

typedef long long ll;
typedef vector<int> VI;

int a[200010];
int b[200010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int n; cin >> n;
    REP(i, n) cin >> a[i];
    int m; cin >> m;
    REP(i, m) cin >> b[i];
    
    bool f=true;
    for(int i=0; i<m; ++i){
        int k=b[i];
        int l=0, r=n;
        for(int j=0; j<100; ++j){
            int mid = l+(r-l)/2;
            if(k==a[mid]) break;
            else if(k>a[mid]){
                l = mid+1;
            }else{
                r = mid-1;
            }
            if(j==99) f = false;
        }
    }
    if(f) cout << 1 << endl;
    else cout << 0 << endl;
    
    
    
    
    
	return 0;
}


Measured memory_bytes: 4660
#include <iostream>
#include <bitset>
#include <algorithm>
 
using namespace std;
 
bitset<10000> cookie[10];
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
    int R, C;
	while(cin >> R >> C && R > 0)
	{
		int i, j;
		for (i = 0; i < R; ++i)
		{
			for (j = 0; j < C; ++j)
			{
				bool upwards;
				cin >> upwards;
				cookie[i][j] = upwards;
			}
		}
 
		// ??¨?¨?????????±???2^R?§??????¢
		int permute_r = 1 << R;
		int result = 0;
		for (i = 0; i < permute_r ; ++i)
		{
			// ????????????????????¢
			for (j = 0; j < R; ++j)
			{
				// ?????????????????????????????¢
				if (i & (1 << j))
				{
					cookie[j].flip();
				}
			}
			
 
			// ??????????????????????????????????????????????\??????°????????¶?????§???
			int possible_answer = 0;
			for (j = 0; j < C; ++j)
			{
				int up_cookie_count = 0;
				for (int k = 0; k < R; ++k)
				{
					if (cookie[k][j])
					{
						++up_cookie_count;
					}
				}
				possible_answer += max(up_cookie_count, R - up_cookie_count);
			}
			// ??????????????§???
			result = max(result, possible_answer);
			
			// ??????
			for (j = 0; j < R; ++j)
			{
				if (i & (1 << j))
				{
					cookie[j].flip();
				}
			}
		}
		cout << result << endl;
	}
 
    return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b;
    cin>>a>>b;
    for(ll i=0;;i++){
        if(i*(a-1)+1>=b){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

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

/************************Start Of Template*************************/

/******** Mahin Shefat - GhOstMan *************/


#define     pb              push_back
#define     popb            pop_back
#define     ll              long long int
#define     ull             unsigned long long int
#define     max3(a,b,c)     max(a,max(b,c))
#define     max4(a,b,c,d)   max(max3(a,b,c),d)
#define     min3(a,b,c)     min(a,min(b,c))
#define     min4(a,b,c,d)   min(a,min3(b,c,d))
#define     MOD             1000000007
#define     f               first
#define     s               second
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     mp              make_pair
#define     check           printf("check")
#define     sqr(x)          (x)*(x)
#define     all(v)          v.begin(),v.end()
#define     fast            ios_base::sync_with_stdio(0);cin.tie(0)
#define     pii             pair<int,int>
#define     Pair            pair<ll,ll>
#define     MAX             1000000000000014
#define     MIN             -1000000000000014
#define     endl            '\n'
#define     Fread           freopen("inputdur.txt","r",stdin)
#define     Fwrite          freopen("output.txt","w",stdout)

/************************End Of Template*************************/
double arr[10005];
int main(){
	
	int n;
	cin >> n;
	ll div = 1;
	for(int i = 1; i <= n; i++){
		div = div * 2LL;
		cin >> arr[i];
	}	
	div /= 2;	
	sort(arr + 1 , arr + n + 1);
	double ans = (arr[1] + arr[2]) / div;
	for(int i = 3; i <= n; i++){
		div /= 2;
		ans += (arr[i] / div);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <string>

using namespace std;
 
int main()
{
    int n;
    cin >>n;
    int p,q;
    q = -1;
    long long t =0;
    int m = 0;
    for(int i =0; i<n;i++){
        cin >> p;
        if(q+1<p){
            m = 1;
            
        }
        if(p<q+1){
            t += q;
        }
        q = p;
    }
    t +=q;
    if(m ==0){
        cout << t;
    }else{
        cout << -1;
    }
    return 0;
}

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

int H,W;
vector<string> fi;
int Left[2100][2100],Right[2100][2100],Up[2100][2100],Down[2100][2100];

int main(){
    cin>>H>>W;
    fi.resize(H);
    for(int i=0;i<H;i++)cin>>fi[i];

    for(int i=0;i<H;i++){
        int cur=0;
        for(int j=0;j<W;j++){
            if(fi[i][j]=='#')cur=0;
            else cur++;
            Left[i][j]=cur;
        }
    }
    for(int i=0;i<H;i++){
        int cur=0;
        for(int j=W-1;j>=0;--j){
            if(fi[i][j]=='#')cur=0;
            else cur++;
            Right[i][j]=cur;
        }
    }
    for(int j=0;j<W;j++){
        int cur=0;
        for(int i=0;i<H;i++){
            if(fi[i][j]=='#')cur=0;
            else cur++;
            Up[i][j]=cur;
        }
    }
    for(int j=0;j<W;++j){
        int cur=0;
        for(int i=H-1;i>=0;i--){
            if(fi[i][j]=='#')cur=0;
            else cur++;
            Down[i][j]=cur;
        }
    }

    int res=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(fi[i][j]=='#')continue;
            res=max(res,Left[i][j]+Right[i][j]+Up[i][j]+Down[i][j]-3);
        }
    }
    cout<<res<<endl;


}

Measured memory_bytes: 72448
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
solve :: [String] -> IO ()
solve (str:q:cs) =
    foldM_ ope str $ map words cs
    where
    slice :: String -> Int -> Int -> (String,String,String)
    slice str bgn end =
        let (a,b) = splitAt bgn str in
        let (c,d) = splitAt (1+end-bgn) b in
        (a,c,d)
    ope :: String -> [String] -> IO String
    ope str ["print",a,b] = do
        let [a',b'] = map read [a,b]
        let (_,c,_) = slice str a' b'
        putStrLn c
        return str
    ope str ["reverse",a,b] = do
        let [a',b'] = map read [a,b]
        let (l,c,r) = slice str a' b'
        return $ l ++ reverse c ++ r
    ope str ["replace",a,b,p] = do
        let [a',b'] = map read [a,b]
        let (l,c,r) = slice str a' b'
        return $ l ++ zipWith (\a b->b) c p ++ r
    ope _ _ = undefined

main =
    solve . lines =<< getContents

Measured memory_bytes: 5408
//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

using PII = pair<int, int>;
using TI3 = tuple<int, int, int>;
using LL = long long;
using ULL = unsigned long long;
using MAT = array<array<LL, 2>, 2>;

template<class T> constexpr inline T begin(const T&) {return 0;}
template<class T> constexpr inline T end(const T& x) {return max(T(0), x);}

#define SZ(x) int((x).size())
#define PB push_back
#define EB emplace_back
#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define CHECK(a,b) static_assert(std::is_same<decltype(a), decltype(b)>::value, "REP diff types");

#define REPPP(i,s,c,t) for(i; ((s) and (c)) or (putchar("\n "[c]) and (c)); (t))
#define REPP2(i,n) REPPP(auto i=begin(n),i==begin(n),i!=end(n),++i)
#define REPP3(i,m,n) CHECK(m,n) REPPP(auto i=(m),i==(m),i<(n),++i)
#define REPP4(i,m,n,s) CHECK(m,n) REPPP(auto i=(m),i==(m),((s)>0 and i<(n)) or ((s)<0 and i>(n)),i+=(s))
#define REPP(...) GET_MACRO(__VA_ARGS__, REPP4, REPP3, REPP2)(__VA_ARGS__)

#define REP2(i,n) for(auto i=begin(n);i!=end(n);++i)
#define REP3(i,m,n) CHECK(m,n) for(auto i=(m);i<(n);++i)
#define REP4(i,m,n,s) CHECK(m,n) for(auto i=(m);((s)>0 and i<(n)) or ((s)<0 and i>(n));i+=(s))
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)

template<class T> void _read(T &x) {cin >> x;}
void _read(size_t &x) {scanf("%zu", &x);}
void _read(int &x) {scanf("%d", &x);}
void _read(LL &x) {scanf("%lld", &x);}
void _read(ULL &x) {scanf("%llu", &x);}
void _read(double &x) {scanf("%lf", &x);}
void _read(char &x) {scanf(" %c", &x);}
void _read(char *x) {scanf("%s", x);}
void read() {}
template<class T, class... U>
void read(T& head, U&... tail) {
    _read(head);
    read(tail...);
}

template<class T> void _print(const T &x) {cout << x;}
void _print(const size_t &x) {printf("%zu", x);}
void _print(const int &x) {printf("%d", x);}
void _print(const LL &x) {printf("%lld", x);}
void _print(const ULL &x) {printf("%llu", x);}
void _print(const double &x) {printf("%.16lf", x);}
void _print(const char &x) {putchar(x);}
void _print(const char *x) {printf("%s", x);}
void _print(const string &x) {printf("%s", x.c_str());}
template<class T> void _print(const vector<T> &x) {
    for(auto i = x.begin(); i != x.end(); _print(*i++)) {
        if (i != x.cbegin()) putchar(' ');
    }
}
void print() {putchar('\n');}
template<class T, class... U> void print(const T& head, const U&... tail) {
    _print(head);
    if(sizeof...(tail)) putchar(' ');
    print(tail...);
}

//}}}
const int MOD = 1000000007;

#define LLINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f

#define MAX_N 200005

int C[MAX_N];
int DP[MAX_N], DP2[MAX_N];

int main()
{
    int N;
    read(N);
    REP(i, 1, N + 1) {
        read(C[i]);
    }
    C[0] = -1;
    DP[0] = 1;

    REP(i, 1, N + 1) {
        DP[i] = DP[i - 1];
        if(C[i] != C[i - 1]) {
            DP[i] = (DP[i] + DP2[C[i]]) % MOD;
            DP2[C[i]] = (DP2[C[i]] + DP[i - 1]) % MOD;
        }
    }
    print(DP[N]);
    return 0;
}


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

#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

#define Debug(x) cout<<(#x)<<" >> "<<(x)<<endl

using namespace std;

ll fastpow(ll angka,ll pangkat,ll MOD){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka)%MOD;
		angka=(angka*angka)%MOD;
		pangkat=pangkat>>1;
	}
	return res;
}

ll fastpow(ll angka,ll pangkat){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka);
		angka=(angka*angka);
		pangkat=pangkat>>1;
	}
	return res;
}

ll gcd(ll angka1,ll angka2){
	while(angka2){
		swap(angka1,angka2);
		angka2=angka2%angka1;
	}
	return angka1;
}

ll lcm(ll angka1,ll angka2){
	return (angka1/gcd(angka1,angka2))*angka2;
}


void solve(){
	
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	cout<<max({b*d,b*c,a*c,a*d})<<endl;
	
}

int main(){
	
	fastio();

//	freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

	int t=1;
//	cin>>t;
	
	for(int tt=0;tt<t;tt++){
//		cout<<"Case "<<tt+1<<":\n";solve();
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
void read(int &N,int &M,vector<vector<int>> &g,vector<int>&p);
signed main(){
    int N,M;
    vector<vector<int>> to;
    vector<int> p;
    read(N,M,to,p);
    int ans=0;
    REP(i,1<<N){//2^nパターン列挙
        vector<int> bulb(M,0);
        REP(j,N){//スイッチjに対してビット走査
            int bit=(i>>j)&1;
            if(bit==1) REP(k,to[j].size()) bulb[to[j][k]]++;
        }
        bool ok=true;
        REP(j,M) if(bulb[j]%2!=p[j]) ok=false;
        if(ok) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

void read(int &N,int &M,vector<vector<int>> &g,vector<int>&p){
    cin>>N>>M;
    g.resize(N);p.resize(M);
    REP(i,M){
        int k;cin>>k;
        REP(j,k){
            int s;cin>>s;
            s--;
            g[s].push_back(i);
        }
    }
    REP(i,M) cin>>p[i];
}


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

int main() {
    int N,K,d,hito;
    cin >> N >> K;
    string S;
    vector<int> okasi(N,0);

    for(int i = 0;i < K; i++){
        cin >> d;
        for(int j = 0; j < d; j++){
            cin >> hito;
            okasi.at(hito-1) += 1;
        }
    }

    int cnt = 0;

    for(int i = 0; i < N; i++){
        if(okasi.at(i) == 0){
            cnt++;
        }
    }

    cout << cnt << endl;

}

Measured memory_bytes: 3632
#include <iostream>
		#include <stdio.h>
		#include <cmath>
		#include <algorithm>
		#include <climits>
		#include <vector>
		#include <iomanip>
		#include <string>
		#include <queue>
		#include <numeric>
		#include <functional>
		#include <array>
		#include <map>

		using namespace std;
		using p = pair<int, int>;

		int main() {
			int H,W;
			cin >> H >> W;

			vector<vector<int>>vec(H,vector<int>(W));
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W;++j) {
					cin >> vec.at(i).at(j);
				}
			}

			vector<p>ans;
			for (int i = 0; i < H;++i) {
				for (int j = 0; j < W;++j) {
					if (vec.at(i).at(j) % 2 == 1) {
						if (i != H - 1) {
							vec.at(i + 1).at(j) += 1;
							ans.push_back(make_pair(i + 1, j + 1));
							ans.push_back(make_pair(i + 2, j + 1));
						}
						else if(j != W - 1){
							vec.at(i).at(j + 1) += 1;
							ans.push_back(make_pair(i + 1, j + 1));
							ans.push_back(make_pair(i + 1, j + 2));
						}
					}
				}
			}

			cout << ans.size()/2 << endl;
			for (int i = 0; i < ans.size();++i) {
				cout << ans[i].first << " " << ans[i].second << " ";
				++i;
				cout << ans[i].first << " " << ans[i].second << endl;
			}
		}


Measured memory_bytes: 5232
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
ll f[10000001];
int main(void) {
	ll n;
	cin >> n;
	rep(i, 1ll, n + 1) {
		for (ll k = i; k <= 10000000ll; k += i) {
			f[k]++;
		}
	}
	ll ans = 0;
	rep(i, 1ll, n + 1) {
		ans += i * f[i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 81844
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>
using namespace std;

/// Info.
///****************************************************************************************************************************************///
/// author                : BAHAA El-DEEN OSAMA .
/// Problem name          : T - SUM OF DIGITS
/// Method                : brute force
/// Online judge          : vjudge(Contest)
/// Date                  : 8/6/2020
///****************************************************************************************************************************************///

#define ll long long

  vector<ll> vec(10000, 0);
  int n;

int main()
{

  cin >> n;
  for(ll x=1;x<101;++x)
  {
    for(ll y=1;y<101;++y)
    {
      for(ll z=1;z<101;++z)
      {
            if(x*x + y*y + z*z + x*y + y*z + z*x <= 10000)
            {
                vec[x*x + y*y + z*z + x*y + y*z + z*x]++;
            }
      }
    }
  }


  for(ll i=1;i<n+1;++i)
  {
     cout << vec[i] << "\n";
  }
}


Measured memory_bytes: 3664
#include<stdio.h>

int main()
{
    int n,k,d,m;
    scanf("%d %d", &n,&k);
    if(k>0 && n>0)
    {
        if(k!=1)
        {
            d=n-(k-1)-1;
        }
        else
            d=0;
        printf("%d",d);
    }
    return 0;
}


Measured memory_bytes: 128