Harryxun/stf_run huggingface dataset:
n = int(input())
#値の初期化
path = [None]*(n + 1)
adjacent_list = [[] for i in range(n+1)]

for i in range(n - 1):
    a, b, c = list(map(int,input().split()))
    adjacent_list[a].append([b,c])
    adjacent_list[b].append([a,c])
#ノード番号、そこまでの距離,検索済みの要素を受け取る。
def dfs(node_n ,distance,finished):
    #検索済みに追加
    finished.add(node_n)
    #そこまでの距離を代入。値の更新などは特にない（はず）
    path[node_n] = distance
    #対象ノードに対する隣接リストをforで回す
    for i in adjacent_list[node_n]:
        next = i[0]
        if next not in finished:
            #検索済みでなかった場合、そこまでのコストを追加し再帰
            dfs(next, distance + i[1],finished)

q,k = list(map(int, input().split()))
dfs(k, 0, set())
#各クエリへの返答
for i in range(q):
    s, g = list(map(int, input().split()))
    print(path[s] + path[g])

### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)
n = int(input())
#値の初期化
path = [None]*(n + 1)
adjacent_list = [[] for i in range(n+1)]

for i in range(n - 1):
    a, b, c = list(map(int,input().split()))
    adjacent_list[a].append([b,c])
    adjacent_list[b].append([a,c])
#ノード番号、そこまでの距離,検索済みの要素を受け取る。
def dfs(node_n ,distance,finished):
    #検索済みに追加
    finished.add(node_n)
    #そこまでの距離を代入。値の更新などは特にない（はず）
    path[node_n] = distance
    #対象ノードに対する隣接リストをforで回す
    for i in adjacent_list[node_n]:
        next = i[0]
        if next not in finished:
            #検索済みでなかった場合、そこまでのコストを追加し再帰
            dfs(next, distance + i[1],finished)

q,k = list(map(int, input().split()))
dfs(k, 0, set())
#各クエリへの返答
for i in range(q):
    s, g = list(map(int, input().split()))
    print(path[s] + path[g])
i=1
while True:
    x=int(input())
    if x==0:
        break
   print("Case {}: {}".format(i,x))
   i+=1
   


### FIXED CODE ###

i=1
while True:
    x=int(input())
    if x==0:
        break
    print("Case {}: {}".format(i,x))
    i+=1
a, b, x = map(int, input().split())
     
    if a <= x <= a + b:
        print("YES")
    else:
        print("NO")

### FIXED CODE ###

a, b, x = map(int, input().split())
 
n = x - a
 
if n >= 0 and b >=  n:
    print('YES')
else:
    print('NO')
from sys import stdin

x, n = [int(x) for x in stdin.readline().rstrip().split()]
if n > 0:
    P = [int(x) for x in stdin.readline().rstrip().split()]

memos = [False] * 102

for p in P:
    memos[p] = True

tgt = x
offset = 1
look_down = True
while True:

    if memos[tgt] == False:
        break
    if look_down:
        look_down = False
        tgt = tgt-offset
    else:
        look_down = True
        tgt = offset + offset
        offset += 1

print(tgt)


### FIXED CODE ###

from sys import stdin

x, n = [int(x) for x in stdin.readline().rstrip().split()]
if n > 0:
    P = [int(x) for x in stdin.readline().rstrip().split()]

    memos = [False] * 102

    for p in P:
        memos[p] = True

    tgt = x
    offset = 1
    look_down = True
    while True:

        if memos[tgt] == False:
            break
        if look_down:
            look_down = False
            tgt = x-offset
        else:
            look_down = True
            tgt = tgt + offset + offset
            offset += 1

    print(tgt)
else:
    print(x)
14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1

### FIXED CODE ###

import statistics
import math
n = int(input()) 
s = list(map(int,input().split()))
s.sort()

