akhauriyash/Code-Regression huggingface dataset:
import java.{util => ju}
import scala.collection.{mutable => mu}
import MyPredef._


object Main extends App {
    val H,W = nextLong
    var h=Math.min(H,W)
    var w=Math.max(H,W)
    //val h=Math.max(H,W)
    //val w=Math.min(H,W)
    //val h=H
    //val w=W
    
    val res = if(h%3==0||w%3==0){
        0
    }else{
        var res = h
        
        (Math.max(w/3,0) to Math.min(w,w/3+1)).foreach(x => {
            val wx = w-x
            val h0 = h/2
            val h1 = h-h/2
            val can = Seq(x*h,wx*h0,wx*h1)
            res = Math.min(res,can.max-can.min)
        })
         
        (Math.max(h/3,0) to Math.min(h,h/3+1)).foreach(x => {
            val hx = h-x
            val w0 = w/2
            val w1 = w-w/2
            val can = Seq(x*h,hx*w0,hx*w1)
            res = Math.min(res,can.max-can.min)
        })
        
        h=Math.max(H,W)
        w=Math.min(H,W)
        
        (Math.max(w/3,0) to Math.min(w,w/3+1)).foreach(x => {
            val wx = w-x
            val h0 = h/2
            val h1 = h-h/2
            val can = Seq(x*h,wx*h0,wx*h1)
            res = Math.min(res,can.max-can.min)
        })
         
        /*
        (Math.max(h/3,0) to Math.min(h,h/3+1)).foreach(x => {
            val hx = h-x
            val w0 = w/2
            val w1 = w-w/2
            val can = Seq(x*h,hx*w0,hx*w1)
            res = Math.min(res,can.max-can.min)
        })
        */
        
        res
    }
    
    println(res)
}


object MyPredef {
  @inline def rep(n: Int, f: => Unit): Unit = { var c = 0; while (c < n) { f; c += 1 } }
  @inline def rep(n: Int, f: Int => Unit): Unit = { var c = 0; while (c < n) { f(c); c += 1 } }

  private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0
  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean =
    if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
    while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte =
    if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }
  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }
  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }
  def nextDouble(): Double = next.toDouble
}
object MyArray {
  def fillT[T : scala.reflect.ClassTag](dimX: Int, dimY: Int)(f: => T): Array[Array[T]] = {
    val arrs = Array.ofDim[T](dimX, dimY)
    for {
      y <- (0 until dimY)
      x <- (0 until dimX)
    } {
      arrs(x)(y) = f
    }
    arrs
  }
}

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, a, b, c;
	cin >> n;
	vector<vector<int>> dp(n, vector<int> (3));

	cin >> dp[0][0] >> dp[0][1] >> dp[0][2];

	for(int i = 1; i < n; i++) {
		cin >> a >> b >> c;
		dp[i][0] = max(a + dp[i-1][1], a + dp[i-1][2]);
		dp[i][1] = max(b + dp[i-1][0], b + dp[i-1][2]);
		dp[i][2] = max(c + dp[i-1][0], c + dp[i-1][1]);
	}

	int ans = max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main(){
  int a,b,c=10000,d=0,e;
  scanf("%d %d",&a,&b);
  for(int i=0; i<a; i++){
    scanf("%d",&e);
    b-=e;
    if(c>e){c=e;}
    d++;
  }
  printf("%d",d+b/c);
  return 0;}

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

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

  vector<int> H(N);
  vector<int> S(N);

  for(int i=0;i<N;i++) {
    cin >> H.at(i);
  }

  for(int i=0;i<N-1;i++) {
    if(H.at(i)>=H.at(i+1)) S.at(i) = 1;
    else S.at(i) = 0;
  }

  int cnt = 0;
  int max = 0;

  for(int i=0;i<N-1;i++) {
    if(S.at(i)) cnt++;
    else { 
      if(max<cnt) max = cnt;
      cnt = 0;
    }
  }

  if(max<cnt) max = cnt;

  cout << max << endl;

  return (0);
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std; 

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

int main(){
        IOS;
        ll n,x,t;
        cin>>n>>x>>t;
        cout<<((n-1+x)/x)*t<<"\n";
}


