akhauriyash/Code-Regression huggingface dataset:
import scala.io.StdIn.readLine

object Main extends App {

  val Array(n, q) = readLine.split(" ").map(_.toInt)
  val queue = new Queue[Process]
  for (i <- 1 to n) {
    val Array(name, time) = readLine.split(" ")
    queue.enqueue(new Process(name, time.toInt))
  }

  var time = 0
  while (!queue.empty) {
    val currentProcess = queue.dequeue
    time += currentProcess.process(q)
    if (!currentProcess.completed) {
      queue.enqueue(currentProcess)
    } else {
      println(s"${currentProcess.name} $time")
    }
  }

  class Process(n: String, t: Int) {

    val name = n
    var time = t

    def process(q: Int): Int = {
      val currentTime = Math.min(time, q)
      time -= currentTime
      currentTime
    }

    def completed(): Boolean = { time == 0 }
  }

  class Queue[T] {

    class Node[T] (v: T) {
      var value: T = v
      var prev: Node[T] = null
      var next: Node[T] = null
    }

    var size = 0
    var head: Node[T] = null
    var tail: Node[T] = null

    def enqueue(value: T): Unit = {
      val newNode = new Node[T](value)
      if (head == null) {
        head = newNode
      } else {
        tail.prev = newNode
        newNode.next = tail
      }
      tail = newNode
      size += 1
    }

    def dequeue: T = {
      val returnNode: Node[T] = head
      head = returnNode.prev
      size -= 1
      returnNode.value
    }

    def empty: Boolean = {
      size == 0
    }
  }
}



Measured memory_bytes: 117120
n = int(input())
aa = list(map(int, input().split()))
c1 = 0 # odd 
c2 = 0 
c4 = 0
la = len(aa)

for a in aa:
  if a % 4 == 0:
    c4 += 1
  elif a % 2 == 0:
    c2 += 1
  else:
    c1 += 1
    
if c1 == 0:
  print('Yes')
  exit()

elif c4 >= c1:
  print('Yes')
  exit()
  
elif c4 == c1 - 1 and c2 == 0:
  print('Yes')
  exit()
  
print('No')

Measured memory_bytes: 20172
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"YES"<<'\n';
#define no cout<<"NO"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,r,g,b;
    //string a,b;
    cin>>r>>g>>b;
    if(r==g)
    cout<<b<<endl;
    else if(r==b)
    cout<<g<<endl;
   else if(g==b)
    cout<<r<<endl;


       return 0;
}





Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define repi(i,a,b) for (int i = int(a); i < int(b); i++)
#define all(x) (x.begin()), (x.end())
#define sz(x) int((x).size())

using namespace std;

//type
typedef long long ll;
typedef long double ld;
typedef long long unsigned int ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

// constants
const double EPS = 1e-7;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);

// maximum size
const int MAX_N = 0;

/** !codes **/
int N, Y;

void solve(){
    vvi ans(0);
    for (int i = 0; i < N + 1; i++)
    {
        for (int j = 0; j < N + 1 - i; j++){
            int price = Y - (10000 * i + 5000 * j);
            if (floor(price / 1000) != N - (i + j)){
                continue;
            }
            vi res(3);
            res.at(0) = i;
            res.at(1) = j;
            res.at(2) = N - (i + j);
            ans.push_back(res);
        }
    }
    if (ans.size() == 0)
    {
        cout << "-1 -1 -1" << '\n';
        return;
    }
    for (auto &&i : ans[0])
    {
        cout << i << ' ';
    }
    cout  << '\n';
    return;
}

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

    cin >> N >> Y;

    solve();
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; ++i)
#define RANGE(i, x, n) for(ll i = x; i < n; ++i)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;

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

    int n;
    cin >> n;
    int m = n/2;
    set<int> S;
    RANGE(i, 1, n+1) S.insert(i);
    if(n%2 == 0) {
        m = 2*(m-1)*m;
        cout << m << endl;
        RANGE(i, 1, n/2+1) {
            int j = n+1-i;
            S.erase(i);
            S.erase(j);
            for(auto x: S) {
                cout << i << " " << x << endl;
                cout << j << " " << x << endl;
            }
        }
    }else {
        m = 2*(m-1)*m + n-1;
        cout << m << endl;
        RANGE(i, 1, n) {
            cout << i << " " << n << endl;
        }
        S.erase(n);
        --n;
        RANGE(i, 1, n/2+1) {
            int j = n+1-i;
            S.erase(i);
            S.erase(j);
            for(auto x: S) {
                cout << i << " " << x << endl;
                cout << j << " " << x << endl;
            }
        }
    }
}


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

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[100010];

    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    int dp[] = new int[100010];
    Arrays.fill(dp, Integer.MAX_VALUE);

    dp[0] = 0;
    for (int i = 0; i < n; i++) {
      dp[i + 1] = Math.min(dp[i] + Math.abs(h[i] - h[i + 1]), dp[i + 1]);
      dp[i + 2] = Math.min(dp[i] + Math.abs(h[i] - h[i + 2]), dp[i + 2]);

      //        if (i - 2 >= 0 && i + 2 < ashiba.length) {
      //          dp[i + 1] = Math.min(Math.abs(dp[i - 1] - ashiba[i + 1]), dp[i + 1]);
      //        }
    }

    System.out.println(dp[n - 1]);
  }
}


