ZhenlongDai/ACPR huggingface dataset:
Problem: p03734
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, W = map(int, input().split())
dp = [[[0] * 301 for _ in range(n + 1)] for _ in range(n + 1)]
li = [list(map(int, input().split())) for _ in range(n)]
p = li[0][0]
for i, x in enumerate(li):
    w, v = x
    w -= p
    for j in range(i + 1):
        for k in range(301):
            if k >= w:
                if dp[i][j][k - w] + v > dp[i][j][k]:
                    dp[i + 1][j + 1][k] = dp[i][j][k - w] + v
                else:
                    dp[i + 1][j + 1][k] = dp[i][j + 1][k]
            else:
                dp[i + 1][j + 1][k] = dp[i][j + 1][k]
ans = 0
for i in range(n + 1):
    for k in range(301):
        if i * p + k <= W:
            ans = max(dp[n][i][k], ans)
print(ans)


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

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
n, W = map(int, input().split())
dp = [[[0] * 301 for _ in range(n + 1)] for _ in range(n + 1)]
li = [list(map(int, input().split())) for _ in range(n)]
p = li[0][0]
for i, x in enumerate(li):
    w, v = x
    w -= p
    for j in range(i + 1):
        for k in range(301):
            if k >= w:
                if dp[i][j][k - w] + v > dp[i][j + 1][k]:
                    dp[i + 1][j + 1][k] = dp[i][j][k - w] + v
                else:
                    dp[i + 1][j + 1][k] = dp[i][j + 1][k]
            else:
                dp[i + 1][j + 1][k] = dp[i][j + 1][k]
ans = 0
for i in range(n + 1):
    for k in range(301):
        if i * p + k <= W:
            ans = max(dp[n][i][k], ans)
print(ans)
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, W = list(map(int, input().split()))

values = [[] for i in range(4)]

w0, v0 = list(map(int, input().split()))
values[0].append(v0)

for i in range(N-1):
    w, v = list(map(int, input().split()))
    values[w-w0].append(v)

for i in range(4):
    values[i].sort()
    for j in range(len(values[i])-1):
        values[i][j+1] = values[i][j] + values[i][j+1]
    values[i].append(0)

res = 0

for i1 in range(len(values[0])+1):
    for i2 in range(len(values[1])+1):
        for i3 in range(len(values[2])+1):
            for i4 in range(len(values[3])+1):
                if(w0*i1 + (w0+1)*i2 + (w0+2)*i3 + (w0+3)*i4 <= W):
                    res = max(res, values[0][i1-1] + values[1][i2-1] + values[2][i3-1] + values[3][i4-1])

print(res)

Failing test case input:
4 6
2 1
3 0
2 9
3 16

Expected output:
25


Actual output:
16


Fixed submission (verdict: Accepted):
N, W = list(map(int, input().split()))

values = [[] for i in range(4)]

w0, v0 = list(map(int, input().split()))
values[0].append(v0)

for i in range(N-1):
    w, v = list(map(int, input().split()))
    values[w-w0].append(v)

for i in range(4):
    values[i].sort(reverse=True)
    for j in range(len(values[i])-1):
        values[i][j+1] = values[i][j] + values[i][j+1]
    values[i].append(0)

res = 0

for i1 in range(len(values[0])+1):
    for i2 in range(len(values[1])+1):
        for i3 in range(len(values[2])+1):
            for i4 in range(len(values[3])+1):
                if(w0*i1 + (w0+1)*i2 + (w0+2)*i3 + (w0+3)*i4 <= W):
                    res = max(res, values[0][i1-1] + values[1][i2-1] + values[2][i3-1] + values[3][i4-1])

print(res)

Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
N,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(N)]
w1=wv[0][0]

Wlist=[0]+[j*(w1+i) for j in range(1,N+1) for i in range(3*j+1)]
Wlist=sorted(set(Wlist))
LW=len(Wlist)
dp=[[0]*LW for _ in range(N+1)]


for i in range(1,N+1):
  w,v=wv[i-1]
  for j in range(LW):
    if w<=Wlist[j]:      
      ind=bisect.bisect_right(Wlist,Wlist[j]-w)-1
      dp[i][j]=max(dp[i-1][j],dp[i-1][ind]+v)
    else:
      dp[i][j]=dp[i-1][j]

ind=bisect.bisect_right(Wlist,W)-1
print(dp[N][ind])

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

Expected output:
18


Actual output:
15


Fixed submission (verdict: Accepted):
import bisect
N,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(N)]
w1=wv[0][0]

Wlist=[0]+[j*w1+i for j in range(1,N+1) for i in range(3*j+1)]
Wlist=sorted(set(Wlist))
LW=len(Wlist)
dp=[[0]*LW for _ in range(N+1)]


for i in range(1,N+1):
  w,v=wv[i-1]
  for j in range(LW):
    if w<=Wlist[j]:      
      ind=bisect.bisect_right(Wlist,Wlist[j]-w)-1
      dp[i][j]=max(dp[i-1][j],dp[i-1][ind]+v)
    else:
      dp[i][j]=dp[i-1][j]

ind=bisect.bisect_right(Wlist,W)-1
print(dp[N][ind])
Problem: p03734
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from itertools import accumulate
import heapq

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
first_item = list(map(int, input().split()))
basew = first_item[0]
w0 = []
w1 = []
w2 = []
w3 = []
heapq.heappush(w0, first_item[1])
for _ in range(N-1):
    w, v = map(int, input().split())
    w -= basew
    if w == 0:
        heapq.heappush(w0, v)
    elif w == 1:
        heapq.heappush(w1, v)
    elif w == 2:
        heapq.heappush(w2, v)
    elif w == 3:
        heapq.heappush(w3, v)

w0_acc = [0]+list(accumulate(reversed(w0)))
w1_acc = [0]+list(accumulate(reversed(w1)))
w2_acc = [0]+list(accumulate(reversed(w2)))
w3_acc = [0]+list(accumulate(reversed(w3)))
v = 0
for i0 in range(len(w0)):
    for i1 in range(len(w1)):
        for i2 in range(len(w2)):
            for i3 in range(len(w3)):
                if basew*(i0+i1+i2+i3)+3*i3 + 2*i2 + i1 > W:
                    break
                else:
                    v = max(v, w0_acc[i0]+w1_acc[i1]+w2_acc[i2]+w3_acc[i3])
