peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import fractions
n,x=map(int,input().split())
x_list=list(map(int,input().split()))
x_list.append(x)

x_list.sort()
x_sa=[]
a=x_list[1]-x_list[0]
for i in range(1,n):
  b=x_list[i+1]-x_list[i]
  a=fractions.gcd(a,b)
print(a)
# Judge status: Wrong Answer
from collections import defaultdict as dd
n = input()
def num_bill(n):
    n = str(n)
    ans = sum([int(num) for num in n])
    return ans

buyer = num_bill(n)
buyer_bill = dd(int)
for i, s in enumerate(n):
    buyer_bill[i] = int(s)
#print(buyer_bill)
seller = 0
for i in range(len(n) - 1, -1, -1):
    if buyer_bill[i] > 5:
        buyer -= buyer_bill[i] - 1
        buyer_bill[i-1] += 1
        seller += 10 - buyer_bill[i]
        buyer_bill[i] = 0

    #print(buyer_bill, buyer, seller)
#print(buyer_bill)
print(buyer + seller)
# Judge status: Wrong Answer
N,M = map(int,input().split())
"""
mat = [[0]*M for _ in range(N)]
dx = [-1,0,1,-1,0,1,-1,0,1]
dy = [1,1,1,0,0,0,-1,-1,-1]
for i in range(N):
    for j in range(M):
        for k in range(9):
            if 0 <= i+dy[k] <= (N-1) and 0 <= j+dx[k] <= (M-1):
                mat[i+dy[k]][j+dx[k]] += 1
print(mat)
"""
if N == 1 or M == 1:
    print(N*M-2)
else:
    print(N*M-2*(N+M-2))
# Judge status: Accepted
n = int(input())

plus,minus = [],[]
for i in range(n):
    a,b = map(int,input().split())
    plus.append(a+b)
    minus.append(a-b)

plus.sort()
minus.sort()

print(max(plus[-1]-plus[0],minus[-1]-minus[0]))
# Judge status: Accepted
H, N = map(int, input().split())
A_list = list(map(int, input().split()))

sum_A = 0

for i in range(len(A_list)):
    sum_A += A_list[i]

if sum_A < H:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
y = [int(z) for z in input().split()]
l = [int(z) for z in input().split()]
d = [0]*(y[0]+1)
c = 0
for i in range(1,y[0]+1):
      d[i] = d[i-1]+l[i-1]
      if (d[i]<=y[1]):
            c+=1
print(c)
# Judge status: Accepted
n,m=map(int,input().split())
costs=[]
for i in range(n):
  a,b=map(int,input().split())
  costs.append([a,b])
costs=sorted(costs, key=lambda student: student[0])
pointer=0
ans=0
while m>0:
  costs[pointer][1]-=1
  ans+=costs[pointer][0]
  m-=1
  if costs[pointer][1]==0:
    pointer+=1
print(ans)
# Judge status: Wrong Answer
n,m,x=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
ans=[]
for bit in range(1>>n):
  total=0
  skill=[0]*m
  for i in range(n):
    if bit & (1>>i):
      total+=a[i][0]
      for j in range(m):
        skill[j]+=a[i][j]
  if all([k>=x for k in skill]):
    ans.append(total)
print(min(ans) if len(ans)!=0 else -1)
# Judge status: Wrong Answer
L=map(int,input().split())
print(min(sum(L)-v for v in L))
# Judge status: Wrong Answer
St = input().split() 
s = St[1]
print('A' + s + 'C')
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def main():
    s = input().strip()
    a = s[0] ; b = None
    c = 1 ; d = 0

    for i in range(1, 4):
        if s[i] == a:
            c += 1

        elif s[i] != a:
            b = s[i]
            d += 1

        elif s[i] == b:
            d += 1

    if c == 2 and d == 2:
        print('Yes')
    else:
        print('No')

main()
# Judge status: Wrong Answer
n, m = map(int, input().split())

