akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int Q;
	cin >> Q;

	priority_queue<int> lh;
	priority_queue<int, vector<int>, greater<int>> uh;

	int lh_cnt = 0, uh_cnt = 0;
	lint lh_sum = 0, uh_sum = 0;
	lint B = 0;

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

		int q;
		cin >> q;

		if (q == 1) {

			int a, b;
			cin >> a >> b;

			B += b;

			if (lh.empty() || lh.top() > a) {

				if (lh_cnt == uh_cnt) {
					
					lh.emplace(a);
					lh_sum += a;

					lh_cnt++;

				}
				else { 

					assert(lh_cnt > uh_cnt);

					lh.emplace(a);
					lh_sum += a;

					int tmp = lh.top();
					lh.pop();
					uh.emplace(tmp);
					lh_sum -= tmp;
					uh_sum += tmp;

					uh_cnt++;

				}

			}

			else {
			
				if (lh_cnt == uh_cnt) {

					uh.emplace(a);
					uh_sum += a;

					int tmp = uh.top();
					uh.pop();
					lh.emplace(tmp);
					uh_sum -= tmp;
					lh_sum += tmp;

					lh_cnt++;

				}
				else {

					assert(lh_cnt > uh_cnt);

					uh.emplace(a);
					uh_sum += a;

					uh_cnt++;

				}

			}


		}
		else {
			int min_x = lh.top();
			cout << min_x << " " << uh_sum - lh_sum + B + (lh_cnt != uh_cnt) * min_x << "\n";
		}

	}

	return 0;
}

Measured memory_bytes: 3452
/**
 * ?????¬???????????????

??\????????????????????????H cm ?????? W cm ???????????????????????°?????????????????????????????????

##########
#........#
#........#
#........#
#........#
##########
?????????????????? 6 cm ?????? 10 cm ???????????¨??????????????????

Input
??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????

H W

H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????

Output
?????????????????????????????????????????? H cm ?????? W cm ?????????????????????????????????

?????????????????????????????????????????????????????\??????????????????

Constraints
3 ??? H, W ??? 300

Sample Input
3 4
5 6
3 3
0 0
Sample Output
####
#..#
####

######
#....#
#....#
#....#
######

###
#.#
###

 */