print(v)


Failing test case input:
4 3
2 1
3 7
4 10
3 6

Expected output:
7


Actual output:
0


Fixed submission (verdict: Accepted):
from itertools import accumulate
import heapq

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
first_item = list(map(int, input().split()))
basew = first_item[0]
w0 = []
w1 = []
w2 = []
w3 = []
w0.append(first_item[1])
for _ in range(N-1):
    w, v = map(int, input().split())
    w -= basew
    if w == 0:
        w0.append(v)
    elif w == 1:
        w1.append(v)
    elif w == 2:
        w2.append(v)
    elif w == 3:
        w3.append(v)

w0_acc = [0]+list(accumulate(sorted(w0, reverse=True)))
w1_acc = [0]+list(accumulate(sorted(w1, reverse=True)))
w2_acc = [0]+list(accumulate(sorted(w2, reverse=True)))
w3_acc = [0]+list(accumulate(sorted(w3, reverse=True)))
v = 0
for i0 in range(len(w0)+1):
    for i1 in range(len(w1)+1):
        for i2 in range(len(w2)+1):
            for i3 in range(len(w3)+1):
                if basew*(i0+i1+i2+i3)+3*i3 + 2*i2 + i1 > W:
                    break
                else:
                    v = max(v, w0_acc[i0]+w1_acc[i1]+w2_acc[i2]+w3_acc[i3])
print(v)
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,W = map(int,input().split())
dic = {"0":[],"1":[],"2":[],"3":[]}
for i in range(N):
  w,v = map(int,input().split())
  if i == 0:
    Min = w
  if w == Min:
    dic["0"].append(v)
  elif w == Min+1:
    dic["1"].append(v)
  elif w == Min+2:
    dic["2"].append(v)
  elif w == Min+3:
    dic["3"].append(v)
    
dic["0"].sort()
dic["1"].sort()
dic["2"].sort()
dic["3"].sort()

ans = 0
for i in range(len(dic["0"])+1):
  for j in range(len(dic["1"])+1):
    for k in range(len(dic["2"])+1):
      for l in range(len(dic["3"])+1): 
        a = int(sum(dic["0"][:i])+sum(dic["1"][:j])+sum(dic["2"][:k])+sum(dic["3"][:l])) 
        b = int(i*Min+j*(Min+1)+k*(Min+2)+l*(Min+3))
        if a > ans and b <= W:
          ans = a
print(int(ans))

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

Expected output:
16


Actual output:
9


Fixed submission (verdict: Accepted):
N,W = map(int,input().split())
dic = {"0":[],"1":[],"2":[],"3":[]}
for i in range(N):
  w,v = map(int,input().split())
  if i == 0:
    Min = w
  if w == Min:
    dic["0"].append(v)
  elif w == Min+1:
    dic["1"].append(v)
  elif w == Min+2:
    dic["2"].append(v)
  elif w == Min+3:
    dic["3"].append(v)
    
dic["0"].sort(reverse=True)
dic["1"].sort(reverse=True)
dic["2"].sort(reverse=True)
dic["3"].sort(reverse=True)

ans = 0
for i in range(len(dic["0"])+1):
  for j in range(len(dic["1"])+1):
    for k in range(len(dic["2"])+1):
      for l in range(len(dic["3"])+1): 
        a = int(sum(dic["0"][:i])+sum(dic["1"][:j])+sum(dic["2"][:k])+sum(dic["3"][:l])) 
        b = int(i*Min+j*(Min+1)+k*(Min+2)+l*(Min+3))
        if a > ans and b <= W:
          ans = a
print(int(ans))
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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


w1 = WV[0][0]
WV.sort()

vlist = [[] for i in range(4)]
for i in range(N):
    w,v = WV[i][0],WV[i][1]
    d = w-w1
    vlist[d].append(v)
    
vrui = [[0] for i in range(4)]
for i in range(4):
    vlist[i].sort(reverse=True)
    for v in vlist[i]:
        vrui[i].append(vrui[i][-1]+v)
        


MAX = 0
for i in range(min(N+1,len(vlist[0])+1)):
    for j in range(min(N-i+1,len(vlist[1])+1)):
        for k in range(min(N-i-j+1,len(vlist[2])+1)):
            l = min(N-(i+j+k),len(vlist[3]))
            
            
            if (w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l) <= W:
                MAX = max(MAX,(vrui[0][i]+vrui[1][j]+vrui[2][k]+vrui[3][l]))

print(MAX)
            

Failing test case input:
4 6
2 0
5 6
4 10
3 9

Expected output:
10


Actual output:
6


Fixed submission (verdict: Accepted):

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


w1 = WV[0][0]
WV.sort()

vlist = [[] for i in range(4)]
for i in range(N):
    w,v = WV[i][0],WV[i][1]
    d = w-w1
    vlist[d].append(v)
    
vrui = [[0] for i in range(4)]
for i in range(4):
    vlist[i].sort(reverse=True)
    for v in vlist[i]:
        vrui[i].append(vrui[i][-1]+v)
        


MAX = 0
for i in range(min(N+1,len(vlist[0])+1)):
    for j in range(min(N-i+1,len(vlist[1])+1)):
        for k in range(min(N-i-j+1,len(vlist[2])+1)):
            for l in range(min(N-(i+j+k)+1,len(vlist[3])+1)):
                
                
                
                if (w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l) <= W:
                    MAX = max(MAX,(vrui[0][i]+vrui[1][j]+vrui[2][k]+vrui[3][l]))

print(MAX)
Problem: p03734
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, W = (int(i) for i in input().split())
w = [0]*N
v = [0]*N
for i in range(N):
  w[i], v[i] = (int(j) for j in input().split())
w0 = w[0]
wh = [a - w0 for a in w]
dp = [[[0]*(N+1) for i in range(3*N+1)] for j in range(N+1)]
for i in range(N):
  for j in range(3*N+1):
    for k in range(N+1):
      dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k])
      if j - wh[i] >=0 and k-1 >=0:
        dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j-wh[i]][k-1]+v[i])
res = 0
for k in range(N+1):
  if w0*k <= W <= (w0+3)*k:
    Wk = W - w0*k
    ans = 0
    for j in range(Wk+1):
      ans = max(dp[N][j][k], ans)
    res = max(res, ans)