Measured memory_bytes: 3660
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int(), K = Reader.Int();
        var A = Reader.IntArray(N);
        long ans = 0;

        for (int i = 0; i + 1 < N; i++)
            if (A[i] + A[i + 1] > K)
            {
                int ate = Math.Min(A[i + 1], A[i] + A[i + 1] - K);
                A[i + 1] -= ate;
                ans += ate;
                if (A[i] + A[i + 1] > K)
                    ans += A[i] + A[i + 1] - K;
            }

        Console.WriteLine(ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 17360
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(int i = 0; i < N; i++)
#define repa(i, a, N) for(int i = a; i < N; i++)
#define repr(i, N) for(int i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

const ll mod = 1e9 + 7;
// const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

int main() {
	ll N, K;
	cin >> N >> K;
	ll ans = 0;

	vi A(N);
	rep(i, N) {
		cin >> A[i];
	}

	vi pre(N, 0);
	vi post(N, 0);

	ll Pre = 0;
	ll Post = 0;
	// K==1のとき
	// O(N * N)
	rep(i, N) {
		rep(j, i) {
			if (A[j] < A[i]) {
				pre[i]++;
				Pre++;
			}
		}
		repa(k, i + 1, N) {
			if (A[k] < A[i]) {
				post[i]++;
				Post++;
			}
		}
	}
	/*
	for (auto a : pre) cout << a << " "; cout << endl;
	cout << Pre << endl;
	for (auto a : post) cout << a << " "; cout << endl;
	cout << Post << endl;
	*/

	ans = K * (K - 1) / 2;
	ans %= mod;
	ans *= (Pre + Post);
	ans %= mod;
	ans += K * Post;
	ans %= mod;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
	int i;
	int n;
	while(scanf("%d",&n),n){
		int a[1001][4];
		for(i=0;i<=n;++i)
			scanf("%d%d%d%d",&a[i][0],&a[i][1],&a[i][2],&a[i][3]);
		bool b=false;
		for(i=0;i<n;++i){
			if(a[i][1]>a[n][0]||a[i][2]>a[n][1]||a[i][3]>a[n][2]||a[i][1]*4+a[i][2]*9+a[i][3]*4>a[n][3])
				continue;
			printf("%d\n",a[i][0]);
			b=true;
		}
		if(!b)
			puts("NA");
	}		
	return 0;
}

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

using namespace std;

int main(){
    int n;
    bool jd=false;
    cin >>n;
    for(int i=2;i<10;i++){
        if(n%i==0){
            if(n/i<10){
                jd= true;
            }
        }
    }
  if(0<n&&n<10){
        jd=true;
    }
    if(jd){
        cout << "Yes" <<endl;
    }
    if(!jd){
        cout << "No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>

#include <chrono>

#define INF 1e9
#define nmax 200010
#define fst first
#define snd second
#define pb push_back
#define SZ(x) ((int)(x.size()))

#define MOD 1000000007

#define MOD1 998244353
#define MOD2 666013
#define P1 255
#define P2 2059

using namespace std;
using namespace std::chrono;

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

int n;
int a[nmax];

map <int, int> mp;

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

    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);

    for (int i = 1; i <= n; i++) mp[a[i]]++;

    ll sum = 0;

    for (auto x : mp) sum = sum + 1LL * x.snd * (x.snd - 1) / 2;

    for (int i = 1; i <= n; i++) {

        int x = mp[a[i]] - 1;

        printf("%lld\n", sum - x);
    }

    // IMPORTANT!!!!!
    // Are you missing something????
    // check limits, int or ll

    return 0;
}

Measured memory_bytes: 8320
import sys
sys.setrecursionlimit(10**7)

MOD = 998244353
A,B,C,D= map(int,input().split())
#A,B,C,D = 1,1,3000,3000

def dpinit(ps, val=0):
    res = [val for i in [0]*ps[-1]]
    for i in ps[:-1][::-1]:
        res = [res[:] for k in [0]*i]
    return res

memo = dpinit((C+1,D+1))

memo[A][B] = 1
for Y in range(A,C+1):
    memo[Y][B] = pow(B,Y-A,MOD)
for X in range(B,D+1):
    memo[A][X] = pow(A,X-B,MOD)

for y in range(A+1,C+1):
    for x in range(B+1,D+1):
        memo[y][x] = (x*memo[y-1][x] + y*memo[y][x-1] - (x-1)*(y-1)*memo[y-1][x-1]) % MOD

print(memo[C][D])






Measured memory_bytes: 133148
#include<bits/stdc++.h>
#define ll long long
#define pie 3.14
using namespace std;
int main()
{
   ll n,m,s=0,t,i;
   cin>>n>>m;
   for(i=0;i<m;i++)
   {
       cin>>t;
       s=s+t;
   }
   if(s==n)
    cout<<0<<"\n";
   else if(n>s)
    cout<<n-s<<"\n";
   else
    cout<<-1<<"\n";
   return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
  for(int i=0;i<M;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++){
      int si;
      cin >> si;
      A.at(si-1) |= 1 << i;
    }
  }
      /*
  for(int i=0;i<N;i++){
    cout << bitset<8>(A.at(i)) << endl;
  }
  */
  int P=0;
  for(int i=0;i<M;i++){
    int x;
    cin >> x;
    P |= x<<i;
  }
  
  int ans=0;
  
  for(int i=0;i<(1<<N);i++){
    int t=0;
    for(int j=0;j<N;j++){
      if(i>>j & 1){
        t ^= A.at(j);
      }
    }
    if(t == P){
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
    int N;
    ll K;
    int A[200005] = {0};
    int C[200005] = {0};

    cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }

    int next = 1;
    for (ll i = 1; i <= K; i++) {
        if (C[next] == 0) {
            C[next] = i;
        } else {
            ll s = K - ll((C[next] - 1));
            ll t = ll(abs(i - C[next]));
            ll u = s % t;
            for (ll j = 0; j < u; j++) {
                next = A[next];
            }
            cout << next << endl;
            return 0;
        }
        next = A[next];
    }
    cout << next << endl;
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    string s;
    cin>>s;
    int flag=0;
    rep(i,1,4)
    {
        if(s[i]==s[i-1]) flag=1;
    }
    if(!flag ) cout<<"Good";
    else cout<<"Bad";

    return 0;
}



Measured memory_bytes: 256
import fractions
A, B, C, D = map(int, input().split())
CD = int((C*D)/fractions.gcd(C, D))

ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
acd = (A-1)//CD
bcd = B//CD

print(int(B - A + 1 - ((bc - ac) + (bd - ad) - (bcd - acd))))


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

template<class T>
void print_vec(vector<T>& v) {
	for (T n: v) cout << n << " ";
	cout << "\n";
}

int main() {
	// freopen("./input.txt", "r", stdin);
	int N;
	cin >> N;
	if (N == 1)
		cout << "Hello World\n";
	else {
		int A, B;
		cin >> A >> B;
		cout << A + B << "\n";
	}
	
	
	return 0;
}


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


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

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

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







class SegmentTree
{
private:
    ll n;    // 配列の要素数
    ll s;    // 配列を初期化するときの値
    vector<ll> data;     // セグメントツリーを持つ配列
public:
    SegmentTree(ll m, ll t);   // mは配列の要素数、tは配列を初期化するときの値
    ll operation(ll t1, ll t2); // 二項演算
    void update(ll k, ll a);  // k番目(0-indexed)の値をaに変更
    ll query(ll a, ll b);   // [a, b) の値を求める。
    ll query(ll a, ll b, ll k, ll l, ll r);   // [a, b) の値を求める。
};

SegmentTree::SegmentTree(ll m, ll t){
    n = 1;
    
    while(n < m) n *= 2;
    
    data.assign(2 * n - 1, t);
    
    s = t;
}

ll SegmentTree::operation(ll t1, ll t2){
    return min(t1, t2);
}

void SegmentTree::update(ll k, ll a){
    k += n - 1;
    data[k] = a;
    
    while(k > 0){
        k = (k - 1) / 2;
        data[k] = operation(data[k * 2 + 1], data[k * 2 + 2]);
    }
}

ll SegmentTree::query(ll a, ll b){
    return query(a, b, 0, 0, n);
}

ll SegmentTree::query(ll a, ll b, ll k, ll l, ll r){
    if(r <= a || b <= l) return s;
    if(a <= l && r <= b){
        return data[k];
    }
    else{
        ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        
        return operation(vl, vr);
    }
}

int main() {
    ll n;
    cin >> n;
    ll cnt = 0;
    vector<ll> b(n + 1);
    REP(i, n){
        cin >> b[i + 1];
        if(b[i + 1] == 0) cnt++;
    }
    ll q;
    cin >> q;
    vector<vector<ll>> v(n + 1);
    REP(i, q){
        ll l, r;
        cin >> l >> r;
        v[l].push_back(r);
    }
    
    SegmentTree st(n + 1, INF);
    st.update(0, 0);
    for(ll i = 1; i <= n; i++){
        sort(v[i].rbegin(), v[i].rend());
        for(auto &r : v[i]){
            ll res = st.query(i - 1, r);
            if(res < st.query(r, r + 1)) st.update(r, res);
        }
        ll res = st.query(i - 1, i) + (b[i]? 1 : -1);
        if(res < st.query(i, i + 1)) st.update(i, res);
    }
    cout << st.query(n, n + 1) + cnt << endl;
}

Measured memory_bytes: 14848
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> as(N, 0);
    rep(i, N){
        cin >> as[i];
    }
    sort(as.begin(), as.end());
    int ans = 0;
    rep(i, as.size()){
        int x = as[i];
        auto iter1 = lower_bound(as.begin(), as.end(), x - 1);
        auto iter2 = lower_bound(as.begin(), as.end(), x + 2);
        int tmp = iter2 - iter1;
        ans = max(tmp, ans);
    }

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


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
typedef vector<long long> vll;

// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	return a/ gcd(a,b)*b;
}
int hin[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,a;
	scanf("%d", &N);
	REP(i, N) {
		cin >> a;
		hin[a]++;
	}
	int ans = 0;
	REPL(i,1, 100010-1) {
		ans = max(ans, hin[i - 1] + hin[i] + hin[i + 1]);
	}
	cout << ans << endl;
	return 0;
}


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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    string s,t;
    cin >> s >> t;
    int n = (int)s.size();
    int ans=0;
    for(int i=0;i<n;i++){
    	if(s[i]!=t[i]) ans++;
	}
	cout << ans << "\n";
    return 0;
} 

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

