akhauriyash/Code-Regression huggingface dataset:
x, n = gets.chomp.split.map(&:to_i)
p_a = []
if not n == 0
  p_a = gets.chomp.split.map(&:to_i)
else
  print x
  exit
end

if not p_a.include?(x)
  print x
  exit
end

xm, xp = x, x
(1...100).each do |delta|
  xm -= 1
  if not p_a.include?(xm)
    print xm
    exit
  end
  xp += 1
  if not p_a.include?(xp)
    print xp
    exit
  end
end

Measured memory_bytes: 14288
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    vector<ll> yobun;
    ll fusoku = 0;
    rep(i, n) {
        if (a[i] >= b[i]) yobun.push_back(a[i] - b[i]);
        else fusoku += b[i] - a[i];
    }

    if (fusoku == 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(all(yobun));
    reverse(all(yobun));
    int m = yobun.size();
    for (int i = 1; i < m; i++) yobun[i] += yobun[i-1];

    auto lb = lower_bound(all(yobun), fusoku);
    if (lb == yobun.end()) {
        cout << -1 << endl;
    } else {
        cout << n - m + (lb - yobun.begin()) + 1 << endl;
    }
}


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

int main() {
	int a, b;
	cin >> a >> b;
	vector<int> cir(5);
	int count = 0;
	for (int i = a; i <= b; i++) {
		int k = i;
		int p = i;
		int j = 0;
		while (k > 0) {
			cir.at(j) = k % 10;
			j++;
			k /= 10;
		}
		reverse(cir.begin(), cir.end());
		int l = 0;
		for (int q = 0; q < cir.size(); q++) {
			l += cir.at(q) * pow(10, q);
		}
		if (p == l) {
			count++;
		}
	}
	cout << count << endl;
}

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

