akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(){
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
      cin>>a[i];
   }
   int ans=0;
   for(int i=0;i<n;i++){
      //cout<<a[i]<<endl;
      if(i%2==0){
         if(a[i]%2==1) ans+=1;
      }
   }
   cout<<ans<<endl;
   return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    
    long long res = 0;
    long long res1 = 0, res2 = 0;
    if(n%2){
        rep(i, (n-1)/2){
            res1 += -2*a.at(i);
        }
        res1 += a.at((n-1)/2);
        res1 += a.at((n-1)/2 + 1);
        for(int i = (n-1)/2 + 2; i < n; i++){
            res1 += 2*a.at(i);
        }
        
        rep(i, (n-1)/2 - 1){
            res2 += -2*a.at(i);
        }
        res2 += a.at((n-1)/2 - 1)*-1;
        res2 += a.at((n-1)/2)*-1;
        for(int i = (n-1)/2 + 1; i < n; i++){
            res2 += 2*a.at(i);
        }
        
        res = max(res1, res2);
    } else {
        rep(i, (n-2)/2){
            res += -2*a.at(i);
        }
        res += a.at((n-2)/2)*-1;
        res += a.at((n-2)/2 + 1);
        for(int i = (n-2)/2 + 2; i < n; i++){
            res += 2*a.at(i);
        }
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

signed main(){
	int N,A,B;
	cin>>N>>A>>B;
	if(N-A-B>=0){
		cout<<min(A,B)<<" "<<0<<endl;
	}
	else{
		cout<<min(A,B)<<" "<<A+B-N<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
bool cmp(int a, int b)
{
    return a > b;
}
signed main()
{
    int n, h, amax = -1, thrown = 0, ans = inf, moves;
    cin >> n >> h;
    vi a(n + 1), b(n + 1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
        amax = max(amax, a[i]);
    }
    sort(b.begin(), b.end(), cmp);
    b.insert(b.begin(), 0);
    for (int i = 0; i <= n; i++)
    {
        h = h - b[i];
        if (i != 0)
            thrown++;
        if (h < 0)
            moves = thrown;
        else
        {
            moves = (h / amax);
            if (h % amax != 0)
                moves++;
            moves += thrown;
        }
        ans = min(ans, moves);
        // cout << b[i] << " " << h << " " << moves << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);
use Memoize;

my ($n, $k) = split / /, <STDIN>;
my @a = split / /, <STDIN>;
@a = sort { $a <=> $b } @a;
my $MOD = 1e9 + 7;
sub modpow {
  my ($a, $n) = @_;
  my $r = 1;
  while ($n > 0) {
    $r = $r * $a % $ MOD if $n & 1;
    $a = $a * $a % $MOD;
    $n >>= 1;
  }
  return $r;
}
sub modinv {
  my $a = shift;
  modpow($a, $MOD - 2);
}
my (@fac, @finv);
$fac[0] = 1;
$finv[0] = 1;
for my $i (1..$n) {
  $fac[$i] = $fac[$i-1] * $i % $MOD;
  $finv[$i] = modinv($fac[$i]);
}
sub combi {
  my ($n, $k) = @_;
  $fac[$n] * ($finv[$n-$k] * $finv[$k] % $MOD) % $MOD;
}
memoize('combi');
memoize('modinv');
memoize('modpow');
my $ans = 0;
for (my $i=0; $i<=$n-$k; $i++) {
  my $c = combi($n-$i-1, $k-1);
  $ans += ($MOD + $a[$n-$i-1]) * $c;
  $ans %= $MOD;
  $ans += ($MOD - $a[$i]) * $c;
  $ans %= $MOD;
}
say $ans;

Measured memory_bytes: 29756
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

int n,m,h,k,pt[1000],tmp[1000];
pi bar[100000];
int ln[100000],ls[100000],rn[100000],rs[100000];

int main()
{
	while(scanf("%d%d%d%d",&n,&m,&h,&k),n)
	{
		rep(i,n)scanf("%d",pt+i);
		rep(i,m)scanf("%d%d",&bar[i].second,&bar[i].first);
		sort(bar,bar+m);
		
		rep(i,n)tmp[i]=i;
		rep(i,m)
		{
			int a=bar[i].second-1;
			ln[i]=tmp[a]; rn[i]=tmp[a+1];
			swap(tmp[a],tmp[a+1]);
		}
		int tot=0; rep(i,n)tmp[i]=i;
		for(int i=m-1;i>=0;i--)
		{
			int a=bar[i].second-1;
			ls[i]=pt[tmp[a]]; rs[i]=pt[tmp[a+1]];
			swap(tmp[a],tmp[a+1]);
		}
		rep(i,k)tot+=pt[tmp[i]];
		
		int ans=0;
		rep(i,m)if((ln[i]<k)^(rn[i]<k))
		{
			ans=min(ans,(ls[i]-rs[i])*(ln[i]<k?1:-1));
		}
		printf("%d\n",ans+tot);
	}
	return 0;
}

Measured memory_bytes: 0
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
s = IR(n)
su = sum(s)
dp = [[0 for i in range(su+1)] for j in range(n)]
dp[0][s[0]] = 1
for i in range(n):
    dp[i][0] = 1
for i in range(1,n):
    for j in range(su+1)[::-1]:
        if s[i]+j <= su:
            dp[i][s[i]+j] = max(dp[i][s[i]+j],dp[i-1][j])
        dp[i][j] = max(dp[i][j],dp[i-1][j])
for i in range(su+1)[::-1]:
    if dp[n-1][i] == 1 and i%10 != 0:
        break
print(i)
"""

#D
n,a,b = LI()
h = IR(n)
l = 0
r = math.ceil(max(h)/b)
while r-l > 1:
    m = (l+r)//2
    k = 0
    for i in range(n):
        k += max(0,math.ceil((h[i]-b*m)/(a-b)))
        if k > m:break
    if k > m:
        l = m
    else:
        r = m
print(r)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 46536
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

bool judge (long long a, long long b, long long c) {
    long long x = a*a + b*b + c*c - 2LL*a*b - 2LL*b*c - 2LL*c*a;
    if (x > 0 && (c - a - b) > 0) return true;
    else return false;
}

void solve() {
    long long a, b, c; cin >> a >> b >> c;
    cout << (judge(a, b, c) ? "Yes" : "No") << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3644
use std::io::{self, Write};

fn main() {
    let mut stdout = io::stdout();
    let stdin = io::stdin();

    let (s, w) = {
        let mut input = String::new();
        stdin.read_line(&mut input).expect("failed to read line");
        let input: Vec<u32> = input
            .split_whitespace()
            .map(|s| s.parse::<u32>().expect("failed to parse string"))
            .collect();
        (input[0], input[1])
    };

    if w >= s {
        println!("unsafe");
    } else {
        println!("safe");
    }
    stdout.flush().unwrap();
}


Measured memory_bytes: 2080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
using namespace std;

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());
  cout << v[n - 1] - v[0] << endl;
}

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


int main(void) {

  string s, p;
  cin >> s;
  for(int i=0; i<s.size(); i++) if( s[i]-'A' >= 0 && s[i]-'A' < 26 ) s[i] += 32;

  int cnt = 0;
  while(cin >> p){

    if( p == "END_OF_TEXT" ) break;
    if( s.size() != p.size() ) continue;

    for(int i=0; i<p.size(); i++) if( p[i]-'A' >= 0 && p[i]-'A' < 26 ) p[i] += 32;

    bool f = true;
    for(int i=0; i<p.size(); i++){
      if( s[i] != p[i] ){
        f = false;
        break;
      }
    }
    if( f ) cnt++;

  }
  cout << cnt << endl;


  return 0;
}

Measured memory_bytes: 3216
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    for(int i=0;i<3;i++){
      if(N%10==7||N/100==7||(N/10)%10==7){
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
    


  
}


Measured memory_bytes: 35816
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <limits.h>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const int INF=INT_MAX;

ll calc(ll n) {
  switch(n % 4) {
    case 0:
      return n;
      break;
    case 1:
      return 1;
      break;
    case 2:
      return n + 1;
      break;
    case 3:
    default:
      return 0;
      break;
  }
}


int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  if(a == 0) {
    cout << calc(b) << endl;
  } else {
    cout << (calc(a - 1) ^ calc(b)) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    ll n; cin>>n;
    string hoge=to_string(n);
    int ans=INF;
    for(ll i=1;i<10000000;i++){
        if(n%i==0){
            string temp=to_string(i);
            string hoge=to_string(n/i);
            ans=min(ans,max((int)temp.size(),(int)hoge.size()));
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())

A = list(map(int, input().split()))

d = {}
for a in A:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

ans_all = 0
ans_list = {}
for k, v in d.items():
    if v == 1:
        ans_list[k] = 0
        continue
    if v == 2:
        ans_all += 1
        ans_list[k] = 1
        continue
    ans_all += v*(v-1)/2
    ans_list[k] = v*(v-1)/2 - (v-1)*(v-2)/2

for a in A:
    print(int(ans_all-ans_list[a]))

Measured memory_bytes: 95436
from collections import deque

def main():
  h,w=map(int,input().split())
  cy,cx=map(int,input().split())
  dy,dx=map(int,input().split())

  M=["##"+input()+"##" for x in range(h)]
  for i in range(2):
    M.insert(0,"#"*(w+4))
    M.append("#"*(w+4))

  C=[[-1 if M[j][i]=="." else -2 for i in range(w+4)] for j in range(h+4)]
  C[-~cy][-~cx]=0
  QA,QB=deque(),deque()
  QA.append((-~cy,-~cx,0))
  W=[[i,j] for i in range(-2,3) for j in range(-2,3) if abs(i)+abs(j)>1]

  while QA:
    h,w,c=QA.popleft()
    QB.append((h,w,c))

    for i,j in [[1,0],[0,1],[-1,0],[0,-1]]:
      dh,dw=h+i,w+j
      if C[dh][dw]==-1:
        C[dh][dw]=c
        QA.appendleft((dh,dw,c))

    if QA:
      continue

    while QB:
      h,w,c=QB.popleft()
      for i,j in W:
        dh,dw=h+i,w+j
        if C[dh][dw]==-1:
          C[dh][dw]=-~c
          QA.append((dh,dw,-~c))

  print(C[-~dy][-~dx])

if __name__ == "__main__":
  main()

Measured memory_bytes: 24608
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; i += 2)
    {
        int count = 0;
        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
                count++;
        }
        if (count == 8)
            ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
    int a;
    int b;
}node;

int compare_ascending(const void* a, const void* b){
    return ((node*)a)->a - ((node*)b)->a;
}

int main(){
    int n, t;
    scanf("%d%d", &n, &t);
    node ar[n];
    for(int i=0; i<n; i++){
        scanf("%d%d", &(ar[i].a), &(ar[i].b));
    }
    qsort(ar, n, sizeof(node), compare_ascending);
    int d[n+1][7001];
    for(int i=0; i<=7000; i++){
        d[0][i] = 0;
    }
    for(int i=1; i<=n; i++){
        for(int j=0; j<=7000; j++){
            if(j < ar[i-1].a){
                d[i][j] = d[i-1][j];
            }else if(j-ar[i-1].a > t-1){
                if(d[i][j-1] > d[i-1][j]){
                    d[i][j] = d[i][j-1];
                }else{
                    d[i][j] = d[i-1][j];
                }
            }else{
                if(d[i-1][j] < d[i-1][j-(ar[i-1].a)] + ar[i-1].b){
                    d[i][j] = d[i-1][j-(ar[i-1].a)] + ar[i-1].b;
                }else{
                    d[i][j] = d[i-1][j];
                }
            }
        }
    }
    printf("%d", d[n][7000]);

    return 0;
}


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

int main() {
	int N, K, A;
	std::cin >> N >> K;
	for(int i = 0; i < N; ++i) {
		std::cin >> A;
	}

	int ans = (N - 1) / (K - 1);
	if( (N - 1) % (K - 1) != 0) ++ans;

	std::cout << ans << std::endl;
 }


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

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

    int N;
    cin >> N;

    vector<int> h(N);
    rep(i,N) cin >> h[i];

    int sum = h[0];
    for (int i = 1; i < N; i++) {
        sum += max(h[i] - h[i - 1], 0);
    }
    
    cout << sum << endl;

    return 0;
}


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();
//        List<Integer> list = new ArrayList<Integer>();
//        List<Integer> lo = new ArrayList<Integer>();
        int B = sc.nextInt();
        
        if(A+B >= A-B && A+B >= A*B) {
            System.out.println(A+B);
        }else  if(A-B >= A+B && A-B >= A*B) {
            System.out.println(A-B);
        } else if(A*B >= A+B && A*B >= A-B) {
            System.out.println(A*B);
        }

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
int main ()
{
	int A,B,C;
	while (cin>>A>>B>>C)
	{
		if (A==5&&B==5&&C==7)
		{
			cout<<"YES"<<endl;
		}
		else if (A==5&&B==7&&C==5)
		{
			cout<<"YES"<<endl;
		}
		else if (A==7&&B==5&&C==5)
		{
			cout<<"YES"<<endl;
		}
		else 
		{
			cout<<"NO"<<endl;
		}
	}
	return 0;
} 

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

vector<ll> ans(0);

void dfs(ll a){
  if(a > 3234566667) return;
  ans.push_back(a);
  int m = a%10;
  if(m > 0) dfs(10*a + m - 1);
  dfs(10*a + m);
  if(m < 9) dfs(10*a + m + 1);
}

int main(){
  int n;
  cin >> n;
  rep1(i,9) dfs(i);
  sort(ans);
  cout << ans[n-1] << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void c_sugar_water(void) {
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;

	// 上限
	// 合計がFを超える
	// 100gあたりの砂糖の量がEを超える
	// a+b+c+dがf以下
	// (c+d)/(a*x+b*y) <= E
	// 100*a*x + 100*b*y
	// c*z + d*w
	int water_max = 0;
	int sugar_max = 0;
	float nodo_max;
	int water = 0;
	int sugar = 0;
	int water_a = 0;
	int water_b = 0;
	int sugar_c = 0;
	int sugar_d = 0;

	float limit = (e*100.0) / (100 + e);

	nodo_max = 0;
	water_max = 100 * a;
	for (int x = 0; (100*a*x) <= f; x++) {
		water_a = 100 * a * x;
		for (int y = 0; (100*b*y) <= (f-water_a); y++) {
			if ((x == 0) && (y == 0))continue;
			water_b = 100 * b * y;
			for (int z = 0; (z*c) <= (f-water_a-water_b); z++) {
				sugar_c = z * c;
				for (int w = 0; (w*d) <= (f-water_a-water_b-sugar_c); w++) {
					sugar_d = w * d;
					water = water_a + water_b;
					sugar = sugar_c + sugar_d;
					//if (((sugar_c + sugar_d) / (a*x + b*y)) > e)break;
					if (water + sugar > f) break;
					float nodo = 100.0 * sugar / (water + sugar);
					if (nodo > limit)break;
					//cout << water<<" "<<sugar<<" "<<nodo <<" "<<nodo_max<< endl;
					if (nodo > nodo_max) {
						water_max = water+sugar;
						sugar_max = sugar;
						nodo_max = nodo;
					}
				}
			}
		}
	}

	cout << water_max << " " << sugar_max << endl;

}

int main()
{
	c_sugar_water();
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

/* include file*/
#include <functional>
#include <vector>
using namespace std;

template <class Monoid>
struct Segment {
  using Func = function<Monoid(Monoid, Monoid)>;

  vector<Monoid> node;
  Monoid ide;
  int n = 1;

  Func bin_f;
  Func update_f;

  Segment(const vector<Monoid>& init, Monoid ide_, Func f_, Func u_f)
      : bin_f(f_), ide(ide_), update_f(u_f) {
    int sz = init.size();
    while (n < sz) n *= 2;
    node.assign(n * 2 - 1, ide);
    for (int i = 0; i < sz; i++) node[i + n - 1] = init[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
  }

  void update(int i, Monoid x) {
    i += n - 1;
    node[i] = update_f(node[i], x);
    while (i) {
      i = (i - 1) / 2;
      node[i] = bin_f(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }

  Monoid get_inter(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    if (a <= l && r <= b) return node[k];
    if (r <= a || b <= l) return ide;

    Monoid lm = get_inter(a, b, k * 2 + 1, l, (l + r) / 2);
    Monoid rm = get_inter(a, b, k * 2 + 2, (l + r) / 2, r);
    return bin_f(lm, rm);
  }
};

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730414#1
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2730425#1

int n;
int m;

int main(){
  cin >> n >> m;
  vector<int> on(n,0);
  for(int i = 0;i < m;i++){
    int a;
    cin>> a;
    on[a] = -1;
  }
  Segment<int> seg(on,0,[](int a,int b){
    if(a == -1 && b != -1) return b;
    if(a != -1 && b == -1) return a;
    if(a == -1 && b == -1) return -1;
    return a + b + 1;
  } , [](int node,int x){return x;});
  cout << max(0,seg.get_inter(0,n)) << endl;
}


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

int main() {
	int h,w; int i,j;
	cin>>h>>w;
	char c[h+2][w+2]; char a;
	
	
		for (i=1; i<=h; ++i)
	{
	    for (j=1; j<=w ; ++j)
	   {  
	       cin>>c[i][j];
	   } 
	}
	
		for (i=0; i<=h+1; ++i)
	{
	    for (j=0; j<=w+1 ; ++j)
	   {  
	       if (i==0 || j==0|| i==h+1 ||j==w+1)
	       c[i][j]='#';
	       
	       cout<<c[i][j];
	   } 
	   cout<<"\n";
	}
		
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  using ld = long double;
  cout << fixed << setprecision(15);

  ll A, B, M;
  cin >> A >> B >> M;
  vector<ll> a(A), b(B);
  for (ll i = 0; i < A; i++)
  {
    cin >> a.at(i);
  }
  for (ll i = 0; i < B; i++)
  {
    cin >> b.at(i);
  }
  vector<ll> x(M), y(M), c(M);
  for (ll i = 0; i < M; i++)
  {
    cin >> x.at(i) >> y.at(i) >> c.at(i);
  }

  ll ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
  for (ll i = 0; i < M; i++)
  {
    ll tmp = a.at(x.at(i) - 1) + b.at(y.at(i) - 1) - c.at(i);
    chmin(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
double const pi = acos(-1);
using namespace std;

int main() {
  double a,b,c,d;
  while(cin>>a>>b>>c>>d && a!=-1) {
    a = a*pi/180.; b = b*pi/180.; c = c*pi/180.; d = d*pi/180.;
    cout << (int)round(6378.1*acos(cos(a)*cos(b)*cos(c)*cos(d)
				   +sin(b)*cos(a)*sin(d)*cos(c)
				   +sin(a)*sin(c))) << endl;
  }
  return 0;
}

Measured memory_bytes: 1272
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_062
{
    class A_062
    {
        static void Main(string[] args)
        {
            ArrayList A_Group = new ArrayList();
            A_Group.Add(1);
            A_Group.Add(3);
            A_Group.Add(5);
            A_Group.Add(7);
            A_Group.Add(8);
            A_Group.Add(10);

            ArrayList B_Group = new ArrayList();
            B_Group.Add(4);
            B_Group.Add(6);
            B_Group.Add(9);
            B_Group.Add(11);

            string[] n = Console.ReadLine().Split(' ');
            int n1 = int.Parse(n[0]);
            int n2 = int.Parse(n[1]);

            if(A_Group.Contains(n1) && A_Group.Contains(n2))
            {
                Console.WriteLine("Yes");
            }
            else if(B_Group.Contains(n1) && B_Group.Contains(n2))
            {
                Console.WriteLine("Yes");
            }
            else if(n1 == 2 && n2 == 2)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long int a,b,c,ans;
	
	cin>>a;
	cin>>b;
	cin>>c;
	
    long long int temp;
	
	
        if(c-a-b>0){
            temp=c-a-b;
	    if(temp*temp>4*a*b)
	    cout<<"Yes"<<endl;
	    
	    else 
	    cout<<"No"<<endl;
	    }
	    
	    else 
	    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    hmax = A[0]
    total = 0
    for i in range(1, N):
        if hmax > A[i]:
            total += hmax-A[i]
        else:
            hmax = A[i]
    print(total)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 94156
#include<stdio.h>

int main(void) {

	int a, b, c, d;

	scanf("%d %d %d %d", &a, &b, &c, &d);

	for (;;) {
		c -= b;
		if (c <= 0) {
			printf("Yes");
			break;
		}
		a -= d;
		if (a <= 0) {
			printf("No");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int n, maxi = 0, ans = 0;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++){
		cin >> h[i];
		maxi = max(maxi, h[i]);
	}
	for (int i = 1; i <= maxi; i++){
		vector<bool> t(n+1);
		for (int j = 0; j < n; j++){
			if (h[j] >= i) t[j+1] = true;
		}
		for (int j = 0; j < n; j++){
			if (t[j] == false && t[j+1] == true) ans++;
		}
	}
	cout << ans << endl;
 	return 0;
 }

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

public static class Program {
    static long mod;
    public static void Main() {
        int[]nm=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n=nm[0];
        mod=(long)nm[1];
        List<int>[]graph=Enumerable.Range(0,n)
            .Select(_=>new List<int>()).ToArray();
        for(int i=0;i<n-1;i++){
            int[]uv=Console.ReadLine().Split().Select(int.Parse).ToArray();
            int u=uv[0]-1;
            int v=uv[1]-1;
            graph[u].Add(v);
            graph[v].Add(u);
        }

        Action<int,int>dfs=null;
        int[]prt=new int[n];
        dfs=(x,p)=>{
            prt[x]=p;
            foreach (int y in graph[x]){
                if(y==p)continue;
                dfs(y,x);
            }
        };
        dfs(0,0);
        for(int x=1;x<n;x++){
            graph[x].Remove(prt[x]);
        }

        Action<int>efs=null;
        long[]dp=new long[n];
        for(int i=0;i<n;i++)dp[i]=1;
        efs=x=>{
            foreach(int y in graph[x]){
                efs(y);
                dp[x]*=dp[y]+1;
                dp[x]%=mod;
            }
        };
        efs(0);

        long[]ep=new long[n];
        ep[0]=1;
        long[]a=new long[n+1];
        long[]b=new long[n+1];
        efs=x=>{
            int sz=graph[x].Count;
            a[0]=1; b[0]=1;
            for(int i=0;i<sz;i++){
                a[i+1]=b[sz-i]=1+dp[graph[x][i]];
            }
            for(int i=1;i<=sz;i++){
                a[i]=a[i]*a[i-1]%mod;
                b[i]=b[i]*b[i-1]%mod;
            }
            for(int i=0;i<sz;i++){
                int y=graph[x][i];
                ep[y]=ep[x];
                ep[y]*=a[i];
                ep[y]%=mod;
                ep[y]*=b[sz-1-i];
                ep[y]+=1;
                ep[y]%=mod;
            }
            foreach(int y in graph[x])efs(y);
        };
        efs(0);

        for(int i=0;i<n;i++){
            // Console.WriteLine($"[dp ep {i}] {dp[i]} {ep[i]}");
            Console.WriteLine((dp[i]*ep[i])%mod);
        }
    }
}



Measured memory_bytes: 44820
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n, m;
	cin>>n>>m;
	int ar[m];
	int dif[m-1];
	fore(i, 0, m) cin>>ar[i];
	//if(m == 1) {cout<<0<<'\n'; return 0;}
	sort(ar, ar + m);
	int res = ar[m-1] - ar[0];
	for(int i = 0; i < m-1; i++)
	{
		dif[i] = ar[i+1] - ar[i];

	}
	sort(dif, dif + m-1);
	n--;
	for(int i = m-2; i > -1; i--)
	{
		if(n == 0) break;
		res -= dif[i];
		n--;
		if(n==0) break;
	}
	cout<<res<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

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

const ll INF = 1LL << 60;
const int MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

int N, K;
string S;
int main() {
    cin >> N >> K >> S;
    S[K-1] = tolower(S[K-1]);

    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll   long long int  
#define pb push_back
const int M=1e9 + 7;
using namespace std;
int N=1000000+1;
int main() {
   
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int* a=new int[n+1];
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
	}
    int* dp=new int[n+1];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++)
    {
    	dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
	}
	cout<<dp[n]<<endl;
  	return 0;
}

Measured memory_bytes: 1024
/*
[dp] R - Walk
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 50;
const ll MOD = 1e9 + 7;

int N;
ll K;
ll a[MAX_N][MAX_N];
ll t[MAX_N][MAX_N];

void mul(ll x[MAX_N][MAX_N], ll y[MAX_N][MAX_N]) {
    ll z[MAX_N][MAX_N];
    memset(z, 0, sizeof(z));

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                (z[i][j] += (x[i][k] * y[k][j]) % MOD) %= MOD;
            }
        }
    }

    memcpy(x, z, sizeof(z));
}

ll solve() {
    for (int i = 0; i < N; i++) {
        t[i][i] = 1;
    }

    for (ll k = K; k > 0; k = k >> 1) {
        if (k & 1LL) {
            mul(t, a);
        }
        mul(a, a);
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            (ans += t[i][j]) %= MOD;
        }
    }

    return ans;
}

int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> a[i][j];
        }
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
X, Y = gets.split.map(&:to_i)
def yen(rank)
  if rank == 1
    300000
  elsif rank == 2
    200000
  elsif rank == 3
    100000
  else
    0
  end
end

ans = yen(X) + yen(Y) + (X == 1 && Y == 1 ? 400000 : 0)
puts ans


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    if(d==1){
        cout<<1<<endl;
        return 0;
    }
    
    cout<<0<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> num(3);
    int sum = 0;
    for(int i = 0; i < 3; ++i){
        cin >> num[i];
        sum += num[i];
    }
    if(sum == 0){
        cout << "No\n";
        return 0;
    }
    vector<P> query(n);
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        int a, b;
        if(s == "AB")   a = 0, b = 1;
        else if(s == "BC")  a = 1, b = 2;
        else    a = 0, b = 2;
        query[i] = P(a, b);
    }
    query.push_back(P(0, 1));

    string ans = "";
    auto add = [&](int x, int y){
        ++num[x];
        --num[y];
        ans += 'A' + x;
    };
    for(int i = 0; i < n; ++i){
        int a = query[i].first, b = query[i].second;
        if(!num[a] && !num[b]){
            cout << "No\n";
            return 0;
        }
        if(!num[a]) add(a, b);
        else if(!num[b])    add(b, a);
        else{
            int na = query[i + 1].first, nb = query[i + 1].second;
            if(a == na || a == nb)  add(a, b);
            else    add(b, a);
        }
    }

    cout << "Yes\n";
    for(int i = 0; i < n; ++i)  cout << ans[i] << '\n';
}

Measured memory_bytes: 4772
Scanf.scanf "%d" @@ fun n ->
  let f _ = Scanf.scanf " %d" @@ fun l -> l in
  let ls = Array.init n f in
  let ma = Array.fold_left max min_int ls in
  let sum = Array.fold_left (+) 0 ls in
  print_endline @@ if ma < sum - ma then "Yes" else "No"

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    cin >> len;
    int A = 0, B = 0, C = 0;
    for(int i = 0; i < len; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        long long dist = abs(b - B) + abs(c - C);
        int time = abs(a - A);
        if(time < dist || (time > dist && time % 2 != dist % 2)) {
            cout << "No";
            return 0;
        }
        A = a;
        B = b;
        C = c;
    }
    cout << "Yes";
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll k;
    cin >> k;
    deque<pii> q;
    vi dist(k + 1, -1);
    q.push_back({1, 1});
    while (!q.empty()) {
        auto p = q.front();
        q.pop_front();
        if (dist[p.second] != -1) {
            continue;
        } else {
            dist[p.second] = p.first;
        }
        int m10 = (p.second * 10) % k;
        q.emplace_front(p.first, m10);
        int p1 = (p.second + 1) % k;
        q.emplace_back(p.first + 1, p1);
    }
    cout << dist[0] << "\n";
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string s, t;
	cin >> s;
	t = s;
	sort(s.begin(), s.end());
	s.erase(unique(s.begin(), s.end()), s.end());
	if (s.size() == t.size()) {
		cout << "yes" << endl;
	}
	else {
		cout << "no" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.se < b.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; ++i)
#define foris(i, a, b) for(ll i = a; i < b; ++i)
#define forise(i, a, b) for(ll i = a; i <= b; ++i)
#define ford(i, n) for(ll i = n; i >= 0; --i)
#define fords(i, a, b) for(ll i = a; i >= b; --i)
#define fordse(i, a, b) for(ll i = a; i > b; --i)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N;
priority_queue<int, vector<int>, greater<int>> arr;

int main() {
  io();
  
  cin >> N;
  fori(i, N) {
    int a;
    cin >> a;
    arr.push(a);
  }
  
  double val = arr.top();
  arr.pop();
  val += arr.top();
  val /= 2.0;
  arr.pop();
  foris(i, 2, N) {
    val = (val + arr.top())/2.0;
    arr.pop();
  }
  
  cout << val << nl;
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

struct task{
	int cost;
	int deadLine;
};

bool myComp(task left,task right){
	return (left.deadLine < right.deadLine);
}

int main()
{
	int n;
	cin>>n;
	vector<int> a(n);
	vector<int> b(n);
	for(int i = 0; i < n; i++){
		cin>>a[i]>>b[i];
	}
	bool finalAns = false;
	for(int i = 0; i < n - 2; i++){
		if( a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2]){
			finalAns = true;
			break;
		}
	}
	if(finalAns == true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string A, B;
        cin >> A >> B;

        if (len(A) > len(B)) { cout << "GREATER" << endl; return 0; }
        else if (len(A) < len(B)) { cout << "LESS" << endl; return 0; }
        if (A > B) cout << "GREATER" << endl;
        else if (A < B) cout << "LESS" << endl;
        else cout << "EQUAL" << endl;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
typedef pair<int,int> P;
P dp[402][402];
std::vector<int> v(500);
P f(int i,int j){
  if(dp[i][j]!=P(-1,-1))return dp[i][j];
  if(i==j)return P(v[i],v[i]);
  int res=LINF;
  for(int k=i;k<j;k++)res=min(res,f(i,k).first+f(k+1,j).first);
  return dp[i][j]=P(res+f(i,i).second+f(i+1,j).second,f(i,i).second+f(i+1,j).second);
}
//main
signed main(){
  int N;cin>>N;
  for(int i=0;i<N;i++)cin>>v[i];
  memset(dp,-1,sizeof(dp));
  /*
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++)cout<<i<<" "<<j<<" "<<f(i,j).first<<endl;
  }
  */
  cout<<f(0,N-1).first-f(0,N-1).second<<endl;
}


Measured memory_bytes: 2816
#include <iostream>

using namespace std;
 
int main()
{
    int b,r,g,c,s,t;
     
    while(cin >> b >> r >> g >> c >> s >> t ,b+r+g+c+s){
        int medal = 100;
        medal += 95*b+63*r+7*g+2*c+3*s-3*t;
        cout << medal << endl;
    }
    return 0;
}

Measured memory_bytes: 3024
#include<iostream>

using namespace std;

int main() {

	int s;
	cin >> s;
	int a = 0;

	if (s % 10 == 1)a++;
	if ((s / 10) % 10 == 1)a++;
	if (s / 100 == 1)a++;

	cout << a << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var S = new List<char>() { '?' };
        S.AddRange(Console.ReadLine().ToList());
        int Q = int.Parse(Console.ReadLine());

        var bit = new BIT[26];
        for(int i = 0; i < 26; i++)
        {
            bit[i] = new BIT(N+1);
        }
        for (int i = 1; i < N+1; i++)
        {
            char s = S[i];
            bit[s - 'a'].add(i, 1);
        }

        var ans = new List<int>();
        for (int i = 0; i < Q; i++)
        {
            var Query = Console.ReadLine().Split();
            if (Query[0] == "1")
            {
                int a = int.Parse(Query[1]);
                char b = Query[2][0];
                int num = bit[S[a] - 'a'].sum(a+1) - bit[S[a] - 'a'].sum(a);

                bit[S[a] - 'a'].add(a, -num);
                bit[b-'a'].add(a, num);
                S[a] = b;
            }
            else if(Query[0]=="2")
            {
                int a = int.Parse(Query[1]), b = int.Parse(Query[2]);
                int num = 0;
                for(int j = 0; j < 26; j++)
                {
                    if (bit[j].sum(b+1) - bit[j].sum(a) > 0) num++;
                }
                ans.Add(num);
            }
        }
        foreach(int i in ans)
            Console.WriteLine(i);
    }
}
//初期は0の集合
class BIT
{
    private int[] bit;
    private int N;
    public BIT(int n)
    {
        bit = new int[n + 1];
        N = n;
    }

    public int sum(int i)
    {
        int s = 0;
        while (i > 0)
        {
            s += bit[i];
            i -= (i & -i);
        }
        return s;
    }

    public void add(int i, int x)
    {
        i++;
        while (i <= N)
        {
            bit[i] += x;
            i += (i & (-i));
        }
    }
}

Measured memory_bytes: 85772