CodeEff/ECCO huggingface dataset:
# Original solution
# https://atcoder.jp/contests/hitachi2020/submissions/10704509

def main():
    import sys
    input = sys.stdin.readline

    inf = 1 << 30
    L = 30

    N, T = list(map(int, input().split()))

    ps = []
    coef_0 = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        if a == 0:
            coef_0.append(b + 1)
        else:
            ps.append((a, b))  # namedtupleやめた,coef,const

    ps.sort(key=lambda p: p[0] / (p[1] + 1), reverse=True)
    coef_0.sort()

    dp = [inf] * (L + 1)
    dp[0] = 0
    for coef, const in ps:
        for visited in reversed(list(range(L))):
            dp[visited + 1] = min(
                dp[visited + 1],
                (dp[visited] + 1) * (coef + 1) + const
            )

    def accumulate(a):
        s = 0
        yield s  # start=x->0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(coef_0)

    ans = {0}
    cnt = len(acc) - 1
    for visited, consumption_time in enumerate(dp):
        rest = T - consumption_time
        if rest < 0: break  # le->lt,continue->break,restは狭義単調減少
        while cnt > 0 and acc[cnt] > rest:  # bisect_right->しゃくとり
            cnt -= 1
        ans.add(visited + cnt)
    print((max(ans)))


if __name__ == '__main__':
    main()


# Optimized solution
# https://atcoder.jp/contests/hitachi2020/submissions/10704509
# PyPyなら通る

def main():
    import sys
    input = sys.stdin.readline

    inf = 1 << 30
    L = 30

    N, T = list(map(int, input().split()))

    ps = []
    coef_0 = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        if a == 0:
            coef_0.append(b + 1)
        else:
            ps.append((a, b))  # namedtupleやめた,coef,const

    ps.sort(key=lambda p: p[0] / (p[1] + 1), reverse=True)
    coef_0.sort()

    dp = [inf] * (L + 1)
    dp[0] = 0
    for coef, const in ps:
        for visited in reversed(list(range(L))):
            dp[visited + 1] = min(
                dp[visited + 1],
                (dp[visited] + 1) * (coef + 1) + const
            )

    def accumulate(a):
        s = 0
        yield s  # start=x->0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(coef_0)

    ans = 0
    cnt = len(acc) - 1
    for visited, consumption_time in enumerate(dp):
        rest = T - consumption_time
        if rest < 0: break  # le->lt,continue->break,restは狭義単調減少
        while cnt > 0 and acc[cnt] > rest:  # bisect_right->しゃくとり
            cnt -= 1
        ans = max(ans, visited + cnt)
    print(ans) # setのminと逐次minどちらが速い


if __name__ == '__main__':
    main()
# Original solution
# https://atcoder.jp/contests/hitachi2020/submissions/10704509
# PyPyなら通る

def main():
    import sys
    input = sys.stdin.readline

    inf = 1 << 30
    L = 30

    N, T = list(map(int, input().split()))

    ps = []
    coef_0 = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        if a == 0:
            coef_0.append(b + 1)
        else:
            ps.append((a, b))  # namedtupleやめた,coef,const

    ps.sort(key=lambda p: p[0] / (p[1] + 1), reverse=True)
    coef_0.sort()

    dp = [inf] * (L + 1)
    dp[0] = 0
    for coef, const in ps:
        for visited in reversed(list(range(L))):
            dp[visited + 1] = min(
                dp[visited + 1],
                (dp[visited] + 1) * (coef + 1) + const
            )

    def accumulate(a):
        s = 0
        yield s  # start=x->0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(coef_0)

    ans = 0
    cnt = len(acc) - 1
    for visited, consumption_time in enumerate(dp):
        rest = T - consumption_time
        if rest < 0: break  # le->lt,continue->break,restは狭義単調減少
        while cnt > 0 and acc[cnt] > rest:  # bisect_right->しゃくとり
            cnt -= 1
        ans = max(ans, visited + cnt)
    print(ans) # setのminと逐次minどちらが速い


if __name__ == '__main__':
    main()


# Optimized solution
# https://atcoder.jp/contests/hitachi2020/submissions/10704509
# PyPyなら通る