print(res)


Failing test case input:
4 13
0 101
1 101
1 100
0 101

Expected output:
403


Actual output:
0


Fixed submission (verdict: Accepted):
N, W = (int(i) for i in input().split())
w = [0]*N
v = [0]*N
for i in range(N):
  w[i], v[i] = (int(j) for j in input().split())
w0 = w[0]
wh = [a - w0 for a in w]
dp = [[[-1]*(N+1) for i in range(3*N+1)] for j in range(N+1)]
dp[0][0][0] = 0
for i in range(N):
  for j in range(3*N+1):
    for k in range(N+1):
      if dp[i][j][k] != -1:
        dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k])
      if j - wh[i] >=0 and k-1 >=0 and dp[i][j-wh[i]][k-1] != -1:
        dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j-wh[i]][k-1]+v[i])
res = 0
for j in range(3*N+1):
  for k in range(N+1):
    if j + w0*k <= W:
      res = max(dp[N][j][k], res)
print(res)
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

if 1:
    N,W = map(int, input().split(' '))
    w,v = [],[]
    for i in range(N):
        w_,v_ = map(int, input().split(' '))
        w.append(w_)
        v.append(v_)
else:
    N,W = 4,6
    w = [2,3,4,3]
    v = [1,4,10,4]

w0 = w[0]

idxs = set()
for i in range(N+1):
    for j in range(3*i+1):
        if i*w0+j <= W:
            idxs.add(i*w0+j)
idxs = list(idxs) 
idx_dict = {idx:i for i,idx in enumerate(idxs)}

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

for i in range(N):
    for j in range(len(idxs)):
        if idxs[j] < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            if 1:
                k = bisect.bisect_left(idxs, idxs[j]-w[i])
                try:
                    dp[i+1][j] = max([dp[i][j],dp[i][idx_dict[idxs[k]]]+v[i]])
                except:
                    dp[i+1][j] = dp[i][j]
            else:
                try:
                    dp[i+1][j] = max([dp[i][j],dp[i][idx_dict[idxs[j]-w[i]]]+v[i]])
                except:
                    dp[i+1][j] = dp[i][j]
                
print(dp[-1][-1])

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

Expected output:
9


Actual output:
10


Fixed submission (verdict: Accepted):

if 1:
    N,W = map(int, input().split(' '))
    w,v = [],[]
    for i in range(N):
        w_,v_ = map(int, input().split(' '))
        w.append(w_)
        v.append(v_)
else:
    N,W = 4,6
    w = [2,3,4,3]
    v = [1,4,10,4]

w0 = w[0]

idxs = set()
for i in range(N+1):
    for j in range(3*i+1):
        if i*w0+j <= W:
            idxs.add(i*w0+j)
idxs = sorted(list(idxs))
idx_dict = {idx:i for i,idx in enumerate(idxs)}

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

for i in range(N):
    for j in range(len(idxs)):
        if idxs[j] < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            try:
                dp[i+1][j] = max([dp[i][j],dp[i][idx_dict[idxs[j]-w[i]]]+v[i]])
            except:
                dp[i+1][j] = dp[i][j]
        
print(max([max(dp_) for dp_ in dp]))
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import accumulate

N, W = map(int, input().split())
d = {i: [0] for i in range(4)}
for i in range(N):
    w, v = map(int, input().split())
    if i == 0:
        w0 = w
    w -= w0
    d[w].append(v)

wv = [[] for _ in range(4)]
for k, v in d.items():
    v.sort()
    wv[k] = tuple(accumulate(v))



ans = 0
for c0, v0 in enumerate(wv[0]):
    for c1, v1 in enumerate(wv[1]):
        for c2, v2 in enumerate(wv[2]):
            for c3, v3 in enumerate(wv[3]):
                weight = w0 * (c0 + c1 + c2 + c3) + c1 + c2 * 2 + c3 * 3
                val = v0 + v1 + v2 + v3
                if weight > W:
                    continue
                ans = max(ans, val)

print(ans)


Failing test case input:
4 1
1 100
1 101
1 011
1 101

Expected output:
101


Actual output:
11


Fixed submission (verdict: Accepted):
from itertools import accumulate

N, W = map(int, input().split())
d = {i: [] for i in range(4)}
for i in range(N):
    w, v = map(int, input().split())
    if i == 0:
        w0 = w
    w -= w0
    d[w].append(v)

wv = [[] for _ in range(4)]
for k, v in d.items():
    v.sort(reverse=True)
    v = [0] + v
    wv[k] = tuple(accumulate(v))



ans = 0
for c0, v0 in enumerate(wv[0]):
    for c1, v1 in enumerate(wv[1]):
        for c2, v2 in enumerate(wv[2]):
            for c3, v3 in enumerate(wv[3]):
                weight = w0 * (c0 + c1 + c2 + c3) + c1 + c2 * 2 + c3 * 3
                val = v0 + v1 + v2 + v3
                if weight > W:
                    continue
                ans = max(ans, val)

print(ans)

Problem: p03734
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,W = map(int, input().split())
ws = []
vs = []
for i in range(N):
    w,v = map(int, input().split())
    ws.append(w)
    vs.append(v)
ws_m = [w-ws[0] for w in ws]


dp = [[[-1]*(3*N+10) for i in range(N+1)] for j in range(N+1)]
dp[0][0][0] = 0
for i,(w,v)  in enumerate(zip(ws_m,vs)):
    for n in range(i+1):
        for j in range(3*N):
            dp[i+1][n][j] = max(dp[i+1][n][j], dp[i][n][j])
            if dp[i][n][j] == -1: continue
            if j + n*ws[0] + w <= W:
                dp[i+1][n+1][j+w] = max(dp[i][n][j+w], dp[i][n][j] + v)
ans= 0
for i,As in enumerate(dp[N]):
    w = W - i*ws[0]
    if w > 0:
        ans = max(ans,max(As[:w+1]))
print(ans)   


Failing test case input:
4 2
1 100
1 110
1 111
1 100

Expected output:
221


Actual output:
111


Fixed submission (verdict: Accepted):
N,W = map(int, input().split())
ws = []
vs = []
for i in range(N):
    w,v = map(int, input().split())
    ws.append(w)
    vs.append(v)
ws_m = [w-ws[0] for w in ws]


