akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

struct rangeL{
  ll l,r;
};
bool operator<(const rangeL& a,const rangeL& b){
  if(a.l==b.l) return a.r < b.r;
  else return a.l > b.l;
}

struct rangeR{
  ll l,r;
};
bool operator<(const rangeR& a,const rangeR& b){
  if(a.r==b.r) return a.l > b.l;
  else return a.r < b.r;
}

int n;
multiset<rangeL> lst;
multiset<rangeR> rst;
vector<P> ps;

int main(){
  cin>>n;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    lst.insert((rangeL){a,b});
    rst.insert((rangeR){a,b});
    ps.push_back(P(a,b));
  }
  ll resa=0,resb=0;
  { // left -> right
    ll crtpos=0;
    rep(i,n){
      if(lst.size()==0||rst.size()==0)break;

      if(i%2==0){
        rangeL nxt=*lst.begin();
        if(crtpos<nxt.l){
          resa+=nxt.l-crtpos;
          crtpos=nxt.l;
        }
        lst.erase(lst.find(nxt));
        rst.erase(rst.find((rangeR){nxt.l,nxt.r}));
      }else{
        rangeR nxt=*rst.begin();
        if(crtpos>nxt.r){
          resa+=crtpos-nxt.r;
          crtpos=nxt.r;
        }
        lst.erase(lst.find((rangeL){nxt.l,nxt.r}));
        rst.erase(rst.find(nxt));
      }
    }

    resa+=abs(crtpos);
  }

  lst.clear(); rst.clear();
  rep(i,n){
    lst.insert((rangeL){ps[i].fi,ps[i].se});
    rst.insert((rangeR){ps[i].fi,ps[i].se});
  }

  { // right -> left
    ll crtpos=0;
    rep(i,n){
      if(lst.size()==0||rst.size()==0)break;
      if(i%2==1){
        rangeL nxt=*lst.begin();
        if(crtpos<nxt.l){
          resb+=nxt.l-crtpos;
          crtpos=nxt.l;
        }
        lst.erase(lst.find(nxt));
        rst.erase(rst.find((rangeR){nxt.l,nxt.r}));
      }else{
        rangeR nxt=*rst.begin();
        if(crtpos>nxt.r){
          resb+=crtpos-nxt.r;
          crtpos=nxt.r;
        }
        lst.erase(lst.find((rangeL){nxt.l,nxt.r}));
        rst.erase(rst.find(nxt));
      }
    }
    resb+=abs(crtpos);
  }
  cout<<max(resa,resb)<<endl;
  return 0;
}


