peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, k = [int(_) for _ in input().split()]

ans = 0
for i in range(k, n+2):
    ans += (((n + (n-i+1)) * i) / 2) - ((i-1) * i) / 2 + 1
    ans = ans % (10**9+7)
print(int(ans))
# Judge status: Accepted
def resolve():
    A = list(input())
    B = list(input())
    C = list(input())
    A.reverse()
    B.reverse()
    C.reverse()
    d = {"a": A, "b": B, "c": C}
    turn = "a"
    while True:
        if len(d[turn]) == 0:
            print(turn.upper())
            return
        _next = d[turn].pop()
        turn = _next
        



if '__main__' == __name__:
    resolve()
# Judge status: Accepted
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
amod4=list(map(lambda x:x%4, a))
d=Counter(amod4)
if n-d[0]-d[2]<d[0]+1:
  print('Yes')
elif d[2]==0 and n==2*d[0]+1:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    W, H, x, y = mi()

    s = W*H/2
    cut = 1 if W/2 == x/1 and H/2 == y/1 else 0

    print(s, cut)

    return

main()
# Judge status: Wrong Answer
from sys import stdin

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

prices = sorted(prices)

sum = 0
for i in range(0, K):
    print(prices[i])
    sum += prices[i]
print(sum)
# Judge status: Wrong Answer
x = input()
if x == 0:
    print(1)
elif x == 1:
    print(0)
# Judge status: Wrong Answer
N = int(input())
S = [input() for i in range(N)]
print(len(S))
# Judge status: Accepted
N, K = [int(i) for i in input().split()]
count = [0]*N

for _ in range(K):
  d = int(input())
  for v in input().split():
    j = int(v) - 1
    count[j] += 1
sunsuke = 0 
for i in count:
  if i == 0:
    sunsuke += 1
print(sunsuke)
# Judge status: Accepted
import math

N = int(input())
for i in range(N, 0, -1):
    if math.sqrt(i) == int(math.sqrt(i)):
        print(i)
        break
# Judge status: Accepted
L,R=map(int,input().split())

result=float("inf")
R=min(R,L+4038)
for i in range(L,R+1):
  for j in range(i+1,R+1):
    result=min(result,i*j%2019)
#if R-L>= 2019:
#  result=0
#else:
#  l=L%2019
#  r=R%2019
#  for i in range(l,r+1):
#    for j in range(i+1,r+1):
#      result=min(result,i*j%2019)

print(result)
# Judge status: Wrong Answer
n,x=map(int,input().split())
l=list(map(int,input().split()))
k=0
cnt=0
for i in range(n):
    k += l[i]
    if k>x:
        print(i+1)
        exit()
    else:
        cnt += 1
        continue
print(cnt)
# Judge status: Accepted
A, B = map(int, input().split())
if A <= 0 and B >= 0:
  print('Zero')
elif A > 0 and B > 0:
  print('Positive')
else:
  if (B-A)%2 != 0:
    print('Positive')
  else:
    print('Negative')
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
i = 0
ans = []
if N == 0:
    print(0)
    sys.exit()
while N != 0:
    i += 1
    if N % 2 == 0:
        N //= 2
        ans.append("0")
    else:
        if i % 2 == 1:
            N -= 1
            N //= 2
            ans.append("1")
        else:
            N += 1
            N //= 2
            ans.append("1")
