Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
h,w = map(int, input().split())
a = [list(input) for _ in range(h)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for k in range(h):
    for j in range(w):
        x,y = k,j
        if a[x][y] == "#":
            for i in range(4):
                xi,yi = x+dx[i],y+dy[i]
                if 0 <= xi < h and 0 <= yi < w and a[xi][yi] == "#":
                    break
            else:
                print("No")
                exit()
 
print("Yes")

Fixed submission:
n, m = map(int, input().split())
field = [list(input()) for i in range(n)]
flg = True
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(n):
    for j in range(m):
        if field[i][j] == "#":
            f = 0
            for k in range(4):
            # 移動した後の点を (nx, ny) とする
                nx = i + dx[k]
                ny = j + dy[k]
                if 0 <= nx and nx < n and 0 <= ny and ny < m and field[nx][ny] == "#":
                    f += 1
            if f==False:
                flg = False
                
print("Yes" if flg else "No")

Buggy python submission (verdict: Runtime Error):
for k in range(h):
    for j in range(w):
        x,y = k,j
        if a[x][y] == "#":
            for i in range(4):
                xi,yi = x+dx[i],y+dy[i]
                if 0 <= xi < h and 0 <= yi < w and a[xi][yi] == "#":
                    break
            else:
                print("No")
                exit()
 
print("Yes")

Fixed submission:
n, m = map(int, input().split())
field = [list(input()) for i in range(n)]
flg = True
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
for i in range(n):
    for j in range(m):
        if field[i][j] == "#":
            f = 0
            for k in range(4):
            # 移動した後の点を (nx, ny) とする
                nx = i + dx[k]
                ny = j + dy[k]
                if 0 <= nx and nx < n and 0 <= ny and ny < m and field[nx][ny] == "#":
                    f += 1
            if f==False:
                flg = False
                
print("Yes" if flg else "No")
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = sorted(list(map(int,input().split())))[::-1]
ans = 0
conb = [0]*a[0]
conb[0] = a[0]
for j in range(1,a[0]):
    conb[j] = conb[j-1]*(a[0]-j)

for i in range(1,n):
    b = conb[a[i]-1] / math.factorial(a[i])
    if b >= ans:
        ans1 = a[i]
        ans = b
print(a[0],ans1)

Fixed submission:
import math
n = int(input())
a = sorted(list(map(int,input().split())))
b = (a[-1]+1)//2
d = float("inf")
for i in a:
    if abs(b-i) < d:
        d = abs(b-i)
        ans = i
print(a[-1],ans)

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb
# from scipy.special import comb
n = int(input())
a = sorted(list(map(int,input().split())))[::-1]
ans = 0
for i in range(1,n):
    b = comb(a[0],a[i])
    if b >= ans:
        ans1 = a[i]
        ans = b
print(a[0],ans1)


Fixed submission:
import math
n = int(input())
a = sorted(list(map(int,input().split())))
b = (a[-1]+1)//2
d = float("inf")
for i in a:
    if abs(b-i) < d:
        d = abs(b-i)
        ans = i
print(a[-1],ans)

Buggy python submission (verdict: Runtime Error):
#from scipy.misc import comb
from scipy.special import comb
n = int(input())
a = sorted(list(map(int,input().split())))[::-1]
ans = 0
for i in range(1,n):
    b = comb(a[0],a[i])
    if b >= ans:
        ans1 = a[i]
        ans = b
print(a[0],ans1)

Fixed submission:
import math
n = int(input())
a = sorted(list(map(int,input().split())))
b = (a[-1]+1)//2
d = float("inf")
for i in a:
    if abs(b-i) < d:
        d = abs(b-i)
        ans = i
print(a[-1],ans)
Buggy python submission (verdict: Runtime Error):
a

Fixed submission:
n = int(input())
d,x = map(int, input().split())
ans = 0
for i in range(n):
    a = int(input())
    j = 0
    while a*j+1 <= d:
        j += 1
    ans += j
print(ans+x)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from scipy.special import comb
#ID
b = defaultdict(lambda: len(b))
n = int(input())
hed = ["M","A","R","C","H"]
for i in hed:
    b[i] 
li = [0]*5
for _ in range(n):
    a = input()
    if a[0] in hed:
        li[b[a[0]]] += 1

c = [i for i in li if i != 0]
print(int(comb(len(c),3))*2 -int(comb(len(c)-1,3)))

Fixed submission:
from collections import defaultdict
import itertools
#ID
b = defaultdict(lambda: len(b))
n = int(input())
hed = ["M","A","R","C","H"]
for i in hed:
    b[i] 
li = [0]*5
for _ in range(n):
    a = input()
    if a[0] in hed:
        li[b[a[0]]] += 1
c = [j for j in li if j != 0]
ans = 0
for k in itertools.combinations(c,3):
    ans += k[0]*k[1]*k[2]
print(ans)
Buggy python submission (verdict: Runtime Error):
rom collections import deque
def bfs():
    #sからそのマスまでの最短距離を保存する配列
    d = [[float("inf")]*m for _ in range(n)]
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    #s,gの座標を得る
    sx,sy = 0,0
    gx,gy = n-1,m-1
    #キューにs座標をセットしてsのマスを0にする
    q = deque([])
    q.append((sx,sy))
    d[sx][sy] = 0
    
    #全部の行けるところをqueに入れてsからの距離を＋1ずつしていく
    while q:
        p = q.popleft()
        #gでbreakしなければ行ける全てのマスまでの最短距離を求める事になる
        if p[0] == gx and p[1] == gy:
            break
        #上下左右のマスを調べる
        for k in range(4):
            xi,yi = p[0]+dx[k],p[1]+dy[k]
            #そのマスにいけて行ったことないなら、そこを起点に再起＋そこまでの距離を求める
            if 0 <= xi < n and 0 <= yi < m and maze[xi][yi] != "#" and d[xi][yi] == float("inf"):
                q.append((xi,yi))
                d[xi][yi] = d[p[0]][p[1]] + 1

    #gまでの最短距離を返す
    return d[gx][gy]

n,m = map(int, input().split())
maze = [list(input()) for _ in range(n)]
c = 0
for i in range(n):
    for j in range(m):
        if maze[i][j] == ".":
            c += 1
res = bfs()
#到達できるなら
if 0 < res < float("inf"):
    print(c - res -1)
else:
    print(-1)

Fixed submission:
from collections import deque
def bfs():
    #sからそのマスまでの最短距離を保存する配列
    d = [[float("inf")]*m for _ in range(n)]
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    #s,gの座標を得る
    sx,sy = 0,0
    gx,gy = n-1,m-1
    #キューにs座標をセットしてsのマスを0にする
    q = deque([])
    q.append((sx,sy))
    d[sx][sy] = 0
    
    #全部の行けるところをqueに入れてsからの距離を＋1ずつしていく
    while q:
        p = q.popleft()
        #gでbreakしなければ行ける全てのマスまでの最短距離を求める事になる
        if p[0] == gx and p[1] == gy:
            break
        #上下左右のマスを調べる
        for k in range(4):
            xi,yi = p[0]+dx[k],p[1]+dy[k]
            #そのマスにいけて行ったことないなら、そこを起点に再起＋そこまでの距離を求める
            if 0 <= xi < n and 0 <= yi < m and maze[xi][yi] != "#" and d[xi][yi] == float("inf"):
                q.append((xi,yi))
                d[xi][yi] = d[p[0]][p[1]] + 1

    #gまでの最短距離を返す
    return d[gx][gy]

n,m = map(int, input().split())
maze = [list(input()) for _ in range(n)]
c = 0
for i in range(n):
    for j in range(m):
        if maze[i][j] == ".":
            c += 1
res = bfs()
#到達できるなら
if 0 < res < float("inf"):
    print(c - res -1)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N,Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        if N-i-k >= 0 and 10000*i + 5000*j + 1000*(N-i-k) == Y:
            c = [i,j,N-i-k]
            break

print(c[0],c[1],c[2])

Fixed submission:
N,Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        a = N - i - j
        if a >= 0 and (10000*i + 5000*j + 1000*a) == Y:
            c = [i,j,a]
            break
print(c[0],c[1],c[2])

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
            if N-i-k >=0 and 10000*i + 5000*j + 1000*(N-i-k) == Y:
                c = [i,j,N-i-k]
                break

print(c[0],c[1],c[2])

Fixed submission:
N,Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        a = N - i - j
        if a >= 0 and (10000*i + 5000*j + 1000*a) == Y:
            c = [i,j,a]
            break
print(c[0],c[1],c[2])

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
            if N-i-k >=0 and 10000*i + 5000*j + 1000*(N-i-k) == Y:
                c = [i,j,N-i-k]
print(c[0],c[1],c[2])

Fixed submission:
N,Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        a = N - i - j
        if a >= 0 and (10000*i + 5000*j + 1000*a) == Y:
            c = [i,j,a]
            break
print(c[0],c[1],c[2])

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
            if 10000*i + 5000*j + 1000*(N-i-k) == Y:
                c = [i,j,N-i-k]
print(c[0],c[1],c[2])

Fixed submission:
N,Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        a = N - i - j
        if a >= 0 and (10000*i + 5000*j + 1000*a) == Y:
            c = [i,j,a]
            break
print(c[0],c[1],c[2])

Buggy python submission (verdict: Runtime Error):
N, Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N-i+1):
            if 10000*i + 5000*j + 1000*(N-i-k) == Y:
                c = [i,j,N-i-k]
