akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

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

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

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

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

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

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

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

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

fn gcd(x: usize, y: usize)->usize{
    if y == 0{
        return x
    }
    gcd(y, x % y)
}

fn main() {
    input! {
        n: usize,
    }
    let ans = if n <= 999{ "ABC"} else {"ABD"};
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int s_to_i(char ch)
{

	return ch-'0';
}
int main()
{
	string s;
	cin>>s;
	int miniiii = 1e9 + 80;
	int len = s.length();
	for(int i=2; i<len; i++)
	{
		int temp = s_to_i(s[i]) + s_to_i(s[i-1])*10 + s_to_i(s[i-2])*100;
		miniiii = min(miniiii,abs(753-temp));	
	}
	cout<<miniiii<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        sc.close();

        if (a == b) {
            System.out.println(c);
        } else if (a == c) {
            System.out.println(b);
        } else {
            System.out.println(a);
        }

    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <stdlib.h>
int main(){
  int t,n,h[100],i,j,k,s;

  scanf("%d",&t);
    for(i=0;i<t;i++){
      scanf("%d",&n);
      for(j=0;j<n;j++){
        scanf("%d",&h[j]);
      }
      for(j=0;j<n-1;j++){
        h[j] = h[j+1]-h[j];
      }
      if(n==2){
        if(h[0]>=0)printf("%d 0\n",h[0]);
        else printf("0 %d\n",abs(h[0]));
        }
      else{
        for(j=0;j<n-2;j++){
          for(k=0;k<n-2;k++){
            if(h[k]<h[k+1]){
              s=h[k];
              h[k]=h[k+1];
              h[k+1]=s;
            }
          }
        }
        if(h[0]<0)h[0]=0;
        if(h[n-2]>0)h[n-2]=0;
        printf("%d %d\n",h[0],abs(h[n-2]));
        }
    }
  return 0;
}

Measured memory_bytes: 596
class MinHeap
  def initialize(arr)
    @heap = []
    arr.each { |e| up_heap(e) }
  end

  def peek
    @heap[1]
  end

  def up_heap(x)
    @heap << nil if @heap == []

    @heap << x
    idx = @heap.size - 1

    while idx != 1
      parent = idx / 2
      break if @heap[idx] > @heap[parent]

      @heap[idx], @heap[parent] = @heap[parent], @heap[idx]
      idx = parent
    end
  end

  def down_heap
    return @heap.pop if @heap.size <= 2

    min = @heap[1]
    @heap[1] = @heap.pop
    idx = 1
    size = @heap.size

    while idx * 2 < size
      l = idx * 2
      r = l + 1

      if @heap[r]
        child = @heap[l] < @heap[r] ? l : r
      else
        child = l
      end

      break if @heap[idx] < @heap[child]

      @heap[idx], @heap[child] = @heap[child], @heap[idx]
      idx = child
    end

    min
  end

  def to_a
    @heap.shift
    @heap
  end

  alias_method :<<, :up_heap
  alias_method :push, :up_heap
  alias_method :shift, :down_heap
end

n, m = gets.split.map(&:to_i)
q = MinHeap.new(gets.split.map(&:to_i))
b, c = Array.new(m) { gets.split.map(&:to_i) }.transpose
count = 0

b.zip(c).sort_by { |x, y| -y }.each do |x, y|
  x.times do
    break if q.peek >= y || count == n

    q.shift
    q << y
    count += 1
  end
end

puts q.to_a.sum

Measured memory_bytes: 32584
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

struct Sieve{
  ll n;
  vector<ll> f, primes;
  Sieve(ll n = 1): n(n), f(n+1, 0){
    f[0] = f[1] = -1;
    for(ll i = 2; i <= n; i++){
      if(f[i]) continue;
      primes.emplace_back(i);
      f[i] = i;
      for(ll j = i*i; j <= n; j += i) if(!f[j]) f[j] = i;
    }
  }
  bool isPrime(const ll x){ return f[x] == x; }
  vector<ll> factorList(ll x){
    vector<ll> res;
    for(ll p : primes){
      while(x%p == 0){
        res.push_back(p);
        x /= p;
      }
    }
    if(x != 1) res.push_back(x);
    return res;
  }
  vector<pair<ll, ll>> factor(const ll x){
    vector<ll> fl = factorList(x);
    if(fl.size() == 0) return {};
    vector<pair<ll, ll>> res(1, pair<ll, ll>(fl[0], 0));
    for(ll p : fl){
      if(res.back().first == p) res.back().second++;
      else res.emplace_back(pair<ll, ll>(p, 1));
    }
    return res;
  }
};

int main(void){
  ll n;
  cin >> n;
  Sieve s(1000000);
  auto fl = s.factor(n);
  ll ans = 0;
  for(auto p : fl){
    ll num = p.first;
    ll m = p.second;
    for(ll i = 1; i <= m; i++){
      ans++;
      m -= i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12104
#include<bits/stdc++.h>
#define long long long
using namespace std;
int mat[505][505];
struct data
{
  int a,b,c,d;
};
vector<data>ans;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n,m;cin>>n>>m;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
    {
      cin>>mat[i][j];
    }
  }
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<m;j++)
    {
      if(mat[i][j]%2)
      {
        ans.push_back({i,j,i,j+1});
        mat[i][j+1]++;
      }
    }
  }
  for(int i=1;i<n;i++)
  {
    if(mat[i][m]%2)
    {
      ans.push_back({i,m,i+1,m});
      mat[i+1][m]++;
    }
  }
  cout<<ans.size()<<endl;
  for(auto x:ans)
    cout<<x.a<<" "<<x.b<<" "<<x.c<<" "<<x.d<<endl;
  return 0;
}


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

const int MAX = 1000000;
vector<int> D(MAX+1);

void pre(){

    for(int i=1;i<=MAX;i++)
        D[i] = i;

    vector<bool> is_prime(MAX+1,true);
    for(int i=2;i*i<=MAX;i++){
        if(!is_prime[i]) continue;
        else{
            for(int j=i;j<=MAX;j+=i){
                is_prime[j] = false;
                D[j] = min(D[j],i);
            }
        }
    }
}

int main(){

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

    pre();
    vector<bool> primes(MAX+1,false);
    bool is_pairwise = true;
    for(int i=0;i<N;i++){
        int a = A[i];
        while(a > 1){
            if(primes[D[a]]){
                is_pairwise = false;
                break;
            }
            else{
                int t = D[a];
                primes[t] = true;
                do{ a /= t; }while(D[a] == t);
            }
        }
        if(!is_pairwise) break;
        /*int a = A[i];
        int d = D[a];
        while(d != a){
            if(!primes[d]){
                primes[d] = true;
                while(a % d == 0 && a != d)
                    a /= d;
                d = D[a];
            }
            else{
                is_pairwise = false;
                break;
            }
        }
        if(!is_pairwise) break;
        primes[d] = true;*/
    }

    bool is_setwise = false;
    int tmp = A[N-1];
    while(N > 1){
        tmp = gcd(tmp,A[N-2]);
        if(tmp == 1){
            is_setwise = true;
            break;
        }
        else N--;
    }

    if(is_pairwise)
        cout << "pairwise coprime";
    else if(is_setwise)
        cout << "setwise coprime";
    else
        cout << "not coprime";

    return 0;
}

Measured memory_bytes: 11352
def form(a)
	a.each_with_index do |val,i|
		print val
		if i == $n - 1
			print "\n"
		else
			print " "
		end
	end
end

$n = gets.chomp.to_i
l=[]
$n.times do 
	u, k, *v = gets.chomp.split(" ").map(&:to_i)
	l[u] = v
end

m=Array.new($n+1){Array.new($n, 0)}

l.each_with_index do |arr,i|
	if arr == nil
		m[i] = nil
		next
	end
	arr.each do |val|
		m[i][val-1] = 1
	end
end

m.each do |a|
	form(a) if a
end


Measured memory_bytes: 6964
n=int(input())
A=list(map(int,input().split()))
ruiseki=[0]
for i in range(n):
    ruiseki.append(ruiseki[i] + A[i])

l=1
r=3
ans=[]
for sikiri in range(2,n-1):
    while( ruiseki[sikiri] > 2*ruiseki[l] ):
        l+=1
    if(ruiseki[sikiri] - 2*ruiseki[l-1] <abs(ruiseki[sikiri] - 2*ruiseki[l])):
        l-=1
    r_sum=ruiseki[-1] - ruiseki[sikiri]
    while( r_sum > 2*(ruiseki[r] - ruiseki[sikiri])):
        r+=1
    if( r_sum- 2*(ruiseki[r-1] - ruiseki[sikiri]) <= 2*(ruiseki[r] - ruiseki[sikiri]) - r_sum ):
        r-=1

    if(l<sikiri and sikiri < r):
        tmp=[ruiseki[l],ruiseki[sikiri]-ruiseki[l],ruiseki[r]-ruiseki[sikiri],ruiseki[-1]-ruiseki[r]]
        ans.append(max(tmp) - min(tmp))

print(min(ans))

Measured memory_bytes: 28956
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
const int mod=1000000007;
int main(){
    int h,w;cin>>h>>w;
    vector<string> s(h);
    vector<vector<int>> rightx(h,vector<int>(w,-1));
    vector<vector<int>> righty(h,vector<int>(w,-1));
    rep(i,h)cin>>s[i];
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#')continue;
            int tmpx=1;
            int tmpy=1;
            if(rightx[i][j]==-1){
                for(int x=j+1;x<w;x++){
                    if(s[i][x]=='#') break;
                    tmpx++;
                }
                for(int x=j-1;x>=0;x--){
                    if(s[i][x]=='#') break;
                    tmpx++;
                }
                for(int x=j+1;x<w;x++){
                    if(s[i][x]=='#') break;
                    rightx[i][x]=tmpx;
                }
                for(int x=j-1;x>=0;x--){
                    if(s[i][x]=='#') break;
                    rightx[i][x]=tmpx;
                }
                rightx[i][j]=tmpx;
            }
            if(righty[i][j]==-1){
                for(int y=i+1;y<h;y++){
                    if(s[y][j]=='#') break;
                    tmpy++;
                }
                for(int y=i-1;y>=0;y--){
                    if(s[y][j]=='#') break;
                    tmpy++;
                }
                for(int y=i+1;y<h;y++){
                    if(s[y][j]=='#') break;
                    righty[y][j]=tmpy;
                }
                for(int y=i-1;y>=0;y--){
                    if(s[y][j]=='#') break;
                    righty[y][j]=tmpy;
                }
                righty[i][j]=tmpy;
            }
            ans=max(ans,rightx[i][j]+righty[i][j]-1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 42640
A,B,C = map(int,input().split())
l = [A*B,B*C,A*C]

l[0] *= abs(C//2-(C-C//2))
l[1] *= abs(A//2-(A-A//2))
l[2] *= abs(B//2-(B-B//2))

print(min(l))

Measured memory_bytes: 3060
/*************************************************/
//abc154C
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b) {
  return *(int*) a - *(int*) b;
}

int main(void) {
  int n, i;
  scanf(" %d", &n);
  int a[n];

  for(i=0; i < n; i++) scanf(" %d", &a[i]);
  qsort(a, n, sizeof(int), compare_int);

  for(i=0; i < n - 1; i++)
    if(a[i] == a[i + 1]){
      printf("NO");
      return 0;
    }
  printf("YES");
  return 0;
}

/*************************************************/


Measured memory_bytes: 1788
"""
最大公約数を追い求める。

少なくとも、Aの合計値より答えが大きくなることはない。
なぜなら、どんなに頑張ってもA同士の差分はAの合計値以下になるからである。

答えの最大値はAの合計値。
マイナスを作る必要はない。
0を作る必要はある。

やっぱり、Aの合計値の約数のどれかが答えになりそうだな。証明はできないけど。
Aの合計値の約数を大きいものから順に、実現可能かどうかを検証していけばよい。

"""

from itertools import accumulate

N,K = map(int,input().split())
A = list(map(int,input().split()))
sumA = sum(A)

yakusu = []
d = 1
while d*d < sumA:
    if sumA%d == 0:
        yakusu.append(d)
        yakusu.append(sumA//d)
    d += 1
if d*d == sumA:
    yakusu.append(d)
yakusu.sort(reverse=True)
for d in yakusu:
    #約数の大きい順に、実現可能かどうかを試していく。
    rest = [a%d for a in A]
    rest.sort()
    Rrest = [d-r for r in rest]
    Rrest = Rrest[::-1]
    rest = [0]+list(accumulate(rest))
    Rrest = [0]+list(accumulate(Rrest))
    for i in range(N+1):
        if rest[i] == Rrest[N-i]:
            if rest[i] <= K:
                print(d)
                exit()
            break

Measured memory_bytes: 74244
#include <stdio.h>
int main(){
 int i,n,v[20]={},c[20]={},ans=0;
 scanf("%d",&n);
 for(i=0;i<n;i++)scanf("%d",&v[i]);
 for(i=0;i<n;i++)scanf("%d",&c[i]);
 for(i=0;i<n;i++)if(v[i]>c[i])ans+=v[i]-c[i];
 printf("%d\n",ans);
 return 0;
}


Measured memory_bytes: 128
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const array <ll,2> &a,const array <ll,2> &b){
    return a[1]<b[1];
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};
ll N=5e5+2;



int main(){
    IOS;
    make(ll,n);
    vector <ll> a(n),b(n);
    fr(i,n) cin>>a[i]>>b[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    if(n%2==1){
        cout<<b[n/2]-a[n/2]+1<<endl;
    }
    else{
        double aa=(double)a[n/2]+(double)a[n/2-1];
        double bb=(double)b[n/2]+(double)b[n/2-1];
        aa/=2; bb/=2;
        cout<<(ll)(2*(bb-aa)+1)<<endl;
    }


    return 0;
}


Measured memory_bytes: 6352
#include<iostream>
using namespace std;
 
const int MAX_N = 110;
const int INF = 1e8;
int d[MAX_N][MAX_N];
int cost[MAX_N][MAX_N];
 
int main(){
  int N,M;
  cin >> N >> M;
  for(int i = 0 ; i < N  ; i++){
    for(int j = 0 ; j < N ; j++){
      cost[i][j] = d[i][j] = INF;
      if(i == j)d[i][j] = 0;
    }
  }
 
  for(int i = 0 ; i < M ; i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    cost[a][b] = d[a][b] =  c;
    cost[b][a] = d[b][a] =  c;
  }
  
  for(int k = 0 ; k < N ; k++){
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
	  if(d[i][k] + d[k][j] < d[i][j]){
	  d[i][j] = d[i][k] + d[k][j];
	}
      }
    }
  }
 
  int ans = 0;
  for(int i = 0 ; i < N ; i++){
    for(int j = i+1 ; j < N ; j++){
      if(cost[i][j] > d[i][j] && cost[i][j] != INF)ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(){
  int N;
  cin >> N;
  long long a[N+1];
  a[0]=2; a[1]=1;
  for(int i=0; i<N; i++){
    a[i+2]=a[i+1] + a[i];
  }
  cout << a[N] << endl;
 }

Measured memory_bytes: 256
A, B, C, X, Y = map(int, raw_input().split())
ans = 0
if A + B < C * 2:
  ans = A*X+B*Y
else:
  num_ab_a = X*2
  num_b_a = 0 if Y-X < 0 else Y-X
  ans_a = C*num_ab_a+B*num_b_a
  num_ab_b = Y*2
  num_a_b = 0 if X-Y < 0 else X-Y
  ans_b = C*num_ab_b+A*num_a_b
  ans = ans_a if ans_a < ans_b else ans_b
print ans


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

#define rep(i, e) for (int i = 0; i < e; i++)
#define repp(i, s, e) for (int i = s; i < e; i++)
#define N_Max 100
#define Card_Max 36
#define ll long long

int main()
{
    int n, k, a[105] = {}, minv = 0, sum = 0;
    cin >> n >> k;
    rep(i, n)
    {
        cin >> a[i];
        minv = min(2 * a[i], 2 * (k - a[i]));
        sum += minv;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
function ABC_D()
    readint()=parse.(Int,readline())
    N=readint()
    s=0

    function nth(x,N)
        a=N÷x
        x*a*(a+1)÷2
    end
    for i in 1:N
        s+=nth(i,N)
    end
    print(s)
end

ABC_D()

Measured memory_bytes: 160732
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int a,b;
	cin>>a>>b;
	if(a<=9 && b<=9)
		cout<<a*b;
	else 
		cout<<"-1";
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	//public static int N,K,a=-1;
	public static String ans="",s;

	//public static int a[][]=new int[5][5];

	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		System.out.println(Math.abs(a[n-1]-a[0]));
	}
}

Measured memory_bytes: 22996
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int main() {
	char in[4];
	scanf("%s", in);

	int ans = 700;
	for (int i = 0; i < 3; i++) if (in[i] == 'o') ans += 100;
	return !printf("%d\n", ans);
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(std::vector<long long> A){
  if(A[0]+A[1]+A[2]>=22)
    std::cout << "bust" << std::endl;
  else
    std::cout << "win" << std::endl;
}

int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
#define csanf scanf

int main(){
	string s;cin>>s;
	rep(i,1<<3){
		int sum=s[0]-'0';
		rep(j,3){
			if(i>>j&1){
				sum+=s[j+1]-'0';
			}
			else sum-=s[j+1]-'0';
		}
		if(sum==7){
			cout<<s[0];
			rep(j,3){
				if(i>>j&1)cout<<'+';
				else cout<<"-";
				cout<<s[j+1];
			}
			cout<<"=7"<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	cout << n * n * n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	int n;
	double t,a;
	cin >> n;cin >> t >> a;
	vector <int> h(n);
	for(int i = 0;i < n;++i) cin >> h[i];
	pair <double,int> minn = {2e18,-1};
	for(int i = 0;i < n;++i){
		double cc = t - 0.006 * h[i];
		if(abs(cc - a) < minn.first){
			minn.first = abs(cc - a);
			minn.second = i + 1;
		}
	}
	cout << minn.second << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3752
long d['~~'];A,x,i,j;main(n){for(scanf("%d%d",&n,&A),d[n*=A]=1;~scanf("%d",&x);i=5e3-i)for(x-=A,j=2*n;j--;)d[5000-i+j]=d[i+j]+(j>x)*d[i+j-x];printf("%ld",d[i+n]-1);}

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

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

  long long a[n], b[n];
  for (int i=0; i<n; i++) {
    int na, nb;
    cin >> na >> nb;
    a[i] = na;
    b[i] = nb;
  }

  long long ans = 0;
  for (int i=n-1; i>=0; i--) {
    if (b[i] == 1 ) {
      continue;
    }

    if ((a[i] + ans) % b[i] == 0) {
      continue;
    }

    int cnt = b[i] - (a[i] + ans) % b[i];

    ans += cnt;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1920
X = int(input())

A = 0
B = 0
test = 10**3
for i in range(-test, test):
	a = (X + i**5)**0.2
	if type(a) == float:
		if round(a, 10).is_integer():
			A, B = int(a), i
			break
print(A, B)

Measured memory_bytes: 9440
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        mut n: Chars,
    };

    let a = n.pop().unwrap().to_digit(10).unwrap();

    let ans = if a == 2 || a == 4 || a == 5 || a == 7 || a == 9 {
        "hon"
    } else if a == 0 || a == 1 || a == 6 || a == 8 {
        "pon"
    } else {
        "bon"
    };

    println!("{}", ans)
}


Measured memory_bytes: 2096
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
 
using namespace std;
 
using ll = long long;
using ld = long double;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }
 
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }
 
template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}
 
struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};
 
void solve(ll Q, ll H, ll S, ll D, ll N) {
  chmin(H, Q * 2);
  chmin(S, H * 2);
  chmin(D, S * 2);
  if (D < S * 2) { cout << N / 2 * D + N % 2 * S << endl; }
  else cout << S * N << endl;
}
 
int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll D;
	ll N;
	ll H;
	ll Q;
	ll S;
	scanf("%lld", &Q);
	scanf("%lld", &H);
	scanf("%lld", &S);
	scanf("%lld", &D);
	scanf("%lld", &N);
	solve(Q, H, S, D, N);
	return 0;
}

Measured memory_bytes: 384
A, B = map(int, input().split())

#maxA = A+0.99
#maxB = B+0.99

maxA = A+1
maxB = B+1

gAmin = A/8 * 100
gAmax = maxA/8 * 100

gBmin = B*10
gBmax = maxB * 10

#print(gAmin)
#print(gAmax)
#print(gBmin)
#print(gBmax)

if gAmax <= gBmin or gBmax <= gAmin:
    ans = -1
elif gAmin <= gBmin:
    ans = gBmin
else:
    ans = gAmin

if ans - int(ans) > 0:
    ans = int(ans) + 1

print(int(ans))


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int a,b;
  cin >> a >> b;
  cout << max(0,a-2*b) << endl;
}

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

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
Arrays.sort(a);
		int sum=0;
for(int i=0;i<n-1;i++)sum+=a[i];
	if(a[n-1]<sum) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}

	}
	}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

const int maxN = 150010;
const int MAXM = 310;
const int MAXK = 17;
const int MOD = 1000000007;
const ll INF = 10000000000000000LL;
const ll inf = 5000000000000LL;


int main()
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int ans = (a-c) * (b-d);
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var EOF    = '0';
  var inputs = stdin.toString().trim().split('\n');

  (function(array) {

    array.forEach(function(x, index) {
      console.log('Case', index + 1 +':', x);
    });

  })(inputs.slice(0, inputs.indexOf(EOF)));

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 20688
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);