#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  unsigned int H, W;

  while (true) {
    while (true) {
      std::string Param;

      getline(std::cin, Param);
      std::istringstream iss(Param);
      iss >> H >> W;

      if ((H < 3 && H != 0) || H > 300 || (W < 3 && W != 0) || W > 300) {
        std::cout << "Error: 3 <= H, W <= 300" << std::endl;
      } else {
        break;
      }
    }
    if (H == 0 && W == 0) {
      break;
    } else {
      for (size_t i = 0; i < W; i++) {
        std::cout << "#";
      }
      std::cout << std::endl;
      for (size_t i = 0; i < H - 2; i++) {
        std::cout << "#";
        for (size_t j = 0; j < W - 2; j++) {
          std::cout << ".";
        }
        std::cout << "#" << std::endl;
      }
      for (size_t i = 0; i < W; i++) {
        std::cout << "#";
      }
      std::cout << std::endl;
      std::cout << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3192
#include<stdio.h>

int main(void){
 int bingo[3][3];
  int i;
  
  for(i=0; i<3; i++){
    scanf("%d%d%d", &bingo[0][i], &bingo[1][i], &bingo[2][i]);
  }
  
  int N;
  scanf("%d", &N);
  
  int ans[N];
  
  for(i=0; i<N; i++){
    scanf("%d", &ans[i]);
  }
  
  int m, NN;
  for(i=0; i<3; i++){
    for(m=0; m<3; m++){
      for(NN=0; NN<N; NN++){
        
        if(bingo[i][m] == ans[NN]){
          bingo[i][m] = 0;
        }
        
      }
    }
  }
  
  for(i=0; i<3; i++){
  if(bingo[i][0] == 0 && bingo[i][2] == 0 && bingo[i][1] == 0){
    printf("Yes");
    return 0;
  }
    
    if(bingo[0][i] == 0 && bingo[2][i] == 0 && bingo[1][i] == 0){
    printf("Yes");
    return 0;
  }
  }
  
  if(bingo[1][1] == 0 && bingo[2][2]==0 && bingo[0][0] == 0){
    printf("Yes");
    return 0;
  }
  
  if(bingo[2][0] == 0 && bingo[1][1] == 0 && bingo[0][2]==0){
        printf("Yes");
    return 0;
  }
  

  
  
  printf("No");
  return 0;  
}

Measured memory_bytes: 128
#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<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#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;
signed main(){
	
	int m,n,count=0;
	set<int> s;
	cin>>m;
	while(count==s.size()){
		count++;
		if(count==1){s.insert(n=m);continue;}
		if(n%2==0)s.insert(n=n/2);
		else s.insert(n=n*3+1);
	}
	cout<<count<<endl;
	

}

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


signed main()
{
    int n , m , high , low , mid , ans = 0;
    long long k , a[200001] , b[200001];
    
    a[0] = b[0] = 0;
    cin >> n >> m >> k;
    for(int i=1 ;i<=n ;i++ ){
        cin >> a[i];
        a[i] += a[i-1];
    }
    for(int i=1 ;i<=m ;i++ ){
        cin >> b[i];
        b[i] += b[i-1];
    }
    
    for(int i=0 ;i<=n ;i++ ){
        
        if(a[i] <= k){
            high = m + 1 , low = -1;
            mid = (high + low) / 2;
            while(high - low > 1){
                
                if(a[i] + b[mid] <= k){
                    low = mid;
                }
                else {
                    high = mid;
                }
                
                mid = (high + low) / 2;
            }
            ans = max(ans , i + mid);
        }
    }
    
    cout << ans << endl;
    
    return (0);
}

Measured memory_bytes: 6768
#include <bits/stdc++.h>
#include <iostream>
#include <cstdlib>

#include <algorithm>
#include <string>
using namespace std;

int main() {
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
  transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
  transform(s3.begin(), s3.end(), s3.begin(), ::toupper);
  cout<<s1[0]<<s2[0]<<s3[0]<<endl;

  }


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


def solve(N: int, A: "List[int]"):
    m = 0
    ans = 0
    for i in range(N) :
        m = max(m,A[i])
        if(A[i] < m):
            ans += m - A[i]
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 33220
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using u64 = uint64_t;

using namespace std;

int main(void)
{
  u64 N, W, w1, v1;
  cin >> N >> W;
  array<vector<u64>, 4> table;
  cin >> w1 >> v1;
  table[0].push_back(v1);
  for(int i = 1; i < N; i++){
    u64 w, v;
    cin >> w >> v;
    table[w-w1].push_back(v);
  }
  for(auto& x : table){
    x.push_back(10000000 + 1);
    sort(x.rbegin(), x.rend());
    x[0] = 0;
    for(int i = 0; i < x.size() - 1; i++){
      x[i+1] += x[i];
    }
  }

  u64 ans = 0;
  for(int l = 0; l < table[0].size(); l++){
    for(int m = 0; m < table[1].size(); m++){
      for(int n = 0; n < table[2].size(); n++){
        for(int o = 0; o < table[3].size(); o++){
          auto w = l*(w1+0) + m*(w1+1) + n*(w1+2) + o*(w1+3);
          if(w > W) continue;
          u64 v = table[0][l] + table[1][m] + table[2][n] + table[3][o];
          ans = max(ans, v);
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input macros
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){

    input!{
        N: usize,
    }

    println!("{}", N*(N+1)/2);
}

Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int Q=1<<17,MOD=1e9+7;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
inline int mul(int a,int b)
{return 1LL*a*b%MOD;}
int a[Q];
int vis[Q];
int pi=1,maxn=0;
int val[Q];
int cir[Q];
void dfs(int x,int Time)
{
    if(vis[x]){
        if(vis[x]!=Time||cir[x])return;
        cir[x]=1;
        for(int t=a[x];t!=x;t=a[t])
            cir[t]=1;
        return;
    }
    vis[x]=Time;
    dfs(a[x],Time);
}
int in[Q];
#define GG return puts("0")&0
int f[Q];
int Ga(int x)
{return cir[x]?x:(a[x]=Ga(a[x]));}
int len[Q];
int l[Q];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]),++in[a[i]];
    for(int i=1;i<=n;i++)
        if(in[i]>2)GG;
    for(int i=1;i<=n;i++)
        if(!vis[i])dfs(i,i);
    for(int i=1;i<=n;i++){
        if(!cir[i])
            if(in[i]>1)GG;
        ++len[Ga(i)];
    }
    for(int i=1;i<=n;i++)
    if(cir[i]&&vis[i]!=-1){
        int mx=0;
        for(int t=i;vis[t]!=-1;t=a[t]){
            vis[t]=-1;
            l[++mx]=len[t]-1;
        }
        for(int i=1;i<=mx;i++)
            l[mx+i]=l[i];
        int lst=998244353,mus=0;
        for(int i=(mx<<1);i;--i)
            if(l[i]){
                if(lst-i<mus)GG;
                if(lst-i>mus&&lst>mx&&lst<=(mx<<1))pi=mul(pi,2);
                lst=i;
                mus=l[i];
            }
        if(lst>n)val[++maxn]=mx;
    }
    sort(val+1,val+maxn+1);
    f[0]=1;
    for(int i=1,had=0;i<=maxn;i++){
        if(val[i]==val[i-1])++had;
        else had=0;
        f[i]=add(mul(f[i-1],((val[i]&1)&(val[i]>1))+1),i==1?0:mul(mul(had,val[i]),f[i-2]));
    }
    printf("%d",mul(f[maxn],pi));
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int N,K;
    cin>>N>>K;
    if(N==1)
    {
        cout<<0;
        return 0;
    }
    int h[N];
    
    for(int i=0;i<N;i++)
    {
        cin>>h[i];
    }
    
    int val[N];
  for(int i=0;i<N;i++)
  {
    val[i]=INT_MAX;
  }
    val[0]=0;
    
    for(int i=1;i<N;i++)
    {
        for(int j=i-1;j>=0 && i-j<=K;j--)
        {
          val[i]=min(val[i],abs(h[i]-h[j])+val[j]);
        }
    }
  
    cout<<val[N-1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 +c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,X,a[205],fac[205],inv[205];
int dp[205][100005];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    read(N);read(X);
    for(int i = 1 ; i <= N ; ++i) read(a[i]);
    sort(a + 1,a + N + 1,[](int a,int b){return a > b;});
    fac[0] = 1;
    for(int i = 1 ; i <= N ; ++i) fac[i] = mul(fac[i - 1],i);
    inv[1] = 1;
    for(int i = 2 ; i <= N ; ++i) inv[i] = mul(inv[MOD % i],MOD - MOD / i);
    dp[0][X] = 1;
    for(int i = 1 ; i <= N ; ++i) {
        for(int j = 0 ; j <= X ; ++j) {
            if(j < a[i]) update(dp[i][j],dp[i - 1][j]);
            else {
                update(dp[i][j % a[i]],mul(dp[i - 1][j],inv[N - i + 1]));
                update(dp[i][j],mul(dp[i - 1][j],mul(N - i,inv[N - i + 1])));
            }
        }
    }
    int ans = 0;
    for(int j = 0 ; j <= X ; ++j) {
        update(ans,mul(dp[N][j],j));
    }
    ans = mul(ans,fac[N]);
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 79744
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, M;
  cin>>N>>M;
  vector<vector<ll> > edge(N);
  ll A, B;
  for(ll i=0;i<M;++i) {
    cin>>A>>B;
    A--;
    B--;
    edge[A].push_back(B);
    edge[B].push_back(A);
  }
  queue<pair<ll, ll> > que;
  que.push(mp(0, 0));
  map<pair<ll, ll>, ll> amap;
  pair<ll, ll> state;
  ll node, dist;
  while(!que.empty()) {
    state = que.front();que.pop();
    node = state.fi;
    dist = state.se%2;
    if(amap[mp(node, dist%2)]>0) continue;
    amap[mp(node, dist%2)]++;
    for(ll i=0;i<edge[node].size();++i) {
      if(amap[mp(node, (dist+1)%2)]>0) continue;
      que.push(mp(edge[node][i], (dist+1)%2));
    }
  }
  ll onenum = 0, zeronum = 0, bothnum = 0;
  for(ll i=0;i<N;++i) {
    if(amap[mp(i, 0)]>0 && amap[mp(i, 1)]==0) zeronum++;
    if(amap[mp(i, 1)]>0 && amap[mp(i, 0)]==0) onenum++;
    if(amap[mp(i, 1)]>0 && amap[mp(i, 0)]>0) bothnum++;
  }
  if(bothnum>0) cout<<N*(N-1)/2-M<<endl;
  else cout<<onenum*zeronum-M<<endl;
}


Measured memory_bytes: 21684
#include<cstdio>

int main(){
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    
    printf("%d %d ", d, r);
    printf("%.5lf", f);
}


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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int H, W, h, w;
   cin >> H >> W >> h >> w;
   if (H % h == 0 && W % w == 0) {
      cout << "No\n";
      return 0;
   }
   cout << "Yes\n";
   for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
         if (i % h == h - 1 && j % w == w - 1) {
            cout << -1403 * (h * w - 1) - 1 << " ";
         } else {
            cout << 1403 << " ";
         }
      }
      cout << "\n";
   }
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int a, b;
  cin >> a >> b;
  if(a < b) {
    cout << 0;
  } else
    cout << 10;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
    val revA = A.reversedArray()

    val l = LongArray(N+1)
    val r = LongArray(N+1)
    for(i in 1..N){
        l[i] = A[i - 1] + l[i - 1]
        r[i] = revA[i - 1] + r[i - 1]
    }

    var min = Long.MAX_VALUE / 10
    for(i in 1 until N){
        min = Math.min(min, Math.abs(l[i] - r[N - i]))
    }
    println(min)
}

Measured memory_bytes: 84604
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd>> Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

bool able(ll x, ll y){
    if(y%2) return false;
    if(y>4*x) return false;
    if(y<2*x) return false;
    return true;
}
int main(){
    ll X,Y; cin>>X>>Y;
    if(able(X,Y)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
int gcd(ll a, ll b){
    if(b == 0) return a;
    gcd(b,a%b);
}


int main() {
int N;
cin >> N;
vector<pair<int,int>> p(N);

for(int i = 0;i<N;i++){
  cin >> p[i].first;
  p[i].second = i+1;
}
sort(p.begin(),p.end());
for(int i = 0;i<N;i++){
  cout << p[i].second << " ";
}
cout << endl;
}

Measured memory_bytes: 1536
class Solver
  @@count = 0
  @@a

  def self.init_a(a)
    @@a = a
  end

  def self.merge(left, mid, right)
    n1 = mid - left
    n2 = right - mid
    l = @@a[left..mid]
    r = []

    (0..n2-1).each do |i|
      r[i] = @@a[mid + i]
    end
  
    l[n1] = Float::INFINITY
    r[n2] = Float::INFINITY
    i = 0
    j = 0
    (left..right-1).each do |k|
      if l[i] <= r[j]
        @@a[k] = l[i]
        i = i + 1
      else
        @@count += l.size - (i+1)
        @@a[k] = r[j]
        j = j + 1
      end
    end
  end
  
  def self.mergeSort(left, right)
    if left+1 < right
      mid = (left + right)/2
      mergeSort(left, mid)
      mergeSort(mid, right)
      merge(left, mid, right)
    end
  end

  def self.puts_result
    puts @@count
  end
end

n = gets.to_i
a = gets.split(' ').map(&:to_i)
Solver.init_a(a)
Solver.mergeSort(0, n)
Solver.puts_result


Measured memory_bytes: 33108
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			char[] c = sc.next().toCharArray();
			for(int i = 0; i < c.length; i++){
				if(c[i] == '@'){
					for(int j = 0; j < c[i+1] - '0'; j++){
						System.out.print(c[i+2]);
					}
					i += 2;
				}else{
					System.out.print(c[i]);
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 25876
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;

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

const int mod = 1000000007;

int main() {
  int n, r;
  cin >> n >> r;

  if (n < 10) {
    r = r + (100 * (10 - n));
  }
  cout << r << 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);
		String S = sc.next();
		boolean possible = false;

		for (int i = 0; i < S.length(); i++) {
			if (i % 2 == 0 && ("R".equals(String.valueOf(S.charAt(i)))
					|| "U".equals(String.valueOf((S.charAt(i))))
					|| "D".equals(String.valueOf((S.charAt(i)))))) {
				possible = true;
				continue;
			} else if (i % 2 == 1 && ("L".equals(String.valueOf(S.charAt(i)))
					|| "U".equals(String.valueOf((S.charAt(i))))
					|| "D".equals(String.valueOf((S.charAt(i)))))) {
				possible = true;
				continue;
			}
			possible = false;
			break;
		}

		if (possible) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
using System;

namespace ConsoleApplicationSample
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            //[0,] スペード
            //[1,] ハート
            //[2,] クラブ
            //[3,] ダイヤ
            bool[,] card = new bool[4, 13];
            for (int i = 0; i < n; i++)
            {
                string[] s = Console.ReadLine().Split();
                int rank = int.Parse(s[1]);
                CardCount(card, s, rank);
            }

            WriteShortageCard(card);
        }

        private static void CardCount(bool[,] card, string[] s, int rank)
        {
            switch (s[0])
            {
                case "S":
                    card[0, rank - 1] = true;
                    break;
                case "H":
                    card[1, rank - 1] = true;
                    break;
                case "C":
                    card[2, rank - 1] = true;
                    break;
                case "D":
                    card[3, rank - 1] = true;
                    break;
                default:
                    break;
            }
        }

        private static void WriteShortageCard(bool[,] card)
        {
            string[] picture = { "S", "H", "C", "D" };

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 13; j++)
                {
                    if (false == card[i, j])
                    {
                        Console.WriteLine("{0} {1}", picture[i], j + 1);
                    }
                }
            }
        }

    }

}