print(c[0],c[1],c[2])

Fixed submission:
N,Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        a = N - i - j
        if a >= 0 and (10000*i + 5000*j + 1000*a) == Y:
            c = [i,j,a]
            break
print(c[0],c[1],c[2])
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
while x <= y:
    ans += 1
    x *= 2
print(ans)

Fixed submission:
x,y = map(int,input().split())
ans = 0
while x <= y:
    ans += 1
    x *= 2
print(ans)
Buggy python submission (verdict: Runtime Error):
import.math
a,b = map(int, input().split())
print(int(math.ceil((a+b)/2)))

Fixed submission:
import math
a,b = map(int, input().split())
print(int(math.ceil((a+b)/2)))

Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())
print(int(math.ceil((a+b)/2)))

Fixed submission:
import math
a,b = map(int, input().split())
print(int(math.ceil((a+b)/2)))
Buggy python submission (verdict: Runtime Error):
N,A = map(int, input().split())
print(">" if N>A else "<" if N<A else "=") 

Fixed submission:
N,A = map(str, input().split())
print(">" if N>A else "<" if N<A else "=")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
for j in ai:
    ans += sum(bi[n-j:])
print(ans)

Fixed submission:
from itertools import accumulate
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
c = [0]+list(accumulate(bi[::-1]))
for j in ai:
    ans += c[j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
for j in ai:
    ans += sum(bi[n-j:])
print(ans)

Fixed submission:
from itertools import accumulate
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
c = [0]+list(accumulate(bi[::-1]))
for j in ai:
    ans += c[j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
a = sorted(list(map(int,input().split())))
b = sorted(list(map(int,input().split())))
c = sorted(list(map(int,input().split())))
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
for j in ai:
    ans += sum(bi[n-j:])
print(ans)

Fixed submission:
from itertools import accumulate
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
b.sort()
c.sort()
ai = []
bi = []
for i in range(n):
    ai.append(n - bisect.bisect_right(b, a[i]))
    bi.append(n - bisect.bisect_right(c, b[i]))
ans = 0
c = [0]+list(accumulate(bi[::-1]))
for j in ai:
    ans += c[j]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if i+1 == p[i]:
        p[i+1] = p[i]
        ans += 1
if p[n] == n:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i+1 == a[i] and i != n-1:
        b = a[i]
        c = a[i+1]
        a[i] = c
        a[i+1] = b
        ans += 1
    elif i+1 == a[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i != n:
        if i+1 == l[i]:
            a = l[i]
            b = l[i+1]
            l[i]=b
            l[i+1]=a
            ans += 1
    else:
        if i+1 == l[i]:
            ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i+1 == a[i] and i != n-1:
        b = a[i]
        c = a[i+1]
        a[i] = c
        a[i+1] = b
        ans += 1
    elif i+1 == a[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i+1 == l[i]:
        a = l[i]
        b = l[i+1]
        l[i]=b
        l[i+1]=a
        ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i+1 == a[i] and i != n-1:
        b = a[i]
        c = a[i+1]
        a[i] = c
        a[i+1] = b
        ans += 1
    elif i+1 == a[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
import math   
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i+1 == a[i]:
        b = a[i]
        c = a[i+1]
        a[i] = c
        a[i+1] = b
        ans += 1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
    if i+1 == a[i] and i != n-1:
        b = a[i]
        c = a[i+1]
        a[i] = c
        a[i+1] = b
        ans += 1
    elif i+1 == a[i]:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
l = []
for i in range(n-1):
    if a[i] == a[i+1] and a[i] not in l:
        l.append(a[i])
        
print(l[0]*l[1])

Fixed submission:
from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split())))
b=[0,0]
for i in a:
    if a[i] > 1:b.append(i)
    if a[i] > 3:b.append(i)
b.sort()
print(b[-1]*b[-2])
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a = Counter(a)
b = []
for i,j in a:
    if j >=4:
        b.append(i)
        b.append(i)
    elif j >= 2:
        b.append(i)
b.sort()
if len(b)>=2:
    print(b[-1]*b[-2])
else:
    print(0)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a = Counter(a).most_common()
b = []
for i,j in a:
    if j >=4:
        b.append(i)
        b.append(i)
    elif j >= 2:
        b.append(i)
b.sort()
if len(b)>=2:
    print(b[-1]*b[-2])
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a = Counter(a).most_common()
b = []
for i,j in a:
    if j >=4:
        b.append(i)
        b.append(i)
    elif j >= 2:
        b.append(i)
b.sort()
if len(b)>=2:
    print(b[-1]*b[-2])
else:
    print(0)
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a = Counter(a)
b = []
for i,j in a:
    if j >=4:
        b.append(i)
        b.append(i)
    elif j >= 2:
        b.append(i)
b.sort()
if len(b)>=2:
    print(b[-1]*b[-2])
else:
    print(0)
提出情報

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a = Counter(a).most_common()
b = []
for i,j in a:
    if j >=4:
        b.append(i)
        b.append(i)
    elif j >= 2:
        b.append(i)
b.sort()
if len(b)>=2:
    print(b[-1]*b[-2])
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = sorted(list(map(int,input().split())))
print(a[-1]+a[-2]+a[-3])

Fixed submission:
n,k= map(int, input().split())
l = sorted(list(map(int, input().split())))
a = 0
for i in range(k):
    a += l[-(i+1)]
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
a = 10000000000
for i in range(1,n):
    a = min(a,abs(sum(l[:i])-sum(l[i:])))
print(a)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
a = 10000000000
A = 0
B = sum(l)
for i in range(n-1):
    A += l[i]
    B -= l[i]
    a = min(a,abs(A-B))
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(str, input().split()))
b = []
for i in a:
    b.append(i)
    b = list(reversed(b))
print(" ".join(b))

Fixed submission:
n = int(input())
a = list(map(str, input().split()))
b = []
if n%2 == 0:
    print(" ".join(a[1::2][::-1]+a[0::2]))
else:
    print(" ".join(a[0::2][::-1]+a[1::2]))
Buggy python submission (verdict: Runtime Error):
a = ""
b = list(map(int, input().split()))
for i in range(3):
  a += b[i]
if int(a)%4:
  print("NO")
else:
  print("YES")

Fixed submission:
a = ""
b = list(map(int, input().split()))
for i in range(3):
  a += str(b[i])
if int(a)%4:
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Runtime Error):
#ABC64C
n = int(input())
a = list(map(int,input().split()))
c = set()
d = 0
fot i in a:
    c = a  // 400:
    if c < 8:
        b.add(c)
    else:
        d += 1:
