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

N = int(input())
P = list(map(int, input().split(" ")))
Q = list(map(int, input().split(" ")))
a, b = 0, 0

for i, perm in enumerate(itertools.permutations(range(N))):
    if all([p1 == (p2 + 1) for p1, p2 in zip(P, perm)]):
        a = i
    if all([p1 == (p2 + 1) for p1, p2 in zip(Q, perm)]):
        b = i

print(abs(a - b))
# Judge status: Accepted
n=int(input())
ans=0
lis=[]
def cnt(n):
  ret=0
  for i in range(1,n):
    ret+=i
  return ret
for i in range(n):
  lis.append(sorted(list(input())))
co=1
lis.sort()
bef=lis[0]

for i in lis[1:]:
  if bef!=i:
    ans+=cnt(co)
    co=1
    bef=i
  else:
    co+=1
ans+=cnt(co)
print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())

answer = a * b

if answer / 2 == 0:
    print('Odd')
else:
    print('Even')
# Judge status: Wrong Answer
n,m=map(int,input().split())
cnt_s=n
cnt_c=m
ans=0
if cnt_s>2*cnt_c:
  ans=cnt_c//2
  print(ans)
elif cnt_s<=2*cnt_c:
  ans+=n
  cnt_c-=2*n
  ans+=cnt_c//4
  print(ans)
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    S = input()

    l = 0
    r = 0
    for i in range(len(S)):
        if l==0 and S[i]=='A':
            l = i
        elif S[i]=='Z':
            r = i
    print(r - l + 1)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
x = list(map(int, input().split()))
h = list(map(int, input().split()))

t = x[0]
a = x[1]
cnt = 1000000000000000000000
ans = 0
for i in range(n):
  tmp = abs(t*h[i] - a)
  if cnt > tmp:
    cnt = tmp
    ans = i+1
print(ans)
# Judge status: Wrong Answer
import sys  
import numpy as np
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
k = [0] * (max(a)+1)

for p in a:
    k[p] += 1
ans = 0
for q,r,s in zip(k, k[1:] , k[2:]):
    ans = max(ans, q+r+s)

print(ans)
# Judge status: Wrong Answer
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=sorted(list(map(int,input().split())),reverse=True)
p=p[:x]
q=q[:y]
ans=sum(p)+sum(q)

while p[-1]<r[0] or q[-1]<r[0]:
  if p[-1]<q[-1]:
    ans+=r[0]-p[-1]
    r.pop(0)
    p.pop(-1)
  else:
    ans+=r[0]-q[-1]
    r.pop(0)
    q.pop(-1)
  if p==[] or q==[] or r==[]:
    break
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum


def çözmek():
    h, m, H, M, K = map(int, input().split(" "))
    if H != 0:
        H = H * 60
    if h != 0:
        h = h * 60
    res = H + M - K - h - m
    print(res)
if __name__ == "__main__":
    çözmek()
# Judge status: Accepted
n,m = [int(x) for x in input().split()]
ab = []
for _ in range(n):
    a,b = [int(x) for x in input().split()]
    ab.append([a,b])

sorted_ab = sorted(ab, key=lambda x: x[0])

price = 0
for i in range(n):
    if m > sorted_ab[i][1]:
        price += sorted_ab[i][0] * sorted_ab[i][1]
        m -= sorted_ab[i][1]
    else:
        price += m * sorted_ab[i][0]
        break

print(price)
# Judge status: Accepted
N, M = map(int, input().split())
X = list(input().split())
MAP = list(sorted([int(X[i]) for i in range(M)]))

if M <= N:
    print(0)
else:
    MAP_diff = list(sorted([MAP[i+1] - MAP[i] for i in range(M-1)]))
    print(sum(MAP_diff[:M-N]))
# Judge status: Wrong Answer
n=int(input())
d=dict() 
d["AC"]=0
d["WA"]=0
d["TLE"]=0
d["RE"]=0
for i in range(n): 
  s=str(input()) 
  d[s]+=1