Measured memory_bytes: 5760
#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 <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int a;
    cin >> a;
    set<string> z;
    for (int i = 0; i < a; i++) {
        string x;
        cin >> x;
        z.insert(x);
    }
    cout << z.size() << endl;
}

Measured memory_bytes: 19224
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   ll n,m,i,a,cnt,j,t;
   while(cin>>n)
   {
       cnt=0;
       set<ll>st;
       for(i=1;i<=n;i++)
       {
           cin>>a;
           st.insert(a);
           if(cnt+1!=st.size())
           {
               st.erase(a);
               cnt=st.size();
           }
           else cnt=st.size();
       }
       cout<<st.size()<<endl;
   }
   return 0;
}



Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(c<=a) a-=c;
	else{
		b=max((ll)0,b-(c-a));
		a=0;
	}
	cout<<a<<' '<<b<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=310;
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int n,m,mp[Maxn][Maxn],st,ed;
int num[Maxn][Maxn],tot=0;
char s[Maxn];
struct Edge{int y,d,next;}e[Maxn*Maxn*12];
int last[Maxn*Maxn<<1],cur[Maxn*Maxn<<1],len=1;

void ins(int x,int y,int d)
{
	int t=++len;
	e[t].y=y;e[t].d=d;
	e[t].next=last[x];last[x]=t;
}
void addedge_1(int x,int y,int d){ins(x,y,d),ins(y,x,0);}
//void addedge_2(int x,int y,int d){/*printf("%d %d %d\n",x,y,d);*/ins(x,y,d),ins(y,x,d);}
void addedge_2(int x,int y,int d){/*printf("%d %d %d\n",x,y,d);*/addedge_1(x,y,d),addedge_1(y,x,d);}
int h[Maxn*Maxn<<1];
bool bfs()
{
	memset(h,0,sizeof(h));h[st]=1;
	static queue<int>q;q.push(st);
	while(!q.empty())
	{
		int x=q.front();q.pop();
		for(int i=last[x];i;i=e[i].next)
		{
			int y=e[i].y;
			if(e[i].d>0&&!h[y])h[y]=h[x]+1,q.push(y);
		}
	}
//	puts("=========");
	return h[ed];
}
int dfs(int x,int f)
{
	if(x==ed)return f;
	int s=0,t;
	for(int i=cur[x];i;i=e[i].next)
	{
		int y=e[i].y;
		if(e[i].d>0&&h[y]==h[x]+1&&s<f)
		{
			cur[x]=i;
			t=dfs(y,min(e[i].d,f-s));
			s+=t;e[i^1].d+=t;e[i].d-=t;
		}
	}
	if(!s)h[x]=0;
	return s;
}
int main()
{
//	freopen("trade.in","r",stdin);
//	freopen("trade.out","w",stdout);
	n=read(),m=read();
	int stx,sty,edx,edy;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)
		{
			if(s[j]=='S')stx=i,sty=j,mp[i][j]=1;
			else if(s[j]=='T')edx=i,edy=j,mp[i][j]=2;
			else if(s[j]=='.')mp[i][j]=3;
			else mp[i][j]=4,num[i][j]=++tot;
		}
	}
	if(stx==edx||sty==edy)return puts("-1"),0;
	st=(tot<<1)+1,ed=(tot<<1)+2;
	for(int i=1;i<=n;i++)
	{
		int t=-1;
		for(int j=1;j<=m;j++)
		if(mp[i][j]!=3)
		{
			if(t!=-1)
			{
				int t1=num[i][t],t2=num[i][j];
				if(mp[i][t]==1)t1=st;
				if(mp[i][t]==2)t1=ed;
				if(mp[i][j]==1)t2=st;
				if(mp[i][j]==2)t2=ed;
				addedge_2(t1,t2,inf);
			}
			t=j;
		}
	}
	for(int j=1;j<=m;j++)
	{
		int t=-1;
		for(int i=1;i<=n;i++)
		if(mp[i][j]!=3)
		{
			if(t!=-1)
			{
				int t1=num[t][j]+tot,t2=num[i][j]+tot;
				if(mp[t][j]==1)t1=st;
				if(mp[t][j]==2)t1=ed;
				if(mp[i][j]==1)t2=st;
				if(mp[i][j]==2)t2=ed;
				addedge_2(t1,t2,inf);
			}
			t=i;
		}
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++)
	if(mp[i][j]==4)addedge_2(num[i][j],num[i][j]+tot,1);
