ZhenlongDai/ACPR huggingface dataset:
Problem: p02865
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
if n%2==0:
  print((n/2)-1)
else:
  print((n-1)/2)

Failing test case input:
11230

Expected output:
5614


Actual output:
5614.0


Fixed submission (verdict: Accepted):
n=int(input())
if n%2==0:
  print(int((n/2)-1))
else:
  print(int((n-1)/2))

Problem: p02865
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
if n % 2 == 0:
  print(n/2 - 1)
else:
  print((n-1)/2)

Failing test case input:
825

Expected output:
412


Actual output:
412.0


Fixed submission (verdict: Accepted):
n = int(input())
if n % 2 == 0:
  print(int(n/2 - 1))
else:
  print(int((n-1)/2))

Problem: p02865
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
if n % 2 == 0:
    print((n - 1) / 2)
else:
    print((n - 1) / 2 - 1)

Failing test case input:
27115

Expected output:
13557


Actual output:
13556.0


Fixed submission (verdict: Accepted):
n = int(input())
if n % 2 == 1:
    print(int((n - 1) / 2))
else:
    print(int(n / 2 - 1))

Problem: p02865
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
if n%2==0:
  print(n/2-1)
else:
  print((n-1)/2)

Failing test case input:
64455

Expected output:
32227


Actual output:
32227.0


Fixed submission (verdict: Accepted):
n=int(input())
if n%2==0:
  print(int(n/2)-1)
else:
  print(int((n-1)/2))

Problem: p02865
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = n/2
print(int(round(a)-1))

Failing test case input:
1339977

Expected output:
669988


Actual output:
669987


Fixed submission (verdict: Accepted):
import math
n = int(input())
a = n/2
print(math.ceil(a)-1)

Problem: p02865
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
if N % 2 == 0:
    print(N/2 -1)
else:
    print((N+1)/2-1)

Failing test case input:
23008

Expected output:
11503


Actual output:
11503.0


Fixed submission (verdict: Accepted):
N = int(input())
if N % 2 == 0:
    print(int(N/2 -1))
else:
    print(int((N+1)/2-1))

Problem: p02865
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
if n%2 == 0:
    print(n>>1-1)
else:
    print(n>>1)


Failing test case input:
1412384

Expected output:
706191


Actual output:
1412384


Fixed submission (verdict: Accepted):
n=int(input())
if n%2 == 0:
    print((n>>1)-1)
else:
    print(n>>1)

Problem: p02865
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
if N%2 ==1:
  print(int(N+1)/2-1)
else:
  print(int(N/2)-1)
  


Failing test case input:
999999

Expected output:
499999

Actual output:
499999.0


Fixed submission (verdict: Accepted):
N = int(input())
if N%2 == 0:
    print(int((N/2)-1))
else:
    print(int((N+1)/2)-1)

Problem: p02865
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

N = int(input())
ans = N/2

if N == 1:
	print(1)
else:
	print(math.floor(ans))

Failing test case input:
133044

Expected output:
66521


Actual output:
66522


Fixed submission (verdict: Accepted):
import math

N = int(input())
ans = math.floor(N / 2)

if N % 2 == 0:
  print(ans - 1)
else:
  print(ans)
Problem: p02865
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
if n % 2 == 1:
    print((n + 1) / 2 - 1)
else:
    print(n / 2 - 1)

Failing test case input:
999999

Expected output:
499999

Actual output:
499999.0


Fixed submission (verdict: Accepted):
n = int(input())
if n % 2 == 1:
    print(int((n - 1) / 2))
else:
    print(int(n / 2 - 1))
Problem: p03003
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))

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


for i, s in enumerate(S):
    for j, t in enumerate(T):
        if s == t:
            dp[i+1][j+1] = dp_sum[i][j] + 1 
        dp_sum[i+1][j+1] = dp[i+1][j+1] + dp_sum[i][j+1] + dp_sum[i+1][j] - dp_sum[i][j]
        
print(dp_sum[N][M]+1)



Failing test case input:
20 20
1 1 1 0 2 1 1 1 0 1 2 1 1 1 1 1 1 1 1 1
1 1 1 2 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1

Expected output:
836684419


Actual output:
3836684440


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

MOD = 10**9+7

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


ret = 0
for i, s in enumerate(S):
    for j, t in enumerate(T):
        if s == t:
            dp[i+1][j+1] = dp_sum[i][j] + 1 
        dp_sum[i+1][j+1] = (dp[i+1][j+1] + dp_sum[i][j+1] + dp_sum[i+1][j] - dp_sum[i][j]) % MOD
        
print(dp_sum[N][M]+1)

Problem: p03003
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
mod = 10**9 + 7

N,M = map(int,input().split())
S = "".join(input().split())
T = "".join(input().split())

dp = [[0]*(M+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    dp[i][0] = 1
for j in range(1,M+1):
    dp[0][j] = 1
for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = dp[i][j-1] + dp[i-1][j]
        else:
            dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1]
        dp[i][j] %= mod

ans = dp[N][M]
print(ans)

Failing test case input:
10 9
14 6 5 7 9 9 8 5 6 7
17 6 8 0 5 7 9 9 7

Expected output:
125


Actual output:
130


Fixed submission (verdict: Accepted):
mod = 10**9 + 7

N,M = map(int,input().split())
S = input().split()
T = input().split()

dp = [[-1]*(M+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
    dp[i][0] = 1
for j in range(1,M+1):
    dp[0][j] = 1

for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = dp[i][j-1] + dp[i-1][j]
        else:
            dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1]
        dp[i][j] %= mod

ans = dp[N][M]
print(ans)
Problem: p03003
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import defaultdict as dd
used = dd(int)

N, M = map(int, input().split())
MOD = 10**9 + 7
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp = [[0 for i in range(M+1)] for j in range(N+1)]
for j in range(M):
    dp[1][j + 1] = dp[1][j] + 1 if s[0] == t[j] else dp[1][j]

for i in range(N):
    dp[i + 1][1] = dp[i][1] + 1 if t[0] == s[i] else dp[i][1]

used[s[0]] = 1
if N > 1 and M > 1:
    for i in range(1, N):
        used[s[i]] = 1
        for j in range(1, M):
            if used[t[j]] == 1:
                dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j]
                used[t[j]] = 2
                if s[i] == t[j]:
                    dp[i+1][j+1] += 1
            else:
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j])
    
