akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [h, w] <- getIntList
  ss <- VB.replicateM h BS.getLine

  let getPos y x | y < 0 || y >= h || x < 0 || x >= w = 'X'
                 | otherwise = (ss VB.! y) `BS.index` x

  arr <- IO.newArray ((0,0),(h-1,w-1)) 0 :: IO (IO.IOUArray (Int, Int) Int)

  let dfs :: Int -> Int -> IO (Int, Int)
      dfs y x
        = do t <- IO.readArray arr (y, x)
             if t > 0
               then return (0, 0)
               else do IO.writeArray arr (y, x) 1
                       let c = getPos y x
                           ds :: [(Int, Int)]
                           ds = [(-1, 0), (1, 0), (0, -1), (0, 1)]
                       wbs <- forM ds $ \(dy, dx) -> do
                         let c' = getPos (y+dy) (x+dx)
                         if c' == 'X' || c == c'
                           then return (0, 0)
                           else dfs (y+dy) (x+dx)
                       let (w, b) =
                             foldr (\(a, b) (c, d) -> (a+c, b+d)) (0, 0) wbs
                           w' = w + if c == '.' then 1 else 0
                           b' = b + if c == '#' then 1 else 0
                       return (w', b')

      solve :: Int -> Int -> Int -> IO Int
      solve y x res | y >= h    = return res
                    | x == w    = solve (y+1) 0 res
                    | otherwise = do (w, b) <- dfs y x
                                     solve y (x+1) (res + w*b)

  ans <- solve 0 0 0
  print ans

Measured memory_bytes: 131452
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int n, y;
  cin >> n >> y;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i + j > n) continue;
      int k = n - i - j;
      if (i * 10000 + j * 5000 + k * 1000 == y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int):
    ans = 0
    for i in range(1, N+1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i
    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

const int maxn = 2e5 + 10;
vector<int> g[maxn];
int v[maxn];
int ans[maxn];
void dfs(int x, int p, int s) {
  s += v[x];
  ans[x] = s;
  for (int y : g[x]) if (y != p) {
    dfs(y, x, s);
  }
}

int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 0; i < q; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a] += b;
  }
  dfs(1, 1, 0);
  for (int i = 1; i <= n; ++i)
    printf("%d%c", ans[i], " \n"[i == n]);
  return 0;
}



Measured memory_bytes: 24064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;

class UnionFind {
	vector<int>parent;
	vector<int>rank;
public:
	UnionFind(int num) {
		num++;
		parent.resize(num);
		rank.resize(num);
		for (int i = 0; i < num; i++) {
			parent[i] = i;
			rank[i] = 0;
		}
	}
	int Find(int node) {
		if (parent[node] == node)return node;
		else return parent[node] = Find(parent[node]);
	}
	void Unite(int u, int v) {
		u = Find(u);
		v = Find(v);
		if (u == v)return;
		if (rank[u] < rank[v])parent[u] = v;
		else {
			parent[v] = u;
			if (rank[u] == rank[v])rank[u]++;
		}
	}
	bool Check_Same(int u, int v) {
		return Find(u) == Find(v);
	}
};

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

void Search(vector<vector<int>>&edge, vector<int>&depth, int node, vector<int>&dir, vector<pair<int, int>>&ans) {
	for (auto i : edge[node]) {
		if (depth[i] > depth[node])Search(edge, depth, i, dir, ans);
	}
	for (auto i : edge[node]) {
		if (depth[i] < depth[node]) {
			if (dir[node] & 1) {
				ans.push_back({ node,i });
			}
			else {
				ans.push_back({ i,node });
				dir[i]++;
			}
		}
	}
	return;
}

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

	cin >> N >> M;
	if (M & 1) {
		cout << -1 << endl;
		return 0;
	}
	vector<int>dir(N);
	vector<vector<int>>edge(N);
	UnionFind uf(N);
	vector<pair<int, int>>ans;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		L--;
		R--;
		if (uf.Check_Same(L, R)) {
			ans.push_back({ L,R });
			dir[L]++;
		}
		else {
			uf.Unite(L, R);
			edge[L].push_back(R);
			edge[R].push_back(L);
		}
	}
	vector<int>depth(N, MOD);
	Calculate_Depth(edge, depth, 0);
	Search(edge, depth, 0, dir, ans);
	for (auto i : ans)cout << i.first + 1 << " " << i.second + 1 << endl;
}

Measured memory_bytes: 18676
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <fstream>

using namespace std;