//	printf("%d %d\n",len,ed);
	int ans=0;
	while(bfs())
	{
		memcpy(cur,last,sizeof(cur));
		ans+=dfs(st,inf);
	}
	printf("%d",ans);
}


Measured memory_bytes: 5888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String n = sc.next();
		
		char[] a = n.toCharArray();
		
		if(a[2] == a[3] && a[4] == a[5]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		

	}

}


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

int main(){
    i64 n,m;
    cin>>n>>m;
    vector<i64> h(n);
    bool t[n];
    for(i64 i=0;i<n;i++) {
        cin>>h[i];
        t[i]=true;
    }
    for(i64 i=0;i<m;i++){
        i64 a,b;
        cin>>a>>b;
        if(h[a-1]<h[b-1]) t[a-1]=false;
        else if(h[a-1]>h[b-1]) t[b-1]=false;
        else{
            t[a-1]=false;
            t[b-1]=false;
        }
    }
    i64 ans=0;
    for(i64 i=0;i<n;i++){
        if(t[i]) ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 4052
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int main()
{
	ll n;
	read(n);
	for (int i=sqrt(n)+1;i>=1;i--)
		if (n%i==0) return printf("%lld",i+n/i-2),0;
	return 0;
}









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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            for(int i =0; i < s.Length; i++)
            {
                var a = zurasu(N, s[i]);
                Console.Write(a);
            }
        }
        
        static char zurasu(int n ,char c)
        {
            int flag;

            if ((int)c + n > 90)
            {
                flag = (int)c + n - 90;
                c = (char)(64 + flag);
            }
            else
            {
                c = (char)((int)c + n);
            }
            return c;
        }
    }

}


