akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>

const int INF = 33554432;

struct W
{
        int min, max;
        int c;
};

std::vector< W > ws;
std::vector< int > ts;
long dp[ 300 ][ 300 ];
int n;
int m;

long solve( int d, int before )
{
        if ( d == n )
        {
                return 0;
        }

        if ( dp[ d ][ before ] != -1 )
        {
                return dp[ d ][ before ];
        }


        long res = -INF;
        for ( int i = 0; i < m; ++i )
        {
                if ( ws[ i ].min <= ts[ d ] && ts[ d ] <= ws[ i ].max )
                {
                        if ( d == 0 )
                        {
                                res = std::max( res, solve( d + 1, i ) );
                        }
                        else {
                                res = std::max( res, solve( d + 1, i ) + std::abs( ws[ before ].c - ws[ i ].c ) );
                        }
                }
        }

        return dp[ d ][ before ] = res;
}

int main()
{
        memset( dp, -1, sizeof( dp ) );

        std::cin >> n >> m;
        ts.resize( n );
        ws.resize( m );
        for ( int i = 0; i < n; ++i )
        {
                std::cin >> ts[ i ];
        }
        for ( int i = 0; i < m; ++i )
        {
                std::cin >> ws[ i ].min >> ws[ i ].max >> ws[ i ].c;
        }

        
        std::cout << solve( 0, 0 ) << std::endl;
        
}

Measured memory_bytes: 1928
CMD=0
VAL=1

class Node
  attr_accessor :value,:left,:right,:parent
  def initialize (value,parent)
    @value = value
    @parent = parent
    @left = nil
    @right = nil
  end

  def insert (value)
    if value < @value
      if @left.nil?
        @left = Node.new(value,self)
      else
        @left.insert(value)
      end
    else
      if @right.nil?
        @right = Node.new(value,self)
      else
        @right.insert(value)
      end
    end
  end

  def find(value)
    if value==@value
      print "yes\n"
    elsif value < @value
      if @left.nil?
        print "no\n"
      else
        @left.find(value)
      end
    else
      if @right.nil?
        print "no\n"
      else
        @right.find(value)
      end
    end
  end

  def delete(value)
     #p "before:#{@value}"
    if value == @value
      if @left.nil? or @right.nil?
         #p "removed"
        update_tree
      else
        @value = @right.get_new_value
         #p "after:#{@value}"
      end
    elsif value < @value
      @left.delete(value)
    else
      @right.delete(value)
    end
  end

  def get_new_value
    unless @left.nil?
      return @left.get_new_value
    else
      update_tree
      return @value
    end
  end
      
  def update_tree 
     #p "value: #{@value}"
     #p "@parent.value: #{@parent.value}"
    if @left.nil? and @right.nil?
      new_child = nil
    elsif @left.nil?
      new_child = @right
    elsif @right.nil?
      new_child =  @left
    else
      p "oops"
    end

    new_child.parent = @parent unless new_child.nil?

    if @value < @parent.value
      @parent.left  = new_child
       #p "parent left: #{@parent.left}"
    else
      @parent.right = new_child
       #p "parent right: #{@parent.right}"
    end
  end
  
  def print_inorder
    @left.print_inorder unless @left.nil?
    print " #{value}"
    @right.print_inorder unless @right.nil?
  end
  
  def print_preorder
    print " #{value}"
    @left.print_preorder unless @left.nil?
    @right.print_preorder unless @right.nil?
  end
end

num_of_cmd = STDIN.gets()
inputs = STDIN.read().split("\n").map{ |input| input.split(' ') }

root=nil
inputs.each do |input|
  if input[CMD] == 'insert'
    if root.nil?
      root = Node.new(input[VAL].to_i,nil)
    else
      root.insert(input[VAL].to_i)
    end
  elsif input[CMD] == 'find'
    root.find(input[VAL].to_i)
  elsif input[CMD] == 'delete'
    root.delete(input[VAL].to_i)
  else
    root.print_inorder unless root.nil?
    print "\n"
    root.print_preorder unless root.nil?
    print "\n"
  end
end

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

