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

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

D={}
for _ in range(M):
    B,C=map(int,input().split())
    if -C in D:
        D[-C]+=B
    else:
        D[-C]=B

H=list(D.items())
heapq.heapify(H)

G=[]
Y=0
while Y<N and H:
    (a,k)=heapq.heappop(H)
    a=-a
    k=min(k,N-Y)
    A+=[a]*k
    Y+=k

A.sort(reverse=True)
print(sum(A[:N]))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort()
a.reverse()
if n%2==0:
    s=0
    s=2*(sum(a[0:(n//2)]))-a[0]
    print(s)
else:
    s=0
    s=2*(sum(a[0:(n//2)+1]))-a[0]-a[n//2]
    print(s)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

X=0
for i in A:
    X^=i
#print(X)

L=[]
for i in A:
    L.append(X^i)
print(*L)
# Judge status: Accepted
a, b, c = map(int, input().split())

d = c - a - b
cond = d > 0 and 4 * a * b < d ** 2
if cond:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  if a[i] in dic:
    dic[a[i]]+=1
  else:
    dic[a[i]]=1
ans=0
for i in dic.values():
  ans+=i*(i-1)/2
for i in range(n):
  bk=dic[a[i]]
  print(int(ans-bk+1 if bk>1 else ans))
# Judge status: Accepted
s=''
for i in input():
    if i!='B':
        s+=i
    else:
        if s!='':
            s=s[:-1]
print(s)
# Judge status: Accepted
a, b, c, x, y = map(int, input().split())
ans = x * a + y * b

for i in range(1, 10 ** 5 + 1):
    ans = min(ans, max(x - i, 0) * a + max(y - i, 0) * b + i * 2 * c)

print(ans)
# Judge status: Accepted
n,d=map(int,input().split())
s=2*d+1
a=n//s
if n%s==0:
  print(a)
else:
  print(a+1)
# Judge status: Accepted
n = int(input())
aa =list(map(int, input().split()))

list1 =[0] * n
cnt = 1  
for i in range(n-1):
  if aa[i+1] > aa[i]:
    list1[i+1] = 1
  elif aa[i+1] < aa[i]:
    list1[i+1] = -1
  elif aa[i+1] == aa[i]:    
    list1[i+1] = 0

while 1 in list1 and -1 in list1:
  del list1[:max(list1.index(1), list1.index(-1))]
  list1[0] = 0
  cnt += 1
  
print(cnt)
# Judge status: Wrong Answer
s=input()
print(s[:3]+'8'+s[5:])
# Judge status: Accepted
from collections import deque
n,m = map(int,input().split())

net = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int,input().split())

    net[a].append(b)
    net[b].append(a)

a = [-1] * (n+1)
d = deque()
d.append(1)
while d:
    u = d.popleft()
    for child in net[u]:
        if a[child] != -1:continue
        a[child] = u
        d.append(child)
print("Yes")
print(*a[2:], sep = " ")
# Judge status: Accepted
a,b=map(int,input().split())
if a>b:
    print(a-1)
else:
    print(a)
# Judge status: Accepted
n,m,x,y = map(int,input().split())
x_list = list(map(int,input().split()))
y_list = list(map(int,input().split()))

isWar = True
z = min(y_list)
if (x<z<=y) and (max(x_list)<z):
    isWar = False

if isWar:
    print('War')
else:
    print('No War')
# Judge status: Wrong Answer
a,b = map(int,input().split())
print(int(a==b))
# Judge status: Accepted
def main():
  N=int(input())
  values=[]
  val=6
  while val<=N:
    values.append(val)
    val*=6
  
  val=9
  while val<=N:
    values.append(val)
    val*=9
  values.append(1)
  values.sort()
  dp=[N]*(N+1)
  dp[0]=0
  for i in range(N):
    for v in values:
      if i+v>N:break
      dp[i+v]=min(dp[i]+1,dp[i+v])
  print(dp[N])
  pass
if __name__ == '__main__':
  main()
# Judge status: Accepted
N = int(input())
S = input()
import collections

c = collections.Counter(S)

ls = list(c.values())

ans = 1
for l in ls:
  ans *= (l+1)

print((ans-1)%(10**9+7))
# Judge status: Wrong Answer
n,l=map(int,input().split())
ans=[]
sum=0
for i in range(n):
    ans.append([abs(l+i),l+i])
    sum+=l+i
ans.sort()
print(ans)
print(sum-ans[0][1])
# Judge status: Accepted
a , b , c = map(int,input().split())
if a <= c <= b:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
MM = input().split()
N = int(MM[0])
M = int(MM[1])
list1 = []
list2 = []
for i in range(N):
  LL = input().split()
  list1.append(LL)

for i in range(M):
  MM = input().split()
  list2.append(MM)

for i in list1:
  mini = 40**8
  ans = 0
  for j in range(len(list2)):
    x = int(i[0]) - int(list2[j][0])
    y = int(i[1]) - int(list2[j][1])
    xx = abs(x) + abs(y)
    if xx < mini:
      mini = xx
      ans = j+1
  print(ans)
# Judge status: Wrong Answer
a, b, c, k = map(int, input().split())

ans = abs(b - a) * (-1) ** (k%2 + 1)
if abs(ans) > 1000000000000000000:
    print("Unfair")
else:
    print(ans)
# Judge status: Wrong Answer
a,b=input().split()
a=int(a)
b=int(b)
if (a*b)%2==0:
    print('Odd')
elif (a*b)%2==1:
    print('Even')
# Judge status: Wrong Answer
import networkx as nx
x,y= list(map(int, input().split()))
G = nx.Graph()
lis=[0]*(x-1)
for i in range(y):
    j,k= list(map(int, input().split()))
    G.add_edge(j-1,k-1)
for j in range(x-1):
    z=nx.dijkstra_path_length(G,0,j+1)
    lis[j]=z

if 0 in lis:
    print("No")
else:
    print("Yes")
    for j in range(len(lis)):
        print(lis[j])
# Judge status: Accepted
n = int(input())
s = input()
ing_total = 0
N = int(n/2)
if n % 2 == 1:
    print("No")
else:
    for i in range(N):
        if s[i] == s[i+N]:
            ing_total +=1
        else:
            ing_total += 0
    if N == ing_total:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
a,b=list(map(int,input().split()))
A=B=''
for i in range(b+1):
  A=A+str(a)
for i in range(a+1):
  B=B+str(b)

print(int(min(A,B)))
# Judge status: Wrong Answer
N = int(input())
from math import log

max6 = int(log(N, 6))
max9 = int(log(N, 9))
dp = [10**18]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    dp[i] = dp[i-1]+1
    for j in range(max6+1):
        if 6**j>i:
            break
        dp[i] = min(dp[i-6**j]+1, dp[i])
    for k in range(max9+1):
        if 9**k>i:
            break
        dp[i] = min(dp[i-9**k]+1, dp[i])

print(dp[-1])
# Judge status: Wrong Answer
N,A,B=map(int, input().split())
S=input().split()
cntA=0
cntB=0
for s in S:
  if s == 'c':
    print('No')
    continue
  if s == 'a' and (cntA+cntB) < A+B:
    print('Yes')
    cntA +=1
  elif (s == 'b') and ((cntA+cntB) < A+B) and (cntB < B):
    print('Yes')
    cntB +=1
  else:
    print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C=[]
for i in range(N):
    C.append(sum(A[0:i+1])+sum(B[i:]))
print(max(C))
# Judge status: Wrong Answer
a,b,c = map(int, input().split())

print("Yes" if c < b and a < c else "No")
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if p[i]<p[j]<p[k]:
                ans += 1
print(ans)
# Judge status: Wrong Answer
N=int(input())

if 1<N<=999:
	print("ABC")
elif 999<N<=1998:
 	print("ABD")
# Judge status: Accepted
N = int(input())

Lst = list(range(400,2200,200))
L = sorted(Lst,reverse=True)

for i in range(len(L)):
    if L[i] <= N < L[i]+200:
        ans = i

print(str(ans))
# Judge status: Wrong Answer
A, B = map(int, input().split())

import math

a = math.floor(math.sqrt(A))
b = math.floor(math.sqrt(B))

A_ = []
for i in range(1, a+1):
    if A % i == 0:
        A //= i
        A_.append(i)
        
B_ = []
for i in range(1, b+1):
    if B % i == 0:
        B //= i
        B_.append(i)

count = 0
for i in A_:
    if i in B_:
        count += 1

print(count)
# Judge status: Accepted
n,m = map(int,input().split())
ans = 0

import math

if n == m:
    ans = (math.factorial(n)%(10**9+7)) * (math.factorial(m)%(10**9+7)) * 2
    
elif abs(n-m) == 1:
    ans = (math.factorial(n)%(10**9+7)) * (math.factorial(m)%(10**9+7))
    
print(ans%(10**9+7))
# Judge status: Accepted
#!/usr/bin/env python3
import sys
from bisect import bisect_left

def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0

    for i in range(N-1):
        for j in range(i+1,N):
            index = bisect_left(L,L[i]+L[j])
            ans += max(0,index-j-1)
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b, c, d = map(int, input().split())
while a > 0 and c > 0:
    c -= b
    if c <= 0:
        break
    a -= d
print('Yes' if c <= 0 else 'No')
# Judge status: Wrong Answer
n = int(input())
minn = 10**12
for i in range(5):
    minn = min(minn, int(input()))
print(n // minn + 5)
# Judge status: Accepted
a, b, x = map(int, input().split())

# ans = 0
bx = b//x + 1
ax = (a-1)//x + 1
ans = bx - ax
print(ans)
# Judge status: Wrong Answer
import numpy as np
S = list('vvvvvv')#input())
print(int(np.sum([1 for a, b in zip(S[:int(np.floor(len(S)/2))], list(reversed(S[int(np.ceil(len(S)/2)):]))) if not a == b])))
# Judge status: Accepted
N, M = map(int, input().split())
a_list = [int(input()) for _ in range(M)]

mod = 1000000007

DP = [-1] * (N + 1) 
DP[0] = 1 
DP[1] = 1 

def fib(n):
    for i in range(2, n + 1):
        DP[i] = DP[i-1] + DP[i-2]
    
    return DP[n]

ans = 1
x = 0

for a in a_list:
    if a == x:
        ans = 0
        break
    
    ans = (ans * fib((a-1)-x)) % mod
    x = a+1
else:
    ans = (ans * fib(N-x)) % mod
    
print(ans)
# Judge status: Accepted
a, b = list(map(int,input().split()))
if a == b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,a,b=map(int,input().split())
ans=0

for i in range(n):
    i_moji=str(i+1)
    array=list(map(int,i_moji))
    if sum(array)>=a and sum(array)<=b:
        ans+=i+1

print(ans)
# Judge status: Accepted
s = int(input())
MOD = 1000000007
dp = [0] * (s+1)
dp[0] = 1
for i in range(1, s+1):
    for j in range(0, (i-3)+1):
        dp[i] += dp[j]
        dp[i] %= MOD

print(dp[s])
# Judge status: Accepted
import collections
import sys
a=input()
b=[]

for i in a:
  b.append(i)
  
b.sort()
c=collections.Counter(b)
c=list(c.values())

for i in range(len(c)):
  if int(c[i])%2==0:
    q=0
  else:
    q=1
    print('No')
    sys.exit()
    
print('Yes')
# Judge status: Accepted
N, K = map(int, input().split())
RSP = list(map(int, input().split()))
T = list(input())
rsp = ['r', 's', 'p']
for i in range(N-K):
    if T[i] == T[i+K]:
        T[i+K] = 0
print(sum(RSP[i]*T.count(rsp[(i+1)%3]) for i in range(3)))
# Judge status: Accepted
n, l = map(int, input().split())
s = sorted(input() for i in range(n))
print(*s, sep='')
# Judge status: Accepted
n,k,x,y=[int(input()) for i in range(4)]
if n-k > 0:
  print(k*x+(n-k)*y)
else:
  print(n*x)
# Judge status: Wrong Answer
N, M, K = map(int, input().split())

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

ans = 0

while K >= 0:
    if len(A) > 0 & len(B) > 0:
        if A[0] <= B[0]:
            k = A.pop(0)
        else:
            k = B.pop(0)
    elif A:
        k = A.pop(0)
    elif B:
        k = B.pop(0)
    else:
        break
    K -= k
    if K >= 0:
        ans += 1
    
print(ans)
# Judge status: Accepted
a,b,c = map(int, input().split())
if (c+b)>=a:
    print(b+c-a)
else:
    print(0)
# Judge status: Wrong Answer

a, b, c, k = map(int, input().split())

if a + b >= k:
    print(a)
else:
    print(a - (k - a - b))
# Judge status: Accepted
n = int(input())

print(800*n - 200*(n//15))
# Judge status: Accepted
S = input()
print('x' * len(S))
# Judge status: Accepted
n,Y=map(int,input().split())
Y//=1000

ans=False
for x in range(n+1):
    for y in range(n+1):
        if Y-10*x-5*y==n-x-y and (n-x-y)>=0:
            ans=True
            break
    if ans==True:
        break

if ans is True:
    print(x,y,n-x-y)
else:
    print(-1,-1,-1)
# Judge status: Wrong Answer
n,k=map(int,input().split())
cnt=0
j=17
for i in range(1,n+1):
    if i>=k:
        cnt+=1
    else:
        while i*(2**j)>k:
            j-=1
        cnt+=1/2**(j+1)
print(cnt/n)
# Judge status: Accepted
N,M,*f = open(0).read().split()
N = int(N)
M = int(M)
A = f[:N]
B = f[N:]
for i in range(N-M+1):
    for j in range(N-M+1):
        if A[i][j:j+M] == B[0]:
            for k in range(1,M):
                if A[i+k][j:j+M] != B[k]:
                    break
            else:
                print('Yes')
                break
    else:
        continue
    break
else:
    print('No')
# Judge status: Wrong Answer
K=int(input())
A,B=map(int,input().split())
c=B-A
d=c-K
if d>-2:
  print('OK')
else:
  print('NG')
# Judge status: Wrong Answer
s_in = input()
if s_in[2]==s_in[3] and s_in[4]==s_in[5]:
    print('yes')
else:
    print('no')
# Judge status: Accepted
def main():
    n,k = map(int,input().split())
    A = list(map(int,input().split()))

    left = 0
    right = max(A)

    while abs(right-left)>1:
        cent = (right+left)//2
        
        ct = 0
        for a in A:
            ct+=(a-0.1)//cent
        
        if ct <= k:
            right=cent
        else:
            left=cent
    
    print(right)
main()
# Judge status: Accepted
import math
print(math.factorial(int(input()))%(10**9+7))
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
if A == B:
    print('NO')
elif A > B:
    if C % (A - B) == 0 or (B - C) % (A - B) == 0:
        print('YES')
    else:
        print('NO')
else:
    if (B - C) % A == 0:
        print('YES')
    else:
        print('NO')
# Judge status: Accepted
a,b,c=map(int,input().split());print([c,max(c-(a-b),0)][a-b>0])
# Judge status: Wrong Answer
# Hello World program in Python
from collections import Counter as cn

d = int (input())
l = []
for k in range(d):
  r = input()
  l.append(cn(r))

oi = l[0]

for g in range(1,d):
    oi = oi & l[g]
    print(oi)
    
print("".join(sorted(oi.elements())))
# Judge status: Accepted
n,k = map(int,input().split())
A = set([i for i in range(1,n+1)])
B = set()
for _ in range(k):
    input()
    tmp = list(map(int,input().split()))
    B = B | set(tmp)
ans = A-B
print(len(ans))
# Judge status: Accepted
X = int(input())
print(10 - X // 200)
# Judge status: Accepted
k, n = map(int, input().split())
alst = list(map(int, input().split()))
alst.append(alst[0] + k)
minus = 0
for i in range(n):
  minus = max(minus, alst[i + 1] - alst[i])
print(k - minus)
# Judge status: Wrong Answer
N,M=map(int,input().split())
h={i for i in range(1,M+1)}
for _ in range(N):
  a=list(map(int,input().split()))
  a=set(a[1:])
  h-=a
print(len(a))
# Judge status: Accepted
sx,sy,tx,ty=map(int,input().split())
d=tx-sx
h=ty-sy
s='U'*h+'R'*d+'D'*h+'L'*(1+d)+'U'*(1+h)+'R'*(1+d)+'D'+'R'+'D'*(h+1)+'L'*(d+1)+'U'
print(s)
# Judge status: Wrong Answer
N = int(input())
MIN = float("inf")
for _ in range(5):
    MIN = min(MIN, int(input()))

print((N // MIN) + 5)
# Judge status: Wrong Answer
from itertools import permutations


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

p = q = 0
for i, x in enumerate(permutations(range(1, N + 1))):
    x = list(x)
    if x == P:
        p = i
    elif x == Q:
        q = i
print(abs(p - q))
# Judge status: Accepted
a,b,k=map(int,input().split())

a = a - k

if a < 0:
    b = 0 if b+a <0 else  b+a
    a=0
print (a,b)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

dict_diffs = dict()
for i in range(1, n+1):
  dict_diffs[i+a[i-1]] = dict_diffs.get(i+a[i-1], 0) + 1
total = 0
for j in range(1, n+1):
  total += dict_diffs.get(j-a[j-1], 0)
print(total)
# Judge status: Accepted
import sys
n,k=map(int,input().split())
d=set(input().split())
for i in range(n,99999+1):
  flag=True
  s=str(i)
  for j in s:
    if j in d:
      flag=False
      break
  if flag:
    print(i)
    sys.exit()
# Judge status: Accepted
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys
import itertools

import numpy as np

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

a,b,h=map(int, read().split())
print(h*(b+a)//2)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s, t = input().split()
a, b = map(int, input().split())
u = input()
if s == u:
    print(a - 1, b)
else:
    print(a, b - 1)
# Judge status: Accepted
A,B,N = map(int,input().split())
def f(x):
  f = int((A*x)/B)-A*int(x/B)
  return f
if(B-1 < N):
  print(f(B-1))
else:
  print(f(N))
# Judge status: Accepted
# -*- coding: utf-8 -*-


def main():
    from collections import Counter

    n = int(input())
    a = list(map(int, input().split()))
    b = Counter(a)
    ans = 0

    for key, value in b.items():
        if value > key:
            ans += value - key
        elif value < key:
            ans += value

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n=int(input())
b=list(map(int,input().split()))
ans=[]
ans.append(b[0])
for i in range(1,n-1):
    ans.append(min(b[i],b[i-1]))
ans.append(b[n-2])
print(sum(ans))
# Judge status: Wrong Answer
import itertools
N = int(input())
S = list(input())
num = [i for i in range(0,N)]
C = list(itertools.combinations(num,3))
ans = 0
for c in C:
    if c[1]-c[0] == c[2]-c[1]:
        continue
    if S[c[0]] != S[c[1]] and S[c[1]] != S[c[2]]:
        ans += 1
print(ans)
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))
B=sorted([A[i]-(i+1) for i in range(n)])
if n%2==1:
    b=B[n//2]
else:
    b=(B[n//2-1]+B[n//2])//2
r=0
for i in range(n):
    r+=abs(B[i]-b)
print(r)
# Judge status: Accepted
X,Y=map(int,input().split())

print(X+Y//2)
# Judge status: Accepted
import sys

def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

a = I()
s = S()

if a >= 3200:
    print(s)
else:
    print('red')
# Judge status: Accepted
import math
a= input()
length=math.floor(len(a)/2)
count = 0
for i in range(length):
    if a[i] is not a[-1*i -1]:
        count += 1
        
print(count)
# Judge status: Accepted
s = input()
hi = "hi"
if s == "hi" * (len(s)//2):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
w,a,b=map(int,input().split())
if w+a >= b:
    print('0')

else:
    if b<=a:
        print(a-b)
    else:
        print(b-a-w)
# Judge status: Accepted
n = int(input())
s = input()

w = [0]*n
e = [0]*n

for i in range(n):
  if s[i] == "W": w[i] += 1
  else: e[i] += 1
  if i != n-1:
    w[i+1] = w[i]
    e[i+1] = e[i]

ans = e[-1]-e[0]
for i in range(1,n):
  ans = min(ans, w[i-1] + e[-1]-e[i])
print(ans)
# Judge status: Accepted
N, X, T = map(int, input().split())
if N % X == 0:
    print((N//X)*T)
else:
    print((N//X + 1)*T)
# Judge status: Wrong Answer
s=list(input())
from copy import copy
t=s.copy()

for i in range(1,len(t)+1):
  if len(s)%2==0 and s[:len(s)%2]==s[len(s)%2+1:]:
    print(len(s)%2)
    exit()
  else:
    s.remove(s[-1])
# Judge status: Accepted
line = input()
line = line.rstrip().split(' ')

x = int(line[0])
n = int(line[1])

line = input()
line = line.rstrip().split(' ')

p = []

for i in range(n):
    p.append(int(line[i]))
p.sort()

if  n == 0:
    print(x)
else:
    min = p[0] - 1
    max = p[-1] + 1
    answer = 1000
    for i in range(min, max + 1):
        if i in p:
            continue
        if abs(x - i) < abs(x - answer):
            answer = i

    print(answer)
# Judge status: Accepted
import copy

N = int(input())

x = list(map(int,input().split()))
sort_x = copy.copy(x)
sort_x.sort()

center_num = (N-1) // 2

for l in x:
    if l <= sort_x[center_num]:
        print(sort_x[center_num+1])
    else:
        print(sort_x[center_num])
# Judge status: Wrong Answer
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

s = input()
for a in range(len(s)-1):
    for b in range(a+1,len(s)):
        if s[a] == s[b]:
            neko = 1
if neko:
    pn()
else:
    py()
# Judge status: Accepted
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))
sl = sorted(s)
sm = sum(sl)
if sm%10 == 0:
    for i in range(n):
        if (sm - sl[i])%10 != 0:
            sm -= sl[i]
            break
if sm%10 == 0:
    print(0)
else:
    print(sm)
# Judge status: Accepted
a,b,c,d=map(int, input().split());print("YNeos"[(abs(b-a)>d or abs(c-b)>d)and(abs(c-a)>d)::2])
# Judge status: Accepted
import math
h=int(input())
w=int(input())
n=int(input())
print(math.ceil(n/max(h,w)))
# Judge status: Accepted
N,M,X,Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
maxX = max(x)
minY = min(y)
if maxX < minY:
    print("No War")
else:
    print("War")
# Judge status: Accepted
X, N = (int(i) for i in input().split())  
p = list(int(i) for i in input().split())  
cnt = 1000
res = 0
for i in range(110):
  if i in p :
    cnt = cnt
  else:
    if abs(X-i) < cnt :
      cnt = abs(X-i)
      res  = i
print(res)
# Judge status: Wrong Answer
def x(K: int, S: str) -> str:
    if len(S) <= K:
        return S
    else:
        return S[:K] + '...'
# Judge status: Accepted
n,m = map(int,input().split())
s_list = [list(map(int,input().split())) for _ in range(n)]
c_list = [list(map(int,input().split())) for _ in range(m)]

def distance(list1,list2):
    return abs(list1[0]-list2[0]) + abs(list1[1]-list2[1])

for i in range(n):
    student = s_list[i]
    distance_list = []
    for j,c in enumerate(c_list):
        dist = distance(student,c)
        distance_list.append(dist)
    print(distance_list.index(min(distance_list))+1)
# Judge status: Wrong Answer
n = int(input())
cnt = 0
ans = 0
j = 1
while j < n:
  if cnt == 8:
    ans += 1
  cnt = 0
  j += 2
  for i in range(j):
    if j % (i+1) == 0:
      cnt += 1


print(ans+1 if cnt == 8 else ans)
# Judge status: Accepted
a, b = map(str, input().split())
b = b[:-3] + b[-2:]
a = int(a)
b = int(b)
c = str(a*b)
c = '000' + c
c = c[:-2]
print(int(c))
# Judge status: Wrong Answer
n = int(input())
s = input()

r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = r*g*b

for i in range(n - 2):
    for j in range(int(n//2)):
        if i + j*2 < n:
            if s[i] != s[i + j]:
                if s[i] != s[i + j*2]:
                    if s[i + j] != s[i + j*2]:
                        ans -= 1

print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)
if A[M-1] >= sum(A)/4*M:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S,W=(int(x) for x in input().split())
if S>W:
    print('safe')
else:
    print('unsafe')
# Judge status: Accepted
t = str(input())

ans = t.replace('?', 'D')

print(ans)
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))

M = max(L)
S = sum(L) - M

print('Yes' if M < S else 'No')
# Judge status: Accepted
n, a, b = map(int,input().split())

if (b-a)%2 == 0:
    print((b-a)//2)
else:
    print(min(a-1, n-b) + 1 + (b-a-1)//2)
# Judge status: Accepted
n = int(input())
point_t = []
f = []
ans = 0
index_0 = 0
cnt = 0
sum_of_0 = 0

for _ in range(n):
    point_t.append(int(input()))

point = sorted(point_t)

for i in range(n):
    if point[i]%10 != 0:
        if cnt == 0:
            index_0 = i
            cnt += 1
        f.append(int(point[i]%10))
if sum(f) == 0:
    print(0)
elif sum(f)%10 != 0:
    for i in range(n):
        ans += int(point[i])
    print(ans)
else:
    print(sum(point) - point[index_0])
# Judge status: Accepted
a,b=map(int,input().split())
if a-1>=b:
    print(a+a-1)
elif b-1>=a:
    print(b+b-1)
else:
    print(a+b)
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))

bad = 0
for i in range(n):
    if(A[i] % 2):
        if(A[i] % 3 != 0 or A[i] % 5 != 0):
            bad += 1

if(bad == 1):
    print("DENIED")
else:
    print("APPROVED")
# Judge status: Accepted
n=int(input())
s=input()
l=[s[i] for i in range(n)]
import collections
c=collections.Counter(l)
mod=10**9+7
li=list(c.values())
ans=1
for i in li:
  ans*=1+i
  ans%=mod
print(ans-1)
# Judge status: Accepted
# coding: utf-8
# Your code here!
 
a = input().split(" ")
H = int(a[0])
A = int(a[1])
ans = 0
while H > 0:
    H -= A
    ans += 1
print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())
print('Possible' if a==3 or b==3 or ((a+b)%3)==0 and a!=0 and b!=0 else 'Impossible')