int main() {
  for(string s; cin >> s && s != "#"; ) {
    int a = 0, n = -1;
    for(int i = s.size(); i; ) {
      a *= 2;
      n += 1;
      if(s.substr(i - 4, 4) == "west") {
        if(n == 0) a = 90;
        else a = a + 90;
        i -= 4;
      } else {
        if(n == 0) a = 0;
        else a = a - 90;
        i -= 5;
      }
    }
    while(n && a % 2 == 0) {
      --n;
      a /= 2;
    }
    if(n == 0) cout << a << endl;
    else cout << a << "/" << (1<<n) << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
"use strict";
    
const main = arg => {
    const b = arg.split("\n")[0];
    
    if(b == "A") {
        console.log("T");
    } else if (b == "T") {
        console.log("A");
    } else if (b == "C") {
        console.log("G");
    } else if (b == "G") {
        console.log("C");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner f = new Scanner(System.in);
        // fill in the dictionary with the initial value
        double x1 = f.nextDouble();
        double y1 = f.nextDouble();
        double x2 = f.nextDouble();
        double y2 = f.nextDouble();
        double dist = Math.sqrt(Math.pow((x2 - x1), 2)+Math.pow((y2-y1),2));
        System.out.println(dist);
    }
}


Measured memory_bytes: 27916
import fractions
N = int(input())
A = list(map(int,input().split()))  

A.sort()

mins = A[-1]
for i in range(N):
    s = fractions.gcd(A[i], A[0])
    if s > 0 and s < mins:
        mins = s
print(min(mins,A[0]))

Measured memory_bytes: 16240
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || a + c == b || c + b == a)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int l;
  l=s.length();
  int count=0;
  for(int i=0;i<l-1;i++)
  {
    if(s[i]==s[i+1])
    {
      if(s[i]=='0')
      {
        s[i+1]='1';
        count++;
      }
      if(s[i]=='1')
      {
        s[i+1]='0';
        count++;
      }
    }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int LL;
typedef vector<LL> VL;
#define INF 1000000000000LL

int main(){
  int A, B, Q;
  cin >> A >> B >> Q;
  VL S, T;
  REP(i, A) {
    LL s;
    cin >> s;
    S.push_back(s);
  }
  REP(i, B) {
    LL t;
    cin >> t;
    T.push_back(t);
  }
  REP(i, Q) {
    LL x;
    cin >> x;
    int iSr = distance(S.begin(), lower_bound(S.begin(), S.end(), x));
    int iTr = distance(T.begin(), lower_bound(T.begin(), T.end(), x));
    int iSl = distance(S.begin(), upper_bound(S.begin(), S.end(), x));
    int iTl = distance(T.begin(), upper_bound(T.begin(), T.end(), x));
    LL dSr = iSr == A ? INF : (S[iSr] - x);
    LL dTr = iTr == B ? INF : (T[iTr] - x);
    LL dSl = iSl == 0 ? INF : (x - S[iSl - 1]);
    LL dTl = iTl == 0 ? INF : (x - T[iTl - 1]);
    LL score1 = max({dSr, dTr});
    LL score2 = max({dSl, dTl});
    LL score3 = dSr + dTl + min({dSr, dTl});
    LL score4 = dSl + dTr + min({dSl, dTr});
    LL ret = min({score1, score2, score3, score4});
    cout << ret << endl;
  }
}

Measured memory_bytes: 3060
// H - Grid 1
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define MOD 1000000007

int main(){
	int H,W; cin>>H>>W;

	vector<string> grid(H);
	rep(h, H) cin>>grid[h];

	vector<vector<int>> dp(H+1, vector<int>(W+1, 0));
	dp[1][1] = 1;

	rep(h, H){
		rep(w, W){
			if(grid[h][w] == '#') continue;
			if(w+1 < W && grid[h][w+1] == '.')
				dp[h+1][w+2] = (dp[h+1][w+1] + dp[h][w+2]) % MOD;
			if(h+1 < H && grid[h+1][w] == '.')
				dp[h+2][w+1] = (dp[h+1][w+1] + dp[h+2][w]) % MOD;
		}
	}
	cout<< dp[H][W] <<endl;

	// // print ==========================
	// puts("===");
	// cout<<"H "<<H<<" W "<<W<<"\n";
	// rep(h,H) cout<<grid[h]<<"\n";
	// for(auto v:dp){
	// 	for(auto x:v)printf(" %2d",x);
	// 	puts("");
	// }
	// // =================================

}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	// 蛇のように塗っていけば大丈夫なのでは
	vector<vector<int>> ans(h, vector<int>(w, 0));
	int row = 0; int col = 0;

	rep(i, n) {
		rep(j, a[i]) {
			ans[row][col] = i + 1;
			if (row % 2 == 0) {
				col++;
				if (col == w) {
					col--;
					row++;
				}
			}
			else {
				col--;
				if (col == -1) {
					col++;
					row++;
				}
			}
		}
	}

	rep(i, h) {
		rep(j, w) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s[ohara],co;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    map<string,ll> mp;
    rep(i,n){
        cin>>s[i];
        mp[s[i]]++;
    }
    cin>>m;
    rep(i,m){
        cin>>co;
        mp[co]--;
    }
    rep(i,n){
        ans=max(ans,mp[s[i]]);
    }
    Cout(ans);
    return 0;
}


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

using namespace std;

#define ops cout<<"ops"<<endl;
#define freopens freopen("cowpatibility.in", "r", stdin);freopen("cowpatibility.out", "w", stdout);
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define DIM 107
#define DIMM 100007
#define INF 10000000000000000007.0
#define X 31
#define eps 0.0000001
#define PI 3.14159265358979323846
#define MAX 25
#define MODULO (long long)1000000007

const long double gr=(1+sqrt(5))/2;

typedef int I;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<I,I> pII;
typedef pair<ll,ll> pllll;
typedef pair<ld,ld> pldld;

typedef vector<I> vI;
typedef vector<ll> vll;
typedef vector<pllll> vpllll;

typedef char cr;
typedef string str;

ll n,W;
ll w[DIM],v[DIM];
ll dp[DIM][DIMM];

int main()
{
    //ops;
    //freopens;
    fast;
    //ll x1,y1,xs,ys,x2,y2,x3,x4,y3,y4;

    cin>>n>>W;
    for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++){
     for(int j=0;j<=W;j++){
      dp[i][j]=dp[i-1][j];
      if(j>=w[i] && dp[i][j]<(dp[i-1][j-w[i]]+v[i]))dp[i][j]=dp[i-1][j-w[i]]+v[i];
     }
    }
    cout<<dp[n][W]<<endl;
    return 0;
}


Measured memory_bytes: 79360
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

int main(int argc,char **argv){
  int32_t h,w;
  std::cin>>h>>w;

  int t;
  if(w==1){
    t=0;
  }else{
    t=h-w;
  }
  std::cout<<t<<std::endl;
  
  return 0;
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int count =0;
    for(int i = 0;i < s.size();i++){
        if(t.size() == s.size() + 1 && t.at(i) == s.at(i)){
            count++;
        }
    }
    if(count == s.size()){
        cout << "Yes" << endl;
    }else{
        cout << "No"  <<endl;
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ll x,k,d = 0;
    cin >> x >> k >> d;
    x = abs(x);
    ll xdc = x / d;
    ll cnt = k - xdc;
    if(xdc <= k){
        if(cnt % 2 == 0){
            cout << x - d * xdc << endl;
        }else{
            cout << abs(x - d * xdc - d) << endl;
        }
    }else{
        cout << abs(x - d * k) << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import math
def prime_factorize(num):
    """
    This function performs prime factorization on the input natural number.
    The result is returned in the form of a dictionary with the prime number as the key
    and its number as the value.
    :param num:
    :return prime_factor: Dictionary with the prime number as the key and its number as the value.
    """
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor


n = int(input())
n_fra = math.factorial(n)
p_f = prime_factorize(n_fra)
count = 1

for k, v in p_f.items():
    count *= (v+1)
    count %= 10**9+7
print(count)


Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n-1; i++){
      a[sc.nextInt()-1]++;
    }
    for(int i = 0 ; i< n; i++){
      System.out.println(a[i]);
    }
  }
}

Measured memory_bytes: 69356
def divisor(x):
    div = []
    for i in range(1,int(x**0.5)+1):
        if x%i == 0:
            div.append(i)
            if x != i**2: div.append(x//i)
    
    return div

def calc(n,x):
    if x==1: return n
    while n>=x:
        if n%x == 0:
            n //= x
        else:
            n %= x
    return n

n = int(input())

div_list = divisor(n)
ans = 0

for div in div_list:
    x = calc(n,div)
    if x==1: ans +=1

ans += len(divisor(n-1)) - 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  int ans=0;
  rep(i,n){
    int v=a.at(i);
    if(a.at(v-1)==i+1){
      ans++;
    }
  }
  cout << ans/2;
}


Measured memory_bytes: 3724
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ky112233
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDivideTheProblems solver = new CDivideTheProblems();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDivideTheProblems {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] d = new int[n];
            for (int i = 0; i < n; i++) d[i] = in.nextInt();
            Arrays.sort(d);
            out.println(d[n / 2] - d[n / 2 - 1]);
        }

    }
}