long long calc(const int& n) {
  bool is_c[n + 1] = {};
  int g[n + 1] = {}; g[1] = 1;
  vector<int> p;
  long long ans(1);
  for (int i = 2; i <= n; ++i) {
    if (!is_c[i]) {
      p.emplace_back(i);
      g[i] = 2;
      int t(i);
      while (t <= n / i)
        g[t *= i] = g[t] + 1;
    }
    for (int j = 0; j < p.size() && p[j] * i <= n; ++j) {
      is_c[i * p[j]] = true;
      if (i % p[j])
        g[i * p[j]] = g[i] * g[p[j]];
      else {
        int t(i);
        while (t % p[j] == 0) t /= p[j];
        g[i * p[j]] = g[t] * g[i * p[j] / t];
      }
      if (i % p[j] == 0) break;
    }
    ans += (long long) i * g[i];
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  cout << calc(n) << endl;
  return 0;
}

Measured memory_bytes: 56248
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> field(h + 2, vector<char>(w + 2, '.'));
    for (int i = 1; i <= h; i++) {
        string s;
        cin >> s;

        for (int j = 1; j <= w; j++) {
            field[i][j] = s[j - 1];
        }
    }

    vector<vector<int>> grid(h + 2, vector<int>(w + 2, 0));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            int dy[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
            int dx[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

            for (int k = 0; k < 8; k++) {
                if (field[i + dy[k]][j + dx[k]] == '#') {
                    grid[i][j]++;
                }
            }
        }
    }

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (field[i][j] == '#') {
                cout << '#';
            } else {
                cout << grid[i][j];
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ld = long double;

// ========================================================================

//ライブラリ(*'▽')

ll gcd(ll a, ll b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}
//最大公約数
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
//最小公倍数
ll box(double a)
{
	ll b = a;
	return b;
}
//切り捨て
ll fff(double a)
{
	ll b = a + 0.5;
	return b;
}
//四捨五入
ll sum(ll n) {
	return (1 + n) * n / 2;
}
//1から整数nまでの合計を出す
bool prime(ll a)//素数判定、primeならtrue,違うならfalse
{
	if (a < 2) return false;
	else if (a == 2) return true;
	else if (a % 2 == 0) return false;
	double m = sqrt(a);
	for (int i = 3; i <= m; i += 2)
	{
		if (a % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}
//素数判定
ll modpow(ll a, ll n, ll mod) {
	ll hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return hi;
}
//いろいろやります（ただの前座）
ll mg(ll a, ll mod) {
	return modpow(a, mod - 2, mod);
}
//割り算の10^9+7等対策で逆元を出します



// ========================================================================


vl e(250000);
vl f(250000, 100000000000);

int main() {
	ll n; cin >> n;
	ll d; cin >> d;
	vl a(n);
	vl b(n);
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		if (d >= sqrt(a[i] * a[i] + b[i] * b[i])) ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10444
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int R[n];
    rep(i, n) {
        cin >> R[i];
    }
    int maxv = -1e9;
    int minv = R[0];

    for(int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv;

    cout << endl;
    return 0;
}


Measured memory_bytes: 3876
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    H,W=map(int,input().split())
    c=[list(map(int,input().split())) for _ in range(10)]
    l=[0]*10
    for _ in range(H):
        A=list(map(int,input().split()))
        for x in A:
            if x!=-1:
                l[x]+=1
    for k in range(10):
        for i in range(10):
            for j in range(10):
                c[i][j]=min(c[i][j],c[i][k]+c[k][j])
    ans=0
    for i,x in enumerate(l):
        ans+=c[i][1]*x
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40428
#include <bits/stdc++.h>
#include <array>
#include <bitset>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
using namespace std;
template <typename T> istream & operator >> (istream & is, vector<T> & vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	vector<int> p6, p9;
	int tmp = 6;
	while (tmp < 100000) {
		p6.push_back(tmp);
		tmp = tmp * 6;
	}
	tmp = 9;
	while (tmp < 100000) {
		p9.push_back(tmp);
		tmp = tmp * 9;
	}

	int n; CI n;

	int ans = INT_MAX;
	// i->9^nで作りたい j->6^nで作りたい
	for (int i = 0; i <=n; i++) {
		int count9 = 0;
		int count6 = 0;
		int j = n - i;
		count9 += (i % 9);
		count6 += (j % 6);

		int c6=j;
		for (int i6=p6.size()-1;i6>=0;i6--) {
			if (p6[i6] > j)continue;
			count6 += c6 / p6[i6];
			c6 = c6 % p6[i6];
		}

		int c9 = i;
		for (int i9 = p9.size()-1; i9 >= 0; i9--) {
			if (p9[i9] > i)continue;
			count9 += c9 / p9[i9];
			c9 = c9 % p9[i9];
		}
		ans = min(ans, count6+count9);
	}
	CO ans EN;
}

Measured memory_bytes: 256
s = input()

for bit in range(1 << 3):
  ans = int(s[0])
  f = s[0]
  
  for i in range(3):
    if bit&(1 << i):
      ans += int(s[i+1])
      f += "+"
    else:
      ans -= int(s[i+1])
      f += "-"
    f += s[i+1]
  if ans == 7:
    print(f + "=7")
    break
  else:
    continue
  break

Measured memory_bytes: 9124
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		B025 b = new B025();
	}
}


class B025 {
	
	B025() {
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		String str = cin.next();
		
		int max = 0;
		int x = 0;
		for (int i = 0; i < N; i++) {
			if (str.charAt(i) == 'I') {
				x++;
			} else if (str.charAt(i) == 'D') {
				x--;
			}
			max = Math.max(max, x);
		}
		System.out.println(max);
	}
}

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


int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;
    x3 = x2 - y2 + y1;
    y3 = y2 + x2 - x1;
    x4 = x3 - x2 + x1;
    y4 = y3 - y2 + y1;

    cout << x3 << " " << y3 << " ";
    cout << x4 << " " << y4 << endl;
    return 0;
}


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


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<1000000007>;
mint dp[210][210];

int main() {
    int N; cin >> N;
    vector<char> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i];

    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= N; ++j) {
            if (v[i] == '-') {
                dp[i+1][j+1] += dp[i][j];
            }
            else if (v[i] == 'U') {
                dp[i+1][j+1] += dp[i][j] * (i - j);
                dp[i+1][j] += dp[i][j];
            }
            else {
                dp[i+1][j+2] += dp[i][j] * (i - j) * (i - j);
                dp[i+1][j+1] += dp[i][j] * (i - j);
            }
        }
    }
    cout << dp[N][N] << endl;
}