Measured memory_bytes: 11164
#include <stdio.h>
 
int main()
{
  int N,n;
  scanf("%d",&N);
 
  n = N%10;
 
  if(n == 3)
    printf("bon");
  else if (n == 0 || n == 1 || n == 6 || n == 8)
    printf("pon");
  else
    printf("hon");
 
  return 0;
}


Measured memory_bytes: 1712
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1), B(N),C(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	A[N] = 0;
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N - 1; i++) {
		cin >> C[i];
	}
	int sum = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] == A[i + 1] - 1) {
			sum += B[A[i] - 1] + C[A[i] - 1];
		}
		else {
			sum += B[A[i] - 1];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
signed main() {
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
	ggr
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import math
N = int(input())
Cs = []
Ss = []
Fs = []
for n in range(N-1):
    C, S, F = map(int, input().split())
    Cs.append(C)
    Ss.append(S)
    Fs.append(F)

for n in range(N-1):
    current_time = 0
    for i in range(n,N-1,1):
        if Ss[i] - current_time <= 0:
            tmp = (current_time + Ss[i]) % Fs[i]
            wait_time = (Fs[i] - tmp) % Fs[i]
            #print('after first train')
            #print(n, i, wait_time)
        else:
            wait_time = (Ss[i] - current_time)
            #print('before first train')
            #print(n, i, wait_time)
        current_time += wait_time
        current_time += Cs[i]
        #print("current_time", current_time)
    print(current_time)
print(0)


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

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a;

    for(int i=0; i<q; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
 
    int ok[n]={};
    for(int i=0; i<q; i++){
        ok[a[i]-1]++;
    }

    //cout << ok[4] << endl;

    for(int i=0; i<n; i++){
        if(k-q+ok[i]>0)cout << "Yes";
        else cout << "No";
        cout << endl;
    }
    cout << endl;
}

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

void solve()
{
    string s,t;
    cin>>s>>t;
    string temp="";
    for(int i=0;i<(int)t.length()-1;i++)
        temp+=t[i];
    if(temp==s) cout<<"Yes\n";
    else cout<<"No\n";
}

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

Measured memory_bytes: 3652
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int min = 0;
		int midle = 0;
		int max = 0;
		
		for(int i = 0; i < a; i++){
			int d = sc.nextInt();
			if(d<=b){
				min++;
			}else if(b+1<=d && d<=c){
				midle++;
			}else if(d>=c+1){
				max++;
			}
		}
		System.out.println(Math.min(Math.min(min,max),midle));
	}
}

