peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from fractions import gcd
from collections import deque
n = int(input())
a = list(map(int, input().split()))
l = [0]
r = deque([0])
g = []
for i in range(n):
    l.append(gcd(l[i], a[i]))
    r.appendleft(gcd(r[-(i + 1)], a[-(i + 1)]))
r = list(r)

for i in range(n):
    g.append(gcd(l[i], r[i + 1]))
print(max(g))
# Judge status: Accepted
D,N = map(int,input().split())
#%%
ans = 0
cur = 0
for i in range(1,(100**D)*N*10):
    a = i
    t = 0
    while a%100==0 and a>0:
        a//=100
        t+=1
    if t==D:
        cur += 1
    if cur == N:
        ans = i
        break
print(ans)
# Judge status: Wrong Answer
from functools import lru_cache
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split(' '))))
i = np.arange(1, N + 1)

right = N * max(A)
left = -1 * right


@lru_cache(maxsize=None)
def cost(b):
    return np.sum(np.abs(A - (i + b)))


while True:
    mid = (left + right) // 2
    c_left = cost(left)
    c_right = cost(right)
    if left == mid or right == mid:
        print(min(c_left, c_right))
        break
    elif c_left < c_right:
        right = mid
    else:
        left = mid
# Judge status: Accepted
X = int(input())

for i in range(X+1):
    if (i * (i+1))/2 >= X:
        print(i)
        break
# Judge status: Accepted
def main():
  from collections import Counter
  M=998244353
  n,*d=map(int,open(0).read().split())
  e=Counter(d)
  a=1if d[0]<1==e[0]else 0
  for i in range(n):a*=pow(e[i],e[i+1],M)
  print(a%M)
main()
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

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

A = sorted(A)[::-1]

ans = 0
for i, a in enumerate(A):
    if i==0:
        ans += a
        itr = 2
    else:
        ans += a
        itr += 1
        if itr >= N:
            break
        ans += a
        itr += 1
        if itr >= N:
            break

print(ans)
# Judge status: Wrong Answer
x, y = map(int, input().split())

diff_abs = abs(abs(x) - abs(y))

if x >= 0 and y >= 0:
  ans = diff_abs
elif x < 0 and y < 0:
  ans = diff_abs + 2
else:
  ans = diff_abs + 1

print(ans)
# Judge status: Wrong Answer
n = int(input())

c = [[0 for i in range(10)] for j in range(10)]

for i in range(n):
    if i % 10 == 0:
        continue
    s = str(i)
    a = int(s[0])
    b = int(s[-1])

    c[a][b] += 1

ans = 0

for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]

print(ans)
# Judge status: Wrong Answer
X = list(map(int,input().split()))
A = X[0]
B = X[1]
C = X[2]
K = int(input())
cnt = 0
if A > B:
  for i in range(K):
   B = B*2
   cnt = cnt + 1
   if A < B:
    break
print(B)
if B > C:
  for j in range(K):
   C = C*2
   cnt = cnt + 1
   if B < C:
    break
print(C)
print(cnt)
if cnt <= K:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
def resolve():
    D, N = map(int, input().split())
    if D == 0:
        if N == 100:
            print("101")
        else:
            print(N)
    elif D == 1:
        if N == 100:
            print("10100")
        else:
            print(100*N)
    else:
        if N == 100:
            print("1010000")
        else:
            print(10000*N)
resolve()
# Judge status: Accepted
import copy
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n, 0, -1):
  c = 0
  for j in range(i - 1, n, i):
    c += b[j]
  if c%2 != a[i - 1]:
    b[i - 1] = 1

if sum(b) == 0:
  print(0)
else:
  print(sum(b))
  for i in range(n):
    if b[i] == 1:
      print(str(i + 1), end=" ")
# Judge status: Wrong Answer
p,q,r=map(int,input().split())
if p+q<=q+r and p+q<p+r:
    print(p+q)
if p+r<p+q and p+r<q+r:
    print(p+r)
if q+r<=p+r and q+r<p+q:
    print(q+r)
if p+r==q+r and p+r<p+q:
    print(p+r)
if p==q==r:
    print(p+q)
if r+p==q+r and r+p>p+q:
    print(r+p)
# Judge status: Accepted
A,B,C,K = map(int,input().split())

if A+B<K:
  print(A-(K-A-B))
else:
  print(min(A, K))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
cnt = 0
if len(A)%2==0:
    q = N//2
else:
    q = N//2 + 1