Measured memory_bytes: 3412
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n, 0, -1):
    if i > n / 2:
        if a[i - 1] == 1:
            b[i - 1] = 1
    else:
        j = 2 * i
        c = 0
        while True:
            if j > n:
                break
            c += b[j - 1]
            j += i
        if (a[i - 1] + c) % 2 != 0:
            b[i - 1] = 1
ans = []
m = 0
for i in range(n):
    if b[i] == 1:
        ans.append(i + 1)
        m += 1
print(m)
if len(ans) != 0:
    print(" ".join(map(str, ans)))

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

int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	for(int i=0;i<n;i++){cin >> l[i];}
	sort(l.begin(),l.end());
	
	int ans =0;
	int tmp;
	
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			tmp = l[i]+l[j];
			for(int k=j+1;k<n;k++){
				//cout << l[i] << " "<<l[j] <<" " <<l[k] << endl;
				if(tmp <= l[k]){
					//cout << "dame" << endl;
					break;
				}
				else{
					//cout << "ok" << endl;
					ans += 1;}
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int F(int x, int y, int z){
  return x*x+y*y+z*z+x*y+y*z+z*x;
}

int main(){
  int N;
  cin >> N;
  vector<int> V(1000001,0);
  for(int x = 1;x<=100; x++){
    for(int y = x;y>=1;y--){
      for(int z = y;z>=1;z--){
        if(x==y&&y==z){
          V[F(x,y,z)]+=1;
        }
        else if(x==y||y==z||z==x){
          V[F(x,y,z)]+=3;
        }
        else{
           V[F(x,y,z)]+=6;
        }
      }
    }
  }
  
  for(int i =1; i<=N;i++){
    cout << V[i] << endl;
  }

        
 
}

      
  
  



Measured memory_bytes: 7164
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=(b); i++)
#define per(i,a,b) for (int i=(a); i>=(b); i--)
using namespace std;

const int maxn = 2005;
int v[maxn][maxn], e0[maxn][maxn], e1[maxn][maxn];
int n, m, Q, X1, X2, Y1, Y2;
char s[maxn];

int main() {
	scanf("%d%d%d", &n, &m, &Q);
	rep (i, 1, n) {
		scanf("%s", s + 1);
		rep (j, 1, m)
			v[i][j] = s[j] - '0';
	}
	rep (i, 1, n) rep (j, 1, m) if (v[i][j]) {
		if (v[i-1][j]) e0[i][j]++;
		if (v[i][j-1]) e1[i][j]++;
	}
	rep (i, 1, n) rep (j, 1, m) {
		v[i][j] += v[i-1][j] + v[i][j-1] - v[i-1][j-1];
		e0[i][j] += e0[i-1][j] + e0[i][j-1] - e0[i-1][j-1];
		e1[i][j] += e1[i-1][j] + e1[i][j-1] - e1[i-1][j-1];
	}
	while (Q--) {
		scanf("%d%d%d%d", &X1, &Y1, &X2, &Y2);
		printf("%d\n", 
			v[X2][Y2] - v[X1-1][Y2] - v[X2][Y1-1] + v[X1-1][Y1-1]
		 - (e0[X2][Y2] - e0[X1][Y2] - e0[X2][Y1-1] + e0[X1][Y1-1])
		 - (e1[X2][Y2] - e1[X1-1][Y2] - e1[X2][Y1] + e1[X1-1][Y1])
		);
	}
	return 0;
}