Measured memory_bytes: 22608
use std::io::*;

fn main() {
  let stdin = stdin();
  let mut lines = stdin.lock().lines().map(|l| l.unwrap());

  let n = lines.next().unwrap().parse().unwrap();
  let nums = lines.take(n).map(|s| s.parse::<u32>().unwrap());

  let count = nums.filter(|&num| {
    if num == 2 {
      true
    }
    else if num % 2 == 0 {
      false
    }
    else {
      let end = (num as f64).sqrt().floor() as u32;

      for i in (1 .. (end + 1) / 2) {
        if num % (i * 2 + 1) == 0 {
          return false
        }
      }
      true
    }
  }).count();

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



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

template<class T> inline bool chmin(T& a,T b){
    if( a > b) {a = b; return 1; } return 0;
}
#define int long long
int dp[100010];
int h[100010];

const int INF = 1LL << 60;

signed main(){
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < 100010; i++)
    dp[i] = INF;

    dp[0] = 0;
    for(int i = 1; i < n; i++){
        chmin(dp[i], dp[i - 1] + abs(h[i - 1] - h[i]));
        if(i != 1)
        chmin(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));

    }
    cout << dp[n - 1] << endl;
 }



Measured memory_bytes: 1792
#include <iostream>
#define endl '\n'
using namespace std;
int a, b, c, k, s = 0;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> c >> k;
    if (a < k)
    {
        if (a + b < k)
        {
            if (a + b + c == k)
                cout << a - c << endl;
            else
                cout << a - (k - a - b) << endl;
        }
        else
            cout << a << endl;
    }
    else
        cout << k << endl;
    return 0;
}


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

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

    if (n == 2) 
    {
        int tmp;
        cin >> tmp;
        cout << tmp * 2 << endl;
        return 0;
    }

    int prev, post;
    cin >> prev;
    int sum = prev;
    for(int i = 1; i < n - 1; i++)
    {
        cin >> post;
        if(prev > post) sum += post;
        else sum += prev;
        prev = post;
    }
    sum += post;
    cout << sum << endl;
}

