ZhenlongDai/ACPR huggingface dataset:
Problem: p02416
Buggy submission (Python3, verdict: Wrong Answer):
x = 1
L=[]
n= 0
s=0
while x is not 0:
    x = int(input())
    L.append(x)
N=1
L.remove(0)
for i in L:
    while i >N:

        N=10*N
        n =i%N
        s+=(n/N*10)
        i-=n
    print (int(s))
    n=0

Failing test case input:
123
188
1011
0

Expected output:
6
17
3


Actual output:
5
6
7


Fixed submission (verdict: Accepted):
x = 1
L=[]
n= 0
s=0
while x is not 0:
    x = int(input())
    L.append(x)
N=1
L.remove(0)
for i in L:
    while i >=N:

        N=10*N
        n =i%N
        s+=(n/N*10)
        i-=n
    print (int(s))
    s=0
    N = 1

Problem: p02416
Buggy submission (Python3, verdict: Wrong Answer):
import sys
from functools import reduce
for line in sys.stdin:
    if line == "0":
        break
    s = reduce(lambda a,b: str(a)+str(b), line.strip())
    print(s)

Failing test case input:
123
139
1000
0

Expected output:
6
13
1


Actual output:
123
139
1000
0


Fixed submission (verdict: Accepted):
import sys
from functools import reduce
for line in sys.stdin:
    if int(line) == 0:
        break
    s = reduce(lambda a,b: int(a)+int(b), line.strip())
    print(s)

Problem: p02416
Buggy submission (Python3, verdict: Wrong Answer):
n = input()
while n != "0":
    ans = 0
    for i in range(len(n)):
        print(ord(n[i:i+1]))
        ans += ord(n[i:i+1]) - 48

    print(ans)
    n = input()

Failing test case input:
123
132
1100
0

Expected output:
6
6
2


Actual output:
49
50
51
6
49
51
50
6
49
49
48
48
2


Fixed submission (verdict: Accepted):
n = input()
while n != "0":
    ans = 0
    for i in range(len(n)):
        ans += ord(n[i:i+1]) - 48

    print(ans)
    n = input()
Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int, input().split())
x=set()
y=set()
for i in range(m):
    a,b=map(int, input().split())
    if a==1:x.add(b)
    if b==n:y.add(a)
if x&y:print('POSSIBLE')
else:print('IMPOSSILE')

Failing test case input:
000100 1
-1 99999

Expected output:
IMPOSSIBLE


Actual output:
IMPOSSILE


Fixed submission (verdict: Accepted):
n,m=map(int, input().split())
x=set()
y=set()
for i in range(m):
    a,b=map(int, input().split())
    if a==1:x.add(b)
    if b==n:y.add(a)
if x&y:print('POSSIBLE')
else:print('IMPOSSIBLE')

Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = input().split(" ")
n = int(x[0])
m = int(x[1])

probInit = set([])
probEnd  = set([])

for i in range(m):
    edge = input().split(" ")
    if edge[0] == 0:
        probInit.add(edge[1])

    if edge[1] == n - 1:
        probEnd.add(edge[0])

union = probEnd.union(probInit)
if (len(union) == 0):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


Failing test case input:
5 5
2 3
4 5
2 3
2 4
1 4

Expected output:
POSSIBLE


Actual output:
IMPOSSIBLE


Fixed submission (verdict: Accepted):
x = input().split(" ")
n = int(x[0])
m = int(x[1])

probInit = set([])
probEnd  = set([])

for i in range(m):
    edge = input().split(" ")
    if edge[0] == "1":
        probInit.add(edge[1])

    if edge[1] == str(n):
        probEnd.add(edge[0])

sec = probEnd.intersection(probInit)
if (len(sec) == 0):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
inf=float('inf')
a=[0]*(200001)


N = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(N[1])]

print(N,x)

for i in x:
    if i[0]==1 :
        if a[i[1]]==1:
            print('OK')
            quit()
        a[i[1]]=1
    if i[1]==N[0]:
        if a[i[0]]==1:
            print('OK')
            quit()
        a[i[0]]=1

print('NG')
quit()

Failing test case input:
110100 1
-1 25951

Expected output:
IMPOSSIBLE


Actual output:
[110100, 1] [[-1, 25951]]
NG


Fixed submission (verdict: Accepted):
a=[0]*(200001)


N = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(N[1])]


for i in x:
    if i[0]==1 :
        if a[i[1]]==1:
            print('POSSIBLE')
            quit()
        a[i[1]]=1
    if i[1]==N[0]:
        if a[i[0]]==1:
            print('POSSIBLE')
            quit()
        a[i[0]]=1

print('IMPOSSIBLE')
quit()
Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
ab = [[int(i) for i in input().split()] for _ in range(M)]

A = []
B = [0]*N
for a,b in ab:
  if a==1:
    A.append(a)
  if b==N:
    B[a]=1

for a in A:
  if B[a]==1:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

Failing test case input:
4 3
1 4
2 3
3 4

Expected output:
IMPOSSIBLE


Actual output:
POSSIBLE


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
ab = [[int(i) for i in input().split()] for _ in range(M)]

A = []
B = [0]*(N+1)
for a,b in ab:
  if a==1:
    A.append(b)
  if b==N:
    B[a]=1

for a in A:
  if B[a]==1:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in[0]*b]
d=[]
e=[]
for i in c:
  if i[0]==1:d+=[i[1]]
  elif i[1]==a:e+=[i[0]]
print((set(d)&set(e)=={})*'IM'+'POSSIBLE')

Failing test case input:
110000 1
-1 810

Expected output:
IMPOSSIBLE


Actual output:
POSSIBLE


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in[0]*b]
d=[]
e=[]
for i in c:
  if i[0]==1:d+=[i[1]]
  elif i[1]==a:e+=[i[0]]
