Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
for i in range(H):
  ans=[0]*W
  for i in range(W):
    if s[i][j]=="#":
      ans[j]=="#"
      continue
    count=0
    if i > 0:
      if s[i-1][j]=="#":
        count+=1
      if j > 0:
        if s[i-1][j-1]=="#":
          count+=1
      if j < W-1:
        if s[i-1][j+1]=5"#":
          count+=1
    if i<H-1:
      if s[i+1][j]=="#":
        count+=1
      if j >0:
        if s[i+1][j-1]=="#":
          count+=1
      if j<W-1:
        if s[i+1][j+1]=="#":
          count+=1
    if j>0:
      if s[i][j-1]==”#”:
        count+=1
    if j<W-1:
      if s[i][j+1]=="#":
        count+=1
    ans[j]=count
  print("".join(map(str,ans)))
        
        

Fixed submission:
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
for i in range(H):
  ans=["0"]*W
  for j in range(W):
    if s[i][j]=="#":
      ans[j]="#"
      continue
    count=0
    if i > 0:
      if s[i-1][j]=="#":
        count+=1
      if j > 0:
        if s[i-1][j-1]=="#":
          count+=1
      if j < W-1:
        if s[i-1][j+1]=="#":
          count+=1
    if i<H-1:
      if s[i+1][j]=="#":
        count+=1
      if j >0:
        if s[i+1][j-1]=="#":
          count+=1
      if j<W-1:
        if s[i+1][j+1]=="#":
          count+=1
    if j>0:
      if s[i][j-1]=="#":
        count+=1
    if j<W-1:
      if s[i][j+1]=="#":
        count+=1
    ans[j]=str(count)
  print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
import bisect
N, K = map(int, input().split())
xy = [tuple(map(int, input().split())) for i in range(N)]
xy.sort(key=lambda x: x[0])
X = [x[0] for x in xy]

ans = 40**18
for a, b in combinations(range(N), 2):
    A, B = max(xy[a][0], xy[b][0]), min(xy[a][0], xy[b][0])
    r = bisect.bisect_right(X, A)
    l = bisect.bisect_left(X, B)
    for c, d in combinations(range(N), 2):
        tmp = 0
        C, D = max(xy[c][1], xy[d][1]), min(xy[c][1], xy[d][1])

        for i in range(l, r):
            if xy[i][1] <= C and xy[i][1] >= D:
                tmp += 1
        #     print(xy[i][1], C, D)

        if tmp >= K and ans > (A-B) * (C - D):
            ans = (A-B) * (C - D)

print(ans)


Fixed submission:
from itertools import combinations
N, K = map(int, input().split())
xy = [tuple(map(int, input().split())) for i in range(N)]

ans = float("inf")
for p1, p2 in combinations(xy, 2):
    x1 = p1[0]
    x2 = p2[0]
    if x2 < x1:
        x1, x2 = x2, x1
        #x2 > x1
    for p3, p4 in combinations(xy, 2):
        y1 = p3[1]
        y2 = p4[1]
        if y2 < y1:
            y1, y2 = y2, y1
        # y2 >= y1
        count = 0
        for x, y in xy:
            if x >= x1 and x <= x2 and y >= y1 and y <= y2:
                count += 1

        if count >= K:
            ans = min(ans, (x2-x1)*(y2-y1))


print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
N, K = map(int, input().split())
xy = [tuple(map(int, input().split())) for i in range(N)]

ans = float("inf")
for p1, p2 in combinations(xy, 2):
    x1 = p1[0]
    x2 = p2[0]
    if x2 < x1:
        x1, x2 = x2, x1
        #x2 > x1
    for p3, p4 in combinations(xy, 2):
        y1 = p3[1]
        y2 = p4[1]
        if y2 < y1:
            y1, y2 = y2, y1
        # y2 >= y1
        count = 0
        for x, y in xy:
            if x >= x1 and x <= x2 and y >= y1 and y <= y2:
                count += 1

        if count >= K:
            ans = min(ans, (x2-x1)*(y2-y1))


print(ans)