Measured memory_bytes: 49576
#include<iostream>
using namespace std;
using ll = long long int;

ll n, a, b;

int main(void) {
	cin >> n >> a >> b;
	ll ret=0;
	if (n > 2) {
		if (b > a)
			ret = (b-a)*(n-2)+1;
		else if (b == a)
			ret = 1;
		else
			ret = 0;
	}
	else if (n == 2) {
		if (b >= a)
			ret = 1;
		else
			ret = 0;
	}
	else {
		if (a != b)
			ret = 0;
		else
			ret = 1;
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>
#include<map>
#include<set>
#include<stack>

using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define double long double
#define en "\n"
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define toUpper(x) transform(x.begin(), x.end(), x.begin(),::toupper);
#define toLower(x) transform(x.begin(), x.end(), x.begin(),::tolower);
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> pii;
bool secdes(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !
bool sir(const pair<int,int>&a , const pair<int,int>&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !
bool bysec(const pair<int,int>&a , const pair<int,int>&b){if(a.se==b.se){return a.fi<b.fi;} else{return a.se<b.se;}}//second ascending !

//--------------------------------------------------------------------------------------------------------------------------------------------------------------

const int no=3e5+5;
const int modulo=1e9+7;
const int inf=1e18;
const int N=1001;
int ar[no],br[no],cr[no],dr[no],dist[N][N],cost[N][N];
stack<int> S;
stack<int> ma;
int dx[]={-1 , 0 , 1 , 0};
int dy[]={0 , 1 , 0 , -1};

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
int mul(int x , int y , int mod) {
	return ((x%mod)*(y%mod))%mod;
}

int powwmod(int x, int y , int mod) { int res=1; while (y) { if (y & 1){ y--; res=mul(res,x,mod); res%=mod; } else { y/=2; x=mul(x,x,mod); x%=mod; } } return res%mod; }

int poww(int x , int y) { int res=1; while(y) { if(y%2) { y--; res=res*x; } else { y/=2; x=x*x; } } return res; }

int div(int x , int y , int mod) {
	return x*poww(y,mod-2)%mod ;
}

bool comp(int x, int y) {
	return (x < y);   // MINIMUM
	return (x > y);   // MAXIMUM
}

int gcd(int x, int y) { if(y==0) return x; else return gcd(y,x%y); }

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

//--------------------------------------------------------------------------------------------------------------------------------------------------------------
vi adj[no];
int used[no];

void solve (){
	int n,m,a=0,b=0;
	cin>>n;
	cout<<1-n<<en;
}

inline void runn(){
	#ifndef ONLINE JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

signed main()
{
	night_rider
	//runn();
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}


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

int main(void) {
  ll h,w;
  cin >> h >> w;
  if(h ==1 || w==1)cout << 1 << endl;
  else cout << (h*w +1)/2 << endl;
  return 0;
  
}


Measured memory_bytes: 256
import numpy as np
N = int(input())
ApB = []

for i in range(N):
	temp1, temp2 = map(int, input().split())
	s = temp1 + temp2
	ApB.append([s, temp1, temp2, i])

ApB.sort()
score = 0
for i in range(N):
	if i % 2 == 0:
		score += ApB.pop()[1]
	else:
		score -= ApB.pop()[2]

print(score)


Measured memory_bytes: 36976
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]


for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])

cnt = 0
for i in range(H):
    for j in range(W):
        here = A[i][j]
        if here not in [-1, 1]:
            cnt += C[here][1]

print(cnt)


Measured memory_bytes: 40924
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll A,B;

void solve(){

}

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

    cout << max(A + B, max(A-B, A*B)) << endl;
}

Measured memory_bytes: 256
K, N = map(int, input().split())
A = list(map(int, input().split()))
lst = []
for i in range(1, N-1):
    diff_1 = abs(A[i + 1] - A[i])
    lst.append(diff_1)

lst.append(K + A[0] - A[N-1])
print(K - max(lst))

Measured memory_bytes: 26444
#include<iostream>
#include<algorithm>
using namespace std;
int n;
long long a[100010],sum[100010];
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);sum[0]=a[0];
	for(int i=1;i<n;i++){
		sum[i]=a[i]+sum[i-1];
	}
	int i=n-2;
	while(true){
		if(sum[i]*2<a[i+1])break;
		i--;
		if(i==-1)break;
	}
	cout<<n-1-i<<endl;
	return 0;
}


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