Measured memory_bytes: 50932
#include<iostream>
#include<string>
using namespace std;
int main() {
	string b;
	cin >> b;

	if (b == "A") {
		cout << "T";
	}
	else if (b == "C") {
		cout << "G";
	}
	else if (b == "G") {
		cout << "C";
	}
	else {
		cout << "A";
	}
	return 0;
}

Measured memory_bytes: 256
// Password
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main()
{
    int N;
    cin >> N;
    cout << N * N * N << endl;

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

string w[3] = { "Sunny", "Cloudy", "Rainy" };

int32_t main() {
    string s; cin >> s;
    if (s == w[0]) quit(w[1]);
    if (s == w[1]) quit(w[2]);
    if (s == w[2]) quit(w[0]);
}


Measured memory_bytes: 256
# aoj 2308
import sys
input = sys.stdin.readline


def calc_y(vy, t):
    return vy*t - g/2*t*t


def loc(y, b, t):
    if y < b+eps:
        return -1
    if y > t-eps:
        return 1
    return 0


def can_hit(x, y):
    if x == 0:
        return False
    a = g*g/4
    b = g*y-V*V
    c = x*x+y*y
    D = b*b-4*a*c
    if D < -eps:  # cannot reach
        return False
    if -eps <= D < 0:
        D = 0
    for d in [-1, 1]:
        t2 = (-b+d*D**.5) / (2*a)
        if t2 <= 0:
            continue
        t = t2**.5
        vx = x/t
        vy = y/t + g/2*t
        if calc_y(vy, X/vx) < Y-eps:  # cannot go above the pig
            continue
        maxt = vy/g
        maxx = vx*maxt
        maxy = calc_y(vy, maxt)
        for L, B, R, T in obstacles:
            left = loc(calc_y(vy, L/vx), B, T)
            right = loc(calc_y(vy, R/vx), B, T)
            if left*right <= 0:
                break
            if L <= maxx <= R:
                mid = loc(maxy, B, T)
                if left*mid <= 0:
                    break
        else:
            return True
    return False


g = 9.8
eps = 1e-10
N, V, X, Y = map(int, input().split())
obstacles = []
for _ in range(N):
    L, B, R, T = map(int, input().split())
    R = min(R, X)
    if L <= X:
        obstacles.append((L, B, R, T))
if X == 0:
    if V*V/(2*g) < Y-eps:
        print('No')
        exit()
    for L, B, R, T in obstacles:
        if B < Y:
            print('No')
            exit()
    print('Yes')
    exit()

# hit directly
if can_hit(X, Y):
    print('Yes')
    exit()

for L, B, R, T in obstacles:
    if can_hit(L, T) or can_hit(R, T):
        print('Yes')
        exit()
print('No')



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

int main() {
  unsigned long long n,x = 0,proa = 1,prob = 1;
  cin >> n;
  vector<unsigned long long> a(n + 1);
  a[0] = 1;
  for(unsigned long long i = 0; i < n; i++){
    cin >> a[i + 1];
    if(a[i + 1] == 0){
      proa = 0;
    }
  }
  for(unsigned long long i = 0; i < n ; i++){
    if(proa == 0){
      break;
    }
    proa *= a[i + 1];
    prob *= a[i];
    if(proa > 1000000000000000000 || proa / a[i + 1] != prob){
      x += 1;
      break;
    }
  }
  if(x == 0){
    cout << proa << endl;
  }else{
    cout << -1 << endl;
  }
  //cout << x << endl;
  //cout << x << endl;
  return 0;
}

Measured memory_bytes: 4028
#include <iostream>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;




int main(){
	unsigned long long int i,t,x;
	cin >> x;
	i=100;
	t=0;
	while(true){
		t++;
		i=i/100+i;
		if (x<=i){
			cout << t;
			return 0;
		}
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7;
const double PI = acos(-1);
ll c[55][55] = {};

ll comb (ll a, ll b){
    if (b > a) return 0;
    if (c[a][b] != 0) return c[a][b];
    if (a == 0 || b == a || b == 0) return c[a][b] = 1;
    return c[a][b] = comb(a-1, b) + comb(a-1, b-1);
}


int main (){
    cout << fixed << setprecision(20);
    ll a, b, n, rep_a=0, rep_total = 0;
    long double media = 0;
    cin >> n >> a >> b;

    vector<ll> v(n);

    for (auto& x: v) cin >> x;

    sort(all(v));
    reverse(all(v));

    for (int i=0; i<a; i++){
        media+=v[i];
    }
    media/=a;
    cout << media << endl; 

    for (int i=0; i<n; i++){
        if (v[i] == v[a-1]){
            rep_total++;
            if (i < a) rep_a++;
        }
    }
    ll ans = 0;
    // cout << rep_a << " " << rep_total << endl;
    if (rep_a == a){
        for (int i=a; i<=b; i++){
            ans += comb(rep_total, i);
        }
    }
    else {
        ans = comb(rep_total, rep_a);
    }

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

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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1) a = 100;
  if(b == 1) b = 100;
  
  if(a > b){
    printf("Alice\n");
  }
  else if(a == b){
    printf("Draw\n");
  }
  else printf("Bob\n");
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
ll n,k,ans;
ll sum[1000005],mod=1000000007ll;
ll pow1(ll x,ll y){
	ll a=1,b=x;while(y){if(y&1)a=(a*b)%mod;b=(b*b)%mod;y>>=1;}return a;
}
int main(){
    cin>>n>>k;
    for(int i=k;i>=1;i--){
		sum[i]=pow1(k/i,n);
		for(int j=2;i*j<=k;j++){
			sum[i]=(sum[i]-sum[i*j]+mod)%mod;
		}
		ans=(ans+i*sum[i])%mod;
	}
	cout<<ans;
	//system("pause");
    return 0;
}


Measured memory_bytes: 4344
sus,fef = map(int,input().split())
r,c = [0]*sus,[0]*fef; 
duk,l,m = [],[],[]
for x in range(sus):
  cuc = input(); duk.append([c for c in cuc])
  r[x] = cuc.count('#')
  for j in range(fef):
    c[j] += 1 if cuc[j] == '#' else 0
for rt in range(sus):
  if not r[rt]: l.append(rt)
for gt in range(fef):
  if not c[gt]: m.append(gt)
for x in range(sus):
  if x in l: continue
  cucky = ''
  for y in range(fef):
    cucky += duk[x][y] if y not in m else ''
  print(cucky)

Measured memory_bytes: 9216
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int result,x,result2,y;
        int mov = 0;
        int ikisaki[][] = new int[n][2];
        for(int i = 0; i < n; i++){
            for(int k = 0; k < 2; k++){
                ikisaki[i][k] = sc.nextInt();
            }
        }
        for(int i = 1; i < n; i++){
            result = ikisaki[i][0] - ikisaki[i-1][0];
            x = Math.abs(result);
            result2 = ikisaki[i][1] - ikisaki[i-1][1];
            y = Math.abs(result2);
            mov = mov + x + y;
            if(result > 0 && result2 > 0 || result < 0 && result2 < 0){
                if(x <= y){
                    mov = mov - x;
                }else{
                    mov = mov - y;
                }
            }
        }
        System.out.println(mov);
    }
}

Measured memory_bytes: 25524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		int N = scanner.nextInt();

		boolean flag = true; //ループの初期値

		for (int i = 0; i < N; i++) {
			int A = scanner.nextInt();

			if (A % 2 == 0 && A % 3 != 0 && A % 5 != 0) {
				
				System.out.println("DENIED");
				flag = false;
				break;
			}
		}
		if (flag == true) {
			System.out.println("APPROVED");
		}
	}

}