print(len(b) len(b)+d)

Fixed submission:
# ABC64C
n = int(input())
a = list(map(int,input().split()))
b = set()
d = 0
for i in a:
    c = i // 400
    if c < 8:
        b.add(c)
    else:
        d += 1
print(max(len(b),1),len(b)+d)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
t = [0 for i in range(n)]
for i in range(m):
    a, b = (map(str, input().split()))
    t[a-1] +=1
    t[b-1] +=1
    
for j in t:
    print(j)

Fixed submission:
#ABC61B
n, m = map(int, input().split())
t = [0 for i in range(n)]
for i in range(m):
    a, b = (map(int, input().split()))
    t[a-1] +=1
    t[b-1] +=1
    
for j in t:
    print(j)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
li=sorted([list(map(int,input().split())) for _ in range(N)])
for l in li:
    K-=l[1]
    if K<=0:
        print(l[0])
        break()


Fixed submission:
N,K=map(int,input().split())
li=sorted([list(map(int,input().split())) for _ in range(N)])
for l in li:
    K-=l[1]
    if K<=0:
        print(l[0])
        break

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
c = []
for i in range(n):
    for _ in range(l[i][1]):
        #print(l[i][0])
        c.append(l[i][0])
    
c.sort()
print(c[k-1])

Fixed submission:
N,K=map(int,input().split())
li=sorted([list(map(int,input().split())) for _ in range(N)])
for l in li:
    K-=l[1]
    if K<=0:
        print(l[0])
        break