Measured memory_bytes: 256
///                    بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
///                   لآ اِلَهَ اِلّا اللّهُ مُحَمَّدٌ رَسُوُل اللّهِ




#include <bits/stdc++.h>

using namespace std;
#define endl "\n"

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
    double a, b, c;
    cin >> a >> b >> c;
    if((a/c) <= b) cout << "Yes" << endl;
    else cout << "No" <<  endl;


	return 0;
}



Measured memory_bytes: 3748
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def ceil(x):
    return int((-x)//1*(-1))


N, A, B = map(int, input().split())
hp = [int(input()) for _ in range(N)]
diff = A-B


def check(x, HP):
    cnt = 0
    for i in range(N):
        if HP[i]-B*x <= 0:
            break
        else:
            cnt += ceil((HP[i]-B*x)/diff)
    return cnt <= x


def solve2():
    HP = sorted(hp, reverse=True)
    mi = HP[0]//A
    ma = ceil(HP[0]/B)
    while mi <= ma:
        mid = (mi+ma)//2
        if check(mid, HP):
            ma = mid-1
        else:
            mi = mid+1
    print(mi)


solve2()


Measured memory_bytes: 44764
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

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

    int k, q;
    cin >> k >> q;

    vector<int64> ds(k);
    for (int i = 0; i < k; i++) {
        cin >> ds[i];
    }

    for (int i = 0; i < q; i++) {
        // 第n項の値を求める
        int64 n, x, m;
        cin >> n >> x >> m;

        vector<int64> new_ds(begin(ds), end(ds));
        int64 sum = 0;
        for (int j = 0; j < k; j++) {
            new_ds[j] %= m;
            if (new_ds[j] == 0) {
                new_ds[j] = m;
            }
            sum += new_ds[j];
        }
        int64 nth = x % m + (n - 1) / k * sum;
        for (int j = 0; j < (n - 1) % k; j++) {
            nth += new_ds[j];
        }
        cout << (n - 1) - nth / m << endl;
    }

    return 0;
}



Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

const int mxn = 1e5 + 10, mod = 1e9 + 7;
vector<int> g[mxn];
int n, s;
int dp[mxn][2];
bool c[mxn][2];

// dp[u][col] = number of ways to color the subtree rooted at 'u'
// 				if u is colored with color 'col'

int f(int u, int col, int par)
{
	if(c[u][col])
		return dp[u][col];

	if(col)
	{
		dp[u][col] = 1;
		for(int v : g[u])
		{
			if(v != par)
				dp[u][col] = (dp[u][col] * f(v, 0, u)) % mod;
		}
	}
	
	else
	{
		dp[u][col] = 1;
		for(int v : g[u])
		{
			if(v != par)
			{
				int ans = (f(v, 0, u) + f(v, 1, u)) % mod;
				dp[u][col] = (dp[u][col] * ans) % mod;
			}
		}
	}
	c[u][col] = 1;
	return dp[u][col];
}

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	FOR(i, 1, n)
		g[i].clear();

	memset(c, 0, sizeof(c));

	FOR(i, 1, n - 1)
	{
		int u,v;	cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	int ans = (f(1, 0, -1) + f(1, 1, -1)) % mod;
	cout << ans;

	return 0;
}


