peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
c = Counter(s)
res = 1
for key in list(c):
    res *= c[key]+1
    res %= mod
print((res-1)%mod)
# Judge status: Accepted
S = [input() for _ in range(3)]
i = 0
while True:
  head = S[i][0:1]
  if len(S[i]) == 0:
    if i == 0:
      print("A")
    elif i == 1:
      print("B")
    elif i == 2:
      print("C")
    exit()
  else:
    S[i] = S[i][1:]
    if head == "a":
      i = 0
    elif head == "b":
      i = 1
    elif head == "c":
      i = 2
# Judge status: Accepted
a,b = map(int,input().split())
exist_flg = False
for kame in range(a+1):
  tsuru = a - kame
  if (kame*4+tsuru*2)==b:
    exist_flg = True
    break
if exist_flg:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
def main():
    n,m = map(int,input().split())
    ans = [[n//2,n//2+1]]
    for _ in range(m-1):
        ans.append([ans[-1][0]-1,ans[-1][1]+1])
    for a in ans:
        print(*a)
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
x = int(input())
i = 2
j = 1
while x > i ** 5:
    if x % (i ** 5) == 0:
        j *= i
        x //= i ** 5
        i = 2
    else:
        i += 1
else:
    y = x // j
    for a in range(int(y ** 0.2) + 1):
        b = int((a ** 5 - y).real)
        if a ** 5 - b ** 5 == y:
            print(a * j, b * j)
            break
# Judge status: Accepted
N = int(input())
S = str(input())
ans = []
lst = ['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']

for i in range(len(S)):
    tmp = lst.index(S[i])
    tmp += N
    if tmp > 25:
        tmp -= 26
    ans.append(lst[tmp])
print(''.join(ans))
# Judge status: Accepted
N = int(input())

ans = N
for i in range(N+1):
    x = 0
    y = i
    while y:
        x += y%6
        y //= 6
    y = N-i
    while y:
        x += y%9
        y //= 9
    ans = min(x, ans)

print(ans)
# Judge status: Accepted
n,x=map(int,input().split())
c=0
l=list(map(int,input().split()))
for i in range(1,n):
    if(l[i-1]+l[i]>x):
        c+=l[i-1]+l[i]-x
        l[i]=max(0,l[i]-(l[i-1]+l[i]-x))
print(c)
# Judge status: Wrong Answer
n, m = map(int, input().split())

if m <= 2 * n:
  ans = n
else:
  ans = n + (m - 2 * n) // 4

print(ans)
# Judge status: Accepted
arr = input().split()
arr = list(map(int,arr))
a = arr[0]
b = arr[1]

if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
    print('Possible')
else:
    print('Impossible')
# Judge status: Wrong Answer
x,y,z=map(int,input().split())
print(x*y/2)
# Judge status: Accepted
a,b,c = map(int, input().split())
k = int(input())
key = 0

for i in range(0,k+1):
    if i == 0:
        cc = c
    else:
        cc = c*(2**i)
    
    if k-i == 0:
        bb = b
    else:
        bb = b*(2**(k-i))
    
    if cc > bb and bb > a:
        key = 1
        break

if key == 1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import numpy as np
N = int(input())

txy = [[0,0,0]]
for i in range(N):
    txy.append(list(map(int,input().split())))

out='Yes'
for i in range(1,N+1):
    x = np.array(txy[i])
    y = np.array(txy[i-1])
    mv = abs(x-y)
    # print(mv)
    dam = mv[0] - (mv[1] + mv[2])
    if dam%2==1 or dam<0:
        out='No'

print(out)
# Judge status: Wrong Answer
# https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b

s = input()
a = b = c = 0
for i in range(len(s)):
    if s[i] == 'a':
        a += 1
    elif s[i] == 'b':
        b += 1
    else:
        c += 1
t = [a, b, c]
t.sort(reverse=True)
if t[0] > t[1] + t[2]:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
n = int(input())
ans = ['a']
for j in ans:
  if len(j) < n:
    c = ord(j[-1])
    #print(c)
    for i in range(97,c+2):
      l = str(j + chr(i))
      ans.append(l)
chk = []
for i in ans:
  if len(i) == n:
    chk.append(i)
for i in chk:
  print(i)
# Judge status: Accepted
import math
n = int(input())
a = [int(input()) for i in range(5)]

print(math.ceil(n/min(a))+4)
# Judge status: Accepted
N = int(input())
data = [[int(__) for __ in input().split()] for _ in range(N)]


data.insert(0, [0, 0, 0])
canTravel = True

for i in range(1, N+1):
    absT = abs(data[i][0] - data[i-1][0])
    absX = abs(data[i][1] - data[i-1][1])
    absY = abs(data[i][2] - data[i-1][2])

    distance = absX + absY
    if absT < distance or absT % 2 != distance % 2:
        canTravel = False
        break

if canTravel:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
def resolve_B():
    s = input()
    l = len(s)
    print("x" * l)
resolve_B
# Judge status: Accepted
N, K = map(int, input().split())
X = list(map(int, input().split()))
check_X = X[0:K]

def calc_distance(check_X):
    if check_X[0] * check_X[-1] < 0:
        result = min(abs(check_X[0]*2)+abs(check_X[-1]), abs(check_X[0])+abs(check_X[-1]*2))
    else:
        result = max(abs(check_X[0]),abs(check_X[-1]))
    return result

ans = calc_distance(check_X)

for i in range(K, len(X)):
    check_X.pop(0)
    check_X.append(X[i])
    ans = min(ans, calc_distance(check_X))

print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
  if a[i]%2 == 0:
    if (a[i]%3)*(a[i]%5) != 0:
      print("DENIED")
      quit()
print("APPROVED")
# Judge status: Accepted
N, L = map(int, input().split())
words = sorted([input() for _ in range(N)])
print(*words, sep="")
# Judge status: Accepted
import sys

input = sys.stdin.readline


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

    sum_A = sum(A)
    center = sum_A / 2
    total = 0
    near_center = 0
    for a in A:
        total += a
        if abs(total - center) < abs(near_center - center):
            near_center = total

    ans = abs((sum_A - near_center) - near_center)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = int(input())

cake = N//4
donuts = N//7
for i in range(cake):
    for j in range(donuts):
        if (4*(i+1)+7*(j+1)) == N:
            print("Yes")
            exit()
print("No")
# Judge status: Accepted
N, M = map(int, input().split())
sc = [[int(i) for i in input().split()] for _ in range(M)]

if N == 1 :
  start = 0
else :
  start = 10 ** (N - 1)
  
ret = float('inf')
for i in range(start, 10 ** N) :
  i = str(i)
  for s, c in sc :
    if int(i[s - 1]) != c :
      break
  else :
    ret = min(ret, int(i))
    
if ret == float('inf') :
  print(-1)
else :
  print(ret)
# Judge status: Accepted
ary = list(input())
print("Yes") if ary.count("9") > 0 else print("No")
# Judge status: Accepted
a,b,c = map(int, input().split())
for i in range(1, b+1):
  if (a * i) % b == c:
    print('YES')
    exit()
print('NO')
# Judge status: Accepted
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b = M()
print(math.ceil((a+b)/2))
# Judge status: Accepted
import math
n=int(input())
def prime_judge(n):
  if n == 2:
    return True
  if n < 2 or n % 2 == 0:
    return False
  for i in range(3, int(math.sqrt(n)) + 1, 2):
    if n % i == 0:
      return False
  return True

while prime_judge(n)==False:
  n+=1
print(n)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))

