akhauriyash/Code-Regression huggingface dataset:
# N < 90なのでテーブルにする必要ある？
table = [0]*90
def L(i):
    if i == 0:
        table[i] = 2
    elif i == 1:
        table[i] = 1
    else:
        table[i] = table[i- 1] + table[i-2]

s = int(input())
for i in range(s + 1):
    L(i)
print(table[s])
# tleした

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll n; cin >> n;
    ll l = 1, r = n;
    while ( r - l > 1 ) {
        ll m = (l + r)/2;
        if ( m*(m+1)/2 >= n ) {
            r = m;
        }
        else {
            l = m;
        }
    }
    FOR(i, 1, r+1) {
        if (i == r*(r+1)/2-n) continue;
        cout << i << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i.second<< " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // bit全探索
  int N;
  cin >> N;
  vector<vector<P>> XY;
  rep(i, N) {
    int A;
    cin >> A;
    vector<P> B;
    rep(j, A) {
      int X, Y;
      cin >> X >> Y;
      --X;
      B.push_back(make_pair(X, Y));
    }
    XY.push_back(B);
  }
  //rep(i, N) show(XY[i]);
  int ans = 0;  
  for (int bit = 0; bit < (1<<N); bit++) {
    bool flag = true;
    for (int i = 0; i < N; i++) {
      if ((bit&(1<<i)) == 0) continue;
      for (auto p : XY[i]) {
        if (((bit>>p.first)&1) ^ (p.second==1)) {
          //cout << bit << '-' << i << '-' << p.first << '\n';
          flag = false; break;
        }
      }
    }
    if (flag) {
      ans = max(ans, __builtin_popcount(bit));
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3544
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// B進数
// 例 B = -2
string calc(ll B, ll N){
    if(N==0) return "0";
    if(N==1) return "1";

    stringstream ss;

    while(N!=0){
        ll r = N%B;
        ll d = N/B;

        // 修正
        if(r<0){
            r-=B;
            d++; 
        }
        N = d;

        ss << r;
    }

    string s = ss.str();
    reverse(ALL(s));
    return s;
}

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

    // input
    ll N;
    cin >> N;

    auto ans = calc(-2, N);
    p(ans);
    
    return 0;
}

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

using namespace std;
const int N = 1e5 + 5;
int par[N];

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

void merge(int a, int b) {
    a = getpar(a);
    b = getpar(b);
    if (a == b) return;
    par[a] = b;
}

int main() {
    //freopen("in.txt", "rt", stdin);
    int n, m;
    scanf("%d %d", &n, &m);
    int a, b, c;
    for (int i = 1; i <= n; ++i) par[i] = i;
    while (m--) {
        scanf("%d %d %d", &a, &b, &c);
        merge(a, b);
    }
    set<int> st;
    for (int i = 1; i <= n; ++i) st.insert(getpar(i));
    printf("%d", (int) st.size());
}

Measured memory_bytes: 5376
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        a: [i64; n],
    };
    let mut ans_minus = 0;
    let mut ans_plus = 0;

    let mut tmp = 0;
    for (i, v) in a.iter().enumerate(){
        if i % 2 == 0{
            tmp = tmp + v;
            if tmp >= 0{
                ans_minus += tmp + 1;
                tmp = -1;
            }
        } else {
            tmp = tmp + v;
            if tmp <= 0{
                ans_minus += -tmp + 1;
                tmp = 1;
            }
        }
    }


    let mut tmp = 0;
    for (i, v) in a.iter().enumerate(){
        if i % 2 == 1{
            tmp = tmp + v;
            if tmp >= 0{
                ans_plus += tmp + 1;
                tmp = -1;
            }
        } else {
            tmp = tmp + v;
            if tmp <= 0{
                ans_plus += -tmp + 1;
                tmp = 1;
            }
        }
    }

    println!(
        "{}",
        if ans_minus < ans_plus { ans_minus}else{ans_plus}
    );
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, K;
  cin >> N >> K;
  i64 ans = 0;
  vi32 H(N);
  cin >> H;
  sort(all(H));
  reverse(all(H));
  rep(i, N) {
    if (K > 0) K--;
    else {
      ans += H[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);


int main(void)
{
    ll n; cin>>n;
    for(int i=1;i<=50000;i++){
        if(i*108/100 == n){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3620
s=set(input())

flg=0
if "N" in s:
    flg+=1
if "S" in s:
    flg-=1
if "W" in s:
    flg+=10
if "E" in s:
    flg-=10

if flg==0:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 9096
(defmacro check-mask (target source)
  `(= (logand (ash ,target (* -1 ,source)) 1) 0))

(defun calc (h w k c &optional (h-max 0) (w-max 0) (result 0))
  (cond ((= h-max (ash 1 h))
         result)
        ((= w-max (ash 1 w))
         (calc h w k c (1+ h-max) 0 result))
        (t
         (let ((black 0))
           (dotimes (i h)
             (dotimes (j w)
               (when (and (check-mask h-max i) (check-mask w-max j) (eql (aref c i j) #\#))
                 (incf black))))
           (when (= black k)
             (incf result))
           (calc h w k c h-max (1+ w-max) result)))))

(defun collect (h w)
  (let ((result (make-array (list h w))))
    (dotimes (y h)
      (let ((tmp (read-line)))
        (dotimes (x w)
          (setf (aref result y x) (aref tmp x)))))
    result))

(defun main ()
  (let ((h (read))
        (w (read))
        (k (read)))
    (princ (calc h w k (collect h w)))))

(main)

Measured memory_bytes: 24680
#include <stdio.h>

int main(){
    int i, j, h, w;
    // char c[110][110];
    scanf("%d %d", &h, &w);
    // for(i = 0; i < h; i++){
    //     scanf("%s", c[i]);
    //     // getchar();
    //     // for(j = 0; j < w; j++){
    //     //     scanf("%c", &c[i][j]);
    //     // }
    // }
    for(i = -1; i <= h; i++){
        for(j = -1; j <= w; j++){
            if(i == -1 || i == h || j == -1 || j == w){
                printf("#");
            }else{
                char c;
                scanf("%c", &c);
                printf("%c", c);
                // printf("%c", c[i][j]);
            }
        }
        printf("\n");
        getchar();
    }
    return 0;
}

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

int main (){
   char c;
  cin >> c;
  
  if (c == 'a' || c == 'e' ||c ==  'i' ||c ==  'o' ||c ==  'u' ){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

// #define _GLIBCXX_DEBUG

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

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
typedef long long ll;
using vi=vector<ll>;

template<class T> void out(T a){cout<<a<<endl;}

void solve() {
  int n; cin>>n;
  vi a(n); int block=1,ans=0;
  bool f=false;
  rep(i,n){
    cin>>a[i];
    if(a[i]==1) f=true;
    if(a[i]==block) block++;
    else ans++;
  }
  if(f) out(ans);
  else out(-1);
}

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using C = complex<int>;

string s;
int N;
int c;
bool ok;

bool check(C x){
	return abs(x.real()) <= 10000 && abs(x.imag()) <= 10000;
}

C expr();
C term();
C factor();
C num();

void debug(string text){
	return;
	cout << text + " ";
	for(int i = 0; i < N; i++){
		if(i == c) cout << '[' << s[i] << ']';
		else cout << s[i];
	}
	cout << endl;
}

C expr(){
	debug("expr");
	C x = term();
	while(c < N){
		if(s[c] == '+'){
			c++;
			x += term();
			if(!check(x)){
				ok = false;
			}
		}
		else if(s[c] == '-'){
			c++;
			x -= term();
			if(!check(x)){
				ok = false;
			}
		}
		else break;
	}
	return x;
}

C term(){
	debug("term");
	C x = factor();
	if(!check(x)){
		ok = false;
	}
	while(c < N){
		if(s[c] == '*'){
			c++;
			x *= factor();
			if(!check(x)){
				ok = false;
			}
		}
		else break;
	}
	return x;
}

C factor(){
	debug("factor");
	if(s[c] == '('){
		c++;
		C ret = expr();
		assert(s[c] == ')');
		c++;
		return ret;
	}
	return num();
}

C num(){
	debug("num");
	C ret = 0;
	bool minus = false;
	if(s[c] == '-'){
		minus = true;
		c++;
	}
	if(s[c] == 'i'){
		ret = C(0, 1);
		c++;
	}
	else{
		while(c < N && isdigit(s[c])){
			ret = ret * 10 + (s[c] - '0');
			if(!check(ret)){
				ok = false;
			}
			c++;
		}
	}
	if(minus) ret *= -1;
	return ret;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	while(cin >> s){
		N = s.size();
		c = 0;
		ok = true;
		C ans = expr();

		if(ok){
			if(ans == 0){
				cout << 0;
			}
			else{
				if(ans.real() != 0){
					cout << ans.real();
				}
				if(ans.imag() != 0){
					if(ans.real() != 0 && ans.imag() > 0) cout << "+";
					cout << ans.imag() << "i";
				}
			}
			cout << endl;
		}
		else{
			cout << "overflow" << endl;
		}
	}
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    double ans=0;
    ans += (double)v[0]/pow(2, n-1);
    for(int i=1; i<n; i++){
        ans+=(double)v[i]/pow(2, n-i);
    }

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

Measured memory_bytes: 384
using System;

namespace ABC_096_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split(' ');
            int a = int.Parse(word[0]);
            int b = int.Parse(word[1]);
            if (a > b)
            {
                Console.WriteLine(a - 1);
            }
            else if (a <= b)
            {
                Console.WriteLine(a);
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <algorithm>

#pragma warning(disable : 4996)

using namespace std;

int n, a[100000]; long long s[200001];

inline int reader()
{
	int ret = 0;

	while (true)
	{
		char c = getchar();

		if (c == '\n') break;

		ret = (ret << 1) + (ret << 3) + c - 48;
	}

	return ret;
}

long long sum(int l, int r)
{
	return s[r] - s[l];
}

int main()
{
	n = reader();

	for (int i = 0; i < n; i++) a[i] = reader();

	s[0] = 0; for (int i = 1; i <= 2 * n; i++) s[i] = s[i - 1] + a[(i - 1) % n];

	long long ret = 0, sums = s[n];

	for (int i = 0; i < n; i++)
	{
		int posr1 = lower_bound(s, s + 2 * n + 1, s[i] + sums / 3) - s;
		int posl1 = posr1 - 1;
		int posr2 = lower_bound(s, s + 2 * n + 1, s[i] + sums * 2 / 3) - s;
		int posl2 = posr1 - 1;

		ret = max(ret, min({ sum(i, posl1), sum(posl1, posl2), sum(posl2, i + n) }));
		ret = max(ret, min({ sum(i, posr1), sum(posr1, posl2), sum(posl2, i + n) }));
		ret = max(ret, min({ sum(i, posl1), sum(posl1, posr2), sum(posr2, i + n) }));
		ret = max(ret, min({ sum(i, posr1), sum(posr1, posr2), sum(posr2, i + n) }));
	}

	printf("%lld\n", ret);

	return 0;
}

Measured memory_bytes: 4656
#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node {int parent,left,right;};
struct Node T[MAX];

int n,D[MAX];

void rec(int,int);
void print_chil(int);


void rec(int u,int p){
  D[u]=p;
  if(T[u].right!=NIL) rec(T[u].right,p);
  if(T[u].left!=NIL) rec(T[u].left,p+1);
}
void print_chil(int u){
  int c,i;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);

  if(T[u].parent==NIL){
    printf("root, ");
  }
  else if(T[u].left==NIL){
    printf("leaf, ");
  }
  else printf("internal node, ");

  printf("[");
  c=T[u].left;
  while(c!=NIL){
    printf("%d",c);
    c=T[c].right;
    if(c!=NIL) printf(", ");
  }

  printf("]\n");

}
int main(){
  int i,j,d,v,c,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)T[v].left=c;
      else T[l].right=c;
      l=c;
      T[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==NIL)r=i;
  }
  rec(r,0);

  for(i=0;i<n;i++)
    print_chil(i);

  return 0;
}
    



Measured memory_bytes: 6380
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int lmax = 1, rmin = n;
	int l, r;
	for (int i = 0; i < m; ++i) {
		cin >> l >> r;
		lmax = max(lmax, l);
		rmin = min(rmin, r);
	}

	cout << (rmin - lmax >= 0 ? rmin - lmax + 1 : 0) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

final class Main {

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = inputReader.readLine().split(" ");
        int[] values = new int[inputs.length];
        for (int i = 0; i < inputs.length; i++) {
            values[i] = Integer.parseInt(inputs[i]);
        }
        Arrays.sort(values);
        int[] temp = new int[values.length];
        for (int i = 0; i < values.length; i++) {
            temp[values.length - i - 1] = values[i];
        }
        String output = "";
        for (int i : temp) {
            output += i + " ";
        }
        System.out.println(output.trim());
    }
}

Measured memory_bytes: 9368
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




int main() {
    ll n;
    cin >> n;
    
    bool s[100000] = {};
    for(int i = 2; i < 60000; i++){
        if(!s[i]){
            for(int j = 2 * i; j < 60000; j += i){
                s[j] = true;
            }
        }
    }
    
    int p = 2;
    REP(i, n - 1){
        while(!(!s[p] && p % 5 == 4))p++;
        cout << p << ' ';
        p++;
    }
    while(!(!s[p] && p % 5 == 4))p++;
    cout << p << endl;
}


Measured memory_bytes: 384
s = str(input())
bk = 0
wk = 0
bg = 0
wg = 0
k = s[::2]
g = s[1::2]
bk = k.count('0')
wk = k.count('1')
bg = g.count('0')
wg = g.count('1')
if bk + wg > wk + bg:
  print(wk + bg)
else:
  print(bk + wg)


Measured memory_bytes: 3188
#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;
double x[110000];
double y[110000];
pair<double,double> p[110000];
int main()
{
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++)
	{
		double X,Y;
		scanf("%lf%lf",&X,&Y);
		x[i]=cos(1)*X-sin(1)*Y;
		y[i]=sin(1)*X+cos(1)*Y;
		p[i]=make_pair(x[i],y[i]);
	}
	std::sort(p,p+a);
	double ret=99999999;
	for(int i=0;i<a;i++)
	{
		for(int j=i-1;j>=0;j--)
		{
			if(p[i].first-p[j].first>ret)break;
			double fir = (p[i].first-p[j].first);
			double sec = (p[i].second-p[j].second);
			ret=min(ret,sqrt(fir*fir + sec * sec));
		}
	}
	printf("%.12f\n",ret);
	return 0;
}


Measured memory_bytes: 6048
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

total = 0
tmp_num = -1

for i in range(N):
    num = A[i]
    total += B[num-1]

    if tmp_num + 1 == num:
        total += C[tmp_num-1]
    tmp_num = num

print(total)


Measured memory_bytes: 3696
from collections import deque
N,M=map(int,input().split())
A=[0]*M;B=[0]*M
C=[[] for i in range(N+1)]

for i in range(M):
  A[i],B[i]=sorted(list(map(int,input().split())))
  C[A[i]].append(B[i])
  C[B[i]].append(A[i])

d=[-1]*(N+1)
d[0]=0
d[1]=0

queue=deque()
queue.append(1)

while queue:
  now = queue.popleft()
  for i in C[now]:
    if d[i]!=-1:continue
    d[i]=d[now]+1
    queue.append(i)
#print(d)
E=[0]*(N+1)
for i in range(M):
#  print(d[A[i]],d[B[i]])
  if d[B[i]]-d[A[i]]==1 and E[B[i]]==0:E[B[i]]=A[i]
  elif d[A[i]]-d[B[i]]==1 and E[A[i]]==0:E[A[i]]=B[i]
if E.count(0)>2:print('No');exit
print('Yes')
for i in range(2,N+1):
  print(E[i])

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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define VEC vector

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				Vint;
typedef vector<Vint>			VV;

template<typename T>string join(const v(T)&v)
{stringstream s;REP(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		400010

const ll LINF = (ll)9e18+7;		//
const int INF = 100100100;			//2,147,483,647 (Max int)
const ll MOD = 1e9+7;
// テンプレ終了
//====================================================================//

// int DP[MAX];

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

	double ans;

	ans = (double)pow(N/3,3);

	printf("%.7lf\n",ans);

	return 0;
}




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

int main(){
  int n; cin >> n;
  vector<ll> f(n + 1, 2);
  f[1] = 1;
  ll ans = 0;
  ans += f[1];
  for(int i = 2; i <= n; i++){
    for(ll j = i * 2; j <= n; j += i){
      f[j]++;
    }
    ans += f[i] * i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 81392
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k1 = 0;
		int k2 = 0;
		for(int i = 0; i < n; i++) {
			String s1 = scan.next();
			String s2 = scan.next();
			if(s1.compareTo(s2) == 0) {
				k1 ++;
				k2 ++;
			}else if(s1.compareTo(s2) >= 1) {
				k1 += 3;
			}else {
				k2 += 3;
			}
		}
		scan.close();
		System.out.println(k1 + " " + k2);
	}
}


Measured memory_bytes: 29364
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define inf -999999999
ll gcd(ll a,ll b)
{
	if(a%b==0)
		return b;
	return gcd(b,a%b);
}
int main()
{	
	ll a,b;
	cin>>a>>b;
	cout<<a*b/gcd(a,b)<<endl;
	

	
		
}


Measured memory_bytes: 256
def dist(p, X, Y):
    s = 0
    for x, y in zip(X, Y):
        s += abs(x - y)**p
    return s**(1/p)
N = int(input())
*X, = map(int, input().split())
*Y, = map(int, input().split())
print(dist(1, X, Y))
print(dist(2, X, Y))
print(dist(3, X, Y))
print(max(abs(x - y) for x, y in zip(X, Y)))


Measured memory_bytes: 5648
N = parse(Int, readline())
A = [parse(Int, x) for x in split(readline())]

res = 0
old_h = 0
function uryu(res, old_h)
    for (i, h) in enumerate(A)
        diff = h - old_h
        if diff < 0
            res -= diff
        else
            old_h = h
        end
    end
    return res
end
println(uryu(0,0))

Measured memory_bytes: 198800
n = int(input())
nums = [int(input()) for _ in range(n)]
max_num = max(nums)
max_cnt = len([i for i in nums if i == max_num])

for i in range(n):
  if nums[i] < max_num or max_cnt > 1:
    print(max_num)
  else:
    print(max(set(nums) - set([nums[i]])))


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

int main() {
    int64_t L1 = 2, L2 = 1, L3;
    int N;
    cin >> N;
    if (N == 1) cout << L2;
    else {
        for (int i = 0; i < N - 1; i++)
        {
            L3 = L1 + L2;
            L1 = L2;
            L2 = L3;
        }
        cout << L2;
    }
}

Measured memory_bytes: 256
while True:
	n = int(raw_input())
	if n == 0:
		break
	
	re = []
	for _ in xrange(n):
		re.append(raw_input())
	
	n = int(raw_input())
	source = []
	for _ in xrange(n):
		source.append(raw_input().split()[0])
	
	for var in re:
		a,b = map(str,var.split())
		for i in xrange(len(source)):
			if source[i] == a:
				source[i] = b + "$"
	
	code = ""
	for i in xrange(len(source)):
		code += source[i][:1]
	
	print code

Measured memory_bytes: 10980
#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9){
        cout<<"hon"<<endl;
    }
    else if(n%10==0||n%10==1||n%10==6|n%10==8){
        cout<<"pon"<<endl;
    }
    else cout<<"bon"<<endl;
    return 0;
}

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

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x; return is;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define dump(x) cout << #x << " = " << (x) << endl

int main(){
    int n, d, l, a;
    double b, c;
    cin >> n >> d;

    vi xi(d);
    vvi x(n);
    rep(i,n){
        cin >> xi;
        x[i] = xi;
    };

    a = 0;
    rep(i,n-1){
        rep(j,n-i-1){
            l = 0;
            rep(k,d){
                l += (x[i][k]-x[j+i+1][k])*(x[i][k]-x[j+i+1][k]);
            }
            b = modf(sqrt(l), &c);
            if (b < 1e-8 || b > 1-1e-8) a++;
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(long long i = a; i < (b); ++i)
typedef long long ll;
 
int main() {
    int N;
    cin >> N;
    vector<long long>A(N);
    rep(i, 0, N){
        cin >> A[i];
    }
    int minasuC = 0;
    long long sum = 0;
    long long minA = 10000000000;
    rep(i, 0, N){
        if(A[i] < 0){
            minasuC++;
        }
        minA = min(abs(A[i]),minA);
        sum += abs(A[i]);
    }
    if(minasuC%2){
        sum = sum-minA*2;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int a, b;
	cin >> a >> b;
	if(a == 1){ a = 14; }
	if(b == 1){ b = 14; }
	puts(a > b ? "Alice" : a < b ? "Bob" : "Draw");
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] t = new long[N];
        long[] a = new long[N];
        for(int i = 0;i < N;i++){
            t[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }
        long A = 1;
        long B = 1;
        for(int i = 0;i < N;i++){
            long n = Math.max((A+t[i]-1)/t[i],(B+a[i]-1)/a[i]);
            A = n*t[i];
            B = n*a[i];
        }
        System.out.println(A+B);
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT32_MAX;

ll i,j;

ll N,W;
V w(100),v(100);
ll dp[100][100000+1];





int main(){
   cin>>N>>W;
   rep(i,N)cin>>w[i]>>v[i];
   ll sum=0;
   rep(i,N)sum+=v[i];
   rep(i,N)rep(j,sum+1)dp[i][j]=INF;

   for(ll x=0;x<N;x++){
      for(ll y=0;y<=sum;y++){
         if(y==0)dp[x][y]=0;
         else if(x==0){
            if(y==v[x])dp[x][y]=w[x];
            else dp[x][y]=INF;
         }
         else{
            if(v[x]>y)dp[x][y]=dp[x-1][y];
            else dp[x][y]=min(dp[x-1][y],dp[x-1][y-v[x]]+w[x]);
         }
      }
   }

   for(ll k=sum;k>=0;k--){
      if(dp[N-1][k]<=W){
         cout<<k<<endl;
         break;
      }
   }



}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
string s;
int a,b,c,sum=0;
int main()
{
    scanf("%d %d",&a,&b);
    for(int i=1;i<=a*b;i++)
    {
        cin>>s;sum++;
        if(s=="snuke")break;
    }
    c=sum%b==0?b:sum%b;
    printf("%c%.0lf",64+c,ceil((sum+0.00)/b));
    return 0;
}

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

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> P(D), C(D);

  for (int i = 0; i < D; i++) {
    cin >> P[i] >> C[i];
  }

  int res = 1 << 29;
  for (int bit = 0; bit < (1 << D); bit++) {
    int sum = 0, num = 0;
    for (int i = 0; i < D; i++) {
      if ((bit >> i) & 1) {
        sum += (i + 1) * 100 * P[i] + C[i];
        num += P[i];
      }
    }
    if (sum >= G)
      res = min(res, num);
    for (int i = D - 1; i >= 0; i--) {
      if ((bit >> i) & 1)
        continue;
      for (int j = 0; j < P[i] - 1; j++) {
        sum += (i + 1) * 100;
        num++;
        if (sum >= G) {
          res = min(res, num);
          break;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
li_h = list(map(int, input().split()))

li_kion = [{'index': idx + 1, 'abs': abs(a - (t - (h * 0.006)))} for idx, h in enumerate(li_h)]

print(sorted(li_kion, key=lambda x: x['abs'])[0]['index'])



Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;

llint a, b, c, d, e, f, g;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b >> c >> d >> e >> f >> g;
	
	llint ans = a/2*2+d/2*2+e/2*2;
	if(a%2 && d%2 && e%2) ans+=3;
	
	llint ans2 = 0;
	if(a && d && e){
		a--, d--, e--;
		ans2 += 3;
		ans2 += a/2*2+d/2*2+e/2*2;
	}
	ans = max(ans, ans2);
	ans += b;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int r, D, x2000;
int func(int N)
{
	if (N == 2000)return x2000;
	return r * func(N - 1) - D;
}

signed main()
{
	cin >> r >> D >> x2000;
	rep(i, 10)cout << func(2001 + i) << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
int col[100001][11];//col[v][d] i回目 キョリd 最大インデックス

ll N,M;
ll A[100001],B[100001];
ll Q;
ll V[100001],D[100001],C[100001];
vector<ll> G[100001];


int main()
{
	ll N,M;
	cin>>N>>M;
	rep1(i,M){
		cin>>A[i]>>B[i];
		G[A[i]].pb(B[i]);
		G[B[i]].pb(A[i]);
	}
	cin>>Q;
	rep1(i,Q){
		cin>>V[i]>>D[i]>>C[i];
		col[V[i]][D[i]]=max(col[V[i]][D[i]],(int)i);
	}
	
	rrep(d,10){
		rep1(i,N){
			rep(j,G[i].size()){
				col[i][d]=max(col[i][d],col[G[i][j]][d+1]);
			}
		}
	}
	
	rep1(i,N){
		int ans=0;
		rep(j,11){
			ans=max(ans,col[i][j]);
		}
		cout<<C[ans]<<endl;
	}
}

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

bool canSolve(const int n, vector<int> & in){
  if (in[0] != 0)return false;
  for(int i = 1;i < n;i++){
    if (in[i-1] + 1 < in[i])return false;
  }
  return true;
}

long long solve(const int n, vector<int> & in){
  if (!canSolve(n, in))return -1;
  long long ans = 0;
  int l = 0;
  while(l < in.size()){
    int r = l;
    for(;r < in.size();r++){
      if (in[l] + r - l != in[r])break;
    }
    ans += in[r-1];
    l = r;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  vector<int> in(n);
  for(int i = 0;i < n;i++){
    cin >> in[i];
  }
  cout << solve(n, in) << endl;
  return 0;
}


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

int main(){
    int h,w;
    while(cin >> h >> w && !(h==0 && w==0)){
        for(int i=0;i<h;++i){
            for(int j=0;j<w;++j){
                if((i+j)%2==0) cout << '#';
                else cout << '.';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  //データ入れ
  int N;
  cin >> N;
  vector<int> push(N);
  for(int i = 0; i < N; i++){
    cin >> push.at(i);
  }
  
  //ボタンを押す
  int count = 0, button = 1;
  for(int i = 0; i < N; i++){
    button = push.at(button-1);
    count++;
    if(button == 2){
      cout << count << endl;
      break;
    }
    if(i == N-1){
      count = -1;
      cout << count << endl;
      break;
    }
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define pb push_back
    #define mp make_pair
    const int N=305;
    const int mod=998244353;
    int a[N][N];
    int main()
    {
    	int n,m,i,j,k;
    	scanf("%i %i",&n,&m);
    	for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%i",&a[i][j]);
    	int r=0;
    	for(i=1;i<=m;i++)
    	{
    		bool ok=0;
    		for(j=r+1;j<=n;j++)
    		{
    			if(a[j][i])
    			{
    				for(k=i;k<=m;k++) swap(a[j][k],a[r+1][k]);
    				ok=1;
    				break;
    			}
    		}
    		if(!ok) continue;
    		r++;
    		for(j=r+1;j<=n;j++) if(a[j][i])
    		{
    			for(k=i;k<=m;k++) a[j][k]=(a[j][k]-a[r][k]+2)%2;
    		}
    	}
    	int ans=1,sol=1;
    	for(i=1;i<=n+m-1;i++) ans=ans*2%mod;
    	for(i=1;i<=n+m-r-1;i++) sol=sol*2%mod;
    	ans-=sol;
    	if(ans<0) ans+=mod;
    	printf("%i\n",ans);
    	return 0;
    }


Measured memory_bytes: 640
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  int A, B;
  cin >> A >> B;
  int answer = 0;
  for (int i = A; i <= B; ++i) {
    string s = to_string(i);
    int l = 0;
    int r = s.size() - 1;
    bool ok = true;
    while (l <= r) {
      if (s[l++] != s[r--]) {
        ok = false;
        break;
      }
    }
    if (ok) ++answer;
  }
  cout << answer << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

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

	vector<ll> a(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		a[i + 1] += a[i];
	}

	vector<ll> bits;
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			bits.emplace_back(a[j + 1] - a[i]);
		}
	}

	vector<ll> now = bits;
	for (ll i = 63; i >= 0; i--) {
		vector<ll> next;
		for (auto v : now) {
			if (v & (1LL << i)) {
				next.emplace_back(v);
			}
		}

		if (next.size() >= k) {
			now = next;
		}
	}

	ll ans = now[0];
	for (int i = 1; i < now.size(); i++) {
		ans &= now[i];
	}

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


Measured memory_bytes: 10092
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long
#define pii pair<int,int>

    ll a,b,n;
ll f(ll x)
{
    return a*x/b - a*(x/b);
}

void test_case()
{
    cin>>a>>b>>n;
    if(n>=b) {
        cout<<f(b-1);
    } else {
        // n < b
        cout<< f(n);
    }
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3616
N, H = map(int, input().split())
maxA, B = 0, 0
rec, recB = [], []

for i in range(N):
    a, b = map(int, input().split())
    rec.append((a, b))
    if a > maxA:
        maxA = a

n = N
for a, b in rec:
    if maxA >= b:
        n -= 1
    else:
        B += b
        recB.append(b)

if H - B <= 0:
    i = 0
    recB = sorted(recB, reverse=True)
    for k in recB:
        H -= k
        i += 1
        if H <= 0:
            print(i)
            break
else:
    ans = max((H - B) // maxA + ((H - B) % maxA != 0), 0)
    print(ans + n)


Measured memory_bytes: 18452
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<map>

using namespace std;

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
	return 0;
}

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

int main()
{
    int A, B;
    cin >> A >> B;
    int tap = 1;

    int ans = 0;
    while (tap < B)
    {
        tap += A - 1;
        ++ans;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=1e5 + 100;
ll A[MAX],res;
int main ()
{
    int N;
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> A[i];
        res+= abs(A[i]-A[i-1]);
    }
    res+=abs(A[N]);
    for(int i=1;i<=N;i++){
      int minus = abs(A[i-1]-A[i]) + abs(A[i]-A[i+1]);
      int plus = abs(A[i-1]-A[i+1]);
      cout<<res-minus+plus<<endl;
    }
    return 0;
}
/*
*/





Measured memory_bytes: 2048
#include <iostream>
#include <cstdio>
#define INF (1e9)
using namespace std;

int main(){
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    int sum[1001]={},in[1001]={};
  
    while(n--){
      int month,day,h,m,id;
      char IO;
      scanf("%d/%d %d:%d %c %d",&month,&day,&h,&m,&IO,&id);
      int t=(h*60)+m;
      if(IO=='I')in[id]=t;
      if(IO=='O'){
	if(in[0])sum[id]+=t-max(in[0],in[id]);
	for(int j=1;!id&&j<1000;j++) sum[j] += in[j]? t-max(in[0],in[j]):0;
	in[id]=0;
      }
    }
    int ans=0;
    for(int i=1;i<1000;i++)ans=max(ans,sum[i]);
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
int main()
{
	long x, y, z, k, l;
	std::vector<long> a, b, c;
	std::cin >> x >> y >> z >> k;
	for (int i = 0; i < x; i++)
	{
		std::cin >> l;
		a.push_back(l);
	}
	for (int i = 0; i < y; i++)
	{
		std::cin >> l;
		b.push_back(l);
	}
	for (int i = 0; i < z; i++)
	{
		std::cin >> l;
		c.push_back(l);
	}
	std::vector<long> buf1;
	for (unsigned int i = 0; i < a.size(); i++)
	{
		for (unsigned int j = 0; j < b.size(); j++)
		{
			buf1.push_back(a[i] + b[j]);
		}
	}
	std::sort(buf1.begin(), buf1.end(), std::greater<long>());
	std::vector<long> buf2;
	for (unsigned int i = 0; i < k; i++)
	{
		if (i >= buf1.size())
		{
			break;
		}
		buf2.push_back(buf1[i]);
	}
	std::vector<long> buf3;
	for (unsigned int i = 0; i < buf2.size(); i++)
	{
		for (unsigned int j = 0; j < c.size(); j++)
		{
			buf3.push_back(buf2[i] + c[j]);
		}
	}
	std::sort(buf3.begin(), buf3.end(), std::greater<long>());
	for (unsigned int i = 0; i < k; i++)
	{
		std::cout << buf3[i] << "\n";
	}
    return 0;
}



Measured memory_bytes: 43408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
    Int K, A, B;
    cin >> K >> A >> B;

    bool flag = false;

    if ((A-1)/K < B / K) flag = true;

    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;

}


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

using namespace std;

const int N = 1e5 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;

int n;
long long a[M], sum;
bool fizz = 0;
int main()
{
	scanf("%d", &n);
	for(int i = 1 ; i <= n; ++i)
	{
		if(a[i] % 3 == 0 && a[i] % 5 == 0 && i % 3 == 0 && i % 5 == 0)
		{
			fizz = 1;
		}
		else if(a[i] % 3 == 0 && i % 3 == 0)
		{
			fizz = 1;
		}
		else if(a[i] % 5 == 0 && i % 5 == 0 && fizz)
		{
			fizz = 1;
		}
		else
			sum += i;
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,N) for(int i=0;i<N;i++)

using namespace std;

const int INF = 1001001001;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
  
    int n;
    cin >> n;
  
    vector<int> h(n);
    rep(i,n) cin >> h[i];
  
    vector<int> dp(n,INF);
    dp[0] = 0; dp[1] = abs(h[1] - h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min( dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
	cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define int long long

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a, Ts... ts) {return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<char> t(q), d(q);
    REP(i, q) cin >> t[i] >> d[i];

    int ok = -1, ng = n;
    while(abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        int cur = mid;
        REP(i, q)
        {
            if(s[cur] == t[i]) cur += (d[i] == 'L' ? -1 : 1);
            if(cur < 0 || cur >= n) break;
        }
        if(cur < 0) ok = mid;
        else ng = mid;
    }
    int l = ok;

    ok = n, ng = -1;
    while(abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        int cur = mid;
        REP(i, q)
        {
            if(s[cur] == t[i]) cur += (d[i] == 'L' ? -1 : 1);
            if(cur < 0 || cur >= n) break;
        }
        if(cur >= n) ok = mid;
        else ng = mid;
    }
    int r = ok;

    cout << r - l - 1 << endl;
}

Measured memory_bytes: 976
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

P v[225816];
int n;
ll x[225816],segtree[816225][2];
bool delayed[816225];

void init(int i=0, int l=0, int r=n){
	if(r-l>1){
		init(i*2+1,l,(l+r)/2);
		init(i*2+2,(l+r)/2,r);
	}else{
		segtree[i][0] = v[l].second;
	}
}

void eval(int i, int l, int r){
	if(delayed[i]){
		segtree[i][0] += segtree[i][1];
		if(r-l>1){
			segtree[i*2+1][1] += segtree[i][1];
			segtree[i*2+2][1] += segtree[i][1];
			delayed[i*2+1] = true;
			delayed[i*2+2] = true;
		}
		segtree[i][1] = 0ll;
		delayed[i] = false;
	}
}

void update(int a, int b, ll v, int i=0, int l=0, int r=n){
	eval(i,l,r);
	if(b<=l || r<=a){
		return;
	}else if(a<=l && r<=b){
		segtree[i][1] += v;
		delayed[i] = true;
		eval(i,l,r);
	}else{
		update(a,b,v,i*2+1,l,(l+r)/2);
		update(a,b,v,i*2+2,(l+r)/2,r);
	}
}

ll query(int a, int b, int i=0, int l=0, int r=n){
	eval(i,l,r);
	if(b<=l || r<=a){
		return 0ll;
	}else if(a<=l && r<=b){
		return segtree[i][0];
	}else{
		return query(a,b,i*2+1,l,(l+r)/2)+query(a,b,i*2+2,(l+r)/2,r);
	}
}

int main(void){
	int i,d,a,j;
	ll h,ans=0ll;
	cin >> n >> d >> a;
	for(i=0; i<n; ++i){
		cin >> x[i] >> h;
		v[i] = P(x[i],(h-1)/a+1);
	}
	sort(x,x+n);
	sort(v,v+n);
	init();
	for(i=0; i<n; ++i){
		j = (int)(upper_bound(x,x+n,x[i]+d*2)-x);
		h = max(query(i,i+1),0ll);
		ans += h;
		update(i,j,-h);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 16384