Problem:


Score : 200 points

Problem Statement

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.

Constraints

1 ≦ | S | ≦ 1000

S consists of the letters N, W, S, E.

Input

The input is given from Standard Input in the following format:

S

Output

Print Yes if it is possible to set each day's travel distance so that he will be back at home at the end of Day N. Otherwise, print No.

Sample Input 1

SENW

Sample Output 1

Yes

If Snuke travels a distance of 1 on each day, he will be back at home at the end of day 4.

Sample Input 2

NSNNSNSN

Sample Output 2

Yes

Sample Input 3

NNEW

Sample Output 3

No

Sample Input 4

W

Sample Output 4

No



Sample input:
SENW


Sample output:
Yes

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=set;print("NYoe s"[s(input())in map(s,["NS","EW","NSEW"])::2])

Submission status: Accepted

Solution code:
s=set(input());print("YNeos"[1 in[(len(s&set(t)))for t in["NS","WE"]]::2])

Submission status: Accepted

Solution code:
S = input()

S = set(S)
if 1 not in [len(S&set(t)) for t in ["NS", "WE"]]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = str(input())

a = []
b = []
for i in S:
    if i == "N" or i == "S":
        a.append(i)
    else:
        b.append(i)

if len(set(a)) == 1 or len(set(b)) == 1:
    print("No")

else:
    print("Yes")

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

s = input()
ans = "Yes"
if "W" in s:
    if not "E" in s:
        ans = "No"
if "E" in s:
    if not "W" in s:
        ans = "No"

if "N" in s:
    if not "S" in s:
        ans = "No"
if "S" in s:
    if not "N" in s:
        ans = "No"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
if (s.count('E')>0 and s.count('W')>0 and s.count('N')>0 and s.count('S')>0):
    print('Yes')
elif ((s.count('E')==0 and s.count('W')==0)) and ((s.count('N')>0 and s.count('S')>0)):
    print('Yes')
elif ((s.count('N')==0 and s.count('S')==0)) and ((s.count('E')>0 and s.count('W')>0)):
    print('Yes')
elif (s.count('E')==0 and s.count('W')==0 and s.count('N')==0 and s.count('S')==0):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

# 南北のうち南だけ、とか東西のうち東だけ、みたいのがあるとNG
if ('N' in S) ^ ('S' in S) or ('E' in S) ^ ('W' in S):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
a=list(input())
if ("N" in a and"S"in a)or(not"N" in a and not "S" in a):
    if ("W" in a and"E"in a)or(not"W" in a and not "E" in a):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
if ("S" in s)^("N" in s):
  print("No")
elif ("W" in s)^("E" in s):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
S = input()

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

for i in range(len(S)):
	if S[i]=='N':
		n = 1
	elif S[i]=='S':
		s = 1
	elif S[i]=='E':
		e = 1
	else:
		w = 1

if abs(n-s)==1 or abs(e-w)==1:
	print('No')
else:
	print('Yes')

Submission status: Accepted

Solution code:
S = input()
OK = True
if 'N' in S:
    if not 'S' in S:
        OK = False
if 'S' in S:
    if not 'N' in S:
        OK = False
if 'E' in S:
    if not 'W' in S:
        OK = False
if 'W' in S:
    if not 'E' in S:
        OK = False
print('Yes' if OK else 'No')

Submission status: Accepted

Solution code:
s = input().strip()
if not ('S' in s and 'N' in s) and ('S' in s or 'N' in s):
        print('No')
        exit()

if not ('E' in s and 'W' in s) and ('E' in s or 'W' in s):
        print('No')
        exit()

 
print('Yes')

Submission status: Accepted

Solution code:
S=input()
rec={"N":0,"W":0,"S":0,"E":0}
for i in S:
    rec[i]+=1

if rec["N"]>0 and rec["S"]==0:
    print("No")
elif rec["N"]==0 and rec["S"]>0:
    print("No")    
elif rec["W"]>0 and rec["E"]==0:
    print("No")
elif rec["W"]==0 and rec["E"]>0:
    print("No")    
else:
    print("Yes")

Submission status: Accepted

Solution code:
a=list(input())
if len(set(a)) == 4 or ("N" in a and "S" in a and len(set(a)) ==2 )or("E" in a and "W" in a and len(set(a)) ==2):
  print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()

set_S = set(list(S))

