akhauriyash/Code-Regression huggingface dataset:
import sys
import math
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    H, A = map(int, readline().split())
    print(math.ceil(H/A))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
arrays = gets.split(' ')
i = 0
f = []
while i < arrays.size
  word = arrays[i].split('')
  f << word
  i += 1
end
# [["r", "n", "g"],
#  ["g", "o", "r", "i", "l", "l", "a"],
#  ["a", "p", "p", "l", "e"]]

if f[0][-1]==f[1][0] && f[1][-1]==f[2][0]
  puts "YES"
else
  puts "NO"
end

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

int main() {
  int r, D, x;
  scanf("%d%d%d", &r, &D, &x);

  for (int i = 0; i < 10; i++) {
    int weight = r * x - D;
    printf("%d\n", weight);
    x = weight;
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    n=int(input())
    s=[input() for _ in [0]*n]
    def check(a):
        for i in range(n):
            for j in range(i):
                if s[i%n][(j+a)%n]!=s[j%n][(i+a)%n]:
                    return 0
        return 1
    print(n*sum([check(i) for i in range(n)]))
main()

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

using namespace std;

struct Square {
    int h, w;
    bool operator<(const Square &r) const {
        if(h * h + w * w < r.h * r.h + r.w * r.w) {
            return true;
        } else if(h * h + w * w == r.h * r.h + r.w * r.w) {
            return h < r.h;
        } else {
            return false;
        }
    }
};

int main() {

    Square s, ans, temp;

    while(cin >> s.h >> s.w, s.h | s.w) {

        ans = (Square){1000, 1000};

        for(int i = 2; i <= 150; ++i) {
            for(int j = 1; j < i; ++j) {

                temp = (Square){j, i};

                if(s < temp && temp < ans) {
                    ans = temp;
                }

            }
        }

        cout << ans.h << " " << ans.w << endl;

    }

}

Measured memory_bytes: 1160
using System;

public class Test
{
	public static void Main()
	{
		int h=0,m=0,s=0;
		int a = int.Parse(Console.ReadLine());
		if(a>=3600){
			h=a/3600;
			a-=h*3600;
		}
		if(a>=60){
			m=a/60;
			a-=m*60;
		}
		s=a;
		Console.WriteLine("{0}:{1}:{2}",h,m,s);
	}
}

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

using namespace std;

int n;
vector<int> p;

bool check(int mid) {
	return (end(p) - lower_bound(begin(p), end(p), mid)) >= mid;
}

void hawawa()
{
	cin >> n;
	p.resize(n);
	for (auto&& i : p) {
		cin >> i;
	}
	sort(begin(p), end(p));
	int ok = 1, ng = 101;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (check(mid)) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	cout << ok << "\n";
}

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



Measured memory_bytes: 3188
import itertools

h, w, k = map(int, input().split())
s = [['0' for i in range(w)] for j in range(h)]

for i in range(h):
  s[i] = input()

cnt = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  cnt[i][0] = int(s[i][0]) + (0 if i == 0 else cnt[i - 1][0])

for i in range(w):
  cnt[0][i] = int(s[0][i]) + (0 if i == 0 else cnt[0][i - 1])

for i in range(1, h):
  for j in range(1, w):
    cnt[i][j] = cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1] + int(s[i][j])

num = [i for i in range(h - 1)]
ans = 99999
for i in range(0, h):
  for v in itertools.combinations(num, i):
    n = list(v)
    n.append(h - 1)
    
    _ans = i
    _left = -1
    for j in range(w):
      for _k in range(len(n)):
        if cnt[n[_k]][j] - (0 if _left < 0 else cnt[n[_k]][_left]) - (0 if _k == 0 else cnt[n[_k - 1]][j]) + (0 if _left < 0 or _k == 0 else cnt[n[_k - 1]][_left]) > k:
          if j - _left == 1:
            _ans = 99999
            break
          _left = j - 1
          j -= 1
          _ans += 1
          break
    ans = min(ans, _ans)

print(ans)

Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll n,k;cin>>n>>k;
    ll a[n];f(i,0,n)cin>>a[i];ll cnt=0;
    f(i,0,n-1){
        f(j,i+1,n){
            if(a[i]>a[j])cnt=(cnt%mod+((k%mod)*((k+1)%mod))/2)%mod;
        }
    }
   // cout<<cnt<<endl;
    for(ll i=n-1;i>=0;i--){
        for(ll j=i-1;j>=0;j--){
            if(a[i]>a[j])cnt=(cnt%mod+((k%mod)*((k-1)%mod))/2)%mod;
        }
    }
    cout<<cnt;
    return 0;
}   

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    int mi = INF;
    vi a(n);
    rep(i,n)cin >> a[i];
    int ans = 0;
    rep(i,n){
        if(a[i] < mi){
            ans++;
        }
        mi = min(mi,a[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;

class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            StringTokenizer st=new StringTokenizer(br.readLine());
            int h=Integer.parseInt(st.nextToken());
            int w=Integer.parseInt(st.nextToken());
            if(w==0&&h==0) break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(i!=0&&i!=h-1&&j!=0&&j!=w-1) System.out.print(".");
                    else System.out.print("#");
                }System.out.println();
            }System.out.println();
        }
    }
}

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

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