int main()
{
  int N, i, key, j, k = 0, minj;
  int *data;

  scanf("%d", &N);

  data = (int *)malloc(N * sizeof(int));

  for(i = 0; i < N; i++) scanf("%d", &data[i]);

  // for(i = 0; i < N; i++) printf("%d ", data[i]);
  //printf("\n");
 
  for(i = 0; i < N; i++){
   
    minj = i;
    
    for(j = i; j < N; j++){
      if(data[j] < data[minj]){
	minj = j;

      }
    }
   
     key = data[minj];
     // printf("key = %d\n", key);
    data[minj] = data[i];
    data[i] = key;
    if(data[i] != data[minj]) k++;
    
  }

  for(i = 0; i < N - 1; i++) printf("%d ", data[i]);
  printf("%d\n", data[i]);
  
  printf("%d\n", k);
 
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
using namespace std;
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int main()
{
	int n=read(),k=read();
	if(k==1)puts("0");
	else printf("%d\n",n-k);
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::io::Write;

// {{{
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}


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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        d: isize,
        a: isize,
        monster: [(isize, isize); n],
    }

    let mut monster = monster;
    monster.sort_by(|x, y| (x.0).cmp(&y.0));
    // debugln!("{:?}", monster);

    let mut coords = vec![];
    let mut hp = vec![];
    for &(c, h) in monster.iter() {
        coords.push(c);
        hp.push(h);
    }

    let mut atack: Vec<(isize, isize)> = vec![];
    let mut cntsum = vec![0];
    for i in 0..n {
        // 体力を計算してhに入れる
        let h =
            if atack.is_empty() {
                hp[i]
            } else {
                let mut first = 0;
                if atack[0].0 >= coords[i] - d {
                    first = 0;
                } else {
                    // lがダメ
                    let mut l = 0;
                    let mut r = atack.len();
                    while l + 1 < r {
                        let mid = (l + r) / 2;
                        if atack[mid].0 >= coords[i] - d {
                            r = mid;
                        } else {
                            l = mid;
                        }
                    }
                    first = r;
                }

                let lastsum = cntsum.last().unwrap();

                hp[i] - a * ((lastsum - cntsum[first]) as isize)
            };

        // let h = hp[i];

        if h <= 0 {
            continue;
        }

        let location = coords[i] + d;
        let count = (h + a - 1) / a;
        atack.push((location, count));
        let lastsum = cntsum.last().unwrap().clone();
        cntsum.push(lastsum + count);
    }

    let ans = cntsum.last().unwrap();
    println!("{}", ans);
}



