peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split())) 

cnt = 0
skip = False
for i in range(N):
    if skip:
        skip = False
        continue
    if i+1 == P[i]:
        cnt += 1
        if i+1 < N and i+2 == P[i+1]:
            skip = True

print(cnt)
# Judge status: Accepted
S = input()
z = 0
o = 0
for c in S:
    if c == '0':
        z += 1
    else:
        o += 1
print(min([z,o])*2)
# Judge status: Wrong Answer
from operator import itemgetter
N = int(input())
robot_list = []

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

sort_robot_list = sorted(robot_list, key=itemgetter(2))

minus_count = 0
for before_value, after_value in zip(sort_robot_list, sort_robot_list[1:]):
    if before_value[1] > after_value[0]:
        minus_count += 1

print(len(sort_robot_list) - minus_count)
# Judge status: Wrong Answer
import sys
N = int(input())

for i in range(1,9):
    if N <= int(str(i)*3):
        print(str(i)*3)
        sys.exit()
# Judge status: Accepted
X, Y = map(int, input().split())
a = 2*Y-X
b = 2*X-Y

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

if a%3==0 and b%3==0 and a>=0 and b>=0:
    a //= 3 
    b //= 3
    print(combination(a+b, a))
else:
    print(0)
# Judge status: Wrong Answer
k, a, b = map(int, input().split())

if k == 1:
    print(2)
elif k < a + 2 or a >= b:
    print(1 + k)
else:
    cnt = (k - (a - 1)) // 2
    mod = (k - (a - 1)) % 2
    ans_1 = (b - a)*cnt + a + mod
    ans_2 = 1 + k
    print(int(max(ans_1, ans_2)))
# Judge status: Wrong Answer
if int(input())>=30:
  print("YES")
else:
  print("NO")
# Judge status: Accepted
n=int(input())
ans=(1000- n%1000)%1000
print(ans)
# Judge status: Accepted
N = int(input())