print("AC ×",end=" ")
print(d["AC"])
print("WA ×",end=" ")
print(d["WA"])
print("TLE ×",end=" ")
print(d["TLE"]) 
print("RE ×",end=" ") 
print(d["RE"])
# Judge status: Wrong Answer
s = list(input())
t = list(input())
s.sort()
t.reverse()

S=''.join(map(str, s))
T=''.join(map(str, t))
if S<T:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
#!/usr/bin/env python3
import sys


def solve(S: int, W: int):
    if S <= W: return 'unsafe'
    else: return 'safe'


# 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 = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    print(solve(S, W))

if __name__ == '__main__':
    main()
# Judge status: Accepted
A,B,C,X=[int(input()) for i in range(4)]

print([500*a+100*b+50*c for c in range(C+1) for b in range(B+1) for a in range(A+1)].count(X))
# Judge status: Wrong Answer
s=str(input())
t=str(input())
lens=len(s)
lent=len(t)
cnt=1000
for i in range(lens-lent):
  temp=0
  for j in range(lent):
    if t[j]!=s[i+j]:
      temp+=1
  if temp<cnt:
    cnt=temp
print(cnt)
# Judge status: Accepted
N,M = [int(i) for i in input().split()]
student = [[int(i) for i in input().split()] for j in range(N)]
check = [[int(i) for i in input().split()] + [j+1] for j in range(M)]
print("\n".join(map(str, [min(check, key=lambda x: abs(i[0] - x[0]) + abs(i[1] - x[1]))[-1] for i in student])))
# Judge status: Accepted
s = input()
ans = ""
for c in s:
    if c == "1":
        ans += "1"
    elif c == "0":
        ans += "0"
    else:
        ans = ans[:-1]
print(ans)
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in range(n-1):
    if a[i] + a[i+1] > x:
        y = a[i] + a[i+1] - x
        count += y
        a[i+1] = max(0, a[i+1]-y)
print(count)
# Judge status: Accepted
s = input()
l = []
for i in range(len(s)):
    l.append(s[i])
if l[len(l)-1] == "s":
    print(s+str("es"))
else:
    print(s+str("s"))
# Judge status: Accepted
def gcd(a, b):
    if a<b:
        a,b = b,a
    r = a%b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b
n = int(input())
a = list(map(int,input().split()))
ans = gcd(a[0],a[1])
for i in range(2,n):
    ans = gcd(ans,a[i])
print(ans)
# Judge status: Accepted
N,P = map(int,input().split())
A = list(map(int,input().split()))

odd = [a%2 for a in A].count(1)
even = N - odd
if odd == 0:
    print(0 if P else 2**N)
else:
    print(2**(N-1))
# Judge status: Accepted
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())))

ans = 0
for i in range(N - K):
    ans += H[i]
print(ans)
# Judge status: Wrong Answer
import fractions
import math
a,b,c,d = map(int, input().split())
x1 = (a-1)//c
x2 = b//c
x = x2-x1
y1 = (a-1)//d
y2 = b//d
y = y2-y1
z1 = (a-1)//((c*d)/fractions.gcd(c,d))
z2 = b//((c*d)/fractions.gcd(c,d))
z = z2-z1
print(int((b-a+1)-x-y+z))
# Judge status: Accepted
n = int(input())
x = list(map(int, input().split()))

x_s = sorted(x)