print((set(d)&set(e)==set())*'IM'+'POSSIBLE')

Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = input().split(" ")
n = int(x[0])
m = int(x[1])

probInit = set([])
probEnd  = set([])

for i in range(m):
    edge = input().split(" ")
    if edge[0] == 0:
        probInit.add(edge[1])

    if edge[1] == n - 1:
        probEnd.add(edge[0])

sec = probEnd.intersection(probInit)
if (len(sec) == 0):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


Failing test case input:
5 5
2 3
4 5
2 3
2 5
1 4

Expected output:
POSSIBLE


Actual output:
IMPOSSIBLE


Fixed submission (verdict: Accepted):
x = input().split(" ")
n = int(x[0])
m = int(x[1])

probInit = set([])
probEnd  = set([])

for i in range(m):
    edge = input().split(" ")
    if edge[0] == "1":
        probInit.add(edge[1])

    if edge[1] == str(n):
        probEnd.add(edge[0])

sec = probEnd.intersection(probInit)
if (len(sec) == 0):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque
N,M=list(map(int,input().split()))
N_l=set()
one_l=set()
for i in range(M):
   A,B=list(map(int,input().split()))
   if A == 1:
      one_l.add(B)
   elif B==N:
      N_l.add(A)
if len(N_l & one_l) > 0:
   print("POSSIBLE")
else:
   print("IMPOSSIIBLE")


Failing test case input:
10 5
1 2
4 5
1 5
4 4
1 0

Expected output:
IMPOSSIBLE


Actual output:
IMPOSSIIBLE


Fixed submission (verdict: Accepted):
from collections import deque
N,M=list(map(int,input().split()))
N_l=set()
one_l=set()
for i in range(M):
   A,B=list(map(int,input().split()))
   if A == 1:
      one_l.add(B)
   elif B==N:
      N_l.add(A)
if len(N_l & one_l) > 0:
   print("POSSIBLE")
else:
   print("IMPOSSIBLE")
Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=[0]*(200001)


N = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(N[1])]

print(N,x)

for i in x:
    if i[0]==1 :
        if a[i[1]]==1:
            print('POSSIBLE')
            quit()
        a[i[1]]=1
    if i[1]==N[0]:
        if a[i[0]]==1:
            print('POSSIBLE')
            quit()
        a[i[0]]=1

print('IMPOSSIBLE')
quit()

Failing test case input:
110100 1
-1 25951

Expected output:
IMPOSSIBLE


Actual output:
[110100, 1] [[-1, 25951]]
IMPOSSIBLE


Fixed submission (verdict: Accepted):
a=[0]*(200001)


N = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(N[1])]


for i in x:
    if i[0]==1 :
        if a[i[1]]==1:
            print('POSSIBLE')
            quit()
        a[i[1]]=1
    if i[1]==N[0]:
        if a[i[0]]==1:
            print('POSSIBLE')
            quit()
        a[i[0]]=1

print('IMPOSSIBLE')
quit()

Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x = input().split(" ")
n = int(x[0])
m = int(x[1])

probInit = set([])
probEnd  = set([])

for i in range(m):
    edge = input().split(" ")
    if edge[0] == 0:
        probInit.add(edge[1])

    if edge[1] == n - 1:
        probEnd.add(edge[0])

union = probEnd.union(probInit)
if (union == set([])):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


Failing test case input:
5 5
1 1
4 5
1 3
2 4
1 4

Expected output:
POSSIBLE


Actual output:
IMPOSSIBLE


Fixed submission (verdict: Accepted):
x = input().split(" ")
n = int(x[0])
m = int(x[1])

probInit = set([])
probEnd  = set([])

for i in range(m):
    edge = input().split(" ")
    if edge[0] == "1":
        probInit.add(edge[1])

    if edge[1] == str(n):
        probEnd.add(edge[0])

sec = probEnd.intersection(probInit)
if (len(sec) == 0):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")

Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import sys
import math

N, M = list(map(int, sys.stdin.readline().rstrip().split()))


Ss = set()
Es = set()
for _ in range(M):
    a_orig, b_orig = list(map(int, sys.stdin.readline().rstrip().split()))
    for a, b in [(a_orig, b_orig), (b_orig, a_orig)]:
        if a== 1:
            Ss.add(b)
        if a == N:
            Es.add(b)

if len(Ss and Es):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
exit(0)


Failing test case input:
4 3
1 2
2 3
3 4

Expected output:
IMPOSSIBLE

Actual output:
POSSIBLE


Fixed submission (verdict: Accepted):


import sys
import math

N, M = list(map(int, sys.stdin.readline().rstrip().split()))


Ss = set()
Es = set()
for _ in range(M):
    a_orig, b_orig = list(map(int, sys.stdin.readline().rstrip().split()))
    for a, b in [(a_orig, b_orig), (b_orig, a_orig)]:
        if a== 1:
            Ss.add(b)
        if a == N:
            Es.add(b)

if len(Ss.intersection(Es)):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
exit(0)
Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict as dd
def main():
    N, M = map(int, input().split())

    D = dd(list)

    for m in range(M):
        a, b = map(int, input().split())
        D[a-1].append(b-1)

    for d in D.keys():
        if N-1 in D[d]:
            print('POSSIBLE')
            return

    print('IMPOSSIBLE')
        

if __name__ == "__main__":
    
    
    main()


Failing test case input:
5 3
2 3
4 5
2 3
2 0
0 4

Expected output:
IMPOSSIBLE


Actual output:
POSSIBLE


Fixed submission (verdict: Accepted):
from collections import defaultdict as dd
def main():
    N, M = map(int, input().split())

    D = dd(list)

    for m in range(M):
        a, b = map(int, input().split())
        D[a-1].append(b-1)

    for d in D[0]:
        if N-1 in D[d]:
            print('POSSIBLE')
            return

    print('IMPOSSIBLE')
        