int main()
{
  char s[4] ;
  
  rep(i, 4){
    cin >> s[i] ;
  }
  
  if(s[0]==s[1] && s[1]==s[2] && s[2]==s[3]){
    cout <<"No"<<endl ;
  }
    
  else if(s[0]==s[1] && s[2]==s[3]){
    cout <<"Yes"<<endl ;
  }
  else if(s[0]==s[2] && s[1]==s[3]){
    cout <<"Yes"<<endl ;
  }
  else if(s[0]==s[3] && s[1]==s[2]){
    cout <<"Yes"<<endl ;
  }
  else {
    cout <<"No"<<endl ;
  }
    return 0 ;
}

Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let k: usize = read!();

    let mut a = Vec::with_capacity(n);
    let mut max = 0;
    for _ in 0..n {
        let ai: usize = read!();
        max = (max).max(ai);
        a.push(ai);
    }

    if k == 0 {
        println!("{}", max);
        return;
    }

    let mut left = 0;
    let mut right = 10000000000;

    while right - left > 1 {
        let mid = (right + left) / 2;

        let ki = a
            .iter()
            .map(|&ai| {
                if ai % mid == 0 {
                    (ai / mid) - 1
                } else {
                    ai / mid
                }
            })
            .sum::<usize>();

        if ki > k {
            left = mid;
        } else {
            right = mid;
        }
    }

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