const [h, n] = input[0].split(" ").map((x: string): number => +x);
const a = input[1].split(" ").map((x: string): number => +x);

let tmp = 0;

for (let i = 0; i <n; i++){
    tmp += a[i];
}

if (tmp >= h){
    console.log('Yes');
}else{
    console.log('No');
}

Measured memory_bytes: 16716
#include <iostream>
using namespace std;
int insertionSort(int N,int A[]){
  int v,j;
  for(int i = 0; N > i; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j + 1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(int i = 0; N > i; i++){
      cout << A[i];
      if(N == i + 1) {
        cout << endl;
      } else {
        cout << " ";
      }
    }
  }
}

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


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

int main() {
  int N, M;
  cin >> N >> M;
  
  if (N >= M) {
    cout << '0' << endl;
    return 0;
  }
  
  vector<int> X(M);
  for (int i = 0; i < M; ++i) cin >> X[i];
  
  sort(X.begin(), X.end());
  vector<int> dis;
  for (int i = 0; i < M - 1; ++i)
    dis.push_back(X[i+1] - X[i]);
  
  sort(dis.begin(), dis.end());
  for (int i = 0; i < N - 1; ++i) 
    dis.pop_back();
  
  cout << accumulate(dis.begin(), dis.end(), 0) << endl;
}

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