if __name__ == "__main__":
    
    
    main()

Problem: p03647
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
ships = sorted([list(map(int,input().split())) for i in range(M)])

ans = "IMPOSSIBLE"

con = 0

for i in range(M):
  if ships[i][0] == 1:
    con += 1

for i in range(0,min(M,con + 1)):
  ship = ships[i][1]
  for j in range(con,M):
    if ships[j][0] == ship and ships[j][1] == N:
      ans = "POSSIBLE"
      break
  else:
    continue
      
print(ans)

Failing test case input:
4 3
1 2
2 3
3 4

Expected output:
IMPOSSIBLE

Actual output:
POSSIBLE


Fixed submission (verdict: Accepted):
def main():
  N,M = map(int,input().split())
  ships = [list(map(int,input().split())) for i in range(M)]
  start, goal = set(), set()
  for i in range(M):
    if ships[i][0] == 1:
      start.add(ships[i][1])
    if ships[i][1] == N:
      goal.add(ships[i][0])
  flg = start & goal
  print("POSSIBLE" if flg else "IMPOSSIBLE")
 
main()
Problem: p03227
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S=input()
if len(S)==2:
    print(S)
else:
    print(reversed(S))


Failing test case input:
`ad

Expected output:
da`


Actual output:
<reversed object at 0x7fb2dcc29210>


Fixed submission (verdict: Accepted):
S=input()
if len(S)==2:
    print(S)
else:
    print(S[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

if len(s) == 3:
    print(reversed(s))
else:
    print(s)

Failing test case input:
a]d

Expected output:
d]a


Actual output:
<reversed object at 0x7fdb02d81210>


Fixed submission (verdict: Accepted):
s = input()

if len(s) == 3:
    print(s[::-1])
else:
    print(s)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def tpbc_2018_a():
    import sys
    input = sys.stdin.readline

    s = input()
    if len(s) == 2:
        return s
    else:
        return s[::-1]


print(tpbc_2018_a())

Failing test case input:
fb

Expected output:
fb


Actual output:

bf


Fixed submission (verdict: Accepted):
def tpbc_2018_a():
    s = input()
    if len(s) == 2:
        return s
    else:
        return s[::-1]


print(tpbc_2018_a())

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input()
a=list(a)
n=len(a)
if(n==2):
 print(a)
else:
 print(a[2]+a[1]+a[0])


Failing test case input:
_f

Expected output:
_f


Actual output:
_, f

Fixed submission (verdict: Accepted):
a=input()
b=list(a)
n=len(b)
if(n==2):
 print(a)
else:
 print(a[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
if len(s) == 2:
    s = s[::-1]
print(s)

Failing test case input:
adb

Expected output:
bda


Actual output:
adb


Fixed submission (verdict: Accepted):
s = input()
if len(s) == 3:
    s = s[::-1]
print(s)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
if len(s) == 2:
  print(s)
else:
  print(reversed(s))

Failing test case input:
_]e

Expected output:
e]_


Actual output:
<reversed object at 0x7f54646b5210>


Fixed submission (verdict: Accepted):
s=input()
if len(s) == 2:
  print(s)
else:
  print(''.join(list(reversed(s))))

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input().split()

if len(S) == 2:
    print(S)
elif len(S) == 3:
    print(S[::-1])


Failing test case input:
_k

Expected output:
_k


Actual output:

Fixed submission (verdict: Accepted):
S = input()

if len(S) == 2:
    print(S)
elif len(S) == 3:
    print(S[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(input())
ans=''
if len(s)==2:
    print(','.join(s))
else:
    tmp=s[0]
    s[0]=s[2]
    s[2]=tmp
    print(','.join(s))

Failing test case input:
cf

Expected output:
cf


Actual output:
c,f


Fixed submission (verdict: Accepted):
s=list(input())
ans=''
if len(s)==2:
    print(''.join(s))
else:
    tmp=s[0]
    s[0]=s[2]
    s[2]=tmp
    print(''.join(s))
Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
if len(S) == 2:
    print(S)
else:
    print(reversed(S))

Failing test case input:
_]e

Expected output:
e]_


Actual output:
<reversed object at 0x7f752fab1210>


Fixed submission (verdict: Accepted):
S = input()
if len(S) == 2:
    print(S)
else:
    print(S[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

s = sys.stdin.read().lstrip()
if len(s) % 2 == 1:
    s = s[::-1]
print(s)


Failing test case input:
adb

Expected output:
bda


Actual output:
adb



Fixed submission (verdict: Accepted):
import sys

s = sys.stdin.read().rstrip()
if len(s) % 2 == 1:
    s = s[::-1]
print(s)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(str(input()))
if len(S) == 2:
  print(S[0],S[1])
else:
  print(S[2],S[1],S[0])

Failing test case input:
ja

Expected output:
ja


Actual output:
j a


Fixed submission (verdict: Accepted):
S = str(input())
if len(S) == 2:
  print(S)
else:
  print(S[2]+S[1]+S[0])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
n = len(s)
if (n == 3):
	for i in range(n):
		print(s[n-i-1],end = "")
		print()
print(s)

Failing test case input:
c]^

Expected output:
^]c


Actual output:
^
]
c
c]^


Fixed submission (verdict: Accepted):
s = input()
n = len(s)
if (n == 3):
	for i in range(n):
		print(s[n-i-1],end = "")
	print()
else:
	print(s)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


s = input().strip()
if len(s) == 2:
    print(s)
else:
    for c in s:
        print(c, end="")
    print()

Failing test case input:
a]^

Expected output:
^]a


Actual output:
a]^


