Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def make_divisors(n):
    cnt = 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            cnt += 1
            if i != n // i:
                cnt += 1
        i += 1
    return cnt
numbers = [1,10, 100, 1000, 10000, 100000, 200000, 250000,300000,350000, 400000,450000, 500000,600000,675000,750000,800000,850000,900000,925000,950000,975000,1000000]
datas = [0,23,473,7053,93643,1166714, 2472071, 3145923, 3829761, 4522005,5221424,5927120,6638407,8075420,9164377,10261678,10997400,11736253,12478098,12850013,13222660,13595947,13969985]

N = int(input())
ttl = 0
numPin = 0

for i in range(len(numbers)):
    if N == 1000000:
        numPin = len(numbers) - 1
        break
    if numbers[i] <= N < numbers[i+1]:
        numPin = i
        break

if numPin != len(numbers)-1:
    if N - numbers[numPin] < numbers[numPin + 1] - N:
        for i in range(numbers[numPin], N):
            ttl += make_divisors(i)
        print(ttl + datas[numPin])
    else:
        for i in range(N,numbers[numPin+1]):
            ttl -= make_divisors(i)
        print(ttl + datas[numPin + 1])
else:
    print(datas[numPin])


### FIXED CODE ###

def make_divisors(n):
    cnt = 0
    i = 1
    while i*i <= n:
        if n % i == 0:
            cnt += 1
            if i != n // i:
                cnt += 1
        i += 1
    return cnt
numbers = [1,10, 100, 1000, 10000, 100000, 150000,200000, 250000,300000,350000, 400000,450000, 500000,550000,600000,630000,675000,700000,720000,750000,800000,825000,850000,875000,900000,912500,925000,950000,975000,987500,1000000]
datas = [0,23,473,7053,93643,1166714, 1810893, 2472071, 3145923, 3829761, 4522005,5221424,5927120,6638407,7354651,8075420,8509899,9164377,9529244,9821778,10261678,10997400,11366472,11736253,12106789,12478098,12664043,12850013,13222660,13595947,13782871,13969985]

N = int(input())
ttl = 0
numPin = 0

for i in range(len(numbers)):
    if N == 1000000:
        numPin = len(numbers) - 1
        break
    if numbers[i] <= N < numbers[i+1]:
        numPin = i
        break

if numPin != len(numbers)-1:
    if N - numbers[numPin] < numbers[numPin + 1] - N:
        for i in range(numbers[numPin], N):
            ttl += make_divisors(i)
        print(ttl + datas[numPin])
    else:
        for i in range(N,numbers[numPin+1]):
            ttl -= make_divisors(i)
        print(ttl + datas[numPin + 1])
else:
    print(datas[numPin])
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()

judge = 0
AC_list = []
for i in range(len(S)):
    if S[i] == "A":
        judge = 1
    elif S[i] =="C":
        if judge == 1:
            judge = 0
            AC_list.append(i-1)
        else:
            pass
    else:
        judge = 0
        
for i in range(Q):
    l, r = map(int,input().split())
    ans = 0
    for j in AC_list:
        if l-1 <= j <= r-2:
            ans += 1
        elif j > r-2:
            break
    print(ans)

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()

AC_list = [0]*(N+1)
for i in range(N):
    if S[i:i+2] == "AC":
        AC_list[i+1] = AC_list[i]+1
    else:
        AC_list[i+1] = AC_list[i]

for i in range(Q):
    l, r = map(int,input().split())
    print(AC_list[r-1]-AC_list[l-1])
### BUGGY CODE ###

n, k = map(int, input().split())
h = tuple(map(int, input().split()))

INF = 10**10
dp = [INF] * n
dp[0] = 0
# dp[i] = (足場iにたどり着いた時点でのコストの最小値)

for i in range(n):
    for j in range(i + 1, min(i + k + 1, n)):
        if dp[j] > dp[i] + abs(h[j] - h[i]):
            dp[j] = dp[i] + abs(h[j] - h[i])

print(dp[n - 1])


### FIXED CODE ###

n, k = map(int, input().split())
h = tuple(map(int, input().split()))

INF = float('inf')
dp = [INF] * n
dp[0] = 0
# dp[i] = (足場iにたどり着いた時点でのコストの最小値)

for i in range(n):
    for j in range(i + 1, min(i + k + 1, n)):
        dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))

print(dp[n - 1])
### BUGGY CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()