int p[25] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int m[25];
int ans = 0;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < 25; i++) {
        int tmp = n;
        while (tmp > 0) {
            tmp /= p[i];
            m[i] += tmp;
        }
    }

    if (m[0] >= 74) {
        ans++;
    }

    for (int i = 0; i < 25; i++) {
        for (int j = 0; j < 25; j++) {
            if (i == j) { continue; }
            if (m[i] >= 2 && m[j] >= 24) { ans++; }
            if (m[i] >= 4 && m[j] >= 14) { ans++; }
            for (int k = 0; k < 25; k++) {
                if (i == k || j == k) { continue; }
                if (m[i] >= 2 && m[j] >= 4 && m[k] >= 4 && j < k) { ans++; }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 888
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

   
    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var input = Reads();
        var n = input[0];
        var k = input[1];
        var h = new long[n];
        for(int i = 0; i < n; i++)
        {
            h[i] = Read();
        }
        Array.Sort(h);
        long min = long.MaxValue;
        for(int i = 0; i < n-k+1; i++)
        {
            if (min > h[k + i - 1] - h[i])
                min = h[k + i - 1] - h[i];
        }

        Console.WriteLine(min);

        Console.Out.Flush();
    }
}

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

int main() {
    int n,f; cin >> n >> f;
    vector<string> info[100];
    rep(i,n) {
        int m; cin >> m;
        rep(j,m) {
            string t; cin >> t;
            info[i].push_back(t);
        }
    }

    map<pair<string,string>, int> mm;
    rep(i,n) {
        rep(j,info[i].size()) {
            for (int k=j+1; k<info[i].size(); k++) {
                auto fi = min(info[i][j], info[i][k]);
                auto la = max(info[i][j], info[i][k]);
                mm[make_pair(fi,la)] ++;
            }
        }
    }
    vector<pair<string,string>> ans;
    for (auto iter = mm.begin(); iter != mm.end(); iter++) {
        auto key = iter->first;
        auto val = iter->second;
        if (val < f) continue;
        ans.push_back(key);
    }
    sort(ans.begin(),ans.end());
    cout << ans.size() << endl;
    for (auto i: ans) {
        cout << i.first << ' ' << i.second << endl;
    }
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, d; 
  cin>>a>>b>>c>>d;
  ll ans[4];
  ans[0] = a*c, ans[1] = a*d, 
  ans[2] = b*c, ans[3] = b*d;
  // sort(all(ans));
  cout<<max({ans[0], ans[1], ans[2], ans[3]})<<"\n";
  return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
namespace csharptest
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int[] ansa = new int[10000];
            int[] ansb = new int[10000];
            int count=0;
            do
            {
                ansa[count]=0;
                ansb[count]=0;
                int n = int.Parse(str);
                for (int m = 0; m < n; m++)
                {
                    int a, b;
                    string[] s = Console.ReadLine().Split(' ');
                    a = int.Parse(s[0]);
                    b = int.Parse(s[1]);
                    if (a > b)
                    {
                        ansa[count] += a + b;
                    }
                    else if (a < b)
                    {
                        ansb[count] += a + b;
                    }
                    else
                    {
                        ansa[count] += a;
                        ansb[count] += b;
                    }
                }
                str=Console.ReadLine();
                count++;
            } while (str != "0");
            for (int n = 0; n < count; n++)
            {
                Console.WriteLine(ansa[n] + " " + ansb[n]);
            }
        }
    }
}

