akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
        String S = sc.next();
      	String[] strArray = new String[S.length()];
      
      	for (int i = 0; i < S.length(); i++) {
    		String str2 = String.valueOf(S.charAt(i));
      		strArray[i] = str2;
          	if(i>0){
            	if(!(strArray[i].equals(strArray[i-1]))){
                	System.out.println("Yes");
                	return;
                }
            }
		}
      	System.out.println("No");
    }
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;
  
  ll s,t;
  double noudo=-1;
  rep(i,101){
    rep(j,101){
      ll water=a*i*100+b*j*100;
      ll rem=f-water;
      rep(k,rem+1){
        rep(l,rem+1){
          ll sugar=c*k+l*d;
          if(water+sugar>f) continue;
          if((water/100*e)<sugar) continue;
          double tmp=1.0*sugar/(water+sugar);
          if(chmax(noudo,tmp)){
            t=sugar+water, s=sugar;
            // cout<<noudo<<" "<<sugar<<" "<<water<<" "<<t<<" "<<s<<endl;
          }
        }
      }
    }
  }
  
  cout<<t<<" "<<s<<endl;
  
}

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

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n + 1];
		int y[] = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			x[i] = sc.nextInt();
		y[i]=x[i];
		}

		Arrays.sort(x);
		int m = n / 2 + 1;
		int k = n / 2;

		for (int i = 1; i <= n; i++) {
			if (y[i] <= x[k]) {
				System.out.println(x[m]);
			} else {
				System.out.println(x[k]);
			}
		}
	}
}

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