Measured memory_bytes: 48896
#include <bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = a; i < b; i++)
#define foR(i, a, b) for(int i = a; i <= b; i++)
#define roF(i, a, b) for(int i = a; i > b; i--)
#define Rof(i, a, b) for(int i = a; i >= b; i--)
#define inf INT_MAX
#define finf 1e308
#define vt vector
#define ii pair<int,int>
#define vii vt<ii>
#define vvii vt<vii>
#define vi vt<int>
#define vvi vt<vi>
#define pq priority_queue
#define pu push
#define pb push_back
#define pob pop_back
typedef long long ll;
template<class type> vt<type> readVector(int n){vt<type> v(n); For(i,0,n) cin >> v[i]; return v;}
template<class type> void writeVector(vt<type> a, char phan_cach){int n = a.size(); For(i,0,n) cout << a[i] << phan_cach;}
template<class type> void writeVector(vt<type> a){int n = a.size(); For(i,0,n) cout << a[i];}
const unsigned long long mod = 1000000007;


int n;
vt<bool> visited;
vt<unsigned long long> socach[2];
vvi adj;

void dfs(int ver){
	visited[ver] = true;
	For(i,0,adj[ver].size()){
		if(!visited[adj[ver][i]]){
			dfs(adj[ver][i]);
			socach[0][ver] *= socach[0][adj[ver][i]] + socach[1][adj[ver][i]];
			socach[0][ver] %= mod;
			socach[1][ver] *= socach[0][adj[ver][i]];
			socach[1][ver] %= mod;
		}
	}
}