print("".join(ans[::-1]))
# Judge status: Accepted
k, x = map(int, input().split())
if 500 * k >= x:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
from fractions import gcd
A, B = map(int, input().split())
print(int(A*B//gcd(A,B)))
# Judge status: Wrong Answer
import numpy as np
import math 
N, K=map(int,input().split())
A2 = np.zeros(N)
A = list(map(int,input().split()))
#A = list(map(lambda x: x -1 , A))
current_town = 0



i=0
while i<K:
    current_town = A[current_town]-1
    i=i+1
    if  A2[current_town] != 0:
        cycle = i - A2[current_town] 
        i = K - (K-i) % cycle
        break
    else:
        A2[current_town] = i

while i<K:
    current_town = A[current_town]-1
    i=i+1

print(current_town+1)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
l=[0]
r=[0]
ans=0
from  fractions import gcd
for i in range(n-1):
    l.append(gcd(l[i],a[i]))
    r.append(gcd(r[i],a[-1]-i))
for i in range(n):
    ans=max(ans,gcd(l[i],r[-1-i]))

print(ans)
# Judge status: Accepted
#nyuuryoku
food=[]
for i in range (5):
  food.append(int(input()))
time = 0

#1keta toru 10 watte amari dasu
#amari wo dasu
machi = []
for i in range (5):
  if food[i]%10 == 0:
    time += food[i]
  else:
    time += food[i]+(10-(food[i]%10))
    machi.append(10-(food[i]%10)) 

if len(machi) == 0:
  print(time)
else:
  print(time-max(machi))
# Judge status: Wrong Answer
import re
word = '?tc????'.replace('?','.')
substring = 'coder'
N = len(word) - len(substring)
found = False
for i in range(N+1):
    regexp = re.compile(word[i:i+len(substring)])
    if regexp.search(substring):
        found = True
        res = word[0:i] + substring
        print(res.replace('.','a'))

if found == False:
    print('UNRESTORABLE')
# Judge status: Accepted
s = list(str(input()))
n = len(s)
cnt = 0
for i in range(n):
    if (i % 2) != int(s[i]):
        cnt += 1
print(min(cnt, n - cnt))
# Judge status: Wrong Answer
n=input()

b=n.upper()
print(b)
# Judge status: Wrong Answer
N = int(input())

import sys
if N & 1:
    print(0)
    sys.exit()

ans = 0
N /= 2
while N != 0:
    ans += N // 5
    N /= 5

print(ans)
# Judge status: Accepted
class mystr:
    def __init__(self,string):
        self.value = string

    def isEven(self):
        l = len(self.value)
        if (not l & 1) and self.value[:l//2] == self.value[l//2:]:
            return True
        else:
            return False

    def pop(self):
        l = len(self.value)
        self.value = self.value[:l-1]

s = mystr(input())
l = len(s.value)
for i in reversed(range(l)):
    s.pop()
    if s.isEven():
        print(i)
        break
# Judge status: Accepted
x = int(input())
k = 2
while k*x%360!=0:
    k += 1
print(k)
# Judge status: Accepted
N, M = sorted(map(int, input().split()))
if N == 1:
    if M == 1:
        print(1)
    elif M == 2:
        print(0)
    else:
        print(M - 2)
elif N == 2:
    if M == 2:
        print(0)
    else:
        print(0)
else:
    print((N - 2) * (M - 2))
# Judge status: Wrong Answer
a,b,c=list(map(int ,input().split()))
ans_range=range(a,b)
if(c in ans_range):
	print("Yes")
else:
	print("No")
# Judge status: Accepted
n, k = map(int, input().split())
s = list(input())
s[k - 1] = chr(ord(s[k - 1]) + 32)
print(''.join(s))
# Judge status: Accepted
import math
N=int(input())
a = [int(input()) for _ in range(N)]
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // math.gcd(ans, a[i])
print(ans)
# Judge status: Wrong Answer
n, a, b, c, d = map(int, input().split())
s = input()
if "##" in s[min(a,b):max(c,d)]:
    print("No")
    exit()
if c < d:
    print("Yes")
else:
    if "..." in s[b-2:c]:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
n = int(input().replace(" ", ""))
print("Yes" if isinstance(n **.5, int) else "No")
# Judge status: Accepted
n, m = map(int, input().split())

a, b = [0] * m, [0] * m
root_i = [False] * n
root_n = [False] * n
for i in range(m):
    a[i], b[i] = map(int, input().split())

for i in range(m):
    if a[i] == 1:
        root_i[b[i]] = True
    elif b[i] == n:
        root_n[a[i]] = True

for i in range(n):
    if root_i[i] == True and root_n[i] == True:
        print("POSSIBLE")
        exit()
    
print("IMPOSSIBLE")
# Judge status: Accepted
s = input()

ac = s.count('a')
bc = s.count('b')
cc = s.count('c')

if max([ac, bc, cc])-min([ac, bc, cc])<=1:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N = int(input())
A=list(map(int,input().split()))
A.sort()
st = sum(A[N:2*N])
ans = 0
for i in range(N):
    ans +=A[-2*i]
print(max(st,ans))
# Judge status: Accepted
n = int(input())

words = set()
w = ''
ok = True
for i in range(n):
  nw = input()
  if nw in words:
    ok = False
    break
  words.add(w)
  if w and w[-1] != nw[0]:
    ok = False
  w = nw

if ok:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N = int(input().strip())
print(N%1000)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
res = 0
for i in range(a, n+1):
  s = str(i)
  sum = 0
  for j in s:
    sum += int(s)
  res += sum
print(res)
# Judge status: Accepted
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    N,M=pin()
    ans=[0]*N
    for i in range(M):
        a,b=pin()
        ans[a-1]+=1
        ans[b-1]+=1
    for an in ans:
        print(an)
#%%submit!
resolve()
# Judge status: Accepted
a, b = map(int, input().split())
if (a+b) % 2 == 0:
  print((a + b) // 2)
else:
  print("IMPOSSIBLE")
# Judge status: Accepted
N = int(input())
if N == 0:
    print(1)
else:print(0)
# Judge status: Accepted
def q3():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = [0] * N
    for i, a in enumerate(A):
        ans[a-1] = i + 1
    print(' '.join([str(i) for i in ans]))


if __name__ == '__main__':
    q3()
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline
    x, y = [int(x) for x in input().strip().split()]
    dist = abs(abs(x) - abs(y))
    if x + dist == y:
        print(dist)
    elif - x + dist == y or - (x + dist) == y:
        print(dist + 1)
    elif - (- x + dist) == y:
        print(dist + 2)

if __name__ == '__main__':
    main()
# Judge status: Accepted
X,N=list(map(int, input().split(' ')))
if N>0:
    p=list(map(int, input().split(' ')))
else:
    p=[]
A=0
A2=400
A3=0
for i in range(0,200):
    if i in p:
        v=0
    else:
        A=abs(i-X)
        if A<A2:
            A2=A
            A3=i
        else:
            print(A3)
            exit()
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ave = sum(a)//n
b = c = 0
for i in range(n):
    b += (a[i]-ave)**2
    c += (a[i] - ave - 1)**2
print(min(b,c))
# Judge status: Wrong Answer
import math

N,D = map(int,input().split())
cnt = 0
for n in range(N):
    a,b = map(int,input().split())
    if math.sqrt(a**2 + b**2)-D>=0:
        cnt+=1
print(cnt)
# Judge status: Wrong Answer
n,m,x,y=map(int,input().split())
l_x=sorted(list(map(int,input().split())))
l_y=sorted(list(map(int,input().split())))
print("No War" if  l_y[0] - l_x[-1] >= 1 else "War")
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())

H = H
W = W
count = 0
paint = 0
while paint<N:
  if W>H:
    count +=1
    paint += W
    H-=1
  else:
    count +=1
    paint += H
    W -=1
else:
  print(count)
# Judge status: Wrong Answer
A,B=map(int, input().split())
if A > 10 or B > 10 or A+B > 16:
  print(":(")
else:
  print("Yay!")
# Judge status: Accepted
n = int(input())
import math as m
if n < 4:
  print(1)
  exit(0)
  
perfect = 1
for b in range(2,int(n**0.5)+1):
  p = int(m.log(n,b))
  x = b**(p+1)
  if x > n:
    x = b**p
  perfect = max(perfect,x)
  #print(b,x)
  if perfect == n:
    break

print(perfect)
# Judge status: Wrong Answer
n,c,k = map(int,input().split())
t = list(int(input()) for i in range(n))
t = sorted(t)

leave = t[0] + k
cnt = 1
ans = 0

for i in range(1,n):
    if cnt == 0 or leave < t[i]:
        ans += 1
        cnt = 1
        leave = t[i] + k
    else:
        cnt += 1

print(ans+1)
# Judge status: Accepted
from itertools import combinations_with_replacement

def main():
  N, M, Q = map(int, input().split())
  abcd = [list(map(int, input().split())) for x in range(Q)]
  ans = 0
  for x in combinations_with_replacement(range(1, M+1), N):
    r = 0
    for a,b,c,d in abcd:
      if x[b-1] - x[a-1] == c:
        r += d
    ans = max(ans,r)
  print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import heapq

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

q = []
for i in range(n):
    q.append(list(map(int, input().split())))

heapq.heapify(q)

cnt = 0
while cnt < k:
    a, b = heapq.heappop(q)
    cnt += b
    
print(a)
# Judge status: Accepted
S,W = list(map(int,input().split()))
print("safe" if S>W else "unsafe")
# Judge status: Wrong Answer
import sys


def input():
    return sys.stdin.readline().strip()


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

odd = sum([a % 2 for a in A])
even = len(A) - odd

ans = (2 ** even) * (2 ** (odd - 1))

print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))
i = A.index(1)
ans = (i+1)//2
ans += ((N-i-1-(i&1))+1)//2
print(ans)
# Judge status: Accepted

N,W=map(int,input().split())
dp=[0]*(W+1)
L = sorted([list(map(int,input().split())) for i in range(N)])
s=0
 
for w, v in L:
    s+=w
    for j in range(min(W,s),w-1,-1):
        if dp[j-w]+v > dp[j]: dp[j]=dp[j-w]+v
    
print(max(dp))
# Judge status: Accepted
a = []
for i in range(5):
    a.append(int(input()))
p = 10
for i in range(5):
    if a[i] % 10 != 0:
        p = min(p,a[i]%10)
ans = 0
for i in range(5):
    if a[i] % 10 != 0:
        if a[i] % 10 == p:
            ans += a[i]
            p = 10
        else:
            ans += a[i] - a[i] % 10 + 10
    else:
        ans += a[i]
print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())
d=b*2+1