for i in range(q):
  if A[2*i]%2!=0:
    cnt += 1
print(cnt)
# Judge status: Wrong Answer
import math
n,a,b = map(int ,input().split())
d= n**2-1

k= math.factorial(n) // (math.factorial(n - a) * math.factorial(a))
p= math.factorial(n) // (math.factorial(n - b) * math.factorial(b))

print((d-(k+p))%(10**9+7))
# Judge status: Accepted
x,y=map(int,input().split());a=0
while x<=y:x*=2;a+=1
print(a)
# Judge status: Accepted
X = int(input())
i = 1
ok = False
while i * i <= X and not ok:
  if X % i == 0:
    for x in (i, X//i):
      A = -10000
      while A <= 10000:
        if A**5-(A-x)**5 == X:
          print(A, A-x)
          ok = True
          break
        A += 1
      if ok:
        break
  i += 1
# Judge status: Wrong Answer
N = int(input())
L = map(int,input().split())

L = sorted(L,reverse = True)
sum = 0
for i in range(N,2*N):
    sum += L[i]
    
print(sum)
# Judge status: Wrong Answer
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:
        tmp = (A[i] + A[i+1])-x
        ans += tmp
        A[i+1] -= tmp
print(ans)
# Judge status: Accepted
N = int(input())

isDouble = []

for i in range(N):
    temp = [int(j) for j in input().split(" ")]
    if temp[0] == temp[1]:
        isDouble.append(1)
    else:
        isDouble.append(0)

cnt = 0
flg = False

for i in range(len(isDouble)):
    if isDouble[i] == 0:
        cnt = 0
    else:
        cnt += isDouble[i]
    if cnt == 3:
        flg = True
        break

if flg:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def resolve():
    s = input()
    one = 0
    zero = 0
    for i in range(len(s)):
        if s[i] =="0":
            zero += 1
        else:
            one += 1
    print(2*min(zero, one))

resolve()
# Judge status: Accepted
a, b = map(int, input().split())

c = min(a, b)
d = max(a, b)
print(str(c) * d)
# Judge status: Accepted
n = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
ans = 0

for i in range(n//2):
    if i == 0:
        ans += li[i]
    else:
        ans += li[i]*2

if n%2 == 1:
    ans += li[i+1]

print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
drink=[list(map(int,input().split())) for i in range(n)]
#print(drink)

drink.sort()
#print(drink)
money=0
number=0
for i in range(n):
    if number+drink[i][0]<m:
        money+=drink[i][0]*drink[i][1]
        number+=drink[i][1]
    elif m<number+drink[i][0]:
        money+=drink[i][0]*(m-number)
        number+=m-number
        break
    if m==number:
        break
print(money)
# Judge status: Accepted
k, a, b = map(int, input().split())
if a + 2 >= b or k <= a:
    print(k + 1)
else:
    print(a + (k - a + 1) // 2 * (b - a) + (k - a + 1) % 2)
# Judge status: Accepted
d = 25 - (int(input()))
answer = "Christmas"

for i in range(d):
    answer = answer + " " "Eve"

print(answer)
# Judge status: Accepted
iss = lambda x:x == x[::-1]
S = input()
N = len(S)
S1 = S[:(N-1)//2]
S2 = S[(N+3)//2-1:]
print("Yes" if iss(S) and iss(S1) and iss(S2) else "No")
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))

min = P[0]
ans = 1
for i in range(1, N):
  if P[i] <= min:
    ans += 1
    min = P[i]
    
print(ans)
# Judge status: Accepted
n = int(input())
l = []
while(n > 0):
  n -= 1
  l.append(chr(97+(n%26)))
  n = n//26
for i in l[::-1]:
    print(i,end="")
print("")
# Judge status: Accepted
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N)]
CD = [tuple(map(int,input().split())) for i in range(M)]

for a,b in AB:
    ans = -1
    mind = float('inf')
    for i,(c,d) in enumerate(CD):
        dist = abs(a-c) + abs(b-d)
        if dist < mind:
            mind = dist
            ans = i+1
    print(ans)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
K=0
for i  in range(1,N):
    for j in A:
        if j%(2**i)!=0:
            break
    else:
        K+=1
        continue
    break

print(K)
# Judge status: Wrong Answer
import collections
n,cc = raw_input(), collections.Counter(map(int, raw_input().split()))
print sum([(k - cc[k] if k <= cc[k] else cc[k]) for k in cc] or [0])
# Judge status: Accepted
s= input()
t = input()

count = len(t)

for i in range(len(s) - len(t) + 1):
    str_ = s[i:i + len(t)]
    temp = 0
    for i in range(len(str_)):
        #print(str_[i])
        if str_[i] != t[i]:
            temp += 1
    count = min(count, temp)    
        
print(count)
# Judge status: Wrong Answer
a,b = input().split()
a = int(a)
b = int(b)
print (int((a+b) / 2) +1)
# Judge status: Wrong Answer


def solution(h):
    n = len(h)
    INF = float('inf')
    dp = [INF]*n
    dp[0] = 0
    for i in range(n):
        for j in range(i+1,i+3):
            if j < n:
                dp[j] = min(dp[j] , dp[i]+abs(h[i]-h[j]) )
    print(*dp)
    return dp[n-1]

N = int(input())
h = list(map(int,input().split()))
res = solution(h)
print(res)
# Judge status: Accepted
n=int(input())
s=[input() for _ in range(n)]
s=sorted(s,key=lambda x: len(x))
for i in range(n):
    s[i]=sorted(s[i])
x=''.join(set(s[0]))
x=sorted(x)
for i in range(len(x)):
    tmp=s[0].count(x[i])
    for j in range(1,n):
        tmp=min(tmp,s[j].count(x[i]))
    print(x[i]*tmp,end="")
# Judge status: Wrong Answer
n, x = map(int, input().split())
l = list(map(int, input().split()))
result = 0
res = 0
for i in l:
    res+=1
    result += i
    if(result > x):
        break
    
    
print(res)
# Judge status: Accepted
C = input()

alp = "abcdefghijklmnopqrstuvwxyz"
alp = list(alp)

print(alp[alp.index(C)+1])
# Judge status: Accepted
n = int(input())
res = [-1] * n
def do(a, b):
    #print("do",a,b)
    if a >= n:
        return
    res[a] = b
    if a == n - 1:
        print("".join(list(map(lambda x: chr(ord("a") - 1 + x), res))))
        return
    for i in range(1, max(res[0:a+1])+2):
        do(a + 1, i)
do(0, 1)
# Judge status: Wrong Answer
#引数としてopを追加
#opには計算で用いた演算子が文字列として格納されている
def func(i,x,op):
    #ベースケース
    if i == 4:
        if x == 7: return op
        else: return ""

    #足す場合
    opP = func(i+1, x + int(S[i]), op+"+")
    if opP != "": return opP

    #引く場合
    opM = func(i+1, x - int(S[i]), op+"-")
    if opM != "": return opM

    return ""
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(20000000)

def fx(X, n):
    if (int(X/n)):
        return fx(int(X/n), n)+int(X/n)
    return 0

N=int(input())
if N%2==1:
  print(0)
else:
  print(fx(N//2,5))
# Judge status: Accepted
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
mix = lambda x:list(li() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########
def main(n,v):
    v = sorted(v)
    res = (v[0]+v[1])/2
    for i in range(2, n):
        res = (res + v[i]) / 2
    print(res)

n = ii()
v = mi()
main(n,v)
# Judge status: Accepted
# import math
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np


a,b,k = map(int, input().split())
# n = int(input())
# p = list(map(int, input().split()))

if a < k and b > k-a:
    print(0,a+b-k)
elif a >= k:
    print(a-k,b)
else: print(0,0)
# Judge status: Wrong Answer
n = int(input())
s = input().split()

min_s = s[0]
count = 0

for num in s:
  if min_s >= num:
    count += 1
    if min_s > num:
      min_s = num

print(count)
# Judge status: Accepted
a, b, k = map(int, input().split())
ll = []
for i in range(k):
    if a+i <= b:
        ll.append(a+i)
for j in range(k):
    if not b-k+j+1 in ll and b-k+j+1>=a:
        ll.append(b-k+j+1)
for k in ll:
    print(k)
# Judge status: Accepted
import math

dishes=[int(input()) for _ in range(5)]
#print(dishes)

remain=[val%10 for val in dishes if val%10!=0]
up=[math.ceil(val/10)*10 for val in dishes]
#print(remain)
#print(up)
if not remain:
    print(sum(up))
else:
    print(sum(up)-10+min(remain))
# Judge status: Wrong Answer
n, m = map(int, input().split())

l = [-1] * n

for _ in range(m):
    s, c = map(int, input().split())
    s -= 1

    if l[s] == -1:
        l[s] = c

    elif l[s] != c:
        print(-1)
        exit()

if n > 1 and l[0] == 0:
    print(-1)
    exit()

if l[0] == -1:
    l[0] = 1

for i in range(n):
    if l[i] == -1:
        l[i] = 0

print(*l, sep='')
# Judge status: Accepted
from collections import Counter, defaultdict

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

C = Counter(A)
D = defaultdict(bool)
for key in C.keys():
    D[key] = True

B = [True] * N
ans = 0
for i in range(N):
    if not D[A[i]]: continue
    if C[A[i]] > 1:
        D[A[i]] = False

    for a in range(2 * A[i], A[-1] + 1, A[i]):
        D[a] = False

ans = 0
for key in D:
    if D[key]:
        ans += 1
print(ans)
# Judge status: Accepted
# coding: utf-8
S = input()
if (S[0] == S[1]) & (S[1] == S[2]):
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

if min(y) < max(x):
    print ("War")
else:
    if X < max(x) < Y or X < min(y) <= Y:
        print ("No War")
    else:
        print ("War")
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
k = int(input())
list = [a, b, c]
max = max(list)
if a == max:
    print(b+c+(a*2*k))
elif b == max:
    print(a+c+(b*2*k))
else:
    print(a+b+(c*2*k))
# Judge status: Accepted
a,b=input(),input();n=[i+j for i,j in zip(a,b)]
print(*[n,n+[a[-1]]][len(a)-len(b)],sep='')
# Judge status: Accepted
D=int(input())
for i in range(D):
  print((25-i)%26+1)
# Judge status: Accepted
s = input()
x = "abcdefghijklmnopqrstuvwxyz"
ans = "None"
for i in x:
    if i in s:
        pass
    else:
        ans = i
        break
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
keys = [list(map(int, input().split())) for _ in range(M)]

left = 1
right = N
for key in keys:
    if left < key[0]:
        left = key[0]
    if key[1] < right:
        right = key[1]
if right < left:
    print(0)
else:
    print(right - left + 1)
# Judge status: Accepted
N, K = map(int, input().split())
*P, = map(int, input().split())
expectations = [(p + 1) / 2 for p in P]
ans = 0
S = sum(expectations[:K])
for i in range(N - K):
    ans = max(ans, S)
    S = S - expectations[i] + expectations[i + K]
ans = max(ans, S)
print(ans)
# Judge status: Accepted
N=int(input())
L=[]
for i in range(N):
    L.append(input())
C=[]
W=['AC', 'WA', 'TLE', 'RE' ]
Q=[0,0,0,0]
for i in range(N):
    for j in range(4):
        if L[i]==W[j]:
            Q[j]=Q[j]+1
            break
print('AC x '+str(Q[0]))
print('WA x '+str(Q[1]))
print('TLE x '+str(Q[2]))
print('RE x '+str(Q[3]))
# Judge status: Accepted
A,B,C = list(map(int,input().split()))
if A+B==C or A+C==B or B+C==A:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A, B, C = map(int, input().split())
S = A+B+C

k = 0
flag = 0
while k<100:
    if A%2==1 or B%2==1 or C%2==1 or min([A,B,C])<1:
        flag = 1
        break
    An = (B + C)//2
    Bn = (A + C)//2
    Cn = (B + A)//2
    A = An 
    B = Bn 
    C = Cn         
    k += 1

if not flag:
    k = -1

print(k)
# Judge status: Accepted
import sys
row = sys.stdin.readline
def read_string(row):
    return row().rstrip()

S = read_string(row)
dic = {"SUN": 7,
       "SAT":1,
       "FRI":2,
       "THU":3,
       "WED":4,
       "TUE":5,
       "MON":6}
print(dic[S])
# Judge status: Accepted
K,N = map(int, input().split())
As  = list(map(int, input().split()))
Bs = As + [K+As[0]]
diff = [abs(Bs[i+1]-Bs[i]) for i in range(N)]
# print(diff)
mx = 0
print(sum(diff) - max(diff))
# Judge status: Wrong Answer
N, X, Y = map(int, input().split())
ans = [0]*(N-1)

def cal_dis(i, j):
    return min(j-i, abs(i-X)+abs(j-Y)+1)

for i in range(1, N+1):
    for j in range(i+1, N+1):
        k = cal_dis(i, j)
        ans[k] += 1

print('\n'.join(map(str, ans)))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
o = 0
t = 0
f = 0
for i in a:
    if i % 4 == 0:
        f += 1
    elif i % 2 == 0:
        t += 1
    else:
        o += 1
if t > 0:
    print("Yes" if f >= o else "No")
else:
    print("Yes" if f >= o - 1 else "No")
# Judge status: Accepted
r,g,b, = map(str, raw_input().split())
s = int(r+g+b)
print 'YES' if s % 4 == 0 else 'NO'
# Judge status: Accepted
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))
Af = sorted(A, reverse=True)
for a in A:
    if a == Af[0]:
        print(Af[1])
    else:
        print(Af[0])
# Judge status: Accepted
temp=int(input())
if(temp>=30):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import string
from collections import Counter

ans = ""
dic = {}

for a in string.ascii_lowercase:
    dic[a] = 51

N = int(input())
for _ in range(N):
    S = list(input())
    S = Counter(S)
    
    for l, c in dic.items():
        if dic[l] > S[l]:
            dic[l] = S[l]

for k, v in dic.items():
    if v != 51:
        ans += k * v

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

m = n%10
l = n // 10

if m==9 or l==9:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b=map(int,input().split())
flag = True
res = 0
if a % b == 0 or b % a ==0:
  flag = False
if flag:
  res = a*b
else:
  res = max(a,b)
print(res)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
B = sorted([a-i-1 for i, a in enumerate(A)])
m = B[n//2]
print(sum(abs(b-m) for b in B))
# Judge status: Wrong Answer
# coding: utf-8


def main():
    
    takahashi, aoki, action_count = map(int, input().split(' '))

    if action_count < takahashi:
        takahashi = action_count - takahashi
        aoki = aoki
    elif action_count <= (takahashi + aoki):
        aoki -= (action_count - takahashi)
        takahashi = 0
    else:
        takahashi = 0
        aoki = 0
    
    print(takahashi, aoki)

    return 0
    
    
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
W,a,b=map(int, input().split())
if a<b and b<a+W:
    print(0)
else:
    print(max(b-(a+W),a-(b+W)))
# Judge status: Wrong Answer
import bisect
from collections import Counter
import math

n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()

t_limit = []
for i in range(n):
    t_limit.append(t[i] + k)

cnt = 0
ans_l = []

for i in t_limit:
    ans_l.append(bisect.bisect_left(t, i+1))

a = Counter(ans_l)
a = a.values()

plus = 0
for j in a:
    if j > c:
        plus += (math.floor(j/c))

print(len(a) + plus)
# Judge status: Wrong Answer
n = int(input())
ans = 100000000
for i in range(n,n+10000):
    cnt = 0
    s = str(i)
    for j in range(len(s)):
        cnt += int(s[j])
        s2 = str(i-n)
    for j in range(len(s2)):
        cnt += int(s2[j])
    if ans > cnt:
        ans = cnt
    #print(cnt)
print(ans)
# Judge status: Accepted
k = int(input())
s = input()
if len(s)<=k:
    print(s)
else:
    print(s[:k]+'...')
# Judge status: Accepted
N=int(input())

X=[]


for i in range(1,N+1):
    count=0
    while i%2==0:
        i//=2
        count+=1
    X.append(count)

print(X.index(max(X))+1)
# Judge status: Accepted
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

n,m = LI()
h = LI()
high = [0]*n

for i in range(m):
    a, b = LI()
    if h[a-1]>h[b-1]:
        high[b-1] += 1
    elif h[a-1]==h[b-1]:
        high[a-1] += 1
        high[b-1] += 1
    else:
        high[a-1] += 1
print(high.count(0))
# Judge status: Accepted
X, Y = map(int, input().split())

cnt = 0
while X <= Y:
    cnt += 1
    X *= 2
print(cnt)
# Judge status: Accepted
#x=int(input())
a,b,k=map(int,input().split())
#xl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

ansl=[]

for i in range(1,min(a,b)+1):
    if a%i==0 and b%i==0:
        ansl.append(i)

ansl.sort(reverse=True)

print(ansl[k-1])
# Judge status: Wrong Answer
s = sorted(input())
t = sorted(input(), reverse=True)

ans = "Yes"
if s == t:
    ans = "No"
else:
    for i in range(len(s)):
        if i == len(t):
            break
        elif s[i] == t[i]:
            continue
        elif s[i] < t[i]:
            break
        else:
            ans = "No"
            break

print(ans)
# Judge status: Accepted
N = int(input())

cnt = [[0]*10 for i in range(10)]
# 先頭がi, 末尾がjであるような数の個数を計算
for n in range(1, N+1):
    n = str(n)
    i = int(n[0])
    j = int(n[-1])
    cnt[i][j] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j]*cnt[j][i]

print(ans)
# Judge status: Accepted
import heapq
from bisect import bisect_left, bisect_right

n = int(input())
a = int(input())
q = [a*(-1)]
# ans = 1

for _ in range(n-1):
    a = int(input())
    # bより大きい最小要素のindex/value
    ind = bisect_right(q, a*(-1))
    ind = ind if 0 <= ind < len(q) else None
    if ind is None:
        q.append(a*(-1))
    else:
        q[ind] = a*(-1)

print(len(q))
# Judge status: Accepted
a,b,c,k=map(int,input().split())
if a>=k:
    print(k)
elif b>=k-a:
    print(a)
else:
    print(a-(k-a-b))
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([ai - bi for ai, bi in zip(a,b) if ai > bi]) <= sum(b) - sum(a)
rule3 = sum([bi - ai for ai, bi in zip(a,b) if bi > ai]) <= sum(b) - sum(a)
if rule1 and rule2 and rule3:
  ans = True

text = "Yes" if ans else "No"
print(text)
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int, input().split())),reverse = True)
Alice = 0
Bob = 0
count = 0

