akhauriyash/Code-Regression huggingface dataset:
N = int(input())
R=[list(map(int,input().split())) for i in range(N) ]
B=[list(map(int,input().split()))  for i in range(N) ]
R.sort(key=lambda x:x[1],reverse=1)
B.sort()
ans=0
for b in B:
    for r in R:
        if b[1]>r[1] and b[0]>r[0]:
            ans+=1
            R.remove(r)
            break
print(ans)

Measured memory_bytes: 3064
function main(input) {
  input=input.trim();
  var N = parseInt(input.split("\n")[0], 10);
  var K = parseInt(input.split("\n")[1], 10);
  var x = input.split('\n')[2].split(' ').map((n) => parseInt(n, 10));
  var ans=0
  for(var i=0; i<N; i++){
    var temp=Math.min.apply(null, [Math.abs(x[i]),Math.abs(K-x[i])])
    ans+=2*temp
  }
  console.log(ans);


}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
#include <iostream>
 
using namespace std;
 
int main (){
int a,b,c,d,e;
cin >> a >> b >> c >> d >> e;
 
if((c-e) >= 0 && (c+e) <= a && (d-e) >= 0 && (d+e) <= b){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    const int SIZE = 100010;
    array<int, SIZE> v{};
    for (int i = 0; i < n; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        v[a-1]++; v[b]--;
    }
    for (int i = 1; i < SIZE; ++i) {
        v[i] += v[i-1];
    }
    int ans = 0;
    for (int i = 0; i < SIZE; ++i) {
        if(v[i] >= i) ans = i;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3592
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int a,b,q,x;
vi s,t;

signed main(){
    I(a); I(b); I(q);
    s.resize(a+2);
    t.resize(b+2);
    s[0] = t[0] = -1e+14;
    s[a+1] = t[b+1] = 1e+14;
    REPS(i,a) I(s[i]);
    REPS(i,b) I(t[i]);
    REP(i,q){
        I(x);
        auto ita = lower_bound(all(s), x);
        auto itb = lower_bound(all(t), x);
        int ia2 = abs(x-*ita);
        int ib2 = abs(x-*itb);
        ita--; itb--;
        int ia1 = abs(x-*ita);
        int ib1 = abs(x-*itb);

        int ret = max(ia1,ib1);
        ret = min(ret, max(ia2,ib2));
        ret = min(ret, min(ia1,ib2)*2 + max(ia1,ib2));
        ret = min(ret, min(ia2,ib1)*2 + max(ia2,ib1));
        printf("%lld\n", ret);
    }
}

Measured memory_bytes: 2944
inpl = lambda: list(map(int,input().split()))
N = int(input())
st = []
for i in range(N):
    k = input().split()
    st.append((k[0],int(k[1])))
X = input()
i = 0
while st[i][0] != X:
    i += 1
ans = 0
for j in range(i+1,N):
    ans += st[j][1]
print(ans)

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

class DisjointSetUnion {
  int size;
  vector<int> V;
  public:
  DisjointSetUnion(int s): size(s), V(s, -1) {
    for (int i = 0; i < s; i++) V[i] = i;
  }
  void connect(int u, int v) {
    V[find(u)] = find(v);
  }
  int find(int node) {
    int cur_node = node, p = V[node];
    while (cur_node != p) {
      V[cur_node] = V[p];
      cur_node = p;
      p = V[p];
    }
    return cur_node;
  }
  int same(int u, int v) {
    return (find(u) == find(v));
  }
};

int main() {
  int N, Q;
  cin >> N >> Q;
  int t, u, v;
  DisjointSetUnion d(N);
  for (int q = 0; q < Q; q++) {
    cin >> t >> u >> v;
    if (t == 0) {
      d.connect(u, v);
    } else {
      cout << d.same(u, v) << endl;
    }
  }
}

Measured memory_bytes: 3864
/**
 * @author Video Vocabulary
 * @date 2020-05-31 18:43:19
 */
#include <bits/stdc++.h>

using namespace std;

void solve() {
    
}

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

    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
}


Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))
B = [0] * (10**5+1)
for a in A:
    B[a] += 1
ans = 0
for b in B:
    if b > 1:
        ans += b - 1
if ans & 1:
    ans += 1
print(N - ans)

