peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import math

n = int(input())
a = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(n-1):
    t = 0
    for j in range(i, n-1):
        if a[j][1] >= t:
            t = a[j][1]
        else:
            t = math.ceil(t / a[j][2]) * a[j][2]
        t += a[j][0]
    print(t)
print(0)
# Judge status: Wrong Answer
import math
def main():
  n=int(input())
  a=int(n/100)
  if a*100+a*10+a>n:
    print(a*100+a*10+a)
  else:
    print((a+1)*100+(a+1)*10+a+1)
main()
# Judge status: Accepted
def resolve():
    N = int(input())
    A = [0]+list(map(int, input().split()))
    dp = [[None for _ in range(2)] for _ in range(N+1)]
    dp[0][0] = 0
    dp[0][1] = -float("inf")
    for i in range(1, N+1):
        dp[i][0] = max(dp[i-1][0]+A[i], dp[i-1][1]-A[i])
        dp[i][1] = max(dp[i-1][0]-A[i], dp[i-1][1]+A[i])
    print(dp[N][0])



if '__main__' == __name__:
    resolve()
# Judge status: Wrong Answer
print(['MON','TUE','WED','THU','FRI','SAT','SUN'].index(input())+1)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
h = sum(a)
ans = 0
for i in range(n):
  h -= a[i]
  ans = (ans+a[i]*(h))%(10**9+7)
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
MOD = 1000000007

ans = 0
for i in range(k, n+2):
    maxNum = i * (2 * n - (i - 1)) / 2
    minNum = i * (i - 1) / 2
    ans += (maxNum - minNum + 1) % MOD