while True:
    Alice += a[count]
    count += 1
    if count == n:
        print(Alice - Bob)
        exit()
    Bob += a[count]
    count += 1
    if count == n:
        print(Alice - Bob)
        exit()
# Judge status: Accepted
N, L = (int(x) for x in input().split())
A = []
for i in range(N):
  A.append(L+i)
s = sum(A)
m = 1000
ans = 0
for i in range(N):
  t = A.pop(i)
  if abs(sum(A)-s) <= m:
    m = abs(sum(A)-s)
    ans = sum(A)
  A.insert(i,t)
print(ans)
# Judge status: Accepted
import itertools
a = [0, 1, 2, 3, 4, 5]
x = int(input())
n = x // 100
m = x % 100
for c in itertools.combinations_with_replacement(a, n):
    if sum(c) == m:
        print(1)
        break
else:
    print(0)
# Judge status: Accepted
a,b,c,k = map(int,input().split())
if k%2 == 0 and a-b <= 10**18:
    print(a-b)
elif k%2 != 0 and a-b <= 10**18:
    print(b-a)
else:
    print("Unfair")
# Judge status: Accepted
N=int(input())
*D,=map(int,input().split())
M=max(D)
from collections import*
C=Counter(D)

ans=1
now=C[1]
for i in range(2,M+1):
    ans*=pow(now,C[i],998244353)
    ans%=998244353
    now=C[i]

