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:
import collections

S=input()
S=collections.Counter(S)

if (S["N"]>0 and S["S"]>0) or (S["N"]==0 and S["S"]==0):
  if (S["E"]>0 and S["W"]>0) or (S["E"]==0 and S["W"]==0): 
    print("Yes")
    exit()
print("No")

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())
ans="Yes"
n=S.count("N")
e=S.count("E")
w=S.count("W")
s=S.count("S")
if n>0 and s>0:
  if e>0 and w>0:
    pass
  elif e==0 and w==0:
    pass
  else:
    ans="No"
elif n==0 and s==0:
  if e>0 and w>0:
    pass
  elif e==0 and w==0:
    pass
  else:
    ans="No"
elif e>0 and w>0:
  if n>0 and s>0:
    pass
  elif n==0 and s==0:
    pass
  else:
    ans="No"
elif e==0 and w==0:
  if n>0 and s>0:
    pass
  elif n==0 and s==0:
    pass
  else:
    ans="No"
else:
  ans="No"
print(ans)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7




S = sys.stdin.readline().rstrip()


n = 'N' in S
w = 'W' in S
s = 'S' in S
e = 'E' in S

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

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
def solve(s):
    s = set(s)
    if ("N" in s) and (not "S" in s):
        return "No"
    if ("S" in s) and (not "N" in s):
        return "No"
    if ("W" in s) and (not "E" in s):
        return "No"
    if ("E" in s) and (not "W" in s):
        return "No"
    return "Yes"