Measured memory_bytes: 14008
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int R;
    cin >> R;

    if (R > 2799) cout << "AGC" << endl;
    else if(R > 1199) cout << "ARC" << endl;
    else cout << "ABC" << endl;

}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int mod = int(1e9) + 7;
ll pro(ll t){
	ll k=1;
	FOR(i,1,t+1){
		k*=i;
		k%=mod;
	}
	return k;
}
int n,m;
int main() {
	cin >> n >> m;
	if(abs(n-m) > 1){
		cout << 0;
	}else if(n-m==0){
		ll a = pro(n);
		a = a * a % mod;
		cout << 2 * a % mod;
	}else{
		if(n<m)swap(n,m);
		// n = m+1
		cout << pro(n) * pro(m) % mod;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
        int N,min=2000000000,max;
        max=min*-1;
        cin >> N;
        int x;for(int i=0 ; i<N ; i++ ){
                cin >> x;
                if(min>x)min=x;
                if(max<x)max=x;
        }
        cout << max-min << endl;
        return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define VI  vector<ll>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
const ll mod=1e9+7;
double pi = 2 * acos(0.0);
#define FASTIO ios_base::sync_with_stdio(false);cout.tie(NULL);cout.tie(NULL);
ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }
bool cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return (a.first)<(b.first);
}
ll power(ll a,ll b)
{
        ll p=1;
        for(ll i=1;i<=b;i++)
        p*=a;

        return p;
}
ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
 }
void bfs(map<ll,vector<ll> > &g,ll src,vector<ll> &c)
{
    queue<ll> q;
    map<ll,ll> p;
    q.push(src);
    p[src]=src;
    c[src]=1;
    while(!q.empty())
    {
        ll u=q.front();
        q.pop();
        ll i=1;
        for(auto v:g[u])
        {
            if(c[v]==-1)
            {
                q.push(v);
                p[v]=u;
                if(i==c[u]||i==c[p[u]])
                    i++;
                if(i==c[u]||i==c[p[u]])
                    i++;
                c[v]=i;
                i++;
            }
        }
    }
}
ll dp[100005],n,k;
ll fun(vector<ll> &h,ll j)
{
    if(j==0) return 0;
    if(dp[j]!=-1) return dp[j];
    ll ans=INT_MAX;
    for(ll i=1;i<=k;i++)
    {
        if(j-i>=0)
            ans=min(ans,fun(h,j-i)+abs(h[j]-h[j-i]));
    }

    return dp[j]=ans;
}
int main()
{
    FASTIO;
    ll i;
    cin>>n>>k;
    vector<ll> h(n);
    memset(dp,-1,sizeof(dp));
    for(i=0;i<n;i++) cin>>h[i];
    cout<<fun(h,n-1)<<endl;
    return 0;
}


Measured memory_bytes: 9600
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int ans[2004][2004];
int xx[2004];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k,n,x,y,i,j,v,c=0;
    cin>>n>>x>>y;
    for(i=1;i<=n;++i){
    	for(j=1;j<=n;++j){
    		if(i!=j && ans[i][j]==0){
    			ans[i][j]=j-i;
    			ans[j][i]=j-i;
			}
		}
	}
	//vii point;
	ans[x][y]=1;
	ans[y][x]=1;
	for(i=1;i<=n;++i){
		for(j=1;j<=n;++j){
			if((ans[i][x]+ans[x][y]+ans[y][j])<ans[i][j]){
				ans[i][j]=(ans[i][x]+ans[x][y]+ans[y][j]);
			}
		}
	}
	for(i=1;i<=n;++i){
		for(j=i+1;j<=n;++j){
			xx[ans[i][j]]++;
		}
	}
	for(i=1;i<n;++i){
		cout<<xx[i]<<'\n';
	}
}

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

int main(){
  int N, K, x = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++){
    if (x < K){
      x *= 2;
      continue;
    }
    
    x += K;
  }
  
  cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define maxn 100005
using namespace std;