Fixed submission:
from itertools import combinations
N, K = map(int, input().split())
xy = [tuple(map(int, input().split())) for i in range(N)]

ans = float("inf")
for p1, p2 in combinations(xy, 2):
    x1 = p1[0]
    x2 = p2[0]
    if x2 < x1:
        x1, x2 = x2, x1
        #x2 > x1
    for p3, p4 in combinations(xy, 2):
        y1 = p3[1]
        y2 = p4[1]
        if y2 < y1:
            y1, y2 = y2, y1
        # y2 >= y1
        count = 0
        for x, y in xy:
            if x >= x1 and x <= x2 and y >= y1 and y <= y2:
                count += 1

        if count >= K:
            ans = min(ans, (x2-x1)*(y2-y1))


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        # 4/N - 1/h - 1/n = 1/w
        # (4hn - Nn - Nh) / nhN = 1/w
        # w = nhN / (4hn - Nn - Nh)

        if (4*h*n - N*(n + h)) != 0 and (n*h*N) % (4*h*n - N*(n + h)) == 0:
            w = (n*h*N) // (4*h*n - N*(n + h))
            if w > 0:
                print(h, n, w)
                exit(0)


Fixed submission:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        # 4/N - 1/h - 1/n = 1/w
        # (4hn - Nn - Nh) / nhN = 1/w
        # w = nhN / (4hn - Nn - Nh)

        if (4*h*n - N*(n + h)) > 0 and (n*h*N) % (4*h*n - N*(n + h)) == 0:
            w = (n*h*N) // (4*h*n - N*(n + h))
            print(h, n, w)
            exit(0)
Buggy python submission (verdict: Runtime Error):
s=input()
if s.startwith("YAKI"):
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
if s.startswith("YAKI"):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

A *= 100
B *= 100
dp = [-1]*(F+1)
dp[A] = 0
dp[B] = 0
for i in range(A, F + 1):
    if A <= i:
        dp[i] = max(dp[i - A], dp[i])
    if B <= i:
        dp[i] = max(dp[i - B], dp[i])
    if C <= i and dp[i-C] >= 0:
        if dp[i-C] + C <= (i-C - dp[i-C]) * (E / 100):
            dp[i] = max(dp[i-C] + C, dp[i])

    if D <= i and dp[i-D] >= 0:
        if dp[i-D] + D <= ((i - D) - dp[i-D]) * (E / 100):
            dp[i] = max(dp[i-D] + D, dp[i])


x = 0
id = 0
for i in range(A, F+1):

    if x <= (dp[i] / (i)):
        x = dp[i] / (i)
        id = i

print(id, dp[id])


Fixed submission:
A, B, C, D, E, F = map(int, input().split())