Measured memory_bytes: 5860
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a=0,b=0;
	int ans=0;
	for(int i=n-1;i>=1;i--)
	{
		a+=i;
	}
	for(int i=m-1;i>=1;i--)
	{
		b+=i;
	} 
	ans=a+b;
	cout<<ans<<endl;
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/24  Problem: 011_agc_b / Link: https://agc011.contest.atcoder.jp/tasks/agc011_b?lang=en  ----- */
/* ------問題------

すぬけ君は，N 匹の変わった生き物を見つけました． それぞれの生き物には色と大きさが定まっており，i 番目の生き物の色は i，大きさは Ai で表されます．
どの生き物も，大きさが自分の 2 倍以下であるような他の生き物を吸収することができます． 大きさ A，色 B の生き物が大きさ C，色 D の生き物を吸収すると (C≤2×A)，合体して大きさ A+C，色 B の生き物になります． ここで，2 匹の生き物の大きさによっては，どちらも他方を吸収することが可能な場合があります．
すぬけ君がこの生き物たちを観察していると，合体を繰り返して，最終的に 1 匹になりました． このとき，残った生き物の色として考えられるものは何種類あるかを求めてください．

-----問題ここまで----- */
/* -----解説等-----

昇順に並べ、ある個体に着目したときその個体より手前の体重の総和が次の個体の半分以上であればよい。
この考えでは着目している個体の次の個体が生存できないといけないので、後ろからやれば良い。

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	RSORT(a);
	VL sum(N + 1, 0);
	FOR(i, 0, N) {
		sum[i + 1] += sum[i] + a[i];
	}

	ans = 1;
	FOR(i, 1, N) {
		if (2 * (sum[N] - sum[i]) >= a[i-1]) {
			ans++;
		}
		else break;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int n,wl;
	cin>>n>>wl;
	
	vector<int> w(n),v(n);
	REP(i,n) cin>>w[i]>>v[i];
	
	vector<llong> dp(wl+1,0);//重さiにおける最大価値dp[i].
	REP(i,n){
		for(int j=wl;j>=w[i];--j){
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
		}
	}
	
	cout<<dp[wl]<<endl;
	return 0;
}//解答参考.

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
 
typedef pair<int,int> pr;
typedef pair<int,pr > ppr;
const int INF=2<<20;

int cake[7];
int m,n,k,d;
int number(string s){
	if(s=="H")
		return 0;
	if(s=="D")
		return 1;
	if(s[0]=='C')
		return s[1]-'0'+1;
	else{
		int number=0;
		for(int i=1;i<s.size();i++){
			number*=10;
			number+=s[i]-'0';
		}
		return number+10;
	}
	return 0;
}
int cakes(int j){
	int sum=0;
	for(int i=0;i<6;i++)
		if((1<<i) & j)
			sum+=cake[i];
	return sum;
}
int main() {
	// your code goes here
	while(cin >> m >> n >> k >> d && d!=0){
		for(int i=0;i<6;i++)
		cake[i]=0;
		string pointA,pointB;
		int dist=0;
		int longs[120][2000]={};
		for(int i=0;i<120;i++)
			for(int j=0;j<2000;j++)
					longs[i][j]=INF;
		longs[0][0]=0;
		vector<pr > root[120];
		for(int i=0;i<m;i++)
			cin >> cake[i];
		for(int i=0;i<d;i++){
		cin >> pointA >> pointB >> dist;
		root[number(pointA)].push_back(pr(dist,number(pointB)));
		root[number(pointB)].push_back(pr(dist,number(pointA)));
		}
		priority_queue<ppr ,vector<ppr>,greater<ppr> > qu;
		qu.push(ppr(0,pr(0,0)));
		while(!qu.empty()){
			int dist=qu.top().first,s=qu.top().second.first,bits=qu.top().second.second;
			qu.pop();
			if(dist!=longs[s][bits]) continue;
			if(2<=s && s<=9)
			longs[s][bits|(int)pow(2,s-2)]=dist;
			//cout << dist << " "  << s << " " << bits << " " <<endl;
			for(int i=0;i<root[s].size();i++){
				int target=root[s][i].second;
				if(2<=s && s<=9 && (int)pow(2,target-2)&bits) continue;
				int nextLong=dist+root[s][i].first;
				if(2<=s && s<=9){
					int canum=bits|(int)pow(2,s-2);
					if(nextLong<longs[target][canum]){
						longs[target][canum]=nextLong;
						qu.push(ppr(nextLong,pr(target,canum)));
					}
				}
				else if(nextLong<longs[target][bits]){
					longs[target][bits]=nextLong;
					qu.push(ppr(nextLong,pr(target,bits)));
				}

			}
		}
		int minim=INF;
		for(int i=0;i<(1<<m+1);i++)
		minim=min(minim,longs[1][i]*k-cakes(i));
		cout << minim << endl;
	}
	return 0;
}

Measured memory_bytes: 2268
//#pragma Gbb optimize("Ofast") 
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<time.h>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;

string s;
char a[2] = { 'h','i' };

int main()
{
	cin >> s;
	int l = s.length();
	if (l % 2 == 0)
	{
		int j = 0;
		bool f = 1;
		for (int i = 0; i < l; i++)
			if (a[j] == s[i]) j = 1 - j;
			else
			{
				f = 0;
				break;
			}
		if (f) cout << "Yes";
		else cout << "No";
	}
	else cout << "No";
	return 0;
}

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

int main() {
  
  char s[5];
  cin >> s;
  
  int ans = 0;
  
  for (int i = 0; i < 4; i++) {
    if(s[i] == '+') ans++;
    else ans--;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main(){
    ll N, D;
    cin >> N >> D;
    
    vector<ll> x(N);
    vector<ll> y(N);
    REP(i, N){
        cin >> x[i] >> y[i];
    }

    int ans = 0;
    REP(i, N){
        if (x[i]*x[i] + y[i]*y[i] <= D*D){
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6424
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> p(200010),q(200010);
    vector<vector<ll> > vp(1010,vector<ll>(2020));
    vector<vector<ll> > vq(1010,vector<ll>(2020));
    rep(sss,m){
        ll a,b;
        cin >> a >> b;
        if(b>=1000){
            for(int i=b-a;i<=n;i+=b){
                if(i>=0){
                    p[i]--;
                    p[i+1]++;
                    q[i]-=b-1;
                }
            }
            p[1]++;
            if(b-a!=1)q[1] += a;
            else q[1]-=1;
        }else{
            int s,t;
            s = b-a+1;
            t = 2*b-a;
            vp[b][s]++;
            vp[b][t]--;
            vq[b][t]-=b-1;
        }
       
    }
    // rep(i,n+1)cout << p[i] << " ";
    // cout << endl;

    // rep(i,n+1)cout << q[i] << " ";
    // cout << endl;
    // cout << endl;
    for(int i=2;i<=n+1;i++){
        p[i] += p[i-1];
    }
    for(int i=1;i<=n+1;i++){
        p[i] += q[i];
    }
    for(int i=2;i<=n+1;i++){
        p[i] += p[i-1];
    }
    for(int i=1;i<1000;i++){
        for(int j=1;j<=2*i;j++){
            vp[i][j] += vp[i][j-1];
        }
        for(int j=1;j<=2*i;j++){
            vp[i][j] += vq[i][j];
        }
        for(int j=1;j<=2*i;j++){
            vp[i][j] += vp[i][j-1];
        }
    }
    // rep(i,n+1)cout << p[i] << " ";
    // cout << endl;
    // for(int i=0;i<10;i++){
    //     for(int j=0;j<15;j++){
    //         cout << vp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    for(int i=1;i<=n;i++){
        ll ans = p[i];
        for(int j=1;j<1000;j++){
            ans += vp[j][i%j];
            ans += vp[j][j+i%j];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 37996
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

string send[] = {" ", "aa", "ba", "ca", "da", "ea", "fa", "ga", "ha", "ia", "ja", "ka", "la", "ma", "na", "oa", "pa", "qa", "ra", "sa", "ta", "ua", "va", "wa", "xa", "ya", "za"};

int main(){
	map<char, int> key;
	key['a'] = 1;
	key['b'] = 2;
	key['c'] = 3;
	key['d'] = 4;
	key['e'] = 5;
	key['f'] = 6;
	key['g'] = 7;
	key['h'] = 8;
	key['i'] = 9;
	key['j'] = 10;
	key['k'] = 11;
	key['l'] = 12;
	key['m'] = 13;
	key['n'] = 14;
	key['o'] = 15;
	key['p'] = 16;
	key['q'] = 17;
	key['r'] = 18;
	key['s'] = 19;
	key['t'] = 20;
	key['u'] = 21;
	key['v'] = 22;
	key['w'] = 23;
	key['x'] = 24;
	key['y'] = 25;
	key['z'] = 26;
	vector<string> enemy;
	enemy.push_back(send[1]);
	string previnput = send[1];
	cout << "?" << send[1] << endl;
	fflush(stdout);
	while(1){
		string str;
		cin >> str;
		for(int i = 0; i < enemy.size(); i++){
			if(str == enemy[i]){
				cout << "!OUT" << endl;
				return 0;
			}
		}
		if(previnput[1]!=str[0]){
			cout << "!OUT" << endl;
			return 0;
		}

		enemy.push_back(str);
		if(str.size() == 1) cout << "?" << send[key[str[str.size()-1]]] << "a" << endl;
		else cout << "?" << send[key[str[str.size()-1]]] << endl;
		previnput = send[key[str[str.size()-1]]];
		fflush(stdout);
	}
	return 0;
}

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> Interval;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

LL W,H,x,y;

int main()
{
    cin >> W >> H >> x >> y;

    printf("%.9lf\n",H*(double)W/2);

    if(x*2 == W && y*2 == H){
        printf("1\n");
    }
    else{
        printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 256
/*
 * b.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 500000;
const int INF = 1 << 30;

/* typedef */

/* global variables */

int as[MAX_N], L[MAX_N + 1], R[MAX_N + 1];

/* subroutines */

int merge(int A[], int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  //create array L[0...n1], R[0...n2]
  for (int i = 0; i < n1; i++) L[i] = A[left + i];
  for (int i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1] = INF;
  R[n2] = INF;
  int i = 0, j = 0, cnt = 0;
  for (int k = left; k < right; k++) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
  return cnt;
}

int merge_sort(int A[], int left, int right) {
  int cnt = 0;
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    cnt += merge_sort(A, left, mid);
    cnt += merge_sort(A, mid, right);
    cnt += merge(A, left, mid, right);
  }
  return cnt;
}

/* main */

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

  int cnt = merge_sort(as, 0, n);

  for (int i = 0; i < n; i++) {
    if (i) putchar(' ');
    printf("%d", as[i]);
  }
  printf("\n%d\n", cnt);
  return 0;
}

Measured memory_bytes: 6032