Measured memory_bytes: 23380
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	string s;
	cin >> s;
	int n = s.size();
	string ans = "yes";
	rep(i, 0, n) {
		rep(j, i + 1, n) {
			if (s[i] == s[j]) {
				ans = "no";
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    ios::sync_with_stdio(0);
    cin>>a>>b;
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(a.begin(),a.end());
    if(b>a)
        cout<<"Yes";
    else cout<<"No";;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  if(S.at(0)==S.at(2) && S.at(1)==S.at(2)|| S.at(1)==S.at(2) && S.at(1) == S.at(3)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

const int MN = 1e5+5, mod = 1e9+7;
int N, i, cnt[30], ans=1;
char ch;

int main(){
    scanf("%d",&N); getchar();
    for(i=1;i<=N;i++){
        scanf("%c",&ch);
        cnt[ch-'a']++;
    }
    for(i=0;i<26;i++){
        ans = (1LL*ans*(cnt[i]+1))%mod;
    }
    ans = (ans-1+mod)%mod;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using iii = pair<ii, ll>;
#define vt vector
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / gcd(a, b)
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
const ll N = 1e5 + 5;

ll n, ans;
ll a[N], ps[N];

void solve() {
    cin >> n;
    for(ll i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for(ll i = 1; i <= n; i++) {
        ps[i] = ps[i - 1] + a[i];
    }
    for(ll i = 1; i < n; i++) {
        if(ps[i] * 2 < a[i + 1]) {
            ans = 0;
        } else ans++;
    }
    cout << ans + 1 << "\n";
}

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

Measured memory_bytes: 5188
l, r = gets.split.map(&:to_i)
if r-l>2019
  puts "0"
  exit
end
min = Float::INFINITY
l.upto(r) do |i|
  (i+1).upto(r) do |j|
    x = (i*j)%2019
    min = x if min > x
  end
end
puts min


Measured memory_bytes: 14388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
ll n,k;
cin >> n >> k;
ll ans = 0;
if(k%2==1){
    ll tmp = n / k;
    ans = tmp * tmp * tmp;
} else {
    ll tmp = n / k;
    ll tmp2 = tmp;
    if (n % k >= k / 2) tmp2++;

    ans = tmp * tmp * tmp;
    ans += tmp2 * tmp2 * tmp2;
}
cout << ans << endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int a[2000020];
int main(void)
{
    ll n,m,s=0,k,t,T,x,y;
    scanf("%lld %lld",&x,&y);
    for(int i=0;i<y;i++)
    {
        scanf("%lld",&t);
        s+=t;
    }
    if(x<=s)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}




Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>
using namespace std;
//#define int long long

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	priority_queue<pair<int, int>> all;
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		all.push({ x,1 });
	}
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		all.push({ b,a });
	}
	long long sum = 0;
	while (n--)
	{
		auto tp = all.top();
		all.pop();
		sum += tp.first;
		if (tp.second != 1)
		{
			all.push({ tp.first, tp.second - 1 });
			}
	}
		cout << sum << "\n";
}


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

int main(){
  int n, m; scanf("%d %d", &n, &m);
  vector<vector<int> > data(100010);
  for(int i = 0; i < n; i++){
    int a, b; scanf("%d %d", &a, &b);
    data[a].push_back(b);
  }
  
  priority_queue<int> que;
  int ans = 0;
  for(int i = 0; i <= m; i++){
    for(int j = 0; j < data[i].size(); j++) que.push(data[i][j]);
    if(que.empty()) continue;
    ans += que.top();
    que.pop();
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 8620
def pick(sol, a):
    count,s = 0, sol
    while (True):
        count += 1
        if s not in a:
            return s
        else:
            if count%2:
                s -= count
            else:
                s += count
def near(a, n):
    ans = set()
    for i in a:
        ans.add(max(i,n))
        if i == n:
            break
        if len(ans)!=1:
            break
    else:
        if len(ans) == 1:
            if (ans[0]==n):
                i = a[0]
            elif ans[0]==a[-1]:
                i = a[-1]
    print(pick(i, a))

n ,k = map(int,input().split())
a = sorted(list(map(int,input().split())))
if k == 0:
    print(n)
else:
    near(a,n)

Measured memory_bytes: 9004
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] M = new int[n][n];

        //??????
        for(int i = 0; i < n; i++) {
            int a = sc.nextInt();
            int k = sc.nextInt();
            for(int j = 0; j < k; j++) {
                int b = sc.nextInt();
                M[a - 1][b - 1] = 1;
            }
        }
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < n; j++) {
                if(j > 0) System.out.print(" ");
                System.out.print(M[i][j]);
            }
            System.out.println();
        }
    }

}