water = set()
for i in range(F//(100*A) + 1):
    for j in range(F // (100*B) + 1):
        if 100*A * i + 100*j*B <= F:
            water |= {100*A * i + 100*j*B}
        else:
            break

sugar = set()
for i in range(F//C + 1):
    for j in range(F // D + 1):
        if C * i + D*j <= F:
            sugar |= {C * i + D*j}
        else:
            break
ans = [100*A, 0]
for x in water:
    if x == 0:
        continue
    for y in sugar:
        if x + y <= F and y <= (x/100)*E:
            if ans[1]/ans[0] < y / (x+y):
                ans = [x+y, y]

print(ans[0], ans[1])
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
B = copy.deepcopy(A)
ans = 0
for i in range(N):
    ans += sum(A[i])
    for j in range(N):
        if i == j:
            continue
        for k in range(N):
            if k == i or k == j:
                continue
            else:
                if B[i][k] == B[i][j]+B[j][k]:
                    ans -= B[i][k]
                B[i][k] = min(B[i][k], B[i][j]+B[j][k])

if A == B:
    print(ans//2)
else:
    print(-1)


Fixed submission:
import copy
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
B = copy.deepcopy(A)
table = [[True]*N for i in range(N)]
ans = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        for k in range(N):
            if k == i or k == j:
                continue
            else:
                if B[i][k] == B[i][j]+B[j][k]:
                    table[i][k] = False
                B[i][k] = min(B[i][k], B[i][j]+B[j][k])


if A == B:
    for i in range(N):
        for j in range(N):
            if table[i][j]:
                ans += B[i][j]
    print(ans//2)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
B = copy.deepcopy(A)
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        for k in range(N):
            if k == i or k == j:
                continue
            else:
                B[i][k] = min(B[i][k], B[i][j]+B[j][k])

if A == B:
    ans = 0
    for i in range(N):
        ans += sum(A[i])
        for j in range(N):
            if i == j:
                continue
            for k in range(N):
                if k == i or k == j:
                    continue
                else:
                    if A[i][k] == A[i][j]+A[j][k]:
                        ans -= B[i][k]
    print(ans//2)
else:
    print(-1)


Fixed submission:
import copy
N = int(input())
A = [list(map(int, input().split())) for i in range(N)]
B = copy.deepcopy(A)
table = [[True]*N for i in range(N)]
ans = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        for k in range(N):
            if k == i or k == j:
                continue
            else:
                if B[i][k] == B[i][j]+B[j][k]:
                    table[i][k] = False
                B[i][k] = min(B[i][k], B[i][j]+B[j][k])


if A == B:
    for i in range(N):
        for j in range(N):
            if table[i][j]:
                ans += B[i][j]
    print(ans//2)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,input().split()))
count=0
import collections

s=collections.deque()
t=set()
for i in range(N):
  if p[i]==i+1:
    s.append(i)
    t.add(i)
ans=0
id=0
while(id<N):
  if id in t:
    if x+1 in t:
      id+=1
    ans+=1
  id+=1
  
  
print(ans)


Fixed submission:
N=int(input())
p=list(map(int,input().split()))
count=0
t=set()
for i in range(N):
  if p[i]==i+1:
    t.add(i)
ans=0
id=0
while(id<N):
  if id in t:
    if id+1 in t:
      id+=1
    ans+=1
  id+=1
  
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
p=list(map(int,input().split()))
count=0
import collections

s=collections.deque()
for i in range(N):
  if p[i]==i+1:
    s.append(i)
ans=0
while(s):
  x=s.popleft()
  if x+1 in s:
    s.popleft()
  ans+=1
  
print(ans)


Fixed submission:
N=int(input())
p=list(map(int,input().split()))
count=0
t=set()
for i in range(N):
  if p[i]==i+1:
    t.add(i)
ans=0
id=0
while(id<N):
  if id in t:
    if id+1 in t:
      id+=1
    ans+=1
  id+=1
  
  
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,input().))
count=0
for i in range(N):
  if p[i]==i:
    count+=1
ans=count//2
if count%2==1:
  ans+=1
  
  
print(ans)

Fixed submission:
N=int(input())
p=list(map(int,input().split()))
count=0
t=set()
for i in range(N):
  if p[i]==i+1:
    t.add(i)
ans=0
id=0
while(id<N):
  if id in t:
    if id+1 in t:
      id+=1
    ans+=1
  id+=1
  
  
print(ans)
Buggy python submission (verdict: Runtime Error):
price=list[map(int,input().split())]
k=[0.25,0.5,1.0,2.0]

N=int(input())

from itertools import permutations
ans=float("Inf")
for x in permutations([0,1,2,3]):
  tmp=0
  n=N
  for y in x:
    tmp+= (n//k[y])*price[y]
    n=n%k[y]
  ans=min(tmp,ans)
  
print(ans)
  
  

Fixed submission:
from itertools import permutations
Q, H, S, D = map(int, input().split())
N = int(input())*4

ans = 0
s = [(Q, 1), (H, 2), (S, 4), (D, 8)]

ans = float("inf")
for x in permutations(s):
    tmp = 0
    n = N
    for a, b in x:
        tmp += (n // b)*a
        n %= b
    ans = min(ans, tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
import collections
A=list(map(int,input().split()))

table=collections.defaultdict(int)
for x in A:
  table[x]+=1
table=list(table.items())
table=[table[i][0] for  i in range(N) if table[i][1]>1]
table.append(0)
table.append(0)
table.sort(reverse=True)
print(table[0]*table[1])
      

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


dic = collections.defaultdict(int)

for x in A:
    dic[x] += 1

dic = list(dic.items())
dic = [x for x in dic if x[1] >= 2]
dic = sorted(dic, reverse=True, key=lambda x: x[0])

if len(dic) >= 2:
    if dic[0][1] >= 4:
        print(dic[0][0] * dic[0][0])
    else:
        print(dic[0][0] * dic[1][0])
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
import collections
table=collections.defaultdict(list)
for i in range(M):
  a,b=map(int,input().split())
  table[a].append(b)
  table[b].append(a)
for x in table[1]:
  if x in table[N]:
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")
    

Fixed submission:
N,M=map(int,input().split())
import collections
table=collections.defaultdict(int)
table2=collections.defaultdict(int)
for i in range(M):
  a,b=map(int,input().split())
  if a==1:
    table[b]+=1
  if b==N:
    table2[a]+=1
for x in table:
  if x in table2:
    print("POSSIBLE")
    exit(0)
print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(1,N+1):
  S[i]=S[i-1]+a[i-1]
  
ans=floot("Inf")
for i in range(1,N):
  tmp=abs(S[N]-S[i])
  ans=min(ans,tmp)
print(ans)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
S=[0]*(N+1)
for i in range(1,N+1):
  S[i]=S[i-1]+a[i-1]
  
ans=float("Inf")
for i in range(1,N):
  tmp=abs(S[N]-S[i]*2)
  ans=min(ans,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
G = [set() for i in range(N)]

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


F = [-1]*N
F[0] = 0
q = collections.deque()
q.append(0)
while(q):
    x = q.popleft()
    for y in G[x]:
        if F[y] < 0:
            F[y] = F[x] + 1
            q.append(y)

S = [-1]*N
S[N-1] = 0
q.append(N-1)
while(q):
    x = q.popleft()
    for y in G[x]:
        if S[y] < 0:
            S[y] = S[x] + 1
            q.append(y)
# print(F)
# print(S)
ans = 0
for i in range(N):
    if F[i] + S[i] == F[-1]:



if ans > N // 2:
    print("Fennec")
else:
    print("Snuke")


Fixed submission:
N=int(input())
import collections
import heapq
ab=[tuple(map(int,input().split())) for i in range(N-1)]
G=[set() for i in range(N)]
for a,b in ab:
  a-=1
  b-=1
  G[a].add(b)
  G[b].add(a)
q=collections.deque()

dis=[[-1]*N for i in range(2)]
dis[0][0]=0
q.append(0)
while(q):
  x=q.popleft()
  for y in G[x]:
    if dis[0][y]==-1:
      q.append(y)
      dis[0][y]=dis[0][x]+1
dis[1][N-1]=0
q.append(N-1)
while(q):
  x=q.popleft()
  for y in G[x]:
    if dis[1][y]==-1:
      q.append(y)
      dis[1][y]=dis[1][x]+1

hqF=[(0,0)]
hqS=[(0,N-1)]
colord=[False]*N

while(1):
  if len(hqF)==0:
    print("Snuke")
    exit(0)
  _,x = heapq.heappop(hqF)
  while(colord[x]):
    if hqF:
      _,x = heapq.heappop(hqF)
    else:
      print("Snuke")
      exit(0)
  colord[x]=True
  for y in G[x]:
    if colord[y]==False:
      heapq.heappush(hqF,(dis[1][y],y))

  if len(hqS)==0:
    print("Fennec")
    exit(0)
  _,x = heapq.heappop(hqS)
  while(colord[x]):
    if hqF:
      _,x = heapq.heappop(hqS)
    else:
      print("Fennec")
      exit(0)
  colord[x]=True
  for y in G[x]:
    if colord[y]==False:
      heapq.heappush(hqS,(dis[0][y],y))
Buggy python submission (verdict: Runtime Error):
from math import factorial
N,P=map(int,input().split())
a=list(map(int,input().split()))
odd=0
even=0
for i in range(N):
  if a[i]%2==0:
    even+=1
  else:
    odd+=1
ans=2**even
k=0
if P==0:
  k=odd//2 +1
else:
  k=(odd+1)//2
tmp=0
for i in range(1,k+1):
  tmp+=factorial(odd)//factorial(odd-i)//factorial(i)

print(ans*tmp)

Fixed submission:
from math import factorial
N,P=map(int,input().split())
a=list(map(int,input().split()))
odd=0
even=0
for i in range(N):
  if a[i]%2==0:
    even+=1
  else:
    odd+=1
ans=2**even
k=0
if P==0:
  k=0
else:
  k=1
tmp=0
for i in range(k,odd+1,2):
  tmp+=factorial(odd)//factorial(odd-i)//factorial(i)

print(ans*tmp)
Buggy python submission (verdict: Runtime Error):
N,A,B,C,D=map(int,input().split())
if A> B:
  A,B=B,A
if C>D:
  C,B=B,C
if B-A>D*(N-1):
  print("NO")
elif B-A>=C*(N-1):
  print("YES")
else:
  flag=False
  diff=B-A
  d=0
  for i in range(2,N,2):
    d+=D-C
    j= N-1 - i
    if j==0:
      if diff==d:
        flag=True
      break
    k=(diff - d) / j
    if k>=C and k<=D:
      flag=True
    
if flag:
  print("YES")
else:
  print("NO")

Fixed submission:
N, A, B, C, D = map(int, input().split())
if A > B:
    A, B = B, A

flag = False
diff = B-A
d = 0
for i in range(0, N, 2):
    if i > 0:
        d += D-C
    j = N-1 - i
    if diff == d and j % 2 == 0:
        flag == True
        break
    if j == 0:
        break

    k = abs(diff - d) / j
    if (k >= C and k <= D) or (abs(diff-d) >= C and abs(diff-d) <= D and j % 2 == 1):
        flag = True
        break
    k = abs(diff + d) / j
    if (k >= C and k <= D) or (diff+d >= C and diff+d <= D and j % 2 == 1):
        flag = True
        break

if flag:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
a = list(map(int, input().split()))
b = collections.deque()

flag = True

for x in a:
    if flag:
        b.append(x)
        flag = False
    else:
        b.appendleft(x)
        flag = True
if flag:
    print(*b)
else:
    print(*b[::-1])


Fixed submission:
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
b[N//2]=a[0]
for i in range(1,N//2+1):
  b[N//2-i]=a[i*2-1]
  if i != N//2 or N%2==1:
    b[N//2+i]=a[i*2]
if N%2==1:
  b=b[::-1]
print(" ".join(map(str,b)))
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
ans=[]*(H+2)
ans[0]=["#"]*(W+2)
ans[H+1]=["#"]*(W+2)
for i in range(1,H+1):
  ans[i]="#"+input()+"#"
for i in range(H+2):
  print("".join(ans[i]))

Fixed submission:
H,W=map(int,input().split())
ans=[[] for i in range(H+2)]
ans[0]=["#"]*(W+2)
ans[H+1]=["#"]*(W+2)
for i in range(1,H+1):
  ans[i]="#"+input()+"#"
for i in range(H+2):
  print("".join(ans[i]))
Buggy python submission (verdict: Runtime Error):
import math
H,W=map(int,input().split())
if H%3==0 or W%3==0:
  print(0)
  exit(0)
S=[0]*3
s=H*import math
H,W=map(int,input().split())
if H%3==0 or W%3==0:
  print(0)
  exit(0)
S=[0]*3
s=H*W/3
w0=math.ceil(s/H)
h0=math.ceil(s/W)

S[0]=w0*H
w1=W-W/3
w0=math.ceil(s/H)
h0=math.ceil(s/W)

S[0]=w0*H
w1=W-w0
if w1%2==0 or H%2==0:
  S[1]=(H*w1)//2
  S[2]=(H*w1)//2
else:
  s1=H*w1/2
  w10=math.ceil(s1/H)
  h10=math.ceil(s1/w1)
  S[2]=max((w1-w10)*H,(H-h10)*w1)
ans=abs(S[0]-S[2])

S[0]=W*h0
h1=H-h0
if h1%2==0 or W%2==0:
  S[1]=(W*h1)//2
  S[2]=(W*h1)//2
else:
  s1=h1*W/2
  w11=math.ceil(s1/h1)
  h11=math.ceil(s1/W)
  S[2]=max((W-w11)*h1,(h1-h11)*W)
ans=min(ans,abs(S[0]-S[2]))


S=[0]*3
s=H*W/3
w0=math.floor(s/H)
h0=math.floor(s/W)

S[0]=w0*H
w1=W-w0
if w1%2==0 or H%2==0:
  S[1]=(H*w1)//2
  S[2]=(H*w1)//2
else:
  s1=H*w1/2
  w10=math.floor(s1/H)
  h10=math.floor(s1/w1)
  S[2]=max((w1-w10)*H,(H-h10)*w1)
ans=min(ans,abs(S[0]-S[2]))

S[0]=W*h0
h1=H-h0
if h1%2==0 or W%2==0:
  S[1]=(W*h1)//2
  S[2]=(W*h1)//2
else:
  s1=h1*W/2
  w11=math.floor(s1/h1)
  h11=math.floor(s1/W)
  S[2]=max((W-w11)*h1,(h1-h11)*W)
ans=min(ans,abs(S[0]-S[2]))

print(ans)

Fixed submission:
import math
H,W=map(int,input().split())
if H%3==0 or W%3==0:
  print(0)
  exit(0)
S=[0]*3
s=H*W/3
w0=math.ceil(s/H)
h0=math.ceil(s/W)

S[0]=w0*H
w1=W-W/3
w0=math.ceil(s/H)
h0=math.ceil(s/W)

S[0]=w0*H
w1=W-w0
if w1%2==0 or H%2==0:
  S[1]=(H*w1)//2
  S[2]=(H*w1)//2
else:
  s1=H*w1/2
  w10=math.ceil(s1/H)
  h10=math.ceil(s1/w1)
  S[2]=max((w1-w10)*H,(H-h10)*w1)
ans=abs(S[0]-S[2])

S[0]=W*h0
h1=H-h0
if h1%2==0 or W%2==0:
  S[1]=(W*h1)//2
  S[2]=(W*h1)//2
else:
  s1=h1*W/2
  w11=math.ceil(s1/h1)
  h11=math.ceil(s1/W)
  S[2]=max((W-w11)*h1,(h1-h11)*W)
ans=min(ans,abs(S[0]-S[2]))


S=[0]*3
s=H*W/3
w0=math.floor(s/H)
h0=math.floor(s/W)

S[0]=w0*H
w1=W-w0
if w1%2==0 or H%2==0:
  S[1]=(H*w1)//2
  S[2]=(H*w1)//2
else:
  s1=H*w1/2
  w10=math.floor(s1/H)
  h10=math.floor(s1/w1)
  S[2]=max((w1-w10)*H,(H-h10)*w1)
ans=min(ans,abs(S[0]-S[2]))

S[0]=W*h0
h1=H-h0
if h1%2==0 or W%2==0:
  S[1]=(W*h1)//2
  S[2]=(W*h1)//2
else:
  s1=h1*W/2
  w11=math.floor(s1/h1)
  h11=math.floor(s1/W)
  S[2]=max((W-w11)*h1,(h1-h11)*W)
ans=min(ans,abs(S[0]-S[2]))

print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
N,m=map(int,input().split())
table=collections.defaultdict(int)
for i in range(M):
  a,b=map(int,input().split())
  table[a]+=1
  table[b]+=1
for i in range(N):
  print(table[i])

Fixed submission:
import collections
N,M=map(int,input().split())
table=collections.defaultdict(int)
for i in range(M):
  a,b=map(int,input().split())
  table[a]+=1
  table[b]+=1
for i in range(1,N+1):
  print(table[i])
Buggy python submission (verdict: Runtime Error):
A,B,C=map(int,input().split())

if C%(((B//A +1)*A)%B) == 0:
  print("YES")
else:
  print("NO")

Fixed submission:
A,B,C=map(int,input().split())
for i in range(1,B):
  if A*i %B==C:
    print("YES")
    exit(0)
print("NO")
Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
t=list(map(int,input().split()))
diff = [t[i]-t[i-1] fossil i in range(1,N)]
ans=T*N
for i in range(N-1):
  ans-=min((T - diff[i]),0)
print(ans)

Fixed submission:
N,T=map(int,input().split())
t=list(map(int,input().split()))
diff = [t[i]-t[i-1] for i in range(1,N)]
ans=T*N
for i in range(N-1):
  ans-=max((T - diff[i]),0)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,T = map(int, input().split())
prev = 0
ans = 0
for i in range(N):
  t = int(input())
  if prev+T <= t:
    ans += T
  else:
    ans += (t - prev)
    prev = t

print(ans + T)
    

Fixed submission:
N,T = map(int, input().split())
prev = 0
ans = 0
tt = list(map(int, input().split()))
for t in tt:
  if prev+T <= t:
    ans += T
  else:
    ans += (t - prev)
  prev = t

print(ans + T)
Buggy python submission (verdict: Runtime Error):
import collections
N, W = map(int, input().split())
wv = collections.defaultdict(list)
w = 0
for i in range(N):
    a, b = map(int, input().split())
    wv[a].append(b)
    if i == 0:
        w = a
s = [[0]*(len(wv[w+i])+1) for i in range(4)]

for i in range(4):
    wv[w + i].sort(reverse=True)
    for j, x in enumerate(wv[w + i]):
        s[i][j+1] = s[i][j] + x
ans = 0
L = len(wv[3])
for i in range(min(len(wv[w]), N)+1):
    tmp1 = s[0][i]
    weight1 = w * i
    if weight1 > W:
        break
    for j in range(min(len(wv[w+1])+1, N+1 - i)):

        tmp2 = tmp1 + s[1][j]
        weight2 = weight1 + (w+1)*j
        if weight2 > W:
            break
        for k in range(min(len(wv[w+2])+1, N+1 - i - j)):
            tmp3 = tmp2 + s[2][k]
            weight3 = weight2 + (w+2)*k
            if weight3 > W:
                break
            d = W - weight3

            ans = max(ans, tmp3 + s[3][min(L, d//(w+3))])
print(ans)


Fixed submission:
import collections
N, W = map(int, input().split())
wv = collections.defaultdict(list)
w = 0
for i in range(N):
    a, b = map(int, input().split())
    wv[a].append(b)
    if i == 0:
        w = a
s = [[0]*(len(wv[w+i])+1) for i in range(4)]

for i in range(4):
    wv[w + i].sort(reverse=True)
    for j, x in enumerate(wv[w + i]):
        s[i][j+1] = s[i][j] + x
ans = 0
L = len(wv[w+3])
for i in range(min(len(wv[w]), N)+1):
    tmp1 = s[0][i]
    weight1 = w * i
    if weight1 > W:
        break
    for j in range(min(len(wv[w+1])+1, N+1 - i)):

        tmp2 = tmp1 + s[1][j]
        weight2 = weight1 + (w+1)*j
        if weight2 > W:
            break
        for k in range(min(len(wv[w+2])+1, N+1 - i - j)):
            tmp3 = tmp2 + s[2][k]
            weight3 = weight2 + (w+2)*k
            if weight3 > W:
                break
            d = W - weight3

            ans = max(ans, tmp3 + s[3][min(L, d//(w+3))])
print(ans)
Buggy python submission (verdict: Runtime Error):
s1,s2,s3=input.split()
ans="".join([s1[0],s2[0],s3[0]])
print(ans.upper())

Fixed submission:
s1,s2,s3=input().split()
ans="".join([s1[0],s2[0],s3[0]])
print(ans.upper())