int main () {
	int a, b;
	cin >> n;
	socach[0].assign(n,1);
	socach[1].assign(n,1);
	visited.assign(n,false);
	adj.assign(n,vi());
	For(i,1,n){
		cin >> a >> b;
		a--;
		b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	dfs(0);
	cout << (socach[0][0] + socach[1][0])%mod;
}



Measured memory_bytes: 11520
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  int d,ii;
  string str[] = {"Christmas Eve Eve Eve","Christmas Eve Eve","Christmas Eve","Christmas"};
  cin >> d;
  cout << str[d-22] << endl;
	
  return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

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

string str;
int ans;

void seica_chan(int seica, int mimori){
	int now = 0;
	if(seica == 4){
		if(mimori == str.size())ans++;
		return;
	}
	bool neko = true;
	while(neko){
		now *= 10;
		now += (str[mimori] - '0');
		if(now == 0)neko = false;
		if(now < 256){
			seica_chan(seica + 1, mimori + 1);
			mimori++;
		}
		else break;
	}
}
	
int main(){
	cin >> str;
	seica_chan(0,0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3204
{-# LANGUAGE BangPatterns #-}


import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import System.IO

main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  ps <- replicateM n (read <$> getLine :: IO Int)
  let m = maximum ps
  print $ sum ps - (m `div` 2)


Measured memory_bytes: 508
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define vair <vector<pair<int,int>>
#define vi vector<int>
#define mp make_pair
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool checkPrime(int n)
{
    if(n<2) return false;
    for(int x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return -1;
	
}
vector<int> Two_PointerSumOfTwo(vector<int> arr, int target)
{
	int l = 0, r = arr.size()-1;
	vector<int> ans;
	while(l<r){
		if(arr[l] + arr[r] == target)
		{
			ans.push_back(l);
			ans.push_back(r);
			break;
		}else if(arr[l] + arr[r] > target){
			r--;
		}else{
			l++;;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i <(int)s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
} 
int main()
{
	int h,n;
	cin >> h >> n;
	int a;
	int s=0;
	forn(i,n)
	{
		cin >> a;
		s += a;
	}
	if(s>= h)
	{
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
import std.stdio, std.conv, std.algorithm;
import std.range, std.array, std.math;

void dump(int[][] field, int n) {
  for(int i = 0; i <= n + 1; i++) {
    for(int j = 0; j <= n + 1; j++) {
      writef("%2d%s", field[i][j], j == (n + 1) ? "\n" : " ");
    }
  }
}

void main() {
  int edge;
  while(readf("%d\n", &edge), edge != 0) {
    int[][] field = new int[][](1002, 1002);
    for(int i = 0; i <= (edge + 1); i++) {
      field[0][i] = 0;
      field[i][0] = 0;
      field[edge + 1][i] = 0;
      field[i][edge + 1] = 0;
    }
    for(int i = 1; i <= edge; i++) {
      string s = readln;;
      for(int j = 0; j < edge; j++) {
        switch(s[j]) {
        case '*':
          field[i][j + 1] = 0;
          break;
        case '.':
          field[i][j + 1] = 1;
          break;
        default:
          throw new Exception("unknown value");
        }
      }
    }
    int square = 0;
    for(int i = edge; i >= 1; i--) {
      for(int j = edge; j >= 1; j--) {
        if (field[i][j] == 0) continue;
        field[i][j] =
          min(field[i][j + 1], field[i + 1][j], field[i + 1][j + 1]) + 1;
        square = max(square, field[i][j]);
      }
    }
    writeln(square);
  }
}

Measured memory_bytes: 16352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int ans = 0;
  string s;
  
  cin >> s;
  
  for(int i = 0;i < 3;i++)
    if(s.at(i) == 'R')
      ans++;
  	
  if(ans > 1 && s.at(1) == 'S')
    ans--;
  
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp make_pair
#define pb push_back
#define X first
#define Y second
using namespace std; 
typedef long long ll; 
int arr[100005];
int main()
{
	// freopen("AGC020-B.in", "r", stdin); 
	int n; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
		scanf("%d", arr + i); 
	ll l = 2, r = 2; 
	for (int i = n - 1; i >= 0 && l <= r; i--)
	{
		ll x = (l + arr[i] - 1) / arr[i], y = r / arr[i]; 
		l = x * arr[i]; 
		r = (y + 1) * arr[i] - 1; 
	}
	if (l > r)
		puts("-1"); 
	else
		printf("%lld %lld\n", l, r);
	return 0; 
}


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

int main() {
	int a, p;
	cin >> a >> p;
	
	if ((3*a+p)%2==0) {
		cout << (3 * a + p)/2 << endl;

	}
	else if ((3 * a + p) % 2 == 1){
		cout << (3 * a + p-1) / 2 << endl;
	}
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	vector<string> s( N );
	vector<int> t( N );
	for( int i = 0; i < N; ++i ) {
		cin >> s[i] >> t[i];
	}

	string X;
	cin >> X;

	int ans = 0;
	int i = 0;

	for( ; i < N; ++i ) {
		if( s[i] == X ) { break; }
	}

	for( i += 1; i < N; ++i ) { ans += t[i]; }
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());

// /mnt/c/Users/vince/Desktop/POST-IOI/  

long n, x, m;
vector<long> vec;
int visited[100003];

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	scanf("%lld %lld %lld", &n, &x, &m);
	long a = x;
	while(1)
	{
		visited[a] = vec.size();
		vec.push_back(a);
		a = (a*a)%m;
		if(visited[a])
		{
			// printf("%lld\n", a);
			break;
		}
	}
	int sz1 = 0, sz2 = vec.size();
	long sum = 0;
	for(int i = visited[a]; i < vec.size(); i++)
	{
		sz2--;
		sz1++;
		sum += vec[i];
	}
	// printf("%lld\n", sum);
	// for(auto x : vec) printf("%lld ", x); printf("\n");

	long res = 0;
	if(n <= sz2)
	{
		for(int i = 0; i < n; i++)
			res += vec[i];
	}
	else
	{
		for(int i = 0; i < sz2; i++)
			res += vec[i];
		n -= sz2;
		
		res += sum*(n/sz1);
		n %= sz1;
		for(int i = 0; i < n; i++)
			res += vec[visited[a]+i];
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 4312
n = int(input())
A = list(map(int, input().split()))

ANS = []
B=A[:]
B.sort()

if abs(B[0]) > abs(B[-1]) :
    absmax = B[0]
else :
    absmax = B[-1]

ind = A.index(absmax)

if absmax != 0 :
    fugou = absmax // abs(absmax)

    for i in range(n) :
        if A[i] * fugou < 0 :
            ANS.append([ind+1, i+1])

    if fugou == 1 :
        if ind+1 != 1 :
            ANS.append([ind+1, 1])
        for i in range(n-1) :
            ANS.append([i+1, i+2])
    else :
        if ind+1 != n :
            ANS.append([ind+1, n])
        for i in range(n,1,-1) :
            ANS.append([i, i-1])

    print(len(ANS))
    for i in range(len(ANS)) :
        print("{} {}".format(ANS[i][0], ANS[i][1]))
else :
    print(0)


Measured memory_bytes: 3064
/*
Author: CNYALI_LK
LANG: C++
PROG: c.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int read(){
	int s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WriteIntBuffer[1024];
template<class T>void write(T a,char end){
	int cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WriteIntBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WriteIntBuffer[cnt]);--cnt;}
	putchar(end);
}
int a[10244],b[10244];
int main(){
#ifdef cnyali_lk
	freopen("c.in","r",stdin);
	freopen("c.out","w",stdout);
#endif
	int n;
	n=read();
	for(int i=1;i<=n;++i)a[i]=a[i-1]+read();
	for(int i=1;i<=n;++i)b[i]=read();
	for(int i=n;i;--i)b[i]+=b[i+1];
	int ans=0;
	for(int i=1;i<=n;++i)chkmax(ans,a[i]+b[i]);
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}




int main(){
  string b;
  cin >> b;
  int val = 0;
  int ans = 0;
  rep(i,b.size()){
    int j = i;
    while(1){
      if(j == b.size() || (b[j] != 'A' && b[j] != 'T' && b[j] != 'G' && b[j] != 'C')) break;
      val++;
      j++;
    }
    ans = max(val,ans);
    val = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

mint dp[3005][3005][3];

int main(){
    int n, s;
    cin >> n >> s;
    mint ans(0);
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    dp[0][0][0] = mint(1);
    
    rep(i, n) rep(j, s+1) {
        dp[i+1][j][0] += dp[i][j][0];
        dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1];
        dp[i+1][j][2] += dp[i][j][1] + dp[i][j][2];
        if (a[i]+j<=s) {
            dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1];
            dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1];
        }
    }
    
    
    cout << dp[n][s][2].x << endl;
    return 0;
}


Measured memory_bytes: 211840
#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>

#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>

#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

#define reE(i,a,b) for(auto (i)=(a);(i)<=(b);(i)++)
#define rE(i,b) reE(i,0,b)
#define reT(i,a,b) for(auto (i)=(a);(i)<(b);(i)++)
#define rT(i,b) reT(i,0,b)
#define rep(i,a,b) reE(i,a,b);

#define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--)
#define itr(i,b) for(auto (i)=(b).begin();(i)!=(b).end();++(i))
#define LL long long
#define all(b) (b).begin(),(b).end()


#define inpur_line(str,is) getline(cin, str);is.str(str);is.clear(istringstream::goodbit)
#define input_token(ss,is,token,num) ss.str(""); ss.clear(stringstream::goodbit); getline(is, token, ','); ss << token; ss >> num

typedef complex<double> P;
typedef vector<P> Poly;

const LL INF = 1 << 30;
const double eps = 1e-8;


inline double dot(const P a, const  P b){//A dot B
	return a.real()*b.real() + a.imag()*b.imag();
}

inline double cross(const P a, const P b){//A cross B
	return a.real()*b.imag() - a.imag()*b.real();
}

bool less_P(const P& l, const P& r){
	if (l.real() == r.real())
		return l.imag() < r.imag();
	else return l.real() < r.real();
}

inline void convex_hull(Poly p, Poly& res){
	int k = 0, t;
	res.resize(2 * p.size());
	sort(all(p),less_P);
	reT(i, 0, (int)p.size()){
		while (k > 1 && (cross(res[k - 1] - res[k - 2], p[i] - res[k - 1])<eps))k--;
		res[k++] = p[i];
	}
	t = k;
	rev(i, 0, (int)p.size() - 1){
		while (k > t && (cross(res[k - 1] - res[k - 2], p[i] - res[k - 1])<eps))k--;
		res[k++] = p[i];
	}
	res.resize(k-1);
}





int main(void){
	int n;
	double x, y;
	Poly p, q;
	stringstream ss;string str, token;istringstream is;
	while (true){
		inpur_line(str, is);
		input_token(ss, is, token, n);
		if (n == 0)break;
		p.resize(n);
		rT(i, n){
			inpur_line(str, is);
			input_token(ss, is, token, x);
			input_token(ss, is, token, y);
			p[i].real(x);
			p[i].imag(y);
		}
		convex_hull(p, q);
		cout << n - q.size() << endl;
	}

	return(0);
}

Measured memory_bytes: 1288
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main(void){
  int n,m;
  cin >> n;
  string s;
  std::map<string,int> ans;
  for(int i=0;i<n;++i){
    cin >> s;
    if(ans.find(s)==ans.end()){
  	  ans.insert(std::make_pair(s,1));
    }else{
      ans.at(s)++;
    }
  }
  cin >>m;
  for(int i=0;i<m;++i){
    cin >> s;
    if(ans.find(s)==ans.end()){
      ans.insert(std::make_pair(s,-1));
    }else{
      ans.at(s)--;
    }
  }
  int max = 0;
  for(auto itr = ans.begin();itr != ans.end();itr++){
     if(max < itr->second){
        max = itr->second;
     }
  }
  cout << max;
return 0;
}

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

int main()
{
  int N;
  cin >> N;
  while (N-- > 0) {
    vector<int> balls(10);
    for (int i = 0; i < 10; i++) {
      cin >> balls[i];
    }

    for (int i = 0; i < 1024; i++) {
      int b = 0, c = 0;
      int j;
      for (j = 0; j < 10; j++) {
        if (i & (1<<j)) {
          if (b < balls[j]) {
            b = balls[j];
          } else {
            break;
          }
        } else {
          if (c < balls[j]) {
            c = balls[j];
          } else {
            break;
          }
        }
      }
      if (j == 10) {
        cout << "YES" << endl;
        goto NEXT;
      }
    }
    cout << "NO" << endl;
NEXT:
    ;
  }
  return 0;
}

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

using namespace std;


template<class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL<<60;


void solve() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

    vector<long long> dp(H+1, INF);
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= H; j++) {
            chmin(dp[min(j+A[i], H)], dp[j] + B[i]);
        }
    }
    cout << dp[H] << endl;
}


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

Measured memory_bytes: 384
class SegmentTree(object):
    def __init__(self, sequence, function, identify):
        N = len(sequence)
        self.length = (1 << (N - 1)).bit_length()
        self.function = function
        self.data = [identify] * (self.length << 1)
        self.identify = identify
        # set values
        for i in range(N):
            self.data[i + self.length - 1] = sequence[i]
        # build
        for i in range(self.length - 2, -1, -1) :
            self.data[i] = self.function(self.data[(i << 1) + 1], self.data[(i << 1) + 2])

    def update(self, idx, x):
        idx += self.length - 1
        self.data[idx] = x
        while idx:
            idx = (idx - 1) >> 1
            self.data[idx] = self.function(self.data[(idx << 1) + 1], self.data[(idx << 1) + 2])

    def query(self, p, q):
        if q <= p:
            return self.identify
        p += self.length - 1
        q += self.length - 2
        res = self.identify
        while q - p > 1:
            if not p & 1:
                res = self.function(res, self.data[p])
            if q & 1:
                res = self.function(res, self.data[q])
                q -= 1
            p >>= 1
            q = (q - 1) >> 1
        return self.function(res, self.data[p]) if p == q else self.function(self.function(res, self.data[p]), self.data[q])

def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


N = int(input())
S = input()
atoi = {chr(ord("a") + d): 1 << d for d in range(26)}
data = [atoi[c] for c in (S)]
seg_tree = SegmentTree(data, lambda a, b: a | b, 0)
Q = int(input())
for _ in range(Q):
    q, a, b = input().split()
    if q == "1":
        idx = int(a) - 1
        seg_tree.update(idx, atoi[b])
    else:
        print(popcount(seg_tree.query(int(a) - 1, int(b))))

Measured memory_bytes: 31896
#include<iostream>

using namespace std;

int main()
{
	int r;
	while(cin>>r)
	{
		if(r<0||r>4208)
		{
			cout<<"数据错误！请重新输入:";
			cin>>r;
		}
		if(r<1200)
		   cout<<"ABC"<<endl;
		if(r>=1200&&r<2800)
		   cout<<"ARC"<<endl;
		if(r>=2800)
		   cout<<"AGC"<<endl;
	} 
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  cout << (1+n)*n/2 << endl;
}


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

int main()
{
    
    int i,len;
    char string[200000];
    int sum=0;
    int result=0;
    
    scanf("%s",string);
    len = strlen(string);
    while(i<len)
    {
    
        
        if(string[i]=='S')
        {
            result++;
        }
        else if(string[i]=='T')
        {
            result--;
        }
        
        if(result<0)
        {
            sum += (-1*result);
            result =0;
        }
        i++;
   
    }
    printf("%d",sum+result);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e5+10;
uli h[mx];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",h+i);
  }
  uli q=1;
  uli ans=0ll;
  for(int i=0;i<n;i++){
    if(q==h[i])q++;
    if(q<h[i]){
      ans+=(h[i]-1)/q;
      q=max(q,2ll);
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1024
import java.math.BigInteger;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		long[] a = new long[n];
		
		a[0] = stdIn.nextLong();
		
		
		long ans = a[0];
		
		BigInteger result = BigInteger.valueOf(a[0]);
		
		for(int i = 1; i < n; i++) {
			a[i] = stdIn.nextLong();
			if(a[0] == 0 || a[i] == 0) {
				System.out.println(0);
				return;
			}
		}
		
		
		for(int i = 1; i < n; i++) {

			result = result.multiply(BigInteger.valueOf(a[i]));
			
			
			if(result.compareTo(BigInteger.valueOf((long)1e18)) ==1){
				System.out.println(-1);
				return;
			}
			
		}
		
		
		
		System.out.println(result);
		
		
		
	}

}


Measured memory_bytes: 62108
#include <stdio.h>

int main(){
	int ah[2],am[2],as[2],bh[2],bm[2],bs[2],ch[2],cm[2],cs[2],aH,bH,cH,aM,bM,cM,aS,bS,cS;
	scanf("%d %d %d %d %d %d",&ah[0],&am[0],&as[0],&ah[1],&am[1],&as[1]);
	scanf("%d %d %d %d %d %d",&bh[0],&bm[0],&bs[0],&bh[1],&bm[1],&bs[1]);
	scanf("%d %d %d %d %d %d",&ch[0],&cm[0],&cs[0],&ch[1],&cm[1],&cs[1]);
	aH=ah[1]-ah[0];
	aM=am[1]-am[0];
	aS=as[1]-as[0];
	bH=bh[1]-bh[0];
	bM=bm[1]-bm[0];
	bS=bs[1]-bs[0];
	cH=ch[1]-ch[0];
	cM=cm[1]-cm[0];
	cS=cs[1]-cs[0];
	if(aS<0){
		aM-=1;
		aS+=60;
	}
	if(aM<0){
		aH-=1;
		aM+=60;
	}
	if(bS<0){
		bM-=1;
		bS+=60;
	}
	if(bM<0){
		bH-=1;
		bM+=60;
	}
	if(cS<0){
		cM-=1;
		cS+=60;
	}
	if(cM<0){
		cH-=1;
		cM+=60;
	}
	printf("%d %d %d\n",aH,aM,aS);
	printf("%d %d %d\n",bH,bM,bS);
	printf("%d %d %d\n",cH,cM,cS);
	return 0;
}
	

Measured memory_bytes: 600
#include <stdio.h>

using namespace std;

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

	for(int i = 1; i<= n; i++)
	{
		if(i%3 == 0){
			printf(" %d",i);
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
			}while(x);
		}
	}
	printf("\n");
}



Measured memory_bytes: 2764
#include<cstdio>
#define RI register int
#define CI const int&
using namespace std;
const int N=17;
int n,a,b,lim;
inline int count(CI x,int ret=0)
{
	for (RI i=0;i<n;++i) ret+=((x>>i)&1); return ret;
}
inline void DFS(CI x,CI y,CI cs)
{
	if (count(cs)==1) return (void)(printf("%d %d ",y,x^y));
	for (RI i=0,j;i<n;++i) if (((x>>i)&1)&&((cs>>i)&1))
	for (j=0;j<n;++j) if (((cs>>j)&1)&&i!=j)
	return (void)(DFS(1<<j,y,cs^(1<<i)),DFS(x^(1<<i)^(1<<j),y^(1<<i)^(1<<j),cs^(1<<i)));
}
int main()
{
	scanf("%d%d%d",&n,&a,&b); if (count(a^b)&1)
	puts("YES"),DFS(a^b,a,(1<<n)-1); else puts("NO"); return 0;
}

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

int main() {
  int N;
  cin >> N;
  int p = 0,w = 0,g = 0,y = 0;

  for(int i = 0 ; i < N ; i++){
    string s;
    cin >> s;

    if (s == "P") p++;
    if (s == "W") w++;
    if (s == "G") g++;
    if (s == "Y") y++;
  }

  int c=0;
    if (p > 0) c++;
    if (w > 0) c++;
    if (g > 0) c++;
    if (y > 0) c++;

  if (c == 3) cout << "Three" << endl;
  if (c == 4) cout << "Four"  << endl;

}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	char a;
	cin >> a;
	cout << char(a + 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return (0);
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

bool isP(int x){
    if(x == 0 or x == 1) return false;
    for(int i=2 ; i*i<=x ; i++){
        if (x%i == 0) return false;
    }
    return true;
}

int main(){
    int n; cin >> n;
    int ct = 0;
    rep(i,n) {
        int x; cin >> x;
        
        if(isP(x)) ct++;
    }
    
    cout << ct << endl;
}
    
    







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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }

lli d[200100];

void func(long long N, std::vector<long long> a){

    set<lli> s;
    s.insert(-1);
    s.insert(N);

    REP(i,0,N)d[a[i]] = i;

    lli ans = 0;

    REP(i,1,N+1){
        lli nowI = d[i];
        auto pos = s.lower_bound(nowI);
        auto lef = pos;
        lef--;
        LOG4(ans,i,(*lef),(*pos));
        ans += i*((*pos-d[i])*(d[i] - (*lef)));
        s.insert(d[i]);
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    func(N, std::move(a));
    return 0;
}


Measured memory_bytes: 15688