if D[0]!=0:
    ans=0
if 0 in D[1:]:
    ans=0
print(ans)
# Judge status: Accepted
A,B,C=map(int,input().split())

if A<C<B or B<C<A:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
W, a, b = map(int, input().split())
if a > b:
    a, b = b, a
print(max(0, b - (a + W)))
# Judge status: Accepted
a, b, k = map(int, input().split())
t = 100
cnt = 0
while t > 0:
    if a%t == 0 and b%t == 0:
        cnt+=1
        if cnt == k: break
    t-=1
print(t)
# Judge status: Accepted
s=input()
t=input()
ans="UNRESTORABLE"
for i in range(len(s)-len(t),-1,-1):
    ss=s[i:i+len(t)]
    flag=0
    for j in range(len(t)):
        if ss[j]=="?":
            ss=ss[0:j]+t[j]+ss[j+1:]
        if ss[j]!=t[j]:
            flag=1
            break
    if flag==0:
        ans=s[0:i].replace("?","a")+ss+s[i+len(t):].replace("?","a")
        break
print(ans)
# Judge status: Accepted
input_num = input().split()
N = int(input_num[0])
A = int(input_num[1])
B = int(input_num[2])

result = 0

for num in range(1, N+1):
  str_num = str(num)
  cur_sum = 0
  for i in range(len(str_num)):
    cur_sum += int(str_num[i])
  if cur_sum >= A and cur_sum <= B:
    result += num
        
print(result)
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1, N):
  ans += (N-1) // i
print(ans)
# Judge status: Accepted
n=int(input())
s=[input() for i in range(n)]
a=set()
for i in range(n):
    a.add(s.pop())
print(len(a))