TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows:    * f(b,n) = n, when n < b   * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b  Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b.  Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold:    * f(10,\,87654)=8+7+6+5+4=30   * f(100,\,87654)=8+76+54=138  You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.

Submission attempts (in order):
import numpy as np
def f(b, n):
    s = 0
    while n > 0:
        s += n % b
        n //= b
    return s

INF = int("inf")
def solve(n, s):
    if n < s:
        return -1
    if n == s:
        return n+1
    m = int(np.sqrt(n)) + 1
    for b in range(2, m+1):
        if f(b, n) == s:
            return b
    best = INF
    for p in range(1, m+1):
        q = s - p
        if (n - q) % p != 0:
            continue
        b = (n - q) // p
        if (b > 1) and (f(b, n) == s):
            best = min(best, s)
    return -1 if (best == INF) else best

n = int(input())
s = int(input())
print(solve(n, s))

import numpy as np
def f(b, n):
    s = 0
    while n > 0:
        s += n % b
        n //= b
    return s

INF = 10**15
def solve(n, s):
    if n == s:
        return n+1
    m = int(np.sqrt(n)) + 1
    for b in range(2, m+1):
        if f(b, n) == s:
            return b
    best = INF
    for p in range(1, m+10):
        q = s - p
        b = (n - q) // p
        if (b > p) and (b > q) and (f(b, n) == s):
            best = min(best, b)
    return -1 if (best == INF) else best

n = int(input())
s = int(input())
print(solve(n, s))

Verdicts: Runtime Error

Accepted
Problem: For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows:    * f(b,n) = n, when n < b   * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b  Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b.  Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold:    * f(10,\,87654)=8+7+6+5+4=30   * f(100,\,87654)=8+76+54=138  You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.

Submission attempts (in order):
#!/usr/bin/env python3
import sys


def f(n, b):
    if n < b:
        return n
    else:
        return n // b + f(n % b, b)


def solve(n: int, s: int):
    if s > n:
        return -1

    if s == n:
        return n+1

    b = 2
    while b * b <= n:
        if f(n, b) == s:
            return b
        b += 1
    
    for p in range(b-1, 0, -1):
        if (n - s) % p > 0:
            continue

        c = (n - s) // p + 1
        if f(n, c) == s:
            return c
    
    return -1


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    s = int(next(tokens))  # type: int
    print(solve(n, s))

if __name__ == '__main__':
    main()


#!/usr/bin/env python3
import sys