if len(set_S) == 2:
    if set_S == set(['N', 'S']):
        print('Yes')
    elif set_S == set(['W', 'E']):
        print('Yes')
    else:
        print('No')
elif len(set_S) == 4:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
ｓ = input()
if (("N" in s and "S" not in s) 
 or ("S" in s and "N" not in s) 
 or ("W" in s and "E" not in s) 
 or ("E" in s and "W" not in s)):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()
if ("N" in s and "S" not in s) \
 or ("S" in s and "N" not in s) \
 or ("W" in s and "E" not in s) \
 or ("E" in s and "W" not in s):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
S = input()
s = set(S)
if ("N" in s and "S" not in s) \
 or ("S" in s and "N" not in s) \
 or ("W" in s and "E" not in s) \
 or ("E" in s and "W" not in s):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = list(input())
N = bool(s.count('N'))
E = bool(s.count('E'))
W = bool(s.count('W'))
S = bool(s.count('S'))

if (N ^ S) or (W ^ E):
    print("No")
else :
    print("Yes")

Submission status: Accepted

Solution code:
ar = list(input())
br = set(ar)
if len(br) == 4:
    print("Yes")
elif len(br) == 1 or len(br) == 3:
    print("No")
else:
    if "N" in br and "S" in br:
        print("Yes")
    elif "E" in br and "W" in br:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]
    W_num = S.count("W")
    E_num = S.count("E")
    if (W_num == 0 and E_num != 0) or (E_num == 0 and W_num != 0):
        print "No"
        return

    N_num = S.count("N")
    S_num = S.count("S")
    if (N_num == 0 and S_num != 0) or (S_num == 0 and N_num != 0):
        print "No"
        return

    print "Yes"


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
if ('N' in S) ^ ('S' in S) or ('W' in S) ^ ('E' in S):
    print('No')
else:
    print('Yes')
#コピペです。

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    """Function."""
    s = str(input())

    N = s.count("N")
    W = s.count("W")
    S = s.count("S")
    E = s.count("E")

    ns_flag = -1
    if N == 0 and S == 0:
        ns_flag = 1
    elif N == 0 and S != 0:
        ns_flag = -1
    elif N != 0 and S == 0:
        ns_flag = -1
    else:
        ns_flag = 1

    we_flag = -1
    if W == 0 and E == 0:
        we_flag = 1
    elif W == 0 and E != 0:
        we_flag = -1
    elif W != 0 and E == 0:
        we_flag = -1
    else:
        we_flag = 1

    if ns_flag == -1 or we_flag == -1:
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
S = set(input())
if S==set("NSEW") or S==set("NS") or S==set("EW"):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
S = input()
ans = "Yes"
if ("N" in S) and ("S" not in S):
    ans = "No"
elif ("S" in S) and ("N" not in S):
    ans = "No"
elif ("E" in S) and ("W" not in S):
    ans = "No"
elif ("W" in S) and ("E" not in S):
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
aa = input()
s =0;w = 0;e=0;n=0;
if "S" in aa:
  s = 1
if "N" in aa:
  n = 1
if "E" in aa:
  e = 1
if "W" in aa:
  w = 1
if (s and w and n and e) or (s and n and e == 0 and w == 0) or(s==0 and n==0 and e and w):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()
if S.count('E') >= 1 and S.count('W') >= 1 and S.count('N') >= 1 and S.count('S') >= 1:
    print('Yes')
else:
    if S.count('E') == S.count('W') == 0 and S.count('N') >= 1 and S.count('S') >= 1:
        print('Yes')
    elif S.count('N') == S.count('S') == 0 and S.count('E') >= 1 and S.count('W') >= 1:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
s = input()
news = [0, 0, 0, 0]
for i in range(len(s)):
    if s[i] == "N":
        news[0] += 1
    elif s[i] == "E":
        news[1] += 1
    elif s[i] == "W":
        news[2] += 1
    elif s[i] == "S":
        news[3] += 1
if news[0] > 0 and news[3] == 0:
    print("No")
    exit()
if news[0] == 0 and news[3] > 0:
    print("No")
    exit()
if news[1] > 0 and news[2] == 0:
    print("No")
    exit()