print(int(ans) % MOD)
# Judge status: Accepted
def main():
  s = input()
  if s != s[::-1]:
    print('No')
    return
  a = s[:(len(s)-1)//2]
  if a != a[::-1]:
    print('No')
    return
  b = s[(len(s)+1)//2:]
  if b != b[::-1]:
    print('No')
    return
  print('Yes')
  return

main()
# Judge status: Accepted
a,b,t=map(int,input().split())
time = (t+0.5)//a
ans =int( time * b)

print(ans)
# Judge status: Accepted
s=input()
l=[chr(ord('a') + i) for i in range(26)]
for i in l:
    if i not in s:
        print(i)
        break
else:
    print("None")
# Judge status: Wrong Answer
N, L = map(int, input().split())

taste = [L + i for i in range(N)]
taste_abs = [abs(i) for i in taste]
eat = min(taste_abs)

print(sum(taste) - eat)
# Judge status: Accepted
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
count = 0
# ソートして
for b in B:
  upeer_b = N - bisect.bisect_right(C, b)
  downer_b = bisect.bisect_left(A, b)
  count += upeer_b * downer_b

# for c in C:
#   under_c = bisect.bisect_left(B, c)
#   for b in B[:under_c]:
#     under_b = bisect.bisect_left(A, b)
#     count += under_b

print(count)
# Judge status: Accepted
b=input().split()
K=int(b[1])
a=input()
count=0
for  i in range(len(a)) :
  if i!=len(a)-1 and a[i]=='R' and a[i+1]=='R':
    count+=1
  elif i!=0 and a[i]=='L' and a[i-1]=='L' :
    count+=1
    
for i in range(K) :
  count+=2

if count>=len(a)-1 :
  print(len(a)-1)
else :
  print(count)
# Judge status: Wrong Answer
N,K=map(int,input().split())
x=list(map(int,input().split()))

ans=max(x)-min(x)

for i in range(N-K+1):
    ans=min(ans,x[i+K-1]-x[i]+min(abs(x[i]),abs(x[i+K-1])))
#    print(i,i+K-1,x[i],x[i+K-1],x[i+K-1]-x[i]+min(abs(x[i]),abs(x[i+K-1])))
if N==1:
    ans=x[0]
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
red = [0]*n
ball = [1]*n
red[0] = 1
for i in range(m):
    x, y = map(int, input().split())
    if red[x-1] == 1:
        red[y-1] = 1
        if ball[x-1] == 1:
            red[x-1] = 0
    ball[y-1] += 1
    ball[x-1] -= 1
print(sum(red))
# Judge status: Wrong Answer
a , b = list(map(int,input().split()))
if (a-b)%2 == 1:
  print("IMPOSSIBLE")
else:
  print((a-b)//2)
# Judge status: Accepted
import math
a, b, t = map(int, input().split())
T = t + 0.5
times = math.floor(T / a)

print(times*b)
# Judge status: Accepted
n, l = map(int, input().split())
apples = [l + i for i in range(n)]

x = 10 ** 9
y = 0

for apple in apples:
    if abs(apple) < x:
        x = abs(apple)
        y = apple
print(sum(apples)-y)
# Judge status: Accepted
N,M = map(int,input().split())
 
s = []
g = []
for i in range(M):
    a,b = map(int,input().split())
    if a == 1:
        s.append(b)
    elif b == N:
        g.append(a)
    
ans = set(s) & set(g)
 
if len(ans) >= 1:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Judge status: Wrong Answer
#ABC131 B

N,L = map(int,input().split())
aji = []
delta = []
for i in range(N):
    aji.append(L + i)
for j in range(N):
    delta.append(abs(aji[i]))
print(sum(aji) - min(aji))
# Judge status: Wrong Answer
a=input()
a=list(map(int,input().split()))
count=0
for itr in range(len(a)):
    if itr+1==a[itr]: count+=1
if count==0: print(0)
else:print(count-1)
# Judge status: Accepted
s = list(input())
K = int(input())
zp1 = 1+ord('z')
for i in range(len(s)):
    si = s[i]
    cost = (zp1-ord(si))%26
    if cost <= K:
        K -= cost
        s[i] = 'a'
s[-1] = chr(ord('a') + (K + ord(s[-1]) - ord('a')) % 26)
print(''.join(s))
# Judge status: Wrong Answer
l = list(map(int,input().split()))

l.sort()

print(l[2]-l[1])
# Judge status: Wrong Answer
N,A,B=map(int,input().split())
if  A==0:
    print(0)
elif N>=A+B:
    print(N-B)
elif N<A+B and N<A:
    print(N)
else:
    print(A)
# Judge status: Accepted
n,k = map(int,input().split())
x = list(map(int,input().split()))

ans = 10**10

for i in range(n-k+1):
    ans = min(ans, min(abs(x[i]), abs(x[i+k-1])) + x[i+k-1] - x[i])

print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def main():
    a, b, c = map(int, input().split())
    if a == 5 and b == 5 and c == 7:
        print("YES")
        return
    if b == 5 and c == 5 and a == 7:
        print("YES")
        return
    if c == 5 and a == 5 and b == 7:
        print("YES")
        return
    print("NO")


if __name__ == "__main__":
    main()
# Judge status: Accepted
N,W = list(map(int,input().split()))
DP = [[0]*(W+1) for i in range(N+1)]
for i in range(1,N+1):
    w,v = list(map(int,input().split()))
    for j in range(W+1):
        DP[i][j] = max(DP[i-1][j],DP[i-1][j-w]+v) if w <= j else DP[i-1][j]
print(max(DP[N]))
# Judge status: Wrong Answer
S = input()
T = input()
L = len(S)
K = len(T)
ans = S
flag = 0
for i in range(L-1,-1,-1):
    for j in range(K-1,-1,-1):
        a = K-1-j
        if i-a < 0 or (S[i-a] != "?" and S[i-a] != T[j]):
            break
    else:
        ans = ans[:i-K+1] + T + ans[i+K:]
        flag = 1
        break
if flag == 0:
    ans = "UNRESTORABLE"
print(ans.replace("?","a"))
# Judge status: Wrong Answer
s = list(input())
s = sorted(s)
if s[0] == s[1] and s[2] == s[3] and s[0] != s[1]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n=int(input())
x=list(map(int,input().split()))
x=sorted(x)
average=sum(x)//n
ans=0
for i in x:
    ans+=(i-average)**2

ans1=0
for i in x:
    ans1+=(i-average-1)**2

print(min(ans,ans1))
# Judge status: Accepted
n=int(input())
l,d=[],[]
for i in range(n):
    x=int(input())
    if(x%10==0):
        l.append(x)
    else:
        d.append(x)
if(d==[]):
    print(0)
else:
    s=sum(l)+sum(d)
    if(s%10==0):
        print(s-min(d))
    else:
        print(s)
# Judge status: Accepted
X = list(map(int,input().split()))

for i in range(5):
  if X[i] == 0:
    print(i+1)
    break
# Judge status: Accepted
import numpy as np
n, d = map(int, input().split())

vector = [[0 for i in range(d)] for j in range(n)]

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

cnt = 0
for i in range(n - 1):
    for j in range(i + 1,n):
        
        num = 0
        for k in range(d):
            num += (vector[i][k] - vector[j][k])**2 * 1.0
        
        if np.sqrt(num).is_integer():
            cnt += 1

print(cnt)
# Judge status: Wrong Answer
s=str(input())
if s=='S':
  print('C')
elif s=='C':
  print('R')  
else:
  print('S')
# Judge status: Accepted
n=int(input())
a=[int(input()) for i in range(n)]
b=sorted(a)
m=b[-1]
c=b[-2]
for i in range(0, n):
  if m == a[i]:
    print(c)
  else:
    print(m)
# Judge status: Accepted
X, Y, A, B, C = list(map(int, input().split(" ")))
p_list = sorted(list(map(int, input().split(" "))), reverse=True)
q_list = sorted(list(map(int, input().split(" "))), reverse=True)
c_list = sorted(list(map(int, input().split(" "))), reverse=True)
p_list = p_list[:X]
q_list = q_list[:Y]
all_list = p_list+q_list+c_list
all_list.sort(reverse=True)
print(sum(all_list[0:X+Y]))
# Judge status: Accepted
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7


n = int(readline())

ans = (pow(10, n, mod) - 2*pow(9, n, mod) + pow(8, n, mod))%mod

print(ans)
# Judge status: Wrong Answer
import random
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]

for i in range(D):
  rand = random.randrange(0, 26)
# Judge status: Accepted
import numpy as np
n = int(input())
s = np.array(input().split(), np.int64)
mod = 10 ** 9 + 7

res = 0
po2 = 1
for i in range(61):
    bit = (s >> i) & 1
    x = np.count_nonzero(bit)
    y = n - x
    res += x * y % mod * po2
    res %= mod
    po2 *= 2 % mod
print(res)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
cnt_4 = 0
cnt_2 = 0
remaining_cnt_2 = 0
cnt_other = 0

for x in a:
    if x % 4 == 0:
        cnt_4 += 1
    elif x % 2 == 0:
        cnt_2 += 1
    else:
        cnt_other += 1

remaining_cnt_2 = cnt_2 % 2

if cnt_2 > 0:
    if cnt_4 >= cnt_other:
        print("Yes")
    else:
        print("No")
else:
    if cnt_4 + 1 >= cnt_other:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
s = list(input())

a = list("dream")
b = list("dreamer")
c = list("erase")
d = list("eraser")
flag = 0

while(flag == 0):
    if s[-7:] == b:
        del s[-7:]
    elif s[-6:] == d:
        del s[-6:]
    elif s[-5:] == a or s[-5:] == c:
        del s[-5:]
    elif s == []:
        print("YES")
        flag = 1
    else:
        print("NO")
        flag = 1
# Judge status: Accepted
from sys import stdin
import math

a,b=map(int,input().split())
if(a&1 and b&1):
    print("Odd")
else:
    print("Even")
# Judge status: Accepted
#!/usr/bin/env python3
import sys


def solve(S: str):
    ans = ['x' for s in S]
    print(''.join(ans))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
# Judge status: Accepted
s = str(input()) + '0'
ans = [0] * (len(s))

cnt = 0
for i in range(len(s)):
    ans[i] = cnt
    if s[i] == '<':
        cnt += 1
    else:
        cnt = 0

cnt = 0
for i in range(len(s))[::-1]:
    ans[i] = max(cnt,ans[i])
    if s[i-1] == '>':
        cnt += 1
    else:
        cnt = 0

print(sum(ans))
# Judge status: Accepted
N=int(input())
lis=[tuple(map(int,input().split())) for _ in range(N)]
import itertools,math
p = itertools.permutations(list(range(N)))
sm=0

for v in p:
    #print(v)
    for k in range(N-1):
        xi,yi=lis[v[k]]
        xj,yj=lis[v[k+1]]
        #print(xi,yi,xj,yj)
        sm+=((xi-xj)**2+(yi-yj)**2)**(1/2)
print(sm/math.factorial(N))
# Judge status: Accepted
string = list(input())
if string[2] == string[3] and string[4] == string[5]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a=int(input())
b=int(input())

for i in range(1,4):
    if i!=a and i!=b:
        print(i)
# Judge status: Accepted
a = input()

b = a[:3] + "8" + a[4:]

print(b)
# Judge status: Wrong Answer
x,y=map(int,input().split())
if x==2 or y==2:
    print("No")
elif (x==4 and y==6,9,11) or (x==6 and y==9,11) or (x==9 and y==11):
    print("Yes")
elif (x==1 and y==3,5,7,8,10,12) or (x==3 and y==5,7,8,10,12) or (x==5 and y==7,8,10,12) or (x==7 and y==8,10,12) or (x==8 and y==10,12) or (x==10 and y==12):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a >= 13:
  print(b)
elif a <= 5:
  print(0)
else:
  print(b/2)
# Judge status: Wrong Answer
Q, H, S, D = map(int, input().split())
N = int(input())
l_1 = min((Q * 4), (H * 2), (S * 1))
l_2 = min((Q * 8), (H * 4), (S * 2), (D * 1))
ans = 0

if N == 1:
    ans = int(l_1)
elif N % 2 == 0:
    ans = int(l_2 * N / 2)
else:
    ans = int((N - 1) / 2 * l_2 + l_1)

print(ans)
# Judge status: Accepted
n = int(input())
ok = [111,222,333,444,555,666,777,888,999]

while n not in ok:
    n += 1
    
print(n)
# Judge status: Wrong Answer
# A
S = input()
ans = [0] * (len(S)+1)
for i in range(len(S)):
  if S[i] == ">":
    ans[i+1] = max(ans[i+1],ans[i])
  
for i in range(len(S)-1,-1,-1):
  if S[i] == '>':
    ans[i] = max(ans[i],ans[i+1]+1)

print(sum(ans))
# Judge status: Accepted
a, b= map(int, raw_input().split())

if a == b:
    print a + b
else:
    print max(a, b) + max(a, b) - 1
# Judge status: Accepted
x = int(input())
if x == 0:
    print(1)
elif x == 1:
    print(0)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
if n==len(set(a)):
    print('Yes')
else:print('No')
# Judge status: Wrong Answer
print(["x" for c in range(len(input()))])
# Judge status: Wrong Answer
# 169A
# A × B を整数として出力せよ

# 1.入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
print(a,b)
# 2.受け取った入力値を使って、適切に処理（計算）すること
answer = a * b

# 3.計算した結果を出力すること
print(answer)
# Judge status: Accepted
import math
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0
cal = 0
for i in range(n):
  for j in range(i+1, n):
    for k in range(d):
      de = abs(x[i][k] - x[j][k])
      cal += de**2
    if math.sqrt(cal)%1==0:
      ans += 1
    cal = 0
print(ans)
# Judge status: Accepted
a = int(input())
if a % 2 == 0:
    print(a // 2)
else:
    print(a // 2 + 1)
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
b = a[:]
bs = set(b)
f = a[-1]
for i in range(n):
    a[i] = min(a[i],f-a[i])
a.sort()
s = a[-1]
if s in bs:
    print(f,s)
    exit()
s = f - s
print(f,s)
# Judge status: Accepted
#ABC-118-B
N = int(input())
L = list(map(int, input().split()))

max_L = max(L)
sum_L = sum(L)

if max_L < sum_L-max_L:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
from heapq import *

readline = sys.stdin.readline
N, M = map(int, readline().split())
days = [[] for _ in range(M)]
for _ in range(N):
    a, b = map(int, readline().split())
    if a <= M:
        days[a-1].append(b)
ans = 0
hq = []
heapify(hq)
for day in days:
    for pay in day:
        heappush(hq, -pay)
    if hq:
        ans += -heappop(hq)
print(ans)
# Judge status: Wrong Answer
N, K = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ls = []
for i in range(K):
    ls.append(p[i])
# Judge status: Wrong Answer
n, m = map(int, input().split())
ans = 0
if n > m:
    n, m = m, n
if n == 1 or m == 1:
    ans = max(0, m - 2)

elif n == 2 or m == 2:
    ans = 0
else:
    ans = (n - 2) * (m - 2)
print(ans)
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]
x = [0]*n
for i in range(n):
    x[a[i]-1] = i+1
ans = ""
for i in x:
    ans += str(i) + " "
print(ans)
# Judge status: Accepted
x,y=map(int,input().split())
a=abs(abs(x)-abs(y))
if x==0:
  if y<0:
    print(a+1)
  else:
    print(a)
elif y==0:
  if x<0:
    print(a)
  else:
    print(a+1)
elif y*x>0 and y>x:
  print(a)
elif y*x>0 and x>y:
  print(a+2)
elif y*x<0:
  print(a+1)
# Judge status: Accepted
N=int(input())
L=list(map(int,input().split(' ')))

N_tri=0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if L[i] != L[j] and L[j]!=L[k] and L[k]!=L[i]:
        L_sorted=sorted([L[i],L[j],L[k]])
        if L_sorted[0]+L_sorted[1]>L_sorted[2]:
          N_tri+=1

print(N_tri)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

x=1
while K:
    if K&1: x=A[x-1]
    K>>=1

    A2 = [None]*N
    for i,a in enumerate(A):
        A2[i]=A[A[i]-1]
    A=A2

print(x)
# Judge status: Accepted
N=int(input())
T= [list(map(int,input().split())) for _ in range(N)]

is_able=True
pre_t = 0
pre_x = 0
pre_y = 0
for i in range(len(T)):
  if (T[i][0] % 2) != (T[i][1]+T[i][2])%2:
    is_able=False
    break
  if T[i][0]-pre_t < (T[i][1]-pre_x + T[i][2]-pre_y):
    is_able=False
    break
  pre_t=T[i][0]
  pre_x=T[i][1]
  pre_y=T[i][2]
if is_able:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N, C, K = list(map(int, input().split()))

passengers = sorted([int(input()) for i in range(N)])
res = 0
bus_time = passengers[0]
bus_count = C
for p in passengers:
    if bus_count == 0 or p - bus_time > K:
        res += 1
        bus_time = p
        bus_count = C - 1
    else:
        bus_count -= 1
if bus_count != C:
    res += 1
print(res)
# Judge status: Accepted
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, m = LI()
if n == 1 and m == 1:
    print(1) 
elif n == 1:
    print(max(0, m-2))
elif m == 1:
    print(max(0, n-2))
else:
    print((n-2)*(m-2))
# Judge status: Accepted
N, M = map(int, input().split())

L = [None] * M
R = [None] * M

for i in range(M):
    l, r = map(int, input().split())
    L[i] = l
    R[i] = r

L_max = max(L)
R_min = min(R)

if L_max > R_min:
    print(0)
else:
    print(R_min - L_max + 1)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(n):
    if a[i] < 0:
        c += 1
        a[i] = abs(a[i])
if c % 2 == 0:
    print(sum(a))
else:
    print(sum(a)-(min(a)*2))
# Judge status: Accepted
X, K, D = [int(x) for x in input().split()]

X = abs(X)

straight = min(K, X // D)

K -= straight;
X -= straight * D;

if K % 2 == 0:
    print(X)
else:
    print(D - X)
# Judge status: Accepted
N = int(input())
ans = 0
A = list(map(int,input().rstrip().split(" ")))
A.sort()
A2 = [True for i in range(A[-1] + 1)]
for i in range(len(A)):
    k = A[i] * 2
    if A2[A[i]]:
        if i != 0 and A[i-1] == A[i]:
            A2[A[i]] = False
        while(k < len(A2)):
            A2[k] = False
            k += A[i]
for i in A:
    if A2[i]:
        ans += 1
print(ans)
# Judge status: Accepted
import queue

o = input()
e = input()

odd = list(o)
even = list(e)

answer = []

o_q = queue.Queue()
e_q = queue.Queue()

for i in range(len(odd)):
    o_q.put(odd[i])

for i in range(len(even)):
    e_q.put(even[i])

while not o_q.empty():
    answer.append(o_q.get())
    if e_q.empty():
        continue
    answer.append(e_q.get())

for i in range(len(answer)):
    print(answer[i],end='')
# Judge status: Accepted
n=int(input())
s=list(input() for _ in range(n))

import collections
ans=collections.Counter(s)
print(len(ans))
# Judge status: Accepted
N,x=map(int,input().split())
a=list(map(int,input().split()))

ans=0
for i in range(N-1):
    if a[i]+a[i+1]>x:
        if a[i]+a[i+1]-x<=a[i+1]:
            ans+=(a[i]+a[i+1]-x)
            a[i+1]-=(a[i]+a[i+1]-x)
        else:
            ans+=(a[i]+a[i+1]-x)
            a[i+1]=0
print(ans)
# Judge status: Wrong Answer
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans=0
N=int(input())
if N<105:
    print(0)
    exit(0)
for i in range(104,N):
    if i%2==1 and len(make_divisors(i))==8:
        ans+=1
print(ans)
# Judge status: Accepted
K = int(input())
S = str(input())
if len(S) <= K:
    print(S)
else:
    print('{}...'.format(S[0:K]))
# Judge status: Accepted
n,a,b=map(int,input().split())
print(max(0,(b-a)*(n-2)+1))
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
A=[0]+A
import math

L=[0 for i in range(N+2)]
R=[0 for i in range(N+2)]
for i in range(0,N+1):
  L[i+1]=math.gcd(L[i],A[i])
for i in range(N,-1,-1):
  R[i]=math.gcd(R[i+1],A[i])

M=[0 for i in range(N+1)]
for i in range(1,N+1):
  M[i]=math.gcd(L[i],R[i+1])
print(max(M))
# Judge status: Wrong Answer
N = int(input())

pos_x=0
pos_y=0
t_now=0
flg = True
for i in range(N):
    t,x,y = map(int,input().split())
    t_del = t-t_now
    res = (t_del-abs(pos_x-x)-abs(pos_y-y))
    if (res>=0) & (res%2==0):
        t_now = t
        x_pos = x
        y_pos=y
        pass
    else:
        flg = False
        break

if flg == True:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
l=list(map(str,input().split()))
l.sort()
a=l[0]
b=l[2]+l[1]
print(int(b)+int(a))
# Judge status: Accepted
import math

N,K=map(int,input().split())
L=list(map(int,input().split()))
ans=math.ceil((N-K)/(K-1))+1
print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
a = [int(input()) for _ in range(n)]

s = deque([a[0]])

from bisect import bisect_right

for i in a[1:]:
    if i <= a[0]:
        s.appendleft(i)
    else:
        s[bisect_right(s, i) - 1] = i

# print(s)
print(len(s))
# Judge status: Wrong Answer
s = str(input())
t = str(input())

#print(s,t)
if min(s) < max(t):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import sys
import fractions
import math
import itertools

n=int(input())
a=list(map(int,input().split()))
list=[]
ans=0

for i in itertools.combinations(a,2):
	value=fractions.gcd(i[0],i[1])
	if ans<=value:
		ans=value

print(ans)
# Judge status: Accepted
import numpy as np
n,m = map(int, input().split())

ac_ques = np.array([0]*n)
count = np.array([0]*n)

for _ in range(m):
    p,s = map(str, input().split())
    if ac_ques[int(p)-1] == 0:
        if s == "WA":
            count[int(p)-1] += 1
        else:
            ac_ques[int(p)-1] = 1

print(sum(ac_ques),sum(ac_ques * count))
# Judge status: Wrong Answer
import sys

def permutation(n, x, mod=10**9+7):
    # nPx
    # 順列
    # ex) permutaion(5, 2) = 20
    tmp = 1
    for i in range(n, n-x, -1):
        tmp = (tmp * i) % mod
    return tmp

N, M = map(int, sys.stdin.readline().strip().split())

if abs(N - M) > 1:
    print(0)
elif N - M == 1:
    print(permutation(N, N) * permutation(M, M) % (10**9+7))
else:
    print(2 * permutation(N, N) * permutation(M, M)  % (10**9+7))
# Judge status: Accepted
import sys
input = sys.stdin.readline
X, A, B = map(int, input().split())
if A - B >= 0: print("delicious")
elif B - A <= X: print("safe")
else: print("dangerous")
# Judge status: Accepted
A, B, C, D = map(int, input().split())
ans = max(min(B, D) - max(A, C), 0)
print(ans)
# Judge status: Accepted
n = int(input())
l = [1]
c = 1
while(6**c <= 100000):
    l.append(6**c)
    c += 1
c = 1
while(9**c <= 100000):
    l.append(9**c)
    c += 1
l.sort()
dp = [100001 for _ in range(n+1)]
dp[0] = 0
for i in range(len(l)):
    for j in range(l[i],n+1):
        dp[j] = min(dp[j],dp[j - l[i]]+1)
print(dp[n])
# Judge status: Accepted
X = int(input())
K = 1
while True:
    if X*K %360 ==0:
        print(K)
        break
    K += 1
# Judge status: Accepted
A = list(input())
print("YES" if A.count("5")==2 and A.count("7")==1 else "NO")
# Judge status: Wrong Answer
from collections import Counter
S = str(input())
CS = Counter(S)
V = list(CS.values())
ans = 'YES'
if len(V) == 1:
  ans = 'NO'
elif len(V) == 2:
  if V[0] >= V[1]+1:
    ans = 'NO'
else:
  if V[0]-V[2] > 1:
    ans = 'NO'

print(ans)
# Judge status: Accepted
X,Y,Z = map (int, input ().split ())
X = X-Z
A = (X/(Y+Z))//1
print (round (A))
# Judge status: Accepted
strings = str(input())
string_list = list(strings)
string_set = set(string_list)

import string

alpha = list(string.ascii_lowercase)
alpha_set = set(alpha)

ans = (alpha_set - string_set)
ans = list(ans)
ans.sort()

if len(ans) > 0:
    print(ans[0])
else:
    print("None")