int c[50][50];
int w, h;

void dfs(int x, int y)
{
  if (x < 0 || y < 0 || w == x || h == y) return;
  if (c[x][y] == 0) return;
  c[x][y] = 0;
  for (int i = 0; i < 8; i++){
    dfs(x + dx[i], y + dy[i]);
  }
}

int main()
{
  while (cin >> w >> h, w){
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        cin >> c[j][i];
      }
    }

    int cnt = 0;
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        if (c[j][i] == 1){
          cnt++;
          dfs(j, i);
        }
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 3172
use proconio::input;

fn main() {
    input! {
        n: usize,
    }

    let ans = dfs(n, 0);
    println!("{}", ans);
}

fn is_753(n: usize) -> bool {
    let mut n = n;
    let mut has_7 = false;
    let mut has_5 = false;
    let mut has_3 = false;

    while n > 0 {
        let d = n % 10;
        n /= 10;

        match d {
            7 => { has_7 = true; },
            5 => { has_5 = true; },
            3 => { has_3 = true; },
            _ => {},
        }
        if has_7 && has_5 && has_3 {
            break;
        }
    }

    has_7 && has_5 && has_3
}

fn dfs(max:usize, num: usize) -> usize {
    if num > max {
        return 0;
    }
    let mut ret = if is_753(num) { 1 } else { 0 };
    let num = num * 10;
    ret += dfs(max, num + 3);
    ret += dfs(max, num + 5);
    ret += dfs(max, num + 7);
    ret
}


