akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int H, N;
    cin >> H >> N;
    vector<int> A(N), B(N), dp(H+1,INF);
    REP (i, N) {
        cin >> A[i] >> B[i];
    }
    dp[0] = 0;
    REP(i,N) REP(j,H+1) {
        dp[min(j+A[i], H)] = min(dp[min(j+A[i],H)],dp[j]+B[i]);
    }
    cout << dp[H] << endl;
    

    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc153/abc153_e && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc153/abc153_e && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc153/abc153_e && sh shellscripts/submit_cpp.sh
*/


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

int main() {
    int n;
    cin >> n;
    long long sum = 0;

    vector<long long> a(n);
    vector<long long> dp(n);

    for(long long &el : a) {
        cin >> el;
        sum += el;
    }

    dp[0] = 0;
    dp[1] = abs(a[1]-a[0]);

    for(int i = 2; i < n; i++)
        dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
    
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn=4010;
int n,sum[4][maxn];
char s[maxn],to[4];
long long ans=0;
int main()
{
	scanf("%d%s",&n,s+1);
	if (n<3) {printf("0\n"); return 0;}
	to[0]='R'; to[1]='G'; to[2]='B';
	for (int i=1;i<=n;i++)
	{
		sum[0][i]=sum[0][i-1]+(s[i]=='R');
		sum[1][i]=sum[1][i-1]+(s[i]=='G');
		sum[2][i]=sum[2][i-1]+(s[i]=='B');
	}
	for (int i=1;i<=n;i++)
	 for (int j=i+2;j<=n;j++)
	 if (s[i]!=s[j])
	 {
	 	for (int k=0;k<=2;k++) if (to[k]!=s[i] && to[k]!=s[j]) ans+=sum[k][j]-sum[k][i];
	 }
	for (int i=1;i<=n;i++)
	 for (int j=i+2;j<=n;j++)
	 if ((i+j)%2==0 && s[i]!=s[j] && s[i]!=s[(i+j)/2] && s[(i+j)/2]!=s[j]) ans--;
	printf("%lld\n",ans);
return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long  i = x; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    long long  N, H, count = 0;
    cin >> N >> H;
    vector<long long > a(N), b(N), b1(N);
    vector<pair<long long , long long> > ab(N), ab1(N);
    rep(i, 0, N)
    {
        cin >> a[i] >> b[i];
        b1[i] = b[i];
        ab[i] = make_pair(a[i], b[i]);
    }
    sort(ab.begin(), ab.end());
    reverse(ab.begin(), ab.end());
    sort(b1.begin(), b1.end());
    reverse(b1.begin(), b1.end());
    rep(i, 0, N)
    {
        if (ab[0].first < b1[i])
        {
            H -= b1[i];
            count++;

            if (H <= 0)
            {
                cout << count << endl;
                return 0;
            }
        }
        else
        {
            break;
        }
    }
    if (H % ab[0].first == 0)
    {
        count += H / ab[0].first;
    }
    else if (H < ab[0].first)
    {
        count += 1;
    }
    else
    {
        count += H / ab[0].first + 1;
    }
    cout << count << endl;
}

Measured memory_bytes: 5760
n, m = map(int,input().split())

road=[]
for i in range(n):
  road.append([])

for i in range(m):
  a, b = map(int,input().split())
  road[a-1].append(b)
  road[b-1].append(a)
  
for i in range(n):
  print(len(road[i]))


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

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    vector<tuple<int, int, int, int>> abcd(q);
    for(int i = 0; i < q; ++i) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--;
        abcd[i] = make_tuple(a, b, c, d);
    }
    vector<int> A;
    auto f = [&](auto &&f, int lst) -> int {
        if(A.size() == n) {
            int res = 0;
            for(auto &[a, b, c, d] : abcd) {
                if(A[b] - A[a] == c) res += d;
            }
            return res;
        }
        int res = 0;
        for(int i = lst; i <= m; ++i) {
            A.push_back(i);
            res = max(res, f(f, i));
            A.pop_back();
        }
        return res;
    };
    cout << f(f, 1) << '\n';
    return 0;
}


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

int main(){

  string w;
  int cnt=0;
  cin >> w;

  for(int i=0; i<w.size(); i++){
    for(int j=0; j<w.size(); j++){
      if(w[i]==w[j]){
        cnt++;
      }
    }
    if(cnt%2!=0){
      cout << "No" << endl;
      break;
    }
  }

  if(cnt%2==0){
    cout << "Yes" << endl;
  }

  return 0;
}

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

using namespace std;

#define BUF_SIZE 1024

struct Node{
	int data;
	Node* prev;
	Node* next;
};