if news[1] == 0 and news[2] > 0:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    s = input()
    n_count = s.count('N')
    s_count = s.count('S')
    e_count = s.count('E')
    w_count = s.count('W')

    if n_count > 0 and s_count == 0:
        print('No')
    elif s_count > 0 and n_count == 0:
        print('No')
    elif e_count > 0 and w_count == 0:
        print('No')
    elif w_count > 0 and e_count == 0:
        print('No')
    else:
        print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
if 'N' in s and 'S' not in s:
    print('No')
    exit()
elif 'S' in s and 'N' not in s:
    print('No')
    exit()
elif 'W' in s and 'E' not in s:
    print('No')
    exit()
elif 'E' in s and 'W' not in s:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
S = input()
if ('N' in S) ^ ('S' in S) or ('W' in S) ^ ('E' in S):
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
ins = input().strip()
if not ('S' in ins and 'N' in ins) and ('S' in ins or 'N' in ins):
        print('No')
        exit()
if not ('E' in ins and 'W' in ins) and ('E' in ins or 'W' in ins):
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
S = input()
NWSE = [0, 0, 0, 0]
for c in S:
    if c=="N":
        NWSE[0]=1
    elif c=="W":
        NWSE[1]=1
    elif c=="S":
        NWSE[2]=1
    else:
        NWSE[3]=1

