peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import collections
import functools
import operator



n=int(input())
s=input()
c=collections.Counter(s)

# l=r*g*b
l = functools.reduce(operator.mul, c.values())
for i in range(0,n-1):
    for j in range(i+1,n):
        k=j-i+j
        if k>=n:
            continue
        if s[i]!=s[j] and s[k]!=s[j] and s[i]!=s[k]:
            l-=1
print(l)
# Judge status: Wrong Answer
S = input().strip()

ans = 0

for i in range(len(S)):
    if S[i] == '0':
        pass
    elif int(S[i]) > 5:
        ans += 10 - int(S[i]) + 1
    else:
        ans += int(S[i])

print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
if b-a==c-b:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
s=input()
ans=False
for i,v in enumerate(s):
    if ans==False:
        if v=="A":
            a=i
            ans=True
    else:
        if v=="Z":
            z=i
print(z-a+1)
# Judge status: Accepted
S = input()
T1 = len(S)*"01"
T2 = len(S)*"10"
ans = []
dif = 0

for s,t in zip(S,T1):
  if s!=t:
    dif+=1

ans+=[dif]
dif = 0

for s,t in zip(S,T2):
  if s!=t:
    dif+=1

ans+=[dif]
print(min(ans))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

mini = A[0]
ans = 0

for i in range(len(A) - 1):
    if A[i] < A[i+1]:
        ans += A[i+1] - A[i]
print(ans)
# Judge status: Accepted
N = int(input())
max=1
for i in range(1, N):
  if int(i**2)<=N:
    max=i**2
  else:
    break
print(max)
# Judge status: Wrong Answer
a=input(int())

if a==3 or a==5 or a==7:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
N = int(input())
n = 1
ans = 10**13
while n*n <= N:
    if N%n==0:
        t = n + N//n - 2
        ans = min(ans, t)
    n += 1
print(ans)
# Judge status: Wrong Answer
x,a,b = map(int,(input().split())) #x日までOK A日前に買ってきて　B日語に食べた

hantei = b - a

if hantei < 0:
    print("delicious")
elif x > hantei:
    print("sefe")
else:
    print("dangerous")
# Judge status: Accepted
import numpy as np
A, B = map(int,input().split())
A,B=int(A),int(B)
c=0
d=True
while(d):
    a=int(c*0.08)
    b=int(c*0.1)
    if a==A and b==B:
        print(c)
        d=False
    elif a>A or b>B:
        print('-1')
        d=False
    else:
        c+=1 
        continue
# Judge status: Accepted
from bisect import bisect_left, bisect_right  # return index

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = L[i]+L[j]  # tmpはこの値より短くなくてはいけない

        ### ここから下は二分探索
        ix = bisect_left(L, tmp)
        ans += ix-(j+1)

print(ans)
# Judge status: Accepted
N = int(input())
S = [list(input().split()) for _ in range(N)]
for i in S:
    i[1] = 100 - int(i[1])
for i in range(N):
    S[i] += i+1,
S.sort()
for i in S:
    print(i[2])
# Judge status: Accepted
s = input()

answer = 10000
for j in range(len(s)-2):
  t = s[j:j+3]
  answer = min(answer,abs(int(t)-753))

print(answer)
# Judge status: Wrong Answer
input()

a=list(map(int, input().split())) #スペース区切りの数字をlistで取得

if int(len([i for i in a if a.count(i) >= 2])) !=0:
    print("No")
else :
    print("Yes")
# Judge status: Accepted
a, b = map(int, input().split())
print(a*b)
# Judge status: Accepted
n,q=map(int,input().split())
s = input()
a = [0,0]
for i in range(1,n):
    a.append(a[i]+(s[i-1]=="A" and s[i]=='C'))
for i in range(q):
    l,r=map(int,input().split())
    print(a[r]-a[l-1]-(s[l-2]=='A' and s[l-1]=='C'))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

s = b[a[0]-1]

for i in range(1,n):
    s += b[a[i]-1]
    if(a[i] == a[i-1]+1):s+=c[a[i-1]-1]
    print(i,s)
print(s)
# Judge status: Accepted
# coding: utf-8
# Your code here!
A, B = map(int, input().split())

if A>=13:
    print(B)
elif A<=5:
    print(0)