class ConnectedList{
public:
	ConnectedList(){
		motherNode = new Node();
		motherNode->data = -1;
		motherNode->prev = motherNode;	//?????°?§?????????????
		motherNode->next = motherNode;
	};
	~ConnectedList(){
		Node* tmpNode = motherNode->next;
		Node* nextNode;
		while(tmpNode != motherNode){
			nextNode = tmpNode->next;
			delete tmpNode;
			tmpNode = nextNode;
		}
		delete motherNode;
	};
	void insertNode(int x){
		Node* tmpNode = motherNode->next;
		motherNode->next = new Node();
		motherNode->next->data = x;
		motherNode->next->next = tmpNode;
		motherNode->next->prev = motherNode;
		tmpNode->prev = motherNode->next;
	};
	void deleteNode(int x){
		Node* tmpNode = motherNode->next;
		while(tmpNode != motherNode && tmpNode->data != x){
			tmpNode = tmpNode->next;
		}
		if(tmpNode != motherNode){	//x????????????????????????????????£?????´???
			tmpNode->prev->next = tmpNode->next;
			tmpNode->next->prev = tmpNode->prev;
			delete tmpNode;
		}
	};

	void deleteFirst(){
		//printf("delete first is called\n");
		Node* tmpNode = motherNode->next;
		motherNode->next = motherNode->next->next;
		motherNode->next->prev = motherNode;
		delete tmpNode;	//?????????tmpNode != motherNode????????§??????????????\
	};

	void deleteLast(){
		//printf("delete last is called\n");
		Node* tmpNode = motherNode->prev;
		motherNode->prev = motherNode->prev->prev;
		motherNode->prev->next = motherNode;
		delete tmpNode; //?????????tmpNode != motherNode????????§??????????????\
	};

	void showList(){
		Node* tmpNode = motherNode->next;
		printf("%d",tmpNode->data);
		tmpNode = tmpNode->next;
		while(tmpNode != motherNode){
			printf(" %d",tmpNode->data);
			tmpNode = tmpNode->next;
		}
		printf("\n");
	}

private:
	Node* motherNode;
};


int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));

	ConnectedList list;

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

		fgets(buf,BUF_SIZE,stdin);

		if(buf[6] == 'F'){
			list.deleteFirst();
		}else if(buf[6] == 'L'){
			list.deleteLast();
		}else{
			int S = 0;
			//??????????¢??????????????????????
			if(buf[0] == 'i'){	//insert x

				for(int i = 0; buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.insertNode(S);
			}else{	//delete x
				for(int i = 0;buf[i] != '\0';i++){
					if(buf[i] >= '0' && buf[i] <= '9'){
						S = 10*S + (buf[i] - '0');
					}
				}
				list.deleteNode(S);
			}

		}

	}

	list.showList();

}

Measured memory_bytes: 32404
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>


int main()
{
double N,P=0;
double x,y;
double p=0,P1=0;
x=0;y=0;
while(1)
{
scanf("%lf,%lf",&N,&P1);
if((int)N==0&&(int)P1==0)break;

x+=N*sin(P*M_PI/180);y+=N*cos(P*M_PI/180);

P+=P1;
}
int X,Y;
X=(int)x;Y=(int)y;
printf("%d\n",X);printf("%d\n",Y);

return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 998244353;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 100 + 10;
const int maxm = 5000;

int d[maxn], c[maxn];

struct node
{
  int v;
  ll a,b;
};

vector<node>graph[maxn];

struct state
{
  int no;
  ll t, qts;
  state(){}
  state(int no, ll t, ll qts): no(no), t(t), qts(qts){}

  bool operator < (const state &s) const
  {
    return t < s.t;
  }
};

ll dist[maxn][maxm + 10];
bool vis[maxn][maxm];

int main()
{
  MSET(dist, INF);
  int n,m,s;
  cin >> n >> m >> s;
  for(int i = 1 ; i <= m; i++)
  {
    int u,v,a,b;
    cin >> u >> v >> a >> b;
    graph[u].push_back({v,a,b});
    graph[v].push_back({u,a,b});
  }

  for(int i = 1; i <= n ; i++)
  {
    cin >> c[i] >> d[i];
  }
  s = min(s, maxm);
  multiset<state>q;
  q.insert(state(1,0,s));
  dist[1][s] = 0;
  while(q.size())
  {
    auto at = *q.begin();
    q.erase(q.begin());
    if(at.t != dist[at.no][at.qts])
      continue;
    int u = at.no;
    ll t = at.t;
    ll qts = at.qts;
    for(const auto &e: graph[u])
    {
      ll a = e.a;
      ll b = e.b;
      int v = e.v;
      if(qts >= a && dist[v][qts - a] > t + b)
      {
        dist[v][qts - a] = t + b;
        q.insert(state(v, t + b, qts - a));
      }
    }
    if(t + d[u] < dist[u][min(ll(maxm), qts + c[u])])
    {
      dist[u][min(ll(maxm), qts + c[u])] = t + d[u];
      q.insert(state(u, t + d[u], min(ll(maxm), qts + c[u])));
    }
  }

  for(int i = 2; i <= n ; i++)
  {
    cout << *min_element(dist[i], dist[i]+ maxm + 2) << endl;
  }


  return 0;
} 

Measured memory_bytes: 16804
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

constexpr lli inf = 10000 * 10000;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	string s;
	cin >> s;

	if (s[0] == s[1] && s[1] == s[2]) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}



	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())