A.sort()
ans=A[-1]+(N-2)*A[-2]
print(ans)
# Judge status: Accepted
X = int(input())
a = [i for i in range(1, 10**5)]
import bisect
from collections import deque
s = deque([])
s.append(0)
i = 0
while s[i] < 10 ** 9:
    s.append(s[i] + a[i])
    i += 1

print(bisect.bisect_left(s, X))
# Judge status: Accepted
import math
 
R = int(input())
 
print(2*math.pi*R)
# Judge status: Accepted
S=input()
if len(set(S)) == 2 and S.count(S[0]) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
"""
""" 
n = int(input())
a = list(map(int, input().split()))

maxA = max(a)
cntA = [0] * (maxA + 1)
cnt3 = [0] * (maxA + 1)

for _a in a:
    cntA[_a] += 1

for i in range(1,maxA):
    cnt3[i] += cntA[i-1] + cntA[i] + cntA[i+1]

# print(cntA)
# print(cnt3)

ans = max(cnt3)
print(ans)
# Judge status: Accepted
s = input()
ans = 999
for i in range(len(s)-2):
    n = int(s[i:i+3])
    if abs(n-753) < ans:
        ans = abs(n-753)
print(ans)
# Judge status: Wrong Answer
s , t = map(str, input().strip().split())