Measured memory_bytes: 3560
//misteer
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    std::vector<int> v(N);
    for (auto& e : v) std::cin >> e;

    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r;
        std::cin >> l >> r;
        std::reverse(v.begin() + l, v.begin() + r);
    }

    for (int i = 0; i < v.size(); ++i) {
        std::cout << v[i] << " \n"[i == v.size() - 1];
    }
}



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

int main() {
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    cout << ((s == "AKIHABARA" || s == "KIHABARA" || s == "AKIHBARA" || s == "KIHBARA" || s == "AKIHABRA" || s == "KIHABRA" || s == "AKIHBRA" || s == "KIHBRA" || s == "AKIHABAR" || s == "KIHABAR" || s == "AKIHBAR" || s == "KIHBAR" || s == "AKIHABR" || s == "KIHABR" || s == "AKIHBR" || s == "KIHBR") ? "YES\n" : "NO\n");
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	int w;
	while(~scanf("%d",&w)){
		if(w==-1) break;
		printf("%d\n",4280 - (1150 + (w > 30 ? 125 * 10 + 140 * 10 + 160 * (w-30)
			: w > 20 ? 125 * 10 + 140 * (w-20)
			: w > 10 ? 125 * (w-10)
			: 0)));
	}
}

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

int main()
{
  int n;cin>>n;
  vector<int> s(n);for (auto &&i : s)
  {
    cin >>i;
  }
  int q;cin>>q;
  vector<int> t(q);for (auto &&i : t)
  {
    cin >> i;
  }

  ll ans = 0;
  for (auto &&i : t)
  {
    if(binary_search(s.begin(),s.end(),i))ans++;
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 3320
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();
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


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

int main() {
  int n,m;
  cin>>n>>m;
  if (n<=m) {
    rep(i,m) cout<<n;
  }
  else {
    rep(i,n) cout<<m;
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i] != l[j] != l[k] and l[i]+l[j] > l[k]:
                ans += 1
print(ans)


Measured memory_bytes: 9172
#include<iostream>
#include<vector>
#include<algorithm>

struct DSU{
	std::vector<int> p;
	DSU(int n):p(n){while(n--)p[n]=n;}
	void join(int a,int b){p[root(a)]=root(b);}
	int root(int a){return a!=p[a]?p[a]=root(p[a]):a;}
};

int main(){
	std::ios::sync_with_stdio(0);std::cin.tie(0);
	int nnode,nedge,ncol;std::cin>>nnode>>nedge>>ncol;
	if(nedge<ncol-1){
		std::cout<<"-1\n";
		return 0;
	}
	std::vector<int> col(nnode);
	for(int i=0;i<nnode;++i){
		std::cin>>col[i];
		if(col[i]==0)
			col[i]=i+ncol; // gray cols: [ncol .. ncol+nnode[
		else
			--col[i]; // colored col: [0 .. ncol[
	}

	struct Edge{
		int x,y,w;
	};
	std::vector<Edge> ed(nedge);
	for(Edge& e:ed){
		std::cin>>e.x>>e.y>>e.w;
		--e.x;--e.y;
	}
	std::sort(begin(ed),end(ed),[](Edge a,Edge b){return a.w<b.w;});

	int n_left=ncol-1;
	int64_t ans=0;
	DSU d(nnode+ncol);
	for(Edge e:ed){
		if(d.root(col[e.x])!=d.root(col[e.y])){
			d.join(col[e.x],col[e.y]);
			ans+=e.w;
			if(0==--n_left){
				std::cout<<ans<<'\n';
				return 0;
			}
		}
	}

	std::cout<<"-1\n";
}

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

void string_com(string& a,ll n)
{
    for (int i = 0; i < n; i++)
    {
        string temp;
        cin >> temp;
        a += temp;
    }
}

int main()
{
    ll n, m;
    cin >> n;
    string a;
    string_com(a, n);
    
    cin >> m;
    string b;
    string_com(b,m);
    
    cout << (lexicographical_compare(a.begin(), a.end(), b.begin(), b.end())) << endl;

    return 0;
}


Measured memory_bytes: 3216
// https://atcoder.jp/contests/abc148/tasks/abc148_f

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

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

// #define DEBUG
#ifdef DEBUG
#define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
#define DUMP2D(a) if (DEBUG) REP(_i, a.size()) DUMP(a[_i]); cout << endl
#else
#define DUMP(a)
#define DUMP2D(a)
#endif

const int N_MAX = 1e5;

int N, u, v;
vector<vector<int>> G;
vector<int> d;
int ans = -1;

void add_edge(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}

void dfs(int p, int v) {
  for (int u : G[v]) {
    if (u == p) continue;
    d[u] = d[v] + 1;
    dfs(v, u);
  }
}

void dfs2(int p, int v, int d2) {
  if (d2 >= d[v]) {
    ans = max(ans, d[v]);
    return;
  }
  ans = max(ans, d2 + (d[v] - d2 - 1));
  for (int u : G[v]) {
    if (u == p) continue;
    dfs2(v, u, d2 + 1);
  }
}

int main() {
  cin >> N >> u >> v;
  u--; v--;
  G = vector<vector<int>>(N);
  REP(i, N - 1) {
    int A, B;
    cin >> A >> B;
    add_edge(A - 1, B - 1);
  }

  d = vector<int>(N);
  d[u] = 0;
  dfs(-1, v);
  DUMP(d);

  dfs2(-1, u, 0);
  cout << ans << endl;
}


Measured memory_bytes: 73472
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int N; std::cin >> N;
  std::vector<std::pair<long long, long long>> pos(N);
  for (int i = 0; i < N; ++i) std::cin >> pos[i].first >> pos[i].second;

  int parity = (std::abs(pos[0].first) + std::abs(pos[0].second)) % 2;
  for (int i = 0; i < N; ++i) {
    if ( parity != ((std::abs(pos[i].first) + std::abs(pos[i].second)) % 2) ) {
      std::cout << -1 << std::endl;
      return 0;
    }
  }

  std::vector<long long> d;
  for (int i = 30; i >= 0; --i) d.push_back(1LL<<i);
  if (parity == 0) d.push_back(1);
  std::cout << d.size() << std::endl;
  for (int j = 0; j < d.size(); ++j) std::cout << d[j] << " ";
  std::cout << std::endl;


  constexpr std::array<long long, 4> dx = {-1, +1, 0, 0};
  constexpr std::array<long long, 4> dy = {0, 0, -1, +1};

  for (int t = 0; t < N; t++) {
    long xx = 0;
    long yy = 0;
    std::string mm = "LRDU";
    for (auto& l : d) {
      int q = 0;
      long best = std::numeric_limits<long long>::max();
      for (int j = 0; j < 4; j++) {
        long xxx = xx + l * dx[j];
        long yyy = yy + l * dy[j];
        long dd = std::abs(xxx - pos[t].first) + std::abs(yyy - pos[t].second);
        if (dd < best) {
          best = dd;
          q = j;
        }
      }
      std::cout << mm[q];
      xx += l * dx[q];
      yy += l * dy[q];
    }
    std::cout << std::endl;
  }

  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};


int levenshtein_distance(string s1, string s2) {
    vector<vector<int> > dp(s1.size() + 1, vector<int>(s2.size() + 1));

    REP(i, s1.length()+1) REP(j, s2.length()+1){
            if(i == 0) dp[i][j] = j;
            else if(j == 0) dp[i][j] = i;
            else dp[i][j] = min({dp[i][j - 1] + 1, dp[i - 1][j] + 1, dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1])});
    }
    return dp[s1.size()][s2.size()];
}