s = input()
print(solve(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
nN = 0
nW = 0
nS = 0
nE = 0
for c in S:
  if c == "N":
    nN += 1
  if c == "W":
    nW += 1
  if c == "S":
    nS += 1
  if c == "E":
    nE += 1
if (nN > 0 and nS == 0) or (nS > 0 and nN == 0) or (nW > 0 and nE == 0) or (nE > 0 and nW == 0):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
S=set(input());print("YNeos"[S!=set("NEWS")and S!={"N","S"}and S!={"E","W"}::2])

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()

if 'N' in S:
    if 'S' not in S:
        print('No')
        exit()
if 'S' in S:
    if 'N' not in S:
        print('No')
        exit()
if 'E' in S:
    if 'W' not in S:
        print('No')
        exit()
if 'W' in S:
    if 'E' not in S:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
s = input()
from collections import Counter
c = Counter(s)
flag = True
if c["S"]>0 and c["N"]==0:
  flag = False
if c["N"]>0 and c["S"]==0:
  flag = False
if c["W"]>0 and c["E"]==0:
  flag = False
if c["E"]>0 and c["W"]==0:
  flag = False
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = set(input())
ALL = set("NSWE") 
NS = set("NS")
EW = set("EW")
if s == ALL or s == NS or s == EW:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s=input();b=[x in s for x in['N','S','E','W']];print('Yes'if b[0]==b[1]and b[2]==b[3]else'No')

Submission status: Accepted

Solution code:
s = input()
a = ['N','S','E','W']
b = [x in s for x in a]

if b[0]==b[1] and b[2]==b[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = {st for st in input()}
if ({'S','N'} & s == {'S','N'} or {'S','N'} & s == set()) and ({'E','W'} & s == {'E','W'} or {'E','W'} & s == set()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

hor = ('W' in s and 'E' in s) or ('W' not in s and 'E' not in s)
ver = ('N' in s and 'S' in s) or ('N' not in s and 'S' not in s)

ans = hor and ver

if ans:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

if "N" in s:
  if "S" not in s:
    print("No")
    exit()
if "S" in s:
  if "N" not in s:
    print("No")
    exit()
if "W" in s:
  if "E" not in s:
    print("No")
    exit()
if "E" in s:
  if "W" not in s:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#AGC3 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
N,W,S,E = 0,0,0,0
for i in range(n):
    if s[i] == 'N':
        N = 1
    elif s[i] == 'W':
        W = 1
    elif s[i] == 'S':
        S = 1
    elif s[i] == 'E':
        E = 1
if N & S and W & E:
    print('Yes')
elif (N==0 and S==0) and W&E:
    print('Yes')
elif N&S and (W==0 and E==0):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
x=input()
n=0
w=0
s=0
e=0
for i in range(len(x)):
    if x[i]=="N":
        n+=1
    elif x[i]=="W":
        w+=1
    elif x[i]=="S":
        s+=1
    else:
        e+=1

f=1
if n:
    if s:
        pass
    else:
        f=0
if s:
    if n:
        pass
    else:
        f=0
if w:
    if e:
        pass
    else:
        f=0
if e:
    if w:
        pass
    else:
        f=0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

ok1 = (c['N'] == 0 and c['S'] == 0) or (c['N'] > 0 and c['S'] > 0)
ok2 = (c['E'] == 0 and c['W'] == 0) or (c['E'] > 0 and c['W'] > 0)
if ok1 and ok2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
s = input()
ans = "Yes"

if ("N" in s) ^ ("S" in s):
  print("No")
  exit()
else:
  ans = "Yes"

if ("W" in s) ^ ("E" in s):
  ans = "No"
else:
  ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    ss = str(input().rstrip('\n'))
    n = 1 if ss.count("N") != 0 else 0
    w = 1 if ss.count("W") != 0 else 0
    s = 1 if ss.count("S") != 0 else 0
    e = 1 if ss.count("E") != 0 else 0
    if n == s and w == e:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
def main():
    S = input()
    lc = list(set(list(S)))
    lc.sort()
    # print(lc)
    if lc == ["E", "N", "S", "W"] or lc == ["E", "W"] or lc == ["N", "S"]:
        return "Yes"
    return "No"

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
s = input()
flag = 1
if s.count('N'):
    if not s.count('S'):
        flag = 0
if s.count('S'):
    if not s.count('N'):
        flag = 0
if s.count('E'):
    if not s.count('W'):
        flag = 0
if s.count('W'):
    if not s.count('E'):
        flag = 0
print('Yes') if flag else print('No')

Submission status: Accepted

Solution code:
dire = [0,0,0,0]
d = {c:i for i,c in enumerate('WENS')}
for c in input():
	dire[d[c]] = 1
print('No' if (dire[0] ^ dire[1]) or (dire[2] ^ dire[3]) else 'Yes')

Submission status: Accepted

Solution code:
S = input()
if 'N' in S and 'S' not in S:
    print('No')
elif 'S' in S and 'N' 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:
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(s: str):
    N = s.count('N')
    S = s.count('S')
    E = s.count('E')
    W = s.count('W')
    if (N == 0 and S != 0) or (N != 0 and S == 0) or (E == 0 and W != 0) or (E != 0 and W == 0):
        print('No')
    else:
        print('Yes')
    return


# 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()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

S = input().strip()
n = S.count("N") > 0
w = S.count("W") > 0
e = S.count("E") > 0
s = S.count("S") > 0

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

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

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

Submission status: Accepted

Solution code:
s = input()

ns, ew = 0, 0
if "N" in s:
    ns += 1
if "S" in s:
    ns -= 1
if "E" in s:
    ew += 1
if "W" in s:
    ew -= 1

if ns == 0 and ew == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a=input();f=lambda x:x in a;print("YNeos"[f("N")^f("S")|f("W")^f("E")::2])

Submission status: Accepted

Solution code:
a=input();print("YNeos"[("N"in a)^("S"in a)|("W"in a)^("E"in a)::2])

Submission status: Accepted

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

if len(S) == 4:
    print ('Yes')
    exit()

if 'N' in S and 'S' in S and len(S) == 2:
    print ('Yes')
    exit()

if 'E' in S and 'W' in S and len(S) == 2:
    print ('Yes')
    exit()

print ('No')

Submission status: Accepted

Solution code:
# 2019/08/14

s=set(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()
ls =[False] * 4
for i in range(len(s)):
    if s[i] == "N":
        ls[0] = True
    elif s[i] == "W":
        ls[1] = True
    elif s[i] == "S":
        ls[2] = True
    elif s[i] == "E":
        ls[3] = True
print("Yes" if not(ls[0] ^ ls[2]) and not(ls[1] ^ ls[3]) else "No")

Submission status: Accepted

Solution code:
s=input()
l=len(s)
a=[0,0,0,0]
for i in range(l):
  if(s[i]=='N'):
    a[0]=1
  elif(s[i]=='W'):
    a[1]=1
  elif(s[i]=='S'):
    a[2]=1
  else:
    a[3]=1
if(a[0]*a[2]==0 and a[0]+a[2]!=0 or a[1]*a[3]==0 and a[1]+a[3]!=0):
  print("No")
else:
  print("Yes")

Submission status: Accepted

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

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 = list(input())
check = 0

if 'E' in S :
    if 'W' in S:
        pass
    else:
        check = 1

if 'W' in S :
    if 'E' in S:
        pass
    else:
        check = 1

if 'N' in S :
    if 'S' in S:
        pass
    else:
        check = 1

if 'S' in S :
    if 'N' in S:
        pass
    else:
        check = 1

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

Submission status: Accepted

Solution code:
s=list(input())
sets=list(set(s))
sets.sort()
l=sets
x=''.join(l)
if x=='ENSW' or x=='EW' or x=='NS':
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:


s = input()
d = {"N":0,"W":0,"S":0,"E":0}

for c in s:
    d[c] += 1
flag = True
if d["N"] > 0:
    if d["S"] <= 0:
        flag = False
if d["S"] > 0:
    if d["N"] <= 0:
        flag = False
if d["W"] > 0:
    if d["E"] <= 0:
        flag = False
if d["E"] > 0:
    if d["W"] <= 0:
        flag = False


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
l=list(s)
N=l.count("N")
W=l.count("W")
S=l.count("S")
E=l.count("E")

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

Submission status: Accepted

Solution code:

def main():
    s = list(input())
    s = list(set(s))
    
    if len(s)==4:
        print("Yes")
    elif len(s)==3:
        print("No")
    elif len(s)==2:
        if "N"in s and "S" in s:
            print("Yes")
        elif "E" in s and "W" in s:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def check(a,b,l):
    return(any([a in l and b not in l,b in l and a not in l]))

s=input()
if any([check("N","S",s),check("E","W",s)]):print("No")
else:print("Yes")

Submission status: Accepted

Solution code:
a = input()
b = [False] * 4
for i in range(len(a)):
    if a[i] == "N":
        b[0] = True
    elif a[i] == "E":
        b[1] = True
    elif a[i] == "S":
        b[2] = True
    elif a[i] == "W":
        b[3] = True
if b[0] == b[2] and b[1] == b[3]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# AGC003A - Wanna go back home
def main():
    S = input().rstrip()
    flg = (("N" in S) ^ ("S" in S) ^ 1) & (("E" in S) ^ ("W" in S) ^ 1)
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# AGC003A - Wanna go back home
from collections import Counter


def main():
    D = Counter(input().rstrip())
    flg = True
    if (
        (D["N"] != 0 and D["S"] == 0)
        or (D["N"] == 0 and D["S"] != 0)
        or (D["E"] != 0 and D["W"] == 0)
        or (D["E"] == 0 and D["W"] != 0)
    ):
        flg = False
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# AGC003A - Wanna go back home
def main():
    S = input().rstrip()
    D = {"N": 0, "S": 0, "E": 0, "W": 0}
    for i in S:
        D[i] += 1

    flg = [True] * 2
    if (D["N"] != 0 and D["S"] == 0) or (D["N"] == 0 and D["S"] != 0):
        flg[0] = False
    
    if (D["E"] != 0 and D["W"] == 0) or (D["E"] == 0 and D["W"] != 0):
        flg[1] = False

    print("Yes" if all(flg) else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    trip  = input()
    logging.info("Hello!")

    if (not (("S" in trip) ^  ("N" in trip))) and (not (("E" in trip) ^  ("W" in trip))):
        print("Yes")
    else:
        print("No")
        
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = str(input())
N = s.count("N")
S = s.count("S")
W = s.count("W")
E = s.count("E")

if (max(N,S)>0 and min(N,S) == 0) or (max(W,E)>0 and min(W,E)==0):
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = [False]*4
b = list(input())
for i in range(len(b)):
    if b[i] == "N":
        a[0] = True
    elif b[i] == "W":
        a[1] = True
    elif b[i] == "S":
        a[2] = True
    elif b[i] == "E":
        a[3] = True
print("Yes" if a[0] == a[2] and a[1] == a[3] else "No")

Submission status: Accepted

Solution code:
S = input()

no = False
so = False
ea = False
we = False
for s in S:
    if s == 'N':
        no = True
    elif s == 'S':
        so = True
    elif s == 'E':
        ea = True
    elif s == 'W':
        we = True

if ((no and so) or (not no and not so)) and ((ea and we) or (not ea and not we)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def check(d1, d2, direction):
    if d1 in direction and not d2 in direction:
        return False
    if d2 in direction and not d1 in direction:
        return False
    return True

S = input()
direction = {s for s in S}
for (x, y) in [("N", "S"), ("W", "E")]:
    if not check(x, y, direction):
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
S = list(input())
tmp = "NWSE"
n = False
w = False
s = False
e = False
for i in range(len(S)):
    if S[i] == "W":
        w = True
    elif S[i] == "N":
        n = True
    elif S[i] == "E":
        e = True
    else:
        s = True

if w and e:
    if n:
        if s:
            print("Yes")
        else:
            print("No")
    elif s:
        print("No")
    else:
        print("Yes")
elif w or e:
    print("No")
else:
    if n and s:
        print("Yes")
    elif n or 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()
ans_NS = 0
ans_EW = 0

if S.count('S') >= 1:
    ans_NS += 1
if S.count('N') >= 1:
    ans_NS += 1
if S.count('E') >= 1:
    ans_EW += 1
if S.count('W') >= 1:
    ans_EW += 1

if ans_EW != 1:
    if ans_NS != 1:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
dict = {
    "N": False,
    "E": False,
    "W": False,
    "S": False
}
for s in S:
    dict[s] = True

if dict["N"] != dict["S"] or dict["E"] != dict["W"]:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#AGC003
s = input()

dicti = {'N':0, 'S':0, 'W':0, 'E':0}
for letter in s:
    dicti[letter] += 1
if dicti['N'] > 0 and dicti['S'] > 0:
    if dicti['W'] > 0 and dicti['E'] > 0:
        print('Yes')
    elif dicti['W'] == 0 and dicti['E'] == 0:
        print('Yes')
    else:
        print('No')
elif dicti['W'] > 0 and dicti['E'] > 0:
    if dicti['N'] > 0 and dicti['S'] > 0:
        print('Yes')
    elif dicti['N'] == 0 and dicti['S'] == 0:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
ans=[0,0]
n=0
S=0
w=0
e=0
for i in range(len(s)):
    if s[i]=="N":
        n=1
    elif s[i]=="S":
        S=1
    elif s[i]=="W":
        w=1
    elif s[i]=="E":
        e=1
print("Yes" if n*S==1 and (w+e==2 or w+e==0) or w*e==1 and (n+S==2 or n+S==0) else "No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = set(input())

if len(S) == 4:
    print('Yes')
elif len(S) == 3 or len(S) == 1:
    print('No')
else:  # len(S)==2
    if S == {'N', 'S'} or S == {'E', 'W'}:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

S = input()

setS = set(S)

check1 = {'E', 'W'}
check2 = {'S', 'N'}

ansflag1 = True
ansflag2 = True
for eachd in setS:
  if len(check1):
    if eachd in check1:
      ansflag1 = not ansflag1
      check1.remove(eachd)
  if len(check2):
    if eachd in check2:
      ansflag2 = not ansflag2
      check2.remove(eachd)

if ansflag1 and ansflag2: print('Yes')
else: print('No')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

s = input()
cnt = 0
if 'N' in s and 'S' in s:
    cnt += 1
elif 'N' not in s and 'S' not in s:
    cnt += 1
if 'W' in s and 'E' in s:
    cnt += 1
elif 'W' not in s and 'E' not in s:
    cnt += 1
if cnt == 2:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


s = list(input())
s_cnt = Counter(s)
s_cnt_keys = list(s_cnt.keys())
if len(s_cnt.keys()) == 4:
    print('Yes')
    exit()
elif len(s_cnt.keys()) == 2:
    if s_cnt_keys[0] == 'S' and s_cnt_keys[1] == 'N':
        print('Yes')
        exit()
    elif s_cnt_keys[0] == 'N' and s_cnt_keys[1] == 'S':
        print('Yes')
        exit()
    elif s_cnt_keys[0] == 'E' and s_cnt_keys[1] == 'W':
        print('Yes')
        exit()
    elif s_cnt_keys[0] == 'W' and s_cnt_keys[1] == 'E':
        print('Yes')
        exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().rstrip()

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

if (N > 0 and S == 0) or (N == 0 and S > 0):
    print('No')
    exit()
if (W > 0 and  E== 0) or (W == 0 and E > 0):
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


s = IS()
if s.count('N') > 0 and s.count('S') == 0 or \
        s.count('N') == 0 and s.count('S') > 0 or \
        s.count('E') > 0 and s.count('W') == 0 or \
        s.count('E') == 0 and s.count('W') > 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
w=['N','W','S','E']
q=[]
for i in range(4):
    if s.count(w[i])>0:
        q.append(1)
    else:
        q.append(0)
if q[0]==q[2] and q[1]==q[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from fractions import gcd
import math
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    s = input()
    if ('N' in s) ^ ('S' in s):
        print('No')
        return
    if ('E' in s) ^ ('W' in s):
        print('No')
        return
    print('Yes')

main()

Submission status: Accepted

Solution code:
S = input()

direct = 'NWSE'
cnt = {}
ans = "Yes"

for ch in direct:
    cnt[ch] = S.count(ch)

if cnt['N'] == 0 and cnt['S'] != 0:
    ans = "No"
elif cnt['N'] != 0 and cnt['S'] == 0:
    ans = 'No'
elif cnt['E'] != 0 and cnt['W'] == 0:
    ans = 'No'
elif cnt['E'] == 0 and cnt['W'] != 0:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
import sys
S = set(input())
ls = ['N','W','S','E']
if ls[0] in S and not ls[2] in S:
    print('No')
    sys.exit()
if ls[1] in S and not ls[3] in S:
    print('No')
    sys.exit()
if ls[2] in S and not ls[0] in S:
    print('No')
    sys.exit()
if ls[3] in S and not ls[1] in S:
    print('No')
    sys.exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

if 'N' in S:
    if 'S' not in S:
        print('No')
        exit()

if 'S' in S:
    if 'N' not in S:
        print('No')
        exit()

if 'W' in S:
    if 'E' not in S:
        print('No')
        exit()

if 'E' in S:
    if 'W' not in S:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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