Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())
G = [[] for _ in range(N+1)]

# weighted graph
for _ in range(M):
    l, r, d = map(int, input().split())
    G[l].append((r, d))
    G[r].append((l, -d))

cache = set(range(1, N+1))

# depth first search
def dfs(graph, start, visited=None):
    global cache  # for checking disconnected
    visited = visited or {}
    visited[start[0]] = start[1]
    cache.remove(start[0])
    for nxt, v in graph[start[0]]:
        nxt_value = start[1] + v
        if nxt in visited:
            if nxt_value != visited[nxt]:
                return False
            continue
        return dfs(graph, (nxt, nxt_value), visited)
    return True

while len(cache)>0:
    if not dfs(G, (list(cache)[0], 0)):
        print('No')
        break
else:
    print('Yes')

### FIXED CODE ###

from collections import deque

def main():
    N, M = map(int, input().split())
    link = [[] for _ in range(N+1)]
    value = [0 for _ in range(N+1)]

    for _ in range(M):
        l, r, d = map(int, input().split())
        link[l].append((r, d))
        link[r].append((l, -d))

    searched = set()
    q = deque()
    for u in range(N+1):
        if u in searched:
            continue
        q.append(u)
        searched.add(u)
        value[u] = 0

        # search
        while q:
            x = q.popleft()
            for y, d in link[x]:
                if y not in searched:
                    value[y] = value[x] + d
                    q.append(y)
                    searched.add(y)

    # verify
    for x in range(N+1):
        for y, d in link[x]:
            if value[y] != value[x] + d:
                print('No')
                return
    else:
        print('Yes')

if __name__ == '__main__':
    main()
def cal(N, i):
    if N > 0:
        return 2 * cal(N - 1, i) + i
    elif N == 0:
        return 1
    else:
        return 0

def pCal(N ,X):
    total = cal(N, 3)
    half = total // 2
    pTmp = cal(N - 1, 1)
    if X == 1 and N == 0:
        return 1
    elif X <= N:
        return 0
    elif X < half:
        return pCal(N - 1, X - 1)
    elif X == half:
        return pTmp
    elif X == half + 1:
        return pTmp + 1
    elif total > X > half + 1:
        return (pTmp + 1) + pCal(N - 1, X - (half + 1))
    else x == total
        return cal(N, 1)
N, X = list(map(int, input().split()))
print(pCal(N, X))

### FIXED CODE ###

def cal(N, i):
    if N > 0:
        return 2 * cal(N - 1, i) + i
    elif N == 0:
        return 1
    else:
        return 0

def pCal(N ,X):
    total = cal(N, 3)
    half = total // 2
    pTmp = cal(N - 1, 1)
    if X == 1 and N == 0:
        return 1
    elif X <= N:
        return 0
    elif X < half:
        return pCal(N - 1, X - 1)
    elif X == half:
        return pTmp
    elif X == half + 1:
        return pTmp + 1
    elif total > X > half + 1:
        return (pTmp + 1) + pCal(N - 1, X - (half + 1))
    elif X == total:
        return cal(N, 1)
N, X = list(map(int, input().split()))
print(pCal(N, X))
S = input()
if S =='ABC':
  print('ARC')