def main():
    import sys
    input = sys.stdin.readline

    inf = 1 << 30
    L = 30

    N, T = list(map(int, input().split()))

    ps = []
    coef_0 = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        if a == 0:
            coef_0.append(b + 1)
        else:
            ps.append((a, b))  # namedtupleやめた,coef,const

    ps.sort(key=lambda p: p[0] / (p[1] + 1), reverse=True)
    coef_0.sort()

    dp = [inf] * (L + 1)
    dp[0] = 0
    for coef, const in ps:
        for visited in reversed(list(range(L))):
            dp[visited + 1] = min(
                dp[visited + 1],
                (dp[visited] + 1) * (coef + 1) + const
            )

    def accumulate(a):
        s = 0
        yield s  # start=x->0
        for x in a:
            s += x
            yield s

    *acc, = accumulate(coef_0)

    ans = 0
    cnt = len(acc) - 1
    for visited, consumption_time in enumerate(dp):
        rest = T - consumption_time
        if rest < 0: break  # le->lt,continue->break,restは狭義単調減少
        while cnt > 0 and acc[cnt] > rest:  # bisect_right->しゃくとり
            cnt -= 1
        visited += cnt
        if visited > ans:
            ans = visited  # 関数呼び出しとどちらが速いか(set->maxよりは逐次が速かった）
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
import sys
input = sys.stdin.readline

N,T=list(map(int,input().split()))
M=[list(map(int,input().split())) for i in range(N)]

def compare(x,y):
    if x==0:
        return (1<<31)+y
    else:
        return (y+1)/x

M.sort(key=lambda x:compare(x[0],x[1]))

k=N
for i in range(N):
    if M[i][0]==0:
        k=i
        break

#print(k)

DP=[[T+1]*(k+1) for i in range(30)]
DP[0][0]=0

def nexttime(x,a,b):
    return x+1+a*(x+1)+b

for i in range(29):
    for j in range(k):
        for l in range(j+1,k+1):
            nt=nexttime(DP[i][j],M[l-1][0],M[l-1][1])
            if nt<DP[i+1][l]:
                DP[i+1][l]=nt
ANS=0
for i in range(30):
    TIME=min(DP[i])
    if TIME>T:
        break
    SC=i
    for j in range(k,N):
        if TIME+M[j][1]+1<=T:
            TIME+=M[j][1]+1
            SC+=1
    ANS=max(ANS,SC)

print(ANS)

# Optimized solution
import sys
input = sys.stdin.readline

N,T=list(map(int,input().split()))
M=[list(map(int,input().split())) for i in range(N)]

def compare(x,y):
    if x==0:
        return (1<<31)+y
    else:
        return (y+1)/x

M.sort(key=lambda x:compare(x[0],x[1]))

k=N
for i in range(N):
    if M[i][0]==0:
        k=i
        break

#print(k)

DP=[[T+1]*(k+1) for i in range(30)]
for i in range(k+1):
    DP[0][i]=0

def nexttime(x,a,b):
    return x+1+a*(x+1)+b

for i in range(1,30):
    for j in range(1,k+1):
        nt=nexttime(DP[i-1][j-1],M[j-1][0],M[j-1][1])
        DP[i][j]=min(DP[i][j-1],nt)
ANS=0
for i in range(30):
    TIME=min(DP[i])
    if TIME>T:
        break
    SC=i
    for j in range(k,N):
        if TIME+M[j][1]+1<=T:
            TIME+=M[j][1]+1
            SC+=1
    ANS=max(ANS,SC)

print(ANS)
# Original solution
import sys
from bisect import bisect_right

N,T = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(N)]
#%%
b0 = []
ab1 = []
for a,b in ab:
    if a==0:
        b0.append(b+1)
    else:
        ab1.append([a/(b+1), a, b+1])

N0 = len(b0)
N1 = len(ab1)

b0.sort()
if N0>0:
    b_ruiseki = [0]*N0
    b_ruiseki[0] = b0[0]
    for i in range(1,N0):
        b_ruiseki[i] = b_ruiseki[i-1] + b0[i]
else:
    b_ruiseki = []

ab1.sort(reverse = True)

