Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03161 (python)

Fixed submission:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

dp = [float("inf") for i in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i]+abs(a[i+j]-a[i]))

print(dp[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split())) + [0]*100010

dp = [float("inf")]*100010
dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]))
    # print(dp)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split())) + [0]*100010

dp = [float("inf")]*100010
dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]))
    # print(dp)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = list(map(int, input().split())) + [0]*100010

dp = [float("inf")]*100010
dp[0] = 0

for i in range(N):
    for k in range(1, K+1):
        dp[i+k] = min(dp[i+k], dp[i] + abs(h[i+k] - h[i]))
    # print(dp)
print(dp[N-1])
Problem p03163 (python)

Fixed submission:
N, W = map(int, input().split())
dp = [-1]*(W+1)
dp[0] = 0
for _ in range(N):
    w, v = map(int, input().split())
    for i in range(W-w, -1, -1):
        if dp[i] == -1:
            continue
        if dp[i+w] < dp[i] + v:
            dp[i+w] = dp[i] + v
print(max(dp))

Buggy submission (verdict: Runtime Error):
import numpy as np
n, W = map(int, input().split())
dp = np.zeros((n,W+1), dtype='int64')

for i in range(n):
    w, v = map(int , input().split())

    # print("left", dp[i, :w])
    # print("right", dp[i-1, :w])
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.fmax(dp[i-1, w:], dp[i-1,:W-w+1]+v)

    # print(dp[i])
print(dp[n-1][W])

Buggy submission (verdict: Runtime Error):
import numpy as np
n, W = map(int, input().split())
dp = np.zeros((n,W+1), dtype='int64')

for i in range(n):
    w, v = map(int , input().split())

    # print("left", dp[i, :w])
    # print("right", dp[i-1, :w])
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.fmax(dp[i-1, w:], dp[i-1,:W-w+1]+v)

    # print(dp[i])
print(dp[n-1][W])

Buggy submission (verdict: Runtime Error):
import numpy as np
n, W = map(int, input().split())
dp = np.zeros((n,W+1), dtype='int64')

for i in range(n):
    w, v = map(int , input().split())

    # print("left", dp[i, :w])
    # print("right", dp[i-1, :w])
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.fmax(dp[i-1, w:], dp[i-1,:W-w+1]+v)

    print(dp[i])
# print(dp[n-1][W])
Problem p03168 (python)

Fixed submission:
N = int(input())
p = list(map(float, input().split()))

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
# dp[0][0] = 1-p[0]
# dp[0][1] = p[0]

for i in range(N):
    for j in range(i+1):
        # print(f"i {i}, j {j}")
        # print(f"p[i] {p[i]}, dp[i][j] {dp[i][j]}")

        if i == 0:
            dp[i+1][j] += 1-p[i]
            dp[i+1][j+1] += p[i]
        else:
            dp[i+1][j] += (1-p[i])*dp[i][j]
            dp[i+1][j+1] += p[i]*dp[i][j]
        # print("dp", dp)

ans = 0
for i, v in enumerate(dp[-1]):
    if i > N//2:
        ans += v

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(float, input().split()))

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
# dp[0][0] = 1-p[0]
# dp[0][1] = p[0]

for i in range(N):
    for j in range(i+1):
        # print(f"i {i}, j {j}")
        # print(f"p[i] {p[i]}, dp[i][j] {dp[i][j]}")

        if i == 0:
            dp[i+1][j] += 1-p[i]
            dp[i+1][j+1] += p[i]
        else:
            dp[i+1][j] += (1-p[i])*dp[i][j]
            dp[i+1][j+1] += p[i]*dp[i][j]
        # print("dp", dp)

ans = 0
for i, v in enumerate(dp[-1]):
    if i > N//2:
        ans += v
print(ans)N = int(input())
p = list(map(float, input().split()))

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
# dp[0][0] = 1-p[0]
# dp[0][1] = p[0]