if n * 2 >= m:
    print(n)
    exit()
else:
    m -= n * 2

print(n + (m // 4))
# Judge status: Wrong Answer
def main():
    a,b,n = map(int,input().split())
    aa = min(b,n)
    ans = 0
    for i in range(aa,n):

        ans = max(ans,a*aa//b  - a * (aa//b))
    print(ans)
if __name__=='__main__':
    main()
# Judge status: Wrong Answer
import sys
c= [list(map(int, input().split())) for i in range(3)]

for a1 in range(100):
  b1=c[0][0]-a1
  b2=c[0][1]-a1
  b3=c[0][2]-a1

  a2=c[1][0]-b1
  a3=c[2][0]-b1
  if a2==c[1][1]-b2 and a2==c[1][2]-b3:
    if a3==c[2][1]-b2 and a2==c[2][2]-b3:
      print('Yes')
      sys.exit(0)
print('No')
# Judge status: Accepted
def main():
    abc = [int(x) for x in input().split()]
    cnt = 0
    while True:
        abc.sort()
        if abc[0] == abc[1] == abc[2]:
            break
        if abc[1] == abc[2]:
            abc[0] += 2
        else:
            abc[0] += 1
            abc[1] += 1
        cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
V=list(map(int,input().split()))

V.sort()
avg=V[0]
for i in range(n):
  avg = (avg +V[i]) /2
  
print(avg)
# Judge status: Accepted
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))

search_num = 1
count = 0

for i in range(n):
    if a_list[i] == search_num:
        search_num = search_num + 1
        count = count + 1

if search_num == 1:
    print(-1)
else:
    print(n-count)
# Judge status: Accepted
a,b=map(int,input().split())
if (a-b)&1:print("IMPOSSIBLE")
else:print(min(a,b)+abs(a-b)//2)
# Judge status: Accepted
import sys
a,b,c = map(int,input().split())
for i in range(1,1001):
	if (a*i)%b == c:
		print("YES")
		sys.exit()
print("NO")
# Judge status: Wrong Answer
n=int(input())
a = 0

for i in range(1,n):
  if 0 <=  i  <= 9 :
    a+=1
  if 100 <= i <= 999 :
    a+=1
  if 10000 <= i <= 99999 :
    a+=1
  
print(a)
# Judge status: Accepted
n = int(input())
s = input()
ans = s.count("R")*s.count("G")*s.count("B")
for i in range(n-2):
    for j in range(i+1, (n-1+i)//2+1):
        k = 2*j-i
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1
print(ans)
# Judge status: Wrong Answer
s=input();a=s[:2]
print(2 if a=="F"else 3 if a=="T"else 4 if a=="W"else 5 if a=="T"else 6 if s=="M"else 7 if s=="SUN"else 1)
# Judge status: Wrong Answer
import sys
import math
import itertools

n,T=list(map(int,input().split()))
min=9999
for i in range(n):
	c,t=list(map(int,input().split()))
	if T>=t:
		if min>c:
			min=c
if min==9999:
	print("TLE")
else:
	print(c)
# Judge status: Accepted
a, b, x = map(int, input().split())
if x < a:
  print('NO')
elif a+b < x:
  print('NO')
else:
  print('YES')
# Judge status: Accepted
N, M = map(int,input().split())
B = [list(map(int,input().split())) for k in range(M)]
H = [1]*N
E = [0]*N
E[0] = 1
for e in B:
    x, y = e[0]-1, e[1]-1
    if E[x] == 1:
        if H[x] == 1:
            E[x] = 0
            E[y] = 1
        else:
            E[y] = 1
    H[x] -= 1
    H[y] += 1
print(E.count(1))
# Judge status: Accepted
a,b = map(int,input().split())
if a==1:
  a=14
if b==1:
  b=14

if a<b:
  print("Bob")
elif a==b:
  print("Draw")
else:
  print("Alice")
# Judge status: Accepted
# coding: utf-8
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = [sr() for _ in range(N)]
count_S = Counter(S)
M = ir()
T = [sr() for _ in range(M)]
count_T = Counter(T)
answer = 0
for k, v in count_S.items():
    temp = v - count_T[k]
    if temp > answer:
        answer = temp

print(answer)
# Judge status: Wrong Answer
n,y= map(int,input().split())
ans=0
for i in range(n+1):
  for j in range(n-i,n+1):
    z=y-i*10000-j*5000
    if 0<=z/1000<n and z % 1000 == 0:
      print(i,j,z/1000)
      exit()
print(-1,-1,-1)
# Judge status: Wrong Answer
from sys import stdin
N,M = stdin.readline().rstrip().split()
a_list = stdin.readline().rstrip().split()
N,M = int(N),int(M)
for a in a_list:
  N-=int(a)
if(N>0):
  print(N)
print(-1)
# Judge status: Wrong Answer
n,d = map(int,input().split())
x = []
for i in range(n):
    xi = [int(i) for i in input().split()]
    x.append(xi)
count = 0
ans = 0
for i in range(n-1):
    for l in range(i+1,n):
        ans = 0
        for j in range(d):
            ans += (x[i][j]-x[l][j])**2

        ans = ans **(1/2)
        print(ans)
        if ans == int(ans):
            count += 1
print(count)
# Judge status: Accepted
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = [int(x) for x in readline().split()]
s = max(A) * 3 - sum(A)
print(s // 2 if s % 2 == 0 else (s + 3) // 2)
# Judge status: Wrong Answer
W,H,x,y = map(int,input().split())
S = W*H
s1 = x*H
s2 = y*W
d1 = abs(s1-S/2)
d2 = abs(s2-S/2)
if d1 == d2:
    cnt = 1
else :
    cnt = 0
    
if d1<=d2:
    print(s1,cnt)
elif d1>d2:
    print(s2,cnt)
# Judge status: Accepted
import sys
input=sys.stdin.readline
A,B,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(m):
	x,y,c=map(int,input().split())
	ans=min(ans,a[x-1]+b[y-1]-c)
print(ans)
# Judge status: Accepted
import sys
import math

a, b, h, m = tuple(map(int, sys.stdin.buffer.read().split()))

mm = m / 60
hh = (h + mm)  / 12
r = (mm - hh) * math.pi * 2

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(r)))
# Judge status: Accepted
x,a,b=map(int,input().split(' '))
if abs(x-a) < abs(x-b):
    print('A')
else:
    print('B')
# Judge status: Accepted
a,b,c=map(int,input().split())
lis=list(range(1,min(a,b)+1))
lis=[x for x in lis if a%x==0 and b%x==0]
print(lis[-c])
# Judge status: Accepted
from math import atan2, degrees
A, B, X = map(int, input().split())
S = X / A


if S >= A * B / 2:
    h = (2 * (A * B - S)) / A
    print(degrees(atan2(h, A)))

else:
    w = (2 * S) / B
    print(degrees(atan2(B, w)))
# Judge status: Wrong Answer
x = int(input())

a = x // 11
b = x % 11


if(b > 5 and b != 0):
    print(a*2 + 2)
elif(b <= 5 and b != 0):
    print(a*2 + 1)
elif(b == 0):
    print(a*2)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 09:40:38 2020

@author: black
"""


S = list(input())

len = 0
ans = 0
for i in S:
    if i == "A" or i == "T" or i == "C" or i == "G":
        len += 1
    else:
        ans = max(len, ans)
        len = 0

print(ans)
# Judge status: Wrong Answer
N=int(input())
def ryuka(n):
    if n==0:
        return 2
    elif n==1:
        return 1
    else:
        return ryuka(n-1)+ryuka(n-2)
ryuka(N)
# Judge status: Accepted
#!/usr/bin/env python3
from collections import Counter
 
n, *d = map(int, open(0).read().split())
c = Counter(d[1:])
c = [(0, 1)] + sorted(c.items())
ans = d[0] == 0
for i in range(1, len(c)):
    if i != c[i][0]:
        ans = 0
        break
    ans *= c[i - 1][1]**c[i][1]
    ans %= 998244353
print(ans)
# Judge status: Accepted
import math
n,d=map(int,input().split())
X=[]
for i in range(n):
    X.append(list(map(int,input().split())))

ans=0
for i in range(n-1):
    for j in range(i+1,n):
        cnt=0
        for k in range(d):
            cnt+=(X[i][k]-X[j][k])**2
        cnt=math.sqrt(cnt)
        if int(cnt)==cnt:
            ans+=1
print(ans)
# Judge status: Accepted
A = sorted(list(map(int,input().split())))

if A == [5,5,7]:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
n = int(input())
s = input()
ans = [0]
for i in range(n):
    if s[i] == 'I':
        ans.append(ans[i-1] +1)
    else:
        ans.append(ans[i-1] -1)
print(max(ans))
# Judge status: Accepted
for i in range(5):
  if i == 0:
    a = int(input())
  elif i == 1 or i == 2 or i == 3:
    tmp = int(input())
  else:
    b = int(input())
k = int(input())
if k >= b - a:
  print("Yay!")
else:
  print(":(")
# Judge status: Accepted
s = list(input())
tmp1 = s[0]
tmp2 = ''
count = 0
for i in range(1, len(s)):
    tmp2 += s[i]
    if tmp2 != tmp1:
        count += 1
        tmp1 = tmp2
        tmp2 = ''
print(count + 1)
# Judge status: Wrong Answer
S = input()
print('Heisei' if S <= '2019/4/30' else 'TBD')
# Judge status: Wrong Answer
N=int(input())
a_list=list(map(int,input().split()))
Q=int(input())
B=[list(map(int,input().split())) for i in range(Q)]
a_list=sorted(a_list)
for i in range(Q):
    if B[i][0] in a_list:
        for j in range(N):
            if a_list[j]==B[i][0]:
                a_list[j]=B[i][1]
                break
    print(sum(a_list))
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 30 01:58:33 2020

@author: liang
"""
import math

x = int(input())

ans = x // 11 *2 + math.ceil(x%11/5)

print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
ans = []

ans.append(a+b)
ans.append(a+(a-1))
ans.append(b+(b-1))

print(max(ans))
# Judge status: Accepted
n = int(input())
if n in [1,2,3,5,6,9,10,13,17]:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
N = int(input())
a = []
b = []
for _ in range(N):
    ab = list(map(int, input().split()))
    a.append(ab[0])
    b.append(ab[1])

count = 0
for i in range(N-1, -1, -1):
    if (a[i]+count) % b[i] != 0:
        count += (b[i] - (a[i]+count) % b[i])
print(count)
# Judge status: Accepted
#

import sys
input=sys.stdin.readline

def main():
    N,M=map(int,input().split())
    lr=[tuple(map(int,input().split())) for i in range(M)]
    imos=[0]*(N+2)
    cnt=0
    for i in lr:
        imos[i[0]]+=1
        imos[i[1]+1]-=1
    for j in range(N+1):
        imos[j+1]+=imos[j]
    for i in imos:
        if i == M:
            cnt+=1
    print(cnt)
    
if __name__=="__main__":
    main()
# Judge status: Accepted
mod = 10**9+7
n = int(input())
print((pow(10,n,mod)-pow(9,n,mod)*2+pow(8,n,mod))%mod)
# Judge status: Wrong Answer
import sys
A,B,X = map(int,input().split())
if not ( 1 <= A <= 100 and 1 <= B <= 100 and 1 <= X <= 200 ):
    sys.exit()

if (B + A) >= X and A <= X:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer

def default():
    a=input()
    a=a.split()
    a[0]=int(a[0])
    a[1]=float(a[1])
    a[1]=int(a[1]*a[0])
    print(a[1])
if(__name__=="__main__"):
    default()
# Judge status: Accepted
s = input()

ans = []

for ss in s:
    if ss == '0':
        ans.append('0')
    elif ss == '1':
        ans.append('1')
    else:
        if len(ans) >= 1:
            del ans[-1]

print("".join(ans))
# Judge status: Accepted
n = int(input())

for i in range(1,n+1):
    if i*(i+1)//2 >=n:
        k = i*(i+1)//2 - n
        for j in range(1,i+1):
            if j == k:
                continue
            else:
                print(j)
        exit()
# Judge status: Wrong Answer
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from collections import deque
def main():

    n = int(input())
    ans = deque()
    num = 1
    while n:
        if n - num not in ans:
            ans.append(num)
            n -= num
        num += 1

    print(*ans, sep='\n')

if __name__ == '__main__':
    main()
# Judge status: Accepted
x,y = map(int,input().split())

res = 10**10
cnt = 0
for mask in range(1<<2):
    _x = x
    _y = y
    if mask & 1:
        _x *= -1
        cnt +=1
    if (mask>>1) & 1:
        _y *= -1
        cnt += 1
    if _x <= _y:
        cnt += _y-_x
        res = min(res,cnt)
    cnt = 0
print(res)
# Judge status: Accepted
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    tmp = i+0
    x = 1/n
    while i<k:
        i*=2
        x/=2
    ans+=x
print(ans)
# Judge status: Accepted
x,y = map(int, input().split())
li = []

if x <= y:
    li.append(y-x)
if -x <= y:
    li.append(1+x+y)
if x <= -y:
    li.append(1-y-x)
if -x <= -y:
    li.append(2+x-y)
print(min(li))
# Judge status: Accepted
n,a,b=(int(x) for x in input().split())
c=0
d=[]
def sual(N,A,B):
  l=list('{}'.format(N))
  for y in range(len(l)):
      d.append(int(l[y]))
  e=sum(d)
  d.clear()
  if A<=e<=B:
    return True
  else:
    return False

for x in range(n):
  if sual(x+1,a,b):
    c=c+x+1
print(c)
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
for i in range(n):
    if i == 0:
        continue
    if i == 1:
        dp[1] = abs(h[0] - h[1])
    else:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
        
print(dp[n-1])
# Judge status: Wrong Answer
n = int(input())
a = []
b = input()
x = 0
for i in range(n):
  if b[i] == "I":
    x += 1
  else:
    x -= 1
  a.append(x)
  
print(max(a))
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

ans=1
flag=False
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        flag=True
        ans=ans%10**18

if flag and ans!=0:
    print(-1)
else:
    print(ans)
# Judge status: Wrong Answer
K, N = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
#print(K,N,A)
min_dis = K+1

for i in range(len(A) -1):
  dis = A[i+1] - A[i]
  if dis < min_dis:
    ans = (i+1)+1
    min_dis = dis
print(ans)
# Judge status: Accepted
s = input()
if "RRR" in s:
    r = 3
elif "RR" in s:
    r = 2
elif "R" in s:
    r= 1
else:
    r = 0
print(r)
# Judge status: Wrong Answer
n = int(input())
hlis = list(map(int, input().split()))
d = 0
for i in range(n-1):
    d = max(d, hlis[i] - hlis[i+1])
if d > 2:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
from collections import Counter
N = int(input())
a = list(map(int,input().split()))
c = Counter(a)
ans = 0
s = []
for e in c:
    if c[e] >= 2:
        s.append(e)
    if c[e] >= 4:
        ans = max(ans,e*e)
s = sorted(s)
if len(s) < 2:
    print(0)
else:
    print(max(ans,s[-1]*s[-2]))
# Judge status: Wrong Answer
import math
A, B = map(float, input().split(" "))
print(math.floor(A*B))
# Judge status: Wrong Answer
X = int(input())
cnt = 0
t = 0
while cnt < X:
    t+=1
    if cnt+t == X:
        cnt += t
    elif X - (cnt+t) > t:
        cnt += t
print(t)
# Judge status: Accepted
n=int(input())
li=list(input().split(" "))
for g in range(n):
    li[g]=int(li[g])
ali=0
bob=0
li.sort()
li.reverse()
for i in range(n):
    if i%2==0:
        ali+=li[i]
    else:
        bob+=li[i]
print(abs(ali-bob))
# Judge status: Accepted
import sys
import heapq
input = sys.stdin.readline
N,M = map(int,input().split())
AB = [[] for i in range(M+1)]
for i in range(N):
    a,b = list(map(int,input().split()))
    if a <= M:
        AB[a].append(-b)
work = 0
AB2 = []
heapq.heapify(AB2)
for i in range(1,M+1):
    for j in AB[i]:
        heapq.heappush(AB2,j)
    if len(AB2) > 0:
        b = heapq.heappop(AB2)
        work += -b
print(work)
# Judge status: Accepted
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
p = list(map(int,input().split()))
ans = 1 # initialization of p[0]
min_i = p[0]
for i in range(1,n):
    if p[i] <= min_i:
        ans += 1
        min_i = p[i]
    else: pass
print(ans)
# Judge status: Accepted
D = {"SUN": 7, "MON": 6, "TUE": 5, "WED": 4, "THU": 3, "FRI": 2, "SAT": 1}
print(D[input()])
# Judge status: Accepted
N,M=map(int,input().split())
if N==M==1:
  r=1
elif N==1 or M==1:
  r=N+M-3
else:
  r=N*M-2*(N-1)-2*(M-1)
print(r)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
res=[0]*n
for i in range(n):
    x=0
    for j in a[:i]+a[i+1:]:
        x^=j
    res[i]=x
print(res)
# Judge status: Accepted
s = input()
l = len(s)
#print(s[:(l-1)//2])
#print(s[(l+3)//2-1:])
def pal(t):
    c = 1
    for i in range((len(t)-1)//2):
        if t[i] != t[-i-1]:
            c = 0
    return c
"""
if pal(s) and pal(s[:(l-1)//2]) and pal(s[(l+3)//2-1:]):
    print("Yes")
else:
    print("No")

"""
if s[:(l-1)//2] == s[(l+3)//2-1:] and pal(s):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():

    five_hundred = int(input())
    one_hundred = int(input())
    fifty = int(input())
    x = int(input())
    ans = 0
    for i in range(five_hundred + 1):
        for j in range(one_hundred + 1):
            for k in range(fifty + 1):
                if 500 * i + 100 * j + 50 * k == x:
                    ans += 1

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from collections import Counter

S = input()
c = Counter(S)

if len(c) == 3 and max(c.values()) - min(c.values()) <= 1:
    print("YES")
elif len(c) == 2 and max(c.values()) == min(c.values()):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
for _ in range(K):
    count_list = [0] * N
    for i, v in enumerate(A_list):
        count_list[i - v if i - v > 0 else 0] += 1
        if i + v + 1 < N:
            count_list[i + v + 1] -= 1
    temp = 0
    flag = True
    for i in range(len(A_list)):
        temp += count_list[i]
        if temp != N:
            flag = False
        A_list[i] = temp
    if flag:
        break

print(*A_list)
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()
if c<d:
    if "##" in s[a:c+1] or "##" in s[b:d+1]:
        print("No")
    else:
        print("Yes")
    exit()
else:
    if "##" in s[a:c+1] :
        print("No")
        exit()
    print("Yes" if "..." in s[b-1:d+2] else "No")
# Judge status: Accepted
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
dist = [j - i for i, j in zip(x, x[1:])]
dist.sort(reverse=1)
print(sum(dist[n-1:]))
# Judge status: Accepted
N,T = map(int,(input().split()))
c = [[0]*2 for _ in range(N)]
ans = []
for i in range(N):
    c[i][0],c[i][1] = map(int,(input().split()))
    if c[i][1] <= T:
        ans.append(c[i][0])
if ans:
    ans.sort()
    print(ans[0])
else:
    print("TLE")
# Judge status: Accepted
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
     
    N = int(readline())
    m = map(int,read().split())
    ABC = zip(m,m,m)
     
    x,y,z = 0,0,0 # 最後の活動 -> 幸福度のmax
    for a,b,c in ABC:
        x,y,z = max(y,z)+a,max(x,z)+b,max(x,y)+c
     
    answer = max(x,y,z)
    print(answer)
main()
# Judge status: Accepted
a, b, c = map(int, input().split())
m = max(a, b, c)
print(m*10+(a+b+c-m))
# Judge status: Accepted
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    S = input()
    par = [0]
    cc = 0
    for i in S:
        if i == '(': cc += 1
        else: cc -= 1
        par.append(cc)

    mp = min(par)
    output = S
    if mp < 0: output = '(' * abs(mp) + output
    if abs(mp) + cc > 0: output = output + ')' * (abs(mp)+cc)
    print(output)

    return

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = [int(a) for a in input().split()]

attend = [0] * N
for i in range(N):
    attend[A[i]-1] = str(i+1)

res = ' '.join(attend)

print(res)
# Judge status: Wrong Answer
n = int(input())
slist = [""]*n
for i in range(n):
	slist[i] =sorted(input())
sslist=sorted(slist)
count=0
for i in range(n-1):
	if sslist[i]==sslist[i+1]:
		count = count +1
#	print(sslist[i])
print(count)
# Judge status: Accepted
import sys

s=input()

lens=len(s)

while lens>0:
    lens0=lens
    if s[lens-7:lens]=="dreamer":
        lens=lens-7
    elif s[lens-5:lens]=="dream":
        lens=lens-5
    elif s[lens-6:lens]=="eraser":
        lens=lens-6
    elif s[lens-5:lens]=="erase":
        lens=lens-5
    if lens0==lens:
        print("NO")
        sys.exit()

print("YES")
# Judge status: Wrong Answer
weather=["Sunny","cloudy","Rainy","Sunny"]

S=input()

for i in range(3):
    if(S==weather[i]):
        print(weather[i+1])
# Judge status: Wrong Answer
K = int(input())
A, B = map(int, input().split())
s = A % B
if s + A > B:
  print('NG')
else:
  print('OK')
# Judge status: Wrong Answer
"""
aを10^3くらいまででいいよね
"""
x = int(input())
# a>0 b>0のとき
for i in range(10**3):
    for j in range(i+1,10**3):
        if j ** 5 - i ** 5 == x:
            print(i,j)
            exit()
# a>0, b<0のとき
for i in range(10**2):
    for j in range(10**2):
        if i**5 + j**5 == x:
            print(i,-j)
            exit()
# Judge status: Accepted
n,k = map(int,input().split())
s = 'R' + input() + 'L'

score = 0
for i in range(1,n+1):
  if s[i] == 'R' and s[i+1] =='R':
    score += 1
  elif s[i] =='L' and s[i-1]=='L':
    score += 1
print(min(n-1,score+2*k))
# Judge status: Wrong Answer
S=int(input())
list=list(range(S))
def get_integral_value_combination(list, target):
    def a(idx, l, r, t):
        if t == sum(l): r.append(l)
        elif t < sum(l): return
        for u in range(idx, len(list)):
            a((u + 1), l + [list[u]], r, t)
        return r
    return a(0, [], [], target)

print(len(get_integral_value_combination(list, S)))
# Judge status: Wrong Answer
x,a,b = map(int,input().split())
if a<=b:
    print('delicious')
elif b>(a+x):
    print('dangerous')
else:
    print('safe')