int main(void)
{
	string s;

	cin >> s;

	cout << s[0] << s.length() - 2 << s[s.length() - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
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;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,a[100010],ans[100010];
P p[100010];
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        p[i]={a[i],i};
    }
    sort(p,p+n,greater<>());
    p[n]={0,0};
    int mi=INF;
    rep(i,n){
        chmin(mi,p[i].se);
        ans[mi]+=(i+1)*(p[i].fi-p[i+1].fi);
    }
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 5120
import java.math.BigDecimal;
import java.util.*;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.nextLine();
        int n = Integer.parseInt(s.split(" ")[0]);
        int a = Integer.parseInt(s.split(" ")[1]);
        int b = Integer.parseInt(s.split(" ")[2]);

        if(n * a < b){
            System.out.println(n * a);
        } else {
            System.out.println(b);
        }


        return;
    }
}


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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

double dis(int x, int y) {
    return sqrt(1ll * x * x + 1ll * y * y);
}

void solve() {
    int n, d, x, y, res = 0;
    cin >> n >> d;
    for (int i = 1; i <= n; i++) {
        cin >> x >> y;
        if (ceil(dis(x, y)) <= d) res++;
    }
    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  int left, right;

  cin >> left;
  for (int i = 1; i < n; i++) {
    cin >> right;
    if (left <= right) {
      if (left < right) {
        right--;
      }
    } else {
      cout << "No" << endl;
      return 0;
    }

    left = right;
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 256
num = int(input())
a_list = list(map(int, input().split(" ")))
ans_list = [0] * num

for i in range(num):
    ans_list[a_list[i]-1] = i+1

for i in range(num-1):
    print(ans_list[i], end=" ")
print(ans_list[num-1])

Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
int a,b;
cin >> a >> b;
if((a+b)%2==0){
    cout << (a+b)/2 << endl;
}else{
    cout << "IMPOSSIBLE" << endl;
}
return 0;
}

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

int main() {
	int a, b;

	for (a = 1; a <= 9; a++) {
		for (b = 1; b <= 9; b++) {
			cout << a << "x" << b << "=" << a*b << endl;

		}
	}
	return 0;
}

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

#define testcases int t; cin>>t; while(t--)
#define int long long
const int MOD =  1e9 + 7;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int32_t main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	FASTIO;

	int n, m, k;
	cin >> n >> m >> k;

	vector<int> a(n + 1);
	vector<int> b(m + 1);

	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;

		a[i] = x + a[i - 1];
		// cout << a[i] << " ";
	}
	// cout << endl;

	for (int i = 1; i <= m; i++)
	{
		int x;
		cin >> x;

		b[i] = x + b[i - 1];
		// cout << b[i] << " ";
	}

	// cout << endl;

	int ans = 0;

	for (int i = 0; i <= n; i++)
	{
		if (a[i] > k) break;

		int rem = k - a[i];
		int l = upper_bound(b.begin(), b.end(), rem) - b.begin();
		// cout << rem << " " << l - 1 << endl;

		ans = max(ans, i + l - 1);
	}

	cout << ans;
}

Measured memory_bytes: 6372
#include<stdio.h>
int main(){
	int i,Q,c,a,n,t,min;
	t=0;
	scanf("%d",&Q);
	for(i=0;i<Q;i++){
		scanf("%d%d%d",&c,&a,&n);
		
		min = c;
		if(min > a){
			min = a;
		}
		if(min > n){
			min = n;
		}
		
		if(n>=1&&a>=1&&c>=1){
			t+=min;
			c-=min;
			a-=min;
			n-=min;
		}
		if(c>=2&&a>=1){
			if(c/2<=a){
				t+=c/2;
				c-=c/2*2;
			}else if(c/2>a){
				t+=a;
				c-=a*2;
			}
		}
		if(c>=3){
			t+=c/3;
		}
		
		printf("%d\n",t);
		t=0;
	}
	
return 0;
}

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

using namespace std;

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

typedef vector<int> Dice;

enum {TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM};
#define rotate_swap(x, a, b, c, d) swap(x[a], x[b]); swap(x[b], x[c]); swap(x[c], x[d]);

void rotate_r(Dice &dice) {rotate_swap(dice, TOP, LEFT, BOTTOM, RIGHT);}
void rotate_l(Dice &dice) {rotate_swap(dice, TOP, RIGHT, BOTTOM, LEFT);}
void rotate_f(Dice &dice) {rotate_swap(dice, TOP, BACK, BOTTOM, FRONT);}
void rotate_b(Dice &dice) {rotate_swap(dice, TOP, FRONT, BOTTOM, BACK);}
void rotate_w(Dice &dice) {rotate_swap(dice, BACK, LEFT, FRONT, RIGHT);}
void rotate_c(Dice &dice) {rotate_swap(dice, BACK, RIGHT, FRONT, LEFT);}

vector<Dice> generate_all(Dice dice) {
  vector<Dice> res;
  rep(i, 6){
    rep(j, 4){
      res.push_back(dice);
      rotate_w(dice);
    }
    if (i % 2 == 0) rotate_r(dice);
    else rotate_f(dice);
  }
  return res;
}

int board[201][201][2];