Fixed submission (verdict: Accepted):

 
s = input().strip()
if len(s) == 2:
    print(s)
else:
    ans = s[::-1]
    print(ans)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
if len(S)==2:
    print(S)
else:
    print(reversed(S))


Failing test case input:
_`d

Expected output:
d`_


Actual output:
<reversed object at 0x7f4645711210>


Fixed submission (verdict: Accepted):
S = input()
if len(S)==2:
    print(S)
else:
    print(S[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
if len(S) == 2:
    print(S)
print(S[::-1])


Failing test case input:
_g

Expected output:
_g


Actual output:
_g
g_


Fixed submission (verdict: Accepted):
S = input()
if len(S) == 2:
    print(S)
    exit()
print(S[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
if len(a) == 2:
  print(a)
else:
  new_str = ''.join(list(reversed(a)))

Failing test case input:
``d

Expected output:
d``


Actual output:

Fixed submission (verdict: Accepted):
a = input()
if len(a) == 2:
  print(a)
else:
  new_str = ''.join(list(reversed(a)))
  print(new_str)
Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
if len(s)==2:
  print(s)
else:
  print(reversed(s))

Failing test case input:
a]^

Expected output:
^]a


Actual output:
<reversed object at 0x7f7ee733d210>


Fixed submission (verdict: Accepted):
s=input()
if len(s)==2:
  print(s)
else:
  s2=s[-1]+s[1]+s[0]
  print(s2)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
if len(s) <= 2:
  print(s)
else :
  for i in reversed(s):
    print(i)

Failing test case input:
a^]

Expected output:
]^a


Actual output:
]
^
a


Fixed submission (verdict: Accepted):
s = input()
if len(s) <= 2:
  print(s)
else :
  print(s[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

print(S if len(S) == 2 else S[-1])

Failing test case input:
c_]

Expected output:
]_c


Actual output:
]


Fixed submission (verdict: Accepted):
S = input()

print(S if len(S) == 2 else S[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
if len(s)==2:
  print(s)
else:
  print(reversed(s))  

Failing test case input:
d]a

Expected output:
a]d


Actual output:
<reversed object at 0x7f95d5819210>


Fixed submission (verdict: Accepted):
s=input()
if len(s)==2:
  print(s)
else:
  s2=s[-1]+s[1]+s[0]
  print(s2)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
print(s if len(s)==2 else reversed(s))

Failing test case input:
d`a

Expected output:
a`d


Actual output:
<reversed object at 0x7f5772af9210>


Fixed submission (verdict: Accepted):
s = input()
print(s if len(s)==2 else s[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



S = input()
if len(S) == 2:
    print(S)
else:
    list(S).reverse()
    print(''.join(S))


Failing test case input:
_]d

Expected output:
d]_


Actual output:
_]d



Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



S = li()
if len(S) == 2:
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input()
print(a if len(a)==2 else reversed(a))

Failing test case input:
`^d

Expected output:
d^`


Actual output:
<reversed object at 0x7f7623d0d210>


Fixed submission (verdict: Accepted):
a=input()
print(a if len(a)==2 else a[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
if len(S) == 2:
	print(type(S))
else:
	S = S[::-1]
	print(type(S))

Failing test case input:
a]^

Expected output:
^]a


Actual output:
<class 'str'>


Fixed submission (verdict: Accepted):
S = input()
if len(S) == 2:
	print(S)
else:
	S = S[::-1]
	print(S)
Problem: p03227
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    print(''.join(list(reversed(S))))


if __name__ == '__main__':
    main()


Failing test case input:
`h

Expected output:
`h


Actual output:
h`


Fixed submission (verdict: Accepted):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    if len(S)==2:
        print(S)
    else:
        print(''.join(list(reversed(S))))


if __name__ == '__main__':
    main()

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()

if len(S)==2:
    print(S)
else:
    print(list(reversed(S)))


Failing test case input:
c_]

Expected output:
]_c


Actual output:
], _, c

Fixed submission (verdict: Accepted):
S=input()

if len(S)==2:
    print(S)
else:
    print(''.join(list(reversed(S))))

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



 
import sys
import math



 

fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile


mod=1000000007
 

def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 

s=str(input())
if(len(s)==2):
    print(2)
else:
    print(s[::-1])
    
    

if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Failing test case input:
`e

Expected output:
`e


Actual output:
2


Fixed submission (verdict: Accepted):



 
import sys
import math



 

fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile


mod=1000000007
 

def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 

s=str(input())
if(len(s)==2):
    print(s)
else:
    print(s[::-1])
    
    

if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(input())

if len(a) == 2:
    print(a)
else:
    a.reverse()
    print(a)

Failing test case input:
d`b

Expected output:
b`d


Actual output:
b, `, d

Fixed submission (verdict: Accepted):
a = list(input())

if len(a) == 2:
    a = "".join(a)
    print(a)
else:
    a.reverse()
    a = "".join(a)
    print(a)

Problem: p03227
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s=input()
if len(s)==3:
  s=sorted(s)
print(s)

Failing test case input:
c_]

Expected output:
]_c


Actual output:
], _, c

Fixed submission (verdict: Accepted):
s=input()
if len(s)==3:
  s=s[2]+s[1]+s[0]
print(s)
Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
S_len = len(S)
S_list = list(S)
ans = ''

if S_len == 2:
    print(S)

elif S_len == 3:
    S_reverse = sorted(S, reverse=True)
    for i in range(S_len):
        ans += S_reverse[i]
    print(ans)

Failing test case input:
a]^

Expected output:
^]a


Actual output:
a^]


Fixed submission (verdict: Accepted):
S = input()
S_len = len(S)
S_list = list(S)
ans = ''

if S_len == 2:
    print(S)

