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:
s = raw_input()

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

Submission status: Accepted

Solution code:
directions=input()
sens=["N","S","W","E"]
compteur=[0]*4
for direction in directions:
    compteur[sens.index(direction)]+=1

if (compteur[0]>0 and compteur[1]==0) or (compteur[1]>0 and compteur[0]==0) or (compteur[2]>0 and compteur[3]==0) or (compteur[3]>0 and compteur[2]==0):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
y=raw_input()
f=0
if y.count('N')>0:
	if y.count('S')==0:
		f=1

if y.count('S')>0:
	if y.count('N')==0:
		f=1

if y.count('E')>0:
	if y.count('W')==0:
		f=1


if y.count('W')>0:
	if y.count('E')==0:
		f=1

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

Submission status: Accepted

Solution code:
s = raw_input()
up,down,left,right = False,False,False,False
for i in xrange(len(s)) :
    if s[i] == 'N' :
        up = True
    elif s[i] == 'S' :
        down = True
    elif s[i] == 'E' :
        left = True
    else :
        right = True
if (up!=down) or (left!=right) :
    print 'No'
else :
    print 'Yes'

Submission status: Accepted

Solution code:
s = raw_input()
count = {}
count['N'] = 0
count['W'] = 0
count['E'] = 0
count['S'] = 0
for c in s:
    count.setdefault(c,0)
    count[c] += 1

ok = True

if(count['N']==0 and count['S']!=0): ok = False
if(count['N']!=0 and count['S']==0): ok = False
if(count['W']==0 and count['E']!=0): ok = False
if(count['W']!=0 and count['E']==0): ok = False

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

s = raw_input()
N = S = W = E = 0
for si in s:
    if si == "N": N = 1
    if si == "S": S = 1
    if si == "W": W = 1
    if si == "E": E = 1
print "Yes" if N == S and W == E else "No"

Submission status: Accepted

Solution code:
S = input()
is_N = S.find("N") != -1
is_W = S.find("W") != -1
is_S = S.find("S") != -1
is_E = S.find("E") != -1
if is_N:
    if is_S:
        flg = True
    else:
        flg = False
else:
    if is_S:
        flg = False
    else:
        flg = True
if not flg:
    print("No")
    exit()


if is_W:
    if is_E:
        flg = True
    else:
        flg = False
else:
    if is_E:
        flg = False
    else:
        flg = True
if not flg:
    print("No")
    exit()


print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

S = s()
check = set(S)

success = True

if 'W' in check and 'E' not in check\
    or 'E' in check and 'W' not in check\
    or 'N' in check and 'S' not in check\
    or 'S' in check and 'N' not in check:
    success = False

if success:
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

Solution code:
S = raw_input()

ans = True

if "N" in S:
    ans = ("S" in S) and ans
    
if "S" in S:
    ans = ("N" in S) and ans
    
if "E" in S:
    ans = ("W" in S) and ans
    
if "W" in S:
    ans = ("E" in S) and ans
    
print "Yes" if ans else "No"

Submission status: Accepted

Solution code:
def solve():
    s = input()
    v = 0
    h = 0
    if 'N' in s:
        v -= 1
    if 'S' in s:
        v += 1
    if 'W' in s:
        h -= 1
    if 'E' in s:
        h += 1
    print('Yes' if v == 0 and h == 0 else 'No')


def main():
    solve()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**9

s = input()
f = [False] * 4
for c in s:
    if c == 'N':
        f[0] = True
    elif c == 'S':
        f[1] = True
    elif c == 'W':
        f[2] = True
    else:
        f[3] = True
if f[0] == f[1] and f[2] == f[3]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = raw_input()
if ((S.find("N")>=0 and S.find("S")>=0 or S.find("N")<0 and S.find("S")<0) and
    (S.find("E")>=0 and S.find("W")>=0 or S.find("E")<0 and S.find("W")<0)):
	print "Yes"