Measured memory_bytes: 24632
#include<bits/stdc++.h>
using namespace std;
int32_t main(){
	string s1,s2; cin>>s1>>s2;
  	int c=0;
  	for(int i=0;i<(int)s1.size();i++){
    	if(s1[i]!=s2[i]) c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3912
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x, (val), sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(ll X, ll A, ll B) {
  X-=A;
  return X%B;
}

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

  ll X, A, B;
  cin >> X >> A >> B;

  auto ans = solve(X, A, B);
  cout << ans << endl;

  return 0;
}


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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

int main(){
    ll n, m; cin>>n>>m;
    vector<ll> a(n+10);
    for(int i=0; i<n; i++) cin>>a[i];

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

    map<ll, ll> mod_sum;
    set<ll> s;
    for(int i=0; i<=n; i++) {
        mod_sum[sum[i] % m]++;
        s.insert(sum[i] % m);
    }

    ll ans=0;
    for(ll i : s){
        ans += (mod_sum[i]*(mod_sum[i] - 1)) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int D, G;
int p[20], c[20];
int dp[20][105510];


void makeDP(){
	repe(i, 0, D) fill(RNG(dp[i], 1, 105510), INF);
	repe(i, 1, D){
		rep(j, 0, p[i])
			chmin(dp[i][i*j], j);
		chmin(dp[i][i*p[i]+c[i]], p[i]);
	}
	repe(i, 2, D){
		rep(j, 1, 105510){
			if(dp[i-1][j] == INF) continue;
			rep(k, 0, p[i]){
				if(j+i*k >= 105510) break;
				chmin(dp[i][j+i*k], dp[i-1][j]+k);
			}
			if(dp[i-1][j] != INF && j+i*p[i]+c[i] < 105510) chmin(dp[i][j+i*p[i]+c[i]], dp[i-1][j]+p[i]);
		}
	}
}


int solve(){
	int ans = INF;
	repe(i, 1, D)
		rep(j, G, 105510) chmin(ans, dp[i][j]);
	return ans;
}


signed main(){
	cin >> D >> G, G/=100;
	repe(i, 1, D) cin >> p[i] >> c[i], c[i]/=100;

	makeDP();

	cout << solve() << endl;

	return 0;
}


Measured memory_bytes: 6400
(let ((a (read))
      (b (read))
      (c (read)))
  (if (or (and (= a b) (/= b c))
          (and (= b c) (/= c a))
          (and (= c a) (/= a b)))
      (format t "Yes~%")
      (format t "No~%")))


Measured memory_bytes: 23184
// 解説前
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>

// 価値を減らしつつ総和を大きくする問題ので、損失を抑えるためにその時点で最も小さい値で操作を行うのが良い
int solve_C() {
  size_t N;
  std::cin >> N;

  std::priority_queue<double, std::vector<double>, std::greater<>> values;
  for (size_t i = 0; i < N; ++i) {
    uint32_t value;
    std::cin >> value;
    values.push(static_cast<double>(value));
  }

  for (size_t i = 0; i < N - 1; ++i) {
    const double x = values.top();
    values.pop();
    const double y = values.top();
    values.pop();
    values.push((x + y) / 2.0);
  }

  std::cout << std::setprecision(20) << values.top();
  return 0;
}

int main() {
  return solve_C();
}


Measured memory_bytes: 256
N = int(input())
ANS = 0
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

L = factorization(N)

for i in range(len(L)):
    for j in range(50):
        if j * (j+1) > 2 * L[i][1]:
            ANS += j - 1
            break
if len(L) == 1 and L[0][0] == 1:
    ANS = 0

print(ANS)

Measured memory_bytes: 63380
#include <cstdio>
#include <vector>
 
using namespace std;
 
static int f(const int* ws, int n, int P, int k) {
  int v = 0;
  int c = 0;
  int ntrack = 0;
  for (int i = 0; i < n; ++i) {
    if (c > 0 && P > 0 && c + ws[i] > P) {
      c = 0;
      ntrack++;
    }
    if (ntrack == k) {
      break;
    }
 
    if (c + ws[i] <= P) {
      c += ws[i];
      v++;
    }
  }
  return v;
}
 
int main() {
  int n, k;
 
  scanf("%d %d", &n, &k);
 
  //vector<int> ws(n);
  int ws[100000];
  int max = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &ws[i]);
    max += ws[i];
  }
 
  int min = 1;
  int mid = (min + max) / 2;
  while (min < max) {
    if (f(ws, n, mid, k) >= n) {
      max = mid;
    } else { // v < n
      min = mid + 1;
    }
    mid = (min + max) / 2;
  }
 
  printf("%d\n", mid);
  return 0;
}

Measured memory_bytes: 3080
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
#define NL cout<<endl;
#define NNL cout<<endl<<endl;

int MAX = 1e+6+5;
int BIG = 1e+18+3;
int MOD = 1e+9+7;

signed main()
{
    IOS;
    int n; cin>>n;
    int ans(0);
    map< pair<int,int>, int > m1;

    repa(i,1,n)
    {
        int beg = (i%10);
        int val = i;

        int cntDigits(0);

        while( val )
        {
            cntDigits++;
            val/=10;
        }

        int sz = cntDigits;
        sz--;
        val=i;
        if (sz)
            repa(i,1,sz)
                val/=10;

        int lst = val;
       // debug3(i,beg,lst);
        m1[{beg,lst}]++;
    }   

    for (auto it: m1)
    {
        int v1 = it.ff.ff;
        int v2 = it.ff.ss;

        int freq = it.ss;

        int cv1 = v2;
        int cv2 = v1;

        int freq2 = m1[{cv1,cv2}];
        ans+=(freq2)*(freq);
        
    }

    cout<< ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(W<x+r || H<y+r || 0>x-r || 0>y-r){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int a, b;

    cin >> a >> b;

    if((a + b) % 2 == 0){
        cout << (a + b) / 2;
    }
    else{
        cout << "IMPOSSIBLE";
    }

    return 0;
}

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

P p[200000];
int main(){
	int n;scanf("%d",&n);
	rep(i,n){
		scanf("%d%d",&p[i].first,&p[i].second);
	}
	sort(p,p+n,[](P a,P b){return a.first+a.second>b.first+b.second;});
	ll ans=0;
	rep(i,n){
		if(i%2==0)ans+=p[i].first;
		else ans-=p[i].second;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    string s;
    cin >> s;
    int cnt=0;
    rep(i,3){
        if(s[i]=='R')cnt++;
    }
    if(s[0]==s[2] && cnt==2)cnt--;
    cout << cnt;


    
}

/*
*/


Measured memory_bytes: 3544
n, m = map(int,input().split())
maxL, minR = 1, n
L = []
R = []
for i in range(m):
  l, r = map(int,input().split())
  maxL = max(maxL, l)
  minR = min(minR, r)

ans = minR - maxL + 1
print(max(ans, 0))

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll R, G, B, N;
  cin >> R >> G >> B >> N;

  ll ans = 0;
  REP(r, 0, N + 1) {
    REP(g, 0, N + 1) {
      ll remain = (R * r) + (G * g);
      if (N >= remain && (N - remain) % B == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <iostream>

using namespace std;
using namespace atcoder;

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

int main(){
    int N,Q;
    scanf("%d%d",&N,&Q);

    dsu uf(N);
    rep(i,Q){
        int t,u,v;
        scanf("%d%d%d",&t,&u,&v);
        if(t==0){
            uf.merge(u,v);
        }
        else{
            if(uf.same(u,v)){
                printf("1\n");
            }
            else{
                printf("0\n");
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4108
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

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

using namespace std;

int main(){
	map<char, char> m;
	m['('] = ')';
	m[')'] = '(';
	m['w'] = 'w';
	m['i'] = 'i';
	
	string s;
	cin >> s;
	int ans = 0;
	rep(i, s.size()/2){
		if(m[s[i]] != s[s.size()-i-1]) ans++;
	}
	if(s.size()&1 && s[s.size()/2] != 'w' && s[s.size()/2] != 'i') ans++;
	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

typedef pair<int,int> P;
typedef vector<P> vP;

#define X first
#define Y second

int distM(P x, P y) {
    return abs(x.X-y.X)+abs(x.Y-y.Y);
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int N, M; cin >> N >> M;

    vP s(N), c(M);
    trav(x, s) cin >> x.X >> x.Y;
    trav(x, c) cin >> x.X >> x.Y;

    bitset<MX> mk;
    F0R(i, N) {
        ii res = {-1,INF};
        F0R(j, M) {
            if (distM(s[i],c[j]) < res.s) {
                res.s = distM(s[i],c[j]);
                res.f = j;
            }
        }

        cout << res.f+1 << "\n";
    }


}


Measured memory_bytes: 256
using System;
  
namespace Aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            const int Max = 1000000;
            var p = new int[Max];
            var count = 1;
            for(int i=3; i < Max; i += 2) {
                if(p[i] == 0) {
                    ++count;
                    if(i <= 1000) {
                        for(int l = i; i * l < Max; l += 2) {
                            p[l * i] = -1;
                        }
                    }
                }
                p[i] = count;
            }
            p[2] = 1;
            for(string n; (n = Console.ReadLine()) != null;){
                int v = int.Parse(n);
                Console.WriteLine(p[(v != 2 && (v & 1) == 0) ? v - 1 : v]);
            }
        }
    }
}

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

System.out.println(c.equals("a")||c.equals("i")||c.equals("u")||c.equals("e")||c.equals("o") ? "vowel" : "consonant");   

 }
  }


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

int main() {
	int n, mode=0;
	vector<int> numbers(101, 0);
	while (cin >> n) {
        numbers[n]++;
        if (numbers[n] > mode) { mode=numbers[n]; }
	}
    for (int i = 0; i != numbers.size(); ++i) {
        if (numbers[i] == mode) { cout << i << endl; }
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int count0 = 0;
    int count1 = 0;
    int N = s.length();
    int i;
    for(i=0;i<N;i++)
    {
        if(i%2==0)
        {
            if(s[i] == '0')
            {
                count0++;
            }
            else
            {
                count1 ++;
            }
        }
        else
        {
            if(s[i] == '0')
            {
                count1++;
            }
            else
            {
                count0++;
            }
        }
    }
    cout << min(count0,count1) << endl;
    return 0;
    
}

Measured memory_bytes: 512
#include <cstdio>

int main(){
    double a,b,c,d,e,f;
    while(scanf("%lf %lf %lf %lf %lf %lf",&a, &b, &c, &d, &e, &f)!=EOF){
        double D = a*e-b*d;
        double x = (e*c-b*f)/D;
        double y = (a*f-c*d)/D;
        if(x==0)
            x = 0;
        if(y==0)
            y = 0;
        printf("%.3f %.3f\n", x, y);
    }
    return 0;
}

Measured memory_bytes: 1080
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include <math.h>
#include <set>
#include <map>
#include <stdio.h>
#include <queue>
#include <iomanip>
#include <cstring>
#include <stack>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ff first
#define ss second
using namespace std;
typedef long long ll;
using namespace std ;
struct node
{
    ll x,y;
    bool operator<(const node&o)const
    {
        return y>o.y;
    }
}a[100005];
ll n,k,cot=0;
bool vis[100005];

stack<ll>s;
int main()
{
    long long ans=0,res=0,type=0;
    cin>>n>>k;
    for(ll i=1;i<=n;i++){
       cin>>a[i].x>>a[i].y ;
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    {
        if(cot<k)
        {
            if(!vis[a[i].x])
            {
                vis[a[i].x]=true;
                type++;
            }
            else s.push(a[i].y);
            res+=a[i].y;
            cot++;
            ans=max(ans,res+type*type);
        }
        else
        {
            if(s.empty())break;
            if(vis[a[i].x]) continue;
            vis[a[i].x]=true;
            type++;
            res+=a[i].y;
            res-=s.top();s.pop();
            ans=max(ans,res+type*type);
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 5520
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

long long K;

long long C[9];
long long f(string &S) {
  rep(i, 9) C[i] = 0;
  C[0] = 1;
  for (char c : S) {
    if (c == 'F') C[1] += C[0];
    else if (c == 'E') C[2] += C[1];
    else if (c == 'S') C[3] += C[2];
    else if (c == 'T') C[4] += C[3];
    else if (c == 'I') C[5] += C[4];
    else if (c == 'V') C[6] += C[5];
    else if (c == 'A') C[7] += C[6];
    else C[8] += C[7];
  }
  return C[8];
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> K;
  string S;
  rep(_, 500) S += "FESTIVA";
  while (f(S) < K) {
    int lo = 0, hi = S.length();
    while (hi-lo > 1) {
      int mid = (lo+hi) / 2;
      string T = S.substr(0, mid)+'L'+S.substr(mid, S.length()-1);
      if (f(T) <= K) lo = mid;
      else hi = mid;
    }
    S = S.substr(0, lo)+'L'+S.substr(lo, S.length()-1);
  }
  assert(f(S) == K);
  cout << S << "\n";
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

ll l[2010];

void solve(){

    ll n;
    cin >> n;
    rep(i,n){
      cin >> l[i];
    }
    l[n]=2000;
    sort(l,l+n);
    ll ans = 0;
    for(int i=n-1; i>=0; i--){
      for(int j=i-1; j>=0; j--){
        //l[0]~l[j-1]までの間で, l[i]-l[j]より大きいもの
        auto itr = upper_bound(l,l+n, l[i]-l[j]);
        //cout << "i: " << i << ", j:" << j << endl;
        //cout << *itr << endl;
        //cout << max(int(0), int(distance(itr,l+j))) << endl;
        ans += max(int(0), int(distance(itr,l+j)));
      }
    }

    cout << ans << endl;

}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    LL n;
    cin >> n;
    LL a[n];
    LL res;
    cin >> a[0];
    res = a[0];
    for( int i = 1; i < n; ++i ) {
        cin >> a[i];
        res ^= a[i];

    }
    if( res != 0 ) cout << "No";
    else cout << "Yes";
    cout << endl;

    return 0;
}


Measured memory_bytes: 1024
s=list(input())
a=s[0]
b=s[1]
c=s[2]
d=s[3]


if a==b and c==d and a!=c:
  print('Yes')
elif a==c and b==d and a!=b:
  print('Yes')
elif a==d and c==b and a!=c:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
import numpy as np
N = int(input())
A = list(map(int,input().split()))
A = np.array(A).astype(np.int64)
odd_even = np.sum(A<0) %2
absA = np.abs(A)
abssum = np.sum(absA)
if odd_even==1:

    ans = abssum - 2 * np.sort(absA)[0]
else:
    ans  = abssum
print(ans)




Measured memory_bytes: 23284
#include<bits/stdc++.h>
#include<math.h>
#include<set>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
#define pb push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x-1;i>=y;i--)
using namespace std;
vector<vector<ll> > vec2d;
vector<pair<ll, ll> > vec_pair;
multiset<ll> node[200003];
// vector<pair<ll, ll> > vec_pair;
int main()
{
    ll n;
    cin>>n;
    ll arr[n+5];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    ll t=0;
    for(ll i=0;i<n-2;i++)
    {
        if((arr[i]<=arr[i+1] && arr[i+1]<=arr[i+2]) || (arr[i]>=arr[i+1] && arr[i+1]>=arr[i+2]))
            t++;
    }
    cout << t << endl;
    return 0;
}

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

using namespace std;

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

int dp[30][3001];
int a, b, c, d, e, f;

void dfs(int x, int y){
    int v = x * a + y * b;
    if (100 * v > f) return;

    if(dp[v][0] == 1){
        return;
    }else{
        dp[v][0] = 1;
    }
    
    dfs(x + 1, y);
    dfs(x, y + 1);
}

int main(){
    
    cin >> a >> b >> c >> d >> e >> f;
    rep(i, 30)rep(j, f + 1) dp[i][j] = 0;
    dfs(0, 0);

    for (int i = 0; 100 * i <= f; i++){
        for (int j = 0; j + i <= f; j++){
            if(100 * i + j > f) continue;
            if(e * i >= j && i >= a && dp[i-a][j]){
                dp[i][j] = 1;
                continue;
            }
            if(e * i >= j && i >= b && dp[i-b][j]){
                dp[i][j] = 1;
                continue;
            }
            if(e * i >= j && j >= c && dp[i][j-c]){
                dp[i][j] = 1;
                continue;
            }
            if(e * i >= j && j >= d && dp[i][j-d]){
                dp[i][j] = 1;
                continue;
            }
        }
    }
    
    int mx1 = 0;
    int mx2 = 100 * a;
    rep(i, 30)rep(j, f + 1){
        if(dp[i][j] == 1 && mx1 * (100 * i + j) < mx2 * j){
            mx1 = j;
            mx2 = (100 * i + j);
        }
    }
    cout << mx2 << " " << mx1 << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//まず全てのドーナツを一個ずつ作り、残りの材料で最もコストの小さいドーナつのみ作

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  rep(i,N){
    cin >> m[i];
  }
  int sum = 0;
  rep(i,N){
    sum += m[i];
  }
  X -= sum;//残りの材料
  sort(m.begin(),m.end());
  cout << N + X/m[0] << endl;
 }

Measured memory_bytes: 256
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

x,a=mp()
if x<a:
    print(0)
else:
    print(10)

Measured memory_bytes: 77372
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
# print(h)
ans = []
for i in range(n):
    ans.append(t-h[i]*0.006)
# print(ans)
x = 10000
cnt = 0
for i in range(n):
    if abs(ans[i]-a) < x:
        cnt = i+1
        x = abs(ans[i]-a)
print(cnt)


Measured memory_bytes: 3828
#include <stdio.h>

int main(){
	int n, b, f, r, v;
	int i, j, k;
	int A[4][3][10] = {0};
	
	scanf("%d", &n);

	for(i=0; i<n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		A[b-1][f-1][r-1] += v;
	}

	for(i=0; i<4; i++) {
		if(i != 0) printf("####################\n");
		for(j=0; j<3; j++) {
			for(k=0; k<10; k++) {
				printf(" %d", A[i][j][k]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << min(min(P+Q, P+R), Q+R) << endl;
  return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			String input = sc.nextLine();
			
			if(input.equals("0")) {break;}
			int sum = 0;
			for(int i=0; i<input.length(); i++) {
				sum += input.charAt(i) - 48;	//0は文字コードで48
			}
			
			System.out.println(sum);
		}
	}

}



Measured memory_bytes: 26716
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
ll ceil1(ll a,ll b)
{
	if(a%b==0)
		return a/b;
	else
		return a/b+1;
}

void solve()
{
	string s;
	cin>>s;
	string s1="gp";
	while(s1.size()<=1e5+3)
	{
		s1+=s1;
	}
	ll ans=0;
	for(ll i=0;i<s.size();i++)
	{
		if(s[i]=='g')
		{
			if(s1[i]=='p')
				ans++;
		}
		else
		{
			if(s1[i]=='g')
				ans--;
		}
	}
	cout<<max(0ll,ans);
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}



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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int k, s;
int solve()
{
	int ret = 0;
	for(int i = 0; i <= k; ++i)
		for(int j = 0; j <= k; ++j) {
			int l = s - i - j;
			if(l >= 0 && l <= k)
				++ret;
		}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> k >> s;

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int bingo[9];
    for(int i=0;i<9;i++){
        cin>>bingo[i];
    }
    int n;
    cin>>n;
    int vec[n];
    for(int i=0;i<n;i++) cin>>vec[i];
    for(int i=0;i<9;i++){
        for(int j=0;j<n;j++){
            if(bingo[i]==vec[j]) bingo[i]=0;
        }
    }
    if(bingo[0]==bingo[1] && bingo[1]==bingo[2]) cout<<"Yes"<<endl;
    else if(bingo[3]==bingo[4] && bingo[4]==bingo[5]) cout<<"Yes"<<endl;
    else if(bingo[6]==bingo[7] && bingo[7]==bingo[8]) cout<<"Yes"<<endl;
    else if(bingo[0]==bingo[3] && bingo[3]==bingo[6]) cout<<"Yes"<<endl;
    else if(bingo[1]==bingo[4] && bingo[4]==bingo[7]) cout<<"Yes"<<endl;
    else if(bingo[2]==bingo[5] && bingo[5]==bingo[8]) cout<<"Yes"<<endl;
    else if(bingo[0]==bingo[4] && bingo[4]==bingo[8]) cout<<"Yes"<<endl;
    else if(bingo[2]==bingo[4] && bingo[4]==bingo[6]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i;
    int j;
    char a[ ( 6 + 2 ) * 9 * 9 + 1 ] = { 0 };
    int p;

    p = 0;
    for ( i = 1; i < 10; i ++ ) {
        for ( j = 1; j < 10; j ++ ) {
            p += sprintf( a + p, "%1dx%1d=%d\n", i, j, i * j );
        }
    }
    a[ p ] = '\0';
    printf( "%s", a );
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  
  int n;
  cin>>n;
  
  int a[n-1];
  
  for(int i=0;i<n-1;i++)cin>>a[i];
  
  int s=a[n-2];
  
  for(int i=n-3;i>=0;i--)
  s+=min(a[i],a[i+1]);
  s+=a[0];
  
  cout<<s;
 return 0; 
}

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

import math

mod = 10**9+7

x, y = list(map(int, input().split()))

# dp = [[0]*(y+1) for _ in range(x+1)]
# dp[0][0] = 1
# for x_tmp in range(1, x+1):
#     for y_tmp in range(1, y+1):
#         print(x_tmp, y_tmp)

#         if x_tmp-2 >= 0 and y_tmp-1 >= 0:
#             dp[x_tmp][y_tmp] += dp[x_tmp-2][y_tmp-1] % mod
#         if x_tmp-1 >= 0 and y_tmp-2 >= 0:
#             dp[x_tmp][y_tmp] += dp[x_tmp-1][y_tmp-2] % mod

# print(dp[-1][-1] % mod)


def comb(n, r):
    X = Y = 1
    if r < 0 or n < r:
        return 0
    if r == 0:
        return 1
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % mod
        X = X*(n-i+1) % mod
    Y = pow(Y, mod-2, mod)
    return X*Y


if (x+y) % 3 != 0:
    print(0)
    exit()

num = min(x, y)-(x+y)//3
if num < 0:
    print(0)
    exit()

# print((x+y)//3, num)
print(comb((x+y)//3, num) % mod)


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

int main(){
  string S;
  cin >> S;
  for(int i=0; i<5; i++) cout << S.at(i);
  cout << ' ';
  for(int i=6; i<13; i++) cout << S.at(i);
  cout << ' ';
  for(int i=14; i<19; i++) cout << S.at(i);
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	
	int lim = 0;
	if(n < k) lim = n;
	else lim = k;
	
	long long int ans = 0;
	for(int i = 1;i <= lim;i++){
		if((i * 2) % k == 0){
			int a = (n - i) / k;
			if(a == 0){
				ans++;
			}else{
				long long int p = 1;
				for(int j = 0;j < 3;j++) p *= a+1;
				ans += p;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 20;

struct State {
    int l, r;
    ll cl, cr;

    State() {}
    State(int l, int r, ll cl, ll cr) : l(l), r(r), cl(cl), cr(cr) {}

    bool operator<(const State &rhs) const {
        if (l != rhs.l) return l < rhs.l;
        if (r != rhs.r) return r < rhs.r;
        if (cl != rhs.cl) return cl < rhs.cl;
        return cr < rhs.cr;
    }
};

int N;
ll A[MAX_N];
map<State, ll> _F;

ll F(int l, int r, ll cl, ll cr) {
    if (l > r) return 0;
    State st(l, r, cl, cr);
    if (_F.count(st)) return _F[st];
    ll &res = _F[st] = LLONG_MAX;
    for (int i = l; i <= r; i++) {
        res = min(res, F(l, i - 1, cl, cl + cr) + F(i + 1, r, cl + cr, cr) + (cl + cr) * A[i]);
    }
    return res;
}

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%lld", &A[i]);
    ll ans = F(2, N - 1, 1, 1) + A[1] + A[N];
    printf("%lld\n", ans);
}


Measured memory_bytes: 20736