class Stack {
    int top;
    int MAX = 100007;
    int[] S = new int[MAX];

    Stack() {
        top = 0;
    }
    boolean isEmpty() {
        return top == 0;
    }
    boolean isFull() {
        return top > MAX;
    }
    void push(int x) {
        if(isFull()) return;
        top++;
        S[top] = x;
    }
    int pop() {
        if(isEmpty()) return -1;
        top--;
        return S[top + 1];
    }
}
class P {
    String name;
    int time;
    P(String n, int t) {
        name = n;
        time = t;
    }
}

Measured memory_bytes: 34812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int N=cin.nextInt();
        string s=cin.next();
       if(N<3200)Console.WriteLine("red");
      else Console.WriteLine(s);
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}

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


void solve(){
    int a,b,c;
    cin >> a >> b >> c;
    int p = max(a,max(b,c));
    int q = min(a,min(b,c));
    cout << p-q << endl;
}

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


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

typedef long long ll;

const int N = 2000006;

ll a[N];
bool b[N];
pair<ll,ll> p[N];
ll v[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	ll ans = 1000;
	vector<ll>v;
	a[0]  = 1000000;
	a[n+1] = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	
	for(int i=1;i<n;i++){
		if(a[i] <= a[i-1] && a[i] <= a[i+1])b[i] = true;
		if(a[i] >= a[i-1] && a[i] >= a[i+1])b[i] = true;
		//cout<<b[i]<<" ";
	}
	//cout<<endl;
	ll mn = 1000,pr = 0;
	for(int i=1;i<=n;i++){
		if(b[i]){
			if(a[i] <= a[i-1] && a[i] <= a[i+1]){
				pr += mn/a[i];
				mn -= (a[i])*(mn/a[i]);
			}else{
				mn += pr*a[i];
				pr = 0;
			}
		}
		ans = max(ans,mn + pr*a[i]);
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3696
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;

	if (x-r < 0) {
		cout << "No" << endl;
		return 0;
	}
	if (y-r < 0) {
		cout << "No" << endl;
		return 0;
	}
	if (x+r > W) {
		cout << "No" << endl;
		return 0;
	}
	if (y+r > H) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 1156
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		
		Scanner num = new Scanner(System.in);
		
		int a = num.nextInt();
		int b = num.nextInt();
		if(a == b){
			System.out.println("a == b");
		}else if(a > b){
			System.out.println("a > b");
		}else if(a < b){
			System.out.println("a < b");
		}else{
			System.out.println("入力に問題があります");
		}
	}
}