INF = T + 100

dp = [[INF]*31 for _ in range(N1+1)]
dp[0][0] = 0
ans = 0
for i in range(N1):
    # dp[i+1][j] : 0~i番目までの店を見て，j個選ぶときの最小時間
    
    for j in range(31):
        if j>i+1:break
        if j==0:
            dp[i+1][j] = 0
        else:
            dp[i+1][j] = min(dp[i][j], dp[i][j-1] + (dp[i][j-1]+1)*ab1[i][1]+ab1[i][2])

for j in range(31):
    if dp[N1][j]>T:break    
    # a>0をj店舗めぐった後にa=0を何店舗めぐれるか
    num0 = bisect_right(b_ruiseki, T - dp[N1][j])
    ans = max(ans, j + num0)
        
    
print(ans)


# Optimized solution
import sys
from bisect import bisect_right

N,T = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(N)]
#%%
b0 = []
ab1 = []
for a,b in ab:
    if a==0:
        b0.append(b+1)
    else:
        ab1.append([(b+1)/a, a, b])

N0 = len(b0)
N1 = len(ab1)

b0.sort()
if N0>0:
    b_ruiseki = [0]*N0
    b_ruiseki[0] = b0[0]
    for i in range(1,N0):
        b_ruiseki[i] = b_ruiseki[i-1] + b0[i]
else:
    b_ruiseki = []

ab1.sort()

INF = T + 100

dp = [[INF]*31 for _ in range(N1+1)]
dp[0][0] = 0
ans = 0
for i in range(N1):
    # dp[i+1][j] : 0~i番目までの店を見て，j個選ぶときの最小時間
    
    for j in range(31):
        if j>i+1:break
        if j==0:
            dp[i+1][j] = 0
        else:
            dp[i+1][j] = min(dp[i][j], (dp[i][j-1]+1)*(ab1[i][1]+1)+ab1[i][2])

for j in range(31):
    if dp[N1][j]>T:break    
    # a>0をj店舗めぐった後にa=0を何店舗めぐれるか
    num0 = bisect_right(b_ruiseki, T - dp[N1][j])
    ans = max(ans, j + num0)
        
    
print(ans)
# Original solution
from bisect import bisect_right

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

shop = []
shop_a0 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    if a != 0:
        shop.append([a, b, a/(b+1)])
    else:
        shop_a0.append(b)

shop = sorted(shop, key=lambda x: -x[2])
shop_a0 = sorted(shop_a0)

n = len(shop)

# dp[i][j]:i番目まで見てj個の店を回るのに掛かる所要時間の最小値
dp = [[10**10]*(n+1) for _ in range(n+1)]
dp[0][0] = 0


for j in range(min(n+1, 50)):
    for i in range(n):
        dp[i+1][j] = min(dp[i][j], dp[i][j-1] + 1 +
                         shop[i][0]*(dp[i][j-1]+1) + shop[i][1])

ss = []
if shop_a0:
    ss.append(1+shop_a0[0])
    for i in range(1, len(shop_a0)):
        ss.append(ss[-1]+1+shop_a0[i])

ans = 0

for i in range(n+1):
    if t - dp[n][i] >= 0:
        ans = max(ans, bisect_right(ss, t-dp[n][i]) + i)

print(ans)


# Optimized solution
from bisect import bisect_right

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

shop = []
shop_a0 = []

for i in range(n):
    a, b = list(map(int, input().split()))
    if a != 0:
        shop.append([a, b, a/(b+1)])
    else:
        shop_a0.append(b)

shop = sorted(shop, key=lambda x: -x[2])
shop_a0 = sorted(shop_a0)

n = len(shop)

# dp[i][j]:i番目まで見てj個の店を回るのに掛かる所要時間の最小値
dp = [[10**10]*50 for _ in range(n+1)]
dp[0][0] = 0


for j in range(min(n+1, 50)):
    for i in range(n):
        dp[i+1][j] = min(dp[i][j], dp[i][j-1] + 1 +
                         shop[i][0]*(dp[i][j-1]+1) + shop[i][1])