med_ind = len(s)//2 -1
#print(med_ind)
ans = s[med_ind+1]-s[med_ind]
#print(s[med_ind+1],s[med_ind])
print(ans)
N,K = map(int,input().split())
dic = {}
A = []
for _ in range(N):
    t,d = map(int,input().split())
    A.append([t,d])
A.sort(key = lambda x:x[1], reverse = True)
val = 0
set_ = set()
duplicated = collections.deque([])
for t,d in A[:K]:
    val += d
    if t in set_:
        duplicated.append(d)
    else:
        set_.add(t)
now = val + len(set_)**2

nx = collections.deque(A[K:])
ans = now
c = len(set_)
while len(set_) < K and nx:
    i,j = nx.popleft()
    if i in set_:
        continue
    d = duplicated.pop()
    diff = j-d + 2*c+1
    set_.add(i)
    now += diff
    ans =max(ans,now)
    c += 1
print(ans)


### FIXED CODE ###

import collections
N,K = map(int,input().split())
dic = {}
A = []
for _ in range(N):
    t,d = map(int,input().split())
    A.append([t,d])
A.sort(key = lambda x:x[1], reverse = True)
val = 0
set_ = set()
duplicated = collections.deque([])
for t,d in A[:K]:
    val += d
    if t in set_:
        duplicated.append(d)
    else:
        set_.add(t)
now = val + len(set_)**2

nx = collections.deque(A[K:])
ans = now
c = len(set_)
while len(set_) < K and nx:
    i,j = nx.popleft()
    if i in set_:
        continue
    d = duplicated.pop()
    diff = j-d + 2*c+1
    set_.add(i)
    now += diff
    ans =max(ans,now)
    c += 1
print(ans)
def start():
    n = int(input())
    arr = [int(v) for v in input().split(" ")]
    dp = [-1] * 100005
    def frog_1(i, arr):
        if i == n - 1:
            return 0
        if dp[i] != -1:
            return dp[i]
        left = abs(arr[i] - arr[i + 1]) + frog_1(i + 1, arr)
        right = float("inf")
        if i+2 < n:
            right = abs(arr[i] - arr[i + 2]) + frog_1(i + 2, arr)
        dp[i] = min(left, right)
        return dp[i]
    print(frog_1(0,arr), end="")



start()

# frog_1([10,10])

### FIXED CODE ###

import sys

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

dp = [sys.maxsize] * n
dp[0] = 0
for i in range(n):
    for j in (i + 1, i + 2):
        if j < n:
            dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]))
print(dp[n - 1], end="")
A, B = map(int, input())
if A == B:
  print("Draw")
elif A == 1:
  print("Alice")
elif B == 1:
  print("Bob")
else:
  if A < B:
    print("Bob")
  else:
    print("Alice")

### FIXED CODE ###

A, B = map(int, input().split())
if A == B:
  print("Draw")
elif A == 1:
  print("Alice")
elif B == 1:
  print("Bob")
else:
  if A < B:
    print("Bob")
  else:
    print("Alice")
l = list(map(int, input().split()))
a = l[0]
b = l[1]

ans1 = a + b
ans2 = a - b
ans3 = a * b