else:
    print(B//2)
# Judge status: Wrong Answer
N = int(input())

if N % 2  == 0:
    print("0.5000000000")
elif N == 1:
    print("1.0000000000")
else:
    print("0.6000000000")
# Judge status: Accepted
from collections import defaultdict
import bisect
N,M = map(int, input().split())
dic = defaultdict(list)
cities = []
for _ in range(M):
  p,y = map(int,input().split())
  cities.append([p,y])
for item in sorted(cities):
  dic[item[0]].append(item[1])
for item in cities:
  print("%06d%06d"%(item[0],bisect.bisect(dic[item[0]],item[1])))
# Judge status: Accepted
S = str(input())
a = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

for i in range(len(a)):
  if S == a[i]:
    print(len(a) - i)
# Judge status: Accepted
import sys
from bisect import bisect_left, bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))

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

    ans = sum(bisect_left(A, b) * (N - bisect_right(C, b)) for b in B)

    print(ans)
    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import deque
 
n = int(input())
a = list(map(int,input().split()))
d = deque(a)
 
tmp = []
cnt = 0
while d:
  v = d.popleft()
  if len(tmp)>=2:
    if not (v >= tmp[-1] >= tmp[0] or v <= tmp[-1] <= tmp[0]):
      tmp = []
      cnt += 1
  tmp.append(v)

print(cnt+1 if tmp else cnt)
# Judge status: Accepted
S = input()
T = input()
if S==T[:-1:]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

H, A = map(int, input().split())