for i in range(N):
    for j in range(i+1):
        # print(f"i {i}, j {j}")
        # print(f"p[i] {p[i]}, dp[i][j] {dp[i][j]}")

        if i == 0:
            dp[i+1][j] += 1-p[i]
            dp[i+1][j+1] += p[i]
        else:
            dp[i+1][j] += (1-p[i])*dp[i][j]
            dp[i+1][j+1] += p[i]*dp[i][j]
        # print("dp", dp)

ans = 0
for i, v in enumerate(dp[-1]):
    if i > N//2:
        ans += v
print(ans)
Problem p03196 (python)

Fixed submission:
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N, P = map(int, input().split())

l = Counter(prime_factorize(P))

ans = 1

for i, v in l.items():
    if v >= N:
        ans *= i**(v//N)
#     print(ans)
# print(l)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N, P = map(int, input().split())

l = Counter(prime_factorize(P))

ans = 1
min_l = min(l.items(), key=lambda x:x[0])
# print(min_l)

for i, v in l.items():
    if v >= N:
        ans *= i*(v//N)
#     print(ans)
# print(l)
print(ans)
Problem p03262 (python)

Fixed submission:
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

n, x = list(map(int, input().split()))
b = list(map(int, input().split()))

a = []
for i in b:
    if i != x:
        a.append(abs(i-x))
print(gcd(a))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce

def gcd(numbers):
    return reduce(gcd, numbers)

n, x = list(map(int, input().split()))
b = list(map(int, input().split()))

a = []
for i in b:
    if i != x:
        a.append(abs(i-x))
print(gcd(a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

n, x = list(map(int, input().split()))
b = list(map(int, input().split()))

a = []
for i in b:
    if i != x:
        a.append(abs(i-x))
print(gcd(a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

n, x = list(map(int, input().split()))
b = list(map(int, input().split()))

a = []
for i in b:
    a.append(abs(i-x))
print(gcd(a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

n, x = list(map(int, input().split()))
b = list(map(int, input().split()))

a = []
for i in b:
    a.append(abs(i-x))
print(gcd(a))
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
lens = len(s)
ans = 1
for i in range(k):
    if i == lens:
        break
    if s[i] != "1":
        ans= s[i]
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
s = input()
if s == n[0] == 1:
  print(1)
else:
  print(n[1])
Problem p03340 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))+[0]

su = 0
ans = 0
right = 0

for left in range(N):
    while (left == right or su+A[right] == su^A[right]) and right < N:
        su += A[right]
        right += 1
    ans += right-left
    su -= A[left]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

xor = 0
sumA = 0

ans = 0
right = 0

for left in range(N):
    while right<N and tmp*s[right] <=K:
        tmp *= s[right]
        right += 1
    ans = max(ans, right-left)
    if right == left:
        right += 1
    else:
        tmp //= s[left]
print(ans)
Problem p03399 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a,b)+min(c,d))

Buggy submission (verdict: Runtime Error):
a,b,c,d = list(map(int,input().split()))
print(min(a,b)+min(c,d))
Problem p03417 (python)

Fixed submission:
n, m = list(map(int, input().split()))
if n == 2 or m == 2:
    print(0)
elif n == 1 or m == 1:
    print(max(1,n*m-2))
else:
    print((n-2)*(m-2))

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
if n>=3 and m>=3:
    print((n-2)*(m-2))
elif n == 1 or m == 1:
    print(n*m-2)
elif :
    print(0)
Problem p03569 (python)

Fixed submission:
s = input()

ans = 0

l, r = 0, len(s)-1
if len(s) != 1:
    while l < r:
        # print("l", l, "r", r)
        if s[l] == s[r]:
            l += 1
            r -= 1
        else:
            if s[l] == "x":
                l += 1
                ans += 1
            elif s[r] == "x":
                r -= 1
                ans += 1
            else:
                ans = -1
                break

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()

ans = 0

l, r = 0, len(s)-1
if len(s) != 1:
    while l != r:
        # print("l", l, "r", r)
        if s[l] == s[r]:
            l += 1
            r -= 1
        else:
            if s[l] == "x":
                l += 1
                ans += 1
            elif s[r] == "x":
                r -= 1
                ans += 1
            else:
                ans = -1
                break

print(ans)
Problem p03574 (python)

Fixed submission:
H,W = map(int,input().split())
src = [input() for i in range(H)]
 
ans = []
for row in src:
    ans.append(list(row))
 
dxy = [(-1,-1),(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1)]
for y in range(H):
    for x in range(W):
        if src[y][x] == '#': continue
        c = 0
        for dx,dy in dxy:
            if x+dx < 0 or x+dx > W-1 or y+dy < 0 or y+dy > H-1: continue
            if src[y+dy][x+dx] == '#': c += 1
        ans[y][x] = c
 
for row in ans:
    print(''.join(list(map(str,row))))

Buggy submission (verdict: Runtime Error):
a,b = list(map(int, input().split()))
s = [input() for i in range(a)]
num = []
for i in range(a):
    ss = s[i]
    numm = []
    for j in range(b):
        if  ss[j]== ".":
            numm.append(0)
        else:
            numm.append("#")
    num.append(numm)
#四隅の判定
if num[0][0] == 0:
    if num[0][1] == "#":
        num[0][0] += 1
    if num[1][0] == "#":
        num[0][0] += 1
    if num[1][1] == "#":
        num[0][0] += 1

if num[0][-1] == 0:
    if num[0][-2] == "#":
        num[0][-1] += 1
    if num[1][-1] == "#":
        num[0][-1] += 1
    if num[1][-2] == "#":
        num[0][-1] += 1

if num[-1][0] == 0:
    if num[-1][1] == "#":
        num[-1][0] += 1
    if num[-2][0] == "#":
        num[-1][0] += 1
    if num[-2][1] == "#":
        num[-1][0] += 1

if num[-1][-1] == 0:
    if num[-1][-2] == "#":
        num[-1][-1] += 1
    if num[-2][-1] == "#":
        num[-1][-1] += 1
    if num[-2][-2] == "#":
        num[-1][-1] += 1

for i in range(1,a-1):
    for j in range(1,b-1):
        if num[i][j] == 0:
            num[i][j] += num[i-1][j-1:j+2].count("#")
            num[i][j] += str(num[i][j-1]).count("#")
            num[i][j] += str(num[i][j+1]).count("#")
            num[i][j] += num[i+1][j-1:j+2].count("#")

for i in range(1,b-1):
    if num[0][i] == 0:
        num[0][i] += str(num[0][i-1]).count("#")
        num[0][i] += str(num[0][i+1]).count("#")
        num[0][i] += num[1][i-1:i+2].count("#")
    if num[-1][i] == 0:
        num[-1][i] += num[-2][i-1:i+2].count("#")
        num[-1][i] += str(num[-1][i-1]).count("#")
        num[-1][i] += str(num[-1][i+1]).count("#")

for i in range(1,a-1):
    if num[i][0] == 0:
        num[i][0] += str(num[i-1][0:2]).count("#")
        num[i][0] += str(num[i][1]).count("#")
        num[i][0] += num[i+1][0:2].count("#")
    if num[i][-1] == 0:
        num[i][-1] += num[i-1][-2:].count("#")
        num[i][-1] += str(num[i][-2]).count("#")
        num[i][-1] += str(num[i+1][-2:]).count("#")

for i in num:
    print("".join(list(map(str,i))))
Problem p03578 (python)

Fixed submission:
from collections import defaultdict
n = int(input())
d = tuple(map(int, input().split()))
m = int(input())
t = tuple(map(int, input().split()))
l = defaultdict(int)
for x in d:
    l[x] += 1
for y in t:
    if l[y] == 0:
        print('NO')
        exit()
    l[y] -= 1
print('YES')

Buggy submission (verdict: Runtime Error):
N = int(input())
D = list(map(int, input().split()))

M = int(input())
T = list(map(int, input().split()))

d = [0 for _ in range(200005)]
t = [0 for _ in range(200005)]

ans = "YES"

for i in range(N):
    d[D[i]] += 1

for i in range(M):
    t[T[i]] += 1

for i in range(len(d)):
    if t[i] > d[i]:
        ans = "NO"

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = list(map(int, input().split()))

M = int(input())
T = list(map(int, input().split()))

d = [0 for _ in range(200005)]

ans = "YES"

for i in range(N):
    d[D[i]] += 1

for i in range(M):
    # print(d[T[i]-1])
    d[T[i]] -= 1
    if d[T[i]] < 0:
        ans = "NO"
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = list(map(int, input().split()))

M = int(input())
T = list(map(int, input().split()))

d = [0 for _ in range(2000005)]

ans = "YES"

for i in range(N):
    d[D[i]] += 1

# print(d)
for i in range(M):
    # print(d[T[i]-1])
    d[T[i]] -= 1
    if d[T[i]] < 0:
        ans = "NO"
        break
# print(d)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
D = list(map(int, input().split()))

M = int(input())
T = list(map(int, input().split()))

d = [0 for _ in range(2000005)]

ans = "YES"

for i in range(N):
    d[D[i]-1] += 1

# print(d)
for i in range(M):
    # print(d[T[i]-1])
    d[T[i]-1] -= 1
    if d[T[i]-1] < 0:
        ans = "NO"
        break
# print(d)
print(ans)
Problem p03593 (python)

Fixed submission:
from collections import Counter
h,w=map(int,input().split())
s=""
for i in range(h):
  s+=input()
sc=Counter(s)
d=[0,0,0]
for v in sc.values():
    d[0]+=(v//4)*4
    d[1]+=2 if v%4>=2 else 0
    d[2]+=v%2

if w%2==0 and h%2==0:
  print("Yes" if d[0]==h*w else "No")
elif (w%2)*(h%2)==1:
  print("Yes" if d[1]<=(w-1)+(h-1) and d[2]==1 else "No")
elif w%2==0:
  print("Yes" if d[1]<=w and d[2]==0 else "No")
elif h%2==0:
  print("Yes" if d[1]<=h and d[2]==0 else "No")

Buggy submission (verdict: Runtime Error):
from collections import Counter
h,w=map(int,input().split())
s=""
for i in range(h):
  s+=input()
sc=Counter(s)
d=[0,0,0]
for v in sc.values():
    d[0]+=(v//4)*4
    d[1]+=2 if v%4>=2 else 0
    d[2]+=v%2

if w%2==0 and h%2==0:
  print("Yes" if d[0]==h*w else "No")
elif (w%2)*(h%2)==1:
  print("Yes" if d[1]<=(w-1)+(h-1) and d[2]==1 else "No")
elif w%2==0:
  print("Yes" if d[1]<=w and d[2]==0 else "No")
elif h%2==0:
  print("Yes" if d[1]<=h and d[2]==0 else "No")

from collections import Counter
h,w=map(int,input().split())
s=""
for i in range(h):
  s+=input()
sc=Counter(s)
d=[0,0,0]
for v in sc.values():
    d[0]+=(v//4)*4
    d[1]+=2 if v%4>=2 else 0
    d[2]+=v%2

if w%2==0 and h%2==0:
  print("Yes" if d[0]==h*w else "No")
elif (w%2)*(h%2)==1:
  print("Yes" if d[1]<=(w-1)+(h-1) and d[2]==1 else "No")
elif w%2==0:
  print("Yes" if d[1]<=w and d[2]==0 else "No")
elif h%2==0:
  print("Yes" if d[1]<=h and d[2]==0 else "No")

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())

# if n*m%2 == 0:
#     if k%2 == 0 and k >= min(n, m):
#         ans = 1
#     else:
#         ans = 0
# else:
#     ans = 1

# if ans:
#     print("Yes")
# else:
#     print("No")

n,m,K=map(int,input().split());print("YNeos"[all(k*m-K+l*n-k*l*2for k in range(n+1)for l in range(m+1))::2])
Problem p03607 (python)

Fixed submission:
n = int(input())
a = [input() for i in range(n)]

count = 0
dic = {}

for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

for i in dic.values():
    if i%2 == 1:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
a = [input() for i in range(n)]
 
count = 0
dic = collections.Counter(l)
 
for i in dic.values():
    if i%2 == 1:
        count += 1
 
print(count)
Problem p03625 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

dic = {}
for i in A:
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1
two = []
four = []
for j, k in dic.items():
	if k>=4:
		four.append(j)
	if k>=2:
		two.append(j)
two.sort(reverse=True)
four.sort(reverse=True)
if len(four) == 0:
	if len(two) <= 1:
		print(0)
	else:
		print(two[0]*two[1])	
else:
	if len(two) <= 1:
		print(four[0]**2)
	else:	
		print(max(two[0]*two[1], four[0]**2))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

dic = {}
for i in A:
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1
two = []
four = []
for j, k in dic.items():
	if k>=4:
		four.append(j)
	elif k>=2:
		two.append(j)
two.sort(reverse=True)
four.sort(reverse=True)
if len(four) == 0:
	if len(two) <= 1:
		print(0)
	else:
		print(two[0]*two[1])	
else:
	print(max(two[0]*two[1], four[0]**2))
Problem p03633 (python)

Fixed submission:
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
t = [int(input()) for i in range(n)]
print(lcm_list(t))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
t = [int(input()) for i in range(n)]
print(lcm_list(t))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
t = [int(input()) for i in range(n)]
print(lcm_list(t))
Problem p03713 (python)

Fixed submission:
H, W = list(map(int, input().split()))
ans = []

#目,円
for i in range(1, H):
    area1 = W*i
    area2 = (H-i)//2*W
    area3 = (H-(H-i)//2-i)*W
    area4 = (H-i)*(W//2)
    area5 = (H-i)*(W-(W//2))
    if area1 != 0 or area2 != 0 or area3 !=0:
        ans.append(max(area1, area2, area3)-min(area1, area2, area3))
    if area1 != 0 or area4 != 0 or area5 !=0:
        ans.append(max(area1, area4, area5)-min(area1, area4, area5))

#皿、ト
for i in range(1, W):
    area6 = H*i
    area7 = (W-i)//2*H
    area8 = (W-(W-i)//2-i)*H
    area9 = (W-i)*(H//2)
    area10 = (W-i)*(H-(H//2))
    if area6 != 0 or area7 != 0 or area8 !=0:
        ans.append(max(area6, area7, area8)-min(area6, area7, area8))
    if area6 != 0 or area9 != 0 or area10 !=0:
        ans.append(max(area6, area9, area10)-min(area6, area9, area10))

print(min(ans))

Buggy submission (verdict: Runtime Error):
def max(iterable, *, default, key)
max(iterable, *[, default=obj, key=func]) -> value max(arg1, arg2, *args, *[, key=func]) -> value

With a single iterable argument, return its biggest item. The default keyword-only argument specifies an object to return if the provided iterable is empty. With two or more arguments, return the largest argument.
Problem p03759 (python)

Fixed submission:
a,b,c = list(map(int, input().split()))
if b-a == c-b:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = list(map(int, input().split()))
if b−a==c−b:
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = list(map(int, input().split()))
if b−a==c−b:
  print("YES")
else:
  print("NO")
Problem p03944 (python)

Fixed submission:
w, h, n = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
 
x1 = 0
x2 = w
y1 = 0
y2 = h
for i in range(n):
	if a[i][2] == 1:
		x1 = max(x1, a[i][0])
	elif a[i][2] == 2:
		x2 = min(x2, a[i][0])
	elif a[i][2] == 3:
		y1 = max(y1,a[i][1])
	elif a[i][2] == 4:
		y2 = min(y2, a[i][1])

if (x2-x1) < 0 or (y2-y1) < 0:
	print(0)
else:
	print((x2-x1)*(y2-y1))

Buggy submission (verdict: Runtime Error):
w, h, n = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
 
x1 = 0
x2 = w
y1 = 0
y2 = h
for i in range(n):
    if a[i][2] == 1:
        x1 = max(x1, a[i][0])
    elif a[i][2] == 2:
        x2 = min(x2, a[i][0])
    elif a[i][2] == 3:
        y1 = max(y1,a[i][1])
	elif a[i][2] == 4:
        y2 = min(y2, a[i][1])
print(max(0,(x2-x1)*(y2-y1)))
Problem p03958 (python)

Fixed submission:
k, t = map(int, input().split())
a = list(map(int, input().split()))

print(max(max(a)-1-sum(a)+max(a), 0))

Buggy submission (verdict: Runtime Error):
k, t = map(int, input().split())
a = list(map(int, input().split()))

ans = max(a)

for i in a:
    if i != max(a):
        ans -= i
print(max(0, ans)

Buggy submission (verdict: Runtime Error):
k, t = map(int, input().split())
a = list(map(int, input().split()))

ans = max(a)

for i in a:
  if i != max(a):
    ans -= i
print(max(0, ans)
Problem p02585 (python)

Fixed submission:
n, k = map(int, input().split())
P = [int(x)-1 for x in input().split()]
C = [int(x) for x in input().split()]

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

res = -10000000000000000000000
for i in range(0,n):
	if vis[i] == 0:
		su = 0
		vis[i] = 1
		v = []
		v.append(C[i])
		su += C[i]
		x = P[i]
		while x != i:
			vis[x] = 1
			su += C[x]
			v.append(C[x])
			x = P[x]
		vs = len(v)
		for ii in range(vs):
			umm = 0
			for j in range(min(k,vs)):
				x = (ii+j)%vs
				umm += v[x]
				steps = 1+(x-ii+vs)%vs
				if k >= vs:
					if(su > 0):
						r = max((k-steps)//vs,0)
						res = max(res, r*su + umm)
					else:
						res = max(res,umm)
				else:
					if steps <= k:
						res = max(res,umm)


print(res)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
P = [int(x)-1 for x in input().split()]
C = [int(x) for x in input().split()]

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

res = -10000000000000000000000
for i in range(0,n):
	if vis[i] == 0:
		su = 0
		vis[i] = 1
		v = []
		v.append(C[i])
		su += C[i]
		x = P[i]
		while x != i:
			vis[x] = 1
			su += C[x]
			v.append(C[x])
			x = P[x]
		vs = len(v)
		for ii in range(vs):
			umm = 0
			for j in range(vis):
				x = (ii+j)%vs
				umm += v[x]
				steps = 1+(x-ii+vs)%vs
				if k >= vs:
					if(su > 0):
						r = max((k-steps)//vs,0)
						res = max(res, r*su + umm)
					else:
						res = max(res,umm)
				else:
					if steps <= k:
						res = max(res,umm)


print(res)
Problem p02554 (python)

Fixed submission:
import math
n=int(input())
m=((10**n)-(2*(9**n))+(8**n))%1000000007
print(m)

Buggy submission (verdict: Runtime Error):
import math
n=int(input)
m=(10**n)-(2*(9**n))+(8**n)
print(m%1000000007)
Problem p02573 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**7)

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

visited=[0]*N
frnds=[[] for i in range(N)]

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

for i in range(N):
    frnds[i]=list(set(frnds[i]))

def saiki(num):
    value=1
    visited[num]=1
    for f in frnds[num]:
        if visited[f]!=1:
            value+=saiki(f)
    return value

ans=0
for i in range(N):
    if visited[i]!=1:
        ans=max(saiki(i),ans)

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

visited=[0]*N
frnds=[[] for i in range(N)]

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

for i in range(N):
    frnds[i]=list(set(frnds[i]))

def saiki(num):
    value=1
    visited[num]=1
    for f in frnds[num]:
        if visited[f]!=1:
            value+=saiki(f)
    return value

ans=0
for i in range(N):
    if visited[i]!=1:
        ans=max(saiki(i),ans)

print(ans)