elif S_len == 3:
    for i in range(S_len-1, -1, -1):
        ans += S_list[i]
    print(ans)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

if s.__len__() == 3:
    print(s[::-1])


Failing test case input:
_g

Expected output:
_g


Actual output:

Fixed submission (verdict: Accepted):
s = input()

if s.__len__() == 3:
    print(s[::-1])
else:
    print(s)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    x = list(input())
    x.reverse()
    print("".join(x))

if __name__ == "__main__":
    main()


Failing test case input:
al

Expected output:
al


Actual output:
la


Fixed submission (verdict: Accepted):
def main():
    x = list(input())
    if len(x) > 2:
        x.reverse()
    print("".join(x))

if __name__ == "__main__":
    main()

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
print(str(sorted(a,reverse=True)) if len(a) > 2 else a)

Failing test case input:
d__

Expected output:
__d


Actual output:
d, _, _

Fixed submission (verdict: Accepted):
a = input();print("".join(reversed(a)) if len(a) == 3 else a)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()[::-1]
if len(S) == 2:
    print(S)
print(S[::-1])

Failing test case input:
d`a

Expected output:
a`d


Actual output:
d`a


Fixed submission (verdict: Accepted):
S = input()
if len(S) == 2:
    print(S)
    exit()
print(S[::-1])

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=list(input())
if len(a) == 3:
  print(str(a[::-1]))
else:
  print(str(a))


Failing test case input:
cb`

Expected output:
`bc


Actual output:
`, b, c

Fixed submission (verdict: Accepted):
a=input()
if len(a) == 3:
    print(a[::-1])
else:
    print(str(a))

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
T = ''
if len(S) == 2:
    T = S[1] + S[0]
else:
    T = S[2] + S[1] + S[0]
print(T)

Failing test case input:
`g

Expected output:
`g