else:
  print('ABC)

### FIXED CODE ###

s=input()
print("ABC" if s=="ARC" else "ARC")
import math
n = input()
i = 11

if n == 8 or n ==9:
  print(11)
  i = 0
elif n == 2 or n== 3 or n == 5 or n == 7:
  print(n)
  i = 0
elif n <= 7 and n%2 == 0:
  print(n+1)
  i = 0

while i != 0:
  j = 3
  js = int(math.sqrt(i))
  while j <= js:
    if  i%j == 0:
      break
    elif j == js or j == js-1:
      print(i)
      break
      i = 0
    else:
      if j%2 == 0:
        j += 1
      else:
        j += 2
  if i%2 == 0:
    i += 1
  else:
    i += 2

### FIXED CODE ###

x = int(input())
if x <= 3:
  n = x
elif x == 4:
  n = 5
else:
  n = x
  j = 0
  while j == 0:
    a = int(n/2) + 1
    i = 2
    while i < a:
      if i == a-1:
        j = 1
        i = a
      elif n % i != 0:
        i += 1
      else:
        i = a
        n += 1
print(n)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    X_bin = readline().strip()
    n = X_bin.count("1")
    X = int(X_bin, 2)

    X_pop_p = X % (n + 1)
    X_pop_m = X % (n - 1)
    
    def count(x):
        cnt = 1
        while x:
            x %= bin(x).count("1")
            cnt += 1
        return cnt
        
    ans = []
    for i in range(N):
        X_i = X ^ (1 << i)
        if X_i == 0:
            ans.append(0)
        else:
            if X_bin[-(i+1)] == "1":
                mod = (X_pop_m - pow(2, i, n - 1)) % (n - 1)
                ans.append(count(mod))
            else:
                mod = (X_pop_p + pow(2, i, n + 1)) % (n + 1)
                ans.append(count(mod))

    print("\n".join(map(str, ans[::-1])))


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    X_bin = readline().strip()
    n = X_bin.count("1")
    X = int(X_bin, 2)

    X_pop_p = X % (n + 1)
    if n != 1:
        X_pop_m = X % (n - 1)

    
    def count(x):
        cnt = 1
        while x:
            x %= bin(x).count("1")
            cnt += 1
        return cnt
        
    ans = []
    for i in range(N):
        X_i = X ^ (1 << i)
        if X_i == 0:
            ans.append(0)
        else:
            if X_bin[-(i+1)] == "1":
                mod = (X_pop_m - pow(2, i, n - 1)) % (n - 1)
                ans.append(count(mod))
            else:
                mod = (X_pop_p + pow(2, i, n + 1)) % (n + 1)
                ans.append(count(mod))

    print("\n".join(map(str, ans[::-1])))


if __name__ == "__main__":
    main()
x = input()

x1 = int(x[:-2])
x2 = int(x[-2:])

c = int(x2 // 5) + 1

if x1 >= c:
	print(1)
else:
	print(0)


### FIXED CODE ###

import sys

x = input()
X = int(x)

if X < 100:
	print(0)
	sys.exit()
elif X >= 100 and X <= 105:
	print(1)
	sys.exit()
elif X % 105 == 0:
	print(1)
	sys.exit()

x1 = int(x[:-2])
x2 = int(x[-2:])

c = int(x2 // 5) + 1

if x1 >= c:
	print(1)
else:
	print(0)
N=int(input())
a=input().split()
a2=sorted(a,reverse=True)
alice=sum(a2[1::2])
bob=sum(a2[0::2])
print(alice-bob)

### FIXED CODE ###

N=int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
S=0
for i in range(N):
  if i%2==0:
    S+=a[i]
  else:
    S-=a[i]
print(S)
a,b,n = map(int,input().split())

if b == 1:
    print(0)
elif n < b:
    print(math.floor(a*n/b)+math.floor(n/b))
else:
    print(math.floor(a*(b-1)/b)+math.floor((b-1)/b))

### FIXED CODE ###

import math
a,b,n = map(int,input().split())

x = math.floor(a*n/b)-( a*math.floor(n/b))
y = math.floor(a*b/b)-( a*math.floor(b/b))
z = math.floor(a*(b-1)/b)-( a*math.floor((b-1)/b))

if b == 1:
    print(0)
elif n < b:
    print(x)
else:
    print(z)
l, r = map(int, input().split())

a = list(range(l, r+1))
a_len = len(a)
if a_len>2019:
    a = a[:2019]

num = 0
ans = 2019

for i in range(a_len):
    for j in range(a_len):
        if a[i]<a[j]:
            num = (a[i]*a[j])%2019
            ans = min(ans, num)
            if ans == 0:
                print(0)
                exit(0)

print(ans)

### FIXED CODE ###

l, r = map(int, input().split())

if r-l>2019:
    print(0)
    exit(0)
else:
    a = list(range(l, r+1))

num = 0
ans = 2019

for i in range(len(a)):
    for j in range(len(a)):
        if a[i]<a[j]:
            num = (a[i]*a[j])%2019
            ans = min(ans, num)
            if ans == 0:
                print(0)
                exit(0)

print(ans)
n = int(input())
ab = [list(map(int, (str(i)+' '+input()).split())) for i in range(n-1)]
coloring = [0]*(n-1)
uc = [set() for _ in range(n)]

def f(x, y):
  for i in ab:
    x1 = i[1]+i[2]-x
    if x == i[1] or x == i[2] and y != x1:
      c = 1
      while c in uc[x-1]:
        c += 1
      uc[x-1].add(c)
      uc[x1-1].add(c)
      coloring[i[0]] = c
      f(x1, x)
f(1, 0)
print(max(coloring))
for i in range(n-1):
  print(coloring[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n = int(input())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab2 = [[] for i in range(n)]
for i in range(n-1):
  ab2[ab[i][0]-1].append([ab[i][1]-1, i])
  ab2[ab[i][1]-1].append([ab[i][0]-1, i])
coloring = [0]*(n-1)

def f(x, y, z):
  c = 0
  for i in ab2[x]:
    if i[0] != y:
      c += 1
      if c == z:
        c += 1
      coloring[i[1]] = c
      x1 = i[0]
      y1 = x
      z1 = c
      f(x1, y1, z1)

f(0, None, None)
print(max(coloring))
for i in range(n-1):
  print(coloring[i])
H, W = [int(n) for n in input().split()]
for i in range(H):
    image = []
    image.append(input())

print("#"*(W+2))
for i in range(H):
    print("#"+image(i)+"#")
print("#"*(W+2))

### FIXED CODE ###


H, W = [int(n) for n in input().split()]
image = []
for i in range(H):
    image.append(input())

print("#"*(W+2))
for i in range(H):
    print("#"+image[i]+"#")
print("#"*(W+2))
S = str(input())
D = ["SUN","MUN","TUE","WED","THU","FRI","SAT"] 
print(7-D.index(S))

### FIXED CODE ###

S = str(input())
D = ["SUN","MON","TUE","WED","THU","FRI","SAT"] 
print(7-D.index(S))
from collections import deque
from decimal import *
n,m,k = [Decimal(int(e)) for e in input().split()]
As = deque([Decimal(int(e)) for e in input().split()])
Bs = deque([Decimal(int(e)) for e in input().split()])
result = 0
while True:
    if (not As) and (not Bs):
        break
        
    if (not As) and (Bs[0]>k):
        break
    if (not As) and (Bs[0]<=k):
        k = k-Bs.popleft()
        result = result + 1
        continue
        
    if (not Bs) and (As[0]>k):
        break
    if (not Bs) and (As[0]<=k):
        k = k-As.popleft()
        result = result + 1
        continue
    
    
    if As[0]+As[1] <= Bs[0]+Bs[1]:
        min_reduce = As.popleft()
    else:
        min_reduce = Bs.popleft()

    if min_reduce > k:
        break
    else:
        k = k-min_reduce
        result = result + 1
print(result)

### FIXED CODE ###

a = int(input())
print(a+a**2+a**3)
N = int(input())
seq = [int(input()) for _ in range(N)]
from collections import deque
LIS = deque([seq[0]])
for i in range(1,len(seq)):
    if seq[i] <= LIS[0]:
        LIS.appendleft(seq[i])
    else:
        LIS[bisect.bisect_left(LIS, seq[i])-1] = seq[i]
print(len(LIS))

### FIXED CODE ###

N = int(input())
seq = [int(input()) for _ in range(N)]
from collections import deque
import bisect
LIS = deque([seq[0]])
for i in range(1,len(seq)):
    if seq[i] <= LIS[0]:
        LIS.appendleft(seq[i])
    else:
        LIS[bisect.bisect_left(LIS, seq[i])-1] = seq[i]

print(len(LIS))
n=int(input())
p=list(map(int,input().split()))
ans=p[0]
cnt=1
for i in range(1,n):
	if p[i]<a:
		cnt+=1
		a=p[i]
print(cnt)


### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
a=p[0]
cnt=1
for i in range(1,n):
	if p[i]<a:
		cnt+=1
		a=p[i]
print(cnt)
N, K = map(int(input().split()))
pi = list(map(int(x) for x in input().split()))

max = 0
maxi = 0
i = 0
for j range(N - K):
    sum = pi(j) + pi(j + 1) + pi(j + 2)
    if sum >= max:
        max = sum
        maxi = j

out = 1 + (pi(i) - 1) * 0.5 + 1 + (pi(i + 1) - 1) * 0.5 + 1 + (pi(i + 2) - 1) * 0.5
print(out)

### FIXED CODE ###

N, K = map(int, input().split())
pi = list(map(int, input().split()))

tmp = sum(pi[0 : K])
max = tmp

if N == K:
    print((max + K) / 2)
else:
    for i in range(N - K):
        tmp = tmp - pi[i] + pi[i + K]
        if tmp > max:
            max = tmp
    print((max + K) / 2)
import numpy as np

N,M=[int(i) for i in input().split()]
x=input().split()
y=[int(i) for i in x]
y.sort()
if(M==1):
    print("0")
    exit()
if(N==1):
    print(y[M-1]-y[0])
    exit()

diff=[]
for i in range(M-1):
    diff.append(y[i+1]-y[i])
sub=[]
array=np.array(diff)
index=np.argsort(array)
c=index[-1::-1]
for i in range(N-1):
    sub.append(c[i])
print(sub)
ans=0
for i in range(N):
    if(i==0):
        ans+=y[sub[i]]-y[0]
    elif(i==N-1):
        ans+=y[M-1]-y[sub[i-1]+1]
    else:
        ans+=y[sub[i]]-y[sub[i-1]+1]
print(ans)

### FIXED CODE ###

import numpy as np
 
N,M=[int(i) for i in input().split()]
x=input().split()
y=[int(i) for i in x]
y.sort()
if(N==1):
    print(max(y)-min(y))
#    print(y[M-1]-y[0])
    exit()
if(M==1):
    print("0")
    exit()
if(N>=M):
    print("0")
    exit()
diff=[]
for i in range(M-1):
    diff.append(y[i+1]-y[i])
sub=[]
array=np.array(diff)
index=np.argsort(array)
c=index[-1::-1]
for i in range(N-1):
    sub.append(c[i])
ans=0
for i in range(N):
    if(i==0):
        ans+=y[sub[i]]-y[0]
    elif(i==N-1):
        ans+=y[M-1]-y[sub[i-1]+1]
    else:
        ans+=y[sub[i]]-y[sub[i-1]+1]
print(ans)
# A
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

re = -1
# 1文字目が必ず一緒であること
if S[0] == T[0]:
    min_num = (N * M)  // gcd(N, M) # 最小公倍数を求める（基本はこれが答え）
    re = min_num
    # 重なる部分が同じ文字かを調べる
    s_d = min_num // N
    t_d = min_num // M
    # 最小公倍数みる
    st_min = (s_d * t_d) // gcd(s_d, t_d)
    st = st_min
    i = 1
    while st // s_d <= N and st // t_d <= M:
        if S[st // s_d] != T[st // t_d]:
            re = -1
            break
        else:
            i += 1
            st = st * i

print(re)

### FIXED CODE ###

# A
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

re = -1
if S == T:
    re = N
elif S[0] == T[0]:
    min_num = (N * M)  // gcd(N, M) # 最小公倍数を求める（基本はこれが答え）
    re = min_num
    # 重なる部分が同じ文字かを調べる
    s_d = min_num // N
    t_d = min_num // M
    # 最小公倍数みる
    st_min = (s_d * t_d) // gcd(s_d, t_d)
    st = st_min
    i = 1
    while st // s_d < N and st // t_d < M:
        if S[st // s_d] != T[st // t_d]:
            re = -1
            break
        else:
            i += 1
            st = st_min * i

print(re)
s = str(input())
n = s.size()
cntz = 0
cnto = 0
for i in range(n):
    if s[i] == '0':
        cntz += 1
    elif s[i] == '1':
        cnto += 1
print(min(cnto,cntz))


### FIXED CODE ###

s = str(input())
cntz = 0
cnto = 0
for i in s:
    if i == '0':
        cntz += 1
    elif i == '1':
        cnto += 1
ans = 2*min(cnto,cntz)
print(ans)
S = [i for i in input()]
f = 0
for i in range(len(S)//2):
  if not S[i] == S[-i]:
    f = 1
    print('No')
    break
if f == 0:
  for i in range(int((len(S)-1)/2)):
    if not S[i] == S[int((len(S)-1)/2-i)]:
      f = 1
      print('No')
      break
if f == 0:
  for i in range((len(S)+3)/2, len(S)) and f == 0:
    if not S[i] == S[-i]:
      f = 1
      print('No')
      break
if f ==0:
  print('Yes')

### FIXED CODE ###

S = [i for i in input()]
f = 0
for i in range(len(S)//2):
  #print(S[i], S[-1-i])
  if not S[i] == S[-1-i]:
    f = 1
    print('No')
    break
#print(f)
if f == 0:
  s = S[:int((len(S)-1)/2)]
  for i in range(int(len(s)//2)):
    if not s[i] == s[-1-i]:
      f = 1
      print('No')
      break
#print(f)
if f == 0:
  s = S[int((len(S)+3)/2-1):]
  for i in range(int(len(s)//2)):
    #print(s[i], s[-1-i])
    if not s[i] == s[-1-i]:
      f = 1
      print('No')
      break
if f ==0:
  print('Yes')
n = int(input())

def digits(n):
    if n < 10:
        return n
    else:
        return n%10 + digits(int(n/10))

sn = digits(n)
if n % sn == 0:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

s = input()
output = 0
for o in s:
    if o == '+':
        output += 1
    elif o == '-':
        output -= 1
    else:
        pass
print(output)
N = int(input())
A = list(int(i) for i in input().split())

A.sort()


if((A[1] - A[0]) == 0):
    min_HP = A[0]
else:
    min_HP = 0
    while((A[1] - A[0]) > 0):
        A.insert(0, A[1] - A[0])
        A.sort()
        if((A[1] - A[0]) == 0):
            break
        min_HP = A[1] - A[0]

tmp_min = min_HP
for a in A:
    if ((a % tmp_min) < min_HP and (a % tmp_min) > 0):
        min_HP = tmp_min

print(min_HP)

### FIXED CODE ###

N = int(input())
A = list(int(i) for i in input().split())

A.sort()


if((A[1] - A[0]) == 0):
    min_HP = A[0]
    print(min_HP)
else:
    min_HP = A[1] - A[0]
    while((A[1] - A[0]) > 0):
        A.insert(0, A[1] - A[0])
        A.sort()
        if((A[1] - A[0]) == 0):
            break
        min_HP = A[1] - A[0]

    # そのループでまだmin_HPが更新されていない
    while(True):
        min_flag = False
        for a in A:
            if ((a % min_HP) < min_HP and (a % min_HP) > 0):
                min_HP = a % min_HP
                min_flag = True
        if( min_HP > 0 and min_flag ):
            continue
        else:
            break
    print(min_HP)
import collections
def main():
    N, M = map(int, input().split())
    bridges = []
    for _ in range(M):
        a, b = map(int, input().split())
        bridges.append([a, b])

    parent = [i for i in range(N+1)]
    count = [1 for _ in range(N+1)]

    def find(i):
        if parent[i] != i:
            parent[i] = find(parent[i])
        return parent[i]

    def union(i, j):
        pi, pj = find(i), find(j)
        df = 0
        if pi != pj:
            parent[pj] = pi
            df += count[pi] * count[pj]
            count[pi] += count[pj]
        return df

    ans = [N*(N-1)//2]
    for i in range(M-1, 0, -1):
        a, b = bridges[i]
        d = union(a, b)
        ans.append(ans[-1]-d)
    return ans

if __name__ == '__main__':
    output = main()
    for i in range(len(output)-1, -1, -1):
        print(output[i])

### FIXED CODE ###

import collections
def main():
    N, M = map(int, input().split())
    bridges = []
    for _ in range(M):
        a, b = map(int, input().split())
        bridges.append([a, b])
    bridges = bridges[::-1]
    parent = [i for i in range(N+1)]
    count = dict()
    for i in range(N+1): count[i] = 1

    def find(i):
        if parent[i] != i:
            parent[i] = find(parent[i])
        return parent[i]

    def union(i, j):
        pi, pj = find(i), find(j)
        df = 0
        if pi != pj:
            if count[pi] > count[pj]:
                parent[pj] = pi
                df += count[pi] * count[pj]
                count[pi] += count[pj]
                del count[pj]
            else:
                parent[pi] = pj
                df += count[pi] * count[pj]
                count[pj] += count[pi]
                del count[pi]                
        return df

    ans = [N*(N-1)//2]
    for a, b in bridges[:-1]:
        d = union(a, b)
        ans.append(ans[-1]-d)
    return ans[::-1]

if __name__ == '__main__':
    output = main()
    for v in output:
        print(v)
from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

for k in range(N):
    A[k] -= k

A.sort()


def get_pity_sum(x):
    pity_sum = 0
    for l in A:
        if A[x] - l >= 0:
            pity_sum += A[x] - l
        else:
            pity_sum += l - A[x]
    return pity_sum


if N % 2 == 1:
    print(min(get_pity_sum(int((N - 1) / 2)), get_pity_sum(int((N - 1) / 2 - 1)), get_pity_sum(int((N - 1) / 2 + 1))))
else:
    print(min(get_pity_sum(int(N / 2)), get_pity_sum(int(N / 2 - 1))))


### FIXED CODE ###

from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

for k in range(N):
    A[k] -= k

A.sort()


def get_pity_sum(x):
    pity_sum = 0
    for l in A:
        if A[x] - l >= 0:
            pity_sum += A[x] - l
        else:
            pity_sum += l - A[x]
    return pity_sum


if N % 2 == 1:
    c = get_pity_sum(int((N - 1) / 2))
    if N == 1:
        print(c)
    else:
        print(min(c, get_pity_sum(int((N - 1) / 2 - 1)), c + (A[int((N - 1) / 2) + 1] - A[int((N - 1) / 2)]) * 2, c + (A[int((N - 1) / 2)] - A[int((N - 1) / 2 - 1)]) * 2))
else:
    d = get_pity_sum(int(N / 2))
    print(min(get_pity_sum(int(N / 2)), d + (A[int(N / 2) + 1] - A[int(N / 2)]) * 2))
a

### FIXED CODE ###

b = input()
if b == "A":
	print("T")
elif b == "T":
	print("A")
elif b == "C":
	print("G")
elif b == "G":
	print("C")
x,y = map(int,input().split())

L = list(range(1,101))
if y != 0:
    L2 = list(map(int,input().split()))
    
    #print(L)
    for i in range(len(L2)):
        L.remove(L2[i])
        
#print(L)
#L = sorted(L)

#print(L)

t = len(L)//2

for j in range(len(L)):
#    print(t,L[t])
    if L[t] >= x:
#        print("L[t] >= x")
        if t == 0:
            print(L[t])
            break
        elif L[t-1] <= x:
            if abs(L[t]-x) < abs(L[t-1]-x):
                print(L[t])
                break
            else:
                print(L[t-1])
                break
        
        t = t//2
    else:
        if t == y-1:
            print(L[t])
            break
        elif L[t+1] >= x:
            if abs(L[t]-x) > abs(L[t+1]-x):
                print(L[t+1])
                break
            else:
                print(L[t])
                break
        t = t + (len(L)-t)//2
        
    

### FIXED CODE ###

x,y = map(int,input().split())

L = list(range(0,102))
if y != 0:
    L2 = list(map(int,input().split()))
    
    #print(L)
    for i in range(len(L2)):
        L.remove(L2[i])
        
#print(L)
#L = sorted(L)

#print(L)

t = len(L)//2

for j in range(len(L)):
#    print(t,L[t])
    if L[t] >= x:
#        print("L[t] >= x")
        if t == 0:
            print(L[t])
            break
        elif L[t-1] <= x:
            if abs(L[t]-x) < abs(L[t-1]-x):
                print(L[t])
                break
            else:
                print(L[t-1])
                break
        
        t = t//2
    else:
        if t == y-1:
            print(L[t])
            break
        elif L[t+1] >= x:
            if abs(L[t]-x) > abs(L[t+1]-x):
                print(L[t+1])
                break
            else:
                print(L[t])
                break
        t = t + (len(L)-t)//2
import sys

length = int(sys.stdin.readline())
num_seq = sys.stdin.readlines()

for i in range(1,length + 1):
    print(num_seq[length - i],end=' ')
print(num_seq[0],end='')


### FIXED CODE ###

import sys

length = int(sys.stdin.readline())
num_seq = sys.stdin.readline().split()

for i in range(1, length):
    print(num_seq[length - i], end=' ')
print(num_seq[0])
i = int(input())

while i != 0:
    i = i % 10
    if i == 0:
        print('pon')
    elif i == 1:
        print('pon')
    elif i == 2:
        print('hon')
    elif i == 3:
        print('bon')
    elif i == 4:
        print('hon')
    elif i == 5:
	print('hon')
    elif i == 6:
	print('pon')
    elif i == 7:
	print('hon')
    elif i == 8:
	print('pon')
    elif i == 9:
	print('hon')

    i = int(input())


### FIXED CODE ###

i = int(input())
i = i % 10
if i == 0:
    print('pon')
elif i == 1:
    print('pon')
elif i == 2:
    print('hon')
elif i == 3:
    print('bon')
elif i == 4:
    print('hon')
elif i == 5:
    print('hon')
elif i == 6:
    print('pon')
elif i == 7:
    print('hon')
elif i == 8:
    print('pon')
elif i == 9:
    print('hon')
import sys

array = []
for line in sys.stdin:
    array.append(line)

char = ["" for _ in range(len(array))]
for i in range(len(array)):
    char[i] = array[i:i+1]

count = [0 for _ in range(26)]
for c in char:
    for i in range(26):
        if c == chr(i+ord("A")) or c == chr(i+ord("a")):
            count[i] += 1

for i in range(26):
    print("{0} : {1}".format(chr(i+ord("a")), alp[i]))

### FIXED CODE ###

import sys

count = [0 for _ in range(26)]

for line in sys.stdin:
    array = line
    char = ["" for _ in range(len(array))]
    for i in range(len(array)):
        char[i] = array[i:i+1]
    for c in char:
        for i in range(26):
            if c == chr(i+ord("A")) or c == chr(i+ord("a")):
                count[i] += 1


for i in range(26):
    print("{0} : {1}".format(chr(i+ord("a")), count[i]))