string s, t;
int main() {
    cin >> s >> t;
    cout << levenshtein_distance(s, t) << endl;
    return 0;
}

Measured memory_bytes: 6812
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  cin>>n;
  int i=1;
  if(n==1)cout<<1<<endl;
  else{
    while(i*(i+1)/2<n)
      i++;
    for(int j=1;j<=i;j++){
      if(((i*(i+1)/2)-n)!=j)
	cout<<j<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
	typedef long long int lli;
	const int MaxN=200005;
	#define fst first
	#define snd second
	int mcd(int a,int b){	
		if(a==0)return b;
		return mcd(b%a,a);
	}		
	lli pre[MaxN];
	lli suf[MaxN];	
	lli arr[MaxN];
int main(){
	lli N,K,i,j,p,q,res=1e15;
	cin>>K>>N;
	for(i=1;i<=N;i++){
		cin>>arr[i];
	}
	arr[N+1]=K;
	for(i=N;i>0;i--){
		suf[i]=(arr[i+1]-arr[i])+suf[i+1];
	}
	for(i=1;i<=N;i++){
		p=arr[i-1]+suf[i];
		q=arr[i]+suf[i+1];
		if(i==1)q=arr[N]-arr[1];
		if(i==N)p=arr[N]-arr[1];	
		res=min(res,min(p,q));
	}
	/*for(i=1;i<=N;i++){
		cout<<arr[i]<<" ";
	}
	cout<<"\n";
	for(i=1;i<=N;i++){
		cout<<suf[i]<<" ";
	}
	cout<<"\n";*/
	cout<<res;
}

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

int main(){
        int x, y;
        cin >> x >> y;
        while (true){
                if(x > y)
                        cout << y << " " << x << endl;
                else
                        cout << x << " " << y << endl;
                cin >> x >> y;
                if( x == 0 && y == 0)
                        break;
        }
        return 0;
}



Measured memory_bytes: 3060
#include <iostream>
#include <queue>
#include <string>
#include <stdio.h>

using namespace std;

int main()
{
  char cmd[2]; // command
  int digit; // digit to insert
  priority_queue<int> Q;
  while (true) {
    scanf(" %s", cmd);
    if (cmd[0] == 'e' && cmd[1] == 'n') break;
    if (cmd[0] == 'i') {
      scanf(" %d", &digit);
      Q.push(digit);
    } else {
      cout << Q.top() << endl;
      Q.pop();
    }
  }
}

Measured memory_bytes: 5668
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline long long read()
{
	long long kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
char ss[2000222];
LL cou[3000];
const int mod=2019;
LL asd=0,bas=1,now=0;
int main()
{
	scanf("%s",ss);
	int len=strlen(ss);
	cou[0]=1;
	for(int i=len-1;i>=0;--i)
	{
		now=(now+bas*(ss[i]-'0')%mod)%mod;
		asd+=cou[now];
		cou[now]++;
		bas=(bas*10)%mod;
	}
	printf("%lld\n",asd);
}

Measured memory_bytes: 3880
#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)
N=gets.to_i
 
 
S=(0...N).map{gets.chomp}
 
internalAB=0
endwithA=0
startwithB=0
startwithBendwithA=0
 
S.each do |s|
  if s[0]=='B'
    if s[-1]=='A'
      startwithBendwithA+=1
    else
      startwithB+=1
    end
  elsif s[-1]=='A'
    endwithA+=1
  end
  lastisA=false
  s.each_char do |c|
    if c=='A'
      lastisA=true
      next
    elsif lastisA && c=='B'
      internalAB+=1
    end
    lastisA=false
  end
end

if startwithBendwithA>=1 && startwithB==0 && endwithA==0
  catAB=startwithBendwithA-1
else
  catAB=startwithBendwithA+[startwithB,endwithA].min
end

puts catAB+internalAB

Measured memory_bytes: 2684
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int a[10];
bool ok(int x)
{
 while(x!=0)
   {
   if(a[x%10]) 
   return false;
   x /= 10;}
   return true;}
int main()
{
int n,k,j;
cin>>n>>k;
for(int i=0;i<k;++i)
{cin>>j;
 a[j]=1;}
for( ; ;)
{
if(ok(n)==true)
{
cout<<n;
system("pause");
return 0;}
n++;}
}

Measured memory_bytes: 504
#include<stdio.h>

int main(){
    int X,A,B;
    scanf("%d %d %d",&X,&A,&B);
    if(A-B>=0){
        printf("delicious\n");
    }
    else if(A+X-B>=0){
        printf("safe\n");
    }else{
        printf("dangerous\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f // -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 2000 + 5;

int n, k;
int d[N];
vector<int> v[N];

void dfs(int x, int p) {
	d[x] = min(d[x], d[p] + 1);
	for (int i = 0; i < (int)v[x].size(); i++) {
		int y = v[x][i];
		if (y == p) continue;
		dfs(y, x);
	}
}

int main() {
	read(n), read(k);
	for (int i = 1, x, y; i < n; i++) {
		read(x), read(y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int ans = INF, tmp = k / 2;
	if ((k & 1) == 0) {
		for (int i = 1; i <= n; i++) {
			memset(d, 0x3f, sizeof d); d[0] = 0;
			dfs(i, 0); int cnt = 0;
			//for (int j = 1; j <= n; j++) printf("%d ", d[j]); printf("\n");
			for (int j = 1; j <= n; j++) if (d[j] - 1 > tmp) cnt++;
			//printf("%d\n", cnt);
			ans = min(ans, cnt);
		}
	}
	if ((k & 1) == 1) {
		for (int i = 1; i <= n; i++) {
			for (int p = 0; p < (int)v[i].size(); p++) {
				int y = v[i][p];
				if (y < i) continue;
				memset(d, 0x3f, sizeof d); d[0] = 0;
				dfs(i, 0); dfs(y, 0); int cnt = 0;
				for (int j = 1; j <= n; j++) if (d[j] - 1 > tmp) cnt++;
				ans = min(ans, cnt);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
ans = 0
for _ in range(N):
  a = list(map(int, input().split()))
  A.append(a)

for i in range(N):
  tmp = 0
  for j in range(M):
    tmp += A[i][j]*B[j]
  tmp += C
  if tmp > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cstring>
using namespace std;

typedef long long ll;

int main()
{
    unsigned long long a, b;
    char s[6];

    scanf("%lld%s", &a, s);
    b = (s[0] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');

    printf("%llu\n", a * b / 100);

    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define endl "\n" 
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k; cin >> n >> k;
  ll ans = k;
  for(int i = 0; i < n-1; ++i) {
    ans *= (k-1);
  }

  cout << ans << endl;


  return 0;
}


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

int main(void){
	int n,m,l;
	int x;
	while(scanf("%d %d %d",&n,&m,&l),n||m||l){
		int z=0;
		int ans=0;
		for(int i=0;i<n;i++){
			scanf("%d",&x);
			if(x>=l)z=m;
			if(z>0)ans++;
			z--;
		}
		cout<<(ans>0?ans-1:ans)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3124
#include<iostream>
using namespace std;
 
int main(){
 
    int n;
 
    cin >> n;
 
    int p[n],t[n],count=0,tcount;
 
    for(int i=0;i<n;i++){
      cin >> p[i];
      t[i] = p[i];
      //count += p[i];
    }
 
    if(p[0] > p[1]){
      count += p[0] + p[1];
      p[1] = 0;
    }
    else{
      count += p[0]*2;
      p[1] -= p[0];
    }
 
    for(int i=1;i<n-1;i++){
      count += p[i] * 2;
      if(p[i] > p[i+1] ){
        p[i+1] = 0;
      }
      else{
        p[i+1] -= p[i];
      }
    }
 
    if(p[n-1] != 0){
      count += p[n-1];
    }
 
 
 
 
    tcount = t[0];
 
    for(int i=1;i<n-1;i++){
      tcount += t[i] * 2;
      if(t[i] > t[i+1] ){
        t[i+1] = 0;
      }
      else{
        t[i+1] -= t[i];
      }
    }
 
    if(t[n-1] != 0){
      tcount += t[n-1];
    }
 
 
 
    /*int maxp = max(p[0],p[1]);
 
    if(maxp == p[0]){
      count += p[0] + p[1];
      p[0] = p[1] = 0;
    }
    else{
      count += p[0] * 2;
      p[1] -= p[0];
    }
 
 
 
    maxp = max(p[n-2],p[n-1]);
 
    if(maxp == p[n-2]){
      count += p[n-2] * 2;
    }
    else{
      count += p[n-2] + p[n-1];
    }*/
 
    cout << min(count,tcount) << endl;
 
    return 0;
}

Measured memory_bytes: 3120
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int H, W;
    cin >> H >> W;
    string ans;
    REP(y, H) REP(x, W) {
        string s;
        cin >> s;
        if(s == "snuke") {
            ans = string(1, (char)('A' + x)) + to_string(y+1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
// CODE FESTIVAL 2016 qual B
// D - Greedy customers

#include <cstdio>
using namespace std;

typedef long long int ll;


int N;
int min_p;
ll ans;

int main() {

  int a;

  scanf("%d", &N);
  min_p = 0;
  ans = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &a);
    ans += (a - 1) / (min_p + 1);
    if (a == min_p + 1 || i == 0) {
      min_p++;
    }
  }
  printf("%lld\n", ans);

  return 0;

}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------
const int MOD=1e9+7;

int cnt=0;
vector<int> merge_sort(vector<int> &a, int l, int r) {
    if(r-l==1) return {a[l]};
    vector<int> la=merge_sort(a,l,(l+r)/2);
    vector<int> ra=merge_sort(a,(l+r)/2,r);
    vector<int> ret;
    int L=0,R=0;
    while(1) {
        if(L<SZ(la) && R<SZ(ra)) {
            ret.push_back(min(la[L],ra[R]));
            (la[L]<ra[R]?L:R)++;
            cnt++;
        }
        else if(L==SZ(la) && R==SZ(ra)) {
            break;
        }
        else if(L<SZ(la)){
            ret.push_back(la[L++]);
            cnt++;
        }
        else if(R<SZ(ra)) {
            ret.push_back(ra[R++]);
            cnt++;
        }
    }
    return ret;
}
signed main() {
    int n;
    cin>>n;
    vector<int> a(n);
    cin>>a;
    vector<int> res=merge_sort(a,0,n);
    cout<<res<<endl;
    cout<<cnt<<endl;
    return 0;
}

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

const int maxn = (int)1e+5 + 5;
int vis[maxn];
int vis2[maxn];

void E()
{
	vis[0] = 1; vis[1] = 1;
	int m = sqrt(maxn);
	for(int i = 2; i < m; i++)
		if(!vis[i])
			for(int j = i*i; j <= maxn; j+=i) vis[j] = 1;
}

void check(int num)
{
	int p;
	if(!vis[num] && !vis[(num+1)/2]) p = 1; else p = 0;
	vis2[num] = vis2[num-1] + p;
}

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

	E();
	vis2[0] = 0;
	for(int i = 0; i < maxn; i++) check(i);
	//for(int i = 0; i < 100; i++) cout << vis2[i] << " "; cout << endl; 
	int l, r;
	while(q--)
	{
		scanf("%d %d", &l, &r);
		printf("%d\n", vis2[r] - vis2[l-1]);
	}
}



Measured memory_bytes: 1408
N=int(input())
A=list(map(int,input().split()))
m=10000000007
n=0
Ans=0
for i in range(N):
    Ans+=abs(A[i])
    if(A[i]<0):
        n+=1;
    m=min(m,abs(A[i]))
if n%2==0:
    print(Ans)
else:
    print(Ans-2*m)

Measured memory_bytes: 14224
/*
Hokudai Practice Contest 2014
E - Cube of Two

ティツァツ」テヲツウツ陛ッツシツ堙」ツつキテ」ツδ淌」ツδ・テ」ツδャテ」ツδシテ」ツつキテ」ツδァテ」ツδウ
テ・ツ崢榲ィツサツ「テ」ツつ津ゥツ?妥・ツシツオテ」ツ?」テ」ツ?ヲテ」ツつキテ」ツδ淌」ツδ・テ」ツδャテ」ツδシテ」ツつキテ」ツδァテ」ツδウテ」ツ?凖」ツつ凝」ツ??
テ」ツつキテ」ツδ淌」ツδ・テ」ツδャテ」ツδシテ」ツつキテ」ツδァテ」ツδウテゥツδィテ・ツ按?」ツ?陛」ツ?暗ヲツ崢クテ」ツ?妥」ツつ古」ツ?ーテ」ツ?づ」ツ?ィテ」ツ?ッテ」ツつ?」ツつ凝」ツ??」ツ?妥」ツ?づ」ツ?療」ツ?凝」ツ?療」ツ?敕」ツつ古」ツ?古」ツ?、テ」ツつ嘉」ツ??」ツ??

テヲツ卍づゥツ鳴禿ィツィツ暗ァツョツ療ゥツ?湘ッツシツ唹(|S|)
*/

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

/*
テ・ツアツ陛ゥツ鳴凝・ツ崢ウテ」ツ?ョテ、ツスツ催ァツスツョテ」ツ?ォテ、ツサツ・テ、ツクツ凝」ツ?ョテ」ツつ暗」ツ??」ツ?ェテァツ閉ェテ・ツ渉キテ、ツサツ佚」ツ?妥」ツつ津ィツ。ツ古」ツ??
.. .. 00 01 .. .. .. ..
.. .. 02 03 .. .. .. ..
04 05 08 09 12 13 16 17
06 07 10 11 14 15 18 19
.. .. 20 21 .. .. .. ..
.. .. 22 23 .. .. .. ..
*/

//テ・ツ青?」ツつュテ」ツδ・テ」ツδシテ」ツδ姪」ツ?ョティツ。ツィテゥツ敖「2テδ?テδ?テ」ツつ津ィツィツ佚ヲツ?カテ」ツ?凖」ツつ凝ゥツ?催・ツ按?
int c[24];

//テ・ツ崢榲ィツサツ「テヲツ督催、ツスツ愿」ツ?ォテ」ツつ暗」ツ?」テ」ツ?ヲテ」ツ??」ツ?ゥテ」ツ?ョテゥツ敖「テ」ツ?古・ツ按・テ」ツ?ョテ」ツ?ゥテ」ツ?ョテゥツ敖「テ」ツ?ォテァツァツサテ・ツ仰陛」ツ?凖」ツつ凝」ツ?凝」ツつ津」ツつキテ」ツδ淌」ツδ・テ」ツδャテ」ツδシテ」ツつキテ」ツδァテ」ツδウテ」ツ?凖」ツつ凝ゥツ鳴「テヲツ閉ーテ」ツ?づ」ツ?、テ」ツつ嘉」ツ??
void rot(char r){
  int t;
  if(r=='U'){
    t = c[4]; c[4] = c[8]; c[8] = c[12]; c[12] = c[16]; c[16] = t;
    t = c[5]; c[5] = c[9]; c[9] = c[13]; c[13] = c[17]; c[17] = t;
    t = c[0]; c[0] = c[2]; c[2] = c[3]; c[3] = c[1]; c[1] = t; 
  }
  else if(r=='F'){
    t = c[2]; c[2] = c[7]; c[7] = c[21]; c[21] = c[12]; c[12] = t;
    t = c[3]; c[3] = c[5]; c[5] = c[20]; c[20] = c[14]; c[14] = t;
    t = c[8]; c[8] = c[10]; c[10] = c[11]; c[11] = c[9]; c[9] = t;
  }
  else if(r=='R'){
    t = c[1]; c[1] = c[9]; c[9] = c[21]; c[21] = c[18]; c[18] = t;
    t = c[3]; c[3] = c[11]; c[11] = c[23]; c[23] = c[16]; c[16] = t;
    t = c[12]; c[12] = c[14]; c[14] = c[15]; c[15] = c[13]; c[13] = t;
  }
  else if(r=='D'){
    t = c[6]; c[6] = c[18]; c[18] = c[14]; c[14] = c[10]; c[10] = t;
    t = c[7]; c[7] = c[19]; c[19] = c[15]; c[15] = c[11]; c[11] = t;
    t = c[20]; c[20] = c[22]; c[22] = c[23]; c[23] = c[21]; c[21] = t;
  }
  else if(r=='B'){
    t = c[0]; c[0] = c[13]; c[13] = c[23]; c[23] = c[6]; c[6] = t;
    t = c[1]; c[1] = c[15]; c[15] = c[22]; c[22] = c[4]; c[4] = t;
    t = c[16]; c[16] = c[18]; c[18] = c[19]; c[19] = c[17]; c[17] = t;
  }
  else{
    t = c[0]; c[0] = c[19]; c[19] = c[20]; c[20] = c[8]; c[8] = t;
    t = c[2]; c[2] = c[17]; c[17] = c[22]; c[22] = c[10]; c[10] = t;
    t = c[4]; c[4] = c[6]; c[6] = c[7]; c[7] = c[5]; c[5] = t;
  }
}

//テ・ツ按敕ヲツ慊淌、ツスツ催ァツスツョテ」ツつ津ヲツ閉ーテ・ツュツ療」ツ?ァティツ。ツィテ」ツ?療」ツ?ヲテ」ツ??」ツつ凝」ツ?淌」ツつ?」ツ??・ツ按敕ヲツ慊淌、ツスツ催ァツスツョテ」ツ?凝」ツつ嘉ィツ可イテ」ツつ津ァツ可ケテ・ツョツ堙」ツ?凖」ツつ凝ゥツ鳴「テヲツ閉ーテ」ツつ津ァツ板ィテ」ツ??」ツつ?
char trans(int x){
  int a = x/4;
  if(a==0)return 'r';
  if(a==1)return 'g';
  if(a==2)return 'y';
  if(a==3)return 'b';
  if(a==4)return 'w';
  return 'o';
}

int main(){
  rep(i,24)c[i] = i;
  string s;
  cin >> s;

  rep(i,s.size())rot(s[i]);

  cout << ".."; rep(i,2)cout << trans(c[i]); cout << "....\n"; 
  cout << ".."; rep(i,2)cout << trans(c[i+2]); cout << "....\n";
  rep(i,2){
    rep(j,8)cout << trans(c[(j%2)+(j/2)*4+i*2+4]); cout << "\n";
  }
  cout << ".."; rep(i,2)cout << trans(c[i+20]); cout << "....\n"; 
  cout << ".."; rep(i,2)cout << trans(c[i+22]); cout << "....\n";
}

Measured memory_bytes: 1168
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCoder {
    class Program {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
        }
    }


    public class ConsoleInput {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputstream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputstream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputstream.Count != 0) return inputstream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (var i = 0; i < tmp.Length; ++i)
                    inputstream.Enqueue(tmp[i]);
                return inputstream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N)
        {
            var ret = new string[N];
            for (long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N)
        {
            var ret = new int[N];
            for (long i = 0; i < N; ++i)
                ret[i] = ReadInt;
            return ret;
        }
        public long[] ReadLongArray(long N)
        {
            var ret = new long[N];
            for (long i = 0; i < N; ++i)
                ret[i] = ReadLong;
            return ret;
        }
    }
}


Measured memory_bytes: 11220