Actual output:
g`


Fixed submission (verdict: Accepted):
S = input()
T = ''
if len(S) == 2:
    T = S
else:
    T = S[2] + S[1] + S[0]
print(T)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

if ( s.__len__() == 3):
    print(s[::-1])

Failing test case input:
cb

Expected output:
cb


Actual output:

Fixed submission (verdict: Accepted):
s = input()

if s.__len__() == 3:
    print(s[::-1])
else:
    print(s)
Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(input())

if len(a) == 2:
    print(a)
else:
    a.reverse()
    a = "".join(a)
    print(a)

Failing test case input:
f_

Expected output:
f_


Actual output:
f, _

Fixed submission (verdict: Accepted):
a = list(input())

if len(a) == 2:
    a = "".join(a)
    print(a)
else:
    a.reverse()
    a = "".join(a)
    print(a)

Problem: p03227
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
print(str(sorted(a,reverse=True)) if len(a) == 3 else a)

Failing test case input:
b^^

Expected output:
^^b


Actual output:
b, ^, ^

Fixed submission (verdict: Accepted):
a = input();print("".join(reversed(a)) if len(a) == 3 else a)
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
a=[0]*N
b=[0]*N
c=[0]*N

for i in range(N):
  a[i],b[i],c[i]=map(int,input().split())
  a[i] += max(b[i-1],c[i-1])
  b[i] += max(a[i-1],c[i-1])
  c[i] += max(a[i-1],b[i-1])

print(max(a[-1],b[-1],c[-1]))

Failing test case input:
1
110 1 0

Expected output:
110


Actual output:
112


Fixed submission (verdict: Accepted):
N=int(input())
a=[0]*N
b=[0]*N
c=[0]*N
a[0],b[0],c[0]=map(int,input().split())
for i in range(1,N):
  a[i],b[i],c[i]=map(int,input().split())
  a[i] += max(b[i-1],c[i-1])
  b[i] += max(a[i-1],c[i-1])
  c[i] += max(a[i-1],b[i-1])

print(max(a[-1],b[-1],c[-1]))

Problem: p03162
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
abc = [list(map(int, input().split())) for i in range(n)]
dp = [-1] * n
m = max(abc[0])
dp[0] = m
x = abc[0].index(m)

for i in range(1,n):
    m = -1
    t = -1
    for j in range(3):
        if x == j:
            continue
        if m < abc[i][j]:
            m = abc[i][j]
            t = j
    x = t
    dp[i] = m + dp[i-1]
print(dp[-1])


Failing test case input:
7
9 1 66
-1 1 2
-1 2 0
2 4 1
0 12 1
0 1 22
2 1 -3

Expected output:
105


Actual output:
75


Fixed submission (verdict: Accepted):
n = int(input())
abc = [tuple(map(int,input().split())) for i in range(n)]

dp = [[0,0,0] for i in range(n+1)]


for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k],dp[i][j]+abc[i][k])

print(max(dp[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for i in range(3)] for j in range(N)]
dp[0] = a[0]

for i in range(N - 1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][k])

print(max(dp[N - 1]))

Failing test case input:
7
5 1 176
0 2 0
-2 2 0
2 8 2
-1 3 1
0 1 4
0 1 -5

Expected output:
190


Actual output:
193


Fixed submission (verdict: Accepted):
N = int(input())
a = [list(map(int, input().split())) for i in range(N)]

dp = [[0 for i in range(3)] for j in range(N + 1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k])

print(max(dp[N]))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

dp = [[0]*3 for _ in range(N)]
for i in range(3):
    dp[0][i] = A[0][i]


for i in range(1, N):
    for j in range(3):
        for k in range(3):
            if i != k: 
                dp[i][j] = max(dp[i-1][k] + A[i][j], dp[i][j])

print(max(dp[N-1]))

Failing test case input:
3
-2 75 0
0 10 6
14 -1 3

Expected output:
95


Actual output:
24


Fixed submission (verdict: Accepted):
N = int(input())

A = []
for i in range(N):
    A.append(list(map(int, input().split())))

dp = [[0]*3 for _ in range(N)]
for i in range(3):
    dp[0][i] = A[0][i]


for i in range(1, N):
    for j in range(3):
        for k in range(3):
            if j != k: 
                dp[i][k] = max(dp[i-1][j] + A[i][k], dp[i][k])

print(max(dp[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a,b,c = 0,0,0
for _ in range(n):
    x, y, z = map(int, input().split())
    a,b,c = max(y,z)+a,max(x,z)+b,max(x,y)+c

print(max(a,b,c))



Failing test case input:
3
0 94 34
20 50 80
30 35 90

Expected output:
209


Actual output:
264


Fixed submission (verdict: Accepted):
n = int(input())
a,b,c = 0,0,0
for _ in range(n):
    x, y, z = map(int, input().split())
    a,b,c = max(c,b)+x,max(a,c)+y,max(a,b)+z

print(max(a,b,c))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())

b = []
m = 0
for i in range(a):
	b.append(list(map(int,input().split())))

c = [[0,0,0] for i in range(a+1)]

for i in range(a):
	for j in range(3):
		for k in range(3):
			if j == k:
				continue
			else:
				c[i+1][k] = max(c[i+1][k],c[i][k] + b[i][j])

print(max(c[-1]))

Failing test case input:
3
-2 29 0
0 10 6
14 -1 1

Expected output:
49


Actual output:
53


Fixed submission (verdict: Accepted):
a = int(input())

b = []
m = 0
for i in range(a):
	b.append(list(map(int,input().split())))

c = [[0,0,0] for i in range(a+1)]

for i in range(a):
	for j in range(3):
		for k in range(3):
			if j == k:
				continue
			else:
				c[i+1][k] = max(c[i+1][k],c[i][j] + b[i][k])

print(max(c[-1]))

Problem: p03162
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())

nums=[]
for _ in range(N):
    nums.append(list(map(int, input().split())))

dp = [[0 for _ in range(3)] for _ in range(N)]


for i in range(N):
    a,b,c=nums[i]
    dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a)
    dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b)
    dp[i][2]=max(dp[i-1][0]+c,dp[i-1][1]+c)
print(max(dp[-1]))


Failing test case input:
1
001 4 0

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
N=int(input())

nums=[]
for _ in range(N):
    nums.append(list(map(int, input().split())))

dp = [[0 for _ in range(3)] for _ in range(N)]


for i in range(N):
    a,b,c=nums[i]
    dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a)
    dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b)
    dp[i][2]=max(dp[i-1][0]+c,dp[i-1][1]+c)
num = max(dp[-1])
if N==1:
    num = max(nums[0])
print(num)
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
S = []
for _ in range(n):
    A = list(map(int, input().split()))
    S.append(A)

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


for i in range(3):
    Dp[0].append(S[0][i])

for i in range(1, n):
    
    for j in range(3):
        
        New_Dp = []
        
        for k in range(3):
            if j==k:
                continue
            else:
                new_dp = Dp[i-1][j] + S[i][k]
                New_Dp.append(new_dp)
        dp = max(New_Dp)
        Dp[i].append(dp)

ans = max(Dp[-1])
print(ans)

Failing test case input:
3
-1 24 37
34 50 149
30 35 6

Expected output:
208


Actual output:
203


Fixed submission (verdict: Accepted):
n = int(input())
S = []
for _ in range(n):
    A = list(map(int, input().split()))
    S.append(A)

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


for i in range(3):
    Dp[0].append(S[0][i])

for i in range(1, n):
    
    for j in range(3):
        
        New_Dp = []
        
        for k in range(3):
            if j==k:
                continue
            else:
                new_dp = Dp[i-1][k] + S[i][j]
                New_Dp.append(new_dp)
        dp = max(New_Dp)
        Dp[i].append(dp)

ans = max(Dp[-1])
print(ans)

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
abcList = []
for i in range(n):
    abcList.append(list(map(int, input().split())))


dp = [abcList[0]]


for i in range(1, n):
    dp.append(
        [
            max(dp[-1][1] + abcList[i][1], dp[-1][2] + abcList[i][2]),
            max(dp[-1][0] + abcList[i][0], dp[-1][2] + abcList[i][2]),
            max(dp[-1][1] + abcList[i][1], dp[-1][0] + abcList[i][0]),
        ]
    )

print(max(dp[-1]))


Failing test case input:
7
9 1 66
-1 1 2
-1 2 0
2 4 1
0 12 1
0 1 22
2 1 -3

Expected output:
105


Actual output:
108


Fixed submission (verdict: Accepted):

n = int(input())
abcList = []
for i in range(n):
    abcList.append(list(map(int, input().split())))



dp = [abcList[0]]


for i in range(1, n):
    dp.append(
        [
            abcList[i][0] + max(dp[-1][1], dp[-1][2]),
            abcList[i][1] + max(dp[-1][2], dp[-1][0]),
            abcList[i][2] + max(dp[-1][0], dp[-1][1]),
        ]
    )

print(max(dp[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[]
for i in range(n):
  a_=list(map(int,input().split()))
  a.append(a_)
  
dp=[[0]*3 for i in range(n)]
dp[0]=a[0]
for i in range(1,n):
  for k in range(3):
    
    for j in range(3):
      
      if k!=j:
        dp[i][k]=max(dp[i][k], dp[i-1][j] + a[i-1][k])
print(dp)        
print(max(dp[n-1]))

Failing test case input:
3
-1 56 -2
-1 52 2
22 0 6

Expected output:
80


Actual output:
[[-1, 56, -2], [55, 55, 54], [54, 107, 57]]
107


Fixed submission (verdict: Accepted):
n=int(input())
a=[]
for i in range(n):
  a_=list(map(int,input().split()))
  a.append(a_)
  
dp=[[0]*3 for i in range(n)]
dp[0]=a[0]
for i in range(1,n):
  for k in range(3):
    
    for j in range(3):
      
      if k!=j:
        dp[i][k]=max(dp[i][k], dp[i-1][j] + a[i][k])

print(max(dp[n-1]))
Problem: p03162
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

N = int(input())
H = [0]*N
abc = list(map(int, input().split()))
H[0] = max(abc)
k = abc.index(H[0])
for i in range(1, N):
    abc = list(map(int, input().split()))
    
    H[i] = max(abc[k-1],abc[(k+1)%3])
    k = abc.index(H[i])
print(sum(H))

Failing test case input:
7
6 2 176
1 3 -3
0 0 0
6 9 4
-1 7 2
-4 1 7
0 1 -5

Expected output:
200


Actual output:
191


Fixed submission (verdict: Accepted):
N = int(input())
H = [[0,0,0] for i in range(N)]
H[0] = list(map(int, input().split()))
for i in range(1, N):
    abc = list(map(int, input().split()))
    for j in range(3):
        H[i][j] = max(H[i-1][j-1],H[i-1][(j+1)%3])+abc[j]

print(max(H[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N=int(input())
ha,hb,hc = map(int,input().split())
for i in range(1,N):
    a,b,c=map(int,input().split())
    ha = max(ha+b,ha+c)
    hb = max(hb+a,hb+c)
    hc = max(hc+b,hc+a)
print(max(max(ha,hb),hc))






Failing test case input:
3
1 40 34
20 50 80
30 35 90

Expected output:
174


Actual output:
210


Fixed submission (verdict: Accepted):

N=int(input())
ha,hb,hc = map(int,input().split())

for i in range(1,N):
    a,b,c=map(int,input().split())
    ha,hb,hc = max(a+hb,a+hc),max(b+ha,b+hc),max(c+hb,c+ha)



hap=max(max(ha,hb),hc)
print(hap)

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

n = int(input())
dp = [[0 for _ in range(3)] for _ in range(n+1)]
ls  = [[1,2],[0,2],[0,1]]
for i in range(1,n+1):
    day = list(map(int,input().split()))
    dp[i][0] = day[0] + max(dp[i-1][1],dp[i][2])
    dp[i][1] = day[1] + max(dp[i-1][0],dp[i][2])
    dp[i][2] = day[2] + max(dp[i-1][0],dp[i][1])
print(max(dp[n]))


Failing test case input:
3
-1 24 37
34 50 80
30 35 6

Expected output:
139


Actual output:
99


Fixed submission (verdict: Accepted):
n = int(input())
dp = [[0 for _ in range(3)] for _ in range(n+1)]
ls  = [[1,2],[0,2],[0,1]]
for i in range(1,n+1):
    day = list(map(int,input().split()))
    dp[i][0] = day[0] + max(dp[i-1][1],dp[i-1][2])
    dp[i][1] = day[1] + max(dp[i-1][0],dp[i-1][2])
    dp[i][2] = day[2] + max(dp[i-1][0],dp[i-1][1])
print(max(dp[n]))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = 3
A=[[10, 40, 70], [20, 50, 80], [30, 60, 90]]
dp = [[0] * 3 for _ in range(N)]  
dp[0] = A[0]  
print(dp[0])
for i in range(N-1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k])
            
print(max(dp[N-1]))
print((dp[N-1]))
print(max(dp[N-2]))
print((dp[N-2]))
print(max(dp[N-3]))
print((dp[N-3]))

Failing test case input:
3
0 56 0
-1 19 5
22 1 6

Expected output:
83


Actual output:
[10, 40, 70]
190
[130, 160, 190]
110
[80, 110, 110]
70
[10, 40, 70]


Fixed submission (verdict: Accepted):
N = int(input())
Y = []
for _ in range(N):
    Y.append(list(map(int, input().split())))  
dp = [[0] * 3 for _ in range(N)]  
dp[0] = Y[0]  


for i in range(N-1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][j] = max(dp[i+1][j], dp[i][k] + Y[i+1][j])
print(max(dp[N-1]))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
ABC = []
for _ in range(N):
    ABC.append(list(map(int, input().split())))

table = [[0]*3 for i in range(N)]


for i in range(0, N):
    if i == 0:
        table[i] = ABC[i]
    else:
        for j in range(3): 
            table[i][j] = max(
                [table[i-1][j1] + ABC[i][j1] for j1 in range(3) if  j1 != j]
                 )
        
        
print(max(table[-1]))

Failing test case input:
7
3 7 19
11 8 0
4 5 3
15 14 6
4 8 1
3 3 7
2 3 -1

Expected output:
68


Actual output:
57


Fixed submission (verdict: Accepted):
N = int(input())
ABC = []
for _ in range(N):
    ABC.append(list(map(int, input().split())))

table = [[0]*3 for i in range(N)]


for i in range(0, N):
    if i == 0:
        table[i] = ABC[i]
    else:
        for j in range(3): 
            table[i][j] = max(
                [table[i-1][j1] + ABC[i][j] for j1 in range(3) if not j1 == j ]
                 )

        
print(max(table[-1]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[0]*3
for i in range(n):
    dp[0],dp[1],dp[2]=max(dp[1],dp[2])+l[i][0],max(dp[0],dp[2])+l[i][1],max(dp[0],dp[1])+l[i][2]
    print(dp)
print(max(dp))

Failing test case input:
1
001 0 -1

Expected output:
1


Actual output:
[1, 0, -1]
1


Fixed submission (verdict: Accepted):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[0]*3
for i in range(n):
    dp[0],dp[1],dp[2]=max(dp[1],dp[2])+l[i][0],max(dp[0],dp[2])+l[i][1],max(dp[0],dp[1])+l[i][2]
    
print(max(dp))
Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

hap = [[0] for i in range(n)]
for i in range(n):
  hap[i] = [int(i) for i in input().split()]
  
dp = [[0]*3 for i in range(n)]
for i in range(3):
  dp[0][i] = hap[0][i]
  
for i in range(1, n):
  for j in range(3):
    dp[i][j] = max(dp[i-1][j]+hap[i][(j+1)%3], dp[i-1][j]+hap[i][(j+2)%3])
print(max(dp[n-1]))
     



Failing test case input:
3
-1 35 53
34 50 149
30 35 5

Expected output:
219


Actual output:
214


Fixed submission (verdict: Accepted):
n = int(input())

hap = [[0] for i in range(n)]
for i in range(n):
  hap[i] = [int(i) for i in input().split()]
  
dp = [[0]*3 for i in range(n)]
for i in range(3):
  dp[0][i] = hap[0][i]
  
for i in range(1, n):
  for j in range(3):
    dp[i][j] = max(dp[i-1][(j+1)%3]+hap[i][j], dp[i-1][(j+2)%3]+hap[i][j])
print(max(dp[n-1]))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
abcs = [None for _ in range(n)]

dp = [[0, 0, 0] for ___ in range(n)]

for i in range(n):
    abcs[i] = list(map(int, input().split()))
for i in range(n):
    for k in range(3):  
        for j in range(3):  
            if k != j:
                dp[i][k] = max(dp[i][k], dp[i - 1][j] + abcs[i][k])
print(max(dp[i]))













Failing test case input:
1
001 6 0

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
n = int(input())
abcs = [None for _ in range(n)]


for i in range(n):
    abcs[i] = list(map(int, input().split()))

dp = [abcs[0]] + [[0, 0, 0] for _ in range(n - 1)]
for i in range(1, n):
    for k in range(3):  
        for j in range(3):  
            if k != j:
                dp[i][k] = max(dp[i][k], dp[i - 1][j] + abcs[i][k])
print(max(dp[i]))

Problem: p03162
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline  

N = int(input())
a,b,c = map(int,input().split())
dp = [[a,b,c]]
for i in range(N-1):
    a,b,c = map(int,input().split())
    A = max(dp[i][1]+a,dp[i][2]+a)
    B = max(dp[i][2]+b,dp[i][0]+b)
    C = max(dp[i][0]+c,dp[i][1]+c)
    dp.append([A,B,C])
print(dp)
print(max(dp[-1]))


Failing test case input:
7
3 7 14
11 8 3
1 5 2
12 13 6
4 6 1
3 3 8
4 3 -1

Expected output:
60


Actual output:
[[3, 7, 14], [25, 22, 10], [23, 30, 27], [42, 40, 36], [44, 48, 43], [51, 47, 56], [60, 59, 50]]
60


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline  

N = int(input())
a,b,c = map(int,input().split())
dp = [[a,b,c]]
for i in range(N-1):
    a,b,c = map(int,input().split())
    A = max(dp[i][1]+a,dp[i][2]+a)
    B = max(dp[i][2]+b,dp[i][0]+b)
    C = max(dp[i][0]+c,dp[i][1]+c)
    dp.append([A,B,C])
print(max(dp[-1]))
Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import itertools
n = int(input())
lst = []

for _ in range(n):
  l = list(map(int, input().split()))
  lst.append(l)
  
hp = [[0] * 3 for _ in range(n)]

plst = list(itertools.permutations([_ for _ in range(3)], 2))

for _ in range(0, n):
    for i in plst:
      hp[_][i[1]] = max(hp[_-1][i[0]] + lst[_][i[1]],hp[_][i[1]])

print(max(hp[n-1]))

Failing test case input:
1
001 3 0

Expected output:
3


Actual output:
6


Fixed submission (verdict: Accepted):
import itertools
n = int(input())
lst = [[0,0,0]]

for _ in range(n):
  l = list(map(int, input().split()))
  lst.append(l)
  
hp = [[0] * 3 for _ in range(n+1)]

plst = list(itertools.permutations([_ for _ in range(3)], 2))

for _ in range(0, n):
    for i in plst:
      hp[_+1][i[1]] = max(hp[_][i[0]] + lst[_+1][i[1]], hp[_+1][i[1]])

print(max(hp[n]))

Problem: p03162
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
import heapq

input = sys.stdin.readline
N = int(input())

dp = [[0,0,0] for _ in range(N)]
for i in range(N):
  a, b, c = map(int, input().split())
  if i == 0:
    dp[i] = [c, b, a]
  else:
    dp[i][0] = max(dp[i-1][0]+b, dp[i-1][0]+c)
    dp[i][1] = max(dp[i-1][1]+a, dp[i-1][1]+c)
    dp[i][2] = max(dp[i-1][2]+a, dp[i-1][2]+b)
print(max(dp[-1]))

Failing test case input:
7
5 1 176
0 2 0
-2 2 0
2 8 2
-1 4 1
0 1 10
0 1 -4

Expected output:
196


Actual output:
203


Fixed submission (verdict: Accepted):
import sys
import heapq

input = sys.stdin.readline
N = int(input())

dp = [[0,0,0] for _ in range(N)]
for i in range(N):
  a, b, c = map(int, input().split())
  if i == 0:
    dp[i] = [a, b, c]
  else:
    dp[i][0] = max(dp[i-1][1]+a, dp[i-1][2]+a)
    dp[i][1] = max(dp[i-1][0]+b, dp[i-1][2]+b)
    dp[i][2] = max(dp[i-1][0]+c, dp[i-1][1]+c)
print(max(dp[-1]))