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

Submission attempts (in order):
s = input()
N = 0
S = 0
W = 0
E = 0
for i in range(len(s)) :
    str = s[i]
    if str == 'N' :
        N = 1
    elif str == 'S':
        S = 1
    elif str == 'W':
        W = 1
    elif str == 'E':
        E = 1
if (N-S)==0 and (W-E)==0 :
    print('YES')
else:
    print('NO')


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


Verdicts: Wrong Answer

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

Submission attempts (in order):
def solve():
    n, e = 0, 0
    for c in input():
        if c == "N":
            n += 1
        if c == "S":
            n -= 1
        if c == "E":
            e += 1
        if c == "W":
            e -= 1
        if n == 0 and e == 0:
            print("Yes")
    else:
        print("No")

if __name__=="__main__":
    solve()

def solve():
    n, e = 0, 0
    for c in input():
        if c == "N":
            n += 1
        if c == "S":
            n -= 1
        if c == "E":
            e += 1
        if c == "W":
            e -= 1

    if n == 0 and e == 0:
        print("YES")
    else:
        print("NO")

if __name__=="__main__":
    solve()

def solve():
    n, e = 0, 0
    for c in input():
        if c == "N":
            n += 1
        if c == "S":
            n -= 1
        if c == "E":
            e += 1
        if c == "W":
            e -= 1
        if n == 0 and e == 0:
            print("YES")
    else:
        print("NO")

if __name__=="__main__":
    solve()

from collections import Counter
c = Counter(input())
print("Yes" if ((c["N"] > 0 and c["S"] > 0) or c["N"] == c["S"]) \
     and ((c["E"] > 0 and c["W"] > 0) or c["E"] == c["W"]) else "No")

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

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


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

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

Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
s=input()
a =["N","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")

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


Verdicts: Runtime Error

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

Submission attempts (in order):
S = 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")	

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

Verdicts: Runtime Error

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

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

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





S = input()

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





Verdicts: Wrong Answer

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

Submission attempts (in order):
s = input()
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')


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


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

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


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


Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

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

Submission attempts (in order):
s = str(input())
if ("W" in s) == ("E" in s):
  if ("N" in s) == ("S" in s):
    print("YES")
    exit()
print("NO")

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
S=list(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)

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