Measured memory_bytes: 2136
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



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

	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)
		cin >> a[i];
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (i % 2 == 0)
		{
			if (a[i] % 2 == 1)
				ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long int ll;
const int N=1e5+5,MAX=1e9+2;
int n,W,w[105],v[105],ans;
ll dp[105][N];
int main(){
    cin.tie(NULL);
    cout.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n>>W;
    for(int i=0;i<n;i++)
        cin>>w[i]>>v[i];
    memset(dp,-1,sizeof dp);
    dp[0][0]=0; dp[0][v[0]]=w[0]; ans=v[0];
    for(int i=1;i<n;i++){
        for(int j=0;j<N;j++){
            if(~dp[i-1][j] && dp[i-1][j]+w[i]<=W){
                if(dp[i][j+v[i]]==-1) dp[i][j+v[i]] = MAX;
                dp[i][j+v[i]]= min(dp[i-1][j]+w[i],dp[i][j+v[i]]);
                ans=max(ans,j+v[i]);
            }
            if(~dp[i-1][j])
                dp[i][j]=min(dp[i-1][j],dp[i][j]);
            if(dp[i][j]==-1&&~dp[i-1][j]) dp[i][j]=dp[i-1][j];
        }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 82304
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

	int N;
	cin >> N;
	vector<double> A(N), B(N);
	rep(i,N) cin >> A[i] >> B[i];

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	int num;
	if(N%2==1){
		int range = B[N/2] - A[N/2];
		num = range;
	}else{
		double meanB = (B[(N-1)/2] + B[(N-1)/2+1])/2;
		double meanA = (A[(N-1)/2] + A[(N-1)/2+1])/2;
		double range = meanB - meanA;
		num = range/0.5;
	}

	cout << num+1 << endl;
}


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

int main(){
  string s,t;
  cin >>s >>t;
  string t1;
  rep(i,t.size()-1) t1 += t[i];
  if(s==t1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define int long long
int n, s;

int sum(int x){
    int tmp = n, ans = 0;
    while(tmp){
        ans += tmp % x;
        tmp /= x;
    }
    return ans;
}

signed main(){
    cin >> n >> s;
    for(int i = 2; i * i <= n; i++){
        if(sum(i) == s){
            cout << i;
            return 0;
        }
    }
    for(int i = sqrt(n) - 1; i >= 1; i--){
        if(s < i) continue;
        int tmp = n - (s - i);
        if((tmp % i) != 0) continue;
        if((tmp / i) <= (s - i)) continue;
        if((tmp / i) == 1) continue;
        //cout << tmp << " " << i << endl;
        cout << tmp / i;
        return 0;
    }
    if(s == 1){
        if(n == 1) cout << 2;
        else cout << n;
        return 0;
    }
    if(s == n){
        cout << n + 1;
        return 0;
    }
    cout << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
   
  if(e-a<k+1){
   	cout << "Yay!" << endl; 
  }
  else{
    cout << ":(" << endl; 
  }   
}

Measured memory_bytes: 256
from itertools import combinations
import numpy as np
h, w, k = map(int, input().split())
cnt = 0
mass = []
for _ in range(h):
    s = list(str(input()))
    mass.append(s)
    
mass = np.array(mass)
for i in range(h+1):
    row_list = list(combinations(range(h), i))
    for j in range(w+1):
        col_list = list(combinations(range(w), j))
        for r_choice in row_list:
            for c_choice in col_list:
                tmp_mass = mass.copy()
                tmp_mass[list(r_choice), :] = "r"
                tmp_mass[:, list(c_choice)] = "r"
                if (tmp_mass == "#").sum() == k:
                    cnt += 1
      
print(cnt)

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

namespace TaskSchedulingProblem
{
    class Program
    {
        static void Main(string[] args)
        {
            //入力
            String[] s = Console.ReadLine().Split();
            int[] a = new int[3];
            for(int i = 0; i<3; i++){
                a[i] = int.Parse(s[i]);
            }

            int an = a.Max()-a.Min();

            Console.WriteLine(an.ToString());
        }
    }
}


Measured memory_bytes: 13268
!!!**********************************************************************
program main
!!!**********************************************************************  

  integer   :: n, d, x, i, max, max2, flag
  integer, allocatable, dimension ( : ) :: a, b
  ! real      ::
  ! character ::
  
!!!----------------------------------------------------------------------

  read ( unit = *, fmt = * ) n

  allocate ( a ( 1:n ) )
  allocate ( b ( 1:n ) )  

  do i = 1, n

     read ( *, * ) a ( i )
     
  end do

  b ( : ) = a ( : )

  max  = maxval ( a )

  do i = 1, n

     if ( b ( i ) == max ) then

        b ( i ) = 0
        
     end if
     
  end do
 
  max2  = maxval ( b )

  flag = 0

  do i = 1, n       
  
  if ( a ( i ) == max ) then

     flag = flag + 1

  end if

end do

  
  
  do i = 1, n

     if ( a ( i ) == max .and. flag == 1 ) then

        print "(i0)", max2
        
     else 

        print "(i0)", max
        
     end if

  end do

 !!**********************************************************************  
end program main
!!!**********************************************************************


Measured memory_bytes: 3200
#include<stdio.h>
#define rep(i,n) for(i=0;i<n;i++)
int min(int a,int b){return a<b?a:b;}
int main(void)
{
  int n,m,mat[20][20],i,j,k,a,b,c,d;
  scanf("%d%d",&n,&m);
  rep(i,n)rep(j,n)mat[i][j]=i-j?1<<21:0;
  rep(i,m){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);a--,b--;
    mat[a][b]=c;mat[b][a]=d;
  }
  rep(i,n)rep(j,n)rep(k,n)mat[j][k]=min(mat[j][k],mat[j][i]+mat[i][k]);
  scanf("%d,%d,%d,%d",&a,&b,&c,&d);a--,b--;
  printf("%d\n",c-mat[a][b]-mat[b][a]-d);
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <map>

using namespace std;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    map<int, int> m;
    x--;
    y--;
    int thre1 = x + (y - x) / 2 + 1;
    int thre2 = x + (y - x) / 2;
    for(int i=0; i < n; i++) {
        for(int j=i+1; j < n; j++) {
            int k = min(j - i, abs(i - x) + abs(j - y) + 1);
            m[k]++;
        }
    }
    for (int i=1; i<n; i++) {
        cout << m[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int A = sc.NextInt();
        int B = sc.NextInt();
        int C = sc.NextInt();
        int K = sc.NextInt();
        long max = Math.Max(Math.Max(A, B), C);
        long others = A + B + C - max;
        max <<= K;
        Console.WriteLine(others + max);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define vlll vector<vll>
int main()
{
    Imposter
    
    int t=1;
    //cin>>t;
    while(t--)
    {
       
       ll n;
       cin>>n;
       ll ans=1000-n%1000;
       cout<<ans%1000<<endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define MAX 1005
#define INF 1000000007
 
int N;
int A[MAX],B[MAX];
int dp[MAX][MAX];
 
int main(){
 
  scanf("%d",&N);
 
  vector<P> t;
  for(int i=0;i<N;i++){
    scanf("%d %d",&A[i],&B[i]);
    t.push_back( P(B[i],i) );
  }
  sort(t.begin(),t.end());
 
  for(int i=0;i<MAX;i++)
    for(int j=0;j<MAX;j++)
      dp[i][j]=INF;
 
  dp[0][0]=0;
 
  int ans=0;
 
  for(int i=1;i<=N;i++){
 
    int id=t[i-1].second;
 
    for(int j=0;j<=N;j++){
      dp[i][j]=dp[i-1][j];
 
      if(j>0){
        int f=dp[i-1][j-1];
 
        if(f<=B[id]-A[id]){
 
          dp[i][j]=min(dp[i][j],f+A[id]);
 
        }
      }
       
      if(dp[i][j]!=INF){
        ans=max(ans,j);
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 7160
function Main(input) {
    fins = [];
    miss = [];
    right = 0;
    left = 0;
    input = input.split("\n");
    a = input[0].split(" ");
    N = Number(a[0]);
    M = Number(a[1]);
    input.shift();
    for(var i = 0;i <= N; i++){
        fins.push(0);
        miss.push(0);
    }
    for(var j = 0;j < M; j++){
        target = input[j].split(" ");
        N = target[0];
        result = target[1];
        if(fins[N] === 1) continue;
        if(result === "WA"){
            miss[N]++;
        }
        else{
            left += miss[N];
            right++;
            fins[N] = 1;
        }
    }
    console.log(right,left);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29112
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N,C,K; cin >> N >> C >> K;
    vector<ll> T(N);
    for(auto& in:T)cin >> in;
    sort(T.begin(),T.end());
    ll l,r;
    l = r = 0;
    ll cnt = 0;
    ll res = 0;
    while(true){
        if(r == N)break;
//        cout << r << " " << l << endl;
        if(l == r){
            cnt++;
            if(cnt == C){
                cnt = 0;
                res++;
                l = r + 1;
            }
            r++;
            continue;
        }
        if(T[r] - T[l] <= K){
            cnt++;
            if(cnt == C){
                res++;
                cnt = 0;
                l = r + 1;
            }
            r++;
        }else{
            res++;
            l = r;
            cnt = 0;
        }
    }
    if(l != r) res++;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
s = gets.chomp
t = gets.chomp
k = s.length - t.length + 1
i = 0
flag = false
while i < k && !flag
	cp = s.clone
	cp[cp.length-t.length-i,t.length] = t
	check = true
	(cp.length).times do |j|
		check = false if s[j] != cp[j] && s[j] != "?"
	end
	flag = true if check
	i += 1
end
if flag
	(cp.length).times do |j|
		cp[j] = "a" if cp[j] == "?"
	end
	puts cp
else
	puts "UNRESTORABLE"
end


Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

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


unsigned GetDigit(long long num){
    unsigned digit = 0;
    while(num != 0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){

  ll N;
  cin >> N;
  ll ans = 0;
  int digit;

  digit = GetDigit(N);

  if(digit == 1){
    cout << N << endl;
    return 0;
  }

  // 199のような場合を求める
  string num = to_string(N);
  bool flag = false;
  for (int i = 1; i < num.size(); i++) {
    if(num[i] == '9'){
      flag = true;
    }else{
      flag = false;
      break;
    }
  }

  if(flag == true){ // 199のような9で詰まる場合は全て足す
    for (int i = 0; i < num.size(); i++) {
      int ni = (int)(num[i]-'0');
      ans += ni;
    }
  }else{ // そうじゃない場合は先頭の桁を切り下げた数値と以下9を足す
    for (int i = 0; i < num.size(); i++) {
      int ni;
      if(i == 0){
        ni = (int)(num[i]-'0') -1;
      } else {
        ni = 9;
      }
      ans += ni;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3648
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll A;
    double b;
    cin >> A >> b;
    ll B = b * 100.0 + 0.1;
    cout << A * B/100;
    return 0;
}

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

using namespace std;

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

  long long min_id = 10000000;
  long long max_id = 0;
  for (int i = 0; i < M; ++i) {
    long long l, r;
    cin >> l >> r;
    min_id = min(r, min_id);
    max_id = max(l, max_id);
  }

  if (min_id - max_id + 1 > 0)
    cout << min_id - max_id + 1 << endl;
  else
    cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        using ll = long long;
         
        int main() {
        	ll n, total = 0;
          	cin >> n;
          	vector<ll> v(n), c(n);
          	for(int i = 0; i < n; i++) cin >> v[i];
          	for(int i = 0; i < n; i++) cin >> c[i];
          	for(int i = 0; i < n; i++) total += max(0ll, v[i] - c[i]);
          	cout << total << endl;
        	return 0;
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main()
{
    int ans=0;
    string S,x="CODEFESTIVAL2016";
    cin>>S;

    for(int i=0;i<16;i++){
        if(S[i]!=x[i])ans++;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=[int(input())for i in range(n)]
a.sort()
c=0
p=sum(a)
if p%10!=0:
    print(p)
else:
    for i in range(n):
        if a[i]%10!=0:
            break
        else:
            c+=1
    print(0 if c==n else p-a[i])

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

#define eb emplace_back
#define INF 1LL<<62
#define FLT_INF pow(10.0, 16)

using ll = long long;
using vll = vector<ll>;
using ull = unsigned long long;
using int2 = pair<int, int>;

template <typename A> string to_string(const A& v);
string to_string(const string& s) { return '"'+ s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(const pair<A, B>& p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A> string to_string(const A& v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename T>
void sort(vector<T>& val) {
  sort(val.begin(), val.end());
}

template <typename T>
void sort_b(vector<T>& val) {
  sort(val.begin(), val.end(), greater<T>());
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

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

#define COMMON_MOD 998244353
#define PI 3.14159265

// sort(a.begin(), a.end(), less<ll>()); greater<ll>()
// cout<<fixed<<setprecision(20)<<(s/kl)*2;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n, k;
  cin >> n >> k;

  cout << (n - k + 1);

  cout << endl;
  return 0;
}


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

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  5e5+5;
const ll   mod   =  1e9+7;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n, m, f[N];

ll fastmod(ll x, ll y = mod-2){
    ll res = 1;
    while(y){
        if(y&1) res = (res*x)%mod;
        x = (x*x)%mod;
        y /= 2;
    }
    return res;
}

ll ncr(ll n, ll r){
    return f[n] * fastmod(f[r]) % mod * fastmod(f[n-r]) % mod;
}

void solve(){
    f[0] = 1;
    for(int i = 1; i < N; i++) f[i] = (f[i-1]*i)%mod;
    cin>>m>>n;
    ll ans = 0;
    for(int i = 0; i <= m; i++){
        ll x = ncr(n-i,m-i), y = ncr(m,i), z = ncr(n,i);
        if(i%2 == 0) ans += f[m-i]*f[m-i]%mod *x %mod *x %mod *y %mod *z %mod *f[i] %mod;
        else ans -= -mod + f[m-i]*f[m-i]%mod *x %mod *x %mod *y %mod *z %mod *f[i] %mod;
        ans %= mod;
    }
    deb1(ans)
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }
}

Measured memory_bytes: 7516
#include <stdio.h>
int main(void){
    long int n,m,i,j,k,sum,tmp,maxn=-100000000000;
    scanf("%ld%ld",&n,&m);
    long int cake[n][3];
    for(i=0;i<n;i++){
        for(j=0;j<3;j++)
            scanf("%ld",&cake[i][j]);
    }
    for(i=0;i<8;i++){
        long int list[n];
        for(j=0;j<n;j++){
            sum=0;
            for(k=0;k<3;k++){
                if(i&(1<<k)) sum+=cake[j][k];
                else sum-=cake[j][k];
            }
            list[j]=sum;
        }
        for(j=0;j<n;j++){
            for(k=j+1;k<n;k++){
                if(list[j]<list[k]){
                    tmp=list[j];
                    list[j]=list[k];
                    list[k]=tmp;
                }
            }
        }
        sum=0;
        for(j=0;j<m;j++)
            sum+=list[j];
        if(maxn<sum) maxn=sum;
    }
    printf("%ld\n",maxn);
    return 0;
}

Measured memory_bytes: 128
import numpy as np

n = int(input())
W = np.array(list(map(int, input().split())))
cumsum = np.cumsum(W)

ans = abs(2*cumsum[0] - cumsum[n-1])

for i in range(1, n):
    diff = abs(2*cumsum[i] - cumsum[n-1])
    ans = min(ans, diff)

print(ans)

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

int main() {
  int n;
  cin>>n;
  long long a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  int s = 0;
  int e = 0;
  long long sum = 0;
  long long tmp_xor = 0;
  long long ans = 0;
  while (e < n) {
    if (sum + a[e] != (tmp_xor ^ a[e])) {
      sum -= a[s];
      tmp_xor ^= a[s];
      ++s;
      if (s > e) {
        ++e;
      }
    } else {
      sum += a[e];
      tmp_xor ^= a[e];
      ans += e - s + 1;
      ++e;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;

class Main {
	MScanner sc;
	int N;
	long K;
	int[] n, p;
	int nlen, plen;
	
	private void calc() {
		sc = new MScanner();
		N = sc.nextInt();
		K = sc.nextLong();
		List<Integer> ne = new ArrayList<>();
		List<Integer> po = new ArrayList<>();
		
		for (int i = 0; i < N; i++) {
			int a = sc.nextInt();
			if (a < 0) ne.add(a);
			else po.add(a);
		}
		nlen = ne.size();
		plen = po.size();
		n = new int[nlen];
		for (int i = 0; i < nlen; i++) n[i] = -ne.get(i);
		p = new int[plen];
		for (int i = 0; i < plen; i++) p[i] = po.get(i);
		Arrays.sort(n);
		Arrays.sort(p);
		
		long l = Long.MIN_VALUE / 2;
		long r = Long.MAX_VALUE / 2;

		while (l <= r) {
			long m = (l + r) >> 1;
			long[] mv = count(m);
			if (mv[0] < K) l = m + 1;
			else if (mv[0] > K) r = m - 1;
			else {
				System.out.println(mv[1]);
				return;
			}
		}
		System.out.println( l );
	}
	
	private long[] count(long t) {
		long s = 0;
		long max = Long.MIN_VALUE;
		if (t < 0) {
			int nr = nlen - 1;
			int pl = 0;
			for (; nr >= 0; nr--) {
				for (; pl < plen; pl++) {
					if ((long)n[nr]*p[pl] >= -t) break;
				}
				if (pl < plen) {
					s += plen - pl;
					max = Math.max(max, (long)-n[nr]*p[pl]);
				} else break;
			}
			return new long[] {s, max};
		} else {
			s = (long)nlen * plen;
			int nl = 0;
			int nr = nlen - 1;
			for (; nl < nlen; nl++) {
				for (; nr > nl; nr--) {
					if ((long)n[nl]*n[nr] <= t) break;
				}
				if (nr > nl) {
					s += nr - nl;
					max = Math.max(max, (long)n[nl]*n[nr]);
				} else break;
			}
			int pl = 0;
			int pr = plen - 1;
			for (; pl < plen; pl++) {
				for (; pr > pl; pr--) {
					if ((long)p[pl]*p[pr] <= t) break;
				}
				if (pr > pl) {
					s += pr - pl;
					max = Math.max(max, (long)p[pl]*p[pr]);
				} else break;
			}
			return new long[] {s, max};
		}

	}
	static class MScanner {
		BufferedReader br;
		String[] tokens;
		int cursor;
		
		MScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		String next() { return fetch(); }
		int nextInt() { return Integer.parseInt(fetch()); }
		long nextLong() { return Long.parseLong(fetch()); }
		double nextDouble() { return Double.parseDouble(fetch()); }
		
		String fetch() {
			if (tokens == null || cursor >= tokens.length) readNext();
			String r = tokens[cursor++];
			return r;
		}

		void readNext() {
			try {
				String line = br.readLine();
				if (line == null || line.equals("")) br.close();
				else {
					tokens = line.split(" ");
					cursor = 0;
				}
			} catch (IOException ioe) {
				throw new RuntimeException(ioe);
			}
		}

		public void finalize() throws Exception {
			if (br != null) br.close();
		}
	}
	public static void main(String[] args) {
		new Main().calc();
	}
}
	


Measured memory_bytes: 63368
function Main(input) {
	input = input.trim().split(" ").map((a)=>Number(a));
  var A = input[0];
  var B = input[1];
  var C = input[2];
  if((A+B==C) || (A+C==B) || (B+C==A)){
     console.log("Yes");
     }else{
     console.log("No");
     }
}

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


Measured memory_bytes: 9420
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;
int g[300][300],n,dis[300][300];
char s[300];
int col[300];
bool dfs(int now) {
    //cout<<now<<endl;
    for(int i=1;i<=n;i++) {
        if(g[now][i]) {
            if(col[i]==col[now])return 1;
        }
    }
    for(int i=1;i<=n;i++) {
        if(col[i]>=0)continue;
        if(g[now][i]) {
           col[i]=col[now]^1;
           if(dfs(i))return 1;
        }

    }
    return 0;
}
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) {
        scanf("%s",s+1);
        for(int j=1;j<=n;j++) {
            if(s[j]=='1')g[i][j]=1,dis[i][j]=1;
            else dis[i][j]=1e9+100;
        }
    }
    for(int i=1;i<=n;i++)col[i]=-1;
    col[1]=1;

    if(dfs(1)) {
        printf("-1");
        return 0;
    }
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }
    int ma=0;
    for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)ma=max(ma,dis[i][j]);
    printf("%d",ma+1);
    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

#define N 5
int main(void){
    int a[N], tmp;
   
    for (int i=0; i<N; i++) scanf("%d", &a[i]);
    for (int i=N-1; i>0; i--){
        for (int j=0; j<i; j++){
            if (a[j] < a[j+1]){
                tmp = a[j];
                a[j] = a[j+1];
                a[j+1] = tmp;
            }
 	}
    }
    for (int i=0; i<N-1; i++) printf("%d ", a[i]);
    printf("%d\n", a[N-1]);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template <typename T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int SET(int N, int pos)  {return N=N | (1<<pos);}
int RSET(int N,int pos)  {return N= N & ~(1<<pos);}
bool CHK(int N,int pos)  {return (bool)(N & (1<<pos));}

#define ll             long long
#define pll            pair<ll,ll>
#define unique(a)      a.resize(unique(a.begin(), a.end()) - a.begin())
#define fill(v, p)     memset(v,p,sizeof v)
#define all(x)         x.begin(), x.end()
#define index(x,i)     x.find_by_order(i)
#define lesscount(x,i) x.order_of_key(i)
#define PI             acos(-1.0)
#define EPS            0.000000001
#define INF            1e18+10
#define MAX            300005
#define MOD            1000000007


signed int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(0);
	
	ll n, yes=1;
	cin >> n;
	
	for(int i=0;i<n;i++)
	{
		ll x;
		cin >> x;
		
		if(x%2==0)
		{
			if(x%3 == 0) continue;
			if(x%5 == 0) continue;
			else
			{
				yes=0;
			}
		}
	}
	
	if(yes) cout << "APPROVED\n";
	else cout << "DENIED\n";
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k;
  string s;
  cin>>n>>k>>s;
  for(int i =0;i<n;i++)
    cin >> s[i];
  k=k-1;
  s[k]=s[k]+0x20;
  cout << s <<endl;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

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

	int x, y; cin >> x >> y;

	if(y >= 2*x && (y-2*x)%2 == 0){
		int b = (y-2*x)/2;
		int a = x-b;
		if(a>=0 && b >=0){
			cout << "Yes\n";
		}else
			cout << "No\n";
	}else{
		cout << "No\n";
	}
	
	return 0;
}


Measured memory_bytes: 3636
K = int(input())

mylist = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(mylist[K-1])

Measured memory_bytes: 3060
while True:
    lista = input().split()
    a = int(lista[0])
    b = int(lista[2])
    op = lista[1]
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        break


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
const lint mod = 1e9 + 7;

int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    lint a[n];
    lint sum = 0;
    rep(i, n){
        scanf("%lld", &a[i]);
        sum += a[i];
    }
    vector<lint> d;
    for(int i=1; i*i<=sum; ++i){
        if(sum % (lint)i == 0){
            d.push_back((lint)i);
            if(i*i != sum) d.push_back(sum / (lint)i);
        }
    }
    lint ans = 1;
    for(lint x: d){
        lint num[n];
        rep(i, n) num[i] = a[i] % x;
        sort(num, num+n);
        int l = 0;
        int r = n-1;
        lint cnt = 0;
        while(l < r){
            lint s = num[l];
            lint t = x - num[r];
            if(s < t){
                num[r] += s;
                cnt += s;
                ++l;
            }
            else{
                num[l] -= t;
                cnt += t;
                --r;
            }
        }
        if(cnt <= k) ans = max(ans, x);
    }
    printf("%lld\n", ans);
}

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

int main()
{
  int A, B, M;

  cin >> A >> B >> M;

  vector<int> a(A);
  vector<int> b(B);
  vector<vector<int>> discount(M, vector<int>(3));

  vector<int> sum(M);

  for (int i = 0; i < A; i++)
  {
    cin >> a.at(i);
  }

  for (int i = 0; i < B; i++)
  {
    cin >> b.at(i);
  }

  for (int i = 0; i < M; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> discount.at(i).at(j);
    }
  }

  int _sum = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());

  int minSum = 100000000;

  for (int i = 0; i < M; i++)
  {
    sum.at(i) = a.at(discount.at(i).at(0) - 1) + b.at(discount.at(i).at(1) - 1) - discount.at(i).at(2);
    if (minSum > sum.at(i))
    {
      minSum = sum.at(i);
    }
  }

  if (minSum < _sum)
  {
    cout << minSum << endl;
  }
  else
  {
    cout << _sum << endl;
  }
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll max(ll x,ll y)
{
	if(x>y)
		return x;
	else
		return y;
}
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll a1=a*c;
	ll a2=a*d;
	ll a3=b*c;
	ll a4=b*d;
	ll x1=max(a1,a2);
	ll x2=max(a3,a4);
	ll ans=max(x1,x2);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
def main():
    n, m = [int(i) for i in input().split()]
    a = [int(i) for i in input().split()]
    
    bc = []
    for _ in range(m):
        b, c = map(int, input().split())
        bc.append((b, c))

    total = 0
    for num, v in sorted(bc, key=lambda x: -x[1]):
        total += num
        a.extend([v]*num)
        if total >= n:
            break
    print(sum(sorted(a)[-n:]))

if __name__ == '__main__':
    main()



Measured memory_bytes: 26516
import java.util.*;
public class Main {
    public static void main(String[] args){
       Scanner scan = new Scanner(System.in);
       int n = scan.nextInt();
       int k = scan.nextInt();
       if(k!=1) {
           System.out.println(n - k);
       }else{
           System.out.println(0);
       }
    }
}


Measured memory_bytes: 22740
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>

using namespace std;

#define  GODSPEED       ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(15);
#define  f              first                 
#define  s              second
#define  newl           cout<<"\n";
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<"\n";
#define  deb2(a,b)      cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());
#define  all(a)         a.begin(),a.end()           
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const int  N     =  5e5+5;
const int  mod   =  998244353;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const int  LEVEL =  log2(N)+1;

ll n, k, l[11], r[11], dp[N], pre[N];

void solve(){
	dp[1] = 1, pre[1] = 1;
	cin >> n >> k;
	for(int i = 1; i <= k; i++){
		cin >> l[i] >> r[i];
	}
	for(int i = 2; i <= n; i++){
		for(int j = 1; j <= k; j++){
			if(i <= l[j]) continue;
			dp[i] += (pre[i-l[j]] - pre[max(1ll, i - r[j]) - 1] + mod);
			dp[i] %= mod;
		}
		pre[i] = (pre[i-1] + dp[i]) % mod;
	}
	deb1(dp[n])
}

int main(){
	GODSPEED;
	int test = 1;
	//cin >> test;
	for(int i = 1; i <= test; i++){
		solve();
	}
	#ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}

Measured memory_bytes: 6788
#include<vector>
#include<queue>
#include<functional>
#include<algorithm>
#include<set>
#include<iostream>

using namespace std;

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

const int MX = 1<<19;
const int MM = 1000000007;

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if( a <= 0 && 0 <= b ) return !printf("Zero\n");
	else if( b < 0 && (b-a+1)%2 == 1 ) return !printf("Negative\n");
	else printf("Positive\n");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <map>
#include <utility>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define MOD 10000000000　+　7    //10億　= 10^9になってる
#define juu 100000               //10万 10e5
#define hyaku 1000000            //100万　10e6
#define mINF -922337200085470000 //llのmax-1桁の小さい方
#define pINF 922337203600070000  //llのmax-1桁のデカい方
#define uINF 1844674407300000000 //ullのmax-1桁してる
#define pi 3.1415926535897932384
ll factor[300];
ll memory[300];
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num)
{
    int i = 0, kosuu = 0;
    while (*(factor + i) != 0)
    {
        while (num % *(factor + i) == 0)
        {
            num /= *(factor + i);
            memory[*(factor + i)] += 1;
        }
        if (num == 1)
            break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろforは<*/
int elast(ll number)
{
    ll tmp = 0;
    int flag = 0;
    *factor = 2;
    for (int i = 3; i <= number; i++)
    {
        flag = 0;
        for (int j = 0; j <= tmp; j++)
        {
            if (i % (*(factor + j)) == 0)
            {
                flag = 1;
                break;
            }
        }
        if (flag)
            continue;
        tmp += 1;
        *(factor + tmp) = i;
    }
    return tmp + 2;
}
/*整数をqsortする為だけのもの*/
long long compare(const long long *a, const long long *b)
{
    if (*a < *b)
        return -1;
    else if (*a > *b)
        return 1;
    return 0;
}
/*intで収まる範囲であってくれ*/
ll nCr(int n, int r)
{
    ll val = 1;
    int i;
    if (r == 0)
        return 1;
    for (i = 0; i < n - r; i++)
    {
        val *= (n - i);
        val /= (i + 1);
    }
    return val;
}
/*intで収まる範囲であってくれ*/
ll nPr(int n, int r)
{
    ll val = 1;
    int i;
    for (i = 0; i < r; i++)
    {
        val *= (n - i);
    }
    return val;
}

void chmin(ll &a, ll b)
{
    if (a > b)
        a = b;
}
void chmax(ll &a, ll b)
{
    if (a < b)
        a = b;
}

/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これをコピペ
*/
/*bool cmp( string& a, string& b){
    return a < b;
}*/
int main()
{
    ll L, N;
    vector<string> mozi;

    cin >> N >> L;
    mozi.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> mozi[i];
    }
    sort(mozi.begin(), mozi.end());
    for (int j = 1; j < N; j++)
    {
        mozi[0] = mozi[0] + mozi[j];
    }
    cout << mozi[0];
    return 0;
}



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

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vi prefblack(n+1);
    for (int i=0; i<n; ++i)
        prefblack[i+1] = prefblack[i] + (s[i] == '#');
    vi suffwhite(n+1);
    for (int i=n-1; i>=0; --i)
        suffwhite[i] = suffwhite[i+1] + (s[i] == '.');
    int minres = INT_MAX;
    for (int i=0; i<=n; ++i)
        minres = min(minres, prefblack[i] + suffwhite[i]);
    cout << minres << endl;
}


Measured memory_bytes: 2196