dp = [[[-1]*(3*N+10) for i in range(N+1)] for j in range(N+1)]
dp[0][0][0] = 0
for i,(w,v)  in enumerate(zip(ws_m,vs)):
    for n in range(i+1):
        for j in range(3*N):
            dp[i+1][n][j] = max(dp[i+1][n][j], dp[i][n][j])
            
            if j + (n+1)*ws[0] + w <= W:
                dp[i+1][n+1][j+w] = max(dp[i][n][j+w], dp[i][n][j] + v)

ans= 0
for i,As in enumerate(dp[N]):
    w = min(W - i*ws[0], sum(ws_m))
    if w >= 0:
        ans = max(ans,max(As[:w+1]))
print(ans)
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
ints = input().split(" ")
N = int(ints[0])
maxW = int(ints[1])
ints = input().split(" ")
a = int(ints[0])
b = int(ints[1])
weight = [a, a+1, a+2, a+3] 
va = [[0,b],[0],[0],[0]]
for i in range(1, N):
	ins = input().split(" ")
	w = int(ins[0])
	v = int(ins[1])
	for j in range(0, 4):
		if w == weight[j]:
			va[j].append(v)
sum = [[0],[0],[0],[0]]
for j in range(0, 4):
	for i in range(1, len(va[j])):
		try:
			sum[j].append(sum[j][i-1] + va[j][i])
		except:
			pass
ans = 0
for i in range(0, len(va[0])):
	for j in range(0, len(va[1])):
		for k in range(0, len(va[2])):
			for l in range(0, len(va[3])):
				sumw = weight[0]*i + weight[1]*j +weight[2]*k + weight[3]*l
				if(sumw <= maxW):
					ans = max(sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l],ans)
print(ans)

Failing test case input:
4 6
2 1
3 12
2 8
3 4

Expected output:
20


Actual output:
16


Fixed submission (verdict: Accepted):
ints = input().split(" ")
N = int(ints[0])
maxW = int(ints[1])
ints = input().split(" ")
a = int(ints[0])
b = int(ints[1])
weight = [a, a+1, a+2, a+3] 
va = [[b],[],[],[]]
for i in range(1, N):
	ins = input().split(" ")
	w = int(ins[0])
	v = int(ins[1])
	for j in range(0, 4):
		if w == weight[j]:
			va[j].append(v)
for i in range(0, len(va)):
	va[i].sort(reverse=True)
	va[i].insert(0,0)

sum = [[0],[0],[0],[0]]
for j in range(0, 4):
	for i in range(1, len(va[j])):
		try:
			sum[j].append(sum[j][i-1] + va[j][i])
		except:
			pass
ans = 0

for i in range(0, len(va[0])):
	for j in range(0, len(va[1])):
		for k in range(0, len(va[2])):
			for l in range(0, len(va[3])):
				sumw = weight[0]*i + weight[1]*j +weight[2]*k + weight[3]*l
				if(sumw <= maxW):
					ans = max(sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l],ans)
print(ans)
Problem: p03734
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, W = map(int, input().split())
dp = [[[0] * 301 for _ in range(n + 1)] for _ in range(n + 1)]
li = [list(map(int, input().split())) for _ in range(n)]
p = li[0][0]
for i, x in enumerate(li):
    w, v = x
    w -= p
    for j in range(i + 1):
        for k in range(301):
            if k >= w:
                if dp[i][j][k - w] + v > dp[i][j][k]:
                    dp[i + 1][j + 1][k] = dp[i][j][k - w] + v
                else:
                    dp[i + 1][j][k] = dp[i][j][k]
            else:
                dp[i + 1][j][k] = dp[i][j][k]
ans = 0
for i in range(n + 1):
    for k in range(301):
        if i * p + k <= W:
            ans = max(dp[n][i][k], ans)
print(ans)


Failing test case input:
4 2
1 100
1 110
1 111
1 100

Expected output:
221


Actual output:
211


Fixed submission (verdict: Accepted):
n, W = map(int, input().split())
dp = [[[0] * 301 for _ in range(n + 1)] for _ in range(n + 1)]
li = [list(map(int, input().split())) for _ in range(n)]
p = li[0][0]
for i, x in enumerate(li):
    w, v = x
    w -= p
    for j in range(i + 1):
        for k in range(301):
            if k >= w:
                if dp[i][j][k - w] + v > dp[i][j + 1][k]:
                    dp[i + 1][j + 1][k] = dp[i][j][k - w] + v
                else:
                    dp[i + 1][j + 1][k] = dp[i][j + 1][k]
            else:
                dp[i + 1][j + 1][k] = dp[i][j + 1][k]
ans = 0
for i in range(n + 1):
    for k in range(301):
        if i * p + k <= W:
            ans = max(dp[n][i][k], ans)
print(ans)
Problem: p03734
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,W = LI()
    a = [LI() for _ in range(n)]
    r = 0
    d = collections.defaultdict(int)
    d[0] = 0
    for w,v in a:
        for e,f in list(d.items()):
            if e+w > W:
                continue
            if d[e+w] < d[e] + v:
                d[e+w] = d[e] + v

    return max(d.values())


print(main())


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

Expected output:
14


Actual output:
16


Fixed submission (verdict: Accepted):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,W = LI()
    a = [LI() for _ in range(n)]
    r = 0
    d = collections.defaultdict(int)
    d[0] = 0
    for w,v in a:
        for e,f in sorted(list(d.items()), key=lambda x: -x[0]):
            if e+w > W:
                continue
            if d[e+w] < d[e] + v:
                d[e+w] = d[e] + v

    return max(d.values())


print(main())
Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
nums = input().split()

S = int(nums[0])
W = int(nums[1])


if (S < W ):
	print("unsafe")
else:
	print("safe")

Failing test case input:
001 1

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
nums = input().split()

S = int(nums[0])
W = int(nums[1])


if (S > W ):
	print("safe")