Buggy python submission (verdict: Time Limit Exceeded):
o = list(input())
e = list(input())
c = ""
for i in range(len(o)):
    c += o[i]
    while e:
        c += e[i]

print(c)

Fixed submission:
o = list(input())
e = list(input())
c = ""
for i in range(len(o)):
    c += o[i]
    if i < len(e):
        c += e[i]

print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
  print((800*n) - (n//15*200))

Fixed submission:
N = int(input())
print(800*N - 200*(N//15))
Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())
c = 0
for i in range(K+1):
    for j in range(K+1):
        b = S - i - j
        if b <= k and b >= 0:
            c += 1
print(c)

Fixed submission:
K, S = map(int, input().split())
c = 0
for i in range(K+1):
    for j in range(K+1):
        b = S - i - j
        if b <= K and b >= 0:
            c += 1
print(c)

Buggy python submission (verdict: Runtime Error):
K, S = map(int, input().split())
c = 0
for i in range(K+1):
    for j in range(K+1):
        b = S - i - j
        if b <= k and b >= 0:
            c += 1
print(c)

Fixed submission:
K, S = map(int, input().split())
c = 0
for i in range(K+1):
    for j in range(K+1):
        b = S - i - j
        if b <= K and b >= 0:
            c += 1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
c = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == S:
                c += 1
print(c)                

Fixed submission:
K, S = map(int, input().split())
c = 0
for i in range(K+1):
    for j in range(K+1):
        b = S - i - j
        if b <= K and b >= 0:
            c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
x,y = map(int, input().split())
if abs(x) <= abs(y):
    c = abs(abs(x) - abs(y))
    if x >= 0 and y >= 0:
        print(c)
    elif x < 0 and y < 0:
        print(c+2)
    else:
        print(c+1)
else:
    c = abs(abs(x) - abs(y))
    if y = 0:
        print(c)
    elif x >= 0 and y >= 0:
        print(c+2)
    elif x < 0 and y < 0:
        print(c)
    else:
        print(c+1)

Fixed submission:
x,y = map(int, input().split())
if abs(x) <= abs(y):
    c = abs(abs(x) - abs(y))
    if x >= 0 and y >= 0:
        print(c)
    elif x < 0 and y < 0:
        print(c+2)
    else:
        print(c+1)
else:
    c = abs(abs(x) - abs(y))
    if y == 0 and x < 0:
        print(c)
    elif y ==0 and x>=0:
        print(c+1)
    elif x >= 0 and y >= 0:
        print(c+2)
    elif x < 0 and y < 0:
        print(c)
    else:
        print(c+1)
Buggy python submission (verdict: Runtime Error):
W, H, N = map(int, input().split())
maxX,minX,maxY,minY = W, 0, H ,0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1 and x > minX:
        minX = x
    elif a == 2 and x < maxX:
        maxX = x
    elif a == 3 and y > minY:
        minY = y
    elif a == 4 and y < maxY:
        maxY = y
        
xl = maxX - minX
yl = maxY - minY
if x1 > 0 and y1 > 0:
    print(x1*y1)
else:
    print(0)

Fixed submission:
W, H, N = map(int, input().split())
maxX,minX,maxY,minY = W, 0, H ,0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1 and x > minX:
        minX = x
    elif a == 2 and x < maxX:
        maxX = x
    elif a == 3 and y > minY:
        minY = y
    elif a == 4 and y < maxY:
        maxY = y
        
x1 = maxX - minX
y1 = maxY - minY
if x1 > 0 and y1 > 0:
    print(x1*y1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
print(a+b*h//2)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
 
s = (a + b)*h/2
print(int(s))
Buggy python submission (verdict: Runtime Error):
D = {"a":0, "b":1, "c":2}
l = ["A", "B", "C"]
 
x = [[D[a] for a in input()] for _ in range(len(l))]
c = 0
while x[c]:
    c = x[c].pop(0)
print(I[c])

Fixed submission:
D = {"a":0, "b":1, "c":2}
l = ["A", "B", "C"]
 
x = [[D[a] for a in input()] for _ in range(len(l))]
c = 0
while x[c]:
    c = x[c].pop(0)
print(l[c])