Measured memory_bytes: 14320
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
 
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//infinity
#define INTINF 2000000000
#define LONGINF 20000000000
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(){
	int n;
	cin >> n;
	map<long long, int> m;

	FOR(i, 1, n+1){
		m[i] = 0;
	}

	int count = 0;
	REP(i, n){
		long long t;
		cin >> t;
		if( t > n ){
			count++;
			continue;
		}
		m[t]++;
	}

	FOR(i, 1, n+1){
		if( m[i] < i ){
			count += m[i];
		}else{
			count += m[i] - i;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <math.h>
using namespace std;

int main()
{
    int n,i,ge;
    while(scanf("%d",&n)!=EOF)
    {
        ge=sqrt(n);
        if(n==(ge*ge))
            printf("%d\n",n);
        else
        {
            for(i=n;i>0;i--)
            {
                if(sqrt(i)-(int)sqrt(i)==0)
                {
                    printf("%d\n",i);
                    break;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void)
{
  int n;
  double x[8];
  double y[8];
  int i,j;
  double l=0;
  double ans;
  double d[8][8];
  double c;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%lf %lf",&x[i],&y[i]);
  
  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      d[i][j]=sqrt(pow((x[i]-x[j]),2)+pow((y[i]-y[j]),2));
    }
  }
  
  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      l+=d[i][j];
    }
  }
  
  l=l/2;
  printf("%lf",2*l/n);
  
  return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  long k;
  cin >> k;

  long a = 7;
  for (long i = 0; i < k; i++) {
    if (a % k == 0) {
      cout << i + 1 << endl;
      return 0;
    }
    a = (a * 10 + 7) % k;
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  int a[n];
  REP(i, n) cin>>a[i];
  int cnt[1000010] = {};
  REP(i, n) cnt[a[i]]++;
  int ans = 0;
  for(int t = 1; t <= 1000000; t++){
    if(cnt[t] == 0) continue;
    if(cnt[t] > 1){
      cnt[t] = 0;
    }
    int temp = 2 * t;
    while(temp < 1000010){
      cnt[temp] = 0;
      temp += t;
    }
  }
  for(int t = 1; t <= 1000000; t++) ans += cnt[t];
  cout << ans << endl;      
  return 0;
}


Measured memory_bytes: 8256
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///最大公約数を返す
func gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var aryA = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    var ans = 0
    for i in 0..<n {
        while aryA[i] % 2 == 0 {
            aryA[i] /= 2
            ans += 1
        }
    }
    print(ans)
}
main()


Measured memory_bytes: 13888
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int arr[5], result = 987654321, chk[5];

void func(int depth, int hap)
{
    if(depth == 5)
    {
        result = min(result, hap);
        return;
    }
    for(int i = 0; i < 5; i++)
    {
        if(chk[i] == 0)
        {
            int temp = 0;
            chk[i] = 1;
            if(depth != 4 && (hap + arr[i]) % 10 != 0)
            {
                temp = 10 - (hap + arr[i]) % 10;
            }
            func(depth + 1, hap + arr[i] + temp);
            chk[i] = 0;
        }
    }
}

int main()
{
    for(int i = 0; i < 5; i++)
    {
        scanf("%d", &arr[i]);
    }
    func(0, 0);
    printf("%d", result);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool isprime(int x)
{
	for (int i = 2; i <= sqrt(x); i++)
	{
		if (x % i == 0) return false;
	}
	return true;
}
int main()
{


	int n;
	cin >> n;



	vector<long long>vc(n + 1, 0);
	for (int i = 2; i <= n; i++)
	{
		if (isprime(i))
		{
			vc[i]++;
		}
		else {

			for (int j = 2; j <= i; j++)
			{
				if (isprime(j) and i % j == 0)
				{
					int ct = 0;
					int x = i;
					while (x % j == 0)
					{
						x = x / j;
						ct++;
					}
					vc[j] += ct;

				}
			}



		}
	}

	long long res = 1;


	for (int i = 2; i <= n; i++)
	{
		if (isprime(i))
		{
			res = ((res % 1000000007) * ((vc[i] + 1) % 1000000007)) % 1000000007;
		}
	}

	cout << res << endl;









	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), C(N);
    int res = 0;
    for(int i=0; i<N; ++i) {
        cin >> A[i];
        --A[i];
    }
    for(int i=0; i<N; ++i) {
        int b; cin >> b;
        res += b;
    }
    for(int i=0; i+1<N; ++i) cin >> C[i];

    for(int i=0; i+1<N; ++i) {
        if(A[i] + 1 == A[i + 1]) res += C[A[i]];
    }

    cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static int N;
    static int A;
    static int B;
    static int C;
    static int[] l;
    static void Main(string[] args)
    {
        int[] NABC = ReadLineParseIntArray();
        N = NABC[0];
        A = NABC[1];
        B = NABC[2];
        C = NABC[3];
        l = new int[N];
        for(int i = 0; i < N; i++)
            l[i] = ReadLineParseInt();
        WriteLine(BFS(0, 0, 0, 0) - 30);
    }
    static int BFS(int d, int a, int b, int c)
    {
        if (d == N)
        {
            return  Abs(a - A) + Abs(b - B) + Abs(c - C) + (Min(Min(a, b), c) == 0 ? 100000000 : 0);
        }
        int ret = BFS(d + 1, a, b, c);
        int ret0 = BFS(d + 1, a + l[d], b, c) + 10;
        int ret1 = BFS(d + 1, a, b + l[d], c) + 10;
        int ret2 = BFS(d + 1, a, b, c + l[d]) + 10;
        return new int[4] { ret,ret0, ret1, ret2 }.Min();
    }
    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

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

int n,s;
int cnt;

void solve(int a,int b,int i){
  if(a == n && b == s){
    cnt++;
    return;
  }
  if(a == n) return;
  if(i == 10) return;

  solve(a+1,b+i,i+1);
  solve(a,b,i+1);
}

int main(){

  while(true){
    cin >> n >> s;
    if(!n && !s) break;

    cnt = 0;
    solve(0,0,0);

    cout << cnt << endl;
  }

}

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

const long long INF = 1LL << 60;

int N;
long long h[100010];

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

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

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

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

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

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

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

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

struct edge {
    int to, cost;
};

int n;
int m;
vector<vector<edge>> g;
vector<int> d;

//ダイクストラ法
void dijkstra(int s) {
    for (int i = 0; i < n; ++i) {
        d[i] = INF;
    }

    //最小値を取り出す優先度付きキュー
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;

    d[s] = 0;
    que.push(make_pair(0, s)); //距離を最初にして、優先度付きキューで最小値を出せるようにする

    while (!que.empty()) {
        pair<int, int> p = que.top(); que.pop();
        int v = p.second;

        //記録してある最短距離よりも取り出した要素に入っている距離情報が大きい場合は打ち切り
        if (d[v] < p.first) continue;

        for (int i = 0; i < g[v].size(); ++i) {
            edge e = g[v][i];

            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

int main() {

    cin >> n >> m;

    g.resize(n);
    d.resize(n);

    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;
        --a; --b;

        g[a].push_back(edge({b, 1}));
        g[b].push_back(edge({a, 1}));
    }

    dijkstra(0);

    for (int i = 0; i < n; ++i) {
        if (d[i] == INF) {
            puts("No");
            return 0;
        }
    }

    cout << "Yes" << endl;

    vector<int> t(n, 0);
    for (int i = 1; i < n; ++i) {
        t[d[i]] = i;
    }

    for (int i = 1; i < n; ++i) {
        cout << t[d[i] - 1] + 1 << endl;
    }
}

Measured memory_bytes: 13224
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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

fn main() {
    input!{
        s: String,
    };

    let patterns = ["eraser", "erase", "dreamer", "dream"];
    let s = patterns.iter().fold(s, |s, x| s.replace(x, ""));
    println!("{}", if s.is_empty() { "YES" } else { "NO "});

}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N=510;
int n,m,d;
char s[4]={'R','Y','B','G'};
int main(){
	cin>>n>>m>>d;
	int x,y;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			x=(i+j)/d,y=(i-j+m+n)/d;
			putchar(s[(x&1)*2+(y&1)]);
		}
		cout<<endl;
	}
}

Measured memory_bytes: 512
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
import numpy as np
def main():
    x = int(input())
    for i1 in range(-201, 201):
        for i2 in range(-201, 201):
            if i1**5 - i2**5 == x:
                print(i1, i2)
                sys.exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 27024
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
int y, m, d;
int main() {
	scanf("%d/%d/%d", &y, &m, &d);
	if (y > 2019) return printf("TBD\n"), 0;
	if (m > 4) return printf("TBD\n"), 0;
	if (m > 30) return printf("TBD\n"), 0;
	printf("Heisei\n"), 0;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.IntMap as IM
import qualified Data.Vector as V
main=print.solve.map(map read.words).lines=<<getContents
solve::[[Int]]->Int
solve([n,m]:abs)=fst(f(-1)0 IM.empty)-1 where
  f s t v=(c+if p==w IM.! t then 1 else 0,w)where
    p=IM.size v
    (c,w)=foldr h(0,IM.insert t p v)$g V.! t
    h i a@(c,v)
      |i==s=a
      |IM.member i v=(c,IM.adjust(min(v IM.! i))t v)
      |otherwise=let(d,w)=f t i v in(c+d,IM.adjust(min(w IM.! i))t w)
  g=V.accum(flip(:))(V.replicate n[])$concatMap(\[a,b]->[(a,b),(b,a)])$map(map pred)abs

Measured memory_bytes: 1020
#include <stdio.h>

int abs(int a){
  if(a >= 0) return a;
  else return -a;
}

int min(int a,int b){
  if(a >= b) return b;
  else return a;
}

int min_array(int *array, int i,int k){//min(array[i,i-1,..,i-k+1 or 0])
  int answer = array[i];
  for(int j = i; j > i - k && j >= 0; j--) answer = min(answer, array[j]);
  return answer;
}

int main(){
  int n,k;
  scanf("%d %d\n", &n, &k);
  int h[n];
  for(int i = 0; i < n; ++i) scanf("%d", &h[i]);
  int cost[n];
  cost[0] = 0;
  int bin[n];
  for(int i = 1; i < n; ++i){//i番目(足場i+1)の総和コスト
    for(int j = i - 1; j > i - k - 1 && j >= 0; j--){
      bin[j] = cost[j] + abs(h[i] - h[j]);
    }
    cost[i] = min_array(bin,i-1,k);
  }
  printf("%d\n", cost[n-1]);
  return 0;
}

Measured memory_bytes: 1280
from fractions import gcd
from math import gcd

def lcm(x,y):
    return (x * y) // gcd(x, y)


def get_2(x):
    curr_2 = 0
    curr_x = x
    while curr_x%2 == 0:
        curr_x = curr_x//2
        curr_2 += 1
    return curr_2

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


if n == 1:
    cnt = (m-al[0]//2)//al[0] + 1
    print(cnt)
    exit()



a2_set = set()
a2_set.add(get_2(al[0]))
for a in al:
    two_cnt = get_2(a)
    if two_cnt not in a2_set:
        print(0)
        exit()
    a2_set.add(two_cnt)


curr_lcm = 1
for a in al:
    curr_lcm = lcm(curr_lcm, a//2)

lcm_cnt = m//curr_lcm
lcm_cnt = (lcm_cnt+2-1)//2

# print(curr_lcm)
print(lcm_cnt)





Measured memory_bytes: 86000
//someshsingh22		
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define loop(i,n) for(int i = 0 ; i < n; i++)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define inp_int(n,arr) int arr[n]; loop(i,n) cin >> arr[i];
#define inp_ll(n,arr) ll arr[n]; loop(i,n) cin >> arr[i];
#define out_int(n,arr) loop(i,n) printf("%d ",arr[i]);
#define out_ll(n,arr) loop(i,n) printf("%lld ",arr[i]); cout << endl;
#define all(c) c.begin(),c.end()
// Snippets : BFS, DFS, edger, ncr, chef, inverse, sieve, lis-d*, mat_d*, pow

typedef long long ll;
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main ()
{
	FAST;

	ll n; cin >> n;
	ll step = n;
	ll div = 1;
	for(ll i = 1; i*i <= n; i++)
	{
		if(n%i==0)
			div=i;
	}
	cout << div+n/div-2;
	return 0;
}


Measured memory_bytes: 256
open Printf
open Scanf

module L =
  struct
    include List
  
    let init n f =
      let rec loop i =
        if i = n then []
        else let x = f i in
             x :: loop (i + 1) in
      loop 0
  end
       
let solve n =
  let f x = x mod 2 = 1 || x mod 3 = 0 || x mod 5 = 0 in
  if L.for_all f @@ L.init n @@ fun _ -> scanf "%d " @@ fun x -> x then "APPROVED" else "DENIED"

let () =
  scanf "%d " solve |> printf "%s\n"


Measured memory_bytes: 384
n,k = map(int, input().split())
s = input()

if s[0]=='1':
    l = [1]
else:
    l = [0,1]

for i in range(1,n):
    if s[i] ==s[i-1]:
        l[-1]+=1
    else:
        l.append(1)

prev = sum(l[0:2*k+1])
ans = prev
for i in range(len(l)//2+1):
    prev = prev-sum(l[2*i:2*i+2]) + sum(l[2*i+2*k+1:2*i+2*k+3])
    ans = max(ans, prev)

print(ans)


Measured memory_bytes: 4596
// ABC142C.cpp 
//

#include <iostream>
#include <vector> // 配列を使う
using namespace std;
int main()
{
	int N; // 生徒の人数を受け取る　整数
	cin >> N;
	vector<int> A(N + 1); // 出席番号0番は使わない　1～Ｎ番までを使う　Ｎ＋１個準備する
	int num; // 読み込んだ値を一時的に保持する
	for (int i = 1; i <= N; i++)
	{
		cin >> num;
		A.at(num) = i;
	}
	// スペース区切りで出力
	for (int j = 1; j < N; j++)
	{
		cout << A.at(j) << " ";
	}
	// 最後の出力にはスペースは入れない　改行する
	cout << A.at(N) <<endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

struct topological_sort{
    const int V;
    vector<vector<int>> board;
    vector<int> into,list;
    vector<bool> visited;
    topological_sort(int v)
        :V(v)
        ,into(v,0)
        ,visited(v,false)
        {
            board.assign(v,vector<int>());
        }
    // 入力
    void add(int from,int to){
        board[from].push_back(to);
        into[to]++;
    }
    // トポロジカルソート
    void build(){
        for(int i=0;i<V;i++){
            if(into[i]==0&&!visited[i]){
                queue<int> q;
                q.push(i);
                while(q.size()){
                    int from=q.front(); q.pop();
                    list.push_back(from);
                    visited[from]=true;
                    for(int to:board[from]){
                        into[to]--;
                        if(into[to]==0&&!visited[to]){
                            q.push(to);
                        }
                    }
                }
            }
        }
    }
    // 取得
    vector<int> get(){
        return list;
    }
    // debug
    // void debug(){
    //     for(int x=1;x<(int)board.size()-1;x++){
    //         for(int y=1;y<(int)board[0].size()-1;y++){
    //             cout<<board[x][y]<<" ";
    //         }
    //         cout<<endl;
    //     }
    // }
};
// verify
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B&lang=jp
int main(){
    int V,E; cin>>V>>E;
    topological_sort graph(V);
    while(E--){
        int s,t; cin>>s>>t;
        graph.add(s,t);
    }
    graph.build();
    vector<int> l=graph.get();
    rep(i,V) cout<<l[i]<<(i==V-1?"\n":" ");
    return 0;
}



Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int main() {
    int d;
    cin >> d;
    if(d == 25)cout << "Christmas" << endl;
    if(d == 24)cout << "Christmas Eve" << endl;
    if(d == 23)cout << "Christmas Eve Eve" << endl;
    if(d == 22)cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 3584
/* https://atcoder.jp/contests/abc122/tasks/abc122_b */

#include <iostream>
#include <string>
#include <set>

int solve(const std::string S)
{
  std::set<char> base = {'A', 'C', 'G', 'T'};
  int max_sub_string_length = 0;

  for (int i = 0; i < int(S.length()); ++i) {
    int sub_string_length = 0;
    for (int j = i; j < int(S.length()); ++j) {
      if (base.find(S.at(j)) == base.end()) {
        break;
      }
      sub_string_length++;
    }
    max_sub_string_length = std::max(max_sub_string_length, sub_string_length);
  }

  return max_sub_string_length;
}

int main(int argc, char *argv[])
{
  // Input
  std::string S;

  std::cin >> S;

  // Output
  std::cout << solve(S) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(i,arr)       for(int& i:arr)cin>>i;
#define output(i,arr)      for(int& i:arr)cout<<i<<" ";
#define for_each(arr)      for(auto& it:arr)
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ll h,w;
    cin>>h>>w;
   // cout<<(w+1)/2*((h+1)/2)<<endl;
   if(h==1||w==1)
   	{
   		cout<<1<<endl;
   	}
   else 
    cout<<(1ll*((w+1)/2)*((h+1)/2))+(1ll*(w/2)*(h/2));
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    private static FastReader in = new FastReader(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    private static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        char[] s = in.next().toCharArray();

        int count = 0;
        for (char ch : s) {
            if (ch == 'p') {
                count++;
            }
        }
        int ans = s.length / 2;
        ans -= count;
        out.println(ans);
    }

    // https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

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

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

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

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

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

        // https://qiita.com/masakinpo/items/5f77f2a879578a85a0bb
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int64_t n, x;

void read()
{
	cin >> n >> x;
}

int64_t rec(int64_t a, int64_t b)
{
	if(a == 0 || b == 0) return -(a + b);
	if(a > b) return rec(b, a);
	
	int64_t c = (b / a);
	return rec(a, b - c * a) + c * a * 2ll;
}

void solve()
{
	cout << n + rec(x, n - x) << endl;
}

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

	read();
	solve();
	return 0;
}



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

using namespace std;

void fast();

/*
*
* Watch out! Another Buggy Code From Muhammad_Mamdouh, Happy Coding;
*
*/

int main()
{
    fast();
    string s, x; cin >> s >> x;

    int cnt = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] != x[i])
            ++cnt;
    }

    cout << cnt;

    return 0;
}

void fast()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

Measured memory_bytes: 3800
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vector<ll> a(n); rep (i, a.size()) cin >> a[i];
    rep (i, k, n) {
        bool ok =  (a[i - k] < a[i]);
        cout << (ok ? "Yes\n" : "No\n");
    }
    return 0;
}

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

using ll = long long int;


int main(){
    int n;
    cin >> n;
    vector<vector<ll> > cnt(10, vector<ll>(10));
    for(int i=1;i<=n;i++){
        int j = i;
        while(j>=10) j /= 10;
        cnt[j][i%10]++;
    }
    ll ans = 0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            ans += cnt[i][j] * cnt[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), x = sc.nextInt();
        int[] a = new int[m];
        int cntl = 0, cntr = 0;
        for(int i = 0; i < m; i++){
            a[i] = sc.nextInt();
            if(a[i] < x) cntl++;
            else cntr++;
        }
        System.out.println(Math.min(cntl, cntr));
    }
}

Measured memory_bytes: 25300
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
double dp[903][602][301];ll a[301],n,n1,n2,n3;
double f(ll i,ll j,ll k)
{
	if(i==0 && j==0 && k==0)
	return dp[i][j][k]=0.00;
	if(dp[i][j][k]!=-1.0)
	return dp[i][j][k];
	ll m=i+j+k;
	double ans = (n*1.00)/m;
	if(i!=0)
	ans+=((i*1.00)/m)*f(i-1,j,k);
	if(j!=0)
	ans+=((j*1.0)/m)*f(i+1,j-1,k);
	if(k!=0)
	ans+=((k*1.0)/m)*f(i,j+1,k-1);
	return dp[i][j][k]=ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout<<setprecision(12)<<fixed;
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k;
    	cin>>n;
    	n1=0; n2=0; n3=0;
    	rep(i,0,n)
    	{
    		cin>>a[i];
    		if(a[i]==1)
    		n1++;
    		else if(a[i]==2)
    		n2++;
    		else
    		n3++;
		}
    	lld ans=0.0;
    	repi(i,0,n1+n2+n3)
    	{
    		repi(j,0,n2+n3)
    		{
    			repi(k,0,n3)
    			{
    				dp[i][j][k]=-1.0;				
				}
			}
		}
		cout<<f(n1,n2,n3);
    } 
	return 0;
}

Measured memory_bytes: 425600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  bool flag=false;
  if(N/100==7){
    flag=true;
  }
  if((N%100)/10==7){
    flag=true;
  }
  if(N%10==7){
    flag=true;
  }
  if(flag==true){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {
	int m, d; cin >> m >> d;
	int cnt = 0;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			int da = j%10;
			int db = j/10;
			if(da>=2&&db>=2){
				if(da*db==i){
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};


void solve(){
	ll n,k;cin>>n>>k;
  vector<ll>A(n);
  vector<ll>F(n);
  rep(i,n)cin>>A[i];
  rep(i,n)cin>>F[i];
  sort(all(A));
  sort(all(F),greater<ll>());
  ll right=INF;
  ll left=-1;
  while(right-left>1){
    ll mid=left+(right-left)/2;
    ll num=0;
    rep(i,n){
      num+=max((ll)0,A[i]-mid/F[i]);
    }
    bool isOK=num<=k;
    if(!isOK)left=mid;
    else right=mid;
  }
  cout<<right<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


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

	cin >>h>>w;
	long long ans;
	if (h==1||w==1)ans=1;
	else if (h%2&&w%2)ans=h*w/2+1;
	else ans=h*w/2;
	cout << ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define max(a, b) ((a) < (b) ? (b) : (a))
using namespace std;
int n;
string s = "a";
void dfs(char a) {
    if (s.size() == n) {
        cout << s << endl;
        return;
    }
    for (char c = 'a'; c <= a + 1; c++) {
        s += c;
        dfs(max(c, a));
        s.erase(s.end() - 1);
    }
}
int main() {
    while (cin >> n) {
        dfs('a');
    }
    return 0;
}

Measured memory_bytes: 1536
n, m = map(int, input().split())
A = []; broken = [True] * n
for i in range(m):
    a = int(input())
    A.append(a)
    broken[a] = False 
dp = [0] * (n+1)
dp[0] = 1
mod = 10**9 + 7
for i in range(1, n+1):
    if broken[i-1] :
        dp[i] += dp[i-1]
    if i >= 2 and broken[i-2] :
        dp[i] += dp[i-2]
    dp[i] %= mod
print(dp[n])
    



Measured memory_bytes: 15416
#include <stdio.h>
int main(void){
    
    int n,m,a[50],b[50],c[50]={0},i,j;
    
    scanf("%d%d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
            if(a[i]==j+1){
                c[j]++;
                break;
            }
        }
        for(j=0;j<n;j++){
            if(b[i]==j+1){
                c[j]++;
                break;
            }
        }
    }
    
    for(i=0;i<n;i++) printf("%d\n",c[i]);
}

Measured memory_bytes: 1720
#include <iostream>

void check(int n){
    n = n - n/100;
    if(n % 10 == 0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}

int main()
{
    int n;
    std::cin >> n;
    check(n);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

int H, W, N;
vector<string> original_field;
vector<string> field;

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

inline bool in_field(int h, int w){
    return 0<=h&&h<H && 0<=w&&w<W;
}

bool vanish(){
    //?¶?????????????true?????????
    vector<vector<bool>> del_field(H, vector<bool>(W));
    
    bool updated = false;
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            if(field[h][w] == '.') continue;
            
            char color = field[h][w];
            for(int d=0; d<2; d++){
                int l = 1;
                while(in_field(h+dh[d]*l, w+dw[d]*l) && field[h+dh[d]*l][w+dw[d]*l] == color){
                    l++;
                }
                if(l < N) continue;
                
                for(int i=0; i<l; i++){
                    del_field[h+dh[d]*i][w+dw[d]*i] = true;
                    updated = true;
                }
            }
        }
    }
    
    if(updated)
        for(int h=0; h<H; h++)
            for(int w=0; w<W; w++)
                if(del_field[h][w])
                    field[h][w] = '.';
    
    return updated;
}

void down(){
    for(int w=0; w<W; w++){
        for(int h=H-1; h>=0; h--){
            if(field[h][w] == '.') continue;
            
            int hi = h+1;
            while(hi < H && field[hi][w] == '.') hi++;
            swap(field[--hi][w], field[h][w]);
        }
    }
}

bool check(){
    down();
    while(vanish())
        down();
    
    for(int h=0; h<H; h++)
        for(int w=0; w<W; w++)
            if(field[h][w] != '.')
                return false;
    
    return true;
}

string solve(){
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int nh = i, nw = j+1;
            if(!in_field(nh, nw)) continue;
            
            field = original_field;
            swap(field[i][j], field[nh][nw]);
            if(check())
                return "YES";
            
        }
    }
    return "NO";
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    
    cin>>H>>W>>N;
    original_field = vector<string>(H);
    for(string &r: original_field) cin >> r;
    
    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    string s;cin>>s;
    ll sum=0;
    for (int i = 0; i < s.size(); i++)
    {
        /* code */
        int a=s[i]-'0';
        sum+=a;
    }
    int n=stoi(s);
    if (n%sum==0)
    {
        /* code */
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
 

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009
#define gcd __gcd

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector <lli> ar(n);
	for(lli &x: ar) cin >> x;
	vector <lli> pre(n);
	vector <lli> suf(n);

	pre[0] = ar[0];
	for(int i=1; i<n; i++){
		pre[i] = gcd(pre[i-1], ar[i]);
	}

	suf[n-1] = ar[n-1];
	for(int i=n-2; i>=0; i--){
		suf[i] = gcd(suf[i+1], ar[i]);
	}

	lli res = suf[1];
	for(int i=1; i<n-1; i++){
		res = max(res, (lli)gcd(pre[i-1], suf[i+1]));
	}
	res = max(res, pre[n-2]);
	cout << res;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<vector<int>> C(3, vector<int>(3));
  for(int i=0;i<3;i++) {
    cin >> C.at(i).at(0) >> C.at(i).at(1) >> C.at(i).at(2);
  }
  
  string res = "No";
  for(int i=0; i<=100; i++){
    for(int j=0; j<=100; j++){
      for(int k=0; k<=100; k++){
        if(
            (C.at(0).at(0) - i == C.at(0).at(1) - j) && (C.at(0).at(1) - j == C.at(0).at(2) - k) &&
            (C.at(1).at(0) - i == C.at(1).at(1) - j) && (C.at(1).at(1) - j == C.at(1).at(2) - k) &&
            (C.at(2).at(0) - i == C.at(2).at(1) - j) && (C.at(2).at(1) - j == C.at(2).at(2) - k)
        ){
          res = "Yes";
        }
      }
    }
  }
  cout << res << endl;
  
}

Measured memory_bytes: 256