lst = [x_s[(n-1)//2], x_s[n//2]]

for i in x:
    print(lst[0] if i >= lst[1] else lst[1])
# Judge status: Accepted
n= int(input())
x = [input().split() for i in range(n)]
for i in range(n):
    x[i].append(i+1)
y= sorted(x,key= lambda i:(i[0],-int(i[1])))
for i in range(n):
    print(y[i][2])
# Judge status: Wrong Answer
#output <= 1000

nums = [int(e) for e in input().split()]
for i in range(1,1001):
  if ((((i * 8) // 100) == nums[0]) & (((i * 10) // 100) == nums[1])):
    print(i)
  else:
    print(-1)
# Judge status: Accepted
s = input()
t = input()

N, M = len(s), len(t)
min_len = min(N, M)

s_ = sorted(s)
t_ = sorted(t, reverse=True)


for a, b in zip(s_, t_):
    if a == b:
        continue
    elif a > b:
        print('No')
        exit()
    else:
        print('Yes')
        exit()

if N < M:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import bisect

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

A.sort()
B.sort()
C.sort()

ans = 0
for b in B:
    a = bisect.bisect_left(A, b)
    b = bisect.bisect_right(C, b)
    ans += (a + 1)*b 

print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())

for i in range(N-K):
    if T[i+K] == T[i]:
        T[i+K] = 0

print(T.count("r")*P+T.count("s")*R+T.count("p")*S)
# Judge status: Wrong Answer
import math

K = int(input())

_sum = 0
_sum = sum([i for i in range(1, K)])
_sum += sum([sum([math.gcd(i, j)*6 for i in range(j+1, K)]) for j in range(1, K)])

for a in range(1, K):
    for b in range(a+1, K):
        for c in range(b+1, K):
            _sum += math.gcd(math.gcd(a, b), c)
print(_sum)
# Judge status: Wrong Answer
import sys

N, _ = map(int, input().split())
D = input().split()

answer = sys.maxsize
for x in range(N, 10000):
    s = str(x)
    if all([y not in s for y in D]):
        answer = min(answer, x)
print(answer)
# Judge status: Accepted
a,b=map(int,input().split())
c=-1
d=-1
e=-1
x=b//10000
for i in range(0,x+1,1):
  y=(b-10000*i)//5000
  for j in range(0,y+1,1):
    k=(b-10000*i-5000*j)//1000
    if i+j+k==a:
      c=i
      d=j
      e=k
print(c,d,e)
# Judge status: Accepted
a, b, c, d = map(int, input().split())
print("Yes" if (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d else "No")
# Judge status: Accepted
X,N=map(int,input().split())
if N==0:
    print(X)
else:
    a = list(map(int,input().split()))
    res = 10**9
    mi = 10**9
    for val in range(200,-100,-1):
        if val not in a:
            tmp = abs(X-val)
            if res >= tmp:
                res = tmp
                mi = val
    print(mi)
# Judge status: Accepted
s = input()
n = len(s)
d = []
for i in range(n):
    if s[i] == 'B':
        if len(d) > 0:
            d.pop()
    else:
        d.append(s[i])
print(''.join(d))
# Judge status: Accepted
X,Y=map(int,input().split())
for i in range(1,1000):
	if X*(2**i)>Y:
		print(i)
		exit()
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i]-(i+1))
B.sort()
if N%2==0:
  a=N/2
else:
  a=(N+1)/2
b=B[int(a-1)]
for i in range(N):
  B[N-1]=abs(B[N-1]-b)
print(sum(B))
# Judge status: Wrong Answer
import numpy as np
N = int(input())
M = np.fromiter(input().split(), dtype=int)
K = (0.5) ** np.arange(1, N+1)
print(np.dot(M, K))
# Judge status: Accepted
N, M = map(int, input().split())
piys = [[] for _ in range(N)]
for i in range(M):
    p, y = map(int, input().split())
    piys[p-1].append((y, i))

ans = [None]*M
for p, iys in enumerate(piys):
    iys.sort()
    for k, (y, i) in enumerate(iys):
        ans[i] = "%06d%06d" % (p+1, k+1)

for i in ans:
    print(i)
# Judge status: Wrong Answer
S = input()
if "L" in S[::2] and "R" in S[1::2]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys

input = sys.stdin.readline

n = int(input())

print(8 - int((n - 400) / 200))
# Judge status: Accepted
sx, sy, tx, ty = [int(n) for n in input().split()]
dx = tx - sx
dy = ty - sy
print('U'*dy+'R'*dx, end="")
print('D'*dy+'L'*dx, end="")
print('L'+'U'*(dy+1)+'R'*(dx+1)+'D', end="")
print('R'+'D'*(dy+1)+'L'*(dx+1)+'U')
# Judge status: Accepted
import itertools

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

reg = 10**12
Acum = list(itertools.accumulate(A))
for i in range(N):
    L = Acum[i]
    R = Acum[-1] - L
    tmp = abs(L-R)
    reg = min(reg, tmp)
print(reg)
# Judge status: Wrong Answer
N, K = map(int,input().split())
S = list(input())

not_happy = 0
R = 0
R_edge = 0

for i in range (N-1):
    if S[i] == "R" and S[i+1] == "L":
        R += 1

if S[0] == "L":
    R_edge +=1
if S[N-1] == "R":
    R_edge +=1

#print(R)
#print(R_edge)

if K <= R:
    R -= K
elif K <= R + R_edge:
    R = 0
    R_edge -= K - R
else:
    R = 0
    R_edge = 0

not_happy = R*2 + R_edge
happy = N - not_happy

#print(R)
#print(R_edge)
#print(not_happy)
print(happy)
# Judge status: Accepted
A, B, M = map(int, input().split())
*a, = map(int, input().split())
*b, = map(int, input().split())
x, y, c = [], [], []
for _ in range(M):
    xa, ya, ca = map(int, input().split())
    x += [xa]; y += [ya]; c += [ca]
mi = min(a[x[i]-1] + b[y[i]-1] - c[i] for i in range(M))
print(min(mi, min(a)+min(b)))
# Judge status: Accepted
import math

L = int(input())
a = L/3
print(pow(a, 3))
# Judge status: Wrong Answer
X,Y = map(int, input().split())

mod=10 ** 9 + 7
def binomial(n,k):
    x=1
    y=1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return x*pow(y,mod-2,mod)%mod

if (2*X-Y)%3==0 and  (2*Y-X)%3==0:
    a=(2*X-Y)//3
    b=(2*Y-X)//3
    if a<0 and b<0:
        print(0)        
    else:
        print(binomial(a+b,a)%mod)
else:
    print(0)
# Judge status: Wrong Answer
import sys
import math
from functools import reduce
from operator import mul
sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, sys.stdin.readline().split(' ')))
def In(): return int(sys.stdin.readline())
def InS(): return sys.stdin.readline()

S = InS()
T = InS()

if S[:-2:] == T[:-3:]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a, b, c, d = map(int, input().split())
s = max(a, c)
e = min(b, d)
print(e - s if e - s > 0 else 0)
# Judge status: Wrong Answer
n=int(input())
l=list(map(int,input().split()))
l.sort()
for i in range(1,n+1):
  if i<=n//2:
    print(l[n//2])
  else:
    print(l[n//2-1])
# Judge status: Accepted
n,m,x = list(map(int,input().split()))
b = []
import numpy as np
for i in range(n):
    ca = list(map(int,input().split()))
    b.append(ca)
b = np.array(b)
ans = float('inf')
for i in range(1<<n):
    num = np.array([0 for j in range(m+1)])
    for k in range(n):
        if (i>>k&1)==1:
            num += b[k]
    if (num[1:]>=x).sum()==m:
        ans = min(ans, num[0])
print(ans if ans!=float('inf') else -1)
# Judge status: Wrong Answer
s=list(input())
n=int(input())
count=0
for i in range(n):
  a=list(input().split())
  if len(a)==1:
    count+=1
  else:
    if count%2==0:
      if a[1]=='1':
        s.insert(0,a[2])
      else:
        s.insert(-1,a[2])
    else:
      if a[1]=='1':
        s.insert(-1,a[2])
      else:
        s.insert(0,a[2])
if count%2==0:
  print(''.join(s))
else:
  print(''.join(reversed(s)))
# Judge status: Accepted
ri = lambda S: [int(v) for v in S.split()]
def rii(): return ri(input())

A, B, C = rii()

print("Yes" if len(set([A, B, C])) == 2 else "No")
# Judge status: Accepted
n,m=map(int,input().split())
d={}#{中継地:(1 or n)}
flag=False

for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        try:
            flag=(d[b]==n)
        except:
            d[b]=1
    elif b==n:
        try:
            flag=(d[a]==1)
        except:
            d[a]=n
    if flag:
        print('POSSIBLE')
        break

if not flag:
    print('IMPOSSIBLE')
# Judge status: Accepted
n, k = map(int, input().split())
p = [(int(p) + 1) / 2. for p in input().split()]
sumexp = sum(p[:k])
maxexp = sumexp
for i in range(n-k):
  sumexp += p[i+k] - p[i]
  if sumexp > maxexp:
    maxexp = sumexp
print(maxexp)
# Judge status: Accepted
x , k , d= map(int, input().split())

t = abs(x)/d
t2 = abs(x)//d
if t>=k:
    print(abs(x)-k*d)
else:
    x = abs(x)-t2*d
    if (k-t2)%2==0:
        print(x)
    else:
        print(d-x)
# Judge status: Wrong Answer
a, b, c = map(int,input().split())

print(c-a+b)
# Judge status: Accepted
X, N = map(int, input().split())
P = list(map(int, input().split()))
ans = -1
mi = 1000
for i in range(102):
    if i in P:
        continue
    if abs(i-X) < mi:
        mi = abs(i-X)
        ans = i
print(ans)
# Judge status: Wrong Answer
n = int(input())

for i in range(n // 2):
  for j in range(n // 2):
    if i*j == n:
      print('Yes')
print('No')
# Judge status: Accepted
a,b,k = map(int,input().split())
r = range(a,b+1)
for i in sorted (set(r[:k])|set(r[-k:])):
    print(i)
# Judge status: Wrong Answer
N = int(input())
a = [0]*N
b = [0]*N
c = [0]*N

for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

dp = [0] * (N+10)
dp[0] = max(a[0], b[0], c[0])
for i in range(1, N):
    if dp[i-1] == a[i-1]:
        dp[i] = max(b[i], c[i])
    elif dp[i-1] == b[i-1]:
        dp[i] = max(a[i], c[i])
    else:
        dp[i] = max(a[i], b[i])
print(sum([dp[i] for i in range(0, N)]))
# Judge status: Wrong Answer
n = int(input())
c = input()
l = 0
j = 0
a = [0]*n
b = [0]*n
for i in range(n):
  if(c[i]=='W'):
    a[l] =i+1
    l +=1
l = 0
for i in range(n-1,0,-1):
  if(c[i]=='R'):
    b[j] = i+1
    j +=1
j = 0
while(a[l] < b[l]):
      a[l]=0
      b[l]=0
      l+=1
      j+=1
print(j)
# Judge status: Wrong Answer
N=int(input())
S=list(input())
A=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
newS=[]
for i in range(len(S)):
  for r in range(len(A)):
    if S[i]==A[r]:
      a=r+N
      if r+N>25:
        a=(r+N)%25-1
      newS.append(A[a])
for h in range(len(newS)):
  print(*newS[h],end='')
# Judge status: Accepted
n,m = map(int,input().split())
count = 0
s = 2*n
if m-s < 0:
    print(m//2)
else:
    m -= s
    m = (m//2)//2
    print(n+m)
# Judge status: Accepted
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
a_list = list(map(int, input().split()))
l_dict = {}
ans = 0
for i in range(0, n):
    a = a_list[i]
    ri = i - a
    if ri in l_dict:
        ans += l_dict[ri]
    li = i + a
    if li in l_dict:
        l_dict[li] += 1
    else:
        l_dict[li] = 1
print(ans)
# Judge status: Accepted
A,B,X = map(int,input().split())

if X < A:
    print("NO")
    exit()
    
if (A+B) < X:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
N = int(input())
A = input().split()
A = [int(a) for a in A]

D = {}

for a in A:
    D[a] = D.get(a, 0) + 1

cnt = 0
for k, v in D.items():
    if k < v:
        cnt += v - k
    elif v < k:
        cnt += v
print(cnt)
# Judge status: Wrong Answer
import math
x,y=map(int,input().split())
a=int(math.log2(y)-math.log2(x))
print(a+1)
# Judge status: Accepted
N = str(input())
if N[-1] == '2' or N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
    print('hon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
else:
    print('bon')
# Judge status: Accepted
from itertools import accumulate
N = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
acc1 = list(accumulate(A[0], lambda x,y:x+y))
acc2 = [0]+list(accumulate(A[1], lambda x,y:x+y))
ma = -1
for i in range(N):
    ma = max(ma, acc2[-1]-acc2[i]+acc1[i])
print(ma)
# Judge status: Accepted
n, m = map(int, input().split())
ps = []
memo = [0 for i in range(n)]
pena = [0 for i in range(n)]
for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC":
        memo[p-1] = 1
    else:
        if memo[p-1] == 0:
            pena[p-1] += 1
ans = 0
for i, p in enumerate(pena):
    if memo[i]:
        ans += p
print(sum(memo), ans)
# Judge status: Wrong Answer
import math
from decimal import *
X, Y = map(int,input().split())
getcontext().prec = 40
log = Decimal(math.log2(Decimal(Y) / Decimal(X)))
print(int(math.modf(log)[1]+1))
# Judge status: Accepted
s = list(input())
n = len(s)
t = 0
odd = 0
even = 0
while t < n:
  odd += int(s[t])
  t += 2
u = 1
while u < n:
  even += int(s[u])
  u += 2
if n%2 == 0:
  print(min(n//2+odd-even,n//2+even-odd))
else:
  print(min(n//2+odd-even,n//2+even+1-odd))
# Judge status: Wrong Answer
a, v = map(int, input().split())
b, w = map(int, input().split())

t = int(input())

if v == w:
  print("NO")
  
elif (v < w):
  ans = (a - b) / (v - w)
  if t <= abs(ans):
    print("YES")
  else:
    print("NO")
else:
  ans = (b - a) / (v - w)
  if t > ans:
    print("YES")
  else:
    print("NO")
# Judge status: Accepted
L = [i for i in map(int,input().split())]
L.sort()
print(L[0]+L[1])
# Judge status: Wrong Answer
X, Y, A, B, C = map(int, input().split())
AA = list(map(int, input().split()))
BB = list(map(int, input().split()))
CC = list(map(int, input().split()))
a = sorted(AA, reverse=True)
b = sorted(BB, reverse=True)
c = sorted(CC, reverse=True)

if X < A:
  del a[X:]

if Y < B:
  del b[Y:]
print(a)
print(b)

NEW = a + b + c
NEWnew = sorted(NEW, reverse=True)
del NEWnew[X+Y:]
K = sum(NEWnew)
print(K)
# Judge status: Wrong Answer
s=input()
t=input()
d=dict()
flag=True
for i in range(len(s)):
  if not(t[i] in d):
    d[t[i]]=s[i]
  else:
    if d[t[i]]!=s[i]:
      flag=False
      break
if flag:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
X = int(input())
print(10 - (X // 200))
# Judge status: Accepted

def main():
    n = int(input())
    if n%2 == 1:
        print(0)
        return
    
    five_cnt = 0
    for i in range(1,25+1):
        base = 2*(5**i)
        five_cnt += n//base

    print(five_cnt)

if __name__ == "__main__":
    main()
# Judge status: Accepted
n1 = int(input())
n2 = [int(i) for i in input().split()]

t3 = 0

for i4 in range(n1):
    if n2[i4] != i4 - t3 + 1:
        t3 += 1



if t3 == n1:
    print(-1)
else:
    print(t3)
# Judge status: Wrong Answer
a = str(input())
k = 0
for i in a:
    print(i)
    if i == ("0"):
        k += 0
    elif i == ("1"):
        k += 1
print(k)
# Judge status: Wrong Answer
number = input()
count = 0

for n in number:
    if n == 1:
      count += 1

print(count)
# Judge status: Accepted
from collections import Counter

n,k=list(map(int,input().split()))
enum=0
denom=2**20

for pip in range(1,n+1):
    cnt=0
    score=pip
    while score<k:
        score*=2
        cnt+=1
    
    enum+=2**(20-cnt)

print(enum/denom/n)
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = str(input())
if '##' in s[a:c] or '##' in s[b:d]:
    print('No')
else:
    if c < d:
        print('Yes')
    else:
        if '...' in s[b - 2:d + 1]:
            print('Yes')
        else:
            print('No')
# Judge status: Accepted
C = [input() for _ in range(2)]
f = C[0][0] == C[1][2] and C[0][1] == C[1][1] and C[1][0] == C[0][2]
if f:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
if __name__ == '__main__':
	x,n = map(int,input().split())
	p = [int(a) for a in input().split()]
	p.sort()
	if x in p:
		m = 100
		ans = 0
		for i in range(-10,200):
			if not i in p:
				v = abs(i-x)
				if m > v:
					m = v
					ans = i
		print(ans)
	else:
		print(x)
# Judge status: Wrong Answer
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    A = [Z() for _ in range(N)]
    output = 0
    for i in range(N):
        output += A[i]//2
        A[i] %= 2
    for i in range(N-1):
        x = min(A[i], A[i+1])
        output += x
        A[i] -= x
        A[i+1] -= x
    print(output)

    return

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n=int(input())
s=input()
ans = 0

for i in range(n):
    for j in range(n):
        for k in range(n):
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k] and i < j and j < k and j-i != k-j:
                print(i,j,k)
                ans = ans + 1

print(ans)
# Judge status: Wrong Answer
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
if a[0]>x:
  ans+=x-a[0]
  a[0]=x
for i in range(n-1):
  if a[i]+a[i+1]>x:
    t=a[i]+a[i+1]-x
    a[i+1]-=t
    ans+=t
print(ans)
# Judge status: Wrong Answer
S=input()
tmp=S[0]
i=1
ans=1
while i<len(S):
    # print(S[i],tmp)
    if S[i]!=tmp:
        ans+=1
        tmp=S[i]
        i+=1
    else:
        ans+=1
        tmp=S[i:i+2]
        i+=2
if len(S)!=1:
    if S[-2]==S[-1] and tmp!=S[-2:]:
        ans-=1
print(ans)
# Judge status: Wrong Answer
n = int(input())

s = 800 * n - 200 * n//15

print(s)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
d = a - b
e = c - d
print (e)
# Judge status: Wrong Answer
n= int(input())
res = 0
for i in range(1,n+1):
    if i%2 == 1:
        res += 1
print(res)
# Judge status: Accepted
n, k, q = map(int, input().split())

res= [0]*n
for _ in range(q):
    a = int(input())
    res[a-1] += 1

for i in range(n):
    if k-q+res[i] <=0:
        print('No')
    else:
        print('Yes')
# Judge status: Accepted
A,B,X=map(int,input().split())
print("YES" if A<=X and A+B>=X else "NO")
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    s, w = map(int, input().split())
    if w >= s:
        print('unsafe')
    else:
        print('safe')
if __name__ == '__main__':
    main()