def base(value, n):  # 10 => 2
    result = ''
    tmp = int(value)
    while tmp >= n:
        result = str(tmp % n) + result
        tmp = int(tmp / n)
    result = str(tmp % n) + result
    return result


print(len(str(base(N, K))))

Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		//MCXI
		int[] ten = new int['z'];
		ten['m'] = 1000;
		ten['c'] = 100;
		ten['x'] = 10;
		ten['i'] = 1;
		
		for (int T = sc.nextInt() - 1; 0 <= T; T--) {
			char[] a = sc.next().toCharArray();
			char[] b = sc.next().toCharArray();
			
			int ka = 0, kb = 0;
			for (int i = 0; i < a.length; i++) {
				int k = 1;
				if ('0' <= a[i] && a[i] <= '9') k = a[i++] - '0';
				ka += k * ten[a[i]];
			}
			for (int i = 0; i < b.length; i++) {
				int k = 1;
				if ('0' <= b[i] && b[i] <= '9') k = b[i++] - '0';
				kb += k * ten[b[i]];
			}
			
			int k = ka + kb;
			String s = "";
			if (k / 1000 > 0) {
				s += k / 1000 > 1 ? "" + k / 1000 : "";
				s += "m";
			}
			k %= 1000;
			if (k / 100 > 0) {
				s += k / 100 > 1 ? "" + k / 100 : "";
				s += "c";
			}
			k %= 100;
			if (k / 10 > 0) {
				s += k / 10 > 1 ? "" + k / 10 : "";
				s += "x";
			}
			k %= 10;
			if (k / 1 > 0) {
				s += k / 1 > 1 ? "" + k / 1 : "";
				s += "i";
			}
			
			System.out.println(s);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main(){
    ll n,w;
    cin>>n>>w;
    vector<vector<ll>> vect(n,vector<ll>(2,0ll));
    for(int i=0 ; i<n ; i++){
        cin>>vect[i][0]>>vect[i][1];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(w+1,0ll));
    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=w ; j++){
            if(vect[i-1][0]>j){
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }else{
                dp[i][j]=max(vect[i-1][1]+dp[i-1][j-vect[i-1][0]],max(dp[i-1][j],dp[i][j-1]));
            }
            
        }
        
    }
    
    cout<<dp[n][w]<<endl;
    return 0;
}

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