else:
	print "No"

Submission status: Accepted

Solution code:
home = True
s = raw_input().strip()
if 'N' in s and 'S' not in s:
    home = False
if 'S' in s and 'N' not in s:
    home = False
if 'W' in s and 'E' not in s:
    home = False
if 'E' in s and 'W' not in s:
    home = False
print('Yes' if home else 'No')

Submission status: Accepted

Solution code:
from collections import Counter

cnt = Counter(input())

print("No" if sum(x in cnt for x in "NS") == 1 or sum(x in cnt for x in "WE") == 1 else "Yes")

Submission status: Accepted

Solution code:
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

###########

s=slist()
ns=0
ew=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%2==0 and ew%2==0):
    print "Yes"
else:
    print "No"

Submission status: Accepted

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

Submission status: Runtime Error

Solution code:
# coding: utf-8

def main():
    S = input()
    dic = {'N':0, 'S':0, 'E':0, 'W':0}
    ans = 'No'

    for s in S:
        dic[s] += 1

    if (dic['N'] == 0 and dic['S'] == 0) or (dic['N'] > 0 and dic['S'] > 0):
        if (dic['E'] == 0 and dic['W'] == 0) or (dic['E'] > 0 and mp['W'] > 0):
            ans = 'Yes'

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
s = input()