print(-(-H//A))
# Judge status: Accepted
N, M = map(int, input().split())
c = [1] * N
r = [True] + [False] * (N-1)
for i in range(M):
    x, y = map(int, input().split())
    if r[x-1] == True:
        r[y-1] = True
    if c[x-1] == 1:
        r[x-1] = False
    c[x-1] -= 1
    c[y-1] += 1
print(sum(r))
# Judge status: Accepted
a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print('red')
# Judge status: Accepted
n = int(input())
a = [input() for i in range(n)]

l = sorted(a)

count = 1
for i in range(n - 1):
    if l[i] != l[i + 1]:
        count += 1
    
print(count)
# Judge status: Wrong Answer
s = list(map(str,input()))
s.sort()
cnt = len(list(set(s)))

if cnt == 26:
    print("None")
else:
    x = chr(ord(s[0]) + 1)
    print(x)
# Judge status: Accepted
A,B = [int(i) for i in input().split()]
if A + B >= 24:
  print(A + B -24)
else:
  print(A+B)
# Judge status: Accepted
K = int(input())
A,B = map(int, input().split())

ans = "NG"
for i in range(A,B+1):
  if i%K == 0:
    ans = "OK"
print(ans)
# Judge status: Accepted
a = str(input())
b = str(input())

if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import math
r = int(input())
print(2*math.pi*r)
# Judge status: Accepted
s = input()
st = s[-1]
if st == "s":
  print(s+"es")
else:
  print(s+"s")
# Judge status: Wrong Answer
s = input()
ss = ["SUN","MON","TUE","WED","THU","FRI","SAT","SUN","MON","TUE","WED","THU","FRI","SAT"]
print(ss[ss.index(s) + 1])
# Judge status: Wrong Answer
a,b,x=list(map(int,input().split()))
import math
import sys
if a*a*b==x:
  print(90.0000000000)
  sys.exit()

if a*a*b/2<=x:
  kakudo=a*a*a/2/(a*a*b-x)
  print(90-math.degrees(math.atan(kakudo)))
else:
  kakudo=2*x/(a*b*b)
  print(90-math.degrees(math.atan(kakudo)))
# Judge status: Accepted
X = int(input())
ans = (X // 500) * 1000 + ((X % 500) // 5) * 5
print(ans)
# Judge status: Wrong Answer
import numpy as np
from fractions import gcd

N=int(input())
A=list(map(int, input().split()))
A=np.array(A)
mod=10**9+7
def lcm(a,b):
    return a//gcd(a,b)*b

LCM=1
for x in A:
    LCM=lcm(LCM,x)



#print(LCM)
print(int((LCM//A).sum())%mod)
# Judge status: Accepted
A,B,C=list(map(int, input().split()))

if A+B>=C:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import math

N = int(input())
csf = [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 t >= csf[j][1]:
            t = math.ceil(t/csf[j][2])*csf[j][2]+csf[j][0]
        else: t = csf[j][1] + csf[j][0]
    print(t)
print(0)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
if a+b+c > 21:
    print ('burst')
else:
    print ('win')
# Judge status: Wrong Answer
import math

n, d = input().split()
count = 0
for idx in range(int(n)):
    x, y = input().split()
    x, y = int(x), int(y)
    if math.sqrt(math.pow(int(x), 2) + math.pow(int(x), 2)) < (int(d) + 1):
        count += 1

print(count)
# Judge status: Accepted
import numpy as np

N = int(input())
a = np.array(list(map(int, input().split())))

if (a/a[0]).sum() == len(a):
    total = 0

total = 10**9
for i in range(a.min(), a.max()+1):
    total_new = ((a - i)**2).sum()
    if total_new <= total:
        total = total_new
print(total)
# Judge status: Accepted
x, y = map(int, input().split())
if x in [1, 3, 5, 7, 8, 10, 12] and y in [1, 3, 5, 7, 8, 10, 12]:
  print('Yes')
elif x in [4, 6, 9, 11] and y in [4, 6, 9, 11]:
  print('Yes')
elif x == 2 and y == 2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
A, B, C = map(int, input().split())

if A == B == C and A%2 == 1:
    print('0')
elif A == B == C:
    print('-1')
else:
    ans = 0
    while A%2 == B%2 == C%2 == 0:
        A, B, C = B//2+C//2, A//2+C//2, A//2+B//2
        ans += 1
    print(ans)
# Judge status: Wrong Answer
from sys import stdin
input = stdin.readline

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

ans = []

for i in range(N - 1):
    ans.append(a[i] ^ a[i + 1])

ans.append(a[0] ^ a[N - 1])

print(*ans)
# Judge status: Accepted
s = str(input())
top = int(s[:2])
bottom = int(s[2:])

if 1 <= top <= 12 and 1 <= bottom <= 12:
    print('AMBIGUOUS')
elif top > 12 and bottom > 12:
    print('NA')
elif 1 <= top <= 12:
    print('MMYY')
elif 1 <= bottom <= 12:
    print('YYMM')
else:
    print('NA')
# Judge status: Accepted
S=input()
print(min(S.count('0'),S.count('1'))*2)
# Judge status: Accepted
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

start1 = a
end1 = a+v*t
start2 = b
end2 = b+w*t
if(a==b):
    print("YES")
    exit()
if(w>=v):
    print("NO")
    exit()

dist = abs(a-b)
rv = abs(v-w)

if(dist <= t*rv): print("YES")
else: print("NO")
# Judge status: Wrong Answer
n,m,x=map(int,input().split())
li=[0]*(m+1)
k=[]
for i in range(n):
    c=list(map(int,input().split()))
    li=li+c
    a=li.pop(0)
    k.append(a)
if min(li)>=x:
    print(sum(k))
else:
    print("-1")
# Judge status: Accepted
from collections import deque
n,m = map(int,input().split())
rootlist = [[] for i in range(n)]
flag = [False]*n

for i in range(m):
    a,b= map(int,input().split())
    rootlist[a-1].append(b)
    rootlist[b-1].append(a)

que = deque([1])
while que:
    now = que.popleft()
    for room in rootlist[now-1]:
        if flag[room-1] == False:
            flag[room-1] = now
            que.append(room)

print('Yes')
for root in flag[1:]:
    print(root)
# Judge status: Accepted
def read_ints():
    return map(int, input().split(' '))


mod = int(1e9 + 7)


def fexp(x, y):
    ret = 1
    while y > 0:
        if y % 2 == 1:
            ret = ret * x % mod
        x = x * x % mod
        y = y // 2
    return ret


input()
a = list(read_ints())
s = sum(a)
ans = 0
for i in a:
    ans = (ans + i * (s - i)) % mod
print(ans * fexp(2, mod - 2) % mod)
# Judge status: Accepted
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    x = int(_in[0])  # type:int
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ans = 1 if x==0 else 0
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n, c, k = map(int, input().split()); a = [int(input()) for _ in range(n)]
a.sort(); t = a[0]+k; m = 1; x = 1
for i in range(n):
    if a[i] > t or m > 3: t = a[i]+k; m = 1; x += 1
    else: m += 1
print(x)
# Judge status: Accepted
a,b = map(int,input().split())

sa = [str(a)]*b
sb = [str(b)]*a

ans = min(sa,sb)

for i in ans:
    print(i,end = "")
# Judge status: Accepted
A,B=map(int, input().split())
cnt=0
for i in range(A,B+1):
  s=str(i)
  if s[0]==s[4] and s[1]==s[3]:
    cnt+=1
    
print(cnt)
# Judge status: Accepted
from collections import Counter as CC

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = CC(A)
C = sorted(B.values())
print(sum(C[:max(0, len(C) - K)]))
# Judge status: Accepted
A,B,C,D = map(int,input().split())
import math
E = C*D//math.gcd(C,D)
A -= 1
c = B//C - A//C
d = B//D - A//D
e = B//E - A//E
print(B-A-(c+d-e))
# Judge status: Accepted
N=int(input())
csf=[tuple(map(int,input().split(' '))) for i in range(N-1)]
for i in range(N-1):
    now = 0
    for j in csf[i:]:
        c,s,f= [k for k in j]
        while now > s:
            s += f
        now = s+c
    print(now)
print(0)
# Judge status: Wrong Answer
a,b,t = map(int,input().split())
print(b * ((t+0.5)//a))
# Judge status: Accepted
def sum(A, B):
  n = 0
  while True:
    if n >= (B-1)/(A-1):
      return n
    else:
      n += 1

num = input().split(' ')
A = int(num[0])
B = int(num[1])

n = sum(A,B)
print(n)
# Judge status: Accepted
n=int(input())
a=[int(x) for x in input().split()]
b=[int(x) for x in input().split()]

sa=[a[i]-b[i] for i in range(n)]

p=0
m=0
for i in sa:
  if 0<i:
    m+=i
  else:
    p+=abs(i)//2

if m<=p:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a = str(input())
n = 0
e = 0
s = 0
w = 0
for i in a:
    if i=="N":
        n+=1
    if i=="E":
        e+=1
    if i=="S":
        s+=1
    if i=="W":
        w+=1
if n==s and e==w:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
a=0
ans=0
if n < 105:
  print(0)

elif n == 105:
  print(1)
  
else:
  for i in range(107,n,2):
    a=0
    for j in range(i):
      if i%(j+1)==0:
        a += 1
    if a==8:
      ans +=1
  print(ans)
# Judge status: Accepted
a = list(input())
b = list(input())
a = a[::-1]
if a == b:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
count = 0       #初期値を0とするcount変数を作る.
n,k = map(int,input().split())      #整数とn進数を入力する。

while n > 0:         #nをkで割った商が0になるまでcountに1を足し続ける。
    count += 1
    n //= k

print(count)
# Judge status: Accepted
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: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = 0
i = -1
for j in range(n):
    if a[j]-1 == i+1:
        ans += c[i]
    i = a[j] - 1
    ans += b[i]
print(ans)
# Judge status: Accepted
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
#方角が南北/東西でセットであればよさげ
    s = input().rstrip()
    s = set(s)
    WE={'W','E'}
    NS={'N','S'}
    all_direction={'N', 'E', 'S', 'W'}

    if s == set(WE):
        print("Yes")
    elif s == set(NS):
        print("Yes")       
    elif s == set(all_direction):
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()
# Judge status: Wrong Answer
n,k = map(int,input().split())
if n == n%k:
    print(n)
else:
    n = n%k
    print(min(n,abs(n-k)))
# Judge status: Accepted
import sys
ans=[1,2,3]
ans.remove(int(sys.stdin.readline()))
ans.remove(int(sys.stdin.readline()))
print(*ans)
# Judge status: Wrong Answer
s=int(input())
ans=1
for i in range(1,s):
  ans*=i
  
print(ans)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())
def check(x, y):
  return abs(x - y) <= d
if (check(a, b) and check(a, c)) or (check(a, b) and check(b, c)):
  print("Yes")
else: print("No")
# Judge status: Accepted
# 優先度付キューのimport
import heapq

n, m = map(int, input().split())

a = [int(i) * -1 for i in input().split()]

heapq.heapify(a)

for i in range(m):
    minPrice = heapq.heappop(a)
    # 負の切捨てが面倒なので正の値にしてからまた負に戻す
    minPrice = -(abs(minPrice) // 2)
    heapq.heappush(a, minPrice)

sum = 0
for i in a:
    sum += -i

print(sum)
# Judge status: Wrong Answer
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = 10 ** 8 * 2
for i in range(N - K + 1):
    if x[i + K - 1] <= 0:
        tmp = -x[i]
    elif x[i] >= 0:
        tmp = x[i + K - 1]
    else:
        tmp = -x[i] * 2 + x[i + K - 1]
        tmp = min(tmp, -x[i] + 2 * x[i + K - 1])

    if tmp < ans:
        ans = tmp
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import sys

def main():
    x = int(input())
    ans = 2 * (x // 11)
    if x % 11 > 6:
        print(ans + 2)
    elif x % 11 > 0:
        print(ans + 1)
    else:
        print(ans) 

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
x = int(input())
dp = [0]*(x + 105 + 1)
dp[100] = 1 
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1

for i in range(100,x-105+1):
    for j in range(100,106):
        dp[i+j] = max(dp[i] , dp[i+j])

print(dp[x])
# Judge status: Accepted
#ABC109-C
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd,numbers)

n,X = map(int,input().split())
x = list(map(int,input().split())) 

x.append(X)
x.sort()

kosa = []

for i in range(1,n+1):
    k = (x[i]-x[i-1])
    kosa.append(k)
    
print(gcd(*kosa))
# Judge status: Wrong Answer
N = int(input())

for i in range(2, 10):
  if (N%i == 0) & (N/i > 1):
    print('Yes')
    exit()
print('No')
# Judge status: Wrong Answer
from random import randint

D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
T = []

for i in range(D):
    T.append(S[i].index(max(S[i])))
print(*T, sep="\n")
# Judge status: Accepted
def main():
    S = input()
    L = len(S)
    c = S.count('0')
    print(min(c, L - c) * 2)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def main():
    n = int(input())
    print(int(n * (n - 1) / 2))


main()
# Judge status: Accepted
A,B,X = map(int,input().split())
cat = X-A
if cat >= 0 and cat <= B :
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
import math

n,a,b = map(int,input().split())


if n > 2:
    aa = math.factorial(n) // (math.factorial(n - a) * math.factorial(a))
    bb = math.factorial(n) // (math.factorial(n - b) * math.factorial(b))
    c = (n * n - aa - bb - 1) % 1000000007
    print("{}".format(c))
else:
    print("0")
# Judge status: Accepted
import math

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

answer = math.ceil(N / (D * 2 + 1))
print(answer)
# Judge status: Accepted
n = int(input())
a_input = list(map(int,input().split()))
b_input = list(map(int,input().split()))

ans=0
for i in range(n):
    first_attack=0
    second_attack=0

    first_attack = min(b_input[i],a_input[i])
    a_input[i]-=first_attack
    if first_attack<b_input[i]:
        second_attack = min(a_input[i+1],b_input[i]-first_attack)
        a_input[i+1]-= second_attack
    ans+=first_attack+second_attack

print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int, input().split()))
m=99999
for i in range(min(a),max(a)+1):
    k=0
    for j in a:
        k=k+(j-i)**2
    if k<m:
        m=k
print(m)
# Judge status: Accepted
import math

X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  q = [int(i)-10 for i in range(121)]
  #print(q)

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 100000
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  print(ans)
# Judge status: Accepted
import collections
import heapq
n,m = map(int,raw_input().split(' '))

elems = [map(int, raw_input().split(' ')) for _ in range(n)]
elems.sort(key = lambda x:x[0])
heap = []

j = 0
cumul = 0
for i in range(1,m+1):

	while(j < len(elems) and elems[j][0] <= i): 
		heapq.heappush(heap,-elems[j][1])
		j+=1
	if heap:
		cumul -= heapq.heappop(heap)

print cumul
# Judge status: Accepted
a,b = list(map(int,input().split()))
s = min(a,b)
l = max(a,b)
print(str(s)*l)
# Judge status: Wrong Answer
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

_ = rl()
maxx = max(rm())
miny = min(rm())
if maxx >= miny-1:
  print('War')
else:
  print('No War')
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int, input().split())))

for i in range(n - 1):
    if a[i] == a[i + 1]:
        print('NO')
        exit()
print('YES')
# Judge status: Wrong Answer
from collections import deque

N = int(input())
H = deque(map(float, input().split()))

prev = H.popleft()

if N == 1:
    print('Yes')
    exit()

for i in range(N-1):
    cor = H.popleft()
    if prev - cor < -1:
        print('No')
        exit()
    
    prev = cor


print('Yes')
# Judge status: Wrong Answer
a = [list(map(int,input().split())) for i in range(3)]
if a[0][0]-a[1][0] == a[0][1]-a[1][1] == a[0][2]-a[1][2] and a[1][0]-a[2][0] == a[1][1]-a[2][1] == a[1][2] == a[2][2]:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N, A, B = map(int, input().split())

if (B - A)%2==0:
    print((B - A)//2)
else:
    print(min(B-1, N-A))
# Judge status: Accepted
def main():
    import sys
    from itertools import accumulate

    n = int(input())
    a = list(map(int, sys.stdin.readline().split()))

    b = list(accumulate(a))
    diff = b[-1]
    total = b[-1]
    for x in b:
        diff = min(diff, abs(total - 2 * x))
    print(diff)

if __name__ == '__main__':
     main()
# Judge status: Accepted
l, r = map(int, input().split())
if r - l > 2019:
  print(0)
else:
  ans = 2019
  for i in range(l, r):
    for j in range(i+1, r+1):
      ans = min(ans, (i*j) % 2019)
  print(ans)
# Judge status: Wrong Answer
s = input()
if s[-1] == s:
  s += 'es'
else:
  s += 's'
print(s)
# Judge status: Accepted
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
bc = sorted([list(map(int, input().split())) for i in range(m)], key =lambda x:x[1])
bc.reverse()

flg = 0
cnt = 0

for i in range(n):
  if bc[flg][1] >a[i] and flg < m:
    a[i] = bc[flg][1]
    cnt +=1
    if cnt == bc[flg][0]:
      flg += 1
      cnt = 0
      if flg == m:
        break
  else:
      break

print(sum(a))
# Judge status: Wrong Answer
S = input()
S_s = set(S)

if len(S)==len(S_s):
    print("yes")
else:
    print("No")
# Judge status: Wrong Answer
n=int(input())
s="abcdefghij"
end=[0,1,2,3,4,5,6,7,8,9]
lim=0
res=[0]*n
for i in res:
  print(s[i],end="")
print("")

while res!=end[:n]:
  res[(n-1)]=res[(n-1)]+1
  for i in range(n-1):
    if res[n-i-1]>(res[n-i-2]+1):
      res[n-i-1]=0
      res[n-i-2]=res[n-i-2]+1
  for i in res:
    print(s[i],end="")
  print("")
# Judge status: Wrong Answer
q, h, s, d = map(int, input().split())
n = int(input())
a = [8*q, 4*h, 2*s, d]

if n % 2 == 0:
    price = min(a) * n / 2
else:
    price = min(a) * (n-1) / 2
    a.remove(d)
    price = price + min(a) / 2

print(int(price))
# Judge status: Wrong Answer
import math

N = int(input().rstrip())
A = list(map(int,input().rstrip().split()))
l = [A[0]]
r = [A[-1]]
for i in range(len(A)-1):
    l.append(math.gcd(A[i+1],l[i]))
    r.append(math.gcd(A[-(i+2)],r[i]))
ans = []
ans.append(r[-2])
for i in range(len(A)-2):
    ans.append(math.gcd(l[i],r[-i]))
ans.append(l[-2])
print(max(*ans))
# Judge status: Wrong Answer
c = input()
if c in "9":
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
K = int(input())
cnt = 0

while A > B and cnt >= K:
    B = B*2
    cnt += 1

if cnt >= K:
    print("No")
else:
    while B > C and cnt >= K:
        C = C*2
        cnt += 1

if C > B:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, K = map(int, input().split())
*h, = map(int, input().split())

dp = [0] * N
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    c = 10**10
    for j in range(i - 1, max(i - K - 1, -1), -1):
        t = abs(h[j] - h[i]) + dp[j]
        if t < c:
            c = t
    dp[i] = c
print(dp[N - 1])