list = [s, t]
list.sort()
print(list[0]+list[1])
# Judge status: Wrong Answer
nm = input('')
n = int(nm.split(' ')[0])
m = int(nm.split(' ')[1])
alist = input('').split(' ')

t = 0
for i in range(n):
  t += int(alist[i])
s = 0
for i in range(n):
  a = int(alist[i])
  if a*4*m > t:
    s+=1

if s >= m:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
s = input()
base = "abcdefghijklmnopqrstuvwxyz"
L = [i for i in base]
L = set(L)

s = set(s)
ans = list(L-s)

try:
    print(sorted(ans)[0])
except:
    print("None")
# Judge status: Accepted
# -*- coding: utf-8 -*-

def main():

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

    if (A + B) % 2 == 0:
        ans = (A + B) // 2

    else:
        ans = 'IMPOSSIBLE'

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
#組み合わせ総数
mod = 10 ** 9 + 7
def comb(n, k):
    res = 1
    for i in range(n - k + 1, n + 1):
        res = res * i % mod
    for i in range(1, k + 1):
        res = res * pow(i, mod - 2, mod) % mod
    return res

x,y = map(int,input().split())

if (x + y) % 3 != 0:
    print(0)
    exit()

m = (2 * x - y) // 3
n = x - 2 * m

if n >= 0 and m >= 0:
    print(comb(m + n,min(m,n)))
else:
    print(0)
# Judge status: Accepted
a,b,c = map(int,input().split())

d = c-a-b
if d>0 and 4*a*b<d*d:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import sys,math,collections,itertools
input = sys.stdin.readline

a,b,c,d =list(input().rstrip())
op_lis = itertools.product('+-*/',repeat=3)
for op in op_lis:
    try:
        if eval(a+op[0]+b+op[1]+c+op[2]+d) == 7:
            print(a+op[0]+b+op[1]+c+op[2]+d+'=7')
            exit()

    except ZeroDivisionError:
        continue
# Judge status: Accepted
s1, s2, s3 = input().split("/")

s1 = 2018

print(s1, s2, s3, sep="/")
# Judge status: Wrong Answer
x = int(input())
y = str(x)
a = list(map(int, y))
for i in range(len(a)):
  if a[i] > 5:
    a[i] = 10 - a[i]
if a[-1] == 0:
  print(sum(a))
else:
  print(sum(a)+1)
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = [1]
jun = 0
i = 0
while len(cnt) == len(set(cnt)):
    cnt.append(a[i])
    i = a[i]-1