ans1 = (("S" in s) and ("N" in s)) or (("S" not in s) & ("N" not in s))
ans2 = (("E" in s) and ("W" in s)) or (("E" not in s) & ("W" not in s)

print("Yes" if ans1 and ans2 else "No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = list(input())
n = s.count('N')
w = s.count('W')
s = s.count('S')
e = s.count('E')
if (n + s) % 2 == 0 and (w + e) % 2 == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()
we = [0,0]
ns = [0,0]

for i in range(len(s)):
    if s[i] == ('N'):
        ns[0] == 1
    elif s[i] == ('W'):
        we[0] == 1
    elif s[i] == ('S'):
        ns[1] == 1
    else
        we[1] == 1

if sum(we) % 2 == 0 and sum(ns) % 2 == 0:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
t=input()
d={}
n=0
s=0
w=0
e=0
for i in range(int(len(s))):
    if t[i] =="N":
        n=1
    if t[i] =="S":
        s=1
    if t[i] =="E":
        e=1
    if t[i] =="W":
        w=1
if (w+e)%2==0 and (n+s)%2==0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
#                          JAI SHREE RAM

import math; from collections import *
import sys; from functools import reduce

# sys.setrecursionlimit(10**6)
def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())
def get_string(): return list(input().strip().split())
def printxsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")

UGLYMOD = int(1e9)+7; SEXYMOD = 998244353; MAXN = int(1e5)

# sys.stdin=open("input.txt","r");sys.stdout=open("output.txt","w")

# for _testcases_ in range(int(input())):
s = input()
n = s = e = w = False
if 'N' in s: n = True
if 'S' in s: s = True
if 'E' in s: e = True
if 'W' in s: w = True
print("Yes" if not(n^s) and not(e^w) else "No")


'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS MINE @luctivud ( UDIT GUPTA )
Link may be copy-pasted here if it's taken from other source.
DO NOT PLAGIARISE.
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Submission status: Runtime Error

Solution code:
string = input()

c1 = True
c2 = True
c3 = True

if ("W" in string and not("E" in string) or "E" in string and not("W" in string): c1 = False
    
if ("N" in string and not("S" in string) or "S" in string and not("N" in string): c2 = False

if "N" in string and "S" in string and "E" in string and "W" in string:
    N = string.count("N")
    S = string.count("S")
    W = string.count("W")
    E = string.count("E")
    if not(N/S == W/E or N/S == E/W): c3 = False
    
if c1 and c2 and c3: print("Yes")
else: print("No")

Submission status: Runtime Error

Solution code:
s = input()
kita, minami = sorted([s.count('N'),s.count('S')])
nisi, higasi = sorted([s.count('W'),s.count('E')])
result = ['No','Yes']
r = 1
if kita==minami:
    continue
elif kita*minami > 0:
    continue
else:
    r *= 0
if nisi==higasi:
    continue
elif nisi*higasi > 0:
    continue
else:
    r = 0
print(result[r])

Submission status: Runtime Error

Solution code:
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

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

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

s = readChar()

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

for i in s:
	d[i]+=1

flg = 1
if !(d["N"]+d["S"]==0 or (d["N"]>0 and d["S"]>0)):
	flg = 0

if !(d["W"]+d["E"]==0 or (d["W"]>0 and d["E"]>0)):
	flg = 0

if flg==1:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
S = str(input())

if ((S.count("N") !=0 and S.count("S") !=0) or (S.count("N") ==0 and S.count("S") ==0)) and
   ((S.count("W") !=0 and S.count("E") !=0) or (S.count("W") ==0 and S.count("E") ==0)):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s = input()

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

print(ans)

Submission status: Runtime Error

Solution code:
S = input()
n = int('N' in S)
s = int('S' in S)
w = int('W' in W)
e = int('E' in E)

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

Submission status: Runtime Error

Solution code:
s=input()
import collections
c = collections.Counter(l)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if 'N' in s:
  if not 'S' in s:
    print("No")
    exit()
  elif s(len) == 2 or s(len)==4:
    print("Yes")
    exit()
    
if 'S' in s:
  if not 'N' in s:
    print("No")
    exit()
  elif s(len) == 2 or s(len)==4:
    print("Yes")
    exit()

if 'W' in s:
  if not 'E' in s:
    print("No")
    exit()
  elif s(len) == 2 or s(len)==4:
    print("Yes")
    exit()

if 'E' in s:
  if not 'W' in s:
    print("No")
    exit()
  elif s(len) == 2 or s(len)==4:
    print("Yes")
    exit()
print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
d = {}
for s in S:
  d[s] = True
  
if 'N' in d:
  if 'S' not in d:
    print 'No'
    exit()
    
if 'S' in d:
  if 'N' not in d:
    print 'No'
    exit()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S=input()

ans="NO"
n=0
w=0
e=0
s=0

for str in S:
  if str=="N":
    n +=1
  elif str=="E":
    e +=1
  elif str=="S":
    s +=1
  else:
    w +=1

if (n>0 and s>0) or (n==0 and s==0):
  tate=True
if (e>0 and w>0) or (e==0 and w==0):
  yoko=True
  
if tate and yoko:
  ans="Yes"
  
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main(s):
    _s = set(s)

    if len(_s) % 2 != 0:
        print('No')
        return

    if ('N' and 'S') in _s:
        print('Yes')
    elif ('W' and 'E') in _s:
        print('Yes')


if __name__ == '__main__':
    s = input()

    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}


#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

main(){
    string s;
    cin>>s;
    int cnt[N]={};
    for(auto c:s){
        cnt[c]=1;
    }
    puts(cnt['N']==cnt['S']&&cnt['W']==cnt['E'] ? "Yes":"No");
    
}

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
for i in range(n):
	x=int(input())
	a.append(x)
ans=0
for i in range(n-1):
	if a[i]>0:
		ans+=(a[i]//2)
		a[i]-=(a[i]//2)*2
	if a[i]>0:
		a[i+1]-=min(a[i],a[i+1])
		ans+=min(a[i],a[i+1])
if a[-1]>0:
	ans+=a[-1]//2
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
for i in range(n):
	x=int(input())
	a.append(x)
ans=0
for i in range(n-1):
	if a[i]>0:
		ans+=(a[i]//2)
		a[i]-=(a[i]//2)*2
	if a[i]>0:
		a[i+1]-=min(a[i],a[i+1])
		ans+=min(a[i],a[i+1])
if a[-1]>0:
	ans+=a[-1]//2
print(ans

Submission status: Runtime Error

Solution code:
=int(input())
a=[]
for i in range(n):
	x=int(input())
	a.append(x)
ans=0
for i in range(n-1):
	if a[i]>0:
		ans+=(a[i]//2)
		a[i]-=(a[i]//2)*2
	if a[i]>0:
		a[i+1]-=min(a[i],a[i+1])
		ans+=min(a[i],a[i+1])
if a[-1]>0:
	ans+=a[-1]//2
print(ans)

Submission status: Runtime Error

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: Runtime Error

Solution code:
dire = [0,0,0,0]
d = {c:i for i,c in numerate('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: Runtime Error

Solution code:
S = input()

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

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

Submission status: Runtime Error

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

n = int(input())
l = list(map(int, input().split()))
l.sort()
print(sum([l[i] for i in range(2*n) if i%2==0]))

Submission status: Runtime Error

Solution code:
n=int(input())
l=[int(input()) for i in range(n)]
ans=0
for i in range(n):
  ans+=(l[i]-l[i]%2)//2
  l[i]%=2
  if l[i]==1
    if i==n-1:break
    ans+=1
    l[i]=0;l[i+1]-=1
print(ans)

Submission status: Runtime Error

Solution code:
s = input()

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

Submission status: Runtime Error

Solution code:
s=input()
a =["N","S","W","E"]
flag1=0
flag2=0
if a[0] in s and a[1] in s:
  flag1=1
if a[0] not in s and a[1] not in s:
  flag1=1
if a[2] in s and a[3] in s:
  flag2=1
if a[2] not in s and a[3] not in s:
  flag2=1
if flag1+flag2=2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s=set(input())
ans='No'
if s in (set('SN'), set('EW'), set('NEWS')):
  ans='Yes'
peint(ans)

Submission status: Runtime Error

Solution code:
print(sum([1 for j in [int(input()) for i in range(int(input()))][::2] if j%2!=1]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
print "Yes" if set("SEWN").issubset(set(input())) else "No"

Submission status: Runtime Error

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


s = set(input())
if s in {{'N', 'S'}, {'W', 'E'}, {'N', 'W', 'S', 'N'}}:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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


s = set(input())
if s in {{'N', 'S'}, {'W', 'E'}, {'N', 'W', 'S', 'N'}}:
    print('yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:


def nibutan2(array,value,left,right,first = True):
    if first:
        if array[left]>value:
            return 0
        elif array[right]<value:
            return len(array)
    if right-left<=1:
        return right
    else:
        i=(left+right)//2
        if array[i]>value:
            return nibutan2(array,value,left,i,False)
        elif array[i]<value:
            return nibutan2(array,value,i,right,False)


N=int(input())
A=[]
B=[]
for i in range(N):
    if i%2==0:
        A.append(int(input()))
    else:
        B.append(int(input()))

A.sort()
B.sort()

count=0

for i in range(len(A)):
    c=nibutan2(B,A[i],0,len(B)-1)
    count+=abs(c-i)

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
print("Yes" if 'N' in s and 'S' in s and 'W' in s and'E' in s for s in [input()] else "No")

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s=set(input())
if len(s)%2==0:
  if s==set("SN") or s==set("WE"):
    print("Yes")
else:
    print("No")
else:
  print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
linp = list(map(int, input().split()))

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: Runtime Error

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: Runtime Error

Solution code:
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: Runtime Error

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: Runtime Error

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
("E" in s and "W" not in s) or
("W" in s and "E" not in s):
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

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
	("E" in s and "W" not in s) or
    ("W" in s and "E" not in s):
      print("No")
else:
  print("Yes")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
ar = list(input())
br = set(ar)
if br.count("N") == br.count("S") and br.count("W") == br.count("E"):
  print("Yes")
else:
  print("No")