print(max(ans1, ans2, ans3)

### FIXED CODE ###

l = list(map(int, input().split()))
a = l[0]
b = l[1]

ans1 = a + b
ans2 = a - b
ans3 = a * b

print(max(ans1, ans2, ans3))
import functools
import math

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

if k > m:
    print("IMPOSSIBLE")
else:
    gcd = functools.reduce(math.gcd, a)
    if k % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


### FIXED CODE ###

import functools
import fractions

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

if k > m:
    print("IMPOSSIBLE")
else:
    gcd = functools.reduce(fractions.gcd, a)
    if k % gcd == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
def prime(n):
    nums = [True]*n
    primes = []
    for i in range(2,n):
        if nums[i]:
            primes.append(i)
            for j in range(2*i,n,i):
                nums[j] = False
    return primes

def prime_fac(n):
    fac = {}
    primes = prime(int(n**0.5)+1)
    for p in primes:
        while n%p==0:
            fac[p] = fac.get(p,0)+1
            n//=p
    if n > 1:
        fac[n] = 1
    return fac

def main():
    n = int(input())
    fac = prime_fac(n)

    ans = 0
    for i in fac.values():
        ct = 1
        while i >= ct*(ct+1)//2:
            ct += 1
            ans+=1
    print(ans)
main()

### FIXED CODE ###

import io,sys
sys.setrecursionlimit(10**6)

def main():
    a,b =map(int,sys.stdin.readline().rstrip().split())
    print(a*b)
main()
line1 = sys.stdin.readline().rstrip()
lista = []
for i in range(int(line1)):
    line2 = sys.stdin.readline().rstrip()
    lista.append(line2)
    #print(line1,lista)
def ans(lista):    
    listb = []
    hantei = "true"
    for i in lista:
        if i not in listb:
            listb.append(i)
        else:
            hantei = "false"
    for i in range(len(listb)-1):
        if listb[i][-1] != listb[i+1][0]:
            hantei = "false"
    if hantei == "true":
        return("Yes")
    else:
        return("No")
ans(lista)

### FIXED CODE ###

import io
import sys
def solve(lista):    
    listb = []
    hantei = "true"
    for i in lista:
        if i not in listb:
            listb.append(i)
        else:
            hantei = "false"
    for i in range(len(listb)-1):
        if listb[i][-1] != listb[i+1][0]:
            hantei = "false"
    if hantei == "true":
        return("Yes")
    else:
        return("No")
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    lista = []
    for i in range(int(line1)):
        line2 = sys.stdin.readline().rstrip()
        lista.append(line2)
    return (lista)

def main():
    a = readQuestion()
    answer = solve(a)
    print(answer)
    
if __name__ == '__main__':
    main()
C = [[int(c) for c in input.split()] for _ in range(3)]

if((C[0][0]-C[1][0]==C[0][1]-C[1][1]==C[0][2]-C[1][2])                    
        and(C[0][0]-C[2][0]==C[0][1]-C[2][1]==C[0][2]-C[2][2])):                  
    print("Yes")
else:
    print("No")

### FIXED CODE ###

C = []
for _ in range(3):
    c = list(map(int,input().split()))
    C.append(c)

if((C[0][0]-C[1][0]==C[0][1]-C[1][1])and(C[0][0]-C[1][0]==C[0][2]-C[1][2])
        and(C[0][0]-C[2][0]==C[0][1]-C[2][1])and(C[0][0]-C[2][0]==C[0][2]-C[2][2])
        and(C[0][0]-C[0][1]==C[1][0]-C[1][1])and(C[0][0]-C[0][1]==C[2][0]-C[2][1])
        and(C[0][0]-C[0][2]==C[1][0]-C[1][2])and(C[0][0]-C[0][2]==C[2][0]-C[2][2])):
    print("Yes")
else:
    print("No")
import math
a,b,c = list(map(int , input().split()))
A = math.sqrt(a)
B = math.sqrt(b)
C = math.sqrt(C)
sahen = A + B
if sahen < C:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b,c = list(map(int , input().split()))
x = c - a - b
X = x ** 2
Y = a * b * 4
Z = X - Y
if Z > 0 and x > 0:
    print("Yes")
else:
    print("No")
N = int(input())
S = list(input())

result = ''
for i in range(0,N):
  num = ord(S[i])
  new = chr(num+2)
  result += new

print(result)

### FIXED CODE ###

N = int(input())
S = list(input())

result = ''
for i in range(0,len(S)):
  num = ord(S[i])
  if num + N > 90:
    p = num + N - 90 + 64
  else:
    p = num + N
  new = chr(p)
  result += new

print(result)
import itertools

N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]

# 重複組み合わせ: nHr = n+r-1Cr を考える
ans = 0
for comb in itertools.combinations_with_replacement([i for i in range(1, N+2)], M):
    temp = 0
    for abcd in ABCD:
        a, b, c, d = abcd
        if comb[b-1] - comb[a-1] == c:
            temp += d
    if temp >= ans:
        ans = temp

    # print("comb: {}, temp: {}, ans: {}".format(comb, temp, ans))