Measured memory_bytes: 19176
N, T =  map(int, input().split())
n = []
t = []
ans = None
for i in range(N):
    ni, ti = map(int, input().split())
    n.append(ni)
    t.append(ti)

for i in range(N):
    if not T < t[i]:
        if ans == None:
            ans = n[i]
        elif ans > n[i]:
            ans = n[i]

if ans == None:
    print("TLE")
else:
    print(ans)


Measured memory_bytes: 3064
# -*- coding utf-8 -*-
from collections import defaultdict

MOD = 10 ** 9 + 7
N, Q = map(int, input().split())

tree = defaultdict(set)
for i in range(N - 1):
    a, b = map(int, input().split())
    tree[a].add(b)
    tree[b].add(a)

counter = defaultdict(int)
for i in range(Q):
    p, x = map(int, input().split())
    counter[p] += x

cur_node = set()
cur_node.add(1)
pre_node = set()
while len(cur_node) != 0:
    next_node = set()
    for ni in cur_node:
        for nj in tree[ni]:
            if nj in pre_node:
                continue
            counter[nj] += counter[ni]
            next_node.add(nj)
    pre_node = cur_node
    cur_node = next_node

print(' '.join((str(counter[i]) for i in range(1, N + 1))))


Measured memory_bytes: 125740
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<bool> v(55555 + 1);
	for (int i = 2; i < v.size(); i++) {
		if (!v.at(i)) {
			for (int j = i * 2; j < v.size(); j += i) {
				v.at(j) = true;
			}
		}
	}

	vector<int> a;
	for (int i = 2; i < v.size(); i++) {
		if (!v.at(i)) {
			if (i % 5 == 1) a.push_back(i);
		}
	}

	for (int i = 0; i < N; i++) {
		if (i) cout << ' ';
		cout << a.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 3644
local mmi, mma = math.min, math.max
local function combination_get_map(n)
  local combmap = {}
  for i = 1, n do
    combmap[i] = {}
    local ret = 1
    for j = 1, i do
      ret = ret * (i + 1 - j) // j
      combmap[i][j] = ret
    end
  end
  return combmap
end
local function combination_get_count(combmap, n, k)
  if k < 0 then return 0
  elseif n < k then return 0
  elseif k == 0 then return 1
  else return combmap[n][k]
  end
end

local function combination_get_array(combmap, n, k, idx)
  local rem = k
  local retary = {}
  for i = 1, n do
    local useCnt = combination_get_count(combmap, n - i, rem - 1)
    local unuseCnt = combination_get_count(combmap, n - i, rem)
    if idx <= useCnt then
      rem = rem - 1
      table.insert(retary, i)
    else
      idx = idx - useCnt
    end
  end
  return retary
end

local n, k = io.read("*n", "*n")
local a = {}
for i = 1, n do
  a[i] = io.read("*n")
end
local cmap = combination_get_map(n)
local tot = combination_get_count(cmap, n, k)
local mincost = 1000000007 * 100
for i = 1, tot do
  local cost = 0
  local ary = combination_get_array(cmap, n, k, i)
  local height = a[1]
  for j = 2, ary[1] do
    height = mma(height, a[j])
  end
  for j = 2, k do
    local pos = ary[j]
    for z = ary[j - 1] + 1, pos - 1 do
      height = mma(height, a[z])
    end
    local v = a[pos]
    if height < v then
      height = v
    else
      cost = cost + height + 1 - v
      height = height + 1
    end
  end
  mincost = mmi(mincost, cost)
end
print(mincost)


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

int main() {
    vector<int> d(3);

    for (int i = 0; i < 3; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());

    int x = d.at(2) - d.at(1);
    int y = d.at(2) - d.at(0);
    int ans;

    if (x % 2 == 0 && y % 2 == 0) {
        ans = x / 2 + y / 2;
    }

    else if (x % 2 == 1 && y % 2 == 1) {
        ans = x / 2 + y / 2 + 1;
    }

    else {
        ans = x / 2 + y / 2 + 2;
    }

    cout << ans << endl;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++) cin >> a.at(i);
  vector<vector<long long>> dp(H, vector<long long>(W, 0));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i+1 < H && a.at(i+1).at(j) == '.') {
        dp.at(i+1).at(j) = (dp.at(i+1).at(j) + dp.at(i).at(j)) % 1000000007;
      }
      if (j+1 < W && a.at(i).at(j+1) == '.') {
        dp.at(i).at(j+1) = (dp.at(i).at(j+1) + dp.at(i).at(j)) % 1000000007;
      }
    }
  }
  cout << dp.at(H-1).at(W-1) << endl;
}

Measured memory_bytes: 9216