int table[maxn] = {}, arr[maxn] = {};
int n, x, m, l, r;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> x >> m;
    table[x] = 1; arr[1] = x;
    for(int i = 2; true; i++) {
        x = x * x % m;
        arr[i] = x;
        if(table[x]) {
            l = table[x];
            r = i;
            break;
        }
        table[x] = i;
    }
    // 2 4 0 0 0 0
    for(int i = 1; i <= r; i++) {
        arr[i] += arr[i - 1];
    }
    int ans = 0;
    if(n < l) {
        ans = arr[n];
    }
    else {
        n -= l;
        ans += arr[l];
        int cnt = n / (r - l);
        ans += cnt * (arr[r] - arr[l]);
        ans += arr[l + n % (r - l)] - arr[l];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 4764
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

template<typename T>
struct SegmentTree {
private:
	int sz, n;
	vector<T> data;
	function<T(T, T)> f;
	T identity_element;
public:
	/* constructor */
	SegmentTree(
		vector<T> v, // initial data
		T identity_element, // identity element
		function<T(T, T)> f // operation
	) {
		sz = v.size();
		n = 1; while (n < sz) n <<= 1;
		this->f = f;
		this->identity_element = identity_element;
		data.resize(2 * n - 1, identity_element);
		for (int i = 0; i < sz; ++i)
			data[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; --i)
			data[i] = f(data[2 * i + 1], data[2 * i + 2]);
	}
	/* update query */
	void update(int idx, const T val) {
		idx += n - 1;
		data[idx] = val;
		while (idx) {
			idx = (idx - 1) >> 1;
			data[idx] = f(data[2 * idx + 1], data[2 * idx + 2]);
		}
	}
	/* get query */
	T get(int left, int right, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		if (r <= left || right <= l) return identity_element;
		if (left <= l && r <= right) return data[k];
		T val_l = get(left, right, 2 * k + 1, l, (l + r) / 2);
		T val_r = get(left, right, 2 * k + 2, (l + r) / 2, r);
		return f(val_l, val_r);
	}
};

int main(void){
	int N, Q; cin >> N >> Q;
	vector<int> c(N);
	for (auto& ci : c) cin >> ci;
	using q = tuple<int, int, int>;
	vector<q> que(Q);
	for (int i = 0; i < Q; ++i){
		int l, r; cin >> l >> r;
		--l, --r;
		que[i] = make_tuple(l, r, i);
	}
	sort(
		que.begin(), que.end(),
		[](auto q1, auto q2){
			return get<1>(q1) < get<1>(q2);
		}
	);
	SegmentTree<int> seg(vector<int>(N + 1, 0), 0, [](int a, int b){ return a + b; });
	vector<int> lastappered(N + 1, -1);
	int R = -1;
	vector<int> res(Q);
	for (int i = 0; i < Q; ++i){
		int id = get<2>(que[i]);
		int l = get<0>(que[i]);
		int r = get<1>(que[i]);
		// cout << id << " " << l << " " << r << endl;
		while (R < r){
			R++;
			int cr = c[R];
			int tmp = lastappered[cr];
			int t;
			if (tmp != -1){
				t = seg.get(tmp, tmp + 1);
				seg.update(tmp, t - 1);
			}
			lastappered[cr] = R;
			t = seg.get(R, R + 1);
			seg.update(R, t + 1);
		}
		// for (int i = 0; i <= N; ++i)
		// 	cout << seg.get(i, i + 1) << " ";
		// cout << endl;
		res[id] = seg.get(l, r + 1);
	}
	for (auto r : res) cout << r << endl;
	return 0;
}

Measured memory_bytes: 19516
import sys
from collections import defaultdict
readline = sys.stdin.readline


class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False


def main():
    N, M = map(int, readline().split())
    a = list(map(int, readline().split()))
    uf = UnionFind(N)
    for _ in range(M):
        x, y = map(int, readline().split())
        uf.union(x, y)
    mins = defaultdict(list)
    for i in range(N):
        mins[uf.find(i)].append(a[i])
    if len(mins) == 1:
        return 0
    ans = 0
    others = []
    for v in mins.values():
        v.sort(reverse=True)
        ans += v.pop()
        others += v
    others.sort()
    return 'Impossible' if len(others) < len(mins) - 2 else ans + sum(others[:len(mins) - 2])

print(main())


Measured memory_bytes: 29864
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cmath>
#include <climits>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;

#define fast_cin() ios_base::sync_with_stdio(false)

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int max_N = 55;
ll nways[max_N][2];
int inp[max_N];

int main()
{
	int N, P;
	cin >> N >> P;
	for (int i = 1; i <= N; ++i) {
		cin >> inp[i];
	}

	nways[0][0] = 1;
	for (int i = 1; i <= N; ++i) {
		nways[i][0] = nways[i - 1][inp[i] % 2] + nways[i - 1][0];
		nways[i][1] += nways[i - 1][(inp[i] % 2) ^ 1] + nways[i - 1][1];;
	}

	cout << nways[N][P] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, a, b;

    scanf("%d %d %d", &n, &a, &b);

    int sum = 0;
    int sum_k = 0;
#if 0
    for(int i = 0;i <= n;++i){
        sum_k = i % 10 + ((i / 10) % 10) + ((i / 100) % 10) + ((i / 1000) % 10) + (i / 10000);
        if(a <= sum_k && sum_k <= b) sum += i;
    }
#endif

    for(int i = 0;i <= n;++i){
        int j = i;
        while(j > 0){
            sum_k += j % 10;
            j /= 10;
            //printf("%d\n", i);
        }
        if(a <= sum_k && sum_k <= b) sum += i;
        sum_k = 0;
    }

    printf("%d\n", sum);

    return 0;
}

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

using namespace std;

#define u64             uint64_t
#define i64             int64_t
#define mod             1000000007
#define inf             1e18
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    /**************************/
    
    u64 a;
    cin >> a;
    u64 ans = 0;    
    for(u64 i = 1; i <= a; ++i)
    {
        u64 j = a/i;
        ans += (j*(j+1)*i)/2;
    }
    cout << ans;
    /**************************/
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}


Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <forward_list>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// sanitize: shift + f11
// debug: shift + f9