ss = []
if shop_a0:
    ss.append(1+shop_a0[0])
    for i in range(1, len(shop_a0)):
        ss.append(ss[-1]+1+shop_a0[i])

ans = 0

for i in range(min(n+1, 50)):
    if t - dp[n][i] >= 0:
        ans = max(ans, bisect_right(ss, t-dp[n][i]) + i)

print(ans)
# Original solution
N,K=list(map(int,input().split()))
p=[int(i)-1 for i in input().split()]
q=[int(i)-1 for i in input().split()]
def inv(seq):
    res=[0 for i in range(N)]
    for i in range(N):
        res[seq[i]]=i
    return res
def times(seq1,seq2):
    res=[0 for i in range(N)]
    for i in range(N):
        res[i]=seq1[seq2[i]]
    return res
md=[[0 for i in range(N)] for i in range(6)]
for i in range(N):
    md[0][i]=p[i]
    md[1][i]=q[i]
for i in range(2,6):
    md[i]=times(md[i-1],inv(md[i-2]))
A=times(times(times(q,inv(p)),inv(q)),p)
T=(K-1)//6
def expseq(seq,k):
    if k==0:
        return [i for i in range(N)]
    elif k==1:
        return seq
    elif k%2==0:
        return expseq(times(seq,seq),k//2)
    else:
        return times(expseq(times(seq,seq),k//2),seq)
tmp=expseq(A,T)
ans=times(times(tmp,md[(K-1)%6]),inv(tmp))
print((" ".join([str(i+1) for i in ans])))


# Optimized solution
N,K=list(map(int,input().split()))
p=[int(i)-1 for i in input().split()]
q=[int(i)-1 for i in input().split()]
def inv(seq):
    res=[0 for i in range(N)]
    for i in range(N):
        res[seq[i]]=i
    return res
def times(seq1,seq2):
    res=[0 for i in range(N)]
    for i in range(N):
        res[i]=seq1[seq2[i]]
    return res
md=[[0 for i in range(N)] for i in range(6)]
for i in range(N):
    md[0][i]=p[i]
    md[1][i]=q[i]
for i in range(2,6):
    md[i]=times(md[i-1],inv(md[i-2]))
A=times(times(q,inv(p)),times(inv(q),p))
T=(K-1)//6
def expseq(seq,k):
    if k==0:
        return [i for i in range(N)]
    elif k==1:
        return seq
    elif k%2==0:
        return expseq(times(seq,seq),k//2)
    else:
        return times(expseq(times(seq,seq),k//2),seq)
tmp=expseq(A,T)
ans=times(times(tmp,md[(K-1)%6]),inv(tmp))
print((" ".join([str(i+1) for i in ans])))
# Original solution
N,K=list(map(int,input().split()))
p=[int(i)-1 for i in input().split()]
q=[int(i)-1 for i in input().split()]
def inv(seq):
    res=[0 for i in range(N)]
    for i in range(N):
        res[seq[i]]=i
    return res
def times(seq1,seq2):
    res=[0 for i in range(N)]
    for i in range(N):
        res[i]=seq1[seq2[i]]
    return res
md=[[0 for i in range(N)] for i in range(6)]
for i in range(N):
    md[0][i]=p[i]
    md[1][i]=q[i]
for i in range(2,6):
    md[i]=times(md[i-1],inv(md[i-2]))
A=times(times(q,inv(p)),times(inv(q),p))
T=(K-1)//6
def expseq(seq,k):
    if k==0:
        return [i for i in range(N)]
    elif k==1:
        return seq
    elif k%2==0:
        return expseq(times(seq,seq),k//2)
    else:
        return times(expseq(times(seq,seq),k//2),seq)
tmp=expseq(A,T)
ans=times(times(tmp,md[(K-1)%6]),inv(tmp))
print((" ".join([str(i+1) for i in ans])))


# Optimized solution
N,K=list(map(int,input().split()));p=[int(i)-1 for i in input().split()];q=[int(i)-1 for i in input().split()]
def I(s):
 r=[0 for i in range(N)]
 for i in range(N):r[s[i]]=i
 return r
def T(s,t):
 r=[0 for i in range(N)]
 for i in range(N):r[i]=s[t[i]]
 return r
m=[[0 for i in range(N)] for i in range(6)];A=T(T(T(q,I(p)),I(q)),p);X=(K-1)//6
for i in range(N):m[0][i]=p[i];m[1][i]=q[i]
for i in range(2,6):m[i]=T(m[i-1],I(m[i-2]))
def E(s,k):
 if k==0:
  return [i for i in range(N)]
 elif k==1:
  return s
 elif k%2==0:
  return E(T(s,s),k//2)
 else:
  return T(E(T(s,s),k//2),s)
t=E(A,X);a=T(T(t,m[(K-1)%6]),I(t));print((" ".join([str(i+1) for i in a])))
# Original solution
N,K=list(map(int,input().split()));p=[int(i)-1 for i in input().split()];q=[int(i)-1 for i in input().split()]
def I(s):
 r=[0 for i in range(N)]
 for i in range(N):r[s[i]]=i
 return r
def T(s,t):
 r=[0 for i in range(N)]
 for i in range(N):r[i]=s[t[i]]
 return r
m=[[0 for i in range(N)] for i in range(6)];A=T(T(T(q,I(p)),I(q)),p);X=(K-1)//6
for i in range(N):m[0][i]=p[i];m[1][i]=q[i]
for i in range(2,6):m[i]=T(m[i-1],I(m[i-2]))
def E(s,k):
 if k==0:
  return [i for i in range(N)]
 elif k==1:
  return s
 elif k%2==0:
  return E(T(s,s),k//2)
 else:
  return T(E(T(s,s),k//2),s)
t=E(A,X);a=T(T(t,m[(K-1)%6]),I(t));print((" ".join([str(i+1) for i in a])))

# Optimized solution
N,K=list(map(int,input().split()));p=[int(i)-1 for i in input().split()];q=[int(i)-1 for i in input().split()]
def I(s):
 r=[0]*N
 for i in range(N):r[s[i]]=i
 return r
def T(s,t):return [s[t[i]] for i in range(N)]
m=[[0 for i in [0]*N] for i in [0]*6]
for i in range(N):m[0][i]=p[i];m[1][i]=q[i]
for i in range(4):m[i+2]=T(m[i+1],I(m[i]))
def E(s,k):
 if k%2==0:
  return E(T(s,s),k//2) if k!=0 else list(range(N))
 else:
  return T(E(T(s,s),k//2),s)
t=E(T(T(T(q,I(p)),I(q)),p),~-K//6);print((" ".join([str(i+1) for i in T(T(t,m[~-K%6]),I(t))])))
# Original solution
n = int(input())
a = list(map(int, input().split()))
print(" ".join(map(str, a)))
for j in range(1,n):
    key = a[j]
    i = j-1
    while i >= 0 and a[i] > key:
        a[i+1] = a[i]
        i = i - 1
    a[i+1] = key
    print(" ".join(map(str, a)))

# Optimized solution
def isort(n,a):
    print(" ".join(map(str, a)))
    for j in range(1,n):
        key = a[j]
        i = j-1
        while i >= 0 and a[i] > key:
            a[i+1] = a[i]
            i = i - 1
        a[i+1] = key
        print(" ".join(map(str, a)))

n = int(input())
a = list(map(int, input().split()))
isort(n,a)
# Original solution
n = int(input())
lst = list(map(int,input().split()))

def pri(lst):
    for i in range(len(lst)-1):
        print(lst[i],end=" ")
    print(lst[-1])

pri(lst)
for i in range(1,n):
    v = lst[i]
    j = i-1
    while True:
        if j < 0:
            lst[0] = v
            break
        if lst[j] > v:
            lst[j+1] = lst[j]
            j -= 1
        else:
            lst[j+1] = v
            break
    pri(lst)



# Optimized solution
def insertsort(array):
    for i in range(1,len(array)):
        print((" ".join(list(map(str,array)))))
        temp = array[i]
        j = i-1
        while j >= 0 and temp < array[j]:
            array[j+1] = array[j]
            j -= 1
        array[j+1] = temp
    return array

eval(input())
a = insertsort(list(map(int,input().split())))
print((" ".join(list(map(str,a)))))
# Original solution
def show_list(num_list):
    for i in range(len(num_list)):
        print(str(num_list[i]), end="")
        if i < len(num_list)-1:
            print(" ", end="")
        else:
            print()

input_num = int(input())
num_list = [int(i) for i in input().split()]
show_list(num_list)
for i in range(1, len(num_list)):
    v = num_list[i]
    j = i - 1
    while j >= 0 and num_list[j] > v:
        num_list[j+1] = num_list[j]
        j -= 1
    num_list[j+1] = v
    show_list(num_list)


# Optimized solution
# -*- coding : utf-8 -*-

def insertion_sort(list):
    for i in range(1, len(list)):
        key = list[i]
        j = i - 1
        show_list(list)
        while(j >= 0 and list[j] > key):
            list[j+1] = list[j]
            j = j - 1
        list[j+1] = key
    show_list(list)
    return list

def show_list(list):
    i = 0;
    while(i < len(list)-1):
        print(list[i], end=" ")
        i = i + 1
    print(list[i])

list_length = int(input())
list = [int(x) for x in input().split(" ")]
insertion_sort(list)
# Original solution
list_len = int(input().rstrip())
num_list = list(map(int, input().rstrip().split()))

for i in range(list_len):
    v = num_list[i]

    j = i - 1
    while j >= 0 and num_list[j] > v:
        num_list[j + 1] = num_list[j]
        j -= 1
    num_list[j+1] = v
    
    output_str = ' '.join(map(str, num_list))
    print(output_str)

# Optimized solution
def insertion_sort(A, N):
    for i  in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        
        print((' '.join(map(str, A))))

def main():
    N = int(input().rstrip())
    A = list(map(int, input().rstrip().split()))
    
    insertion_sort(A, N)
    
if __name__ == '__main__':
    main()
# Original solution
def insertion_sort(array, element_number):
    for i in range(element_number):
        v = array[i]
        j = i - 1

        while(j>=0 and array[j] > v):
            array[j+1] = array[j]
            j = j - 1

        array[j+1] = v

        for k in range(element_number):
            if k < element_number-1:
                print(str(array[k]) + ' ', end='')
            else:
                print(str(array[k]), end='')

        print('\n', end='')

def test():
    element_number = int(input())
    input_array = list(map(int, input().split()))

    insertion_sort(input_array, element_number)

if __name__ == '__main__':
    test()


# Optimized solution
def insertion_sort(array):
    '''?????????????´?????????????????????¨??????????????????????????¨???????????????????????§?????\?????????????????°????????????
    1. ??????????????¨??????????????????????´?????????????????????? v ????¨?????????????
    2. ????????????????????¨??????????????????v ????????§??????????´??????????????????????????§?????????????
    3. ?????????????????????????????????????????????????´? v???????????\?????????'''

    for i in range(len(array)):
        v = array[i]
        j = i - 1

        while(j>=0 and array[j] > v):
            array[j+1] = array[j]
            j = j - 1

        array[j+1] = v
        print((' '.join(map(str, array))))

def test():
    '''??? input =
    6
    5 2 4 6 1 3
    ->
    5 2 4 6 1 3
    2 5 4 6 1 3
    2 4 5 6 1 3
    2 4 5 6 1 3
    1 2 4 5 6 3
    1 2 3 4 5 6'''
    
    element_number = int(eval(input()))
    input_array = list(map(int, input().split()))

    insertion_sort(input_array)

if __name__ == '__main__':
    test()
# Original solution
l = []
for i in range(1,151):
    for j in range(1,151):
        if i==j or i>j: continue
        l += [[i**2+j**2,i,j]]
l = sorted(l)
while True:
    h,w = map(int,input().split())
    if w==h==0: break
    i = l.index([w**2+h**2,h,w])+1
    print(*l[i][1:],sep=' ')


# Optimized solution
l = [[i**2+j**2,i,j] for j in range(1,151) for i in range(1,151) if i!=j and i<j]
l = sorted(l)
while True:
    h,w = map(int,input().split())
    if w==h==0: break
    i = l.index([w**2+h**2,h,w])+1
    print(*l[i][1:],sep=' ')
# Original solution
a,b,c = list(map(int, input().split()))
if (a+b) >= c:
    print("Yes")
else:
    print("No")

# Optimized solution
a,b,c = list(map(int, input().split()))
print(("Yes" if a+b >= c else "No"))
# Original solution
a, b, c = list(map(int, input().split(' ')))
print(("Yes" if a + b >= c else "No" ))

# Optimized solution
coin_1, coin_2, value = list(map(int, input().split(' ')))
if (coin_1 + coin_2) >= value:
  print("Yes")
else:
  print("No")
# Original solution
(a, b, c) = list(map(int, input().split()))
if a + b >= c:
    print("Yes")
else:
    print("No")

# Optimized solution
a, b, x = list(map(int, input().split()))

if a+b >= x:
    print("Yes")
else:
    print("No")
# Original solution
a,b,c = list(map(int,input().split()))
# print(a,b,c)

if c <= a + b:
    print('Yes')
else:
    print('No')


# Optimized solution
a,b,c = list(map(int,input().split()))
print(('No' if a+b < c else 'Yes'))
# Original solution
Tmp = []
Tmp = input().rstrip().split(' ')


X = int(Tmp[0])
Y = int(Tmp[1])
C = int(Tmp[2])

Ans = X + Y
if Ans >= C:
    print('Yes')
else:
    print('No')


# Optimized solution
A, B, C=list(map(int,input().split()))

A += B

if A >= C:
  print('Yes')
else:
  print('No')
# Original solution
N = int(eval(input()))
P = list(map(int, input().split()))

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

Pi = [0] * (N + 1)
for i, n in enumerate(P, 1):
    Pi[n] = i

T = [0] * N
f = [0] * N

if Pi[N] > Pi[N - 1]:
    T[N - 1] = 0
    f[N - 1] = N - 1
else:
    T[N - 1] = 1
    f[N - 1] = N

for i in range(N - 2, 0, -1):
    if T[i + 1] == 0:
        i_i = Pi[i]
        i_ii = Pi[i + 1]
        if i_ii > i_i:
            T[i] = T[i + 1]
            f[i] = f[i + 1]
        else:
            T[i] = T[i + 1] + 1
            f[i] = i + 1
    else:
        i_f = Pi[f[i + 1]]
        i_i = Pi[i]
        i_ii = Pi[i + 1]
        if i_f < i_i < i_ii or i_ii < i_f < i_i or i_i < i_ii < i_f:
            T[i] = T[i + 1]
            f[i] = f[i + 1]
        else:
            T[i] = T[i + 1] + 1
            f[i] = i + 1

print((T[1]))

# Optimized solution
N = int(eval(input()))
P = list(map(int, input().split()))

Pi = [0] * (N + 1)
for i, n in enumerate(P, 1):
    Pi[n] = i

i = N - 1
T = 0
f = 0

while i:
    i_f = Pi[f]
    i_i = Pi[i]
    i_ii = Pi[i + 1]
    if i_f < i_ii < i_i or i_i < i_f < i_ii or i_ii < i_i < i_f:
        T += 1
        f = i + 1
    i -= 1

print(T)
# Original solution
from math import ceil


def main():
    x = int(eval(input()))
    answer = ceil(x / 11)
    if 1 <= x % 11 <= 6:
        answer = answer * 2 - 1
    else:
        answer *= 2
    print(answer)


if __name__ == '__main__':
    main()



# Optimized solution
def main():
    x = int(eval(input()))
    answer = (x // 11) * 2
    if 1 <= x % 11 <= 6:
        answer += 1
    elif 7 <= x % 11:
        answer += 2
    print(answer)


if __name__ == '__main__':
    main()
# Original solution
import sys

x = int(sys.stdin.readline().strip())

"""
1
5423
6
"""

r = x // 11
res = x - 11*r
if res == 0:
    print((2*r))
elif res > 6:
    print((2*r + 2))
else:
    print((2*r + 1))

# Optimized solution
import sys

x = int(sys.stdin.readline())
n = x // 11
r = x % 11
if r == 0:
    print((2*n))
elif r <= 6:
    print((2*n + 1))
else:
    print((2 * (n+1)))