print(ans)


### FIXED CODE ###

import itertools

N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]

# 重複組み合わせ: nHr = n+r-1Cr を考える
ans = 0
R = [i for i in range(1, M+1)]
# print(R)

for comb in itertools.combinations_with_replacement(R, N):
    temp = 0
    for abcd in ABCD:
        a, b, c, d = abcd
        if comb[b-1] - comb[a-1] == c:
            temp += d
    if temp >= ans:
        ans = temp

    # print("comb: {}, temp: {}, ans: {}".format(comb, temp, ans))

print(ans)
cmax=0
def crmv(c,istr):
    if len(istr)<=1:
        return c
    if not('1' in istr) or not('0' in istr):
        return c

    rv=0
    for i in range(len(istr)-1):
        if istr[i] != istr[i+1]:
            tstr=istr[:i]+istr[i+1+1:]
            r=crmv(c+2,tstr)
            if r>rv:
                rv=r
    return rv

istr=input()
print(crmv(0,istr))

### FIXED CODE ###

istr=input()
c0=0
c1=0
for ch in istr:
    if ch == '0':
        c0+=1
    else:
        c1+=1
print(min(c0,c1)*2)
x=input()
X=list('{}'.format(x))
A=sum(X)
print(A)

### FIXED CODE ###

x=input()
X=list('{}'.format(x))
a=[]
for i in range(len(X)):
    a.append(int(X[i]))
A=sum(a)
print(A)
n = int(input())
#a,b = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
#print(li)
num = 0

for i in range(n-4):
    if li[i] == li[i+1] ==li[i+2] == li[i+3]:
        li.pop(li[i+3])
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if li[i]+li[j]>li[k] and li[i]<li[j]+li[k] and li[i]+li[k]>li[j]:
                num += 1
print(num)


### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
li.sort()

num = 0
import bisect
for i in range(n):
    for j in range(i+1,n):
        num += bisect.bisect_left(li,li[i]+li[j])-(j+1)
print(num)
N=int(input())
ans=0
for i in range(N+1):
  count=0
  for j in range(i+1):
    if i%j==0:
      count+=1
  if i%2==1 and count==8:
    ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
ans=0
for i in range(1,N+1):
  count=0
  for j in range(1,i+1):
    if i%j==0:
      count+=1
  if i%2==1 and count==8:
    ans+=1
print(ans)
N, K = map(int, input().split())
H = map(int, input().split())
count = 0
for i in range(H):
  if i >= K:
    count += 1
print(count)


### FIXED CODE ###

N, K, *H = map(int, open(0).read().split())
li = [i for i in H if i >= K]
print(len(li))
N = int(input("N = "))
A = int(input("A = "))
B = int(input("B = "))
train = N * A
taxi = B
if train >= taxi:
    print(taxi)
else:
    print(train)

### FIXED CODE ###

N, A, B = (int(x) for x in input().split())
if(N * A < B):
  print(N * A)
else:
  print(B)
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

def solve(N,K,trees):
    trees.sort()

    diffs = []
    for i,h in enumerate(trees[:N-K+1]):
        min_h = h
        max_h = trees[i+K-1]
        print(min_h,max_h)
        diffs.append(max_h-min_h)

    print(min(diffs))
return

solve(N,K,trees)

### FIXED CODE ###

N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

def solve(N,K,trees):
    trees.sort()

    diffs = []
    for i,h in enumerate(trees[:N-K+1]):
        min_h = h
        max_h = trees[i+K-1]
        #print(min_h,max_h)
        diffs.append(max_h-min_h)

    print(min(diffs))
    return

solve(N,K,trees)
import re
number=input()
number=number.replace("?",".",100000)
length=len(number)

replica=number
while True:
    if replica[0]==".":
        replica=replica[1:]
    else:
        break