Measured memory_bytes: 17160
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,n=0,m=0,f=0;
    cin>>a;
    while(n!=a+1){
        f=0;
        m=n;
        if(n%3==0&&n!=0){
            cout<<" "<<n;
            f=1;
        }
        if(f!=1){
            while(1){
                if(m%10==3){
                    cout<<" "<<n;
                    break;
                }else if(m<=10){
                    break;
                }
            m/=10;
            }
        }
        n++;
    }
    cout<<endl;
}



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

int main(){
#ifdef LOCAL
    freopen("../a.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for(int &x : a) cin >> x;
    const int N = 1e5;
    vector<int> cntOdd(N+1), cntEven(N+1);
    bool isOdd = 1;
    for(int x : a){
        isOdd ? ++cntOdd[x] : ++cntEven[x];
        isOdd = !isOdd;
    }
    pair<int,int> maxOdd, maxEven;
    for(int i = 0; i < N; ++i){
        maxOdd = max(maxOdd, {cntOdd[i], i});
        maxEven = max(maxEven, {cntEven[i], i});
    }
    
    const int halfSize = n >> 1;    
    int ans1 = halfSize - maxOdd.first;
    pair<int,int> even;
    cntEven[maxOdd.second] = 0;
    for(int i = 1; i < n; i += 2){
        even = max(even, {cntEven[a[i]], a[i]});
    }
    ans1 += halfSize - even.first;

    int ans2 = halfSize - maxEven.first;
    pair<int,int> odd;
    cntOdd[maxEven.second] = 0;
    for(int i = 0; i < n; i += 2){
        odd = max(odd, {cntOdd[a[i]], a[i]});
    }
    ans2 += halfSize - odd.first;

    cout << min(ans1, ans2);
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define pii pair<int,int>
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

const int inf=1e9+10;
const int maxn=55;

vector <pii> q,g[maxn];
vector <int> v[maxn];
int n,m;
bool vis[maxn];

bool get_path(int x,int ed,int id){
	vis[x]=1;
	if(x==ed) return true;	
	for(int i=0;i<g[x].size();i++){
		int to=g[x][i].fst;
		if(!vis[to]) if(get_path(to,ed,id)){
			v[id].pb(g[x][i].snd);
			return true;
		}
	}
	return false;
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int u,v;
		scanf("%d%d",&u,&v); 
		u--; v--;
		g[u].pb(mp(v,i));
		g[v].pb(mp(u,i));
	}
	scanf("%d",&m);
	for(int i=0;i<m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		u--; v--;
		q.pb(mp(u,v));
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<maxn;j++) vis[j]=0;
		get_path(q[i].fst,q[i].snd,i);
	}
	ll ans=0ll;
	for(int mask=0;mask<(1<<m);mask++){
		for(int i=0;i<n;i++) vis[i]=0;
		vector <int> t;
		for(int i=0;i<m;i++)
			if(mask&(1<<i)) t.pb(i); 
		int sum=0;
		for(int i=0;i<t.size();i++) for(int j=0;j<v[t[i]].size();j++)
			if(!vis[v[t[i]][j]]) vis[v[t[i]][j]]=1;
		for(int i=0;i<n-1;i++) if(vis[i]) sum++;
		ll sum2=1ll;
		for(int i=0;i<n-1-sum;i++) sum2=sum2*2ll;
		if(t.size()%2==0) ans+=sum2;
		else ans-=sum2;		
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


def main():
    sx, sy, tx, ty = map(int, input().split())
    y = ty - sy
    x = tx - sx

    print("R" * x + "U" * y, end="")
    print("L" * x + "D" * y, end="")
    print("D" + "R" * (x + 1) + "U" * (y + 1) + "L", end="")
    print("U" + "L" * (x + 1) + "D" * (y + 1) + "R")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
int h[maxn];
int main()
{
	int n;
	int sum=0;
	int off=0;
	cin>>n;
	h[0]=h[n+1]=0;
	for(int i=1;i<=n;i++) 
	{
		cin>>h[i];
	}
	for(int i=1;i<=n+1;i++)
	{
		if(h[i]<h[i-1])
		{
			sum+=h[i-1]-off;
			off=h[i];
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, a, b) = get!(usize, i64, i64);
    let hs = get!(i64; n);

    let mut l = 0i64;
    let mut r = 1000000000i64;
    while l+1 < r {
        let m = (l+r)/2;
        let mut mm = 0;
        for h in hs.iter() {
            let hh = h - m * b;
            if hh > 0 {
                mm += (hh + (a-b) - 1) / (a-b);
            }
        }
        if mm <= m {
            r = m;
        } else {
            l = m;
        }
    }
    println!("{}", r);
}

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

int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    int n = 1;
    int m = -1;
    for (int a = 0; 100 * A * a <= F; a++) {
        int x = F - 100 * A * a;
        for (int b = 0; 100 * B * b <= x; b++) {
            int y = min(x - 100 * B * b, E * (A * a + B * b));
            for (int c = 0; c * C <= y; c++) {
                int d = (y - (c * C)) / D;
                if (m * (a * A + b * B) < (c * C + d * D) * n) {
                    n = a * A + b * B;
                    m = c * C + d * D;
                }
            }
        }
    }
    cout << n * 100 + m << " " << m << endl;
}

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

vector<ll> vec;
void add753(ll num, int seven, int five, int three){
    if(num > 10000000000)
        return;
    if(seven > 0 && five > 0 && three > 0)
        vec.push_back(num);
    add753(num*10 + 7, seven + 1, five, three);
    add753(num*10 + 5, seven, five + 1, three);
    add753(num*10 + 3, seven, five, three + 1);
}
 
int main(){
    ll N;
    cin >> N;

    add753(3, 0, 0, 1);
    add753(5, 0, 1, 0);
    add753(7, 1, 0, 0);
    // 昇順ソート
    sort(vec.begin(), vec.end());
    for(int i=0;i<vec.size();i++){
        if(N < vec[i]){
            cout << i << endl;
            return 0;
        }
    }
    
}

Measured memory_bytes: 1400
h, w = map(int, input().split())
lst = []
for i in range(h):
    lsti = list(map(int, input().split()))
    lst.append(lsti)

num = 0
ans = []
for i in range(h-1):
    for j in range(w):
        if lst[i][j] % 2 == 1:
            lst[i][j] -= 1
            lst[i+1][j] += 1
            num += 1
            ans.append([i+1, j+1, i+2, j+1])

for j in range(w-1):
    if lst[h-1][j] % 2 == 1:
        lst[h-1][j] -= 1
        lst[h-1][j+1] += 1
        num += 1
        ans.append([h, j+1, h, j+2])

print(num)
for i in range(num):
    ansi = ans[i]
    print(ansi[0], ansi[1], ansi[2], ansi[3])

Measured memory_bytes: 71004
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	h, w, _ := nextInt(), nextInt(), nextInt()
	s := make([]string, h)
	for i := range s {
		s[i] = next()
	}

	cake := make([][]int, h)
	for i := range cake {
		cake[i] = make([]int, w)
	}

	id := 0
	for top := 0; top < h; {
		// 1段目の状態で初期化
		exist := make([]bool, w)
		for i := 0; i < w; i++ {
			exist[i] = s[top][i] == '#'
		}
		// ヨコに切れるところまで切る
		bottom := top + 1
		for ok := true; ok && bottom < h; {
			line := make([]bool, w)
			for i := 0; i < w; i++ {
				line[i] = s[bottom][i] == '#'
				if line[i] && exist[i] {
					ok = false
					break
				}
			}
			if ok {
				for i := 0; i < w; i++ {
					exist[i] = exist[i] || line[i]
				}
				bottom++
			}
		}

		cnt := 0
		for l := 0; l < w; {
			if exist[l] {
				cnt++
			}
			r := l
			for ; r+1 < w; r++ {
				if exist[r+1] {
					cnt++
					if cnt > 1 {
						break
					}
				}
			}
			id++
			for i := l; i <= r; i++ {
				for j := top; j < bottom; j++ {
					cake[j][i] = id
				}
			}
			l = r + 1
		}

		top = bottom
	}

	for i := range cake {
		for j := 0; j < w; j++ {
			if j < w-1 {
				putf("%d ", cake[i][j])
			} else {
				putf("%d\n", cake[i][j])
			}
		}
	}
}


Measured memory_bytes: 3072
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(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((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i, n){
        cin >> h[i];
    }
    h[0]--;
    bool ok = true;
    FOR(i, 1, n){
        if(h[i-1] > h[i]){
            ok = false;
            break;
        }
        else if(h[i-1] < h[i])
            h[i]--;
    }

    cout << (ok?"Yes":"No") << endl;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    for (auto &x : X) cin >> x;
    int ret = 1e9;
    for (int i = 0; i < 101; i++) {
        int tmp = 0;
        for (auto x : X) tmp += (i - x) * (i - x);
        ret = min(ret, tmp);
    }
    cout << ret << endl;
}


Measured memory_bytes: 256