# SegmentTree
class SegmentTree:
  def __init__(self,n,p,unit,f):
    self.num=2**((n-1).bit_length())
    self.seg=[unit]*(2*self.num)
    for i in range(n):self.seg[i+self.num]=p[i]
    for i in range(self.num-1,0,-1):
      self.seg[i]=f(self.seg[i<<1],self.seg[(i<<1)+1])
    self.f=f
    self.unit=unit
  def update(self,i,x):
    i+=self.num
    self.seg[i]=x
    while i:
      i>>=1
      self.seg[i]=f(self.seg[i<<1],self.seg[(i<<1)+1])
  def query(self,l,r):
    ansl=ansr=self.unit
    l+=self.num
    r+=self.num-1
    if l==r:
      return self.seg[l]
    while l<r:
      if l&1:
        ansl=self.f(ansl,self.seg[l])
        l+=1
      if ~r&1:
        ansr=self.f(self.seg[r],ansr)
        r-=1
      l>>=1
      r>>=1
    if l==r:
      ansl=self.f(ansl,self.seg[l])
    return self.f(ansl,ansr)


n,q=map(int,input().split())
a=list(map(int,input().split()))
f=lambda x,y: max(x,y)
seg=SegmentTree(n,a,0,f)
for _ in range(q):
  t,a,b=map(int,input().split())
  if t==1:
    seg.update(a-1,b)
  if t==2:
    print(seg.query(a-1,b))
  if t==3:
    ng=a-1
    ok=n+1
    while ng+1!=ok:
      mid=(ng+ok)//2
      if seg.query(ng,mid)>=b:ok=mid
      else:ng=mid
    print(ok)

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()

n,q=map(int,input().split())
a=list(map(int,input().split()))

num = 2**(n-1).bit_length()
def segfunc(x, y): return max(x, y)
seg = [0]*(2*num-1)
for i in range(n):
  seg[i+num-1] = a[i]
for i in range(num-2, -1, -1):
  seg[i] = segfunc(seg[2*i+1], seg[2*i+2])
def update(i, x):
  i += num-1
  seg[i] = x
  while i:
    i = (i-1)//2
    seg[i] = segfunc(seg[i*2+1], seg[i*2+2])
def query(l, r):
  l += num-1
  r += num-2
  if l == r:
    return seg[l]
  s = seg[l]
  l += 1
  while r-l > 1:
    if ~l % 2:
      s = segfunc(seg[l], s)
    if r % 2:
      s = segfunc(seg[r], s)
      r -= 1
    l //= 2
    r = (r-1)//2
  if l == r:
    return segfunc(s, seg[l])
  return segfunc(s, segfunc(seg[l], seg[r]))

for _ in range(q):
  t,a,b=map(int,input().split())
  if t==1:
    update(a-1,b)
  if t==2:
    print(query(a-1,b))
  if t==3:
    ng=a-1
    ok=n+1
    while ng+1!=ok:
      mid=(ng+ok)//2
      if query(ng,mid)>=b:ok=mid
      else:ng=mid
    print(ok)
### BUGGY CODE ###

N, M = map(int, input().split())

relation = [[] for _ in range(N+1)]

for _ in range(M) :
	X, Y, Z = map(int, input().split())
	Z &= 1
	relation[X].append((Y, Z))
	relation[Y].append((X, Z))

visited = [False] * (N + 1)
p = [-1] * (N + 1)

def dfs(init) :
	queue = [init]
	p[init] = 0

	while queue :
		x_ = queue.pop(0)
		visited[x_] = True

		for y_, z_ in relation[x_] :
			if visited[y_] :
				if (z_ & 1) ^ p[x_] != p[y_] :
					return False
			else :
				p[y_] = (z_ & 1) ^ p[x_]
				queue.append(y_)

	return True

def calc() :
	# 閉路ごと実行
	res = 0
	for i in range(1, N + 1) :
		if len(relation[i]) and not visited[i] :
			res += 1
			if not dfs(i) :
				return -1

	return res + visited.count(False) - 1

print(calc())

### FIXED CODE ###

N, M = map(int,input().split())

parent = [-1] * (N + 1)

def root(x):
	while parent[x] >= 0:
		x = parent[x]
	return x

def unite(x,y):
	root_x = root(x)
	root_y = root(y)

	if root_x != root_y :
		if parent[root_x] > parent[root_y] :
			parent[root_x]=root_y
		else :
			if parent[root_x] == parent[root_y] :
				parent[root_x] -= 1
			parent[root_y] = root_x
    
	return

for _ in range(M) :
	X, Y, Z = map(int, input().split())
	unite(X, Y)
	