if (NWSE[0] and not NWSE[1] and NWSE[2] and not NWSE[3]) or (not NWSE[0] and NWSE[1] and not NWSE[2] and NWSE[3]) or (NWSE[0] and NWSE[1] and NWSE[2] and NWSE[3]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict as dd

s = input().strip()
coll = dd(int)

for el in s:
    coll[el] += 1


condition = (
    min(coll["N"], coll["S"]) == 0 and
    max(coll["N"], coll["S"]) != 0 or
    min(coll["E"], coll["W"]) == 0 and
    max(coll["E"], coll["W"]) != 0)

if condition:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s=list(input())
if s.count('W')>0 and s.count('E')>0 and s.count('N')>0 and s.count('S')>0:
    print("Yes")
elif s.count('W')>0 and s.count('E')>0 and s.count('N')==0 and s.count('S')==0:
    print('Yes')
elif s.count('W')==0 and s.count('E')==0 and s.count('N')>0 and s.count('S')>0:
    print('Yes')
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
n = "N" in S
s = "S" in S
e = "E" in S
w = "W" in S
print("Yes" if n == s and e == w else "No")

Submission status: Accepted

Solution code:
S = input()
rec = {"N": 0, "W": 0, "S": 0, "E": 0}
for i in S:
    rec[i] += 1

if rec["N"] > 0 and rec["S"] == 0:
    print("No")
elif rec["N"] == 0 and rec["S"] > 0:
    print("No")
elif rec["W"] > 0 and rec["E"] == 0:
    print("No")
elif rec["W"] == 0 and rec["E"] > 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s=input()
x=[s.count("N"),s.count("S"),s.count("E"),s.count("W")]
if (x[0]!=0 and x[1]==0) or (x[1]!=0 and x[0]==0) or (x[2]!=0 and x[3]==0) or (x[3]!=0 and x[2]==0):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
S = input()

n = S.count("N")
s = S.count("S")
e = S.count("E")
w = S.count("W")

home = False
if n and s:
    if e and w:
        print("Yes")
    elif not e and not w:
        print("Yes")
    else:
        print("No")

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

else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin


def main() -> None:
    s = next_str()
    x = set()
    y = set()

    for c in s:
        if c == "N" or c == "S":
            y.add(c)
        if c == "W" or c == "E":
            x.add(c)

    if len(x) % 2 != 0 or len(y) % 2 != 0:
        print("No")
    else:
        print("Yes")


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = list({i for i in input()})

if len(S)==1 or len(S)==3:
    print("No")
    exit()

elif len(S)==4:
    print("Yes")
    exit()

else:
    if ('E' in S and 'W' in S) or ('N' in S and 'S' in S):
        print("Yes")
        exit()
    else:
        print("No")
        exit()

Submission status: Accepted

Solution code:
x = input()
n = x.count("N")
w = x.count("W")
s = x.count("S")
e = x.count("E")
if (n == 0 and s != 0) or (n != 0 and s == 0) or (w == 0 and e != 0) or (w != 0 and e == 0):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
news = str(input())
news = list(news)
cn = news.count('N')
ce = news.count('E')
cw = news.count('W')
cs = news.count('S')
if cn > 0 and ce > 0 and cw > 0 and cs > 0 :
  print("Yes")
elif cn == cs == 0:
  if cw > 0 and ce > 0:
    print("Yes")
  else:
    print("No")
elif cw == ce == 0:
  if cn > 0 and cs > 0:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
S = list(input())
w = 0
e = 0
n = 0
s = 0
if "W" in S :
    w = 1
if "E" in S :
    e = 1
if "N" in S :
    n = 1
if "S" in S :
    s = 1
if w == e and n == s :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
s = input()
a = -1
b = -1
c = -1
d = -1

for i in range(len(s)):
    if s[i] == "W":
        a = 1
    elif s[i] == "E":
        b = 1
    elif s[i] == "S":
        c = 1
    else:
        d = 1

if a * b == 1 and c * d == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
st = list(input())

#print(s)

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

for i in range(len(st)):
    if st[i] == 'N':
        n = 1
    elif st[i] == 'S':
        s = 1
    elif st[i] == 'W':
        w = 1
    elif st[i] == 'E':
        e = 1


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

else:
    print("No")

Submission status: Accepted

Solution code:
listS=list(input())

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

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

else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

Count = {"N":0, "W":0, "S":0, "E":0}

for ch in S:
  Count[ch] += 1
  
if max(Count["N"], Count["S"]) > 0 and min(Count["N"], Count["S"]) == 0:
  print("No")
elif max(Count["E"], Count["W"]) > 0 and min(Count["E"], Count["W"]) == 0:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
s = list(input())

v = [i in s for i in ['S', 'N']]
h = [i in s for i in ['E', 'W']]
if sum(v) == 1 or sum(h) == 1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
string = input()

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

for i in range(len(string)):
    if string[i] == 'W':
        w = 1
    elif string[i] == 'E':
        e = 1
    elif string[i] == 'S':
        s = 1
    else:
        n = 1
        
if w == e and s == n:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(input())
print("No" if (("N" in a) ^ ("S" in a)) or (("W" in a) ^ ("E" in a)) else "Yes")

Submission status: Accepted

Solution code:
hoge = str(input())
list_hoge = list(hoge)
n = list_hoge.count("N")
s = list_hoge.count("S")
e = list_hoge.count("E")
w = list_hoge.count("W")
ans = "Yes"
if n+s != 0:
    if n == 0 or s == 0:
        ans ="No"
    else:
         pass
else:
    pass

if e+w != 0:
    if e == 0 or w == 0:
        ans = "No"
    else:
        pass
else:
    pass

print(ans)

Submission status: Accepted

Solution code:
S = input()
SENW = ['S','N','E','W']
dic = {}
for s in SENW:
    dic[s] = 0
for s in S:
    dic[s] += 1

ch = 0
if dic['S'] > 0:
    if dic['N'] == 0:
        ch = 1

if dic['N'] > 0:
    if dic['S'] == 0:
        ch = 1

if dic['E'] > 0:
    if dic['W'] == 0:
        ch = 1

if dic['W'] > 0:
    if dic['E'] == 0:
        ch = 1


if ch == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter
s = Counter(input())

if s["N"]>=1 and s["S"]>=1 and s["W"]>=1 and s["E"]>=1:
    print('Yes')
    exit()
elif s["N"]>=1 and s["S"]>=1 and s["W"]==0 and s["E"]==0:
    print('Yes')
    exit()
elif s["N"]==0 and s["S"]==0 and s["W"]>=1 and s["E"]>=1:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
S = input()
T = set(S)
if (len(T) == 4):
  print('Yes')
elif (len(T) == 1 or len(T) == 3):
  print('No')
else:
  if ('N' in T):
    if ('S' in T):
      print('Yes')
    else:
      print('No')
  elif ('S' in T):
    if ('N' in T):
      print('Yes')
    else:
      print('No')
  elif ('W' in T):
    if ('E' in T):
      print('Yes')
    else:
      print('No')
  else:
    if ('W' in T):
      print('Yes')
    else:
      print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = set(input())
ans = 0
if len(s) == 4:
    ans = 1
elif len(s) == 2:
    if set("NS") == s or set("EW") == s:
        ans = 1
print("Yes" if ans else "No")

Submission status: Accepted

Solution code:
# coding:utf-8

INF = float('inf')


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


S = input()
S_li = list(S)
direction = ('N', 'W', 'S', 'E')
judge = []
for di in direction:
    if di in S_li:
        judge.append(1)
    else:
        judge.append(0)


if judge[0] ^ judge[2] == 1:
    print('No')
elif judge[1] ^ judge[3] == 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = input()
print(['Yes','No'][('N'in s)^('S'in s)|('E'in s)^('W'in s)])

Submission status: Accepted

Solution code:
s = input()
print(['No','Yes'][('W'in s)==('E'in s)and('N'in s)==('S'in s)])

Submission status: Accepted

Solution code:
s=list(input())
if int('N' in s)==int('S' in s) and int('W' in s)==int('E' in s):print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
s = input()
if "N" in s and not "S" in s:
  print("No")
  exit()
elif not "N" in s and "S" in s:
  print("No")
  exit()
elif "W" in s and not "E" in s:
  print("No")
  exit()
elif not "W" in s and "E" in s:
  print("No")
  exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

s = lc()

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

Submission status: Accepted

Solution code:
s = input()
l = [0]*4
y = "Yes"
n = "No"
res = ""

for i in s:
    if i == "S":
        l[0] += 1
    elif i == "E":
        l[1] += 1
    elif i == "N":
        l[2] += 1
    elif i == "W":
        l[3] += 1

if (l[0] == 0 and l[2] >= 1) or (l[0] >= 1 and l[2] == 0) or (l[1] == 0 and l[3] >= 1) or (l[3] == 0 and l[1] >= 1):
    res = n
else:
    res = y

print(res)

Submission status: Accepted

Solution code:
S = input()
if len(set(S)) % 2 == 1:
    print('No')
elif len(set(S)) == 4:
    print('Yes')
elif len(set(S)) == 2:
    if 'N' in S and 'S' in S:
        print('Yes')
    elif 'W' in S and 'E' in S:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
def main23():
    strbuf = input("");
    flag = [];
    for i in range(4):
        flag.append(False);
    for i in range(len(strbuf)):
        if strbuf[i] == 'N':
            flag[0] = True;
        if strbuf[i] == 'W':
            flag[1] = True;
        if strbuf[i] == 'S':
            flag[2] = True;
        if strbuf[i] == 'E':
            flag[3] = True;
    if (flag[0] and not(flag[2])) or (flag[2] and not(flag[0])):
        print("No");
    elif (flag[1] and not(flag[3])) or (flag[3] and not(flag[1])):
        print("No");
    else:
        print("Yes");

if __name__ == '__main__':
    main23()

Submission status: Accepted

Solution code:
# cook your dish here
s=list(input())
a = s.count('N')
b = s.count('W')
c = s.count('S')
d = s.count('E')
ass = 0
if a ==0:
    if c == 0:
        ass += 1
else:
    if c > 0:
        ass += 1
if b == 0:
    if d == 0:
        ass += 1
else:
    if d > 0:
        ass += 1

if ass == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x,y=0,0
s=input()

a=s.count("N")>0
b=s.count("S")>0
c=s.count("E")>0
d=s.count("W")>0
e=(a,b,c,d)
if e==(True,True,False,False) or e==(False,False,True,True) or e==(True,True,True,True):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s=input()
print("Yes" if (not ('N' in s)^('S' in s)) and (not ('W' in s)^('E' in s)) else "No")

Submission status: Accepted

Solution code:
s = set(raw_input())
l = len(s)
if l in [1, 3]:
    print 'No'
elif l == 4:
    print 'Yes'
else:
    print ['No', 'Yes'][s in [set('NS'), set('WE')]]

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

SS = list(input())
W = N = S = E = 0
for s in SS:
	if s == 'W':
		W += 1
	elif s == 'N':
		N += 1
	elif s == 'S':
		S += 1
	elif s == 'E':
		E += 1

if (W == 0 and E != 0) or (W != 0 and E == 0):
	print('No')
elif (N == 0 and S != 0) or (N != 0 and S == 0):
	print('No')
else:
	print('Yes')

Submission status: Accepted

Solution code:
Ss = input()

setS = set(Ss)
lenS = len(setS)

if lenS in [1, 3]:
    print('No')
elif lenS == 4:
    print('Yes')
else:
    if setS in [set('NS'), set('WE')]:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
S = input()

from collections import Counter

cs = Counter(S)

result = not (((cs["N"] > 0) ^ (cs["S"] > 0)) | ((cs["W"] > 0) ^ (cs["E"] > 0)))

if result:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input();print(['Yes','No'][(('N'in s)^('S'in s))|(('E'in s)^('W'in s))])

Submission status: Accepted

Solution code:
s=input();print('No'if(('N'in s)^('S'in s))|(('E'in s)^('W'in s))else'Yes')

Submission status: Accepted

Solution code:
s = input()

cnt_n = s.count('N')
cnt_s = s.count('S')
cnt_e = s.count('E')
cnt_w = s.count('W')

p1 = ((cnt_n > 0) and (cnt_s > 0)) or ((cnt_n == 0) and (cnt_s == 0))
p2 = ((cnt_e > 0) and (cnt_w > 0)) or ((cnt_e == 0) and (cnt_w == 0))
print('Yes' if p1 and p2 else 'No')

Submission status: Accepted

Solution code:
S = list(input())
if S.count("N") == 0 and S.count("S") == 0:
	if S.count("E") >= 1 and S.count("W") >= 1:
		print("Yes")
	else:
		print("No")
elif S.count("E") == 0 and S.count("W") == 0:
	if S.count("N") >= 1 and S.count("S") >= 1:
		print("Yes")
	else:
		print("No")
else:
	if S.count("N") >= 1 and S.count("S") >= 1 and S.count("W") >= 1 and S.count("E") >= 1:
		print("Yes")
	else:
		print("No")

Submission status: Accepted

Solution code:
def back_home():
    S=input()
    if((('S'in S) and ('N' in S)) and not (('E' in S) or  ('W' in S))):
        print('Yes')
    elif(not (('S' in S) or ('N'  in S)) and (('E' in S) and ('W' in S))):
        print("Yes")
    elif((('S'in S) and ('N' in S)) and (('E' in S) and ('W' in S))):
        print("Yes")
    else:
        print("No")
          
back_home()

Submission status: Accepted

Solution code:
def backhome():
	s = input()
	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")

backhome()

Submission status: Accepted

Solution code:
s = input()
print(["Yes","No"][(("N"in s) ^ ("S"in s)) or (("W"in s) ^ ("E" in s))])

Submission status: Accepted

Solution code:
s = set(list(input()))

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

Submission status: Accepted

Solution code:
import collections
s = input()
d = collections.Counter(s)
if len(d.keys()) == 4:
    print("Yes")
elif len(d.keys()) == 2 and "N" in d.keys() and "S" in d.keys():
    print("Yes")
elif len(d.keys()) == 2 and "E" in d.keys() and "W" in d.keys():
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

n = S.count("N")
w = S.count("W")
s = S.count("S")
e = S.count("E")

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

Submission status: Accepted

Solution code:
def getinputdata():

    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

s = "".join(arr_data[0])

if s.find("N")>=0 and s.find("S")>=0 and s.find("E")>=0 and s.find("W")>=0:
    
    print("Yes")
    
elif s.find("N")>=0 and s.find("S")>=0 and s.find("E")==-1 and s.find("W")==-1:
    
    print("Yes")
    
elif s.find("E")>=0 and s.find("W")>=0 and s.find("N")==-1 and s.find("S")==-1:
    
    print("Yes")
    
else:
    
    print("No")

Submission status: Accepted

Solution code:
def main():
    s = input()
    
    s_set = set(s)
    if len(s_set) == 4:
        print("Yes")
    elif len(s_set) == 2:
        if ("N" in s_set and "S" in s_set) or ("W" in s_set and "E" in s_set):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
        
        
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = set(input())
if S == set(['N', 'S', 'W', 'E']) or S == set(['N', 'S']) or S == set(['E', 'W']):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = set(list(input()))
if len(s) == 3 or len(s) == 1:
  print('No')
elif 'N' in s and 'S' in s and 'E' in s and 'W' in s:
  print('Yes')
elif len(s) == 2:
  if 'N' in s and 'S' in s:
    print('Yes')
  elif 'W' in s and 'E' in s:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
import collections
S = input().strip()
count = collections.Counter(S)

cond1 = (count['N']==0) == (count['S']==0)
cond2 = (count['E']==0) == (count['W']==0)
if cond1 and cond2:
  print('Yes')
else:
  print('No')