void A() {
}

void B() {
}

void C() {
    ll L;

    cin >> L;

    cout.precision(6);
    cout << fixed << ((double)L/3.)*((double)L/3.)*((double)L/3.) << endl;
}

int fact(int n);

int nCr(int n, int r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

// Returns factorial of n
int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}

void D() {
    ll N;
    cin >> N;
    vi ai(N);
    map<ll, ll> freq;
    map<ll, ll> ncrs;

    R1(N)
        cin >> ai[i];

    R1(N)
        ++freq[ai[i]];

    ll sum = 0;
    for(auto e : freq) {
        sum += (e.second)*(e.second-1)/2;
    }

    R1(N) {
        ll currSum = sum;
        currSum -= (freq[ai[i]])*(freq[ai[i]] - 1)/2;
        currSum += (freq[ai[i]]-1)*(freq[ai[i]]-2)/2;
        cout << currSum << endl;
    }
}

void E() {
}

int main()
{
    D();
}

Measured memory_bytes: 11008
#include <iostream>
#include <vector>

using namespace std;

int m=1;
vector<int> A;

int cnt(int n, int i){

	if(n%(m+1)==0){
		A[i]=m;
		return n/(m+1)-1;
	}else{
		A[i]=m-1;//
		return n/(m+1);
	}
}

int main(){
	int N;
	cin>>N;
	A.resize(N);
	for(int i=0; i<N; i++){
		cin>>A[i];
	}

	unsigned long long int ans=A[0]-1;
	for(int i=1; i<N; i++){
		if(A[i]==m+1){
			m++;
		}
		int c=cnt(A[i], i);
		ans+=c;
	}
	cout<<ans<<endl;

	return 0;
}


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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a, b(n);
    rep(i, n - 1)
    {
        cin >> b[i];
    }
    a.push_back(b[0]);
    rep(i, n - 2) a.push_back(min(b[i], b[i + 1]));
    a.push_back(b[n - 2]);
    cout<<accumulate(a.begin(), a.end(), 0)<<endl;
    // rep(i, n ) cout << a[i];
    return 0;
}

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

int main(void) {
	long int a,v,b,w,t;
	scanf("%ld%ld",&a,&v);
	scanf("%ld%ld",&b,&w);
	scanf("%ld",&t);
	if(b-a > 0){
		if(((b+w*t) - (a+v*t))<= 0){
			printf("YES");
		}else{
			printf("NO");
		}
	}
	else if(a-b > 0){
		if((b-w*t) - (a-v*t) >= 0){
			printf("YES");
		}
		else{
			printf("NO");
			}
	}
	return 0;
}

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

using namespace std;
int main(){
	string str,dammy;
	int s;
	while(getline(cin,str)){
		dammy=str;
		for(int i=1;i<27;i++){
			for(int j=0;j<str.size();j++)if(str[j]!=' '&&str[j]!='.')str[j]++;
			//cout<<str<<endl;
			for(int j=0;j<str.size();j++)if(str[j]>'z')str[j]='a';
			s=str.find("this");
			if(s!=string::npos)break;
			s=str.find("that");
			if(s!=string::npos)break;
			s=str.find("the");
			if(s!=string::npos)break;
		}
	cout<<str<<endl;
}
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 int n; 
 cin >> n;
 vector<int> A(n) ;rep(i,n) cin >> A[i] ;
 int ans=0 ;
 rep(i,n){
   int ord =0 ;
   rep(j,30){
     
   if(A[i]%2==1){
     break ;
   }
   A[i] /=2 ;
   ord++ ;
   }
  ans+= ord ;
 }
 cout <<ans<<endl ;
     return 0;
}


Measured memory_bytes: 256
import queue

n = int(input())
graph = []
for _ in range(n):
    line = list(map(int, input().split()))
    graph.append([v - 1 for v in line[2:]])

q = queue.Queue()
q.put(0)
dist = [-1] * n
dist[0] = 0

while True:
    v = q.get()
    for next_v in graph[v]:
        if dist[next_v] == -1: 
            q.put(next_v)
            dist[next_v] = dist[v] + 1

    if q.empty():
        break

for i in range(n):
    print(i + 1, dist[i])



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

typedef vector<int> vi;
map<char,vi> part;

string e;
int pos;