print(sum(i < 0 for i in parent) - 1)
### BUGGY CODE ###

N, K = map(int, input().split())
MOD = 10**9 + 7

num = []
now = N + 1
i = 1
while True:
  r = N // (i+1) + 1
  if r == now:
    break
  num.append(now - r)
  now = r
  i += 1
  
num += [1] * (N - sum(num))
n = len(num)
dp = [[0]*n for i in range(K)]
for _n in range(n):
  dp[0][_n] = num[_n]

for i in range(1, K):
  s = 0
  for _n in range(n):
    j = n - 1 - _n
    s += dp[i-1][j] % MOD
    s %= MOD
    dp[i][_n] = s * num[_n] % MOD

ans = sum(dp[-1])
print(ans % MOD)

### FIXED CODE ###

N, K = map(int, input().split())
MOD = 10**9 + 7

num = []
now = N + 1
i = 1
while True:
  r = N // (i+1) + 1
  if r == now:
    break
  num.append(now - r)
  now = r
  i += 1
  
num += [1] * (N - sum(num))
n = len(num)
dp = [[0]*n for i in range(K)]
for _n in range(n):
  dp[0][_n] = num[_n]

for i in range(1, K):
  s = 0
  for _n in range(n):
    j = n - 1 - _n
    s += dp[i-1][j] % MOD
    s %= MOD
    dp[i][_n] = s * num[_n] % MOD

ans = sum(dp[-1])
print(ans % MOD)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Dec 19 10:03:26 2017

@author: kotania
"""
N = int(input())
AList = [0]*N

for n in range(0,N):
    AList[n] = int(input())
  
PList = []

for a in AList:
    if a not in PList:
        PList.append(a)
    elif a in PList:
        PList.remove(a)

print(len(PList))

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Dec 19 10:03:26 2017

@author: kotania
"""
from collections import Counter

N = int(input())
 
AList = []
 
count = 0
        
for n in range(0,N):
    AList.append(input())
    
countDict = Counter(AList)
countDictValues = countDict.values()

count = 0

for c in countDictValues:
    if c % 2 == 1 :
        count += 1

print(count)
### BUGGY CODE ###






N,Q = map(int,input().split())
S = []
for c in str(input()):
    S.append(c)


a = []
for i in range(N-1):
    if (S[i] == "A")and(S[i+1] == "C"):
        a.append(1)
    else:
        a.append(0)
for i in range(Q):
    l, r = map(int, input().split())
    print(sum(a[l-1:r-1]))

        
    
            
        
    
    
    





### FIXED CODE ###





import numpy as np

N,Q = map(int,input().split())
S = []
for c in str(input()):
    S.append(c)

a = np.zeros(N)
   
for i in range(1,N):
    if (S[i-1] == "A")and(S[i] == "C"):
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]
        
for i in range(Q):
    l, r = map(int, input().split())
    print(int(a[r-1] - a[l-1]))
### BUGGY CODE ###

n,k = map(int,input().split())
line = list(map(int,input().split()))
num = len(set(line))
nums = {}
for i in set(line):
  numnum = line.count(i)
  nums[i] = numnum
snums = sorted(nums.values())
if num <= k:
  print(0)
else:
  require = num - k
  answer = 0
  for j in range(require):
    answer += snums[j]
  print(answer)


### FIXED CODE ###

import collections
n,k = map(int,input().split())
line = list(input().split())
c = collections.Counter(line)
answer = 0
if k > len(c):
  answer = 0
else:
  gap = len(c) - k
  sorted_c = list(sorted(c.items(),key = lambda x:x[1]))
  for i in range(gap):
    answer += int(sorted_c[i][1])
print(answer)
### BUGGY CODE ###

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
for _ in range(m):
    b, c = map(int, input().split())
    a.extend([c] * b)
a.sort()
ans = sum(a[-n:])
print(ans)

### FIXED CODE ###

import collections
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
k = collections.Counter(a)
for _ in range(m):
    b, c = map(int, input().split())
    k[c] += b
ans = 0
count = 0
for key in list(reversed(sorted(list(k.keys())))):
    ans += (min(k[key], n - count)) * key
    count += min(k[key], n - count)
    if count == n:
        break
print(ans)
### BUGGY CODE ###

N,H=map(int,input().split())
a=[0]*N
b=[0]*N
for i in range(N):
  a[i],b[i]=map(int,input().split())
#print(a)
#print(b)

b.sort(reverse=True)
#print(max(a))
#print(b)