int gcd(int a, int b) {
	if (a < b) swap(a, b);

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

int main() {
	int N, K;
	cin >> N >> K;
	int A[N];
	int maxv=0;
	for (int i = 0; i < N; i++){ 
    	cin >> A[i];
    	maxv=max(maxv,A[i]);
	}

	int g = A[0];
	for (int i = 1; i < N; i++) {
		g = gcd(g, A[i]);
	}

	if (K%g == 0 && K<=maxv )cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define Aint(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
const int MOD = 1e9+7;
const int INF = 1e9;
const int MAXN = 1050000;

ll N,T,a,b,c,d,e,f;
ll A[MAXN];

string S;
int main(){
  cin>>T>>N;
  for (int i=1;i<=N;++i){
    cin>>A[i];
  }
  for (int i=1;i<N;++i){
    a = max(a, A[i+1]-A[i]);
  }
  a = max(A[1] + T - A[N], a);
  cout<<T-a;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

//0-index 半開区間セグツリー(値の更新or加算 , 最小値or最大値or和) verified AOJ DSL_2_A
template<typename T, typename E>
class segment_tree{
    typedef function<T(T,T)> F;
    typedef function<T(T,E)> G;
private:
    int num_of_elm_;
    vector<T> dat_;
    F f_;
    G g_;
    T ident_;
public:
    segment_tree(int n, F f, G g, T ident):f_(f), g_(g), ident_(ident){
        num_of_elm_ = 1;
        while(num_of_elm_<n)num_of_elm_*=2;
        dat_.resize(2*num_of_elm_,ident);
    }

    void update(int pos,T val){
        int p = num_of_elm_ + pos;
        dat_[p] = g_(dat_[p],val);
        while(p!=1){
            p/=2;
            dat_[p] = f_(dat_[p*2], dat_[p*2+1]);
        }
    }

    T query(int L, int R,int l=0,int r=0, int k=1){
        if(k==1)r = num_of_elm_;
        if(r<=L || R<=l)return ident_;
        else if(L<=l && r<=R){
            return dat_[k];
        }
        else{
            return f_(query(L,R,l,(l+r)/2,k*2), query(L,R,(l+r)/2,r,k*2+1));
        }
    }
};


int main(){
    int n,q;
    cin>>n>>q;
    auto  f = [](int a, int b){ return min(a,b); };
    auto  g = [](int a, int b){ return b; };
    segment_tree<int,int> st(n,f,g,(1LL<<31)-1);

    rep(i,q){
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0){
            st.update(x,y);
        }else{
            cout<<st.query(x,y+1)<<endl;
        }

    }
}





Measured memory_bytes: 3884
package main

import "fmt"

type Node struct {
    na, nb int
}

func addNeighbor(c byte, v *Node) {
    if c == 'A' {
        v.na++
    } else {
        v.nb++
    }
}

func removeNeighbor(c byte, v*Node) int {
    if c == 'A' {
        v.na--
        return v.na
    }
    v.nb--
    return v.nb
}

func main() {
    var n, m int
    var s string
    fmt.Scan(&n, &m, &s)
    vs := make([][]int, n)
    counts := make([]Node, n)
    for i := 0; i < m; i++ {
        var a, b int
        fmt.Scan(&a, &b)
        a--
        b--
        vs[a] = append(vs[a], b)
        vs[b] = append(vs[b], a)
        addNeighbor(s[a], &counts[b])
        addNeighbor(s[b], &counts[a])
    }

    var used []bool = make([]bool, n)

    var del []int
    var n_del int = 0
    for i, c := range counts {
        if c.na == 0 || c.nb == 0 {
            used[i] = true
            del = append(del, i)
            n_del++
        }
    }
    for i := 0; i < n_del; i++ {
        var del_i int = del[i]
        for _, x := range vs[del_i] {
            if used[x] == false && removeNeighbor(s[del_i], &counts[x]) == 0 {
                used[x] = true
                del = append(del, x)
                n_del++
            }
        }
    }
    if n_del == n {
        fmt.Println("No")
    } else {
        fmt.Println("Yes")
    }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

int main() {
    int N,K; cin >> N >> K;
    vector<int> A(N);
    REP(i,N) cin >> A[i];

    int ans = 0;
    N -= K;
    ans++;

    if(N!=0) ans += (N-1)/(K-1) + 1;

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

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

using namespace std;
deque<int> q;
int v[200005],n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>v[i];
    }
    if(n%2)
    {
        q.push_back(v[1]);
        for(int i=2;i<=n;i+=2)
        {
            q.push_back(v[i]);
            q.push_front(v[i+1]);
        }

    }
        else
    {
        for(int i=1;i<=n;i+=2)
        {
            q.push_back(v[i]);
            q.push_front(v[i+1]);
        }
    }
    while(!q.empty())
    {
        printf("%d ",q.front());
        q.pop_front();
    }
    return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int k;cin>>k;vector<int> v(k);
  for(int i=0;i<k;i++) cin>>v[i];
  vector<int> vv=v;
  sort(vv.begin(),vv.end());
  int t=0;
  for(int i=0;i<k;i++) if(v[i]!=vv[i]) t++;
  if(t==2||t==0) cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
ll N;
ll M;
string s;
vector<ll > input1;  
vector<vector <ll > > input2;

int main(){
    
    //cin >> N;
    int a,b,c,d,e,k;
    cin >> a >> b;
    /*
    vector<ll > aa(5);
    for(int i = 0; i < 5; i++){
        cin >> aa[i];
    } 
    */
   if(a < b){
       cout << "0" << endl;
   }if(a >= b){
       cout << "10" << endl;
   }


} 

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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vec<vec<char>> C(H, vec<char>(W));
  REP(y, H) REP(x, W) cin >> C[y][x];

  REP(i, 2 * H) {
    REP(j, W) cout << C[i / 2][j];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3668
#include <iostream>
using namespace std;
typedef long long ll;
const ll R = 1e9 + 7;

int main() {
    int n, m; cin >> n >> m;
    int t = abs(n - m);
    ll ans;
    if (t >= 2) ans = 0;
    else {
        ll a = n, b = m;
        for (ll i = 2; i < n; i++) {
            a *= i;
            a %= R;
        }
        for (ll i = 2; i < m; i++) {
            b *= i;
            b %= R;
        }
        if (t == 1) ans = a * b % R;
        else ans = 2 * a * b % R;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
p = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(p[int(input())-1])


Measured memory_bytes: 2940
dp = [[0 for _ in range(10**5+10)] for _ in range(10**2+10)]

N, W = map(int,input().split())
w = []
v = []

for i in range(N):
    wi,vi = map(int,input().split())

    w.append(wi)
    v.append(vi)

for i in range(N):
    for capacity in range(W+1):
        if w[i] > capacity:
            dp[i+1][capacity] = dp[i][capacity]
        else:
            dp[i+1][capacity] = max(dp[i][capacity], dp[i][capacity-w[i]] + v[i])

print(dp[N][W])

Measured memory_bytes: 181896
#include<stdio.h>

int main(){
	int n,t,a,i,h[1000],ans=0;
	float kion[1000];
	scanf("%d%d%d",&n,&t,&a);
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
		kion[i]=t-h[i]*0.006f;
		float b=(a-kion[ans]);
		float c=a-kion[i];
		if(b<0)b=-b;
		if(c<0)c=-c;
		if(b>c){
			ans=i;
		}
	}
	printf("%d\n",ans+1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N, K;
  cin >> N >> K;
  ll h[N];
  REP(i, N) { cin >> h[i]; }
  sort(h, h + N);

  ll ans = INF;

  REP(i, N - K + 1) { ans = min(ans, h[i + K - 1] - h[i]); }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int x;
	cin >> x;
	
	if(x >= 30)cout << "Yes";
	else cout << "No";
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
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;
bool fl;
struct edge{int to,cost;};
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n){
        rep(j,n){
            if(i==j)continue;
            ans+=a[i]*a[j];
        }
    }
    Cout(ans/2);
    return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cout << x << " ";} cout << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    int N;
    cin >> N;
    vector<string> s(2);
    bool toRight = true;
    while (true) {
        rep(state, 4) {
            if (toRight) {
                cout << s[0] + (state % 2 ? '.' : '#') << endl;
                cout << s[1] + (state / 2 ? '.' : '#') << endl;
            } else {
                cout << (state % 2 ? '.' : '#') + s[0] << endl;
                cout << (state / 2 ? '.' : '#') + s[1] << endl;
            }
            string ret;
            cin >> ret;
            if (ret[0] == 'e') {
                return 0;
            } else if (ret[0] == 'T') {
                // next_step
                if (toRight) {
                    s[0] = s[0] + (state % 2 ? '.' : '#');
                    s[1] = s[1] + (state / 2 ? '.' : '#');
                } else {
                    s[0] = (state % 2 ? '.' : '#') + s[0];
                    s[1] = (state / 2 ? '.' : '#') + s[1];
                }
                break;
            } else {
                // go_on_this_step

                if (state == 3) {
                    // change_direction
                    assert(toRight);
                    toRight = false;
                }
            }
        }
    }

}


Measured memory_bytes: 724
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
bool check(string s){
    int n=s.length();
    for(int i=0;i<n/2;i++)if(s[i]!=s[n-i-1])return 0;
    return 1;
}

int main(){
   string s;cin>>s;
   int l=s.length();
   string s1=s.substr(0,(l-1)/2),s2=s.substr(l-(l-1)/2,(l-1)/2);

   if(check(s)&&check(s1)&&check(s2))cout<<"Yes";
   else cout<<"No";
   
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000 //カード枚数の上限
#define SENTINEL 2000000000 //カードに書かれている数の上限

/*構造体Cardの宣言
suit : カードの絵柄(S,H,C,Dのいずれか)
value : カードの数字()*/
struct Card{
	char suit;
	int value;
};

/* 構造体Cardを要素数MAX/2+2個作成したものを左Lと右Rの２つ用意する*/
struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

/*リストの統合を行う関数(ALDS1_5_B)
left : 部分配列の先頭の要素のインデックス
right : 部分配列の末尾+1の要素のインデックス
mid : left+right/2
*/
void merge(struct Card A[], int n, int left, int mid, int right){
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	for( i = 0; i < n1; i++ ) L[i] = A[left + i];
	for( i = 0; i < n2; i++ ) R[i] = A[mid + i];
	L[n1].value = R[n2].value = SENTINEL;
	i = j = 0;
	for(k = left; k < right; k++){
		if(L[i].value <= R[j].value){
			A[k] = L[i++];
		}else{
			A[k] = R[j++];
		}
	}
}

/*リストの分割を行う関数(ALDS1_5_B)
リストを２分割していき最終的にリストの要素が１つになったら, mergeによって順に統合を行っていく*/
void mergeSort(struct Card A[], int n, int left, int right){
	int mid;
	if(left + 1 < right){
		mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

/*パーティション関数(ALDS1_6_B)
配列Aのr番目(最後)の要素xを配列の基準とし, xより大きい要素はpからi番目までの範囲,xより小さい要素はi+1からj番目までの範囲に移動させる*/
int partition(struct Card A[], int n, int p, int r){
	int i,j;
	struct Card t, x;
	x = A[r];
	i = p - 1;
	for(j = p; j < r; j++){
		if(A[j].value <= x.value){
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
	return i + 1;
}

/*クイックソート関数
パーティション関数を使う範囲を狭めていき精度を高くしてリストをソートする*/
void quickSort(struct Card A[], int n, int p, int r){
	int q;
	if(p < r){
		q  = partition(A, n, p, r);
		quickSort(A, n, p, q - 1);
		quickSort(A, n, q + 1, r);
	}
}

int main(){
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A, n, 0, n);
	quickSort(B, n, 0, n - 1);
	
	for(i = 0; i < n; i++){
		if(A[i].suit != B[i].suit) stable = 0;
	}
	
	if(stable == 1)printf("Stable\n");
	else printf("Not stable\n");
	for(i =  0; i < n; i++){
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	
	return 0;
}


Measured memory_bytes: 4044
import sys
input = sys.stdin.readline
N = int(input())
XYI = [tuple(map(int,input().split() + [i])) for i in range(N)]
XYI.sort()

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self._size = [1] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self._size[ra] < self._size[rb]: ra,rb = rb,ra
        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        self.count += 1
    def size(self,a):
        return self._size[self.root(a)]

import heapq
hq = []
uf = UnionFind(N)
for x,y,i in XYI:
    miny = mini = None
    while hq and hq[0][0] < y:
        ty,ti = heapq.heappop(hq)
        if miny is None:
            miny, mini = ty, ti
        uf.unite(i,ti)
    if miny is None:
        heapq.heappush(hq, (y,i))
    else:
        heapq.heappush(hq, (miny,mini))

ans = []
for i in range(N):
    ans.append(uf.size(i))
print(*ans, sep='\n')

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

typedef long long ll;

int N;
ll a[(int)2e5];

int main() {
    // ll tes[] = {(ll)1e9, (ll)1e9, (ll)1e9, (ll)1e9};
    // cout << accumulate(tes, tes + 4, 0LL) << endl;
    // return 0;
    ll ans = 1e18;
    cin >> N;
    rep(i, N) {
        cin >> a[i];
    }

    ll sum = accumulate(a, a + N, 0LL);
    ll x = 0;
    for (int i = 0; i <= N - 2; i++) {
        x += a[i];
        ll y = sum - x;
        // printf("x: %lld y: %lld abs: %lld\n", x, y, abs(x - y));
        ans = min(ans, abs(x - y));
        // ans = min(ans, abs(sum - 2 * x));
    }

    cout << ans << endl;
}


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

namespace AtCoder
{

    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var A = vals[0];
            var B = vals[1];
            var C = vals[2];

            var result = Math.Min(B / A, C);
            Console.WriteLine(result);
        }

    }
}
//A

Measured memory_bytes: 11220
def examA():
    S = SI(); N = len(S)
    T = "CODEFESTIVAL2016"
    ans = 0
    for i in range(N):
        if S[i]!=T[i]:
            ans +=1
    print(ans)
    return

def examB():
    N, A, B = LI()
    S = SI()
    d = defaultdict(int)
    for s in S:
        if s=="a":
            if d["a"]+d["b"]<A+B:
                print("Yes")
                d[s] += 1
            else:
                print("No")
        elif s=="b":
            if d["a"]+d["b"]<A+B and d["b"]<B:
                print("Yes")
                d[s] += 1
            else:
                print("No")
        else:
            print("No")
    return

def examC():
    W, H = LI()
    P = [I() for _ in range(W)]; P.sort()
    Q = [I() for _ in range(H)]; Q.sort()
    dh = 0; dw = 0
    p = 0; q = 0
    ans = 0
    for i in range(H+W):
        if (q<H and p<W and P[p]<Q[q]) or not q<H:
            ans += P[p]*(H+1-dh)
            p +=1; dw +=1
        else:
            ans += Q[q]*(W+1-dw)
            q +=1; dh+=1
    print(ans)
    return

def examD():
    N = I()
    A = [I() for _ in range(N)]
    flag = 1
    ans = A[0]-1
    A[0] = 1
    for i in range(1,N):
        a = A[i]
        if a==flag+1:
            flag +=1
        ans += (a-1)//(1+flag)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,ALPHABET, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 1e-9
alphabet = [chr(ord('a') + i) for i in range(26)]
ALPHABET = [chr(ord('A') + i) for i in range(26)]

if __name__ == '__main__':
    examD()


Measured memory_bytes: 7644
//ΔARC087D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int N = 8080;
char ch[N];
int n,x,y;
vector<int> v[2];
int dp[N][N<<1];
int main()
{
	int i,j,k,h,ans;
	scanf("%s%d%d",ch,&x,&y);
	n=strlen(ch);
	i=0;
	while(ch[i]=='F'){
		x--;
		i++;
	}
	if(x<-N+5){
		cout<<"No\n";
		return 0;
	}
	j=0;
	k=0;
	for(;i<=n;i=i+1){
		if(i!=n&&ch[i]=='F')
			k++;
		else{
			if(k)
				v[j].push_back(k);
			j^=1;
			k=0;
		}
	}
	ans=1;
	memset(dp,0,sizeof(dp));
	dp[0][N]=1;
	h=v[0].size();
	for(i=0;i<h;i=i+1){
		k=v[0][i];
		for(j=5;j<N+N-5;j=j+1)
			if(dp[i][j])
				dp[i+1][j+k]=1,dp[i+1][j-k]=1;
	}
	ans&=dp[h][x+N];
	memset(dp,0,sizeof(dp));
	dp[0][N]=1;
	h=v[1].size();
	for(i=0;i<h;i=i+1){
		k=v[1][i];
		for(j=5;j<N+N-5;j=j+1)
			if(dp[i][j])
				dp[i+1][j+k]=1,dp[i+1][j-k]=1;
	}
	ans&=dp[h][y+N];
	if(ans)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

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

int main() {
    int a, b;
    string str;
    cin >> a >> b >> str;
    bool flag = true;
    rep(i, a) if(!isdigit(str.at(i))) flag = false;
    if(str.at(a) != '-') flag = false;
    rep(i, b) if(!isdigit(str.at(i + a + 1))) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n=int(input())
a=[0 for _ in range(n)]
for i in range(n):
  a[i]=int(input())
a.sort()
ans,cnt=0,0
p=-1
for x in a:
  if p==x:
    cnt+=1
  else:
    p=x
    if cnt%2==1:
      ans+=1
    cnt=1
if cnt%2==1:
  ans+=1
print(ans)

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k; cin >> n >> k;
  double ans = 0;
  for(int i=1; i<=n; i++) {
    int tmp = i;
    double now = 1.0;
    while(tmp < k) {
      tmp*=2;
      now /= 2.0;
    }
    ans += now;
  }
  cout << setprecision(12) << ans/n << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --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 ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

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

  int T, X;
  cin >> T >> X;
  cout << (double)T / X << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	printf("%d\n", (a - 1) * (b - 1));
	return 0;
}


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

int N; string S;

char memo[1 << 10][10];

bool solve() {
    for (int i = 0; i < (1 << 10); ++i)
        fill(memo[i], memo[i]+10, 0);

    {
        int st = 0;
        for (char ch : S) {
            if (ch == 'u')
                st = 0;
            else {
                int v = ch - '0';
                memo[st][v] = 1;
                st |= 1 << v;
            }
        }
    }

    // j & k == 0
    // -> P(j, s)
    // -> P(k, t)
    // -> s <- k
    // -> P(j | k, t)

    for (int i = 1; i < (1 << 10); ++i) {
        for (int j = 1; j < i; ++j) {
            if ((i | j) != i) continue;

            for (int x = 0; x < 10; ++x) {
                for (int y = 0; y < 10; ++y) {
                    if (memo[j][x] && memo[i^j][y] && ((i^j) >> x)%2)
                        memo[i][y] = 1;
                }
            }
        }
    }

    for (int i = 1; i < (1 << 10); ++i) {
        for (int d = 0; d < 10; ++d) {
            if (memo[i][d] && (i >> d)%2) return false;
        }
    }

    return true;
}

int main(void) {
    while (true) {
        cin >> N; if (N == 0) break;
        cin >> S;
        cout << (solve() ? "SAFE" : "UNSAFE") << endl;
    }
    return 0;
}



Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc =new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		String S=sc.next();
		S.toCharArray();
		String h="-";
		int cnt=0;
		for(int i=0;i<S.length();i++) {
			char c = S.charAt(i);
			if(h.equals(String.valueOf(c))) {
				cnt++;
			}
		}
		if(S.indexOf("-")+1==A+1 && S.length()==A+B+1 && cnt==1) {
			System.out.println("Yes");
		}else System.out.println("No");
	}
}


Measured memory_bytes: 21844
N, K = map(int, input().split())

cnt = 0
for b in range(K+1,N+1):
    x = (b-K)*(N//b) + max(0,(N%b)-K+1)
    # print(b,"num",x)
    cnt+= x

if K == 0:
    print(N**2)
else:
    print(cnt)

Measured memory_bytes: 3060
class BIT
    def initialize(n)
        @n = n
        @dat = Array.new(@n, 0)
    end

    def sum(i)
        s = 0
        while i >= 0 do
            s += @dat[i]
            i = (i & (i+1)) - 1
        end
        s
    end

    def sum_between(a, b)
        sum(b) - sum(a-1)
    end

    def add(i, x)
        while i < @n do
            @dat[i] += x
            i |= i+1
        end
    end

    def lower_bound(x)
        return -1 if x <= 0
        ret = -1
        k = 1
        k <<= 1 while 2*k <= @n
        while k > 0
            if ret+k < @n && @dat[ret+k] < x
                x -= @dat[ret+k]
                ret += k
            end
            k >>= 1
        end
        ret + 1
    end
end

N = gets.to_i
P = gets.split.map(&:to_i)
pos = []
N.times do |i|
    pos[P[i]] = i
end
bit = BIT.new(N)
ans = 0
N.downto(1) do |i|
    bit.add(pos[i], 1)
    s = bit.sum(pos[i])
    l2 = bit.lower_bound(s-2)
    l1 = bit.lower_bound(s-1)
    r1 = bit.lower_bound(s+1)
    r2 = bit.lower_bound(s+2)
    ans += i * ((l1-l2)*(r1-pos[i]) + (pos[i]-l1)*(r2-r1))
end
puts ans

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


int main(void) {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int  n ;
	cin>>n;
	string in_;
	cin>>in_;
	
	vector<int> r, g, b;
	for (int i = 0; i < n; i++) {
		if (in_[i] == 'R') {
			r.push_back(i);
		} else if (in_[i] == 'G') {
			g.push_back(i);
		} else if (in_[i] == 'B') {
			b.push_back(i);
		}
	}	
	long long int ans = 0;
	for (int i = 0; i < r.size(); i++) {
		for (int k = 0; k < b.size(); k++) {
			int i1 = r[i], j1 = b[k];
			// cout<<i1<<" "<<j1<<"\n";
			if (i1 < j1) {
				ans += upper_bound(g.begin(), g.end(), i1) - g.begin();
				ans += g.size() - (upper_bound(g.begin(), g.end(), j1) - g.begin());
				if (binary_search(g.begin(), g.end(), 2*i1 - j1)) {
					// cout<<"--\n";
					ans--;
				}
				if (binary_search(g.begin(), g.end(), 2*j1 - i1)) {
					// cout<<"--\n";
					ans--;
				}
				ans += upper_bound(g.begin(), g.end(), j1) - upper_bound(g.begin(), g.end(), i1);
				if ((i1+j1) % 2 == 0 && binary_search(g.begin(), g.end(), (i1+j1)/2)) {
					// cout<<"--\n";
					ans--;
				}

			} else {
				ans += upper_bound(g.begin(), g.end(), j1) - g.begin();
				ans += g.size() - (upper_bound(g.begin(), g.end(), i1) - g.begin());
				if (binary_search(g.begin(), g.end(), 2*j1 - i1))
					ans--;
				if (binary_search(g.begin(), g.end(), 2*i1 - j1))
					ans--;
				ans += upper_bound(g.begin(), g.end(), i1) - upper_bound(g.begin(), g.end(), j1);
				if ((i1+j1) % 2 == 0 && binary_search(g.begin(), g.end(), (i1+j1)/2)) {
					// cout<<"--\n";
					ans--;
				}
			}
		}
	}

	
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <math.h>

using namespace std;

int main() {
    int N, D;
    cin >> N >> D;
    int X[N][D];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }
    // 処理
    int cnt = 0;

    for(int i = 0; i < N-1; i++) {
        for(int j = i+1; j < N; j++) {
            double sum = 0;
            for(int k = 0; k < D; k++) {
                sum += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
            sum = sqrt(sum);
            // cout << "i: " << i << "j: " << j << "sum: " << sum << endl;
            if(ceil(sum) == floor(sum)) ++cnt;
        }
    }

    // for(int i = 0; i < N-1; i++) {
    //     double sum1 = 0;
    //     for(int j = 0; j < D; j++) {
    //         sum1 += (X[i][j] - X[i+1][j])*(X[i][j] - X[i+1][j]);
    //     }
    //     sum1 = sqrt(sum1);
    //     cout << "sum1  " << sum1 << endl;
    //     if(ceil(sum1) == floor(sum1)) ++cnt;
    // }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n; std::vector<std::pair<i64, i64>> vec;
	for(int i = 0; i < n; i++) {
		i64 a, b; cin >> a >> b;
		
		vec.push_back({a, b});
	}
	sort(begin(vec), end(vec));
	
	std::vector<i64> s(n + 1, 0);
	for(int i = 0; i < n; i++) s[i + 1] = s[i] + vec[i].second;
	
	i64 mi = (1LL << 60), ans = -(1LL << 60);
	for(int i = 0; i < n; i++) {
		mi = std::min(mi, s[i] - vec[i].first);
		i64 now = s[i + 1] - vec[i].first;
		
		ans = std::max(ans, now - mi);
	}
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 14568
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>


int main(){
  char str[1006];
  
  scanf("%s", str);
  
  int fim = strlen(str);
  
  if (str[fim-1] == 's'){
    str[fim] ='e';
    str[fim+1] = 's';
    str[fim+2] = '\0';
  }
  else {
    str[fim] = 's';
    str[fim+1] = '\0';
  }
    
  printf("%s\n", str);
  

  return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> p(n); rep(i,n) cin >> p[i];
  vector<int> q(n); rep(i,n) cin >> q[i];

  vector<int> a(n); rep(i,n) a[i] = i+1;

  int cnt = 0;
  int kp,kq;
  do{
    cnt++;    
    if(p==a) kp = cnt;
    if(q==a) kq = cnt;
  }while(next_permutation(a.begin(),a.end()));

  int ans = abs(kp-kq);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3616