vi merge(vi a,vi b){
    vi c(a.size());
    for(int i = 0 ; i < a.size() ; i++){
        c[i] = a[b[i]];
    }
    return c;
}
vi seq(int x,vi a){
    vi lg[32];
    lg[0] = a;
    for(int i = 1 ; i < 32 ; i++)
        lg[i] = merge(lg[i-1],lg[i-1]);
    vi res(a.size());
    for(int i = 0 ; i < a.size() ; i++) res[i] = i;
    for(int i = 0 ; i < 32 ; i++)
        if( x >> i & 1 ){
            res = merge(res,lg[i]);
        }
    return res;
}

vi f2();

vi f1(){
    vi res = f2();
    while( e[pos] == '+' ){
        pos++;
        res = merge(res,f2());
    }
    return res;
}

vi f2(){
    if( e[pos] >= '0' && e[pos] <= '9' ){
        int num = 0;
        while( e[pos] >= '0' && e[pos] <= '9'){
            num = num * 10 + e[pos++] - '0';
        }
        return seq(num,f2());
    }
    if( e[pos] == '('){
        pos++;
        vi res = f1();
        pos++;
        return res;
    }
    if( e[pos] >= 'A' && e[pos] <= 'Z'){
        return part[e[pos++]];
    }
    while(1){}
}

int main(){
    int N,M;
    cin >> N >> M;
    for(int i = 0 ; i < M ; i++){
        char name;
        int H;
        cin >> name >> H;
        vi p;
        for(int j = 0 ; j < N ; j++) p.push_back(j);
        for(int j = 0 ; j < H-1 ; j++){
            for(int k = 0 ; k + 1 < N ; k++){
                int x; cin >> x;
                if(x){
                    swap(p[k],p[k+1]);
                }
            }
        }
        part[name] = p;
    }

    int EN;
    cin >> EN;
    while(EN--){
        cin >> e;
        pos = 0;
        e += "~";
        vi res = f1();
        //vi res = merge(merge(part['A'],part['B']),merge(part['A'],part['B']));
        //vi res = merge(part['A'],part['A']);
        for(int i = 0 ; i < res.size() ; i++){
            cout << res[i]+1;
            if( i + 1 == res.size() ) cout << endl;
            else cout << " ";
        }
    }

}

Measured memory_bytes: 1264
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let a = input::<i64>();
    let b = input::<i64>();

    println!("{}", if a <= 8 && b <= 8 { "Yay!" } else { ":(" });
}


Measured memory_bytes: 4352
a, b = gets.chomp.split(' ').map(&:to_i)

eight_tax_price = (a / 0.08).round
ten_tax_price = (b / 0.1).round

eight_is_true = false
ten_is_true = false

eight_is_true = true if (eight_tax_price * 0.1).floor == b
ten_is_true = true if (ten_tax_price * 0.08).floor == a

if eight_tax_price === ten_tax_price
  puts eight_tax_price
elsif eight_is_true && ten_is_true
  puts eight_is_true <= ten_is_true ? eight_is_true : ten_is_true
elsif eight_is_true
  puts eight_tax_price
elsif ten_is_true
  puts ten_tax_price
else
  puts -1
end

Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
    int h,w,n,x;
    scanf("%d%d%d",&h,&w,&n);
    if(h>w) { x=h;h=w;w=x; } //w>=h
    if(n<=w) printf("1\n");
    else if(!(n%w)) printf("%d\n",n/w);
    else printf("%d\n",n/w+1);
    return 0;
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

ll gcb(ll a,ll b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    ll n,x;
    vector<ll> nxmul;
    ll d = 1;
    cin >> n >> x;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        nxmul.pb(abs(x-tmp));
    }
    d = gcb(nxmul[0],nxmul[1]);
    FOR(i,2,n){
        d = gcb(d,nxmul[i]);
    }
    cout << d << endl;
    return 0;
}


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