print((dp[N][M] + 1)%MOD)


Failing test case input:
10 9
9 6 5 12 5 9 8 5 6 7
8 2 14 7 5 7 9 9 2

Expected output:
23


Actual output:
6


Fixed submission (verdict: Accepted):
N, M = map(int, input().split())
MOD = 10**9 + 7
s = list(map(int, input().split()))
t = list(map(int, input().split()))

dp = [[0 for i in range(M+1)] for j in range(N+1)]
for j in range(M):
    dp[1][j + 1] = dp[1][j] + 1 if s[0] == t[j] else dp[1][j]

for i in range(N):
    dp[i + 1][1] = dp[i][1] + 1 if t[0] == s[i] else dp[i][1]

for i in range(1, N):
    for j in range(1, M):
        if s[i] == t[j]:
            dp[i + 1][j + 1] = (dp[i][j + 1] + dp[i + 1][j] + 1)%MOD
        else:
            dp[i + 1][j + 1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j])%MOD
    
print((dp[N][M] + 1)%MOD)
Problem: p03003
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from math import ceil

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nok(a, b):
    m = a * b
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return m 


def main():
    mod = 1e9 + 7
    n, m = rinput()
    s = rlinput()
    t = rlinput()
    a = [1] * (m + 1)
    for j in s:
        d = a[:]
        k = 0
        for i, v in enumerate(t):
            d[i] = (k + d[i]) % mod
            if j == v:
                k = (k + a[i]) % mod
        d[-1] = (k + d[-1]) % mod
        a = d[:]
    print(a[-1])
    
    
    
main()

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

Expected output:
556030426


Actual output:
556030426.0


Fixed submission (verdict: Accepted):
import sys
from math import ceil

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nok(a, b):
    m = a * b
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return m 


def main():
    mod = 1e9 + 7
    n, m = rinput()
    s = rlinput()
    t = rlinput()
    a = [1] * (m + 1)
    for j in s:
        d = a[:]
        k = 0
        for i, v in enumerate(t):
            d[i] = (k + d[i]) % mod
            if j == v:
                k = (k + a[i]) % mod
        d[-1] = (k + d[-1]) % mod
        a = d[:]
    print(int(a[-1]))
    
    
    
main()

Problem: p03003
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [[0] * (m+2) for _ in range(n+2)]
mod = 1000000007
dp[0][0] = 1
for i in range(1, n+1):
    for j in range(1, m+1):
        dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod
        if s[i-1] == t[j-1]:
            dp[i][j] += 1 + dp[i-1][j-1]
            dp[i][j] %= mod
print(dp[n][m])


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

Expected output:
150262455


Actual output:
150262454


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [[0] * (m+2) for _ in range(n+2)]
mod = 1000000007

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

for i in range(1, n+1):
    for j in range(1, m+1):
        dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod
        if s[i-1] == t[j-1]:
            dp[i][j] += dp[i-1][j-1]
            dp[i][j] %= mod
print(dp[n][m])
Problem: p03003
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [[0] * (m+2) for _ in range(n+2)]
dp[0][0] = 1
for i in range(1, n+1):
    for j in range(1, m+1):
        dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]
        if s[i-1] == t[j-1]:
            dp[i][j] += 1 + dp[i-1][j-1]
print(dp[n][m])


Failing test case input:
10 9
9 6 5 12 5 9 8 5 6 7
8 2 14 7 5 7 9 9 2

Expected output:
23


Actual output:
7


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
dp = [[0] * (m+2) for _ in range(n+2)]
mod = 1000000007

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

for i in range(1, n+1):
    for j in range(1, m+1):
        dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod
        if s[i-1] == t[j-1]:
            dp[i][j] += dp[i-1][j-1]
            dp[i][j] %= mod
print(dp[n][m])

Problem: p03003
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
S = inpl()
T = inpl()

total = [0]*(N+1)*(M+1)
for i in range(N):
	for j in range(M):
		if S[i] == T[j]:
			n = total[(M+1)*i+j] + 1
		else:
			n = 0
		total[(M+1)*(i+1)+(j+1)] = n + total[(M+1)*i+(j+1)] + total[(M+1)*(i+1)+j] - total[(M+1)*i+j]
print(total[-1]+1)

Failing test case input:
20 20
1 1 1 1 1 1 1 0 1 1 1 1 2 1 1 1 1 1 1 1
1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Expected output:
761868929


Actual output:
17761869048


Fixed submission (verdict: Accepted):
inpl = lambda: list(map(int,input().split()))
MOD = 10**9 + 7
N, M = inpl()
S = inpl()
T = inpl()

total = [0]*(N+1)*(M+1)
for i in range(N):
	for j in range(M):
		if S[i] == T[j]:
			n = total[(M+1)*i+j] + 1
		else:
			n = 0
		total[(M+1)*(i+1)+(j+1)] = (n + total[(M+1)*i+(j+1)] + total[(M+1)*(i+1)+j] - total[(M+1)*i+j]) % MOD
print((total[-1]+1) % MOD)
Problem: p03003
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))

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