int main()
{
	int m, nmin, nmax, res;
	while (cin >> m >> nmin >> nmax, m || nmin || nmax) {
		int gmax = 0;
		vector<int> P;
		P.reserve(m);
		for (int i = 0, tmp, btm = 100000; i < m; i++) {
			cin >> tmp;
			P.push_back(tmp);
			if (i >= nmin && i <= nmax && btm != 100000 && btm != tmp && btm - tmp >= gmax) {
				res = i;
				gmax = btm - tmp;
			}
			btm = tmp;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
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;}

#define INF 1120000000

int main(){
  string s;
  cin>>s;
  vector<int> vec(26,0);
  for(auto c: s) vec[c-'a']++;

  rep(i,26) if(vec[i]==0){cout << (char)(i+'a')<<endl;return 0;}

  cout << "None" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>

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

    long long int n;
    
    std::cin >> n;

    for (; n--;) {
        std::string str, train;
        std::cin >> str;
        bool is_back = false;
        std::map<char, int> m;
        for (unsigned int i = 0; i < str.size(); i += 3) {
            if (m[str[i]]++ == 0) {
                if (is_back) {
                    train += str[i];
                }
                else {
                    train = str[i] + train;
                }
            }
            
            if (i + 1 != str.size()) {
                if (str[i + 1] == '-') {
                    is_back = true;
                }
                else {
                    is_back = false;
                }
            }
        }
        std::cout << train << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			System.out.println(getPoint(sc));
		}
	}
	
	public static int getPoint(Scanner sc){
		int returnValue = 0;
		int outCount = 0;
		int runner = 0;
		while(true){
			String letter = sc.next();
			if(letter.equals("HIT")){
				if(runner < 3){
					runner += 1;
				}
				else{
					runner = 3;
					returnValue += 1;
				}
			}else if(letter.equals("OUT")){
				outCount += 1;
				if(outCount == 3){
					return returnValue;
				}
			}else if(letter.equals("HOMERUN")){
				returnValue += runner + 1;
				runner = 0;
			}
		}
	}
}

Measured memory_bytes: 17196
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// ------ Classes ------ //
class Point {
public:
	long double px, py;
	Point() : px(0), py(0) {};
	Point(long double px_, long double py_) : px(px_), py(py_) {};
	friend bool operator==(const Point& p1, const Point& p2) { return p1.px == p2.px && p1.py == p2.py; }
	friend bool operator!=(const Point& p1, const Point& p2) { return p1.px != p2.px || p1.py != p2.py; }
	friend bool operator<(const Point& p1, const Point& p2) { return p1.px < p2.px ? true : (p1.px == p2.px && p1.py < p2.py); }
	friend bool operator>(const Point& p1, const Point& p2) { return p1.px > p2.px ? true : (p1.px == p2.px && p1.py > p2.py); }
	friend bool operator<=(const Point& p1, const Point& p2) { return !(p1 > p2); }
	friend bool operator>=(const Point& p1, const Point& p2) { return !(p1 < p2); }
	friend Point operator+(const Point& p1, const Point& p2) { return Point(p1.px + p2.px, p1.py + p2.py); }
	friend Point operator-(const Point& p1, const Point& p2) { return Point(p1.px - p2.px, p1.py - p2.py); }
	friend Point operator*(const Point& p1, long double d) { return Point(p1.px * d, p1.py + d); }
	friend Point operator*(long double d, const Point& p1) { return p1 * d; }
	friend Point operator/(const Point& p1, long double d) { return Point(p1.px / d, p1.py / d); }
	Point& operator+=(const Point& p1) { px += p1.px; py += p1.py; return *this; }
	Point& operator-=(const Point& p1) { px -= p1.px; py -= p1.py; return *this; }
	Point& operator*=(long double d) { px *= d; py *= d; return *this; }
	Point& operator/=(long double d) { px /= d; py /= d; return *this; }
};
// ------ Functions ------ //
long double norm(const Point& a) { return a.px * a.px + a.py * a.py; }
long double abs(const Point& a) { return sqrtl(norm(a)); }
long double dot(const Point& a, const Point& b) { return a.px * b.px + a.py * b.py; }
long double crs(const Point& a, const Point& b) { return a.px * b.py - a.py * b.px; }
int ccw(Point p0, Point p1, Point p2) {
	Point a = p1 - p0, b = p2 - p0;
	if (crs(a, b) > 1e-10) return 1;
	if (crs(a, b) < -1e-10) return -1;
	if (dot(a, b) < -1e-10) return 2;
	if (norm(a) < norm(b)) return -2;
	return 0;
}
bool is_convex(vector<Point> v) {
	if (v.size() < 3) return false;
	int s = -3;
	for (int i = 0; i < v.size(); i++) {
		int r = ccw(v[i], v[(i + v.size() - 1) % v.size()], v[(i + 1) % v.size()]);
		if (abs(r) == 1 && s == -3) s = r;
		if (s * r == -1) return false;
	}
	return true;
}
// ------ Main ------ //
int n; vector<Point> v;
int main() {
	cin >> n; v.resize(n);
	for (int i = 0; i < n; i++) cin >> v[i].px >> v[i].py;
	cout << (is_convex(v) ? 1 : 0) << endl;
}

Measured memory_bytes: 3232
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d\n", &a[i])
	}

	key, count := 1, 0
	buttons := map[int]bool{key: true}
	for {
		count++
		key = a[key-1]
		if buttons[key] {
			fmt.Println(-1)
			break
		} else if key == 2 {
			fmt.Println(count)
			break
		} else {
			buttons[key] = true
		}
	}

}


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

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

    if(N / 100 == 7 || N % 10 == 7 || N % 100 / 10 == 7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
import sys
N,M=map(int,input().split())
L=list(map(int,input().split()))
if N>=M:
    print(0)
    sys.exit()
L.sort()
K=[]
s=0
for i in range(M-1):
    K.append(L[i+1]-L[i])
K.sort(reverse=True)
for i in range(N-1):
    s+=K[i]
print(L[M-1]-L[0]-s)

Measured memory_bytes: 20388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
struct edge{int from, to;};

int main(){
    string s;
    cin>>s;
    bool ex=false;
    int start,last;
    for(int i=0;i<s.size();i++){
        if(!ex && s[i]=='A'){
            ex=true;
            start=i;
        } 
        if(ex&&s[i]=='Z'){
           last=i;     
        }
    }
    cout<<last-start+1<<endl;
    return 0;
}

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B

import           Data.Array.IArray
import           Data.Array.IO
import           Data.Array.MArray
import           Data.Function         (on)
import           Data.List

readi :: B.ByteString -> Int
readi b | Just (n, _) <- B.readInt b = n

dijk :: Array Int [(Int, Int)]
     -> IOUArray Int Bool
     -> IOUArray Int Int
     -> IO ()
dijk b c d = go
  where
    go :: IO ()
    go = do
        as <- filterM (readArray c . fst) =<< getAssocs d
        unless (null as) $ do
            let (i, _) = minimumBy (compare `on` snd) as
            writeArray c i False -- confirmed
            bs <- filterM (readArray c . fst) (b ! i)
            forM_ bs $ \(v, w) -> do
                di <- readArray d i
                dv <- readArray d v
                when (di + w < dv) $ writeArray d v (di + w)
            go

main :: IO ()
main = do
    let f []       = Nothing
        f (i:j:ks) = Just ((i, j), ks)

    n <- readLn
    xss <-
        replicateM n $ do
            (i:_:xs) <- fmap readi . B.words <$> B.getLine
            return (i, unfoldr f xs)

    let b = array (0, n-1) xss      :: Array Int [(Int, Int)]
    c <- newArray (0, n-1) True     :: IO (IOUArray Int Bool)
    d <- newArray (0, n-1) maxBound :: IO (IOUArray Int Int)
    writeArray d 0 0

    dijk b c d

    forM_ [0 .. n-1] $ \i -> do
        v <- readArray d i
        putStr (show i ++ " ")
        print v



Measured memory_bytes: 5448
#include <cstdio>
long long f[2003]={0,0,0,1};
int main(){
    int s;scanf("%d",&s);
    for(int i=4;i<=s;i++) f[i]=(f[i-1]+f[i-3])%1000000007;
    printf("%lld\n",f[s]);
    return 0;
}

Measured memory_bytes: 1744
c = int(input())
n = list(map(int,input().split()))
flag =True
n.sort()
if(len(n)%2==0):
	count=1
else:
	count=2
	if(n.pop(0)!=0):
		flag = False
		print('not 0 false')
while flag:
	if(len(n)==0): break
	if(not count==n.pop(0)==n.pop(0)):
		flag=False
	count += 2

if flag:
	ans = 2**int(c/2)
else:
	ans = 0
print(ans%(10**9+7))

Measured memory_bytes: 13880
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
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;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    in >> a >> b;
    if(a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0){
        out << "Possible" << endl;
    }else{
        out << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

int A,B,q;

signed main(){
    int a,b,c;
    scanf("%d/%d/%d",&a,&b,&c);
    if(a<2019)cout<<"Heisei"<<endl;
    else if(a>2019)cout<<"TBD"<<endl;
    else{
        if(b<4)cout<<"Heisei"<<endl;
        else if(b>4)cout<<"TBD"<<endl;
        else{
            if(c<=30)cout<<"Heisei"<<endl;
            else cout<<"TBD"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >>s;
    int n = s.length();
    int a = 0;
    int b = 0;
    for(int i = 0;i< n;i++)
    {
        if(s[i] == '0')
        {
            a++;
        }
        else if(s[i] == '1')
        {
            b++;
        }
    }
    int ans = min(a,b);;
    
    cout << ans*2 << endl;
}


Measured memory_bytes: 3688
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    N = int(sys.stdin.readline())
    s = set()
    for _ in range(N):
        s.add(int(sys.stdin.readline()))
    print(len(s))

Measured memory_bytes: 5452
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> A;
	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		A.push_back(a);
	}
	{
		vector<int> sortedA(A);
		sort(sortedA.rbegin(),sortedA.rend());
		for(int i=0;i<N;i++){
			if(A[i]==sortedA[0]){
				cout << sortedA[1] << endl;
			}else{
				cout << sortedA[0] << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3316
#include<stdio.h>


int main(void)
{
    int a=0,b=0,c=0,i;
    char s[3];
    scanf("%s",s);
    for(i=0;i<3;i++){
        if(s[i]=='a') a++;
        else if(s[i]=='b') b++;
        else c++;
    }   
    if((a==1)&&(b==1)&&(c==1)) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        Enumerable.Repeat(0, 10)
            .Select(x => int.Parse(Console.ReadLine()))
            .OrderByDescending(x => x)
            .Take(3)
            .ToList()
            .ForEach(Console.WriteLine);
    }
}


Measured memory_bytes: 18604
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Control.Monad
import Control.Monad.ST
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Builder as BSB
import System.IO (stdout)
import Data.Monoid

warshallFloyd1 :: Int -> U.Vector (Int, Int, Int) -> V.Vector (U.Vector Int)
warshallFloyd1 !n !edges = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  U.forM_ edges $ \(a,b,c) -> do
    UM.unsafeWrite (arr `V.unsafeIndex` a) b c
    UM.unsafeWrite (arr `V.unsafeIndex` b) a c
  forM_ [0..n-1] $ \a -> do
    UM.unsafeWrite (arr `V.unsafeIndex` a) a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr `V.unsafeIndex` k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr `V.unsafeIndex` i
      a_ik <- UM.unsafeRead a_i k
      forM_ [0..n-1] $ \j -> do
        a_kj <- UM.unsafeRead a_k j
        UM.unsafeModify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

warshallFloyd2 :: Int -> Int -> V.Vector (U.Vector Int) -> V.Vector (U.Vector Int)
warshallFloyd2 !n !l !graph = runST $ do
  !arr <- V.replicateM n (UM.replicate n (10^9+1))
  forM_ [0..n-1] $ \a -> do
    let !a_a = arr `V.unsafeIndex` a
    let !g_a = graph `V.unsafeIndex` a
    forM_ [0..n-1] $ \b -> do
      let v = g_a `U.unsafeIndex` b
      when (v <= fromIntegral l) $ do
        UM.unsafeWrite a_a b 1
    UM.unsafeWrite a_a a 0
  forM_ [0..n-1] $ \k -> do
    let !a_k = arr `V.unsafeIndex` k
    forM_ [0..n-1] $ \i -> do
      let !a_i = arr `V.unsafeIndex` i
      a_ik <- UM.unsafeRead a_i k
      forM_ [0..n-1] $ \j -> do
        a_kj <- UM.unsafeRead a_k j
        UM.unsafeModify a_i (min (a_ik + a_kj)) j
  V.mapM U.unsafeFreeze arr

main = do
  [n,m,l] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  edges <- U.replicateM m $ do
    [a,b,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (a-1,b-1,c)
  let !w1 = warshallFloyd1 n edges
      !w2 = warshallFloyd2 n l w1
  q <- readLn
  queries <- U.replicateM q $ do
    [s,t] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (s,t)
  BSB.hPutBuilder stdout $ mconcat [ BSB.intDec (if d > 10^9 then -1 else d - 1) <> BSB.char7 '\n' | (s,t) <- U.toList queries, let d = w2 `V.unsafeIndex` (s-1) `U.unsafeIndex` (t-1) ]


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

int main() {
	long int n,i,k;
	cin>>n>>k;
	long int a[n];
	for(i=0;i<n;i++)
	  cin>>a[i];
	long long min1=LLONG_MAX;  
	//cout<<((INT_MAX)<300000000)<<" ";
	for(i=0;i<=(n-k);i++)
	  {
	     if(a[i+k-1]<=0)
	       {  //cout<<'a';
	       	min1=min(min1,(long long )(0-a[i]));
	       }
	     else if(a[i]>=0)
	       {   
	       	min1=min(min1,(long long )(a[i+k-1]));
	       }
	     else{
	        long long int ans=min(a[i+k-1]-a[i]+(0-a[i]),a[i+k-1]-a[i]+(a[i+k-1]));	
	       min1=min(min1,ans);}
	  }
	 cout<<min1<<"\n"; 
	return 0;
}

Measured memory_bytes: 1024
<?php

class Simulator
{
    private $inputs;
    private $backslash = array();
    private $area_pond = array();
    private $pending_area = array();

    public function __construct()
    {
        $this->inputs = trim(fgets(STDIN));
    }

    public function calculateAreas()
    {
        $count = 0;

        for ($index = 0; $index < strlen($this->inputs); $index++) {
            if ($this->inputs[$index] == "\\") {
                $this->backslash[] = $index;
            } elseif ($this->inputs[$index] == "/" and $this->backslash) {
                $last_bs_index = array_pop($this->backslash);
                $diff = $index - $last_bs_index;
                $count += $diff;
                while ($this->area_pond and end($this->area_pond) > $last_bs_index) {
                    $diff += array_pop($this->pending_area);
                    array_pop($this->area_pond);
                }
                $this->area_pond[] = $last_bs_index;
                $this->pending_area[] = $diff;
            }
        }
        echo $count . PHP_EOL;
        echo implode(" ", array_merge([count($this->area_pond)], $this->pending_area)) . PHP_EOL;

        // echo count($this->area_pond), " ", implode(" ", $this->pending_area) . PHP_EOL;
    }
}

$simulator = new Simulator();
$simulator->calculateAreas();



Measured memory_bytes: 12152
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,k,f[N],ans[N];
int getf(int x){return f[x]==x?x:f[x]=getf(f[x]);}
vector<int>v[N],e[N];
bitset<N>b1,b2;
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++) f[i]=i;
    for(int i=1;i<=m;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        e[u].push_back(v);
        e[v].push_back(u);
        u=getf(u);v=getf(v);
        if(u==v) continue;
        f[u]=v;
    }
    for(int i=1;i<=k;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        e[u].push_back(v);
        e[v].push_back(u);
    }
    for(int i=1;i<=n;i++)
        v[getf(i)].push_back(i);
    for(int i=1;i<=n;i++)
        if(f[i]==i)
    {
        b1.reset();
        for(int u:v[i]) b1[u]=1;
        for(int u:v[i])
        {
            b2.reset();
            for(int x:e[u]) b2[x]=1;
            b2[u]=1;
            b2=~b2;
            ans[u]=(b2&b1).count();
        }
    }
    for(int i=1;i<=n;i++)
        printf(i==n?"%d\n":"%d ",ans[i]);
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

    string s;
    cin >> s;
    int sum = s.size(), a = (s.size() - 1)/2;
    for(int i = 0;i < sum/2;i ++){
      if(s[i] != s[sum - i - 1]){
	cout << "No\n";
	return 0;
      }
    }
    for(int i = 0;i < a/2;i ++){
      if(s[i] != s[a - i - 1]){
	cout << "No\n";
	return 0;
      }
    }
    int b = 1;
    for(int i = (sum + 3)/2 - 1;i < sum;i ++){
      if(s[i] != s[sum - b]){
	cout << "No\n";
	return 0;
      }
      b ++;
    }
    cout << "Yes\n";
    
    return 0;
} 


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

int main() {
	// your code goes here
	int k, n, mx=INT_MIN;
	cin >> k >> n;
	vector<int> v(n);
	for(int i=0; i<n; i++){
		cin >> v[i];
		if(i>0)
			mx=max(mx, v[i]-v[i-1]);
	}
	mx=max(mx, k-(v[n-1]-v[0]));
	cout << k-mx << endl;
	return 0;
}		

Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
 int i, c;
 printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

 if(T[u].p == NIL) printf("root, ");
 else if(T[u].l == NIL) printf("leaf, ");
 else printf("internal node, ");

 printf("[");
 for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
   if(i) printf(", ");
   printf("%d", c);
 }
 printf("]\n");

}

void calcDepth(int u, int p){
 D[u] = p;
 if(T[u].r != NIL) calcDepth(T[u].r,p);
 if(T[u].l != NIL) calcDepth(T[u].l,p+1);
}

int main(){
 int i, j, k;
 int n;
 int id, sib, child;
 int root = NIL;
 scanf("%d", &n);
 for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

 for(i=0; i<n; i++){
   scanf("%d %d", &id, &k);
   for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
     scanf("%d", &child);
     T[child].p = id;
     if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
     else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
     sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
   }
 }

 //根を求める (find the root)
 for(i=0; i<n; i++){
   if(T[i].p == -1) root = i;
 }

 //それぞれのノードの深さを求める (find depth of each node)
 calcDepth(root, 0);

 //出力 (output)
 for(i=0; i<n; i++) print(i);

 return 0;
}






Measured memory_bytes: 6376
// AOJ ALDS1_5_B Merge Sort
// 2018.4.30 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20];
void mypr(int n)
{
	int w;
	if (!n) { pc('0'); return; }
	w = 0; while (n) buf[w++] = n%10 + '0', n/=10;
	while (w--) pc(buf[w]);
}

#define MAX_N 500002
#define INF   0x7f7f7f7f

int a[MAX_N];
int w[MAX_N/2+2];
int cnt;

void merge_sort(int low, int high) 
{ 
	int i, j, k, p, mid; 

	if (low < high) {
		mid = (low + high) >> 1;
		merge_sort(low,   mid);
		merge_sort(mid+1, high);

cnt += high-low+1;

		p = mid-low+1;
		memcpy(w, a+low, p << 2);
		i = mid+1, j = 0; k = low;

		w[p] = INF;
		while (i <= high) {
			if (w[j] <= a[i]) a[k++] = w[j++];
			else              a[k++] = a[i++];
		}
		memcpy(a+k, w+j, (p-j) << 2);
	}
}

int main()
{
	int n, i;
	
	n = in(); for (i = 0; i < n; i++) a[i] = in();

	cnt = 0;
	merge_sort(0, n-1);

	mypr(a[0]); for (i = 1; i < n; i++) pc(' '), mypr(a[i]); pc('\n');
	mypr(cnt); pc('\n');
	return 0;
}


Measured memory_bytes: 4528
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    int n; cin >> n;
    vector<pair<ll, ll>> xl(n);
    rep(i, n) {
        ll x, l; cin >> x >> l;
        xl[i] = make_pair(x+l, x-l);
    }
    sort(xl.begin(), xl.end());

    int ans = 0;
    rep(i, n) {
        ll right = xl[i].first;
        ++ans;
        while(i+1<n && xl[i+1].second<right) ++i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<queue>
using namespace std;
int main(){
	queue<char> q;
	string s;
	int m, h;
	while (cin >> s, s != "-"){
		cin >> m;
		for (int i = 0; i<s.size(); ++i)
			q.push(s[i]);
		for (int i = 0; i < m; ++i){
			cin >> h;
			for (int j = 0; j < h; ++j){
				q.push(q.front());
				q.pop();
			}
		}
		for (int i = 0; i<s.size(); ++i){
			s[i] = q.front();
			q.pop();
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1208
def main():
    n,q = list(map(int,input().split(' ')))
    s = input()
    tmp = 0
    s_tr =[]
    q_list = []
    for i in range(n-1):
        if len(s_tr) !=i:
            continue
        if s[i] == 'A' and s[i+1] =='C':
            tmp += 1
            s_tr.append(tmp)
            s_tr.append(tmp)
        else:
            s_tr.append(tmp)
    if len(s_tr) != n:
        s_tr.append(tmp)
    for i in range(q):
        q_list.append(list(map(int,input().split(' '))))

    for l,r in q_list:
        if s_tr[r-1] ==s_tr[r-2]:
            if l ==1:
                print(s_tr[r-1])
            else:
                print(s_tr[r-1]-s_tr[l-2])
        else:
            if l ==1:
                print(s_tr[r-1] - 1)
            else:
                print(s_tr[r-1] - s_tr[l-2] -1 )

if __name__ == '__main__':
    main()

Measured memory_bytes: 30700
#include<bits/stdc++.h>
#define ull unsigned long long
# define lli long long int
# define ulli unsigned long long int
#define ll long long
#define db double
#define ldb long double
#define vi vector<int>
#define vull vector<ull>
#define vll vector<ll>
#define pb push_back
#define eb emplace_back
#define si set<int>
#define sll set<ll>
#define ins insert
#define rep(i,n) for(int i=0;i<n;i++)
#define vpp vector<pair<int,int>>
#define mp make_pair
#define ft first
#define sc second
#define gp " ";
#define MAX 9999999
#define MOD 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t,i=0,c=0,s,d,r,mx=0,n,j=0;
    cin>>n;
    ll a[n+1],b[n+1];
    for(i=0;i<n;i++)
    {
              cin>>a[i]>>b[i];
    }
    for(i=0;i<n;i++)
    {
           if(a[i]==b[i])
                    c++;
           else{
                    mx=max(c,mx);c=0;}
    }
    mx=max(mx,c);
    if(mx>=3) cout<<"Yes";
    else cout<<"No";

}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
int main(void) {
  std::vector<int> v;
  for(int i=0; i<3; i++) {
    int x;
    std::cin >> x;
    v.push_back(x);
  }
  std::sort(v.begin(), v.end());
  std::cout << (v[1]-v[0]) + (v[2]-v[1]) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {

	//ループ変数
	int i ;

	//移動回数
	int num ;
	scanf("%d", &num) ;

	//合計
	int sum = 1 ;

	//サイコロの目の値
	int N, E, W, S, T, U ;
	
	//一時保存用
	int temp ;

	//初期値
	T = 1 ;
	U = 6 ;
	N = 5 ;
	E = 3 ;
	W = 4 ;
	S = 2 ; 

	//移動回数の値が0になるまでループ
	while (num != 0) {

		for (i = 0 ; i < num ; i++) {
	
			char s[20] ;
			scanf("%s", s) ;

			if (!strcmp(s, "North")) {
				sum += S ;
				temp = T ;
				T = S ;
				S = U ;
				U = N ;
				N = temp ;
			}
			else if (!strcmp(s, "West")) {
				sum += E ;
				temp = T ;
				T = E ;
				E = U ;
				U = W ;
				W = temp ;
			}
			else if (!strcmp(s, "East")) {
				sum += W ;
				temp = T ;
				T = W ;
				W = U ;
				U = E ;
				E = temp ;
			}
			else if (!strcmp(s, "South")) {
				sum += N ;
				temp = T ;
				T = N ;
				N = U ;
				U = S ;
				S = temp ;
			}
			else if (!strcmp(s, "Left")) {
				sum += T ;
				temp = S ;
				S = W ;
				W = N ;
				N = E ;
				E = temp ;
			}
			else if (!strcmp(s, "Right")) {
				sum += T ;
				temp = S ;
				S = E ;
				E = N ;
				N = W ;
				W = temp ;
			}

		}

		printf("%d\n", sum) ;
		
		sum = 1 ;
		T = 1 ;
		U = 6 ;
		N = 5 ;
		E = 3 ;
		W = 4 ;
		S = 2 ; 

		scanf("%d", &num) ;

	}

	return 0 ;

}

Measured memory_bytes: 604
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    k: i64,
    n: usize,
    a: [i64; n],
  }
  let mut rest = (a[0] + k) - a[n-1];
  for i in 0 .. n-1 {
    rest = cmp::max(rest, a[i+1] - a[i]);
  }

  puts!("{}\n", k - rest);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;

class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}

bool solve() {
    string s; cin >> s;
    sort(ALL(s));
    if (s == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static int goal;
	static Integer[] list;
	static int[] cache;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		goal = sc.nextInt();
		int c = sc.nextInt();
		list = new Integer[c];
		cache = new int[goal + 1];
		for (int i = 0; i < c; i++) {
			list[i] = sc.nextInt();
		}
		Arrays.sort(list,Collections.reverseOrder());
		System.out.println(compute(goal));
	}

	public static int compute(int value) {
		if (cache[value] != 0) {
			return cache[value];
		}
		if (value == 0) {

			return 0;
		}
		int result = Integer.MAX_VALUE;
		for (int e : list) {
			if (e <= value) {
				int sub = compute(value - e);
				if (sub + 1 < result) {
					result = sub + 1;
				}
			}
		}
		cache[value] = result;
		return result;
	}
}

Measured memory_bytes: 26988
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;

int main()
{
//	freopen("input.txt","r",stdin);
	string c;
	cin>>c;
	int res=0;
	for(int i=0;i<c.size();i++)
	{
		res+=(c[i]=='x');
	}
	if(res<=7) cout<<"YES\n";else cout<<"NO\n";
	return 0;
}

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

int main(void){
    int N;
    cin >> N;

    N %= 10;
    if(N == 3){
        cout << "bon" << endl;
    }else if(N == 0 || N == 1 || N == 6 || N == 8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

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

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

  vector<int> list;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    list.push_back(tmp);
  }

  sort(list.begin(), list.end());  // 昇順
  
  int min = list[0];
  int max = list[N - 1];

  cout << max - min << endl;
}


Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const double eps = 1e-8;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	int n; cin >> n;
	ll k; cin >> k;
	vector<ll> a(n), f(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> f[i];
	sort(all(a));
	sort(rall(f));
	ll r = 0;
	ll l = -1;
	for (int i = 0; i < n; i++) r = max(r, a[i] * f[i]);
	while (r - l > 1) {
		ll mid = (l + r) / 2;
		ll cur = k;
		for (int i = 0; i < n; i++) {
			cur -= max(0LL, a[i] - mid / f[i]);
		}
		if (cur >= 0) r = mid;
		else l = mid;
	}
	cout << r << endl;
}

Measured memory_bytes: 3456
h = int(input())
w = int(input())
n = int(input())

n_push = []

for n_h in range(h+1):
  for n_w in range(w+1):
    n_tmp = (n_h)*w + (n_w)*h - ((n_h)*(n_w))

    if n_tmp>=n:
      n_push.append(n_h + n_w)

print(min(n_push))

Measured memory_bytes: 3060
// based on http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2784229#1
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };
bool dfs(int x, int y, int goalx, int goaly, std::vector<std::vector<bool>>&canGo) {
  if (x == goalx && y == goaly) { return true; }
  canGo[y][x] = false;
  for (int i = 0; i < 4; i++) {
    int next_x = x + needleX[i];
    int next_y = y + needleY[i];
 
    if (canGo[next_y][next_x]) {
      bool flag = dfs(next_x, next_y, goalx, goaly, canGo);
      if (flag)
        return true;
    }
  }
  return false;
}
int main(void) {
  int h, w, n;
  std::cin >> w >> h;
  std::vector<std::string> ans;
  while(!(h == 0 && w == 0)){
    int color=-1, orient, leftX, leftY;
    int sx, sy, gx, gy;
    std::cin >> sx >> sy >> gx >> gy;
    std::vector<std::vector<int>> board(h + 2, std::vector<int>(w + 2, 0));
    std::vector<std::vector<bool>> canGo(h + 2, std::vector<bool>(w + 2, false));
    std::cin >> n;
    int start = -1, goal = -1;
    for (int i = 0; i < n; i++) {
      std::cin >> color >> orient >> leftX >> leftY;
 
 
      if (orient == 0) {
        for (int j = 0; j <= 3; j++) {
          for (int k = 0; k <= 1; k++) {
            board[leftY + k][leftX + j] = color;
            if (leftX + j == sx && leftY + k == sy) {
              start = color;
            }
            else if (leftX + j == gx && leftY + k == gy) {
              goal = color;
            }
          }
        }
 
      }
      else {
        for (int j = 0; j <= 1; j++) {
          for (int k = 0; k <= 3; k++) {
            board[leftY + k][leftX + j] = color;
            if (leftX + j == sx && leftY + k == sy) {
              start = color;
            }
            else if (leftX + j == gx && leftY + k == gy) {
              goal = color;
            }
          }
        }
      }
    }

    // for (int i = 0; i <= h; i++) {
    //   for (int j = 0; j <= w; j++) {
    //     std::cerr << board[i][j] << " ";
    //   }
    //   std::cerr << std::endl;
    // }
    
    if (start != -1) {
      for (int i = 0; i <= h; i++) {
        for (int j = 0; j <= w; j++) {
          if (board[i][j] == start) {
            canGo[i][j] = true;
          }
        }
      }
    }

    if (start != goal || start == -1) {
      ans.push_back("NG");
      std::cin >> w >> h;
      continue;
    }

    bool result = dfs(sx, sy, gx, gy, canGo);
    if (result) { ans.push_back("OK"); }
    else { ans.push_back("NG"); }
    std::cin >> w >> h;
  }
  int anssize = ans.size();
  for (int i = 0; i < anssize; i++) {
    std::cout << ans[i] << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3244
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep2(x,from,to) for(long long x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
long long n;
long long ans;
long long gcd(long long a,long long b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}
int main()
{
    cin>>n;
    rep2(i,1,n+1)rep2(j,1,n+1)rep2(k,1,n+1)
    {
        ans+=gcd(i,gcd(j,k));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3640
# -*- coding: utf-8 -*-

N = int(input())
A = [input() for _ in range(N)]

def count(a):
  if '.' in a:
    c = a.split('.')
    n = int(c[0]+c[1])
    count2 = count5 = 9 - len(c[1])
  else:
    n = int(a)
    count2 = count5 = 9
  while n%2==0 and count2<18:
    n //= 2
    count2 += 1
  while n%5==0 and count5<18:
    n //= 5
    count5 += 1
  return count2, count5

Z = [[0 for _ in range(19)] for _ in range(19)]
answer = 0
for a in A:
  c2, c5 = count(a)
  answer += Z[18-c2][18-c5]
  for i in range(c2+1):
    for j in range(c5+1):
      Z[i][j] += 1

print(answer)

Measured memory_bytes: 94476
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,L; cin >> N >> L;
	V<int> a(N);
	for(int i = 0; i < N; ++i) a[i] = L + i;
	int sum = accumulate(ALL(a),0);
	int ans, dif = 12345678;
	for(int i = 0; i < N; ++i){
		int cnt = sum - a[i];
		if(abs(sum-cnt)<dif){
			dif = abs(sum-cnt);
			ans = cnt;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from operator import itemgetter
import datetime

n = int(input())
sn = dict()

for i in range(n):
    s = input()
    if(s in sn):
        sn[s] += 1
    else:
        sn[s] = 1

sn = sorted(sn.items(), key=lambda x:(-x[1],x[0]))
#print(sn)

max_val = max(dict(sn).values())

for si in sn:
    if(int(si[1]) == max_val):
        print(si[0])
    else:
        break

Measured memory_bytes: 68688