int main() {
  Dice ini(6);
  rep (i, 6) ini[i] = i;
  vector<Dice> all = generate_all(ini);
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    rep (i, 201) rep (j, 201) board[i][j][0] = 0;
    rep (i, n) {
      int t, f;
      cin >> t >> f;
      Dice dice;
      rep (j, 24) if (all[j][TOP] == t - 1 && all[j][FRONT] == f - 1) {
	dice = all[j];
	break;
      }
      int x = 100, y = 100;
      while (true) {
	pair<int, int> r = make_pair(-1, -1);
	if (dice[FRONT] > 2 && board[x][y + 1][0] < board[x][y][0]) {
	  if (r.first < dice[FRONT]) r = make_pair(dice[FRONT], (int)FRONT);
	}
	if (dice[RIGHT] > 2 && board[x + 1][y][0] < board[x][y][0]) {
	  if (r.first < dice[RIGHT]) r = make_pair(dice[RIGHT], (int)RIGHT);
	}
	if (dice[LEFT] > 2 && board[x - 1][y][0] < board[x][y][0]) {
	  if (r.first < dice[LEFT]) r = make_pair(dice[LEFT], (int)LEFT);
	}
	if (dice[BACK] > 2 && board[x][y - 1][0] < board[x][y][0]) {
	  if (r.first < dice[BACK]) r = make_pair(dice[BACK], (int)BACK);
	}
	if (r.first == -1) break;
	if (r.second == FRONT) {
	  ++y;
	  rotate_f(dice);
	} else if (r.second == RIGHT) {
	  ++x;
	  rotate_r(dice);
	} else if (r.second == LEFT) {
	  --x;
	  rotate_l(dice);
	} else {
	  --y;
	  rotate_b(dice);
	}
      }
      ++board[x][y][0];
      board[x][y][1] = dice[TOP];
    }
    int res[6] = {};
    rep (i, 201) rep (j, 201) if (board[i][j][0] > 0) ++res[board[i][j][1]];
    rep (i, 6) {
      if (i > 0) cout << " ";
      cout << res[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1532
n = int(input())
v = list(map(int,input().split()))
minimum1 = 0
#minimum1_id = 0
minimum2 = 0
#minimum2_id = 0

for i in range(n-1):
    ans = 0
    minimum1 = min(v)
    del v[v.index(minimum1)]
    minimum2 = min(v)
    del v[v.index(minimum2)]
    ans = ans+((minimum1+minimum2)/2)
    v.append(ans)
#    print(v)

print(v[0])


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> D(k);
    for (auto i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        D[i] = d;
    }
    int ans = n;
    while (1)
    {
        int tmp = ans;
        bool is_ok = true;
        while (tmp != 0)
        {
            int r = tmp % 10;
            for (auto i = 0; i < k; i++)
            {
                if (r == D[i])
                {
                    is_ok = false;
                    break;
                }
            }
            tmp /= 10;
        }
        if(is_ok){
            break;
        }else{
            ans += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int a = int.Parse(input[1]);
        int b = int.Parse(input[2]);
        
        int result = 0;
        for(int i = 1;i <= n;i++){
            String s = i.ToString();
            int tmp = 0;
            for(int j = 0;j < s.Length;j++){
               tmp += int.Parse(s[j].ToString());
            }
            if(a <= tmp && tmp <= b) result+= i;
        }
        Console.WriteLine(result);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stack>
const int MAX_W = 500, MAX_H = 500;
int W, H;
std::string map[MAX_H];
int temp[MAX_H][MAX_W];

struct Rectangle{int height; int pos;};

int getLargestRect(int buffer[], int size){
	std::stack<Rectangle> s;
	buffer[size] = 0;
	int maxv = 0;
	for(int i=0;i<=size;i++){
		Rectangle rect;
		rect.height = buffer[i];
		rect.pos = i;
		if(s.empty()){
			s.push(rect);
		}
		else{
			if(s.top().height < rect.height){
				s.push(rect);
			}
			else if(s.top().height > rect.height){
				int target = i;
				while(!s.empty() && s.top().height >= rect.height){
					int area = (i - s.top().pos) * s.top().height;
					target = s.top().pos;
					maxv = std::max(maxv, area);
					s.pop();
				}
				rect.pos = target;
				s.push(rect);
			}
		}	
	}

	return maxv;
}

//ツ渉可甘コツ渉按猟敖づーツつオツづ仰づ淞づゥ
int getLargestRect(){
	memset(temp, 0, sizeof(temp));
	for(int j=0;j<W;j++){
		int seq = 0;
		for(int i=0;i<H;i++){
			if(map[i][j] == '*')
				seq = temp[i][j] = 0;
			else
				temp[i][j] = ++seq;
		}
	}

	int maxs = 0;
	for(int i=0;i<H;i++){
		maxs = std::max(maxs, getLargestRect(temp[i], W));
	}
	return maxs;
}

int main(){
	while(std::cin >> H >> W, W && H){
		for(int i=0;i<H;i++){
			std::cin >> map[i];
		}

		std::cout << getLargestRect() << std::endl;
	}
}

Measured memory_bytes: 2164
#!/usr/bin python3
# -*- coding: utf-8 -*-

n = int(input())
dp = [[0]*19 for _ in range(19)]
dq = [[0]*19 for _ in range(19)]

for i in range(n):
    s = input()
    x = s.find('.')
    if x == -1:
        s = s + '0'*9
    else:
        s = s.replace('.','') + '0'*(10-(len(s)-x))
    s = int(s)
    d2 = 0
    d5 = 0
    for _ in range(18):
        if s%2 != 0:
            break
        s = s//2
        d2 += 1
    for _ in range(18):
        if s%5 != 0:
            break
        s = s//5
        d5 += 1
    dp[d2][d5] += 1
    dq[d2][d5] += 1

for i in range(18,-1,-1):
    for j in range(18,0,-1):
        dp[i][j-1]+=dp[i][j]
for j in range(18,-1,-1):
    for i in range(18,0,-1):
        dp[i-1][j]+=dp[i][j]

ret = 0
for i in range(19):
    for j in range(19):
        if dq[i][j] == 0:
            continue
        ret += dq[i][j] * dp[18-i][18-j]
ret -= dp[9][9]
print(ret//2)


Measured memory_bytes: 9212
#include<iostream>
using namespace std;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
long long K,ans=0LL;
int main(){
    cin>>K;
    for(int a=1;a<=K;a++)for(int b=1;b<=K;b++)for(int c=1;c<=K;c++)ans+=gcd(a,gcd(b,c));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        ArrayList<Integer> tokuhyou = new ArrayList<>();
        int sum = 0;

        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            tokuhyou.add(a);
            sum = sum + a;
        }
        Collections.sort(tokuhyou);
        Collections.reverse(tokuhyou);
        String answer = "Yes";

        for (int j = 0; j < m; j++){
            int ninnki = tokuhyou.get(j);
            if (((double)sum/(4.0*(double) m))> ninnki){
                answer = "No";
                break;
            }
        }
        System.out.println(answer);


    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin>>n; char x[2*n];
  for (int i = 0; i < n; i++) cin >> x[2*i];
  for (int i = 0; i < n; i++) cin >> x[2*i+1];
  for (int i = 0; i < 2*n; i++) cout<<x[i];
  cout<<endl;
}

Measured memory_bytes: 256
import bisect

n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
acum1=[0]
for i in range(n):
  acum1.append(acum1[-1]+arr1[i])
acum2=[0]
for i in range(m):
  acum2.append(acum2[-1]+arr2[i])
ans=0
for i in range(n+1):
  if acum1[i]>k:
    break
  ans=max(ans,i+bisect.bisect_right(acum2,k-acum1[i])-1)
print(ans)

Measured memory_bytes: 126772
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
 
int k;
double okl, okr, p, e, t;

double calc(int c, double l, double r) {
    double m = (l + r) / 2;
    if (k == c) return okl < m && m < okr;
    if (r < okl || okr < l) return 0;
    if (okl < l && r < okr) return 1;
    if (t < m)
        return calc(c + 1, l, m) * (1 - p) + calc(c + 1, m, r) * p;
    else
        return calc(c + 1, l, m) * p + calc(c + 1, m, r) * (1 - p);
}
 
int main() {
    int l, r;
    cin >> k >> l >> r >> p >> e >> t;
    okl = t - e;
    okr = t + e;
    printf("%.9lf\n", calc(0, l, r));
    return 0;
}

Measured memory_bytes: 3256
#include"bits/stdc++.h"
#include<valarray>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define MAX 18

int n;

vector<long long int> v;


unordered_map<int,long long int> dp[MAX][MAX][5000];

inline long long int dfs(int l,int r,int vl,int vr){
	if(l+1>=r)return 0;
	if(dp[l][r][vl].count(vr))return dp[l][r][vl][vr];
	dp[l][r][vl][vr]=LLONG_MAX;
	for(int i=l+1;i<r;i++){
		long long int tmp=vl+vr;
		long long int cof=tmp;
		long long int ret=dfs(l,i,vl,cof)+dfs(i,r,cof,vr)+cof*v[i];
		dp[l][r][vl][vr]=min(dp[l][r][vl][vr],ret);
	}
	return dp[l][r][vl][vr];
}


int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		long long int a;
		scanf("%lld",&a);
		v.push_back(a);
	}
	long long int ans=dfs(0,n-1,1,1)+v[0]+v.back();
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 100224
#include "bits/stdc++.h"

#define int long long

using namespace std;

int mod;
vector<vector<int>> g;
vector<bool> used;
vector<int> dp;
vector<int> ans;

void dfs(int v) {
    used[v] = true;
    dp[v] = 1;
    for (int to: g[v]) {
        if (used[to]) {
            continue;
        }
        dfs(to);
        dp[v] *= dp[to];
        dp[v] %= mod;
    }
    dp[v] += 1;
}

void dfs2(int v, int cur) {
    used[v] = true;
    //cerr << v + 1 << " " << cur << " " << dp[v] << endl;
    ans[v] = cur * (dp[v] + mod - 1) % mod;
    vector<int> sons;
    for (int to: g[v]) {
        if (!used[to]) {
            sons.push_back(to);
        }
    }
    if (sons.size() == 0) {
        return;
    }
    vector<int> pref(sons.size() + 1), suf(sons.size() + 1);
/*    suf[i]
    [ i, sons.size() )
    pref[i]
    [ 0, i )*/
    pref[0] = 1;
    for (int i = 0; i < sons.size(); i++) {
        pref[i + 1] = pref[i] * dp[sons[i]] % mod;
    }
    suf[sons.size()] = 1;
    for (int i = (int)(sons.size()) - 1; i >= 0; i--) {
        suf[i] = suf[i + 1] * dp[sons[i]] % mod;
    }
    for (int i = 0; i < sons.size(); i++) {
        dfs2(sons[i], (cur * pref[i] % mod * suf[i + 1] % mod + 1) % mod);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n >> mod;
    g.resize(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    used.resize(n);
    dp.resize(n);
    dfs(0);
    ans.resize(n);
    used.assign(n, false);
    dfs2(0, 1);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 24096
n,m=map(int,input().split())
E=[list(map(int,input().split())) for i in range(m)]
INF=float("inf")
dist=[INF]*n
dist[0]=0
for i in range(n):
  for fr,to,cost in E:
    fr,to=fr-1,to-1
    # スコアの正負を逆にしてスコアを最小化することを考える
    cost*=-1
    if dist[fr]!=INF and dist[to]>dist[fr]+cost:
      dist[to]=dist[fr]+cost
      # 負経路の存在チェック
      # 一番最後に緩和（更新）が発生するとNG（負閉路の長さは頂点の個数以下なので）
      if i==n-1 and to==n-1:
        print("inf")
        exit(0)
print(-dist[-1])



Measured memory_bytes: 45528
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  ll n, a, b ;
  cin >> n >> a >> b ;
  
  if(a==b){
    cout << 1 <<endl ;
  }
  
  else if(a>b){
    cout << 0 <<endl ;
  }
  
  else{
    cout << max((ll)0,(n-2)*(b-a)+1) <<endl ;
  }


  return 0 ;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define sevensins ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod  1000000007
#define vect vector<long long int>
#define bins binary_search
#define vecti vector<int>::iterator
#define bitout __builtin_popcount
int main() 
{sevensins
    ll i,j,k,l,n;
    ll a,b,c;
    
    cin>>a>>b>>c>>k;
    
    ll sum=0;
    
    if(k<=a)
    sum=k;
    else
    {
        sum=a;
        k-=a;
        if(k<=b&&k>=0)
        {
            k=0;
        }
        else
        {
            k-=b;
            sum-=k;
        }
    }
    cout<<sum<<"\n";
    
    
return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, A[85];
vector <ll> V;

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


  int now = A[0];
  for (int i = 0; i < N; i++){
    if (V.size() % 2 == 0){
      if (now >= A[i]) now = A[i];
      else V.push_back(now), now = A[i];
    }else{
      if (now <= A[i]) now = A[i];
      else V.push_back(now), now = A[i];
    }
  }
  V.push_back(now);


  if (V.size() == 1){
    cout << 1000 << endl;
    return 0;
  }
  ll res = 1000, kabu = 0;
  for (int i = 0; i < V.size() - 1; i+=2){
    kabu = res / V[i];
    res %= V[i];

    res += kabu * V[i + 1];
    kabu = 0;
  }
  cout << res << endl;


  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define each(i, mp) for (auto &i : mp)

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> snu(n, 0);
  rep(i, k)
  {
    int d;
    cin >> d;
    rep(j, d)
    {
      int a;
      cin >> a;
      a--;
      snu[a] = 1;
    }
  }
  int ans = 0;
  rep(i, snu.size())
  {
    if (snu[i] == 0)
    {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define MOD 1000000007;

using namespace std;
using namespace __gnu_pbds;
//typedef tree<TYPE, null_type, less<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//typedef tree<TYPE, null_type, less_equal<TYPE>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

int n;
long long cnt[61][2];

void decompose(long long var){
	for(int i = 60; i >= 0; i--)
		if((long long)1 << i <= var)
			cnt[i][1]++, var -= (long long)1 << i;
		else cnt[i][0]++;
}

int main(){
	//IO("input.txt", "output.txt");
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++){
		long long a;
		cin >> a;
		decompose(a);
	}
	long long sum = 0;
	for(int i = 0; i <= 60; i++){
		long long mlt = ((long long)1 << i) % (long long)MOD;
		long long wys = cnt[i][0] * cnt[i][1] % (long long)MOD;
		sum += wys * mlt;
		sum %= (long long)MOD;
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 256
import itertools
N,K = list(map(int,input().split()))
p = list(map(int,input().split()))
k = [(1+i)/2 for i in p]
a = list(itertools.accumulate(k))
max = a[K-1]
for i in range(K,N):
    if max < a[i] - a[i-K]:
        max = a[i] - a[i-K]
print(max)

Measured memory_bytes: 77448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c;cin>>a>>b>>c;
  if(a%2==1||b%2==1||c%2==1){
    cout<<0<<endl;
    return 0;
  }
  a/=2;b/=2;c/=2;
  ll d=2*a-b-c;
  ll e=2*b-a-c;
  ll f=2*c-a-b;
  ll cnt=0;
  ll ad,ae,af;
  if(d==0){
    if((a+b+c)%3==0)ad=100000;
    else ad=1;
  }
  else{
    for(;;){
    if(d%2!=0)break;
    d/=-2;
    cnt++;
  }
  for(ll i=cnt;i>=0;i--){
    if((2*(a+b+c)-d)%3==0){
      ad=i+1;
      break;
    }
    d*=-2;
  }
  }
  cnt=0;
  if(e==0){
    if((a+b+c)%3==0)ae=100000;
    else ae=1;
  }
  else{
    for(;;){
    if(e%2!=0)break;
    e/=-2;
    cnt++;
  }
  for(ll i=cnt;i>=0;i--){
    if((2*(a+b+c)-e)%3==0){
      ae=i+1;
      break;
    }
    e*=-2;
  }
  }
  cnt=0;
  if(f==0){
    if((a+b+c)%3==0)af=100000;
    else af=1;
  }
  else{
    for(;;){
    if(f%2!=0)break;
    f/=-2;
    cnt++;
  }
  for(ll i=cnt;i>=0;i--){
    if((2*(a+b+c)-d)%3==0){
      af=i+1;
      break;
    }
    f*=-2;
  }
  }
  if(ad==100000&&ae==100000&&af==100000){
    cout<<-1<<endl;
  }
  else{
    ll y=min(ad,ae);
    cout<<min(y,af)<<endl;
  }
  
}

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

int a[100000000];

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, L, key = -1;
	long long int p = 0;
	cin >> N >> L;
	for (int i = 0; i < N; i++) cin >> a[i];

	for (int i = 0; i < N - 1; i++) {
		if (L <= a[i] + a[i+1]) {
			p = a[i] + a[i+1];
			key = i;
			break;
		}
	}

//	cout << "key = " << key << endl;

	if (key == -1) {
		cout << "Impossible\n";
	} else {
		cout << "Possible\n";
		for (int i = 0; i < key; i++) cout << i+1 << endl;
		for (int i = N-1; i > key + 1; i--) cout << i << endl;
		cout << key + 1 << endl;
	}

	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int a1[100001]={0};

	long long int n,q,a,b,k;

	cin>>n;

	int i;
	 long long int sum=0;

	for(i=0;i<n;i++)
	{
		cin>>k;
		sum+=k;
		a1[k]++;
	}

	cin>>q;


	while(q--)
	{
		cin>>a>>b;
		k=a1[a];
		a1[a]=0;
		sum-=k*a;
		sum+=k*b;
		a1[b]+=k;
		cout<<sum<<"\n";
	}
	
	
	

	return 0;
}


Measured memory_bytes: 4420
import java.util.Scanner;

class Main
{
 public static void main(String x[])
 {
  Scanner sc= new Scanner(System.in);
  int a[]= new int[3];
  for(int i=0;i<3;i++)
    a[i]=sc.nextInt();
  int sum=a[0]+a[1]+a[2];
  if(sum<22)
    System.out.println("win");
  else
    System.out.println("bust");
	}
}
 


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios::sync_with_stdio(false)
#define pb push_back
#define mp make_pair
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <pair<char , ll>> vi;
ll MOD = 1e9+7;
//vi v1[200005],v2;
//bool visit[200005]={false};
/*void bfs(ll n){
    queue<ll> q;
    q.push(n);
    visit[n]=true;
    while(!q.empty()){
        ll t=q.front();
        q.pop();
        v2.pb(t);
        for(ll i=0;i<v1[t].size();i++){
            if(visit[v1[t][i]]==false){
                q.push(v1[t][i]);
                visit[v1[t][i]]=true;
            }
        }
    }
}*/
/*void dfs(ll n){
    for(ll i=0;i<v1[n].size();i++)
    {
        ll y=v1[n][i];
        if(visit[y]==0)
        {
            v2.pb(y);
            visit[y]=1;
            dfs(y);
        }
    }
}*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    ll n,i,g,b,r,j,k,ans=0,c=0,error=0;
    cin>>n;
	for (ll i=1;i*i<n;i++){
		if (n%i==0 && n%((n-i)/i)){
			ans += (n-i)/i;
		}
	}
 
	cout << ans << endl;
    return 0; 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, K;
int dp[310][310][310];
bool used[26];
string str;

int loop(int a, int b, int k) {
	if(k < 0) return -inf;
	else if(a > b + 1) return 1;
	else if(a == b + 1) return 0;
	else if(a == b) return 1;
	else if(dp[a][b][k] != -1) return dp[a][b][k];
	else {
		int res = 1;
		if(str[a] == str[b]) {
			MAX(res, loop(a + 1, b - 1, k) + 2);
		}
		else {
			MAX(res, loop(a + 1, b, k));
			MAX(res, loop(a, b - 1, k));
			MAX(res, loop(a + 1, b - 1, k - 1) + 2);
			for(int i = a; i < b; i++) {
				if(str[i] == str[b]) {
					MAX(res, loop(i + 1, b - 2, k - 1) + 2);
					break;
				}
			}
			for(int i = b; i > a; i--) {
				if(str[i] == str[a]) {
					MAX(res, loop(a + 2, i - 1, k - 1) + 2);
					break;
				}
			}
		}
		return dp[a][b][k] = res;
	}
}

void solve() {
	memset(dp, -1, sizeof(dp));
	cin >> str >> K;
	N = sz(str);
	cout << loop(0, N - 1, K) << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 116608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public void Run()
        {
            N = Input.ReadInt();
            Console.WriteLine(N % 2 == 0 ? N : 2 * N);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13140
import sys

if __name__ == '__main__':
    S = list(map(lambda x: int(x), sys.stdin.readline().rstrip()))
    M1 = [0 if i % 2 == 0 else 1 for i in range(len(S))]
    M2 = [0 if i % 2 == 1 else 1 for i in range(len(S))]
    d1 = sum([1 if S[i] != M1[i] else 0 for i in range(len(S))])
    d2 = sum([1 if S[i] != M2[i] else 0 for i in range(len(S))])
    if d1 < d2:
        print(d1)
    else:
        print(d2)


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

using namespace std;

int main(){
  int n,cnt;
  int a[101] = {};
  while(1){
    cin >> n;
    if(n == 0)break;
    cnt = 0;
    for(int i=0;i<n;i++){
      cin >>a[i];
    }
    for(int j=0;j<n;j++)
      for(int i=0;i<n-1;i++){
	if(a[i] > a[i+1]){swap(a[i],a[i+1]);
	  cnt++;}
      }

    
    cout << cnt << endl;
      }

  }



Measured memory_bytes: 3072
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    double a,b,h,m,ans;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    ans=sqrt((b*b)+(a*a)-2*b*a*cos((h*60-11*m)*3.14159265358979/360));
    printf("%.10lf",ans);
}

Measured memory_bytes: 2624
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAXN = 100500;
ll n, a, b;
ll arr[MAXN];

bool check(ll x)
{
	ll sum = 0;

	for (int i = 0; i < n; i++)
	{
		ll cur_h = arr[i] - x * b;
		if (cur_h > 0)
			sum += (cur_h + a - b - 1) / (a - b);
	}

	return sum <= x;
}

int main()
{
	cin >> n >> a >> b;

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

	ll bl = 0;
	ll br = 1e9 + 7;

	while (br - bl > 1)
	{
		ll bm = (bl + br) / 2;

		if (check(bm))
			br = bm;
		else
			bl = bm;
	}

	cout << br << '\n';


	return 0;	
}


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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

void solve(){
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    long double cs=2.0 * atan(1)*4.0 * (h / 12.0 + m / 720.0 - m / 60.0);
    long double len=sqrt((a*a)+(b*b)-(2*a*b*cos(cs)));
    cout << setprecision(16) << len << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4120
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7; // change if needed

struct Modint {
  ll val;
  
  Modint (ll _val = 0)
    : val(_val % MOD) {}

  Modint operator+ (Modint other) const {
    return Modint(val + other.val);
  }

  void operator+= (Modint other) {
    val += other.val;
    val %= MOD;
  }

  Modint operator- () const {
    return Modint(MOD - val);
  }

  Modint operator- (Modint other) const {
    return Modint(val + MOD - other.val);
  }

  void operator-= (Modint other) {
    val += MOD - other.val;
    val %= MOD;
  }

  Modint operator* (Modint other) const {
    return Modint(val * other.val);
  }

  void operator*= (Modint other) {
    val *= other.val;
    val %= MOD;
  }

  bool operator== (Modint other) const {
    return val == other.val;
  }

  bool operator!= (Modint other) const {
    return val != other.val;
  }
};

Modint exp (Modint a, int k) {
  if (k == 0) {
    return Modint(1);
  } else if (k % 2 == 0) {
    Modint half = exp(a, k / 2);
    return half * half;
  } else {
    return a * exp(a, k - 1);
  }
}

Modint inv (Modint a) {
  return exp(a, MOD - 2);
}

ostream& operator<< (ostream& out, Modint p) {
  out << p.val;
  return out;
}


int main () {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  string s;
  cin >> s;

  int last = -1, ptr = 0;
  Modint ans (1);
  while (ptr < n) {
    int type;
    if (ptr + 1 == n || s[ptr] != s[ptr + 1]) { // one vertical
      type = 1;
    } else {
      type = 0;
    }

    if (type == 0) { // 2 horizontal
      if (last == -1) {
        ans *= Modint(6);
      } else if (last == 0) {
        ans *= Modint(3);
      } else if (last == 1) {
        ans *= Modint(2);
      }
      ptr += 2;
    } else {
      if (last == -1) {
        ans *= Modint(3);
      } else if (last == 0) {
        ans *= Modint(1);
      } else if (last == 1) {
        ans *= Modint(2);
      }
      ptr += 1;
    }

    last = type;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> li = new ArrayList<Integer>();
        //ArrayList<ArrayList<Integer>> li = new ArrayList<ArrayList<Integer>>();
        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
        int ans = 0;
        for(int i = 0; i < n; i++){
            int x = sc.nextInt();
            int l = sc.nextInt();
            li.add(x);
            map.put(x,l);
        }
        Collections.sort(li);
        int i = 0;
        int left = 0;
        int right = 0;
        for(int v: li){
            if(i == 0){
                left = v-map.get(v);
                right = v+map.get(v);
                ans++;
                //System.out.println(left+" "+right);
            }else{
                int nl = v-map.get(v);
                int nr = v+map.get(v);
                //System.out.println(nl+" "+nr);
                if(nl-right >= 0){
                    ans++;
                    left = nl;
                    right = nr;
                }else if(nl-right < 0 && nr-right >= 0){
                    continue;
                }else if(nl-right < 0 && nr-right < 0){
                    right = nr;
                }
            }
            i++;
        }
        System.out.println(ans);
    }
}
 

Measured memory_bytes: 101416
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}
 
fn main() {
  let xs: Vec<u32> = read_vec();

  let ans: u32 = if xs[0] >= xs[1] && xs[0] >= xs[2] {
    xs[1] + xs[2]
  } else if xs[1] >= xs[0] && xs[1] >= xs[2] {
    xs[0] + xs[2]
  } else {
    xs[0] + xs[1]
  };

  println!("{}", ans);
}


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

int main()
{
    int a, b;
    int sum = 0;
    cin >> a >> b;

    for (int i = 0; i < 2; i++)
    {

        if (a >= b)
        {
            sum += a;
            a--;
        }
        else
        {
            sum += b;
            b--;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    ll n; cin >> n;
    int k; cin >> k;

    int cnt = 0;
    while(n!=0){
        n/=k;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}


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

using ll = long long;
using pll = pair<ll,ll>;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)

#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 

template <class INT_T> INT_T powi(INT_T x, INT_T y) {
    if (y == 0) return 1;
    if (y == 1) return x;
    if (y & 1) return powi(x*x, y/2) * x;
    return powi(x*x, y/2);
}

ll solve(map<pll, ll>& memo, ll lv, ll eat)
{
    ll len = 4 * powi((ll)2, lv) - 3;

    auto p = make_pair(lv, eat);
    if (memo.find(p) != memo.end()) {
        return memo[p];
    }
    
    ll c = (len + 1) / 2;
    ll res = eat >= c ? 1 : 0;

    if (lv > 0) {
        ll eat_max = (len - 3) / 2;
        res += solve(memo, lv-1, min(eat-1, eat_max));
        if (eat > c) {
            res += solve(memo, lv-1, min(eat-c, eat_max));
        }
    }
    
    return memo[p] = res;
}


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

    ll n, x;
    cin >> n >> x;

    map<pll, ll> memo;

    cout << solve(memo, n, x) << endl;
}


Measured memory_bytes: 764
S = list(map(int, list(input().strip()) ))
l = len(S)

r = S[0] * 100 + S[1] * 10 + S[2]
# r = int(S[0:3])
sa = abs(r-753)
temp = 0

# print(r)

# 数としては0からl-3まで
for i in range(0, l-2):
  temp = S[i]*100 + S[i+1] * 10 + S[i+2]
  tempsa = abs(temp-753)
  if tempsa < sa:
    r = temp
    sa = tempsa
print(sa)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int  a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b && b < c)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	putchar('\n');

	return 0;

}

Measured memory_bytes: 1012