for i, s in enumerate(S):
    for j, t in enumerate(T):
        if s == t:
            dp[i+1][j+1] = dp_sum[i][j] + 1 
        else:
            dp[i+1][j+1] = 0
        dp_sum[i+1][j+1] = dp[i+1][j+1] + dp_sum[i][j+1] + dp_sum[i+1][j] - dp_sum[i][j]
        
print(dp_sum[N][M]+1)



Failing test case input:
20 20
1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1
1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Expected output:
672631781


Actual output:
17672631900


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

MOD = 10**9+7

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


ret = 0
for i, s in enumerate(S):
    for j, t in enumerate(T):
        if s == t:
            dp[i+1][j+1] = dp_sum[i][j] + 1 
        dp_sum[i+1][j+1] = (dp[i+1][j+1] + dp_sum[i][j+1] + dp_sum[i+1][j] - dp_sum[i][j]) % MOD
        
print(dp_sum[N][M]+1)

Problem: p03003
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int, input().split())
ss = input()
ts = input()
d = [[1] * (m+1) for _ in range(n+1)]
for i in range(n):
    for j in range(m):
        d[i+1][j+1] = d[i][j+1] + d[i+1][j] - (ss[2*i] != ts[2*j])*d[i][j]
print(d[n][m]%(10**9+7))

Failing test case input:
10 9
9 6 5 12 5 9 8 5 6 7
8 2 8 7 5 12 9 9 7

Expected output:
49


Actual output:
336


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
ss = input().split()
ts = input().split()
d = [[1] * (m+1) for _ in range(n+1)]
for i in range(n):
    for j in range(m):
        d[i+1][j+1] = (d[i][j+1] + d[i+1][j] - (ss[i] != ts[j])*d[i][j]) % (10**9+7)
print(d[n][m])
Problem: p03437
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

x, y = map(int, input().split())
if y%x == 0:
    ans = -1
else:
    ans = x
print(ans)

Failing test case input:
-6 12

Expected output:
-6


Actual output:
-1


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

x, y = map(int, input().split())
if x%y == 0:
    ans = -1
else:
    ans = x
print(ans)

Problem: p03437
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
if y%x==0:
	print(-1)
else:
	print(x)

Failing test case input:
-6 12

Expected output:
-6


Actual output:
-1


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
if x%y==0:
	print(-1)
else:
	print(x)

Problem: p03437
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int, input().split())
print(-1 if Y % X == 0 else X)


Failing test case input:
-6 12

Expected output:
-6


Actual output:
-1


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())
print(-1 if X % Y == 0 else X)

Problem: p03437
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int,input().split(" "))
if Y%X == 0:
  print(-1)
else:
  print(X)

Failing test case input:
-6 12

Expected output:
-6


Actual output:
-1


Fixed submission (verdict: Accepted):
X, Y = map(int,input().split(" "))
if X%Y == 0:
  print(-1)
else:
  print(X)

Problem: p03437
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, Y = map(int, input().split())
if Y % X == 0 or X % Y == 0:
  ans = -1
else:
  ans = X
if ans > 10**18:
  ans = -1
if X == 1 and Y != 1:
  ans = Y + 1
print(ans)

Failing test case input:
-6 12

Expected output:
-6


Actual output:
-1


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())
if X % Y == 0:
  ans = -1
elif Y % X == 0:
  ans = X * (Y
else:
  ans = X
if ans > 10**18:
  ans = -1
if X == 1 and Y != 1:
  ans = Y + 1
print(ans)

Problem: p03437
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int, input().split())
if Y % X == 0:
    print(-1)
else:
    print(X)


Failing test case input:
-6 12

Expected output:
-6


Actual output:
-1


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())
if X % Y == 0:
    print(-1)
else:
    print(X)

Problem: p03437
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X,Y = map(int,input().split())
if Y%X == 0:
  print(-1)
else:
  print(X)


Failing test case input:
-6 12

Expected output:
-6


Actual output:
-1


Fixed submission (verdict: Accepted):
X,Y=map(int,input().split())
if X%Y!=0:
    print(X)
else:
    print(-1)

Problem: p03437
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
print(x if y%x!=0 else -1)

Failing test case input:
-6 12

Expected output:
-6


Actual output:
-1


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
print(x if x%y!=0 else -1)
Problem: p03437
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

input = sys.stdin.readline

def main():
    X, Y = map(int, input().split())
    if X == Y:
        print(-1)
    else:
        for i in range(2,10**1):
            if X*i%Y != 0:
                print(X*i)
                exit()

if __name__ == '__main__':
    main()

Failing test case input:
41 9

Expected output:
41


Actual output:
82


Fixed submission (verdict: Accepted):
import sys

input = sys.stdin.readline

def main():
    X, Y = map(int, input().split())
    if X%Y == 0:
        print(-1)
    else:
        print(X)

if __name__ == '__main__':
    main()

Problem: p03437
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X, Y = map(int, input().split())
if (X % Y == 0) or (Y % X == 0):
    print(-1)
else:
    print(X * 2)


Failing test case input:
46 6

Expected output:
46


Actual output:
92


Fixed submission (verdict: Accepted):
X, Y = map(int, input().split())
if (X % Y == 0):
    print(-1)
else:
    print(X)
Problem: p03617
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
q, h, s, d = map(int, input().split())
n = int(input())

half = min(2 * q, h)
one = min(2 * half, s)
two = min(2 * one, d)

l = zip([2, 1, 0.5, 0.25], [two, one, half, q])

ans = 0
rest = n
for vol, cost in l:
    ans += rest 
    rest %= vol
print(int(ans))

Failing test case input:
10000 1011 110 14
-2

Expected output:
-14


Actual output:
-2


Fixed submission (verdict: Accepted):
q, h, s, d = map(int, input().split())
n = int(input())