def f(n, b):
    if n < b:
        return n
    else:
        return n % b + f(n // b, b)


def solve(n: int, s: int):
    if s > n:
        return -1

    if s == n:
        return n+1

    b = 2
    while b * b <= n:
        if f(n, b) == s:
            return b
        b += 1
    
    for p in range(b-1, 0, -1):
        if (n - s) % p > 0:
            continue

        c = (n - s) // p + 1
        if f(n, c) == s:
            return c
    
    return -1


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    s = int(next(tokens))  # type: int
    print(solve(n, s))

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i.  Tak the traveler has the following two personal principles:    * He never travels a distance of more than L in a single day.   * He never sleeps in the open. That is, he must stay at a hotel at the end of a day.  You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.

Submission attempts (in order):
from bisect import bisect, bisect_left
import sys

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

def search_1(start):
	return bisect(x, x[start] + l) - 1

route = [[] for _ in range(n)]

i = 0 
for i in range(n - 1):
	if route[i] == []:
		j = search_1(i) 
		num = 1 
		route[i].append(j)
		if route[j] == []:
			route[j] = (i, num)
		else: 
			route[i] += route[route[j][0]][route[j][1]:]
			continue
		while j < n - 1:
			j = search_1(j)
			num += 1
			route[i].append(j)
			if route[j] == []:
				route[j] = (i, num)
			else: 
				route[i] += route[route[j][0]][route[j][1]:]
				break
	else:
		continue

# print(route)

def search_2(start, goal):
	if type(route[start]) == type([]):
		return bisect_left(route[start], goal) + 1
	else:
		return bisect_left(route[route[start][0]][route[start][1]:], goal) + 1



q = int(input())
for _ in range(q):
	a, b = map(int, sys.stdin.redline().strip().split())
	if a > b:
		a, b = b, a
	print(search_2(a - 1, b - 1))

from bisect import bisect
import sys

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


r = [[i for i in range(n)] for _ in range(18)]
for j in range(n):
	r[0][j] = bisect(x, x[j]+l) - 1
for i in range(1, 18):
	for j in range(n):
		r[i][j] = r[i-1][r[i-1][j]]

def search(x, y):
	res = 0
	cur = x
	i = 17
	while True:
		if i == 0 and r[i][cur] >= y:
			return res+1
		if r[i][cur] < y:
			cur = r[i][cur]
			res += 1 << i
			continue
		i -= 1

for _ in range(q):
	a, b = map(int, sys.stdin.readline().strip().split())
	print(search(min(a, b)-1, max(a, b)-1))

Verdicts: Runtime Error

Accepted
Problem: N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i.  Tak the traveler has the following two personal principles:    * He never travels a distance of more than L in a single day.   * He never sleeps in the open. That is, he must stay at a hotel at the end of a day.  You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.

Submission attempts (in order):
import sys
from bisect import bisect

n = int(input())
xxx = list(map(int, input().split()))
l = int(input())

reachable = [[bisect(xxx, x + l) - 1 for x in xxx]]
while reachable[-1][0] < n - 1:
    rp = reachable[-1]
    reachable.append([rp[rp[i]] for i in range(n)])

q = int(input())
buf = []
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    if a > b:
        a, b = b, a
    ans = 0
    for i in range(len(reachable) - 1, -1, -1):
        if reachable[i][a] > b:
            continue
        ans += 1 << i
        a = reachable[i][a]
    if a != b:
        ans += 1
    buf.append(ans)

print(*buf)


import sys
from bisect import bisect

n = int(input())
xxx = list(map(int, input().split()))
l = int(input())

reachable = [[bisect(xxx, x + l) - 1 for x in xxx]]
while reachable[-1][0] < n - 1:
    rp = reachable[-1]
    reachable.append(list(map(rp.__getitem__, rp)))

q = int(input())
buf = []
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    if a > b:
        a, b = b, a
    ans = 0
    for i in range(len(reachable) - 1, -1, -1):
        ria = reachable[i][a]
        if ria >= b:
            continue
        ans += 1 << i
        a = ria
    if a != b:
        ans += 1
    buf.append(ans)

print('\n'.join(map(str, buf)))


Verdicts: Wrong Answer

Accepted
Problem: N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i.  Tak the traveler has the following two personal principles:    * He never travels a distance of more than L in a single day.   * He never sleeps in the open. That is, he must stay at a hotel at the end of a day.  You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.

Submission attempts (in order):
N = int(input())
X = list(map(int, input().split()))
L = int(input())
Q = int(input())

V = [0]*N
ib = 0
for i in range(N):
    while X[i]-X[ib] > L:
        V[ib] = i-1
        ib += 1
while ib!=N-1:
    V[ib]=N-1
    ib += 1
S = [0]*N
h=N-1
cnt = 1
for i in range(N-2, -1, -1):
    if h==V[i]:
        S[i] = cnt
    else:
        cnt+=1
        h=i+1
        S[i] = cnt
for i in range(Q):
    a, b = map(int, input().split())
    a, b = sorted([a, b])
    print(min(1, S[a-1]-S[b-1]))


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

V = [0]*N
ib = 0
for i in range(N):
    while X[i]-X[ib] > L:
        V[ib] = i-1
        ib += 1
while ib!=N-1:
    V[ib]=N-1
    ib += 1
dbl = [[0]*N for i in range(18)]
dbl[0]=V
for i in range(1, 18):
    for j in range(N):
        ii = dbl[i-1][j]
        if ii == 0:
            break
        dbl[i][j] = dbl[i-1][ii]
for i in range(Q):
    a, b = map(int, input().split())
    a, b = sorted([a, b])
    a-=1
    b-=1
    ind = a
    ans = 0
    for j in range(17, -1, -1):
        if dbl[j][ind]==0:
            continue
        if dbl[j][ind]>b:
            continue
        if dbl[j][ind]==b:
            ans |= 1<<j
            break
        else:
            ans |= 1<<j
            ind = dbl[j][ind]
    else:
        ans += 1
    print(ans)


Verdicts: Wrong Answer

Accepted
Problem: N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i.  Tak the traveler has the following two personal principles:    * He never travels a distance of more than L in a single day.   * He never sleeps in the open. That is, he must stay at a hotel at the end of a day.  You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.

Submission attempts (in order):
n = int(input())
hot = list(map(int,input().split())) 
n_ = n.bit_length()
db = [[n-1]*(n)]
L = int(input())
r = 1
for i in range(n-1):
  while r < n-1 and hot[r+1]-hot[i] <= L:
    r += 1
  db[0][i] = r
for j in range(1,n_+1):
  new = [db[-1][db[-1][i]] for i in range(n)]
  db.append(new)
  if new[0] == n-1:
    break
n_ = len(db)

for x in db:
  print(x)
  
def query(s,t):
  dt = 0
  for j in range(n_-1,0,-1):
    if db[j][s] < t:
      dt += 2**j
      s = db[j][s]
  while s < t:
    dt += 1
    s = db[0][s]
  return dt 

q = int(input())
for _ in range(q):
  s,t = map(int,input().split())
  if t < s:
    s,t = t,s
  print(query(s-1,t-1))
   

n = int(input())
hot = list(map(int,input().split())) 
n_ = n.bit_length()
db = [[n-1]*(n)]
L = int(input())
r = 1
for i in range(n-1):
  while r < n-1 and hot[r+1]-hot[i] <= L:
    r += 1
  db[0][i] = r
for j in range(1,n_+1):
  new = [db[-1][db[-1][i]] for i in range(n)]
  db.append(new)
  if new[0] == n-1:
    break
n_ = len(db)

def query(s,t):
  dt = 0
  for j in range(n_-1,0,-1):
    if db[j][s] < t:
      dt += 2**j
      s = db[j][s]
  while s < t:
    dt += 1
    s = db[0][s]
  return dt 

q = int(input())
for _ in range(q):
  s,t = map(int,input().split())
  if t < s:
    s,t = t,s
  print(query(s-1,t-1))
   

Verdicts: Wrong Answer

Accepted
Problem: N hotels are located on a straight line. The coordinate of the i-th hotel (1 \leq i \leq N) is x_i.  Tak the traveler has the following two personal principles:    * He never travels a distance of more than L in a single day.   * He never sleeps in the open. That is, he must stay at a hotel at the end of a day.  You are given Q queries. The j-th (1 \leq j \leq Q) query is described by two distinct integers a_j and b_j. For each query, find the minimum number of days that Tak needs to travel from the a_j-th hotel to the b_j-th hotel following his principles. It is guaranteed that he can always travel from the a_j-th hotel to the b_j-th hotel, in any given input.

Submission attempts (in order):
from math import*
from bisect import*
n,*t=map(int,open(0).read().split())
m=int(log2(n))+1
x=t[:n]
l=t[n]
d=[[bisect(x,y+l)-1for y in x]]+[[0]*n for _ in range(m)]
for i in range(m):
    for j in range(n):
        d[i+1][j]=d[i][d[i][j]]
print(d)
for a,b in zip(t[n+2::2],t[n+3::2]):
    a-=1
    b-=1
    if b<a:a,b=b,a
    c=1
    for i in range(m,-1,-1):
        if d[i][a]<b:
            a=d[i][a]
            c+=2**i
    print(c)

n,*x=map(int,open(0).read().split())
d=[0]+[10**9]*~-n
l=x[n]
i=t=0
for j,y in enumerate(x[1:n],1):
    t=y-x[i]
    while t>l:
        i+=1
        t=y-x[i]
    print(i,j,t)
    d[j]=d[i]+1
for a,b in zip(x[n+2::2],x[n+3::2]):
    print(abs(d[a-1]-d[b-1])or 1)

from math import*
from bisect import*
n,*t=map(int,open(0).read().split())
m=int(log2(n))+1
x=t[:n]
l=t[n]
d=[[bisect(x,y+l)-1for y in x]]+[[0]*n for _ in range(m)]
for i in range(m):
    for j in range(n):
        d[i+1][j]=d[i][d[i][j]]
for a,b in zip(t[n+2::2],t[n+3::2]):
    a-=1
    b-=1
    if b<a:a,b=b,a
    c=1
    for i in range(m,-1,-1):
        if d[i][a]<b:
            a=d[i][a]
            c+=2**i
    print(c)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Let x be a string of length at least 1. We will call x a _good_ string, if for any string y and any integer k (k \geq 2), the string obtained by concatenating k copies of y is different from x. For example, `a`, `bbc` and `cdcdc` are good strings, while `aa`, `bbbb` and `cdcdcd` are not.  Let w be a string of length at least 1. For a sequence F=(\,f_1,\,f_2,\,...,\,f_m) consisting of m elements, we will call F a _good representation_ of w, if the following conditions are both satisfied:    * For any i \, (1 \leq i \leq m), f_i is a good string.   * The string obtained by concatenating f_1,\,f_2,\,...,\,f_m in this order, is w.  For example, when w=`aabb`, there are five good representations of w:    * (`aabb`)   * (`a`,`abb`)   * (`aab`,`b`)   * (`a`,`ab`,`b`)   * (`a`,`a`,`b`,`b`)  Among the good representations of w, the ones with the smallest number of elements are called the _best representations_ of w. For example, there are only one best representation of w=`aabb`: (`aabb`).  You are given a string w. Find the following:    * the number of elements of a best representation of w   * the number of the best representations of w, modulo 1000000007 \, (=10^9+7)  (It is guaranteed that a good representation of w always exists.)

Submission attempts (in order):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

W = list(map(int,read().rstrip()))

N = len(W)

def Z_Algorithm(S):
    
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

Z_Algorithm(W)

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

W = read().rstrip()

N = len(W)

def Z_algorithm(S):
    
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

def is_periodic_left(W):
    Z = Z_algorithm(W)
    is_periodic = [False] * N
    for p in range(1,N//2 + 1):
        if is_periodic[p-1]:
            continue
        for i in range(p,N,p):
            if Z[i] >= p:
                is_periodic[p + i - 1] = True
            else:
                break
    return is_periodic

L = is_periodic_left(W)
R = is_periodic_left(W[::-1])[::-1]

if not L[-1]:
    answer = (1,1)
elif len(set(W)) == 1:
    answer = (N,1)
else:
    x = sum(not(x or y) for x,y in zip(L,R[1:]))
    answer = (2,x)
print('\n'.join(map(str,answer)))

Verdicts: Wrong Answer

Accepted
Problem: Let x be a string of length at least 1. We will call x a _good_ string, if for any string y and any integer k (k \geq 2), the string obtained by concatenating k copies of y is different from x. For example, `a`, `bbc` and `cdcdc` are good strings, while `aa`, `bbbb` and `cdcdcd` are not.  Let w be a string of length at least 1. For a sequence F=(\,f_1,\,f_2,\,...,\,f_m) consisting of m elements, we will call F a _good representation_ of w, if the following conditions are both satisfied:    * For any i \, (1 \leq i \leq m), f_i is a good string.   * The string obtained by concatenating f_1,\,f_2,\,...,\,f_m in this order, is w.  For example, when w=`aabb`, there are five good representations of w:    * (`aabb`)   * (`a`,`abb`)   * (`aab`,`b`)   * (`a`,`ab`,`b`)   * (`a`,`a`,`b`,`b`)  Among the good representations of w, the ones with the smallest number of elements are called the _best representations_ of w. For example, there are only one best representation of w=`aabb`: (`aabb`).  You are given a string w. Find the following:    * the number of elements of a best representation of w   * the number of the best representations of w, modulo 1000000007 \, (=10^9+7)  (It is guaranteed that a good representation of w always exists.)

Submission attempts (in order):
w=list(input())
n=len(w)
per=-1
def Z(s):
    m=len(s);z=[0]*m;c=0;f=[1]*m;
    for i in range(1,m):
        if i+z[i-c]<c+z[c]:z[i]=z[i-c]
        else:
            j=max(0,c+z[c]-i)
            while i+j<n and s[j]==s[i+j]:j=j+1
            z[i]=j;c=i
    for p in range(1,m):
        for k in range(2,z[p]//p+2):f[k*p-1]=0
    return f
for j in range(1,n//2+1):
    if n%j==0 and w[:n-j]==w[j:]:t=j;break;
if t==-1:print ('1\n1')
elif t==1:print (n);print (1)
else:
    zl=Z(w)
    w.reverse()
    zr=Z(w)
    cnt=0
    for i in range(0,n-1):
        if zl[i] and zr[n-2-i]:cnt=cnt+1
    print(2);print(cnt);

w=list(input());n=len(w);t=-1
def Z(s):
    m=len(s);z=[0]*m;c=0;f=[1]*m;
    for i in range(1,m):
        if i+z[i-c]<c+z[c]:z[i]=z[i-c]
        else:
            j=max(0,c+z[c]-i)
            while i+j<n and s[j]==s[i+j]:j=j+1
            z[i]=j;c=i
    for p in range(1,m):
        for k in range(2,z[p]//p+2):f[k*p-1]=0
    return f
for j in range(1,n//2+1):
    if n%j==0 and w[:n-j]==w[j:]:t=j;break;
if t==-1:print ('1\n1')
elif t==1:print (n);print (1)
else:
    zl=Z(w)
    w.reverse()
    zr=Z(w)
    cnt=0
    for i in range(0,n-1):
        if zl[i] and zr[n-2-i]:cnt=cnt+1
    print(2);print(cnt);


Verdicts: Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s=input()
n=s.count("N")
w=s.count("W")
s=s.count("S")
e=s.count("E")
ns=n+s
we=w+e
if n>0 and w>0 and s>0 and e>0:
  print("Yes")
elif n>0 and w>0 and we==0:
  print("Yes")
elif ns==0 and s>0 and e>0:
  print("Yes")
else print("No")

i=set(input())
if i=={"E","N","S","W"} or i=={"N","S"} or i=={"E","W"}:
    print("Yes")
else:
    print("No")

Verdicts: Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s=input()
if (("N" in s) and ("S" in s)) or (("E" in s) and ("W" in s)):
  print("No")
else:
  print("Yes")


S = input()
if (("N" in S) ^ ("S" in S)) | (("E" in S) ^ ("W" in S)):
  print("No")
else:
  print("Yes")


Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s=input()s=input()
if "N" in s and "S" in s and "W" in s and "E" in s:
    print("Yes")
elif "N" in s and "S" in s:
    print("Yes" if "W" in s or "E" in s else "No")
else:
    print("Yes" if "N" in s or "S" in s else "No")

s=input()
if "N" in s and "S" in s and "W" in s and "E" in s:
    print("Yes")
elif "N" in s and "S" in s:
    print("No" if "W" in s or "E" in s else "Yes")
elif "W" in s and "E" in s:
    print("No" if "N" in s or "S" in s else "Yes")
else:
    print("No")  

Verdicts: Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
a = input()
W = a.count("W")
S = a.count("S")
E = a.count("E")
N = a.count("N")
print("YES" if N-S == 0 and W-E == 0 else "No")

a = input()
for i in ["SN","EW","ENSW"]:
    if set(i) == set(a):
        print("Yes")
        exit()
print("No")

Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    if 'N' in s and 'S' in s and 'W' in s and 'E' in s:
        ans='Yes'
    elif 'N' in s and 'S' in s and 'W' not in s and 'E' not in s:
        ans='Yes'
    elif 'N' not in s and 'S' not in s and 'W' in s and 'E' in s:
        ans='Yes'
    else:
        ans='No'
    print(ans)
resolve()

import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=set(input())
    ans='No'
    if s==set('NSWE') or s==set('NS') or s==set('WE'):
        ans='Yes'
    print(ans)
resolve()

Verdicts: Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s = input()
from collections import defaultdict
d = defaultdict(bool)
def inv(c):
    dic = {"W":"E", "E":"W", "S":"N", "N":"S"}
    return dic[c]
for c in s:
    d[c] = True
def sol():
    for c in "NSWE":
        if d[c] == True and d[inv(c)] == False:
            return False
    return True
print("YNEOS"[not sol()::2])  

s = input()
from collections import defaultdict
d = defaultdict(bool)
def inv(c):
    dic = {"W":"E", "E":"W", "S":"N", "N":"S"}
    return dic[c]
for c in s:
    d[c] = True
def sol():
    for c in "NSWE":
        if d[c] == True and d[inv(c)] == False:
            return False
    return True
print("YNeos"[not sol()::2])  

Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
S = input()
a = S.count('N')
b = S.count('S')
c = S.count('E') 
d = S.count('W')

if a*b > 0 and c==0 and d==0:
  print('Yes')
elif c*d >0 and a==0 and b==0:
  print('Yes')
elif a==0 and b==0 and c==0 and d==0:
  print('Yes')
else:
  print('No')

S = input()
a = S.count('N')
b = S.count('S')
c = S.count('E') 
d = S.count('W')

if a*b*c*d > 0:
  print('Yes')
elif a*b > 0 and c==0 and d==0:
  print('Yes')
elif c*d >0 and a==0 and b==0:
  print('Yes')
elif a==0 and b==0 and c==0 and d==0:
  print('Yes')
else:
  print('No')

Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
def inpl():
    return list(map(int, input().split()))


def f(a, b):
    if a == 0 and b == 0:
        return True
    elif a * b == 0:
        return False
    else:
        return True

S = input()

N = S.count('N')
W = S.count('W')
S = S.count('S')
E = E.count('E')

if f(N, S) is True and f(W, E) is True:
    print('Yes')
else:
    print('No')

def inpl():
    return list(map(int, input().split()))


def f(a, b):
    if a == 0 and b == 0:
        return True
    elif a * b == 0:
        return False
    else:
        return True


S = input()
# print(S)
cN = S.count('N')
cW = S.count('W')
cS = S.count('S')
cE = S.count('E')

if f(cN, cS) is True and f(cW, cE) is True:
    print('Yes')
else:
    print('No')


Verdicts: Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
def main():
    for line in sys.stdin:
		s = line
		if (('N' in s) and ('S' in s)) and not (('W' in s) or ('E' in s)):
			print("Yes")
		elif (('W' in s) and ('E' in s)) and not (('N' in s) or ('S' in s)):
			print("Yes")
		elif (('W' in s) and ('E' in s)) and (('N' in s) and ('S' in s)):
			print("Yes")
		else:
			print("No")

from sys import stdin

def main():
    M = stdin.readline().strip()
    S,E,N,W=False,False,False,False
    for i in M:
        if i == 'S':
            S = True
        elif i == 'E':
            E = True
        elif i == 'N':
            N = True
        elif i == 'W':
            W = True
    if S == N and E == W:
        print('Yes')
    else:
        print('No')

main()


Verdicts: Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
se = set(input())
bl = not ((se ^ set('WE')) or (se ^ set('NS')))
print('Yes' if bl else 'No')

import sys

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

S = read().decode()

N, W, S, E = 'N' in S, 'W' in S, 'S' in S, 'E' in S

cond1 = not N ^ S
cond2 = not W ^ E

print('Yes' if cond1 and cond2 else 'No')

Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a[::2])
a.sort()
now = 0
ans = 0
br = (n+1) // 2
for k,v in enumerate(a):
  if b[now] == v:
    ans += abs(k-now*2)
    now += 1
  if now == br:
    break
print(ans)

n = set(list(input()))
if n == set("N","S") or n == set("W","E") or n == set("N","S","W","E")
  print("Yes")
else:
  print("No")

n = set(list(input()))
if n == set(["N","S"]) or n == set(["W","E"]) or n == set(["N","S","W","E"]):
  print("Yes")
else:
  print("No")

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s = input()

def f(a,b):
  return (a in s and b not in s) or (b in s and a not in s):
  
if f('W', 'E') or f('N', 'S'):
  print('No')
else:
  print('Yes')

s = input()

def f(a,b):
  return (a in s and b not in s) or (b in s and a not in s)
  
if f('W', 'E') or f('N', 'S'):
  print('No')
else:
  print('Yes')



Verdicts: Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s = input()


def walk(s):
    ls = len(s)
    nc = 0
    sc = 0
    wc = 0
    ec = 0
    l=[]
    for i in range(ls):
        if s[i] == "W":
            wc += 1
            l.append(wc)
        elif s[i] == "E":
            ec += 1
            l.append(ec)
        elif s[i] == "N":
            nc += 1
            l.append(nc)
        else:
            sc += 1
            l.append(sc)
    if (wc>0 and ec==0) or (wc==0 and ec>0) or (nc==0 and sc>0) or (nc>0 and sc==0):
        print("NO")
        return
    
    else:
        print("YES")
        return


walk(s)


s=input()

def walk(s):
  ls=len(s)
  if ls%2==1:
    print("NO")
    return
  nc=0
  sc=0
  wc=0
  ec=0
  for i in range(ls):
    if s[i]="W":
      wc+=1
    elif s[i]="E":
      ec+=1
    elif s[i]="N":
      nc+=1
    else:
      sc+=1
  if wc==ec and nc==sc:
    print("YES")
    return
  else:
    print("NO")
    return
walk(s)
    

s = input()


def walk(s):
    ls = len(s)
    nc = 0
    sc = 0
    wc = 0
    ec = 0
    l=[]
    for i in range(ls):
        if s[i] == "W":
            wc += 1
            l.append(wc)
        elif s[i] == "E":
            ec += 1
            l.append(ec)
        elif s[i] == "N":
            nc += 1
            l.append(nc)
        else:
            sc += 1
            l.append(sc)
    if (wc>0 and ec==0) or (wc==0 and ec>0) or (nc==0 and sc>0) or (nc>0 and sc==0):
        print("No")
        return
    
    else:
        print("Yes")
        return
walk(s)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
S = input()
i = 0
X = [False,False]
Y = [False,False]
flg = False
while(i < len(S)):
    if S[i:i+1] == 'N':
        X[0] = True
    elif S[i:i+1] == 'S':
        X[1] = True
    elif S[i:i+1] == 'W':
        Y[0] = True
    elif S[i:i+1] == 'E':
        Y[1] = True
    print(X,Y)
    if X[0]==X[1] and Y[0]==Y[1]:
        flg = True
        break
    i+=1
print('Yes' if flg else 'No')


print('NYoe s'[set(input())in map(set,['','NS','EW','NSEW'])::2])

Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s = input()

n = 0
e = 0
w = 0
s = 0

for v in s:
    if v == 'N': n+=1
    if v == 'E': e+=1
    if v == 'W': w+=1
    if v == 'S': s+=1

if n == s and e == w:
    print('Yes')
else:
    print('No')

S = input()

n = 0
e = 0
w = 0
s = 0

for v in S:
    if v == 'N': n+=1
    if v == 'E': e+=1
    if v == 'W': w+=1
    if v == 'S': s+=1
if ((0<n and 0<s) or (n==0 and s==0)) and ((0<e and 0<w) or (e==0 and w==0)):
    print('Yes')
else:
    print('No')

Verdicts: Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
S = input()
N = len(S)
d = [0,0,0,0]
s = ['N','W','S','E']
for i in range(N):
    for j in range(3):
        if S[i] == s[j]:
            d[j] += 1
            break
flag = True
if (d[0] == 0 and d[2] == 0) or (d[0] != 0 and d[2] != 0):
    pass
else:
    flag = False
if (d[1] == 0 and d[3] == 0) or (d[1] != 0 and d[3] != 0):
    pass
else:
    flag = False
    
if flag:
    print('Yes')
else:
    print('No')


S = input()
N = len(S)
d = [0,0,0,0]
s = ['N','W','S','E']
for i in range(N):
    for j in range(4):
        if S[i] == s[j]:
            d[j] += 1
            break

flag = True
if (d[0] == 0 and d[2] == 0) or (d[0] != 0 and d[2] != 0):
    pass
else:
    flag = False
if (d[1] == 0 and d[3] == 0) or (d[1] != 0 and d[3] != 0):
    pass
else:
    flag = False
    
if flag:
    print('Yes')
else:
    print('No')



Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s=input()
ans=[0]*4
checK='NWSE'
for i in range(len(s)):
  for j in range(len(check)):
    if s[i]==check[j]:
      ans[j]+=1
if (ans[0]%2+ans[2]%2)%2==0 and (ans[1]%2+ans[3]%2)%2==0:
  print('Yes')
else:
  print('No')

s=input()
ans=[0]*4
checK='NWSE'
for i in range(len(s)):
  for j in range(len(check)):
    if s[i]==check[j]:
      ans[j]+=1
if (ans[0]+ans[2])%2==0 and (ans[1]+ans[3])%2==0:
  print('Yes')
else:
  print('No')

s=input()
ans=[0]*4
check='NWSE'
for i in range(len(s)):
  for j in range(len(check)):
    if s[i]==check[j]:
      ans[j]=1
if (ans[0]+ans[2])%2==0 and (ans[1]+ans[3])%2==0:
  print('Yes')
else:
  print('No')

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s = input()

a = 'N' in s
b = 'S' in s
c = 'E' in s
d = 'W' in s
ans = all([a == b, c == d])
print(ans)



s = input()

a = 'N' in s
b = 'S' in s
c = 'E' in s
d = 'W' in s

ans = 'Yes' if all([a == b, c == d]) else 'No'
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
# coding:utf-8

S = input()
n = S.count('N')
s = S.count('S')
e = S.count('E')
w = S.count('W')
print(n, s, e, w)

if (n == 0 and s != 0) or (n != 0 and s == 0):
    print('No')
elif (e == 0 and w != 0) or (e != 0 and w == 0):
    print('No')
else:
    print('Yes')


# coding:utf-8

S = input()
n = S.count('N')
s = S.count('S')
e = S.count('E')
w = S.count('W')
# print(n, s, e, w)

if (n == 0 and s != 0) or (n != 0 and s == 0):
    print('No')
elif (e == 0 and w != 0) or (e != 0 and w == 0):
    print('No')
else:
    print('Yes')


Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
def NS(S):
  return ("N" in S) ^ ("S" in S)

def EW(S):
  return ("E" in S) ^ ("W" in S)

S = input()
if NS(S) and EW(S):
  print("Yes")
else:
  print("No")


def NS(S):
  return ("N" in S) ^ ("S" in S)

def EW(S):
  return ("E" in S) ^ ("W" in S)



S = input()
if not(NS(S)) and not(EW(S)):
  print("Yes")
else:
  print("No")

Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s = set(input())
if len(s) == 4 and (len(s) == 2 and (s == {'S', 'N'} or s == {'E', 'W'})):
    print('Yes')
else:
    print('No')

s = set(input())
if len(s) == 4 or (len(s) == 2 and (s == {'S', 'N'} or s == {'E', 'W'})):
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s = list(set(input()))
l = [["N","S"], ["W","E"], ["N", "S", "W", "E"]]
dame = True
for i in l:
    for j in s:
        x = 0
        if j in i:
            x += 1
        else:
            pass
    if x == len(s):
        print("Yes")
        exit()
print("No")
            

s = list(set(input()))
l = [["N","S"], ["W","E"], ["N", "S", "W", "E"]]
if len(s) != 2 and len(s) != 4:
    print("No")
    exit()
for i in l:
    x = 0
    for j in s:
        if j in i:
            x += 1
    if x == len(i):
        print("Yes")
        exit()
print("No")

Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
s = input()
print('Yes' if('W' in s == 'E' in s and 'S' in s == 'N' in s) else 'No')

s = input()
print('Yes' if(('W' in s)==('E' in s) and ('N' in s)==('S' in s)) else 'No')

Verdicts: Wrong Answer

Accepted
Problem: Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:    * North if the i-th letter of S is `N`   * West if the i-th letter of S is `W`   * South if the i-th letter of S is `S`   * East if the i-th letter of S is `E`  He has not decided each day's travel distance. Determine whether it is possible to set each day's travel distance so that he will be back at home at the end of Day N.

Submission attempts (in order):
i = input()
s = i.count("S")
n = i.count("N")
e = i.count("E")
w = i.count("W")
print(s,n,e,w)

if s == n and e == w:
  print("Yes")
else:
  print("No")


i = input()

if "S" in i and "N" not in i:
    print("No")
elif "N" in i and "S" not in i:
    print("No")
elif "E" in i and "W" not in i: 
	print("No")
elif "W" in i and "E" not in i: 
	print("No")
else:
  	print("Yes")

Verdicts: Wrong Answer

Accepted