int main(){

  string s;
  cin >> s;

  long long  sum = 0;
  int n = s.size();

  for(int temp = 0; temp < (1 << n-1); temp++){//(n-1)個の数字間に+を入れるかいれないかの全パターン2^(n-1)通りをtempで回す（n-1回のroop）
      long long t = s[0] - '0';//要素0を数字に変換

      for(int i = 0; i < n-1; i++){//iで「sの要素1からの中身　n-1個」と「+の有無を表すbit列tempの中身　n-1個」を一文字ずつ見ていく

          if(temp & (1 << i)){ //tempの(i+1)要素が1ならば、
              sum += t;//tの直後には+が入るためtをsumに加算
              t = s[i+1] - '0';//tを次の数字に更新
          }
          else{//tempの(i+1)要素が0ならば、
              t *= 10; //tの直後には+は入らないためtを10倍して
              t += s[i+1] - '0';//そこに次の数字を足してtとする
          }
      }
        sum += t;//sのn個目の要素だけは例外処理（この数字はいかなる場合でもシンプルに足される）
    }

    cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) throws Exception {
    solve(System.in, System.out);
  }

  static final int MOD = (int)Math.pow(10,9)+7;

  static void solve(InputStream is, PrintStream os) {
    // Your code here!
    Scanner scan = new Scanner(is);
    int N = scan.nextInt();
    int ans = 0;
    for(int i = 1; i < N; i++) {
      int tgt = N - i;

      int tmp = 1;
      for (int j = 2; j <= Math.sqrt(tgt); j++) {
        int cnt = 0;
        while (tgt % j == 0) {
          cnt++;
          tgt/= j;
        }
        tmp *= (cnt + 1);
        if (tgt == 1)
          break;
      }
      if (tgt != 1)
        tmp *= 2;

      ans += tmp;
    }
    os.println(ans);
  }
}


Measured memory_bytes: 27284
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

const val mod = (1e9 + 7).toInt()

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

   /* val H = sc.nextLong()
    val W = sc.nextLong()
    val t = sc.nextLong()

    val w = gcd(W, t)
    val h = gcd(H, t)

    var res = 0L

    val x = H / h
    val y = W / w
    res = (res + pow(2, x)) % mod
    res = (res + pow(2, y)) % mod
    res = (res + pow(2, gcd(x, y))) % mod
    res = (res - 3 + mod) % mod

    res = pow(res, (w * h) % mod)

    println(res)
*/
    val n = sc.nextLong()
    val m = sc.nextLong()
    val T = sc.nextLong()
    val gn = gcd(T, n)
    val gm = gcd(T, m)
    val mod = 1000000007
    val q = gcd(n / gn, m / gm)
    println(pow(pow(2, q) - 2 + pow(2, n / gn) + pow(2, m / gm) - 1, gn * gm))
}

fun inv(h: Long): Long = pow(h, (mod - 2).toLong())

fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)
fun pow(a: Long, x: Long): Long {
    var res = 1L
    var x = x
    var a = a
    while (x > 0) {
        if (x % 2 == 1L) res = (res * a) % mod
        a = (a * a) % mod
        x /= 2
    }
    return res
}


class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31392
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    vector<ll>v1,v2,v3;
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    for(int i=0;i<a;i++)
    {
        ll a2;
        cin>>a2;
        v1.push_back(a2);
    }
    sort(v1.begin(),v1.end());
    for(int i=0;i<b;i++)
    {
        ll a2;
        cin>>a2;
        v2.push_back(a2);
    }
    sort(v2.begin(),v2.end());
    for(int i=0;i<c;i++)
    {
        ll a2;
        cin>>a2;
        v3.push_back(a2);
    }
    sort(v3.begin(),v3.end());
    int i=a-x;
    int j=b-y;
    int k=c-1;
    while(i<a&&j<b&&k>=0)
    {
        if(v1[i]>=v2[j])
        {
            if(v3[k]>v2[j])
            {
                k--;
                j++;
            }
            else
                break;
        }
        else if(v1[i]<=v2[j])
        {
            if(v3[k]>v1[i])
            {
                k--;
                i++;
            }
            else
                break;
        }
    }
    while(k>=0&&j==b&&i<a)
    {
        if(v3[k]>v1[i])
        {
            k--;
            i++;
        }
        else
            break;
    }
    while(k>=0&&i==a&&j<a)
    {
        if(v3[k]>v2[j])
        {
            k--;
            j++;
        }
        else
            break;
    }
    ll sum=0;
    //cout<<i<<" "<<j<<" "<<k<<"\n";
    while(i<a)
    {
        sum+=v1[i];
        i++;
    }

    while(j<b)
    {
          sum+=v2[j];
          j++;
    }

    while(k!=c-1)
    {
        sum+=v3[k+1];
        k++;
    }
    cout<<sum<<"\n";
    return 0;
}


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

int main(){
    long N;
    vector<long> X(100002, 0);
    long a;
    cin >> N;
    for(long i=0;i<N;i++){
        cin >> a;
        X[a]++;
        if(a != 0) X[a-1]++;
        if(a != 1e5-1) X[a+1]++;
    }
    cout << *max_element(X.begin(), X.end()) << endl;
    return 0;
}

Measured memory_bytes: 1024
N,M = map(int, input().strip().split(' '))

def factorial(n):
  ans = 1
  for i in range(2,n+1):
    ans = ans*i % 1000000007
  return ans

if abs(N-M) >= 2:
  print(0)