c=a/d
if c>b:
  print(c+1)
else:
  print(c)
# Judge status: Wrong Answer
A, B, N = map(int, input().split())

maxFloor = 0

def floor(x):
    num = int(x // 1)
    return num

check = floor(A * (B - 1) / B) - A * floor((B - 1) / B)
print(check)
# Judge status: Accepted
n = int(input())
s_1 = input()
word_list = [s_1]
target = s_1[-1]
frag = "Yes"
for i in range(n-1):
  s = input()
  if s in word_list :
    frag = "No"
  if target == s[0]:
    target = s[-1]
  else:
    frag = "No"
 
  word_list.append(s)
    
print(frag)
# Judge status: Wrong Answer
s=input()
t=input()

l=""
i=0
j=0
while i < len(s):
  l+=s[i]
  i+=1
while j < len(t):
  l+=t[j]
  j+=1
print(l)
# Judge status: Wrong Answer
l,r,n=map(int,input().split())
print((r-l)//n)
# Judge status: Wrong Answer
N = int(input())
MOD = 1e+9 + 7
a = [int(i) for i in input().split()]

b = [0 for _ in range(60)]

for i in a:
  for j in range(60):
    b[j] += (i >> j) & 1

ans = 0
for i, j in enumerate(b):
  second = 1
  for _ in range(i):
    second *= 2
    second %= MOD
  ans += (j * (N - j)) * second
  ans %= MOD
  
print(int(ans))
# Judge status: Accepted
n, k = map(int, input().split())
lst = list(map(int, input().split()))
cst = [float('inf')] * n
cst[0] = 0
for _ in range(0, n):
    m = min(n-(_+1),k)
    for i in range(0, m+1):   
      cst[_+i] = min(cst[_] + abs(lst[_+i] - lst[_]),cst[_+i])
print(cst[n-1])
# Judge status: Wrong Answer
from itertools import accumulate

N = int(input())
A = list([int(x) for x in input().split()])

count = 0
ironbar = list(accumulate(A))

print(ironbar)

i = 0
j = len(A) - 1

while i + 1 < j:
    left = ironbar[i]
    right = ironbar[j] - ironbar[i]
    if left > right:
        j = (i+j) // 2
    elif left < right:
        i = (i+j) // 2
    else:
        print(0)
        exit()

print(abs(ironbar[i]-ironbar[j]))
# Judge status: Accepted
x = list(input())
if 'N' in x and 'S' in x:
  if 'E' in x and 'W' in x:
    print('Yes')
  elif 'E' not in x and 'W' not in x:
    print('Yes')
  else:
    print('No')
elif 'N' not in x and 'S' not in x:
  if 'E' in x and 'W' in x:
    print('Yes')
  elif 'E' not in x and 'W' not in x:
    print('Yes')
  else:
    print('No')
else:
  print('No')
# Judge status: Wrong Answer
S = int(input())
mod = 10**9 + 7

dp = [0]*(S+10)
dp[0] = 1

for i in range(S-2):
  for j in range(3, 10):
    dp[i+j] += dp[i]
    dp[i+j] %= mod

print(dp[S])
# Judge status: Wrong Answer
num = int(input())

hap1000 = num/500
hap5    = (num-hap1000*500)/5

print(int(1000*hap1000+5*hap5))
# Judge status: Wrong Answer
s = input()

ans1 = True
ans2 = True

if "N" in s:
    ans1 = "S" in s
if "W" in s:
    ans2 = "E" in s

print("Yes" if ans1 & ans2 else "No")
# Judge status: Accepted
from math import gcd
n = int(input())
ans = 0

for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            ans += gcd(a,gcd(b,c))
print(ans)
# Judge status: Wrong Answer
N = 100

x = N * 800

y = 0

for i in range(N+1):
  if i % 15 == 0:
    y = y + 200
    
print(x-y)
# Judge status: Accepted
n = int(input())
item = {}
for i in range(n):
  it = input()
  item[it] = 'y'
print(len(item))
# Judge status: Accepted
n = int(input())
a = 0
for i in range(n+1):
    for j in range(n+1-i):
        if i*4 + j*7 == n:
            a += 1
if a >= 1:
    print("Yes")     
else:
    print("No")
# Judge status: Accepted
N,M=map(int,input().split())
C=[0]*N
for i in range(N):
  C[i]=tuple(map(int,input().split()))
  
C.sort(key=lambda x:x[0])
cnt=0
cost=0

for i in range(N):
  #print(C[i][0],C[i][1])
  if cnt+C[i][1] < M:
    #print(cnt,cost)
    cnt += C[i][1]
    cost += C[i][0]*C[i][1]
  else:
    #print(cnt,cost)
    cost += (M-cnt)*C[i][0]
    break
    
print(cost)
# Judge status: Wrong Answer
N = int(input())

t_0 = 0
x_0 = 0
y_0 = 0
flag = True

for _ in range(N):
    t,x,y = map(int,input().split())

    if abs(x-x_0) + abs(y-y_0) <= abs(t-t_0) and (abs(x-x_0)+abs(y-y_0))%2 == abs(t-t_0)%2:
        continue
    flag = False

print("Yes" if flag else "No")
# Judge status: Accepted
H=int(input())
W=int(input())
N=int(input())
if H<W:
    H,W=W,H
ans = N // H
if N % H > 0: ans += 1
print(ans)
# Judge status: Accepted
from math import gcd
n=int(input())
a=int(input())

for i in range(n-1):
    b=int(input())
    g=gcd(a,b)
    a=a*b//g

print(a)
# Judge status: Accepted
N, K = 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(len(Base_10_to_n(N, K)))
# Judge status: Wrong Answer
import numpy as np
N=int(input())
S=str(input())
s_list = "abcdefghijklmnopqrstuvwxyz"
max_count = 0
for i in range(1,N-1): # N字目で切った場合
  count_list = np.zeros(26)
  for k in range(i):
    if S[k] in S[i:len(S)-1]:
      count_list[s_list.index(S[k])] = count_list[s_list.index(S[k])] + 1
#  print(len([1 for x in count_list if x>0]))
  if max_count < len([1 for x in count_list if x>0]):
    max_count = len([1 for x in count_list if x>0])

print(max_count)
# Judge status: Accepted
l = [list(map(int, input().split()))]
i = 0
while (1):
    a, b, c = map(int,l[i])
    if (a % 2 == 1 or b % 2 == 1 or c % 2 == 1):
        print(i)
        break
    t = [b / 2 + c / 2, c / 2 + a / 2, a / 2 + b / 2]
    if (t in l):
        print(-1)
        break
    l.append(t)
    i+=1
# Judge status: Accepted
a=input()
b=input()
dic_a={}
dic_b={}
for i in a:
    if i not in dic_a:
        dic_a[i]=1
    else:
        dic_a[i] += 1
for i in b:
    if i not in dic_b:
        dic_b[i]=1
    else:
        dic_b[i] += 1


print("Yes" if (sorted(dic_a.values())==sorted(dic_b.values())) else "No" )
# Judge status: Accepted
a,b,x = map(int, input().split())

if a + b < x :
    print("NO")

elif a > x :
    print("NO")

else :
    print("YES")
# Judge status: Wrong Answer
S = str(input())
count = 0
for x in range(len(S)):
    if S[0] == 'R' and x == 0:
        count = count + 1
    elif S[x] == 'R' and S[x - 1] == 'R':
        count = count + 1
    elif S[x] == 'S':
        continue

if count >= 0:
    print(count)
else:
    print(0)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
d={}
ans="YES"
for i in range(n):
  if(a[i] in d):
    ans="NO"
    break
  else:
    d[a[i]]=1
print(ans)
# Judge status: Wrong Answer
import numpy as np
def plus(n):
    return n+1

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

A = np.array(A)
A = A.argsort()
ans = [ n+1 for n in A]
for i in ans:
    print(i,end="")
# Judge status: Accepted
from math import ceil,floor
ansc,ansf = 0,0
n = int(input())
a = list(map(int,input().split()))
 
gp = sum(a)/len(a)
c = ceil(gp)
f = floor(gp)

for i in a:
  ansc += (i-c)**2
  ansf += (i-f)**2
  
print(min(ansc,ansf))
# Judge status: Accepted
n = int(input())

for i in range(50001):
	if n == int(i*1.08):
		print (i)
		exit()
print (":(")
# Judge status: Accepted
S=raw_input()
print "x"*len(S)
# Judge status: Wrong Answer
from collections import deque

s = input()
q = int(input())

Q = []
for _ in range(q):
    Q.append(list(map(str, input().split())))

S = deque([s])
for i in Q:
  if int(i[0]) == 1:
    S.reverse()
  else:
    if int(i[1]) == 1:
      S.appendleft(i[2])
    elif int(i[1]) == 2:
      S.append(i[2])
      
print(''.join(S))
# Judge status: Wrong Answer
def main():
    def reviewSum(n):
      sum = 0
      while n > 0:
          sum += n % 10
          n = n // 10
      return sum
    
    N, A, B = map(int, input().split())
    total = 0
    for i in range(N):
        sum = reviewSum(i)
        if sum >= A and sum <= B:
          total += i
    print(total)
main()
# Judge status: Accepted
import itertools
def main():

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

    a = list(itertools.permutations([i for i in range(1, N+1)]))
    k, l = 0, 0
    for i in range(len(a)):
        if list(a[i]) == P: k = i
        if list(a[i]) == Q: l = i
    return abs(k-l)

if __name__ == '__main__':
    print(main())
# Judge status: Wrong Answer
s = input()

if s=="Sunny":
  print("Cloudy")
elif s=="Cloudy":
  print("Cloudy")
else:
  print("Sunny")
# Judge status: Accepted
n, k = map(int, input().split())
h = []
for i in range(n):
  h_ = int(input())
  h.append(h_)
h.sort()
#print(h)
ans = float('inf')
for i in range(n-k+1):
  ans = min(ans, h[i+k-1]-h[i])
print(ans)
# Judge status: Wrong Answer
import sys
import math

class cin():
    def getInt():
        return int(sys.stdin.readline().rstrip())
    def getString():
        return sys.stdin.readline().rstrip()

N = cin.getInt()
A = [list(map(int,cin.getString().split())) for i in range(N - 1)]

for i in range(N):
    t = 0
    for j in range(i,N - 1):
        if t <= A[j][1]:
            t = A[j][1] + A[j][0]
        else:
            t = (1 + t // A[j][2]) * A[j][2] + A[j][0]
    print(t)
# Judge status: Wrong Answer
a,b,c,x = map(int, input().split())

if abs(c-a) <= x or (abs(c-b) <= x and abs(b-a) <= x):
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
l=sorted(list(set(input())))
#print(l)
flag=1
for i in range(len(l)):
    if not(ord(l[i])==i+97):
        print(chr(i+97))
        flag=0
        break
if flag==1:
    print("None")
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
m=0
for i in range(N-1):
  b=A[i]
  j=i+b+1
  for k in range(j,N):
    if k-A[k]>0:
      pass
    else:
      if abs(k-i)==A[i]+A[k]:
        m+=1
print(m)
# Judge status: Accepted
n = int(input())
a_list = list(map(int, input().split()))

money = 1000
num = 0

for i in range(len(a_list)-1):
    if a_list[i] <= a_list[i+1]:
        num += money // a_list[i]
        money -= num * a_list[i]

        money += num * a_list[i+1]
        num = 0

print(money)
# Judge status: Wrong Answer
N = int(input())
re = 0
for i in range(N):
    if i % 3 == 0 or i % 5 == 0:
        re = re + 0
    else:
        re = re + i
print(re)
# Judge status: Accepted
s = input()
if s=='Sunny': print('Cloudy')
elif s=='Cloudy': print('Rainy')
else: print('Sunny')
# Judge status: Accepted
x, a, b = map(int, input().split())
if b - a <= 0:
    print("delicious")
elif 0 < b - a <= x:
    print("safe")
else:
    print("dangerous")
# Judge status: Accepted
N=int(input())
S=input()
if S[:(N//2)]==S[(N//2):]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
A = [0]*5
for i in range(5):
	A[i] = int(input())

mi = 10
sm = 0
min_r = 0
for i in range(5):
	d = A[i] // 10
	r = A[i] % 10
	if r == 0:
		sm += (d)*10
	else:
		sm += (d+1)*10

	if r != 0 and min(mi,r) < mi:
		mi = min(mi,r)
		idx = i
		min_r = r
		min_d = d
	#print(min_r,min_d,i,sm)


print(sm - (10-min_r))