replen=len(replica)

print()


i=0
sumnum=0
while True:
    checknum=str(13*i+5)
    if len(checknum)<replen:
        i+=1
        continue
    g=length-replen 
    if checknum[-1*replen]!=number[-1*replen]:
        i+=1
        continue
    while len(checknum)<length:
        checknum="0"+checknum

    if len(checknum)>length:
        break
        
    m=re.match(number,checknum)
    if m:
        sumnum+=1
        sumnum=sumnum%1000000007
        print(checknum)
    i+=1
    
print(sumnum)

### FIXED CODE ###

#数字はnumberに格納
number=input()
length=len(number)


#調整のための数字
sizemin=1000000007

#まずはからのDPリストを用意
dp=[[0 for i in range(13)] for j in range(length)]

#1桁目の情報を入力
if number[-1]=="?":
    for i in range(10):
        dp[0][i]=1
else:
    dp[0][int(number[-1])]=1

#１０〜９０の、13modリストを作る
modlist=[(i*10)%13 for i in range(10)]


        
#二桁目からの情報を更新していく。
for n in range(length-1):
    #n桁目の情報があれば、次のようにn+1行目を更新。

    #n+1のくらいの数をchecknumとする
    checknum=number[-1*(n+1)-1]
#     print(checknum)

    #n+1の位が整数であれば
    if checknum!="?":
        
        #n[m]の値をn+1[m+(その整数)]にすればいい
        for m in range(13):
            dp[n+1][(m+modlist[int(checknum)])%13]=dp[n][m]
#         print(dp)
        
        
        
        
        
    #n+1のくらいが？の時
    else:
    #？が０〜９までの可能性を全て試す  
    
        for checknum in range(10):
            for m in range(13):
                dp[n+1][(m+modlist[int(checknum)])%13]=(dp[n+1][(m+modlist[int(checknum)])%13]+dp[n][m])%sizemin
#             print(dp)

    #modlistを更新
    modlist=[(j*10)%13 for j in modlist]


print(dp[-1][5])
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

if k - q > 0:
  res = ['Yes'] * n
else:
  res = ['No'] * n
  ans = [0] * n
  for i in range(len(a)):
    ans[a[i]-1] += 1
  for i in range(len(n)):
    if k - q + a[i] > 0:
      res[i] = 'Yes'
print('\n'.join(map(str, res)))

### FIXED CODE ###

n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

if k - q > 0:
  res = ['Yes'] * n
else:
  res = ['No'] * n
  ans = [0] * n
  for i in range(len(a)):
    ans[a[i]-1] += 1
  for i in range(n):
    if k - q + ans[i] > 0:
      res[i] = 'Yes'
print('\n'.join(map(str, res)))
from collections import deque
from collections import defaultdict
import heapq

N,M=map(int, raw_input().split())
cost=map(int, raw_input().split())

if M==N-1:
	print 0
	quit()

nl=[ [] for i in range(N) ]

for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)


d=[ None for i in range(N) ]
V=[ None for i in range(N) ]

group_cost=defaultdict(lambda: [])

def dfs(start):
	q = deque([]) 
	V[start]=start
	d[start]=0
	heapq.heappush(group_cost[start],cost[start])
	q.append(start)

	while len(q)!=0:
		v=q.pop()
		for i in nl[v]:
			if V[i] is None:
				V[i]=start
				q.append(i)
				heapq.heappush(group_cost[start],cost[i])

while None in V:
	i=V.index(None)
	dfs(i)



edges=(N-M-1)*2

ans=0
for i in group_cost.keys():
	ans+=heapq.heappop(group_cost[i])
	edges-=1

nokori_cost=[]
if edges==0:
	print ans
	quit()
else:
	nokori_cost=heapq.merge(*group_cost.values())

	if len(nokori_cost)<edges:
		print "Impossible"
		quit()

	for i in range(edges):
		ans+=heapq.heappop()
	print ans