ans=0
for i in range(N):
  if b[i]<max(a):
    break
  if H<=0:
    break
  H-=b[i]
  ans+=1
if H>0:
  ans+=-(-H//max(a))
print(ans)

### FIXED CODE ###

N,H=map(int,input().split())
a=[0]*N
b=[0]*N
for i in range(N):
  a[i],b[i]=map(int,input().split())
#print(a)
#print(b)

b.sort(reverse=True)
maxa=max(a)
#print(max(a))
#print(b)

ans=0
for i in range(N):
  if b[i]<maxa:
    break
  if H<=0:
    break
  H-=b[i]
  ans+=1
if H>0:
  ans+=-(-H//maxa)
print(ans)
### BUGGY CODE ###

s = str(input())
k = int(input())
subs = set()
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        subs.add(s[i:j])
print(sorted(list(subs))[k - 1])


### FIXED CODE ###

s = str(input())
k = int(input())
subs = set()
for i in range(len(s)):
    for j in range(i + 1, i + k + 1):
        subs.add(s[i:j])
print(sorted(list(subs))[k - 1])
### BUGGY CODE ###

n,k=map(int,input().split())
P=[list(map(int,input().split())) for _ in range(n)]
X=sorted(list(map(lambda x:x[0],P)))
Y=sorted(list(map(lambda x:x[1],P)))
s=(X[0]-X[-1])*(Y[0]-Y[-1])
ans=0
for r in range(n-1,0,-1):
  for l in range(r):
    for u in range(n-1,0,-1):
      for b in range(u):
        c=0
        for p in P:
          if X[l]<=p[0]<=X[r] and Y[b]<=p[1]<=Y[u]:
            c+=1
        if c>=k:
          s=min(s,(X[r]-X[l])*(Y[u]-Y[b]))
        else:break
print(s)

### FIXED CODE ###

n,k=map(int,input().split())
P=[list(map(int,input().split())) for _ in range(n)]
X=sorted(list(map(lambda x:x[0],P)))
Y=sorted(list(map(lambda x:x[1],P)))
s=(X[0]-X[-1])*(Y[0]-Y[-1])
ans=0
for r in range(n-1,0,-1):
  for l in range(r):
    for u in range(n-1,0,-1):
      for b in range(u):
        c=0
        for p in P:
          if X[l]<=p[0]<=X[r] and Y[b]<=p[1]<=Y[u]:
            c+=1
        if c>=k:
          s=min(s,(X[r]-X[l])*(Y[u]-Y[b]))
        else:break
    if u==n-1 and b==0 and c<k:
      break
print(s)
### BUGGY CODE ###

import math
N=int(input())
a=list(map(int,input().split()))
a_=sorted(a,key=lambda x:-x)
ans=0
while len(a_)>1:#1になった時点で終わり。
    x,y=0,0
    t=int(math.log2(a_[0]))+1
    if 2**(t-1)==a_[0]:
    #これは、2,4,8とか2のべき乗だけが引っかかる条件
        if a_[0]==a_[1]:
        #2のべきでも、きちんと2個存在するならおｋ
            a_.remove(a_[0])
            a_.remove(a_[0])
            ans+=1
        else:
            a_.remove(a_[0])
    else:
        x+=a_[0]
        y+=2**t-a_[0]
        if y in a_:
        #上で被りうる奴は排除できている。
            ans+=1
            a_.remove(x)
            a_.remove(y)
        else:
            a_.remove(a_[0])
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
c = Counter(a)

ans = 0
for i in a:
    if c[i] == 0:
        continue
    c[i] -= 1
    k = 1<<i.bit_length()
    j = k-i
    if j in c and c[j] > 0:
        ans += 1
        c[j] -= 1
print(ans)
### BUGGY CODE ###

import collections

INF = float('inf')

N, M = list(map(int, input().split()))
d = {i: [] for i in range(N)}

for _ in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    d[a].append(b)
    d[b].append(a)

queue = collections.deque()
queue.append((0, 0))
results = [(INF, -1) for i in range(N)]

while queue:
    cost, cur = queue.pop()
    next_list = d[cur]

    for next_cur in next_list:
        next_cost = cost+1
        if next_cost < results[next_cur][0]:
            results[next_cur] = (next_cost, cur)
            queue.append((next_cost, next_cur))

del results[0]
# print(results)

is_no = False
for result in results:
    if result[1] == -1:
        is_no = True

if is_no:
    print('No')
else:
    print('Yes')
    for result in results:
        print(result[1]+1)


### FIXED CODE ###

import collections

INF = float('inf')

N, M = list(map(int, input().split()))
d = {i: [] for i in range(N)}

for _ in range(M):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    d[a].append(b)
    d[b].append(a)

queue = collections.deque()
queue.append((0, 0))
results = {i: (INF, -1) for i in range(N)}
results[0] = (0, 0)
used = set()

while queue:
    cost, cur = queue.pop()
    if cur in used:
        continue
    used.add(cur)
    next_list = d[cur]

    for next_cur in next_list:
        next_cost = cost+1
        if next_cost < results[next_cur][0]:
            results[next_cur] = (next_cost, cur)
            queue.appendleft((next_cost, next_cur))

is_no = False
for k, result in results.items():
    if k == 0:
        continue
    if result[1] == -1:
        is_no = True

if is_no:
    print('No')
else:
    print('Yes')
    for k, result in results.items():
        if k == 0:
            continue
        print(result[1] + 1)
### BUGGY CODE ###

N, P = map(int, input().split())

div = 2
res = 1
while div * div <= P:
    cnt = 0
    tmp = P
    while P % div == 0:
        tmp /= div
        cnt += 1

        if cnt == N:
            res *= div
            cnt = 0
    div += 1

print(res)


### FIXED CODE ###

N, P = map(int, input().split())

if N == 1:
    print(P)
    exit()

div = 2
res = 1
R = P

while div * div <= R and div <= P:
    cnt = 0
    while P % div == 0:
        P /= div
        cnt += 1

        if cnt == N:
            res *= div
            cnt = 0
    div += 1

print(res)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# abc 127 d
# input
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
upd = []
for i in range(m):
    s, l = map(int, input().split())
    for j in range(s):
        upd.append(l)
upd = sorted(upd, reverse=True)
a = sorted(a)

# output
f = len(a)
o = 0
c = len(upd)
if f > c:
    for i in range(c):
        o += max(upd[c-1-i], a[c-1-i])
    print(o+sum(a[c:]))
else:
    for i in range(f):
        o += max(upd[i], a[i])
    print(o)


### FIXED CODE ###

# -*- coding: utf-8 -*-
# abc 127 d
from operator import itemgetter
# input
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
upd = []
for i in range(m):
    upd.append(list(map(int, input().split())))
upd.sort(key=itemgetter(1), reverse=True)
# print(upd)
# output
f = len(a)
p = 0
for t in upd:
    for i in range(p, p+t[0]):
        if p < f:
            if a[p] < t[1]:
                a[p] = t[1]
            else:
                break
        else:
            break
        p += 1
print(sum(a))
### BUGGY CODE ###

from collections import Counter
import itertools


n = int(input())
v = [int(i) for i in input().split()]

if len(set(v)) == 1:
    print(int(len(v) / 2))
    exit()

max_hit = 0
a_nums = [v[i] for i in range(0, len(v), 2)]
a_count = Counter(a_nums)
b_nums = [v[i] for i in range(1, len(v), 2)]
b_count = Counter(b_nums)
vals = [None, None]

for i, j in itertools.product(set(a_nums), set(b_nums)):
    if i == j:
        continue

    if a_count[i] + b_count[j] > max_hit:
        max_hit = a_count[i] + b_count[j]
        vals[0] = i
        vals[1] = j

fix = 0
for i, x in enumerate(v):
    if x != vals[i % 2]:
        fix += 1
print(fix)


### FIXED CODE ###

from collections import Counter

n = int(input())
v = list(map(int, input().split()))

"""数字が1種類の場合は半分を書き換える必要が確定"""
if len(set(v)) == 1:
    print(len(v) // 2)
    exit()

"""要素出現数を集計"""
odd_count = Counter(v[1::2])
even_count = Counter(v[::2])

"""一番多く出現する2つの数字を探す"""
max_hit = 0
odd = None
even = None
for odd_val, odd_hit in odd_count.most_common(5):
    # if max_hit > odd_hit:
    #     break  # もう最大値は更新されないので打ち止め
    for even_val, even_hit in even_count.most_common(5):
        # if max_hit > even_hit:
        #     break  # もう最大値は更新されないので打ち止め
        if odd_val == even_val:
            continue  # 数字は2種類ないとダメ
        if odd_hit + even_hit > max_hit:
            max_hit = odd_hit + even_hit
            odd = odd_val
            even = even_val

"""一致していない要素が書き換え必要回数"""
print(len(v) - max_hit)
### BUGGY CODE ###

n=int(input())
x=list(map(int,input().split()))
for i in range(n):
    y=[]
    for j in range(n):
        if j!=i:
            y.append(x[j])
    y.sort(reverse=True)
    print(y[n//2-1])

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
y =[]
for i in range(n):
    y.append([x[i],i])
y.sort(key = lambda x:x[0])
ans1 =y[n//2][0]
ans2 =y[n//2-1][0]
#print(ans1,ans2)
for i in x:
    if i <=ans2:
        print(ans1)
    else:
        print(ans2)
### BUGGY CODE ###

S = input()
len_org = len(S)
while True:
    len_before = len(S)
    S = S.replace("10","").replace("01","").replace("11110000","").replace("00001111","")
    len_after = len(S)
    if len_before == len_after:
        break

print(len_org - len_after)

### FIXED CODE ###

S = input()
num_0 = list(S).count('0')
num_1 = list(S).count('1')
print(len(S) - abs(num_0 - num_1))
### BUGGY CODE ###

N,K,Q = map(int, input().split())
#A = [K] * N

A = [0] * N

for i in range(Q):
	a = int(input())
	A[a-1] += 1

sum(A)

for j in range(N):
	if K - (sum(A)-A[j]) > 0:
		print("Yes")
	else:
		print("No")




### FIXED CODE ###

N,K,Q = map(int, input().split())
#A = [K] * N

A = [0] * N

for i in range(Q):
	a = int(input())
	A[a-1] += 1

sm = sum(A)

for j in range(N):
	if K - (sm-A[j]) > 0:
		print("Yes")
	else:
		print("No")
### BUGGY CODE ###

from collections import defaultdict
from copy import copy
n = int(input())
a = list(map(int, input().split()))

ok, ng = n, 0
while ok-ng > 1:
	x = (ok+ng)//2
	d = defaultdict(int)
	last = 0
	valid = True
	if x == 1:
		for i in range(n-1):
			if a[i] >= a[i+1]:
				valid = False
				break
		if valid:
			ok = x
		else:
			ng = x
		continue

	for i in range(n-1):
		if a[i] > a[i+1]:
			if a[i+1] > last:
				d[a[i+1]] = 1
			else:
				j = a[i+1]
				while d[j] == x-1 and j > 0:
					del d[j]
					j -= 1
				d[j] += 1
			last = a[i+1]
		elif a[i] == a[i+1]:
			j = a[i+1]
			while d[j] == x-1 and j > 0:
				del d[j]
				j -= 1
			d[j] += 1
			last = a[i+1]

		e = copy(d)
		for k in d.keys():
			if k > last:
				del e[k]
		d = copy(e)

		#if x  < 5:
			#print(x, last, d)

		if d[0] > 0:
			valid = False
			break


	if valid:
		ok = x
	else:
		ng = x
print(ok)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))

ok, ng = n, 0
while ok-ng > 1:
	x = (ok+ng)//2
	#d = defaultdict(int)
	d = dict()
	last = 0
	valid = True
	if x == 1:
		for i in range(n-1):
			if a[i] >= a[i+1]:
				valid = False
				break
		if valid:
			ok = x
		else:
			ng = x
		continue

	for i in range(n-1):
		dels = []
		if a[i] < a[i+1]:
			last = a[i+1]
			continue

		j = a[i+1]
		for k in d.keys():
			if j < k:
				dels.append(k)

		while j > 0:
			if j in d and d[j] == x-1:
				#d[j] = 0
				dels.append(j)
				j -= 1
			else:
				break

		if j in d:
			d[j] += 1
		else:
			d[j] = 1

		for k in dels:
			del d[k]

		if 0 in d:
			valid = False
			break
		last = j

	if valid:
		ok = x
	else:
		ng = x
print(ok)
### BUGGY CODE ###

def main():
    x = int(input())
    s = 0
    f = 0
    ans = 0
    while ans < x:
        s += 1
        ans += 6
        if ans >= x:
            print(s+f)
            exit()
        f += 1
        ans += 5
        if ans >= x:
            print(s+f)
            exit()

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    x = int(input())
    ans = x//11
    chk = x%11
    if chk == 0:
        print(2*ans)
    elif chk <=6:
        print(2*ans+1)
    else:
        print(2*ans+2)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
ans = 0
for i in range(1,n):
    ans += i
print(ans)

### FIXED CODE ###

n = int(input())
ans = int(((n-1) * (n)) // 2)
print(ans)