elif N == M:
  print(factorial(N)*factorial(M)*2 % 1000000007)
else:
  print(factorial(N)*factorial(M) % 1000000007)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int d[N];
    int i;
    for(i=0;i<N;i++)cin >> d[i];
    sort(d,d+N);
    cout << d[N/2]-d[N/2-1] << endl;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

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

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vll a(7);
  rep(i,7) cin>>a[i];
  
  ll ans=0;
  if(a[0]&&a[3]&&a[4]){
    ans=max(3+(a[0]-1)/2*2+(a[3]-1)/2*2+(a[4]-1)/2*2, a[0]/2*2+a[3]/2*2+a[4]/2*2);
  }else{
    ans=a[0]/2*2+a[3]/2*2+a[4]/2*2;
  }
  ans+=a[1];
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;

int my_pow(int a) { return a*a; }

int main(int argc, char ** argv) {
	int ans = (1<<30);
	int N, a[101];
	scanf("%d", &N);
	rep(i, 0, N) scanf("%d", a+i);
	REP(k, -100, 100) {
	    int curr = 0;
	    rep(i, 0, N) curr += my_pow(a[i]-k);
	    ans = min(ans, curr);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3792
n = int(input())

s = list(map(int, input().rstrip().split(" ")))
maxnum = s[0]
minnum = s[0]

for i in range(1, n): 
    if s[i] > maxnum:
        maxnum = s[i]
    if s[i] < minnum:
        minnum = s[i]

print(maxnum - minnum)


Measured memory_bytes: 2940
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = k;
    for (int i=0; i<n-1; i++){
        ans *= k-1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 10^^9L+7;

long[10^^5+1] SS;
bool[10^^5+1] BS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    foreach (_; 0..M) {
        auto a = readln.chomp.to!int;
        BS[a] = true;
    }
    SS[0] = 1;
    foreach (i; 0..N) {
        if (BS[i]) continue;
        SS[i+1] = (SS[i+1] + SS[i]) % P;
        if (i+2 < N+1) SS[i+2] = (SS[i+2] + SS[i]) % P;
    }
    writeln(SS[N]);
}

Measured memory_bytes: 2172
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
  f_1 = min(a[i],b[i])
  f_2 = max(0,min(a[i+1],b[i]-a[i]))
  cnt += f_1+f_2
  a[i] -= f_1
  a[i+1] -= f_2
print(cnt)


Measured memory_bytes: 18624
#include<stdio.h>

int main(void)
{
        int a,b,n,cnt ;
    
        scanf("%d %d",&a,&b);

        n = 0 ; 
        while(n*(a-1)+1 < b){ 
                n++;
        }   

        printf("%d\n",n);

        return 0;
}


Measured memory_bytes: 1732
#include <algorithm>
#include <iostream>

using namespace std;

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

  int A, B;
  cin >> A >> B;

  int ans = 0;
  string i_s;
  for (int i = A; i <= B; ++i) {
    i_s = to_string(i);
    if (i_s[0] == i_s[4] && i_s[1] == i_s[3]) {
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using  namespace std;
#define ll long long int
int main()
{
  ll  n,a,b;
  cin>>n>>a>>b;
  if((a+b)>n)
    cout<<min(a,n)<<endl;
  else
  cout<<(n/(a+b))*a+min(n%(a+b),a)<<endl;
    return 0;
}


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

int main(){

    long long int A, B;
    cin >> A >> B;

    bool flag=true;
    for(int i=1; i<1001; i++){
        int x = round((i*8)/100);
        int y = round(i/10);
        if(x==A && y==B){
            cout << i << "\n";
            flag=false;
            break;
        }
    }
    if(flag) cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

s = [0 for i in range(n)]
for i in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	for i in a:
		s[i-1] += 1
cnt = 0
for i in s:
	if i == 0:
		cnt += 1
print (cnt)

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//桁数
ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//約数全列挙
vector<ll> enum_div(ll n)
{
  vector<ll> ret;
  for (ll i = 1; i * i <= n; ++i)
  {
    if (n % i == 0)
    {
      ret.push_back(i);
      if (i * i != n)
      {
        ret.push_back(n / i);
      }
    }
  }
  sort(begin(ret), end(ret));
  return ret;
}

//累乗(xのn乗%mod)
ll modpow(ll x, ll n, ll mod = MAX)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

//階乗
ll factorial(ll n)
{
  if (n > 0)
    return n * factorial(n - 1);
  else
    return 1;
}

ll modinv(ll a, ll mod)
{
  ll b = mod, u = 1, v = 0;
  while (b)
  {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= mod;
  if (u < 0)
    u += mod;
  return u;
}

void Main()
{
  ll x; cin >> x;
  ll ans = x / 11 * 2;
  x %= 11;
  if(x == 0) fin(ans);
  else if(x <= 6) fin(ans + 1);
  else fin(ans + 2);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 998244353;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,s;
    cin >> n >> s;
    int ary[n];
    rep(i,n) cin >> ary[i];

    // dp[i][j]:=i番目まででsumがｊとなルトお理数
    // dp[i][j] = dp[i-1][j] * 2 + dp[i-1][j-ary[i]];
    ll dp[n][s+1];
    rep(i,n) rep(j,s+1) dp[i][j] = 0; 
    dp[0][0] = 2;
    dp[0][ary[0]] = 1;
    REP(i,1,n) rep(j,s+1)
    {
      dp[i][j] = dp[i-1][j] * 2;
      if (j-ary[i]>=0)
      {
        dp[i][j] += dp[i-1][j-ary[i]];
      }
      dp[i][j] %= MOD;
    }
    // rep(i,n) cout << dp[i][s] << " ";
    // cout << endl;
    cout << dp[n-1][s] << endl;

}


Measured memory_bytes: 73956
package main

import (
  "bufio"
  "fmt"
  "os"
  "strings"
   "strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  if sc.Scan() {
  }
  if sc.Scan() {
    s := strings.Split(sc.Text(), " ")
    cnt := 0
    for i := 1; i < len(s) - 1; i++ {
      a, _ := strconv.Atoi(s[i-1])
      b, _ := strconv.Atoi(s[i])
      c, _ := strconv.Atoi(s[i+1])
      if a < b && b < c {
        cnt++
      }
      if c < b && b < a {
        cnt++
      }
    }
    fmt.Println(cnt)
  }
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int minv = Integer.MAX_VALUE;
		int maxv = Integer.MIN_VALUE;
		for (int i = 0; i < n; i++) {
			int j = Integer.parseInt(reader.readLine());
			if (maxv < j - minv)
				maxv = j - minv;
			if (j < minv)
				minv = j;
		}
		System.out.println(maxv);
	}
}

Measured memory_bytes: 37588
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, A[200005];

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

  cin >> N;
  rep(i, N) cin >> A[i];
  int base = INF;
  int cnt = 0;
  rep(i, N) {
    if (base > A[i]) {
      base = A[i];
      cnt++;
    }
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 1024
loop do
  t,h,s=gets.split.map(&:to_i)
  break if t==-1
  mi=7200-t*3600-h*60-s
  printf("%02d:%02d:%02d\n",mi/3600,(mi%3600)/60,mi%60)
  printf("%02d:%02d:%02d\n",3*mi/3600,3*mi%3600/60,3*mi%60)
end

Measured memory_bytes: 8564
// author -> LetsGoAC
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using    namespace std;
using    namespace __gnu_pbds; 
#define  ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) cout<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  gi  greater<int> 
#define  gpi greater<pii>  
#define  sp(n) fixed<<setprecision(n)
vector   <int> Fact(100005 , 0);
const int mod = (int)(1e9+7);
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int mod_inverse(int n , int m)
{   //mod = m; // change const mod;
    int modi = power(n , m-2);
    return modi;
}
int  pct(int x)
{    return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void cal_fac()
{
     Fact[0] = Fact[1] = 1;
     for(int i=2; i<1e5; i++)
         Fact[i] = (Fact[i-1]*i)%mod;
}
int C(int n , int k)
{
    int res = Fact[n];
    res = (res * mod_inverse( Fact[k] , mod ))%mod;
    res = (res * mod_inverse( Fact[n-k] ,mod ))%mod;
    return res;
}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " <<sp(5)<< 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ---------------------- new.cpp --------------------------------- */
const int maxn = 1e4+5; 
void solve(int tc)
{
    //  cout<<"Case #"<<tc<<": ";
    int n,i,j,k,m,q,l,r;
    cin>>n;
    int ar[n];
    rep(i,n)
        cin>>ar[i];
    int ans= 0;
    rep(i,n-2)
    {
        repv(j,i+1 , n-2)
        {
            repv(k,j+1,n-1)
            {
                int sum = ar[i]+ar[j]+ar[k] , mx = max({ar[i],ar[j],ar[k]});
                if(ar[i]!=ar[j] && ar[j]!=ar[k] && ar[i]!=ar[k] &&  (mx < sum-mx ))
                    ans++;
            }
        }
    }
    cout<<ans;
}
signed main()
{
    // new.cpp
    RAGE;
  //  db();  
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
  //  timeit();
    return 0;
}
/*
    1. To find 2's complement , reverse all the bits after 1st set bit. (right - >left.)

*/

Measured memory_bytes: 3844