Verdicts: Runtime Error

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

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
s = set(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")

s = set(list(input()))

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

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
s = input()
l = len(s)
judge = 0
if 'N' in s:
    judge += 1
if 'W' in s:
    judge += 1/1000
if 'S' in s:
    judge -= 1
if 'E' in s:
    judge -= 1/1000

print('Yes' if judge == 0 else 'No')

s = input()
l = len(s)
judge = 0
if 'N' in s:
    judge += 2
if 'W' in s:
    judge += 1/1000
if 'S' in s:
    judge -= 2
if 'E' in s:
    judge -= 1/1000

print('Yes' if judge == 0 else 'No')

s = input()
l = len(s)
judge = 0
if 'N' in s:
    judge += 1000
if 'W' in s:
    judge += 1
if 'S' in s:
    judge -= 1000
if 'E' in s:
    judge -= 1

print('Yes' if judge == 0 else 'No')

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
s=input();f=lambda c:c in s;print(['No','Yes'][f('N')^f('S') or f('E')^f('W')])

s=input();f=lambda c:c in s;print(['Yes','No'][f('N')^f('S') or f('E')^f('W')])

Verdicts: Wrong Answer

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

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

n = S.count('N')
s = S.count('S')
w = S.count('W')
e = S.count('E')
a = 0

if n > 0:
    a += 1
elif s > 0:
    a -= 1
elif w > 0:
    a += 2
elif e > 0:
    a -= 2

if a == 0:
    print("Yes")
else:
    print("No")


S = input()

n = S.count('N')
s = S.count('S')
w = S.count('W')
e = S.count('E')
a = 0

if n > 0:
    a += 1
if s > 0:
    a -= 1
if w > 0:
    a += 2
if e > 0:
    a -= 2

if a == 0:
    print("Yes")
else:
    print("No")


Verdicts: Wrong Answer

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

Submission attempts (in order):
k = str(input())


n = 0
w = 0
s = 0
e = 0
for i in range(len(k)):
    if k[i] == "N":
        n += 1
    elif k[i] == "W":
        w += 1
    elif k[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")

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

k = str(input())


n = 0
w = 0
s = 0
e = 0
for i in range(len(k)):
    if k[i] == "N":
        n += 1
    elif k[i] == "W":
        w += 1
    elif k[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("Yes")

Verdicts: Wrong Answer

Runtime Error

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

Submission attempts (in order):
# 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)

print(judge)

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


from collections import Counter
s = input()

C = Counter(s)
if all([C['N'], C['S']]) is any([C['N'], C['S']]) and all([C['W'], C['E']]) is any([C['W'], C['E']]):
    print('Yes')
else:
    print('No')


Verdicts: Wrong Answer

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

Submission attempts (in order):
s = input()
a = s.count("S") - s.count("N")
b = s.count("E") - s.count("W")
if (a == 0 && a == b):
 print ("Yes")
else:
 print ("No")


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

if (s == n):
 if (e>=1 & w >= 1):
  print ("Yes")
 else:
  print ("No")
elif (e == w):
 if (s >= 1 & n >= 1):
  print ("Yes")
 else:
  print ("No")
else:
 print ("No")

Verdicts: Runtime Error

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

Submission attempts (in order):
Plan=input()
N,W,S,E=Plan.count("N"),Plan.count("W"),Plan.count("S"),Plan.count("E")
if N+S==0 and W+E==0:
    print("Yes")
else:
    print("No")

Plan=input()
N,W,S,E=Plan.count("N"),Plan.count("W"),Plan.count("S"),Plan.count("E")
if (N==0 and S>=1) or (N>=1 and S==0) or (W==0 and E>=1) or (W>=1 and E==0):
    print("No")
else:
    print("Yes")

Verdicts: Wrong Answer

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

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

if S.count("N")==S.count("S") and S.count("E") == S.count("W"):
  print("YES")
else:
  print("NO")

S = input()

if ((S.count("N")>0 and S.count("S")==0) or (S.count("S")>0 and S.count("N")==0)) and ((S.count("E")>0 and S.count("W")==0) or (S.count("W")>0 and S.count("E")==0)):
  print("NO")
else:
  print("YES")


S = input()

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

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
t=str(input())
n=t.count('N')
s=t.count('S')
w=t.count('W')
e=t.count('E')

if n-s !=0 and n*s==0:
    print('NO')
    exit()
    
if w-e !=0 and w*e==0:
    print('NO')
    exit()

print('YES')

t=str(input())
n=t.count('N')
s=t.count('S')
w=t.count('W')
e=t.count('E')

if n-s !=0 and n*s==0:
    print('No')
    exit()
    
if w-e !=0 and w*e==0:
    print('No')
    exit()

print('Yes')


Verdicts: Wrong Answer

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

Submission attempts (in order):
from collections import Counter

s = Counter(input())
if s['N'] > 0 == s['S'] > 0 and s["W"] > 0 == s['E'] > 0:
    print("Yes")
else:
    print("No")


from collections import Counter

s = Counter(input())
if (s['N'] > 0) == (s['S'] > 0) and (s["W"] > 0) == (s['E'] > 0):
    print("Yes")
else:
    print("No")


Verdicts: Wrong Answer

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

Submission attempts (in order):
import collections
S=str(input())

List=list(set(S))
List.sort()

flag=0
if len(List)%2==0:
    if len(List)//2==1:
        if List[0]=="E" and List[1]=="W":
            flag=1
        elif List[0]=="N" and List[1]=="S":
            flag=1
    elif len(List)//2==2:
            flga=1
            
print("Yes" if flag==1 else "No")

import collections
S=str(input())

List=list(set(S))
List.sort()

flag=0
if len(List)%2==0:
    if len(List)//2==1:
        if List[0]=="E" and List[1]=="W":
            flag=1
        elif List[0]=="N" and List[1]=="S":
            flag=1
    elif len(List)//2==2:
            flag=1
            
print("Yes" if flag==1 else "No")

Verdicts: Wrong Answer

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

Submission attempts (in order):
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")

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

Verdicts: Runtime Error

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

Submission attempts (in order):
S=input()
n,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')

print(n)
print(w)
print(e)
print(s)

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



Verdicts: Wrong Answer

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

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

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

s = input()

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
def backhome(s):
	if (('N' in s) and ('S' in s)) and not (('W' in s) or ('E' in s)):
		return "Yes"
	elif (('W' in s) and ('E' in s)) and not (('N' in s) or ('S' in s)):
		return "Yes"
	elif (('W' in s) and ('E' in s)) and (('N' in s) and ('S' in s)):
		return "Yes"
	else:
		return "No"

def back_home():
    S=input()
    if('S'in S and 'N' in S and 'E'not in S and 'W'not in S):
        print('YES')
    elif('S'not in S and 'N' not 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()

def back_home():
    r=input()
    print(r)
    l = dict()
    for i in r:
        if i in l:
            l[i]=int(l[i])+1
        else:
            l[i]=1
    if (len(l)==1):
        return('NO')
    elif(len(l)==2):
        if (l['S']>0 and l['N']>0):
            return ("yes")
        elif(l['E']>0 and l['W']>0):
            return("yes")
        else:
            return("NO")
    elif(len(l)==3):
        return("NO")
    else:
        return("YES")
        
back_home()

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

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

Submission attempts (in order):
n, w, s, e = 0
for c in input():
	if c == "N":
		n += 1
	if c == "W":
		w += 1
	if c == "S":
		s += 1
	if c == "E":
		e += 1
b = ((n >= 1 and s >= 1) or (n==s==0)) and ((w >= 1 and e >= 1) or (w==e==0))
print("Yes" if b else "No")



n = w = s = e = 0
for c in input():
	if c == "N":
		n += 1
	if c == "W":
		w += 1
	if c == "S":
		s += 1
	if c == "E":
		e += 1
b = ((n >= 1 and s >= 1) or (n==s==0)) and ((w >= 1 and e >= 1) or (w==e==0))
print("Yes" if b else "No")



Verdicts: Runtime Error

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

Submission attempts (in order):
s = input()
print(set(s))
if 0 in [s.count("W"),s.count("E")] or 0 in [s.count("N"),s.count("S")]:
    print("No")
else:
    print("Yes")

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
import numpy as np

S = input()
NSEW = [S.count("N"), S.count("S"), S.count("E"), S.count("W")]

if np.prod(NSEW) > 0:
    print("Yes")
elif NSEW[0] + NSEW[1] > 0:
    if NSEW[0] == 0 or NSEW[1] == 0:
        print("No")
        exit()
elif NSEW[2] + NSEW[3] > 0:
    if NSEW[2] == 0 or NSEW[3] == 0:
        print("No")
        exit()
print("Yes")

import numpy as np

S = input()
NSEW = [S.count("N"), S.count("S"), S.count("E"), S.count("W")]

if np.prod(NSEW) > 0:
    print("Yes")
    exit()
elif NSEW[0] + NSEW[1] > 0 and NSEW[0] * NSEW[1] == 0:
    print("No")
    exit()
elif NSEW[2] + NSEW[3] > 0 and NSEW[2] * NSEW[3] == 0:
    print("No")
    exit()
print("Yes")

Verdicts: Wrong Answer

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

Submission attempts (in order):
s = input()
set_s = set(s)
ans = ''
if len(set_s) == 2:
    if 'S' in set_s and 'N' in set_s:
        ans = 'YES'
    elif 'E' in set_s and 'W' in set_s:
        ans = 'YES'
    else:
        ans = 'NO'
elif len(set_s) == 4:
    ans = 'YES'
else:
    ans = 'NO'
print(ans)


s = input()
set_s = set(s)
ans = ''
if s.count('N') == s.count('S') == s.count('E') == s.count('W'):
    ans = 'YES'
elif len(set_s) == 2 and s.count('E') == s.count('W'):
    ans = 'YES'
elif len(set_s) == 2 and s.count('N') == s.count('S'):
    ans = 'YES'
else:
    ans = 'NO'
print(ans)


s = input()
set_s = list(set(s))
ans = ''
if set_s.count('N') == set_s.count('S') == set_s.count('E') == set_s.count('W'):
    ans = 'YES'
elif len(set_s) == 2 and set_s.count('E') == set_s.count('W'):
    ans = 'YES'
elif len(set_s) == 2 and set_s.count('N') == set_s.count('S'):
    ans = 'YES'
else:
    ans = 'NO'
print(ans)


s = input()
list_s = list(set(s))
ans = ''
if len(set(s)) == 4:
    ans = 'Yes'
elif len(list_s) == 2 and list_s.count('E') == list_s.count('W'):
    ans = 'Yes'
elif len(list_s) == 2 and list_s.count('N') == list_s.count('S'):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
S=set(list(input()))
n=0
s=0
e=0
w=0
if 'N' in S:
  n=1
if 'S' in S:
  s=1
if 'E' in S:
  e=1
if 'W' in S:
  w=1

if (n^s)&(e^w):
  print('Yes')
else:
  print('No')

S=set(list(input()))
n=0
s=0
e=0
w=0
if 'N' in S:
  n=1
if 'S' in S:
  s=1
if 'E' in S:
  e=1
if 'W' in S:
  w=1

if (n^s)|(e^w):
  print('No')
else:
  print('Yes')

Verdicts: Wrong Answer

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

Submission attempts (in order):
S = input()
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')

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

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

Verdicts: Runtime Error

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

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

a = set(list(input()))
print("Yes" if ~("N" in a ^ "S" in a) and ~("W" in a ^ "E" in a) else "No")

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

Verdicts: Wrong Answer

Runtime Error

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

Submission attempts (in order):
s=set(list(input()))
print("Yes" if len(s)%2==0 and s in [[],["N","S"],["E","W"],["N","S","E","W"]] else "No")

print("Yes" if set(list(input())) in [['S', 'N'],['W', 'E'],['S', 'N', 'W', 'E']] else "No")

s=set(list(input()))
print("Yes" if len(s)%2==0 and (("N" in s and "S" in s) or ("E" in s and "W" in s))  else "No")

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
a = input()
v = 0
h = 0
if a.count('W') >=1:
  if a.count('E') ==0:
    print('NO')
    exit()
if a.count('E') >=1:
  if a.count('W') ==0:
    print('NO')
    exit()
if a.count('N')>= 1:
  if a.count('S') ==0:
    print('NO')
    exit()
if a.count('S')>= 1:
  if a.count('N')==0:
    print('NO')
    exit()
print('YES')

a = input()
v = 0
h = 0
if a.count('W') >=1:
  if a.count('E') ==0:
    print('NO')
    exit()
elif a.count('E') >=1:
  if a.count('W') ==0:
    print('NO')
    exit()
elif a.count('N')>= 1:
  if a.count('S') ==0:
    print('NO')
    exit()
elif a.count('S')>= 1:
  if a.count('N')==0:
    print('NO')
    exit()
print('YES')

a = input()
v = 0
h = 0
if a.count('W') >=1:
  if a.count('E') ==0:
    print('No')
    exit()
if a.count('E') >=1:
  if a.count('W') ==0:
    print('No')
    exit()
if a.count('N')>= 1:
  if a.count('S') ==0:
    print('No')
    exit()
if a.count('S')>= 1:
  if a.count('N')==0:
    print('No')
    exit()
print('Yes')


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
n=int(input())
a=[]
ans=0
for i in range(n):
    a.append(int(input()))
    ans+=a[-1]//2
    a[-1]//=2
    if(i>0 and a[-2]==1 and a[-1]==1):
        ans+=1
        a[-2]-=1
        a[-1]-=1

print(ans)


n=int(input())
a=[]
ans=0
for i in range(n):
    a.append(int(input()))
    if(i>0 and a[-2]==1 and a[-1]>0):
        ans+=1
        a[-2]-=1
        a[-1]-=1
    ans+=a[-1]//2
    a[-1]=a[-1]%2
    if(i>0 and a[-2]==1 and a[-1]==1):
        ans+=1
        a[-2]-=1
        a[-1]-=1

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
# keyence2019C - Exam and Wizard
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))
    dif = sorted(i - j for i, j in zip(A, B))
    ans, shortage = 0, 0
    for i in dif:
        if i < 0:
            ans += 1
            shortage += i
        else:
            break
    for i in dif[::-1]:
        if shortage >= 0:
            print(ans)
            return
        ans += 1
        shortage += i
    print(-1)


if __name__ == "__main__":
    main()


def main():
    # split in subsequences when 0 appears -> sum up cur // 2
    N, *A = map(int, open(0).read().split())
    A.append(0)
    ans, cur = 0, 0
    for i in A:
        if i:
            cur += i
        else:
            ans += cur // 2
            cur = 0
    print(ans)


if __name__ == "__main__":
    main()

Verdicts: Runtime Error

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
N,*A = map(int, open(0).read().split())
ans = 0
for i in range(N):
    if A[i] > 2:
        if A[i] % 2 == 0:
            ans += A[i] // 2 - 1
            A[i] = 2
        else:
            ans += A[i] // 2
            A[i] = 1
for i in range(1,N):
    if A[i] > 0:
        if A[i-1] > 0:
            temp = min(A[i],A[i-1])
            ans += temp
            A[i] -= temp
print(ans)

N,*A = map(int, open(0).read().split())
ans = 0
cum = 0
for i in range(N):
    if A[i] > 0:
        cum += A[i]
    else:
        ans += cum // 2
        cum = 0
print(ans+cum//2)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He has A_i cards with an integer i.  Two cards can form a pair if the absolute value of the difference of the integers written on them is at most 1.  Snuke wants to create the maximum number of pairs from his cards, on the condition that no card should be used in multiple pairs. Find the maximum number of pairs that he can create.

Submission attempts (in order):
n = int(input())


def f(lst):
  res = 0
  ex = 0
  for a in lst:
    ex += a
    res += ex//2
    ex %= 2
  return res

A = []
ans = 0
for _ in range(n):
  a = int(input())
  if a%2:
    a = 1
  else:
    a = min(a, 2)

  if a!= 0:
    A.append(a)
  elif A:
    ans += max(f(A), f(A[::-1]))
  else:
    continue
print(ans)

n = int(input())

def f(lst):
  res = 0
  ex = 0
  for a in lst:
    ex += a
    res += ex//2
    ex %= 2
  return res

A = []
ans = 0
for _ in range(n):
  a = int(input())
  if a%2:
    ans += a//2
    a = 1
  else:
    if a>2:
      ans += a//2-1
      a = 2

  if a!= 0:
    A.append(a)
  elif A:
    ans += max(f(A), f(A[::-1]))
    A = []
  else:
    continue
else:
  ans += max(f(A), f(A[::-1]))
print(ans)



Verdicts: Wrong Answer

Accepted