else:
	print("unsafe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s,w = input().split()
print("safe") if s < w else print("unsafe")

Failing test case input:
000 -1

Expected output:
safe


Actual output:
unsafe


Fixed submission (verdict: Accepted):
s,w = input().split()
print("safe") if int(s) > int(w) else print("unsafe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s,w=input().split()
if s<=w:
  print("unsafe")
else:
  print("safe")

Failing test case input:
000 0

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
s,w=map(int, input().split())
if s<=w:
  print("unsafe")
else:
  print("safe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

s, w = map(int, input().split())
if s<w:
    print('safe')
else:
    print('unsafe')

Failing test case input:
0 -23

Expected output:
safe


Actual output:
unsafe


Fixed submission (verdict: Accepted):
s, w = map(int, input().split())
if s>w:
    print('safe')
else:
    print('unsafe')

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
W, S = map(int, input().split())

if W >= S:
  print("unsafe")
else:
  print("safe")

Failing test case input:
000 -4

Expected output:
safe


Actual output:
unsafe


Fixed submission (verdict: Accepted):
S, W = map(int, input().split())

if W >= S:
  print("unsafe")
else:
  print("safe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S,W=[int(i) for i in input().split(" ")]
if W>=S:
    print("unsage")
else:
    print("safe")

Failing test case input:
000 1

Expected output:
unsafe


Actual output:
unsage


Fixed submission (verdict: Accepted):
S,W=[int(i) for i in input().split(" ")]
if W>=S:
    print("unsafe")
else:
    print("safe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s, w = map(int, input().split())

if  w > s:
  print("unsafe")
else:
  print("safe")

Failing test case input:
001 1

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
s, w = map(int, input().split())
 
if  w >= s:
  print("unsafe")
else:
  print("safe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b = map(int, input().split())
if b  > a:
  print("unsafe")
else:
  print("safe")

Failing test case input:
001 1

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
if b >= a:
  print("unsafe")
else:
  print("safe")
Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S,W=map(int,input().split())

if S<W:
    print('safe')
else:
    print('unsafe')

Failing test case input:
011 -2

Expected output:
safe


Actual output:
unsafe


Fixed submission (verdict: Accepted):
S,W=map(int,input().split())

if S>W:
    print('safe')
else:
    print('unsafe')

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S,W = list(map(int,input().split()))

if S < W:
    print("unsafe")
else:
    print("safe")


Failing test case input:
001 1

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
S,W = list(map(int,input().split()))

if S <= W:
    print("unsafe")
else:
    print("safe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a=input().split()
S = int(a[0])
W = int(a[1])
if S >= W:
    print("unsafe")
else:
    print("safe")

Failing test case input:
000 -5

Expected output:
safe


Actual output:
unsafe


Fixed submission (verdict: Accepted):
a = input().split()
S = int(a[0])
W = int(a[1])
if S <= W:
    print("unsafe")
else:
    print("safe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


H, O = map(int, input().split())

if (H < O):
  print("unsafe")
else:
  print("safe")

Failing test case input:
000 0

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):


H, O = map(int, input().split())

if (H <= O):
  print("unsafe")
else:
  print("safe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b = map(int, input().split())

if a<b:
    print("unsafe")
else:
    print("safe")

Failing test case input:
001 1

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
a,b = map(int, input().split())

if a<=b:
    print("unsafe")
else:
    print("safe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s, w = input().split()
if s < w:
  print('safe')
else:
  print('unsafe')

Failing test case input:
001 1

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
i = list(map(int, input().split()))
if i[0] > i[1]:
  print('safe')
else:
  print('unsafe')

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S, W = map(int, input().split())
S = int(S / 2)

if S < W:
    print("unsafe")
else:
    print("safe")

Failing test case input:
000 0

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
S, W = map(int, input().split())

if S <= W:
    print("unsafe")
else:
    print("safe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b = map(int, input().split())
print("Yes" if a <= b else "No")

Failing test case input:
011 -2

Expected output:
safe


Actual output:
No


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
print("safe" if a > b else "unsafe")
Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S,W=map(int,input().split())
if S<W:
  print('unsafe')
else:
  print('safe')

Failing test case input:
001 1

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
S,W=map(int,input().split())
if S<=W:
  print('unsafe')
else:
  print('safe')

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s,w = map(int, input().split())

print("safe" if w<s else "unself")

Failing test case input:
000 1

Expected output:
unsafe


Actual output:
unself


Fixed submission (verdict: Accepted):
s,w = map(int, input().split())
print("safe" if w<s else "unsafe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s , w = input().split()

if s <= w:
  print("unsafe")
else:
  print("safe")

Failing test case input:
000 0

Expected output:
unsafe


Actual output:
safe


Fixed submission (verdict: Accepted):
s , w = map(int, input().split())

if s > w:
  print("safe")
else:
  print("unsafe")

Problem: p02699
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S, W  = map(int, input().split())

print("safe" if S > W else"unsefe")

Failing test case input:
000 1

Expected output:
unsafe


Actual output:
unsefe


Fixed submission (verdict: Accepted):
S, W  = map(int, input().split())

print("safe" if S > W else "unsafe")
Problem: p02469
Buggy submission (Python3, verdict: Wrong Answer):
def gcd(x,y):
    p=min(x,y)
    q=max(x,y)
    while True:
            m=q%p
            if m==0:

                break
            p=m
            q=p
    g=p




    return g

c=0
n=int(input())
a=sorted(set(list(map(int, input().split()))))
b=[]
while len(a) > 1:
    n=len(a)
    for i in range(n-1):
        p=a[i]
        q=a[i+1]
        g=gcd(p,q)
        r=a[i]*a[i+1]
        b.append(r)
    a=sorted(b)
    b=[]
print(*a)

Failing test case input:
4
1 2 5 8

Expected output:
40


Actual output:
8000


Fixed submission (verdict: Accepted):
def gcd(x,y):
    p=min(x,y)
    q=max(x,y)
    while p != q:
        if q > p:
            q = q - p
        else:
            p = p - q
    return q

c=0
n=int(input())
a=sorted(set(list(map(int, input().split()))))
b=[]
while len(a) > 1:
    p=a[0]
    q=a[1]
    g=gcd(p,q)
    if g !=0:
        a.append(p*q
    a.pop(0)
    a.pop(0)
    a=sorted(a)
print(*a)

Problem: p02469
Buggy submission (Python3, verdict: Wrong Answer):
def GCD(x,y):
    r = x%y
    if r == 0:
        return y
    else:
        return GCD(y,r)


n = int(input())
list1 = list(map(int,input().split()))
result = list1[0]
for i in list1[1:]:
    result = result*i/GCD(i,result)

print(result)

Failing test case input:
3
1 22 5

Expected output:
110


Actual output:
110.0


Fixed submission (verdict: Accepted):
def GCD(x,y):
    r = x%y
    if r == 0:
        return y
    else:
        return GCD(y,r)


n = int(input())
list1 = list(map(int,input().split()))
result = list1[0]
for i in list1[1:]:
    result = result*i/GCD(i,result)

print(int(result))

Problem: p02469
Buggy submission (Python3, verdict: Wrong Answer):
def gcd(x,y):
    p=min(x,y)
    q=max(x,y)
    while True:
            m=q%p
            if m==0:

                break
            p=m
            q=p

    if p==q:
        g=1
    else:
        g=p
    return g

c=0
n=int(input())
a=sorted(set(list(map(int, input().split()))))
b=[]
while len(a) > 1:
    n=len(a)
    for i in range(n-1):
        p=a[i]
        q=a[i+1]
        g=gcd(p,q)

        r=a[i]*a[i+1]
        b.append(r)
    a=sorted(b)
    b=[]
print(*a)

Failing test case input:
4
1 2 5 44

Expected output:
220


Actual output:
44000


Fixed submission (verdict: Accepted):
def gcd(x,y):
    p=min(x,y)
    q=max(x,y)
    while p != q:
        if q > p:
            q = q - p
        else:
            p = p - q
    return q

c=0
n=int(input())
a=sorted(set(list(map(int, input().split()))))
b=[]
while len(a) > 1:
    p=a[0]
    q=a[1]
    g=gcd(p,q)
    if g !=0:
        a.append(p*q
    a.pop(0)
    a.pop(0)
    a=sorted(a)
print(*a)
Problem: p02243
Buggy submission (Python3, verdict: Wrong Answer):
from heapq import*
n=int(input())
A=[[]for _ in[0]*n]
for _ in[0]*n:
 e=list(map(int,input().split()))
 for i in range(e[1]):k=2*-~i;A[e[0]]+=[(e[k],e[k+1])]
H=[[0,0]]
d=[0]+[1e6]*n
c=[1]*n
while H:
 f=heappop(H)
 print(f)
 u=f[1]
 c[u]=0
 if d[u]>=f[0]:
  for s in A[u]:
   v=s[0]
   if c[v]and d[v]>d[u]+s[1]:
    d[v]=d[u]+s[1]
    heappush(H,[d[v],v])
for i in range(n):print(i,d[i])


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

Expected output:
0 0
1 1
2 3
3 3
4 4


Actual output:
[0, 0]
[1, 1]
[3, 2]
[3, 3]
[4, 4]
0 0
1 1
2 3
3 3
4 4


Fixed submission (verdict: Accepted):
from heapq import*
n=int(input())
A=[[]for _ in[0]*n]
for _ in[0]*n:
 e=list(map(int,input().split()))
 for i in range(e[1]):k=2*-~i;A[e[0]]+=[(e[k],e[k+1])]
H=[[0,0]]
d=[0]+[1e6]*n
c=[1]*n
while H:
 f=heappop(H)
 u=f[1]
 c[u]=0
 if d[u]>=f[0]:
  for s in A[u]:
   v=s[0]
   if c[v]and d[v]>d[u]+s[1]:
    d[v]=d[u]+s[1]
    heappush(H,[d[v],v])
for i in range(n):print(i,d[i])
Problem: p02243
Buggy submission (Python3, verdict: Wrong Answer):
from heapq import heappop, heappush
import sys


class SSSP:
    
    def __init__(self, graph):
        self.size = len(graph)
        self.tree = []
        self.weights = [0] * self.size
        self._search(graph)

    def weight(self, n):
        return self.weights[n]

    def _search(self, graph):
        h = []
        count = 1
        for i, w in graph[0]:
            heappush(h, (w, 0, i))

        while count < self.size:
            while len(h) > 0:
                weight, src, dst = heappop(h)
                if self.weights[dst] == 0 and dst > 0:
                    self.weights[dst] = weight
                    count += 1
                    self.tree.append((src, dst))
                    for i, w in graph[dst]:
                        if self.weights[i] == 0 and dst > 0:
                            heappush(h, (w+weight, dst, i))
                    break


def run():
    n = int(input())

    nodes = [None] * n
    for line in sys.stdin:
        id_, deg, *edges = [int(i) for i in line.split()]
        nodes[id_] = []
        for _ in range(deg):
            tgt, wgt, *edges = edges
            nodes[id_].append((tgt, wgt))

    st = SSSP(nodes)
    for node in range(n):
        print('{} {}'.format(node, st.weight(node)))


if __name__ == '__main__':
    run()



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

Expected output:
0 0
1 2
2 0
3 0
4 1


Actual output:
0 0
1 0
2 1
3 0
4 1


Fixed submission (verdict: Accepted):
from heapq import heappop, heappush
import sys


class SSSP:
    
    def __init__(self, graph):
        self.size = len(graph)
        self.tree = []
        self.weights = [-1] * self.size
        self._search(graph)

    def weight(self, n):
        return self.weights[n]

    def _search(self, graph):
        h = []
        self.weights[0] = 0
        count = 1
        for i, w in graph[0]:
            heappush(h, (w, 0, i))

        while count < self.size:
            while len(h) > 0:
                weight, src, dst = heappop(h)
                if self.weights[dst] < 0:
                    self.weights[dst] = weight
                    count += 1
                    self.tree.append((src, dst))
                    for i, w in graph[dst]:
                        if self.weights[i] < 0:
                            heappush(h, (w+weight, dst, i))
                    break


def run():
    n = int(input())

    nodes = [None] * n
    for line in sys.stdin:
        id_, deg, *edges = [int(i) for i in line.split()]
        nodes[id_] = []
        for _ in range(deg):
            tgt, wgt, *edges = edges
            nodes[id_].append((tgt, wgt))

    st = SSSP(nodes)
    for node in range(n):
        print('{} {}'.format(node, st.weight(node)))


if __name__ == '__main__':
    run()
Problem: p02243
Buggy submission (Python3, verdict: Wrong Answer):
V=int(input())

G=[[] for i in range(V)]
d=[1001001001 for i in range(V)]

import heapq

def dijkstra(s):
    q=[]
    d[s]=0
    heapq.heappush(q,(0, s))
    
    while(len(q)):
        print(q)
        p=heapq.heappop(q)
        v=p[1]
        if d[v]<p[0]:
            continue
        for e in G[v]:
            if d[e[0]]>d[v]+e[1]:
                d[e[0]]=d[v]+e[1]
                
                heapq.heappush(q, (d[e[0]], e[0]))

import sys
for l in sys.stdin:
    l=list(map(int,l.split()))
    u=l[0]
    k=l[1]
    G[u]=zip(*[iter(l[2:])]*2)
    
dijkstra(0)
for i in range(V):
    print(i, d[i])
    

    

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

Expected output:
0 0
1 2
2 2
3 1
4 3


Actual output:
[(0, 0)]
[(1, 3), (3, 1), (2, 1)]
[(2, 1), (3, 1), (2, 2), (4, 4)]
[(2, 2), (3, 1), (4, 4)]
[(3, 1), (4, 4), (3, 4)]
[(3, 4), (4, 4)]
[(4, 4)]
0 0
1 2
2 2
3 1
4 3


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

G=[[] for i in range(V)]
d=[1001001001 for i in range(V)]

import heapq

def dijkstra(s):
    q=[]
    d[s]=0
    heapq.heappush(q,(0, s))
    
    while(len(q)):
        
        p=heapq.heappop(q)
        v=p[1]
        if d[v]<p[0]:
            continue
        for e in G[v]:
            if d[e[0]]>d[v]+e[1]:
                d[e[0]]=d[v]+e[1]
                
                heapq.heappush(q, (d[e[0]], e[0]))

import sys
for l in sys.stdin:
    l=list(map(int,l.split()))
    u=l[0]
    k=l[1]
    G[u]=zip(*[iter(l[2:])]*2)
    
dijkstra(0)
for i in range(V):
    print(i, d[i])
Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
print(" ".join(reversed(input().split())))

Failing test case input:
8
-1 2 8 5 -1 -1 12 14

Expected output:
14 12 -1 -1 5 8 2 -1


Actual output:
8


Fixed submission (verdict: Accepted):
num = input()
print(" ".join(reversed(input().split())))

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
x = [int(i) for i in input().split()]
x.sort()
x.reverse()
for i in range(n):
    print(x[i]," ",sep="",end="")
print("")



Failing test case input:
8
0 1 4 4 5 0 7 14

Expected output:
14 7 0 5 4 4 1 0


Actual output:
14 7 5 4 4 1 0 0 


Fixed submission (verdict: Accepted):
n = int(input())
x = [int(i) for i in input().split()]
x.reverse()
for i in range(n-1):
    print(x[i]," ",sep="",end="")
print(x[n-1])

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
import sys


def main():
    sys.stdin.readline()
    list1 = list(map(str, sys.stdin.readline().split()))
    list.sort(list1, reverse=True)
    print(' '.join(list1))
    return


if __name__ == '__main__':
    main()



Failing test case input:
8
-2 6 0 25 -1 -1 95 26

Expected output:
26 95 -1 -1 25 0 6 -2


Actual output:
95 6 26 25 0 -2 -1 -1


Fixed submission (verdict: Accepted):
import sys


def main():
    sys.stdin.readline()
    list1 = list(map(str, sys.stdin.readline().split()))
    list.reverse(list1)
    print(' '.join(list1))

    return


if __name__ == '__main__':
    main()

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
input()
a = input().split()
a.reverse()
for b in a:
    print(b, end='_')

Failing test case input:
5
-1 0 1 6 -2

Expected output:
-2 6 1 0 -1


Actual output:
-2_6_1_0_-1_

Fixed submission (verdict: Accepted):
input()
a = input().split()
a.reverse()
print(" ".join(a))

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
import sys

length = int(sys.stdin.readline())
num_seq = [ int(num) for num in sys.stdin.readline().split() ]
print(num_seq)

for i in range(1,length):
    print(num_seq[length - i],end=' ')
print(num_seq[0],end='')


Failing test case input:
8
-2 0 0 32 -1 -2 95 26

Expected output:
26 95 -2 -1 32 0 0 -2


Actual output:
[-2, 0, 0, 32, -1, -2, 95, 26]
26 95 -2 -1 32 0 0 -2

Fixed submission (verdict: Accepted):
import sys

length = int(sys.stdin.readline())
num_seq = sys.stdin.readline().split()

for i in range(1, length):
    print(num_seq[length - i], end=' ')
print(num_seq[0])

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
a = list(map(int, input().split()))
a = list(a[i] for i in range(len(a)-1,-1,-1))
print(" ".join(map(str, a)))

Failing test case input:
8
-1 2 8 9 -1 -3 13 9

Expected output:
9 13 -3 -1 9 8 2 -1


Actual output:
8


Fixed submission (verdict: Accepted):
_ = input()
a = list(map(int, input().split()))
a = list(a[i] for i in range(len(a)-1,-1,-1))
print(" ".join(map(str, a)))
Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
input()
xs = input().split()
print(list(reversed(xs)))

Failing test case input:
5
1 0 3 4 9

Expected output:
9 4 3 0 1


Actual output:
9, 4, 3, 0, 1

Fixed submission (verdict: Accepted):
input()
xs = input().split()
print(' '.join(list(map(str, reversed(xs)))))

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = str(input())
list = a.split()
for i in list[4:0:-1]:
    print(i, end = ' ')
print(list[0])


Failing test case input:
8
-1 2 0 13 -1 -3 26 15

Expected output:
15 26 -3 -1 13 0 2 -1


Actual output:
-1 13 0 2 -1


Fixed submission (verdict: Accepted):
n = int(input())
a = str(input())
list = a.split()
for i in list[n:0:-1]:
    print(i, end = ' ')
print(list[0])

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
print(" ".join(map(str, sorted(list(map(int, input().split())), reverse=True))))

Failing test case input:
5
-1 0 1 5 -2

Expected output:
-2 5 1 0 -1


Actual output:
5 1 0 -1 -2


Fixed submission (verdict: Accepted):
n = input()
a = [int(x) for x in input().split()]
a.reverse()
print(" ".join(map(str, a)))

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
x = [int(i) for i in input().split()]
x.sort()
x.reverse()
for i in range(n-1):
    print(x[i]," ",sep="",end="")
print(x[n-1])



Failing test case input:
5
0 1 4 1 0

Expected output:
0 1 4 1 0


Actual output:
4 1 1 0 0


Fixed submission (verdict: Accepted):
n = int(input())
x = [int(i) for i in input().split()]
x.reverse()
for i in range(n-1):
    print(x[i]," ",sep="",end="")
print(x[n-1])

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
input()
A = input().split()
print(A[::-1])


Failing test case input:
8
-1 1 8 5 -1 -1 12 14

Expected output:
14 12 -1 -1 5 8 1 -1


Actual output:
14, 12, -1, -1, 5, 8, 1, -1

Fixed submission (verdict: Accepted):
input()
print(" ".join(input().split()[::-1]))

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
input()
a = input().split()

print(a)
a.reverse()
print(" ".join(a))

Failing test case input:
8
4 3 4 4 5 8 7 14

Expected output:
14 7 8 5 4 4 3 4


Actual output:
['4', '3', '4', '4', '5', '8', '7', '14']
14 7 8 5 4 4 3 4


Fixed submission (verdict: Accepted):
input()
a = input().split()
a.reverse()
print(" ".join(a))

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
Arr = list(map(int, input().split()))
for i in range(N):
 if i==N-1:
  print(Arr[0])
 else:
  print(str(Arr[N-1-i]) + " ")

Failing test case input:
8
0 2 4 4 5 0 7 14

Expected output:
14 7 0 5 4 4 2 0


Actual output:
14 
7 
0 
5 
4 
4 
2 
0


Fixed submission (verdict: Accepted):
N = int(input())
Arr = list(map(int, input().split()))
for i in range(N-1):
 print("{} ".format(Arr[N-1-i]), end="")
print(Arr[0])
Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
print(" ".join(input().split())[::-1])

Failing test case input:
5
0 0 1 31 0

Expected output:
0 31 1 0 0


Actual output:
0 13 1 0 0


Fixed submission (verdict: Accepted):
n = int(input())
print(" ".join(input().split()[::-1]))

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
n = input()
print(list(map(int, input().split()))[::-1])


Failing test case input:
5
-1 -1 1 1 -1

Expected output:
-1 1 1 -1 -1


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


Fixed submission (verdict: Accepted):
input()
print(" ".join(input().split()[::-1]))

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
input()
list1 = list(map(int, input().split()))
list1.sort()
result=""
for i in range(0,len(list1)):
    result += str(list1[i])+" "
print(result)

Failing test case input:
5
0 0 3 4 12

Expected output:
12 4 3 0 0


Actual output:
0 0 3 4 12 


Fixed submission (verdict: Accepted):
input()
list1 = list(map(int, input().split()))
list1.reverse()
result=""
for i in range(0,len(list1)):
    result += str(list1[i])
    if len(list1)-1 == i:
        pass
    else:
        result += " "
print(result)

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    n = int(input())
    a = input()
    print(a[::-1])

if __name__ == "__main__":
    main()

Failing test case input:
8
-2 0 0 32 -1 -1 95 26

Expected output:
26 95 -1 -1 32 0 0 -2


Actual output:
62 59 1- 1- 23 0 0 2-


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = map(int, input().split())
    print(" ".join(map(str, list(a)[::-1])))

if __name__ == "__main__":
    main()

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
n = input()
print(" ".join(input().split())[::-1])

Failing test case input:
5
-1 1 0 21 -2

Expected output:
-2 21 0 1 -1


Actual output:
2- 12 0 1 1-


Fixed submission (verdict: Accepted):
n = int(input())
print(" ".join(input().split()[::-1]))

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
import sys

length = int(sys.stdin.readline())
num_seq = sys.stdin.readline().split()
print(num_seq)

for i in range(1,length):
    print(num_seq[length - i],end=' ')
print(num_seq[0])


Failing test case input:
8
-1 1 4 4 5 0 7 14

Expected output:
14 7 0 5 4 4 1 -1


Actual output:
['-1', '1', '4', '4', '5', '0', '7', '14']
14 7 0 5 4 4 1 -1


Fixed submission (verdict: Accepted):
import sys

length = int(sys.stdin.readline())
num_seq = sys.stdin.readline().split()

for i in range(1, length):
    print(num_seq[length - i], end=' ')
print(num_seq[0])

Problem: p02407
Buggy submission (Python3, verdict: Wrong Answer):
_ = input()

print("".join(reversed(input())))

Failing test case input:
8
-2 1 0 32 -2 -2 153 26

Expected output:
26 153 -2 -2 32 0 1 -2


Actual output:
62 351 2- 2- 23 0 1 2-


Fixed submission (verdict: Accepted):
_ = input()
print(" ".join(reversed(input().split())))
Problem: p02385
Buggy submission (Python3, verdict: Wrong Answer):
def N():
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E():
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W():
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S():
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
Dice=[int(i) for i in input().split()]
Dice2=[int(i) for i in input().split()]
if (Dice[0] in Dice2)==False:
    print('No')
else:
    count=0
    for j in range(12):
        if count%2==0:
            N()
        else:
            W()
        count+=1
        for i in range(4):
            N()
            W()
            S()
            if Dice==Dice2:
                break
    if Dice==Dice2:
        print('Yes')
    else:
        print('No')

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

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
def N():
    num=Dice[0]
    Dice[0]=Dice[1]
    Dice[1]=Dice[5]
    Dice[5]=Dice[4]
    Dice[4]=num
def E():
    num=Dice[0]
    Dice[0]=Dice[3]
    Dice[3]=Dice[5]
    Dice[5]=Dice[2]
    Dice[2]=num
def W():
    num=Dice[0]
    Dice[0]=Dice[2]
    Dice[2]=Dice[5]
    Dice[5]=Dice[3]
    Dice[3]=num
def S():
    num=Dice[0]
    Dice[0]=Dice[4]
    Dice[4]=Dice[5]
    Dice[5]=Dice[1]
    Dice[1]=num
Dice=[int(i) for i in input().split()]
Dice2=[int(i) for i in input().split()]
if (Dice[0] in Dice2)==False:
    print('No')
else:
    for j in range(6):
        if j%2==0:
            N()
        else:
            W()
        for i in range(4):
            N()
            W()
            S()
            if Dice==Dice2:
                break
        if Dice==Dice2:
            break 
    if Dice==Dice2:
        print('Yes')
    else:
        print('No')