Harryxun/testdata huggingface dataset:
Buggy python 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))))

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


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


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


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


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



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 python 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])


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

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 python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [input().split() for i in range(n)]

count = 0
 
for i in a:
    ii = a.count(i)
    if ii%2 ==1:
        count += 1

print(count)

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 python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [input().split() for i in range(n)]

l_c = []
count = 0

for i in a:
    ii = a.count(i)
    l_c.append(ii)
    
for i in l_c:
    if i%2 == 1:
        count += 1

print(count)

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 python submission (verdict: Time Limit Exceeded):
from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

N, M, R = map(int, input().split())
r = list(map(int, input().split()))

road = [[float("inf")]*N for _ in range(N)]

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

for j in range(N):
    road[j][j] = 0

road = warshall_floyd(road)

# print(road)
ans = float("inf")

for v in permutations(r, len(r)):
    # print("v", v)
    tmp = 0
    for i in range(len(r)-1):
        tmp += road[v[i]-1][v[i+1]-1]
    # print(tmp)
    ans = min(ans, tmp)

print(ans)

Fixed submission:
from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

N, M, R = map(int, input().split())
r = list(map(int, input().split()))

road = [[float("inf")]*N for _ in range(N)]

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

for j in range(N):
    road[j][j] = 0

road = warshall_floyd(road)

# print(road)
ans = float("inf")

for v in permutations(r, len(r)):
    # print("v", v)
    tmp = 0
    for i in range(len(r)-1):
        tmp += road[v[i]-1][v[i+1]-1]
    # print(tmp)
    ans = min(ans, tmp)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = []
a_s = sorted(a)
for i in range(len(a)):
    for j in range(len(a)):
        if a_s[j]-a_s[i] <= 2:
            ans.append(j-i+1)

print(max(ans))

Fixed submission:

n = int(input())
cnt = [0] * 100002
a = list(map(int, input().split()))
for v in a:
    cnt[v] += 1
    cnt[v+1] += 1
    cnt[v+2] += 1
    
print(max(cnt))
Buggy python 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))

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

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

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 python submission (verdict: Runtime Error):
def dfs(st, depth=0):
    dist[st] = depth
    for to, c in tree[st]:
        if dist[to]>=0:
            continue
        dfs(to, depth+c)


N = int(input())
tree = [[] for _ in range(N)]
dist = [-1]*N

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

Q, K = map(int, input().split())
dfs(K-1, 0)
# print(dist)
# print(tree)
for _ in range(Q):
    x, y = map(int, input().split())
    print(dist[x-1]+dist[y-1])

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

def dfs(st, depth=0):
    dist[st] = depth
    for to, c in tree[st]:
        if dist[to]>=0:
            continue
        dfs(to, depth+c)


N = int(input())
tree = [[] for _ in range(N)]
dist = [-1]*N

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

Q, K = map(int, input().split())
dfs(K-1, 0)
# print(dist)
# print(tree)
for _ in range(Q):
    x, y = map(int, input().split())
    print(dist[x-1]+dist[y-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(m)]

start = []
goal = []
flag = False

for i in range(m):
    if 1 in a[i]:
        start.append(a[i])
    if n in a[i]:
        goal.append(a[i])

for i in range(len(goal)):
    middle_i = goal[i][0]
    for j in range(len(start)):
        if start[j][1] == middle_i:
            flag = True
            break
    else:
        continue
    break

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

ans = []
flag = False

for i in range(m):
    if 1 in a[i]:
        ans.append(a[i][1])
    if n in a[i]:
        ans.append(a[i][0])

if len(set(ans)) != len(ans):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = float("inf")

for i in range(1,n):
    ans = min(ans, abs(sum(a[:i])-sum(a[i:])))

print(ans)

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

ans = float("inf")
suml = sum(a)
snuke = 0

for i in range(n-1):
    snuke += a[i]
    ans = min(ans, abs(suml-snuke*2))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
b = []
for i in range(n):
	b.append(A[i])
	b.reverse()
print(*b)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
odd_b = A[::2]
even_b = A[1::2]
even_b.reverse()
ans = even_b+odd_b
if n%2 == 0:
	print(*ans)
else:
	ans.reverse()
	print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [int(input()) for i in range(n)]

point = [0]
for i in range(2**n):
    cnt = 0
    for j in range(n):
        if ((i >> j)&1):
            cnt += s[j]
    if cnt%10 != 0:
        point.append(cnt)
print(max(point))

Fixed submission:
N = int(input())
s = sorted([int(input()) for _ in range(N)])

l10 = []
l = []

for i in s:
    if i%10:
        l.append(i)
    else:
        l10.append(i)

ss = l + l10
# print(s)
# print(ss)
if sum(ss)%10 == 0:
    while sum(ss)%10 == 0:
        # print(s)
        if ss:
            ss.pop(0)
        else:
            break
    ans = sum(ss)
else:
    ans = sum(ss)
print(ans)
Buggy python 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.





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 python submission (verdict: Runtime Error):
a,b,c = list(map(int, input().split()))
if b−a==c−b:
	print("YES")
else:
	print("NO")


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

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


Fixed submission:
a,b,c = list(map(int, input().split()))
if b-a == c-b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import fractions
n = int(input())
half = int(fractions.sqrt(n))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))

Fixed submission:
import math
n = int(input())
half = int(math.sqrt(n))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
half = min(n//10**(len(str(n))//2),n%10**(len(str(n))//2))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))

Fixed submission:
import math
n = int(input())
half = int(math.sqrt(n))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
half = min(n//10**(len(str(n))//2),n%10**(len(str(n))//2))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))

Fixed submission:
import math
n = int(input())
half = int(math.sqrt(n))

ans = []
for i in range(half, 0, -1):
    if n%i==0:
        ans.append(max(len(str(i)), len(str(n//i))))
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 1
for i in range(1,n+1):
    ans *= i
print(ans%1000000007)

Fixed submission:
n = int(input())

ans = 1
for i in range(1,n+1):
    ans *= i
    ans = ans%1000000007 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = list(map(int, input().split()))
cnt = 0
for x in range(k+1):
    for y in range(k+1):
       for z in range(k+1):
        if x+y+z == s:
            cnt += 1
print(cnt)

Fixed submission:
k, s = list(map(int, input().split()))
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0 <= z <= k:
            cnt += 1
print(cnt)
Buggy python 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)))

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


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

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

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 python submission (verdict: Runtime Error):
import math
n=int(input)
m=(10**n)-(2*(9**n))+(8**n)
print(m%1000000007)

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