x = cnt.pop()
id = cnt.index(x)
k -= id
cnt = cnt[id:]
print(cnt[k%len(cnt)])
# Judge status: Accepted
n, d = map(int, input().split())
d *= 2
print((d + n) // (d + 1))
# Judge status: Accepted
T = list(map(int,input().split()))
n = int(input())*4
q_s = 1
h_s = 2
s_s = 4
d_s = 8

L = []
temp = 1
for i in range(4):
    s = temp
    v = T[i] / s
    L.append([T[i],s,v])
    temp *= 2

L.sort(key=lambda x: x[2])

ans = 0
for l in L:
    ans += (n // l[1])*l[0]
    n = n % l[1]

print(ans)
# Judge status: Accepted
import bisect
N,H = map(int,input().split())
a = []; b = []
for i in range(N):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)

a = sorted(a)
b = sorted(b)
strn_a = a[N-1]
damage = [strn_a]
for i in range(bisect.bisect_left(b,strn_a),N):
    damage.append(b[i])

ans = 0
for i in damage[::-1]:
    H -= i
    ans += 1
    if H <= 0:
        break
if H > 0:
    if H % damage[0] == 0:
        ans += H // damage[0]
    else:
        ans += H // damage[0] + 1

print(ans)
# Judge status: Wrong Answer
import sys

N = int(input())
W = list(input() for _ in range(N))

if len(set(W)) == N:
	for i in range(N-1): 
		if W[i][0] != W[i+1][-1]:
			print('No')
			sys.exit()
		else:
			print('Yes')
else:
	print('No')
# Judge status: Wrong Answer
def resolve():
    n = int(input())
    S0 = sorted(list(input()))
    dic = dict(zip(set(S0), [0]*len(S0)))
    for s0 in S0:
        dic[s0] += 1

    for i in range(n-1):
        S = list(input())
        for k, v in dic.items():
            cnt = S.count(k)
            dic[k] = min(v, cnt)

    ans = ''
    for k, v in dic.items():
        ans += k * v
    print(ans)

if __name__ == '__main__':
    resolve()
# Judge status: Wrong Answer
def main():
    x, a, b = map(int, input().split())
    distance_a = a - x
    distance_b = b - x
    if distance_a < 0:
        distance_a = distance_a * -1
    elif distance_b < 0:
        distance_b = distance_b * -1
    if distance_a > distance_b:
        print('B')
    else:
        print('A')
main()
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

if len(a)  == len(set(a)):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
def main():
    N, K = (int(i) for i in input().split())
    D = {i for i in input().split()}
    ans = N
    while any(a in D for a in str(ans)):
        ans += 1
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
S = input()
a=0
for i in range(len(S)):
  if a==1:
    break
  if i==len(S)-1:
    print("yes")
    break
  for j in range(i+1,len(S)):
    if S[i]==S[j]:
      print("no")
      a=1
      break
# Judge status: Wrong Answer
x = int(input())

if (x >= 2000):
    ans = 1

elif (x < 100):
    ans = 0
else:
    hundred = x // 100
    deci = x % 100

    five = deci // 5
    if (hundred >= five):
        ans = 1
    else:
        ans = 0


print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
c2=0
c4=0
for aa in a:
  if aa%2 == 0:
    if aa%4 == 0:
      c4+=1
    else:
      c2+=1
c0=n-(c2+c4)
cc=2*c4-c0
if c2>=1:
  cc-=1
print("Yes" if cc >= 0 else "No")
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1,n+1):
    if i%15 ==0:
        pass
    elif i%3 == 0:
        pass
    elif i%5 == 0:
        pass
    else:
        ans += i
print(ans)
# Judge status: Accepted
import sys
import collections

readline = sys.stdin.readline

def main():
    N = int(readline())
    A = []
    for _ in range(N):
        A.append(int(readline()))
    Aitems = list(zip(*collections.Counter(A).items()))
    Acount = list(Aitems[1])
    tmp = [x%2 for x in Acount]
    ans = sum(tmp)
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
str = input()
cnt = 0
 
for i in range(3):
  if str == 'RRR':
    cnt = 3
  elif str == 'RRS':
    cnt = 2
  elif str == 'SRR':
    cnt = 2
  elif str == 'SSS':
    cnt = 0
  else:
    cnt = 1
    
print(cnt)
# Judge status: Accepted
x = int(input())
if x <= 599:
    print("8")
elif x <= 799:
    print("7")
elif x <= 999:
    print("6")
elif x <= 1199:
    print("5")
elif x <= 1399:
    print("4")
elif x <= 1599:
    print("3")
elif x <= 1799:
    print("2")
else:
    print("1")
# Judge status: Wrong Answer
N = int(input())
B = [int(s) for s in input().split(' ')]
def doit(bb):
    bb = list(bb)
    A = []
    for b in bb:
        if len(A) == 0:
            A.append(b)
            continue
        A.append(min(A[-1], b))
    A.append(min(bb[-1], A[-1]))
    return sum(A)

print(max(doit(B), doit(reversed(B))))
# Judge status: Wrong Answer
from math import gcd

k = 200
total = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            # print(a, b, c, gcd(a, gcd(b, c)))
            total += gcd(a, gcd(b, c))
print(total)
# Judge status: Wrong Answer
X=str(input())
if X=='RRR':
    print(3)
elif X=='RRS' or X=='SRR':
    print(2)
elif X=='SSS':
    print(0)