half = min(2 * q, h)
one = min(2 * half, s)
two = min(2 * one, d)

l = zip([2, 1, 0.5, 0.25], [two, one, half, q])

ans = 0
rest = n
for vol, cost in l:
    ans += (rest 
    rest %= vol
    if rest == 0:
        print(ans)
        break

Problem: p03617
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input().split(" ")
b = list(map(int, a))
c = int(input())
ans = 0
r = min([b[0] * 4, b[1] * 2, b[2]])
r2 = min([b[0]*8,b[1]*4,b[2]*2, b[3]])




if c%2==1:
	ans=r+((c-1)/2)*r2
else :
	ans=c
print(int(ans))


Failing test case input:
3065533 854010 10742875 54687163
27604

Expected output:
47148184080


Actual output:
27604


Fixed submission (verdict: Accepted):
b=list(map(int,input().split()))
c = int(input())
ans = 0
r = min([b[0]*4, b[1]*2, b[2]])
r2 = min([b[0]*8,b[1]*4,b[2]*2, b[3]])






if c%2==1:
	print(((c-1)
else :
	print((c
Problem: p03617
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
Q,H,R,S = map(int,input().split())
N = int(input())

efficient_num,efficient_cost = 0,8*Q
if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
if(efficient_cost > 2*R): efficient_num,efficient_cost = 2,2*R
if(efficient_cost > S): efficient_num,efficient_cost = 3,S


min_cost = 0
n = N
if(efficient_num == 0): min_cost = int(n/0.25)*2*Q
elif(efficient_num == 1): min_cost = int(n/0.50)*2*H
elif(efficient_num == 2): min_cost = n*2*R
elif(efficient_num == 3): min_cost = int((n/2)*2*S)


if(N%2 == 0):
  print(min_cost)

else:
  
  efficient_num,efficient_cost = 0,8*Q
  if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
  if(efficient_cost > 2*R): efficient_num,efficient_cost = 2,2*R
  
  if(efficient_num == 0): min_cost += int(1/0.25)*Q
  elif(efficient_num == 1): min_cost += int(1/0.50)*H
  elif(efficient_num == 2): min_cost += 1*R
  print(min_cost)

Failing test case input:
91259 3187 23088 2979879
16689

Expected output:
106375686


Actual output:
212757746


Fixed submission (verdict: Accepted):
Q,H,S,D = map(int,input().split())
N = int(input())

efficient_num,efficient_cost = 0,8*Q
if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
if(efficient_cost > 2*S): efficient_num,efficient_cost = 2,2*S
if(efficient_cost > D): efficient_num,efficient_cost = 3,D


min_cost = 0

if(N%2 == 0):
 if(efficient_num == 0): min_cost = int(N/0.25)*Q
 elif(efficient_num == 1): min_cost = int(N/0.50)*H
 elif(efficient_num == 2): min_cost = N*S
 elif(efficient_num == 3): min_cost = (N
 

else:
 N = 2*(N
 if(efficient_num == 0): min_cost = int(N/0.25)*Q
 elif(efficient_num == 1): min_cost = int(N/0.50)*H
 elif(efficient_num == 2): min_cost = N*S
 elif(efficient_num == 3): min_cost = (N
 
 
 efficient_num,efficient_cost = 0,8*Q
 if(efficient_cost > 4*H): efficient_num,efficient_cost = 1,4*H
 if(efficient_cost > 2*S): efficient_num,efficient_cost = 2,2*S
  
 if(efficient_num == 0): min_cost += int(1/0.25)*Q
 elif(efficient_num == 1): min_cost += int(1/0.50)*H
 elif(efficient_num == 2): min_cost += 1*S
    
print(min_cost)

Problem: p03617
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
q,h,s,d=map(int,input().split())
n=int(input())

l=min(q*n*8,h*n*4,s*n*2,d*n)
if l != d*n:
    print(int(l/2))
else:
    m=min(q*4,h*2,s)
    print(int((d*(n-1)/2)+m) if n%2==1 else int(l/2))

Failing test case input:
11100 0010 111 -2
-1

Expected output:
22


Actual output:
-44400


Fixed submission (verdict: Accepted):
q,h,s,d=map(int,input().split())
n=int(input())
l=min(q*n*4,h*n*2,s*n,d*n
if l != d*n
    print(l)
else:
    m=min(q*4,h*2,s)
    print(int((d*(n-1)
Problem: p03617
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
q,h,s,d = map(int,input().split())
n = int(input())
value = [0]*4
value[0] = q*4
value[1] = h*2
value[2] = s
value[3] = d/2
dum = min(value)
ind = value.index(dum)
if ind == 0:
    print(value[0]*n)
elif ind == 1:
    print(value[1]*n)
elif ind == 2:
    print(value[2]*n)
else:
    if n == 1:
        value.sort()
        print(value[1])
    elif n%2 == 0:
        print(math.floor(value[3]*n))
    else:
        dum1 = n
        value.sort()
        print(math.floor(value[1]+dum1))

Failing test case input:
11100 0010 111 -2
-1

Expected output:
22


Actual output:
19


Fixed submission (verdict: Accepted):
import math
q,h,s,d = map(int,input().split())
n = int(input())
value = [0]*4
value[0] = q*4
value[1] = h*2
value[2] = s
value[3] = d/2
dum = min(value)
ind = value.index(dum)
if ind == 0:
    print(value[0]*n)
elif ind == 1:
    print(value[1]*n)
elif ind == 2:
    print(value[2]*n)
else:
    if n == 1:
        value.sort()
        print(value[1])
    elif n%2 == 0:
        print(math.floor(d*n
    else:
        dum1 = (n
        value.sort()
        print(math.floor(value[1]+dum1))

Problem: p03617
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
q, h, s, d = map(int, input().split())
n = int(input())

if n % 2 == 0:
    l = [4*q*n, 2*h*n, s*n, d*n/2]
    l.sort()
    print(int(l[0]))
else:
    l = [4*q*(n-1), 2*h*(n-1), s*(n-1), d*(n-1)/2]
    l_rest =  [4*q, 2*h, s]
    l.sort()
    l_rest.sort()
    print(int(l[0]+l_rest[0]))


Failing test case input:
01100 0111 000 -5
-6

Expected output:
15


Actual output:
-26400


Fixed submission (verdict: Accepted):
q, h, s, d = map(int, input().split())
n = int(input())

if n % 2 == 0:
    l = [4*q*n, 2*h*n, s*n, d*(n
    l.sort()
    print(int(l[0]))
else:
    l = [4*q*(n-1), 2*h*(n-1), s*(n-1), d*((n-1)
    l_rest =  [4*q, 2*h, s]
    l.sort()
    l_rest.sort()
    if n > 1:
        print(int(l[0]+l_rest[0]))
    elif n == 1:
        print(l_rest[0])

Problem: p03617
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
q,h,s,d=map(int,input().split())
n=int(input())
l=min(q*n*4,h*n*2,s*n,d*n/2)
if l != d*n/2:
    print(l)
else:
    m=min(q*4,h*2,s)
    print((d*(n-1)/2)+m if n%2==1 else l)

Failing test case input:
11100 0010 111 -2
-1

Expected output:
22


Actual output:
-44400


Fixed submission (verdict: Accepted):
q,h,s,d=map(int,input().split())
n=int(input())
l=min(q*n*4,h*n*2,s*n,d*n
if l != d*n
    print(l)
else:
    m=min(q*4,h*2,s)
    print(int((d*(n-1)
Problem: p03617
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    q, h, s, d = LI()
    n = II()
    q4 = q * 4
    h2 = h * 2
    l1 = min(q4, h2, s)
    l2 = min(l1 * 2, d)
    print((n >> 1) * l2 + (n & 1 * l1))
    
    return



if __name__ == '__main__':
    solve()


Failing test case input:
41015 95070 23088 46307626
30432

Expected output:
702614016


Actual output:
702635040


Fixed submission (verdict: Accepted):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10


def solve():
    q, h, s, d = LI()
    n = II()
    q4 = q * 4
    h2 = h * 2
    l1 = min(q4, h2, s)
    l2 = min(l1 * 2, d)
    print((n >> 1) * l2 + (n & 1) * l1)
    
    return



if __name__ == '__main__':
    solve()

Problem: p03617
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
q,h,s,d=map(int,input().split())
n=int(input())
cospa=[[q/0.25,0.25,q],[h/0.5,0.5,h],[s,1.0,s],[d/2,2.0,d]]
cospa.sort()
money=0
for i in range(4):
  if(n>=cospa[i][1]):
    x=n
    money+=x*cospa[i][2]
    n%=cospa[i][1]
print(int(money))

Failing test case input:
3065533 854010 10742875 54687163
69254

Expected output:
118287217080


Actual output:
59143608540


Fixed submission (verdict: Accepted):
q,h,s,d=map(int,input().split())
n=int(input())
cospa=[[q/0.25,0.25,q],[h/0.5,0.5,h],[s,1.0,s],[d/2,2.0,d]]
cospa.sort()
money=0
for i in range(4):
  if(n>=cospa[i][1]):
    x=int(n
    money+=int(x*cospa[i][2])
    n%=cospa[i][1]
print(int(money))
Problem: p03617
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
q,h,s,d=map(int,input().split())
n=int(input())
 
l=min(q*n*8,h*n*4,s*n*2,d*n)
if l != d*n:
    print(l/2)
else:
    m=min(q*4,h*2,s)
    print((d*(n-1)/2)+m if n%2==1 else l/2)

Failing test case input:
20 30 126 63
1

Expected output:
60


Actual output:
60.0


Fixed submission (verdict: Accepted):
q,h,s,d=map(int,input().split())
n=int(input())
 
l=min(q*n*8,h*n*4,s*n*2,d*n)
if l != d*n:
    print(l
else:
    m=min(q*4,h*2,s)
    print((d*(n-1))
Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):

























































r,c = map( int,input().split() )

data = []
csum = [0]*c

for i in range(r):
	data.append(  list(map( int,input().split() ))  )

for i in range( r ):
	for j in range(c):
		print("{0} ".format(data[i][j]), end="")
		csum[j] +=data[i][j]
	print( sum(data[i]) )






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

Expected output:
1 1 11 8 8 29
2 2 2 4 5 15
3 5 0 0 2 10
2 9 4 8 1 24
8 17 17 20 16 78


Actual output:
1 1 11 8 8 29
2 2 2 4 5 15
3 5 0 0 2 10
2 9 4 8 1 24


Fixed submission (verdict: Accepted):

























































r,c = map( int,input().split() )

data = []
csum = [0]*c

for i in range(r):
	data.append(  list(map( int,input().split() ))  )

for i in range( r ):
	for j in range(c):
		print("{0} ".format(data[i][j]), end="")
		csum[j] +=data[i][j]
	print( sum(data[i]) )

for j in range(c):
	print("{0} ".format( csum[j] ), end="" )

print( sum(csum) )

Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):
(r, c) = [int(i) for i in input().split()]

ct = [0 for d in range(c)]
tmp = []
for rc in range(r):
    tmp = [int(i) for i in input().split()]
    total = 0
    for cc in range(c):
        ct[cc] += tmp[cc]
        total += tmp[cc]
        print(tmp[cc], end=' ')
    print(total)
total = sum(ct)
print(' '.join([str(i) for i in tmp]), total)

Failing test case input:
4 5
2 1 3 4 13
2 2 2 5 5
3 3 0 1 1
2 6 4 1 11

Expected output:
2 1 3 4 13 23
2 2 2 5 5 16
3 3 0 1 1 8
2 6 4 1 11 24
9 12 9 11 30 71


Actual output:
2 1 3 4 13 23
2 2 2 5 5 16
3 3 0 1 1 8
2 6 4 1 11 24
2 6 4 1 11 71


Fixed submission (verdict: Accepted):
(r, c) = [int(i) for i in input().split()]

ct = [0 for d in range(c)]
tmp = []
for rc in range(r):
    tmp = [int(i) for i in input().split()]
    total = 0
    for cc in range(c):
        ct[cc] += tmp[cc]
        total += tmp[cc]
        print(tmp[cc], end=' ')
    print(total)
total = sum(ct)
print(' '.join([str(i) for i in ct]), total)
Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s) for s in sum_row]))

from pprint import pprint
pprint(data)
pprint(sum_row)

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

Expected output:
4 1 3 5 0 13
4 4 1 6 10 25
3 4 0 1 3 11
2 0 4 18 5 29
13 9 8 30 18 78


Actual output:
4 1 3 5 0 13
4 4 1 6 10 25
3 4 0 1 3 11
2 0 4 18 5 29
13 9 8 30 18 78
[[4, 1, 3, 5, 0, 13],
 [4, 4, 1, 6, 10, 25],
 [3, 4, 0, 1, 3, 11],
 [2, 0, 4, 18, 5, 29]]
[13, 9, 8, 30, 18, 78]


Fixed submission (verdict: Accepted):
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s) for s in sum_row]))

Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):
n,m = map(int,(input().split()))
a = []
for i in range(n):
    k = [int(i) for i in input().split()]
    k.append(sum(k))
    a.append(k)

for j in a:
    print(' '.join(map(str, j)))

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

Expected output:
1 0 1 5 8 15
2 2 2 4 5 15
3 3 0 1 1 8
2 3 4 4 0 13
8 8 7 14 14 51


Actual output:
1 0 1 5 8 15
2 2 2 4 5 15
3 3 0 1 1 8
2 3 4 4 0 13


Fixed submission (verdict: Accepted):
n,m = map(int,(input().split()))
a = []
s = []
for i in range(m):
    s.append(0)

for i in range(n):
    k = [int(i) for i in input().split()]
    k.append(sum(k))
    a.append(k)
    for j in range(m):
        s[j] += k[j]

s.append(sum(s))
a.append(s)

for j in a:
    print(' '.join(map(str, j)))
Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):
H,W = map(int,input().split())
table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split()))
    for col in range(W):
        table[row][col] = work[col]

for row in range(H):
    for col in range(W):
        table[row][W] += table[row][col]

for col in range(W):
    for row in range(H):
        table[H][col] += table[row][col]

for row in range(H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end="")
    print()
    



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

Expected output:
1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 2 9
2 6 0 8 6 22
8 12 5 17 21 63


Actual output:
1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 2 9
2 6 0 8 6 22
8 12 5 17 21 0


Fixed submission (verdict: Accepted):
H,W = map(int,input().split())
table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split()))
    for col in range(W):
        table[row][col] = work[col]

for row in range(H):
    for col in range(W):
        table[row][W] += table[row][col]

for col in range(W+1):
    for row in range(H):
        table[H][col] += table[row][col]

for row in range(H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end="")
    print()

Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):
r,c = map(int,input().split(' '))
arr = [[0 for i in range(c+1)] for i in range(r+1)]

for i in range(r):
    row = list(map(int,input().split(' ')))
    for j in range(c):
        arr[i][j] = row[j]

for i in range(r):
    for j in range(c):
        arr[i][-1] += arr[i][j]
for i in range(c):
    for j in range(r):
        arr[-1][i] += arr[j][i]
for i in range(r+1):
    arr[-1][-1] += arr[-1][i]

for i in range(r+1):
    for j in range(c):
        print(arr[i][j],end = ' ')
    print(arr[i][-1])

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

Expected output:
-2 0 2 3 9 12
-2 0 2 3 9 12


Actual output:
-2 0 2 3 9 12
-2 0 2 3 9 -2


Fixed submission (verdict: Accepted):
r,c = map(int,input().split(' '))
arr = [[0 for i in range(c+1)] for i in range(r+1)]

for i in range(r):
    row = list(map(int,input().split(' ')))
    for j in range(c):
        arr[i][j] = row[j]

for i in range(r):
    for j in range(c):
        arr[i][-1] += arr[i][j]
for i in range(c):
    for j in range(r):
        arr[-1][i] += arr[j][i]
        
if c == 1:
    for i in range(r):
        arr[-1][-1] += arr[i][0]
elif r == 1:
    for i in range(c):
        arr[-1][-1] += arr[0][i]
else:
    for i in range(r):
        arr[-1][-1] += arr[i][-1]
    
for i in range(r+1):
    for j in range(c):
        print(arr[i][j],end = ' ')
    print(arr[i][-1])
Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += [list(map(int, input().split()))]
    print(a)
    a[i] += [sum(a[i])]
for i in range(m+1):
    b += [sum(x[i] for x in a)]
a += [b]
for i in range(n+1):
    print(*a[i])


Failing test case input:
4 5
4 1 3 1 13
0 2 2 12 5
3 6 1 1 1
2 6 3 1 21

Expected output:
4 1 3 1 13 22
0 2 2 12 5 21
3 6 1 1 1 12
2 6 3 1 21 33
9 15 9 15 40 88


Actual output:
[[4, 1, 3, 1, 13]]
[[4, 1, 3, 1, 13, 22], [0, 2, 2, 12, 5]]
[[4, 1, 3, 1, 13, 22], [0, 2, 2, 12, 5, 21], [3, 6, 1, 1, 1]]
[[4, 1, 3, 1, 13, 22], [0, 2, 2, 12, 5, 21], [3, 6, 1, 1, 1, 12], [2, 6, 3, 1, 21]]
4 1 3 1 13 22
0 2 2 12 5 21
3 6 1 1 1 12
2 6 3 1 21 33
9 15 9 15 40 88


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += [list(map(int, input().split()))]
    a[i] += [sum(a[i])]
for i in range(m+1):
    b += [sum(x[i] for x in a)]
a += [b]
for i in range(n+1):
    print(*a[i])

Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):
r,c = map(int, input().split())
L=[]
for i in range(r):
 al = input()
 print(al, end="")
 AL = list(map(int, al.split()))
 S = sum(AL)
 print(" " + str(S))
 AL. append(S)
 L.append(AL)

for i in range(c):
 S = 0
 for j in range(r):
  S += L[j][i]
 print(str(S) + " ", end="")
print()

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

Expected output:
1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 2 9
2 6 4 8 6 26
8 12 9 17 21 67


Actual output:
1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 2 9
2 6 4 8 6 26
8 12 9 17 21 


Fixed submission (verdict: Accepted):
r,c = map(int, input().split())
L=[]
for i in range(r):
 al = input()
 print(al, end="")
 AL = list(map(int, al.split()))
 S = sum(AL)
 print(" " + str(S))
 AL. append(S)
 L.append(AL)

for i in range(c):
 S = 0
 for j in range(r):
  S += L[j][i]
 print(str(S) + " ", end="")

S = 0
for j in range(r):
 S += L[j][-1]
print(str(S))
Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):
(r,c) = [int(i) for i in input().split()]

table = []
for rc in range(r):
    table.append([int(i) for i in input().split()])

table.append([0 for  _ in range(c)])

for rc in range(r):
    row_total = 0
    for cc in range(c):
        table[r][cc] += table[rc][cc]
        row_total += table[rc][cc]

    table[rc].append(row_total)

for row in table:
    for column in row:
        print(column,end=' ')

    print()

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

Expected output:
1 1 3 4 8 17
2 2 2 4 5 15
3 3 0 1 2 9
2 6 4 8 6 26
8 12 9 17 21 67


Actual output:
1 1 3 4 8 17 
2 2 2 4 5 15 
3 3 0 1 2 9 
2 6 4 8 6 26 
8 12 9 17 21 


Fixed submission (verdict: Accepted):
(r,c) = [int(i) for i in input().split()]

table = []
for rc in range(r):
    table.append([int(i) for i in input().split()])

table.append([0 for  _  in range(c + 1)])

for rc in range(r):
    row_total = 0
    for cc in range(c):
        table[r][cc] += table[rc][cc]
        row_total += table[rc][cc]

    table[rc].append(row_total)
    table[r][c] += row_total

for row in table:
   print(' '.join([str(column) for column in row]))

Problem: p02413
Buggy submission (Python3, verdict: Wrong Answer):
r,c=map(int, input().split())
for i in range(r):
    a=list(map(int, input().split()))
    a.append(sum(a))
    print(*a)


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

Expected output:
2 1 3 5 1 12
4 3 1 6 10 24
3 4 0 1 2 10
2 6 4 21 5 38
11 14 8 33 18 84


Actual output:
2 1 3 5 1 12
4 3 1 6 10 24
3 4 0 1 2 10
2 6 4 21 5 38


Fixed submission (verdict: Accepted):
r,c=map(int, input().split())
total=[0]*(c+1)
for i in range(r):
    a=list(map(int, input().split()))
    a.append(sum(a))
    print(*a)
    for j in range(c+1):
        total[j]+=a[j]
print(*total)
Problem: p02867
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
ail=[(i,a) for i,a in enumerate(al)]
bil=[(i,b) for i,b in enumerate(bl)]
ail=sorted(ail,key=lambda x:x[1])
bil=sorted(bil,key=lambda x:x[1])
if not all([ail[i][1]<=bil[i][1] for i in range(n)]):
    print('No')
    exit()
if any([ail[i][0]==bil[i][0] for i in range(n)]):
    print('Yes')
    exit()
c=[(ail[i][0],bil[i][0]) for i in range(n)]
c=sorted(c)
idx=0
for _ in range(n-2):
    idx=c[idx][1]
    if idx==0:
        print('Yes')
        break
else:
    print('No')

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

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n=int(input())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
ail=[(i,a) for i,a in enumerate(al)]
bil=[(i,b) for i,b in enumerate(bl)]
ail=sorted(ail,key=lambda x:x[1])
bil=sorted(bil,key=lambda x:x[1])
if not all([ail[i][1]<=bil[i][1] for i in range(n)]):
    print('No')
    exit()
if any([ail[i+1][1]<=bil[i][1] for i in range(n-1)]):
    print('Yes')
    exit()
c=[(ail[i][0],bil[i][0]) for i in range(n)]
c=sorted(c)
idx=0
for _ in range(n-1):
    idx=c[idx][1]
    if idx==0:
        print('Yes')
        break
else:
    print('No')
Problem: p02867
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 998244353
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def init(n):
  for i in range(N+1):
    par[i] = i
    rnk[i] = 0
def find(x):
  if par[x] == x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]
def unite(x, y):
  x = find(x)
  y = find(y)
  if x == y:
    return
  if (rnk[x] < rnk[y]):
    par[x] = y
  else:
    par[y] = x
    if(rnk[x] == rnk[y]):
      rnk[x] += 1
def same(x, y):
  return find(x) == find(y)

N = I()
a = IL()
b = IL()

par = [0 for i in range(N+1)]
rnk = [0 for i in range(N+1)]
init(N)

adata = []
bdata = []
for i in range(N):
  adata.append([a[i], i])
  bdata.append([b[i], i])
adata.sort()
bdata.sort()
print(adata)
print(bdata)

for i in range(N-1):
  atmp, aID = adata[i]
  btmp, bID = bdata[i]
  atmp2, aID2 = adata[i + 1]
  btmp2, bID2 = bdata[i + 1]
  if atmp > btmp or atmp2 > btmp2:
    print("No")
    exit()
  if atmp2 <= btmp:
    print("Yes")
    exit()

for i in range(N-1):
  atmp, aID = adata[i]
  btmp, bID = bdata[i]
  
  
  
  if aID == bID:
    break
  if same(aID, bID):
    break
  else:
    unite(aID, bID)
else:
  print("No")
  exit()
print("Yes")

Failing test case input:
3
1 -3 2
-1 14 8

Expected output:
Yes


Actual output:
[[-3, 1], [1, 0], [2, 2]]
[[-1, 0], [8, 2], [14, 1]]
Yes


Fixed submission (verdict: Accepted):
import sys
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 998244353
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def init(n):
  for i in range(N+1):
    par[i] = i
    rnk[i] = 0
def find(x):
  if par[x] == x:
    return x
  else:
    par[x] = find(par[x])
    return par[x]
def unite(x, y):
  x = find(x)
  y = find(y)
  if x == y:
    return
  if (rnk[x] < rnk[y]):
    par[x] = y
  else:
    par[y] = x
    if(rnk[x] == rnk[y]):
      rnk[x] += 1
def same(x, y):
  return find(x) == find(y)

N = I()
a = IL()
b = IL()

par = [0 for i in range(N+1)]
rnk = [0 for i in range(N+1)]
init(N)

adata = []
bdata = []
for i in range(N):
  adata.append([a[i], i])
  bdata.append([b[i], i])
adata.sort()
bdata.sort()



a.sort()
b.sort()
f = 0
for i in range(N-1):
  atmp = a[i]
  btmp = b[i]
  atmp2 = a[i + 1]
  btmp2 = b[i + 1]
  if atmp > btmp:
    print("No")
    exit()
  if atmp2 > btmp2:
    print("No")
    exit()
  if atmp2 <= btmp:
    f = 1
else:
  if f == 1:
    print("Yes")
    exit()

for i in range(N-1):
  atmp, aID = adata[i]
  btmp, bID = bdata[i]
  
  
  
  if aID == bID:
    break
  if same(aID, bID):
    break
  else:
    unite(aID, bID)
else:
  print("No")
  exit()
print("Yes")
Problem: p02867
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

N=int(input())

a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa=[[a[i],i] for i in range(N)]
bb=[[b[i],i] for i in range(N)]
aa.sort()
bb.sort()


for i in range(N):
    if aa[i][0]>bb[i][0]: print("No"),sys.exit()


for i in range(N-1):
    if aa[i][0]==aa[i+1][0] or bb[i][0]==bb[i+1][0]: print("Yes"),sys.exit()
    if bb[i][0]>=aa[i+1][0]: print("Yes"),sys.exit()


dicb={}
for i in range(N):
    dicb[bb[i][0]]=i


tmp=1
j=0
print(dicb)

while tmp<N-1:
    j=dicb[b[j]]
    if j==0: print("Yes"),sys.exit()
    tmp+=1
    
print("No")

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

Expected output:
Yes

Actual output:
{1: 0, 2: 1, 3: 2}
Yes


Fixed submission (verdict: Accepted):
import sys

N=int(input())

a=list(map(int,input().split()))
b=list(map(int,input().split()))
xx=[[b[i],a[i]] for i in range(N)]
xx.sort()

a=[xx[i][1] for i in range(N)]

aa=[[xx[i][1],i] for i in range(N)]
bb=[[xx[i][0],i] for i in range(N)]

aa.sort()
bb.sort()


for i in range(N):
    if aa[i][0]>bb[i][0]:
        print("No")
        sys.exit()

for i in range(N-1):
    if aa[i][0]==aa[i+1][0] or bb[i][0]==bb[i+1][0]:
        print("Yes")
        sys.exit()

for i in range(1,N):
    if aa[i][0]<=bb[i-1][0]:
        print("Yes")
        sys.exit()


dic={}
for i in range(N):
    dic[aa[i][0]]=i

inij=1
cycle=1
j=inij

while True:
    j=dic[a[j]]
    if j==inij:
        break
    cycle+=1

print("Yes" if cycle<N else "No")
Problem: p02867
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))



N = I()
A = III()
B = III()

from bisect import bisect_left



def index_sort(A):
    a = []
    for i,x in enumerate(A):
        a.append([i,x])
    return sorted(a,key=lambda x: x[1])

A2 = sorted(A)
B2 = sorted(B)

for i in range(N):
    if A2[i]>B2[i]:
        print('No')
        exit()

for i in range(N-1):
    if B2[i]>=A2[i+1]:
        print('Yes')
        exit()

print('No')

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

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))



N = I()
A = III()
B = III()

def index_sort(A):
    a = []
    for i,x in enumerate(A):
        a.append([i,x])
    asort = sorted(a,key=lambda x: x[1])
    return [asort[i][0] for i in range(len(a))]

A2 = sorted(A)
B2 = sorted(B)

for i in range(N):
    if A2[i]>B2[i]:
        print('No')
        exit()

Aindex = index_sort(A)
Bindex = index_sort(B)
move = [0]*N
for i in range(N):
    move[Aindex[i]] = Bindex[i]

now = 0
for i in range(N):
    if move[now]==0 and i!=N-1:
        print('Yes')
        exit()
    now = move[now]

for i in range(N-1):
    if B2[i]>=A2[i+1]:
        print('Yes')
        exit()

print('No')