### FIXED CODE ###

from collections import deque
from collections import defaultdict
import heapq

N,M=map(int, raw_input().split())
cost=map(int, raw_input().split())

if M==N-1:
	print 0
	quit()

nl=[ [] for i in range(N) ]

for i in range(M):
	x,y=map(int,raw_input().split())
	nl[x].append(y)
	nl[y].append(x)


d=[ None for i in range(N) ]
V=[ None for i in range(N) ]

group_cost=defaultdict(lambda: [])

def dfs(start):
	q = deque([]) 
	V[start]=start
	d[start]=0
	heapq.heappush(group_cost[start],cost[start])
	q.append(start)

	while len(q)!=0:
		v=q.pop()
		for i in nl[v]:
			if V[i] is None:
				V[i]=start
				q.append(i)
				heapq.heappush(group_cost[start],cost[i])

for i in range(N):
	if V[i] is None:
		dfs(i)


H = []

ans=0
for v in group_cost.values():
	v=sorted(v)
	ans+=v[0]
	H.append(v[1:])

nokori_cost=list(heapq.merge(*H))


if N < 2*(N-M-1):
	print "Impossible"
elif M == N-1:
	print 0
else:
	ans += sum(nokori_cost[:2*(N-M-1) - len(group_cost.keys())])
	print ans
n = int(input())
A = list(map(int,input().split()))
Alice_card = []
Bob_card = []
for i in range(n):
        if i%2 == 0:
                Alice_card.append(A[i])
        else:
                Bob_card.append(A[i])
Alice_total = sum(Alice_card)
Bob_total = sum(Bob_card)
print(abs(Alice_total - Bob_total))

### FIXED CODE ###

n = int(input()) % 500
a = int(input())
if a >= n:
    print('Yes')
else:
    print('No')
import math

line = input()
numList = [int(num) for num in line.split(' ')]
monsterHP,servalA = numList[0].numList[1]
print(math.ceil(monsterHP/servalA))


### FIXED CODE ###

import math
 
line = input()
numList = [int(num) for num in line.split(' ')]
monsterHP,servalA = numList[0],numList[1]
print(math.ceil(monsterHP/servalA))
import math
n,k=map(int,input().split())
l=list(map(int,input().split()))
ma=max(l)
if k>ma:
  print('IMPOSSIBLE')
else:
  gcd=l[0]
  l.remove(gcd)
  for x in l:
    gcd=math.gcd(gcd,x)
  if gcd==1:
    print('POSSIBLE')
  else:
    if k%gcd==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

### FIXED CODE ###

import fractions
n,k=map(int,input().split())
l=list(map(int,input().split()))
ma=max(l)
if k>ma:
  print('IMPOSSIBLE')
else:
  gcd=l[0]
  l.remove(gcd)
  for x in l:
    gcd=fractions.gcd(gcd,x)
  if gcd==1:
    print('POSSIBLE')
  else:
    if k%gcd==0:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')
H, W = map(int, input().split())
mas = []
deltags = []

for x in range(W):
    try:
        temp = list(input())
    except:
        pass
    if "#" in temp:
        mas.append(temp)
W = len(mas)
for y in range(H):
    deltag = False
    for x in range(W):
        if mas[x][y] == "#":
            break
        if x == W-1:
            deltag = True
    deltags.append(deltag)

for x in range(W):
    for y in range(H):
      if deltags[y]:
        mas[x][y] = "A"

for x in range(W):
    for y in range(H):
      while "A" in mas[x]:
        mas[x].remove("A")
    print("".join(mas[x]))


### FIXED CODE ###

H, W = map(int, input().split())
mas = []
deltags = []
for x in range(H):
    try:
        temp = list(input())
    except:
        pass
    if "#" in temp:
        mas.append(temp)

for x in range(len(mas[0])):
    deltag = False
    for y in range(len(mas)):
        if mas[y][x] == "#":
            break
        if y == len(mas)-1:
            deltag = True
    deltags.append(deltag)