# Judge status: Accepted
def main():
    n = int(input())
    x = list(map(int,input().split()))
    s = sorted(x)
    m1 = s[n//2-1]
    m2 = s[n//2]
    for i in x:
        if i <= m1:
            print(m2)
        else:
            print(m1)

if __name__ == '__main__':
    main()
# Judge status: Accepted
k,x=map(int,input().split())
print(*[i for i in range(x-k+1,x+k)])
# Judge status: Accepted
def com(n,r,mod):
    k=min(r,n-r)
    C=1
    for i in range(1,k+1):
        C=(C*(n+1-i)*pow(i,mod-2,mod))%mod
    return C

x, y = map(int,input().split())
mod = 10 ** 9 + 7

m = 2 * x - y
n = 2 * y - x
if m >= 0 and n >= 0 and m % 3 == 0 and n % 3 == 0:
    print(com((n + m) // 3, n // 3, mod))
else:print(0)
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))
#h, w = list(map(int, input().split()))
count = 0
ans = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        count += 1

    else:
        if count > ans:
            ans = count
        count = 0
    #print(count)

if count > ans:
    ans = count

print(ans)
# Judge status: Wrong Answer

if __name__ == '__main__':
	n,m,x,y = map(int,input().split())
	X = list(map(int,input().split()))
	Y = list(map(int,input().split()))

	x_max = max(X)
	y_min = min(Y)

	for Z in range(x,y):
		if x_max < Z <= y_min:
			print("No war")
			break
	else:
		print("War")
# Judge status: Accepted
import math
N,D = map(int, input().split())
print(math.ceil(N/(D*2+1)))
# Judge status: Accepted
def count_anagram_strings():
    n = int(input())
    count = 0
    d = dict()
    for i in range(n):
        key = "".join(sorted(list(input())))
        if key not in d:
            d[key] = 1
        else:
            d[key] += 1

    # N numbers have N * (N - 1) / 2 pairs
    for v in d.values():
        count += v * (v - 1) / 2
    
    print(int(count))

if __name__ == '__main__':
    # n = int(input())
    count_anagram_strings()
# Judge status: Accepted
ans = 6
for _ in range(2):
    ans -= int(input())
print(ans)
# Judge status: Accepted
x, y = map(int, input().split())

ans = 2* (10 **9)

if y - (-x) >= 0:
    ans = y + x + 1

if -y -x >= 0:
    ans = min(ans, -y -x + 1)

if -y - (-x) >= 0:
    ans = min(ans, -y +x +2)

if y - x >= 0:
    ans = min(ans, y-x)

print(ans)
# Judge status: Wrong Answer
def resolve():
	n, x = map(int, input().split())
	a = list(map(int, input().split()))
	c = 0
	for i in range(n-1):
		if a[i] + a[i+1] > x:
			st = (a[i] + a[i + 1]) - x
			a[i+1] = 0
			c += st
	print(c)
resolve()
# Judge status: Accepted
n,k = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf')]*n
dp[0] = 0
for i in range(1,n):
    dp[i] = min([dp[j]+abs(h[i]-h[j]) for j in range(max(0,i-k),i)])
print(dp[-1])
# Judge status: Accepted
s=input()
t=input()
flag=0
if (s[0]==t[2])and(s[1]==t[1])and(s[2]==t[0]):
    flag=1
if flag==0:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
n, k , s = map(int, input().split())
ans = []
for i in range(n):
    if k != 0:
        ans.append(s)
        k -= 1
    else:
        ans.append(s+1 if s != 10**9 else s-1)
print(" ".join([str(x) for x in ans]))
# Judge status: Wrong Answer
S = input()

if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
    print("Yes")
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x, y = [int(_) for _ in input().split()]
print(x + y//2)
# Judge status: Accepted
n=int(input())
ans='Yes'
ab=input()
l=[ab]
for i in range(n-1):
    a=input()
    l.append(a)
    if l[i][-1]!=a[0]:
        ans='No'
        break
    if len(set(l))!=len(l):
        ans='No'
        break
print(ans)
# Judge status: Wrong Answer
N,M=map(int,input().split())
A=[[] for _ in range(N+1)]
for _ in range(M):
    a,b=map(int,input().split())
    A[a].append(b)

ans=False
for i in A[1]:
    if i==M:
        ans=True
        break
    for j in A[i]:
        if j==M:
            ans=True
            break
print("POSSIBLE" if ans else "IMPOSSIBLE" )
# Judge status: Wrong Answer
t = input('')
a = ''
n = ''
for i in range(len(t)):
    if t[i] == 'P':
        n = 'D'
        a += t[i]
    if t[i] == 'D':
        n = 'D'
        a += t[i]
    if t[i] == '?':
        a+=n

print(a)
# DDDDDD -> 6
# PDPDPD -> 6
# PDPDPDP -> 3 + 3
# PDDDDDP -> 1 + 5
# Judge status: Wrong Answer
import sys
input=sys.stdin.readline
w,h,x,y=map(int,input().split())
if w*y!=h*x:
    print(min(w*y,h*x),0)

else:print(min(w*y,h*x),1)
# Judge status: Accepted
a, b = map(int, input().split())
if a<0 and b>0:
  print('Zero')
elif b<0:
  if (b-a+1)%2 == 0:
    print('Positive')
  else:
    print('Negative')
else:
  print('Positive')
# Judge status: Wrong Answer
import math
n,h = map(int,input().split())
a = []
b = []
for i in range(n):
  x,y = map(int, input().split())
  a += [x]
  b += [y]
amax = max(a)
ans = 0
for x in b:
  if x > amax:
    ans += 1
    h -= x
  if h <= 0:
    print(ans)
    exit()
 
if h % amax == 0:
  print(ans + h//amax)
else:
  print(ans + h//amax + 1)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
c2 = 0
c4 = 0
for i in a:
    if i%2==0:
        if i%4==0:
            c4 += 1
        else:
            c2 += 1
if c2>0:
    m = c4*2 + c2
else:
    m = c4*2 + 1

if m>= n:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from collections import Counter
S=input()+"abc"
C=Counter(S)
print("YES" if max(C.values())-min(C.values())<=1 else "NO")
# Judge status: Accepted
import math
from functools import reduce
import fractions
#import math
#import itertools
#import statistics
#import numpy as np
#import collections
#n = int(input())
n, k  = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(k)
x.sort()

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

dif = []
for i in range(n):
    dif.append(x[i+1]-x[i])

ans = gcd_list(dif)
print(ans)
# Judge status: Wrong Answer
n=int(input())
for i in range(1,10):
    if(n%i==0 and n/i<=9):
        print("Yes")
        break
    else:
        print("No")
# Judge status: Accepted
k, x= map(int, input().split())
pos = [i for i in range(x-k+1, x+k)]
print(*pos, sep=" ")
# Judge status: Accepted
import itertools
N, M, X = map(int, input().split())
a = [list(map(int, input().split())) for i in range(N)]
li = []
for i in range(N+1):
    for j in itertools.combinations(range(N), i):
        sm = [0] * (M+1)
        for k in j:
            for l in range(M+1):
                sm[l] += a[k][l]
        if all(y >= X for y in sm[1:M+1]):
            li.append(sm[0])
if li == []:
    print(-1)
else:
    print(min(li))
# Judge status: Accepted
a, b, c = map(int, input().split())
if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
    exit()

a, b, c = sorted([a, b, c])
print(a * b)
# Judge status: Accepted
N = int(input())
a = []
for _ in range(N):
    a.append(int(input()))

route = set()
route.add(0)
before = 0
ans = 0
for i in range(N):
    now = a[before] - 1
    ans += 1
    if now == 1:
        break
    elif now not in route:
        route.add(now)
        before = now
    else:
        ans = -1
        break
print(ans)
# Judge status: Accepted
n, k, x, y = [int(input()) for _ in range(4)]
if n <= k:
    print(x * n)
else:
    print(x * k + y * (n - k))
# Judge status: Wrong Answer
n = int(input())//500
a = int(input())
if n >= a:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
data=input().split()
N=int(data[0])
K=int(data[1])
ans=0
for i in range(1,N+1):
    dice=i
    n=0
    while 1<=dice<=K-1:
        dice*=2
        n+=1
    ans+=((1/2)**n)/N
print(ans)
# Judge status: Accepted
r, g, b = map(int, input().split())
if (g*10 + b) % 4 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
A = list(input())
B = list(input())
c = len(B)
del B[c-1]
if A == B:
  print("Yes")
else:
  print("NO")
# Judge status: Wrong Answer
N,M,X,Y = map(int,input().split())
x_lis = list(map(int,input().split()))
y_lis = list(map(int,input().split()))

x_max = max(x_lis)
y_min = min(y_lis)

ans = "War"
for Z in range(X,Y+1):
  if x_max < Z <= y_min:
    ans = "No War"
    
print(ans)
# Judge status: Accepted
n, m, x, y = map(int, input().split())
xn = [int(i) for i in input().split()]
ym = [int(i) for i in input().split()]
if max(xn) >= y:
    print("War")
elif min(ym) <= x:
    print("War")
elif max(xn) >= min(ym):
    print("War")
else:
    print("No War")