A = str(N//2)
B = str(N-int(A))

ans1,ans2 = 0,1
for i in range(len(A)):
  ans1 += int(A[i])
for i in range(len(B)):
  ans1 += int(B[i])

B = str(N-1)

for i in range(len(B)):
  ans2 += int(B[i])

ans = min(ans1,ans2)

print(ans)
# Judge status: Accepted
s = input().rstrip()

if s[-1]=='s':
  s += 'es'
else:
  s += 's'
  
print(s)
# Judge status: Accepted
s=int(input())
dp=[0 for i in range(s+10)]
dp[3]=1
mod=10**9+7
for i in range(3,s+3):
    dp[i]=1
    for j in range(i-2): dp[i]=(dp[i]+dp[j])%mod
print(dp[s])
# Judge status: Wrong Answer
n = int(input())
L = input().split()
L.sort()
count = 0
for i in range(n):
  for j in range(i + 1,n):
    for k in range(j + 1 ,n):

        if ((int(L[k]) < int(L[i]) + int(L[j])) & (L[k] != L[i])& (L[k] != L[j])& (L[j] != L[i])):
            count += 1
        
print(count)
# Judge status: Accepted
N=input()
if '9' in N:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a[0] == sum(b):
  print(-1)
else:
  print(a[0] - sum(b))
# Judge status: Accepted
a,b = map(int,input().split())
if a > 8 or b > 8: print(':(')
else: print('Yay!')
# Judge status: Wrong Answer
#!/usr/bin/env python3
(*c, ) = map(int, open(0).read().split())
print("YNeos"[sum(c) % 3 > 0::2])
# Judge status: Wrong Answer
#!/usr/bin/env python3
import numpy as np


N, M = [int(str) for str in input().strip().split()]
sc = set([tuple([int(str) for str in input().strip().split()]) for _ in range(M)])

sc_dict = {}
for key, value in sc:
    if key in sc_dict:
        sc_dict[key] = min(value, sc_dict[key])
    else:
        sc_dict[key] = value

if N != 1 and sc_dict.get(1, 0) == 0:
    print(-1)
else:
    num = int(''.join([str(sc_dict.get(d + 1, 0)) for d in range(N)]))
    print(num if len(str(num)) == N else -1)
# Judge status: Accepted
import collections as c

n,k = map(int,input().split())
l = list(map(int,input().split()))
count = c.Counter(l)
ans = 0
check = 0
right = len(count)-k
if right <= 0:
    print(0)
    exit()
for i,j in count.most_common()[::-1]:
    ans += j
    check += 1
    if check == right:
        print(ans)
        exit()
# Judge status: Accepted
from sys import stdin

n,m = [int(x) for x in stdin.readline().rstrip().split()]

if n == m:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
B = list(map(int,input().split()))
A= B[0]
for i in range(1,n-1):
    A += min(B[i-1],B[i])
A+= B[n-2]
print(A)
# Judge status: Accepted
import math
n = int(input())
x = list(map(int,input().split()))
sums = sum(x)
xsort = sorted(x,reverse=True)
temp = math.ceil((n-1)/2)
if n % 2 == 0:
    medi = xsort[temp]
else:
    medi = xsort[n//2]

medi2 = xsort[temp-1]

for i in range(n):
    if x[i] <= medi:
        print(medi2)
    else:
        print(medi)
# Judge status: Accepted
c = 0
N, D = list(map(float, input().split()))
for i in range(int(N)):
    a, b = map(float, input().split())
    if a ** 2 + b ** 2 <= D**2:
        c += 1
print(c)
# Judge status: Wrong Answer
N = int(input())
ans = []
for _ in range(N - 1):
    C, S, F = map(int, input().split())
    ans.append(S + C)
    for i in range(len(ans) - 1):
        if ans[i] <= S:
            ans[i] = S + C
        else:
            if (ans[i] - S) % F == 0:
                ans[i] += C
            else:
                ans[i] += F * ((ans[i] - S) // F + 1) + C

ans.append(0)
for a in ans:
    print(a)
# Judge status: Wrong Answer
import collections
n = int(input())
p = list((map(int,input().split())))
x = collections.Counter(p)
y = [i[0] for i in x.items() if i[1]>=2]
z = [i[0] for i in x.items() if i[1]>=4]
y.sort(reverse=True)
y.append(0)
y.append(0)
z.append(0)
ans = y[0]*y[1]
ans1 = z[0]*z[0]
if ans1 > ans:
    ans =ans1
print(ans)
# Judge status: Accepted
s = input()

if s=='hi' or s=='hihi' or s=='hihihi' or s=='hihihihi' or s=='hihihihihi':
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a = [int(input()) for i in range(5)]
k = int(input())
print('Yay!' if a[-1] - a[0] <= k else ':(')
# Judge status: Accepted
N, M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

good = [True]*N

for i in range(M):
    a, b = [int(i)-1 for i in input().split()]
    if H[a] >= H[b]:
        good[b] = False
    if H[b] >= H[a]:
        good[a] = False

print(sum(good))
# Judge status: Accepted
n,m,x=map(int,input().split())
cx=[list(map(int,input().split())) for i in range(n)]

ans=10000000000000000000000000000

for dummy in range(2**n):
  books=format(dummy, 'b')
  books='0'*(n-len(books))+books
  point=[0]*(m+1)
  cost=0
  for i in range(n):
    if books[i]=='1':
      cost+=cx[i][0]
      for j in range(1,m+1):
        point[j]+=cx[i][j]
  ok=1
  for j in range(1,m+1):
    if point[j]<x:
      ok=0
  if ok:
    ans=min(ans,cost)


if ans==10000000000000000000000000000:
  ans=-1
print(ans)
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmax=max(a)
tmin=0
t=(tmax+tmin)/2
import math
ans=0
if k==0:
  print(tmax)
else:
  while True:
    s=0
    for i in range(n):
      s=s+math.ceil(a[i]/t)-1
    if k>=s:
      ans=t
      tmax=t
      t=(tmin+t)/2
    else:
      tmin=t
      t=(t+tmax)/2
    if tmax-tmin<0.01:
      break
  print(math.ceil(ans))
# Judge status: Wrong Answer
import sys
l,r = map(int,input().split())
c = 10**9
if r - l >= 2019:
    print(0)
    sys.exit()
for i in range(l,r):
    for j in range(i+1,r+1):
        print(i,j)
        x = (i * j) % 2019
        print(x)
        if x < c:
            c = x
    
print(c)
# Judge status: Wrong Answer
N=int(input())

if N<=999:
  print("ABC"+str(N))
else:
  print("ABR"+str(N-1000+1))
# Judge status: Accepted
N = int(input())
S = input()
x = 0
max_x = 0
for i in range(N):
    if S[i]=="D":
        x -= 1
    else:
        x += 1
    if x > max_x:
        max_x = x
print(max_x)
# Judge status: Accepted
S = {"a": input(), "b": input(), "c": input()}

t = "a"
while S[t]:
    nt = S[t][0]
    S[t] = S[t][1:]
    t = nt

else:
    print(t.upper())
# Judge status: Accepted
n = int(input())
s = input()
alph = ["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"]

cnt = 0
for i in range(n):
    prev = s[:i]
    subseq = s[i:]
    inner_cnt = 0
    for j in alph:
        if j in prev and j in subseq:
            inner_cnt += 1
    if inner_cnt > cnt:
        cnt = inner_cnt
print(cnt)
# Judge status: Accepted
s = input()
s = list(s)

s_unique = list(set(s))
if len(s) == len(s_unique):
  print("yes")
else :
  print("no")
# Judge status: Accepted
from math import ceil
h, w = map(int, input().split())
if h == 1 or w == 1:
    print(1)
else:
	print(ceil(h/2)*ceil(w/2) + int(h/2)*int(w/2))
# Judge status: Accepted
*aa,n = map(int, open(0).read().split())

n *= 1000

bb = [250,500,1000,2000]

for i in range(1,4):
    aa[i] = min(aa[i], aa[i-1]*2)

ans = 0
for b,a in zip(bb[::-1], aa[::-1]):
    ans += n // b * a
    n %= b

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

ans = ""
for i in range(len(T)):
    if(T[i] == "?"):
        if(i != len(T)-1 and T[i+1] == "D"):
            ans += "P"
            continue
        elif(i != 0 and T[i-1] == "?"):
            ans += "P"
            continue
        ans += "D"
    else:
        ans += T[i]
    
print(ans)
# Judge status: Wrong Answer
n = int(input())
count = ((n-1)*2)
a = [i for i in range(2, n//2)]
i = 2
while a:
  count += len(a)*2
  i += 1
  limit = n//i if n%i==0 else 1+n//i
  a = [j for j in range(i, limit)]
print(count-(i-1))
# Judge status: Accepted
s = input()
dp = [0]*(len(s) + 1)

for i, x in enumerate(s):
    if x in "ACGT":
        dp[i+1] = dp[i] + 1
print(max(dp))
# Judge status: Accepted
s=input()
lis=["q","w","e","r","t","y","u","i","o","p","l","k","j","h","g","f","d","s","a","z","x","c","v","b","n","m"]
a=set()
for i in range(len(s)):
    a.add(s[i])
#print(a)
ans=[]
for i in range(len(lis)):
    if lis[i] in a:
        continue
    ans.append(lis[i])
ans.sort()
if ans:
    print(ans[0])
else:
    print("None")
# Judge status: Accepted
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
vch=[]
ac=10**15
for i in range(A):
    ac=min(ac,a[i])
bc=10**15
for i in range(B):
    bc=min(bc,b[i])
ans=ac+bc
for i in range(M):
    c=list(map(int,input().split()))
    ans=min(ans,a[c[0]-1]+b[c[1]-1]-c[2])
print(ans)
# Judge status: Accepted
import collections
N=int(input())
S=[str(input()) for _ in range(N)]
C=collections.Counter(S)
print('AC x ' + str(C['AC']))
print('WA x ' + str(C['WA']))
print('TLE x ' + str(C['TLE']))
print('RE x ' + str(C['RE']))
# Judge status: Accepted
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


n,m=map(int,input().split())
for i in make_divisors(m)[::-1]:
    if n*i<=m:print(i);break
# Judge status: Accepted
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

B = [A[0]]
for i in range(1,N-1):
    B.append(gcd(B[-1], A[i]))

C = [A[-1]]
for i in range(N-2,0,-1):
    C.append(gcd(C[-1], A[i]))

MAX = 0
for i in range(N):
    if i == 0:
        MAX = max(MAX, C[-1])
    elif i == N-1:
        MAX = max(MAX, B[-1])
    else:
        MAX = max(MAX, gcd(B[i-1], C[N-i-2]))

print(MAX)
# Judge status: Wrong Answer
import sys
N, M, X=map(int, sys.stdin.readline().rstrip().split())
A = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(N)]
cost=[]
for i in range(1<<N):	#Bit All Search
	l=[0]*(M+1)
	for j in range(N):
		if((i>>j)&1)==1:
			l=[l[k]+A[j][k] for k in range(M+1)]
	for k in range(M):
		if l[k+1]<X:
			break
		else:
			cost.append(l[0])
cost.sort()
print(-1 if cost==[] else cost[0])
# Judge status: Wrong Answer
p, q, r = map(int, input().split())
if p + q < q + r:
    print(p + q)
else:
    print(q + r)
# Judge status: Wrong Answer
N=input()
l=len(N)
if(N[-1]=='e'):
 print(N+'s')
elif(N[-1]=='x'):
 print(N+'s')
else:
 print(N+'es')
# Judge status: Wrong Answer
N=int(input())
A=[]
W=input()
A.append(W)
ans=True
for i in range(N-1):
    w=input()
    if (W[-1]!=w[0]) or (w in A):
        ans=False
    else:
        A.append(w)
else:
    print('Yes' if ans==True else 'No')
# Judge status: Accepted
def ret_distance(list1,list2,D):
    result = 0
    for i in range(D):
        result += (list1[i]-list2[i])**2
    return result**(1/2)

N,D = map(int,input().split())
s = [list(map(int,input().split())) for i in range(N)]
count = 0

for n in range(N):
    I = n
    for i in range(N-I-1):
        if ret_distance(s[n],s[N-i-1],D).is_integer():
            count+=1

print(count)
# Judge status: Wrong Answer
H,W = map(int, input().split())
if H == 1 or W == 1:
    print (max(W,H)-2)
    exit()
print(W*H - (2*H+2*W-4))
# Judge status: Wrong Answer
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    x = ni()
    
    base=x//11*2
    mod = x%11
    if mod > 5:
        base+=2
    else:
        base+=1
    
    print(base)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n, k = map(int, input().split())
if n % k == 0:
    print(0)
else:
    l = [n]
    p = n // k
    c = n - (p * k)
    half = k // 2
    while c > half:
        c = abs(c - k)
    l.append(c)
    print(min(l))
# Judge status: Accepted
a, b = map(int, input().split())
if b >= a:
    ans = a
else:
    ans = a-1
print(ans)
# Judge status: Accepted
n = int(input())
A = [int(input()) for i in range(n)]

ans = 0
for i in range(n):
    m = A[i] // 2
    ans += m
    A[i] -= 2*m
    if i <= n-2 and min(A[i], A[i+1]) == 1:
        ans += 1
        A[i] -= 1
        A[i+1] -= 1
print(ans)
# Judge status: Accepted
N = int(input())


def f(L):
    l = len(L)
    if l == N:
        print(''.join(list(map(lambda i: chr(i + 96), L))))
        return
    for d in range(1, min(l, max(L)) + 2):
        f(L + [d])


f([1])
# Judge status: Accepted
N=int(input())

#bit探索
start=int((2*N+1)**0.5)

for i in range(3):
    i += start
    if i*(i+1) >= 2*N:
        ret = i
        delete=i*(i+1)/2 - N
        break

for k in range(1,ret+1):
    if k != delete:
        print(k)
# Judge status: Accepted
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    n = int(input())
    for i in range(8):
        if 2**i > n:
            print(2**(i-1))
            return


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b = map(int,input().split())
c = round((a+b)/2)
print(c)
# Judge status: Accepted
H = input()
arr = [int(i) for i in H.split(' ')]
count = 1
if(arr[0]<arr[1]):
	print(count)
else:
	while arr[0]>arr[1]:
		arr[0] = arr[0] - arr[1]
		count = count + 1
	print(count)
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
xy = [0] * n

xy_plus_max = -10 ** 10
xy_plus_min = 10 ** 10
xy_minus_max = -10 ** 10
xy_minus_min = 10 ** 10
for i in range(n):
    x, y = map(int, input().split())
    xy_plus_max = max(xy_plus_max, x + y)
    xy_plus_min = min(xy_plus_min, x + y)
    xy_minus_max = max(xy_minus_max, x - y)
    xy_minus_min = min(xy_minus_min, x - y)

print(max(xy_plus_max - xy_plus_min, xy_minus_max - xy_minus_min))
# Judge status: Wrong Answer
N = int(input())

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

m = 1000
s = 0
for i in range(N-1):
  if A[i]<=A[i+1]:
    s += m//A[i]
    m -= (m//A[i])*A[i]
  else:
    m +=s*A[i+1]
    s = 0
if s>0:
  m+=A[-1]*s
print(m)
# Judge status: Accepted
n, a, b = map(int,input().split())
mod = 10**9+7
total = pow(2, n, mod) - 1
def c(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q, mod-2, mod)%mod

print((total - c(n, a) - c(n, b))%mod)
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,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()))

a,b,c = inpl()
print('YES' if b-a == c-b else 'NO')
# Judge status: Accepted
from collections import defaultdict
N,K=map(int,input().split())
L=list(map(int,input().split()))
Hash=defaultdict(lambda:list())
for i in range(K):
    x,y=map(int,input().split())
    Hash[x-1].append(y-1)
    Hash[y-1].append(x-1)
count=0
for i in range(N):
    FLAG=0
    for k in Hash[i]:
        if L[k]>=L[i]:
            FLAG=1
            break
    if FLAG==0:
        count+=1
print(count)
# Judge status: Accepted
n = int(input())
a_list = list(map(int,input().split()))
a_list.sort()
a_max = a_list.pop()
result = []
import math
for a in a_list:
  result.append(abs(math.ceil(a_max /2) - a))

print(a_max,a_list[result.index(min(result))])
# Judge status: Accepted
n,k = list(map(int,input().split()))
s = str(input())
ans = 0
for i in range(1,len(s)):
  if s[i] == s[i-1]:
    ans += 1

if (n-1) >= (ans + 2*k):
  ans += 2*k
else:
  ans = n - 1

print(ans)
# Judge status: Wrong Answer
n=int(input())
l=sorted(list(map(int,input().split())))
print(l[n//2]-l[n//2-1]-int(l[n//2]==l[n//2-1]) )
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

A = sorted([i-k-1 for k,i in enumerate(A)])
b = A[N//2]
print(sum(abs(i-b) for i in A))
# Judge status: Accepted
N, M = map(int, input().split())

d = {i+1: []  for i in range(N)}
for _ in range(M):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

for i in range(N):
    print(len(d[i+1]))
# Judge status: Accepted
N, M, K = map(int, input().split())

for n in range(N+1):
    for m in range(M+1):
        if K == n*(M-m) + (N-n)*m:
            print("Yes")
            exit()
print("No")
# Judge status: Accepted
d, n = map(int, input().split())
if n != 100:
    print((100**d)*n)
else:
    print((100**d)*101)
# Judge status: Wrong Answer
H,N = map(int,input().split())
a = [int(s) for s in input().split()]
s = H - sum(a)
if s < 0:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
# 記録
N = int(input())
results = []
for i in range(1,N):
    results.append(sum(map(int,str(i))) + sum(map(int,str(N-i))))
print(min(results))
# Judge status: Accepted
K = int(input())
if K%2==0:
    print("-1")
elif K%5==0:
    print("-1")
else:
    ans = 0
    temp = 0
    check = 0
    for i in range(K):
        ans += 1
        temp *= 10
        temp += 7
        temp %= K
        
        if temp==0:
            check+=1
        
        if check==1:
            break
    print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split(" "))
ar = [[0,1] for i in range(n)]
ar[0] = [1,1]
r = 0
for i in range(m):
    a,b = map(int,input().split(" "))
    a -= 1
    b -= 1
    if ar[a][0] == 1 and ar[a][1] >= 1:
        ar[b][0] = 1
        ar[b][1] += 1
    ar[a][1] -= 1
    if ar[a][1] == 0:
        ar[a][0] = 0
count = 0
for r in ar:
    if r[0] == 1:
        count += 1
print(count)
# Judge status: Accepted
N, K=map(int, input().split())
D=set(map(str, input().split()))
while True:
  s=str(N)
  for t in s:
    if t in D:
      N+=1
      break
  else:
    print(N)
    exit()
# Judge status: Accepted
s=input()
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12 and 1<=b<=12:
  print('AMBIGUOUS')
elif 1<=b<=12:
  print('YYMM')
elif 1<=a<=12:
  print('MMYY')
else:
  print('NA')
# Judge status: Accepted
n = int(input())
a = n * 800
b = n // 15 * 200

print(a - b)
# Judge status: Accepted
a,b,c = sorted(map(int, input().split()))
if (a+b+c==17)&(a==b)&(c==7):
  print("YES")
else:
  print("NO")
# Judge status: Accepted
#! /usr/bin/env python3

import sys
import numpy as np
from collections import defaultdict
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S = readline().decode().rstrip()
dicts = defaultdict(int)

for c in S:
  dicts[c] += 1

for pair in [('N', 'S'), ('W', 'E')]:
  if min(dicts[pair[0]], dicts[pair[1]]) == 0:
    if max(dicts[pair[0]], dicts[pair[1]]) != 0:
      print('No')
      sys.exit()
print('Yes')
# Judge status: Wrong Answer
N,M = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(N)]

c =[[int(i) for i in input().split()] for j in range(M)]

n = 10000000
n1 = 0
n2 = 0

for i in range(N):
    for j in range(M):
        n1 = abs(c[j][0] - a[i][0]) + abs(c[j][1] - a[i][1])
        if n1 < n:
            n = n1
            n2 = j
    n = 10000000
    print(n2 + 1)
# Judge status: Accepted
a, b, c, d = map(int,input().split())

if ((abs(a-b) <= d) and (abs(b-c) <= d)) or abs(a-c) <= d:
  print("Yes")
  
else:
  print("No")
# Judge status: Accepted
s = input()
#n = s.length()
if s[-1] in ['2','4','5','7','9']:
  print('hon')
elif s[-1] in ['0','1','6','8']:
  print('pon')
else:
  print('bon')
# Judge status: Accepted
import sys
S = sys.stdin.readline().strip()
T = sys.stdin.readline().strip()
if T[:-1] == S:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input().strip())
a = list(map(int, input().split()))
reps = []

a.sort()
tmp = 0
for e in a:
    if e == tmp:
        reps.append(e)
        tmp = 0
    else:
        tmp = e
if len(reps) < 2:
    print(0)
else:
    print(reps[-1] * reps[-2])
# Judge status: Accepted
N, A, B = map(int, input().split())
a = N//(A+B)
b = N % (A+B)

if A == 0:
    print(0)
elif b <= A:
    print(a*A+b)
else:
    print(a*A+A)
# Judge status: Accepted
n = int(input())
if n>=30:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a, b = map(int, input().split())
print(a + b//2)
# Judge status: Accepted
S = input()
N = len(S)

end = (N-1)//2
stt = (N+3)//2

S1 = S[:end]
S2 = S[stt-1:]

if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
#!/usr/bin/python3

import sys
#import math
import fractions as math

def input():
    return sys.stdin.readline().rstrip('\n')

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A,B))
# Judge status: Accepted
# coding: utf-8
n = int(input())
dic = {}
for i in range(n):
    s = "".join(sorted(input()))
    dic.setdefault(s, 0)
    dic[s] += 1
ans = 0
for x in dic.values():
    ans += int(x * (x - 1) / 2)
print(ans)
# Judge status: Wrong Answer
N = int(input())
X = list(map(str,input().split()))
X_ = sorted(X)
for x in X:
  if x < X_[(N//2)]:
    print(X_[(N)//2])
  elif x == X_[(N//2)]:
    print(X_[(N)//2-1])
  else:
    print(X_[(N)//2-1])
# Judge status: Wrong Answer
from itertools import combinations


sq_nums = {i * i for i in range(101)}

N, D = map(int, input().split())
coords = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for Y, Z in combinations(coords, 2):
    if sum((y - z) ** 2 for y, z in zip(Y, Z)) in sq_nums:
        ans += 1
print(ans)
# Judge status: Wrong Answer
n = int(input())
f = list(map(int,input().split()))
f.sort(reverse = True)
ans = 0
if n%2 == 0:
    for i in range(n//2):
        ans += f[i] * 2
    ans -= f[0]
else:
    for i in range(n//2):
        ans += f[i] * 2
    ans += f[n//2+1]-f[0]

print(ans)
# Judge status: Accepted
w,h,x,y = map(int, input().split())

t = w * h / 2

if x == w/2 and y == h/2:
  print(t, 1)
else:
  print(t, 0)
# Judge status: Accepted
S , T = map(str,input().split())
A , B = map(int,input().split())
U =str(input())

if U == S:
    A -=1
else:
    B -=1
print(str(A)+" "+str(B))