for x in range(len(mas)):
    for y in range(len(mas[x])):
      if deltags[y]:
        mas[x][y] = "A"

try:
    x = 0
    while True:
        while "A" in mas[x]:
            mas[x].remove("A")
        print("".join(mas[x]))
        x += 1
except:
    pass
N, a, b = map(int, input().split())
num = b - a
if num%2 == 0:
    half = num//2
    print(half)
else:
    edge = min(N-a, b-1)
    print(min((b-a-1)//2), edge)

### FIXED CODE ###

N, a, b = map(int, input().split())
num = b - a
if num%2 == 0:
    half = num//2
    print(half)
else:
    edge = min(N-a, b-1)
    edge2 = min((b-a-1)//2+a, (b-a-1)//2+N-b+1)
    print(min(edge2, edge))
n, m ,c = map(int,input().split())
b = list(map(int,input().split()))

for i in range(n):
	a = list(map(int,input().split()))
    
x=0

for i in range(n):
	if ((sum(a[i]*b[i] for j in range(m)) + c)>0):
		x+=1
print(x)

### FIXED CODE ###

n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for _ in range(n):
	a=list(map(int,input().split()))
	if sum(a[i]*b[i] for i in range(m))+c>0: ans+=1
print(ans)
n=raw_input()
A=map(int,raw_input.split())
q=raw_input()
m=map(int,raw_input.split())

def solve(c, m):
  if m == 0:
    return 1
  if c >= n or sum(A)<m:
    return 0
  res = solve(c + 1, m) or solve(c + 1, m - A[c])
  return res

for i range(0,q):
  if solve(0,m[i]):
    print 'yes'
  else:
    print 'no'

### FIXED CODE ###

n=int(raw_input())
A=map(int, raw_input().split())
q=int(raw_input())
m=map(int, raw_input().split())

def solve(j, m):
  if m == 0:
    return 1
  if j >= n or m > sum(A):
    return 0
  res = solve(j + 1, m) or solve(j + 1, m - A[j])
  return res

for i in range(0,q):
  if solve(0,m[i]):
    print "yes"
  else:
    print "no"
a = int(ipnut())
s = str(input())
if a >= 3200:
    print(s)
else:
    print('red')

### FIXED CODE ###

a = int(input())
s = str(input())
if a >= 3200:
    print(s)
else:
    print('red')
A,B=input().sp;it()
print(int(A)-int(B)*2)


### FIXED CODE ###

A,B=input().split()
ans=int(A)-int(B)*2
if ans > 0:
  print(ans)
else:
  print(0)
n, x = map(int, input().split())
l = [int(x) for x in input().split()]
bounds = 1
coodinate = 0
for i in range(n+1):
    coodinate += l[i]
    if coodinate > x:
        break
    bounds += 1
print(bounds)

### FIXED CODE ###

n, x = map(int, input().split())
l = [int(x) for x in input().split()]
bounds = 1
coodinate = 0
for i in l:
    coodinate += i
    if coodinate > x:
        break
    bounds += 1
print(bounds)
import math

def lcm(x, y):
    return (x*y)//math.gcd(x, y)

N = int(input())
a = list(map(int, input().split()))
lcm2 = 1
for i in range(len(a)):
    lcm2 = lcm(a[i], lcm2)
lcm2 -= 1
f = 0
for i in range(len(a)):
    f += lcm2%a[i]
print(f)

### FIXED CODE ###

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(x, y):
    return (x*y)//gcd(x, y)

N = int(input())
a = list(map(int, input().split()))
lcm2 = 1
for i in range(N):
    lcm2 = lcm(a[i], lcm2)
lcm2 -= 1
f = 0
for i in range(N):
    f += lcm2%a[i]
print(f)
X,n = map(int,input().split(" "))
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
 print(Base_10_to_n(X, n))

### FIXED CODE ###

X,n = map(int,input().split(" "))
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
a=Base_10_to_n(X, n)
print(len(str(a)))