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

Fixed submission:
import sys,collections,math,random,fractions,bisect,itertools;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
x,k,d = I()

if abs(x)/d >= k:
    print(abs(x)-k*d)
else:
    if (k - math.floor(x/d))%2 == 0:
        print(abs(x%d))
    else:
        print(abs(x%d-d))

Buggy submission (verdict: Runtime Error):
import sys,collections,math,random,fractions,bisect,itertools;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
x,k,d = I()
if abs(x)/d >= k:
    print(abs(x)-k*d))
elif x > 0:
    if (k - math.floor(x/d))%2 == 0:
        print(x%d))
    else:
        print(x%d-d))
elif x <= 0:
    if (k - math.ceil(x/d))%2 == 0:
        print(x%d))
    else:
        print(x%d+d))
Problem p02732 (python)

Fixed submission:
import itertools,sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

N, = I()
A = I()
d = dict()
def dd(n):
    if n in d:
        return d[n]
    else:
        if n < 2:
            return 0
        else:
            d[n] = math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
            return d[n]
c = collections.Counter(A)
total = 0
for e in c.items():
    total += dd(e[1])
for e in A:
    print(total -  dd(c[e]) + dd(c[e]-1))

Buggy submission (verdict: Runtime Error):
import itertools,sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

N, = I()
A = I()
d = dict()
def dd(n):
    if n in d:
        return d[n]
    else:
        d[n] = math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
        return d[n]
c = collections.Counter(A)
total = 0
for e in c.items():
    total += dd(e[1])
for e in A:
    print(total -  dd(c[e]) + dd(c[e]-1))
Problem p02784 (python)

Fixed submission:
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
H,N = I()
A = I()
if sum(A) >= H:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t if len(t) > 1 else t[0]
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
H,N = I()
A = I()
if sum([A]) >= H:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t if len(t) > 1 else t[0]
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

H,N = I()
A = I()
if sum(A) >= H:
    print("Yes")
else:
    print("No")
Problem p02788 (python)

Fixed submission:
import sys,math
sr = sys.stdin.readline
def I(i=0):return [int(x)-i for x in sr().split()]
L1,L2 = [],[]

N,D,A = I()
for i in range(N):
    X,H = I()
    L1.append([X,math.ceil(H/A)])
L1 = sorted(L1)
j = 1
L2 = [-1]*N
for i in range(N):
    lim = L1[i][0] + 2*D
    for k in range(j,N):
        if L1[k][0] > lim:
            L2[i] = k-1
            j = k-1
            break
        elif k == N-1:
            L2[i] = N-1
            j = N-1
ans = 0
a,s = 0,0
for i in range(N):
    x,h = L1[i]
    h -= a
    if h > 0:
        ans += h
        a += h
        L1[i][1] = h
    else:
        L1[i][1] = 0
    while s < N and L2[s] <= i:
        a -= L1[s][1]
        s += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t 
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

H,N = I()
for i in range(N):
    A,B = I()
    L1.append([A,B,A/B])
L2 = sorted(L1,reverse=True,key=lambda x: x[2])
ans = 0
for i in range(10):
    for e in L2:
        if H >= e[0]:
            ans += H//e[0] * e[1]
            H = H%e[0]
            print(ans,H)
            break
print(ans,H)
L3 = sorted(L1,key=lambda x: x[1])
P2(L3)
if H > 0:
    for e in L3:
        if H <= e[0]:
            ans += e[1]
            break
print(ans,H)
Problem p02995 (python)

Fixed submission:
import sys,collections,math,random,fractions;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())

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

a,b,c,d = Is()
mc = b//c - (a-1)//c
md = b//d - (a-1)//d
mincom = lcm(c,d)
mcd = b//(mincom) - (a-1)//(mincom)
ans = b-a+1 - (mc + md - mcd)
#print(mc,md,mcd)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())

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

a,b,c,d = Is()
mc = b//c - (a-1)//c
md = b//d - (a-1)//d
mincom = lcm(c,d)
mcd = b//(mincom) - (a-1)//(mincom)
ans = b-a+1 - (mc + md - mcd)
#print(mc,md,mcd)
print(ans)
Problem p03262 (python)

Fixed submission:
import sys,collections,math,functools;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n, s = Is()
xs = Is()
xs2 = [abs(e-s) for e in xs]
c = xs2[0]
ans = c
for e in xs2:
    ans = gcd(ans,e)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys,collections,math,functools;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n, s = Is()
xs = Is()
xs2 = [e-s for e in xs]
gcd = functools.reduce(math.gcd, xs2)
print(gcd)
Problem p03316 (python)

Fixed submission:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
s = 0
for e in str(n):
    s += int(e)
if n%s == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k = Is()
ls = Is()
_1 = ls.index(1)
if _1 < k-1:
    _1 = k-1
elif _1 < n-k:
    _1 = n-k
print(math.ceil(_1/(k-1))+math.ceil((n-1-_1)/(k-1)))
Problem p03423 (python)

Fixed submission:
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
print(n//3)

Buggy submission (verdict: Runtime Error):
import sys
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())

H,W,D = Is()
d = dict()
for i in range(H):
    s = Is()
    for j,e in enumerate(s):
        d[e] = (i,j)
Q = I()

m = [[0]*H*W for i in range(H*W)] 
def calc(l,r):
    if m[l][r] != 0:
        return m[l][r]
    else:
        maho = 0
        for k in range(l,r,D):
            maho += abs(d[k+D][0] - d[k][0]) + abs(d[k+D][1] - d[k][1])
        m[l][r] = maho
        return maho
    
for q in range(Q):
    l,r = Is()
    maho = calc(l,r)
    print(maho)

Buggy submission (verdict: Runtime Error):
import sys
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())

H,W,D = Is()
d = dict()
for i in range(H):
    s = Is()
    for j,e in enumerate(s):
        d[e] = (i,j)
Q = I()
for q in range(Q):
    l,r = Is()
    maho = 0
    for k in range(l,r,D):
        maho += abs(d[k+D][0] - d[k][0]) + abs(d[k+D][1] - d[k][1])
    print(maho)

Buggy submission (verdict: Runtime Error):
import sys
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())

H,W,D = Is()
d = dict()
for i in range(H):
    s = Is()
    for j,e in enumerate(s):
        d[e] = (i,j)
Q = I()
for q in range(Q):
    l,r = Is()
    maho = 0
    for k in range(l,r,D):
        maho += abs(d[k+D][0] - d[k][0]) + abs(d[k+D][1] - d[k][1])
    print(maho)

Buggy submission (verdict: Runtime Error):
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W,D = Is()
d = dict()
for i in range(H):
    s = Is()
    for j,e in enumerate(s):
        d[e] = (i,j)
Q = I()
for q in range(Q):
    l,r = Is()
    maho = 0
    for k in range(l,r,D):
        maho += abs(d[k+D][0] - d[k][0]) + abs(d[k+D][1] - d[k][1])
    print(maho)

Buggy submission (verdict: Runtime Error):
import sys,collections;sys.setrecursionlimit(10**7)
import itertools
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W,D = Is()
d = dict()
for i in range(H):
    s = Is()
    for j,e in enumerate(s):
        d[e] = (i,j)
Q = I()
for q in range(Q):
    l,r = Is()
    maho = 0
    for k in range(l,r,D):
        maho += abs(d[k+D][0] - d[k][0]) + abs(d[k+D][1] - d[k][1])
    print(maho)
Problem p03490 (python)

Fixed submission:
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def S(): return input()
 
s = S()
gx,gy = Is()
l = s.split("T")
for i in range(len(l)):
    l[i] = len(l[i])
xlis,ylis = l[::2],l[1::2]
sx = xlis.pop(0) if len(xlis)>0 else 0
sy = 0
xlis.sort(reverse=True)
ylis.sort(reverse=True)
def calc(start,goal,lis):
    p = start
    for e in lis:
        if p < goal:
            p += e
        else:
            p -= e
    return p == goal
if calc(sx,gx,xlis) and calc(sy,gy,ylis):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def S(): return input()

s = S()
gx,gy = Is()
xlis,ylis = [],[]
x,y = 0,0
h = 0
for e in s:
    if e == "F":
        if h == 0:
            x += 1 
        else:
            y += 1 
    else:
        if h == 0:
            if x:
                xlis.append(x) 
        else:
            if y:
                ylis.append(y)
        x,y = 0,0
        h = not h
if h == 0:
    if x:
        xlis.append(x) 
else:
    if y:
        ylis.append(y)
sx = xlis.pop(0) if len(xlis)>0 else 0
sy = 0
xmat = [[False]*16001 for i in range(len(xlis)+1)]
ymat = [[False]*16001 for i in range(len(ylis)+1)]
xmat[0][sx] = True
ymat[0][sy] = True
def xdp(i,d):
    if xmat[i][d]:
        return True
    if i == 0:
        return False
    xmat[i][d] = xdp(i-1,d + xlis[i-1]) or xdp(i-1,d - xlis[i-1])
    return xmat[i][d]
def ydp(i,d):
    if ymat[i][d]:
        return True
    if i == 0:
        return False
    ymat[i][d] = ydp(i-1,d + ylis[i-1]) or ydp(i-1,d - ylis[i-1])
    return xmat[i][d]
if xdp(len(xlis),gx) and ydp(len(ylis),gy):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def S(): return input()

s = S()
gx,gy = Is()
xlis,ylis = [],[]
x,y = 0,0
h = 0
for e in s:
    if e == "F":
        if h == 0:
            x += 1 
        else:
            y += 1 
    else:
        if h == 0:
            if x:
                xlis.append(x) 
        else:
            if y:
                ylis.append(y)
        x,y = 0,0
        h = not h
if h == 0:
    if x:
        xlis.append(x) 
else:
    if y:
        ylis.append(y)
sx = xlis.pop(0) if len(xlis)>0 else 0
sy = 0
xmat = [[False]*16001 for i in range(len(xlis)+1)]
ymat = [[False]*16001 for i in range(len(ylis)+1)]
xmat[0][sx] = True
ymat[0][sy] = True
def xdp(i,d):
    if xmat[i][d]:
        return True
    if i == 0:
        return False
    xmat[i][d] = xdp(i-1,d + lis[i-1]) or xdp(i-1,d - lis[i-1])
    return xmat[i][d]
def ydp(i,d):
    if ymat[i][d]:
        return True
    if i == 0:
        return False
    ymat[i][d] = ydp(i-1,d + lis[i-1]) or ydp(i-1,d - lis[i-1])
    return xmat[i][d]
if xdp(len(xlis),gx) and ydp(len(ylis),gy):
    print("Yes")
else:
    print("No")
Problem p03543 (python)

Fixed submission:
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

x = S() 
ans = "No"
for i in range(2):
    c = 0
    for j in range(i+1,i+3):
        if x[i] == x[j]:
            c += 1
        else:
            break
    if c == 2:
        ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
import sys,collections
sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

x = S()
c = 0
ans = "No"
for i in range(len(x)):
    for j in range(i,len(x)-i):
        if x[i] == x[i + j]:
            c += 1
    if c = 3:
        ans = "Yes"
print(ans)
Problem p03587 (python)

Fixed submission:
S = input()
print(S.count("1"))

Buggy submission (verdict: Runtime Error):
S = input()
print(S.count(1))
Problem p03589 (python)

Fixed submission:
N = int(input())
i = 1
while i<=7000:
    if N/i >= 4:
        i += 100
        continue
    if i >100:
        i -= 100
    for x in range(i,3501):
        for y in range(i,3501):
            a = (4*x*y - N*y - N*x)
            if a == 0:
                continue
            z = N*x*y/a
            if z == int(z) and z >= 1:
                print(x,y,int(z))
                exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
i,j = 1,1
for x in range(i,3501):
    for y in range(j,3501):
        z = N*x*y/(4*x*y - N*y - N*x)
        if z == int(z) and z >= 1:
            print(x,y,int(z))
            exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
i,j = 1,1
while i<3501 and j<3501:
    if N/i >= 4:
        i += i
        continue
    if N/j >= 4:
        j += j
        continue
    i = i//2
    j = j//2
    for x in range(i,3501):
        for y in range(j,3501):
            z = N*x*y/(4*x*y - N*y - N*x)
            if z == int(z) and z >= 1:
                print(x,y,int(z))
                exit()
Problem p03635 (python)

Fixed submission:
n,m =map(int,input().split())
print((n-1)*(m-1))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Here your code !
import math
N = input()
A = list(map(int, input().split()))

f,e,d = 0,0,0

for a in A:
    x = a % 4
    if(x==0):
        f = f+1
    elif(x==2):
        e = e+1
    else:
        d = d+1
if(e>0): d = d+1
if(d <= math.ceil(len(A)/2)):
    print("Yes")
else:
    print("No")
Problem p03636 (python)

Fixed submission:
s = input()
print(s[0] + str(len(s)-2) + s[len(s)-1])

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

f,e,d = 0,0,0

for a in A:
    x = a % 4
    if(x==0):
        f = f+1
    elif(x==2):
        e = e+1
    else:
        d = d+1
if(e>0): d = d+1
if(d <= math.ceil(len(A)/2)):
    print("Yes")
else:
    print("No")
Problem p03645 (python)

Fixed submission:
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

seta,setb = set(),set()
af,bf = [False]*M,[False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    if a-1 == 0:
        af[m] = True
        seta.add(b-1)
    if b-1 == N-1:
        bf[m] = True
        setb.add(a-1)
    if af[m] and bf[m]:
        ans = "POSSIBLE"
        break
    
for a in seta:
    if ans == "POSSIBLE":
        break
    if a in setb:
        ans = "POSSIBLE"
        break

print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

ls = {}
f = [False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    ls[a-1] = b-1
    
    if a-1 == 0 and b-1 == N-1:
        ans = "POSSIBLE"
    if a-1 == 0:
        f[a-1] = True

for m in range(M):
    if ans == "POSSIBLE":
        beak
    if f[m] and ls[m] in ls and  ls[ls[m]] == N-1 :
        ans = "POSSIBLE"

print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

ls = {}
f = [False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    ls[a-1] = b-1
    
    if a-1 == 0 and b-1 == N-1:
        ans = "POSSIBLE"
    if a-1 == 0:
        f[a-1] = True

for m in range(M):
    if ans == "POSSIBLE":
    if f[m] and ls[m] in ls and  ls[ls[m]] == N-1 :
        ans = "POSSIBLE"

print(ans)

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

ans = "IMPOSSIBLE"

ls = [[] for m in range(M)]
for m in range(M):
    a,b = map(int,(input().split()))
    ls[m].append(a-1)
    ls[m].append(b-1)
    
    if a-1 == 0 and b == N-1:
        ans = "POSSIBLE"
    if a-1 == 0:
        ls[m].append("P")
    else:
        ls[m].append("I")

for m in range(M):
    if ls[m][2] == "P" and ls[ls[m][1]][1] == N-1:
        ans = "POSSIBLE"

print(ans)
Problem p03660 (python)

Fixed submission:
import sys
sys.setrecursionlimit(sys.getrecursionlimit()*1000)

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

depth = [None]*(N+1)
def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e[0] != p:
            DFS(e[0], v, d + e[1])
DFS(1,0,0)

depthN = [None]*(N+1)
def DFSN(v,p,d):
    depthN[v] = d
    for e in tree[v]:
        if e[0] != p:
            DFSN(e[0], v, d + e[1])
DFSN(N,0,0)

black = 0
for i in range(1,N):
    if depth[i] <= depthN[i]:
        black += 1

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

Buggy submission (verdict: Runtime Error):
import sys

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

depth = [None]*(N+1)
def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e[0] != p:
            DFS(e[0], v, d + e[1])
DFS(1,0,0)

depthN = [None]*(N+1)
def DFSN(v,p,d):
    depthN[v] = d
    for e in tree[v]:
        if e[0] != p:
            DFSN(e[0], v, d + e[1])
DFSN(N,0,0)

black = 0
for i in range(1,N):
    if depth[i] <= depthN[i]:
        black += 1

if black > N/2:
    print("Fennec")
else:
    print("Snuke")
Problem p03713 (python)

Fixed submission:
import math
H,W = map(int,input().split())

if H%3==0 or W%3==0:
    print(0)
elif H==2 and W==2:
    print(1)
else:

    def cal(x,y):
        return max(x*y,(W-x)*y,(H-y)*W) - min(x*y,(W-x)*y,(H-y)*W)

    x1,x2 = math.floor(W/2),math.ceil(W/2)
    y1,y2 = math.floor((2*H)/3),math.ceil((2*H)/3)

    ans1 = min(cal(x1,y1),cal(x2,y1),cal(x1,y2),cal(x2,y2))

    W,H = H,W
    x1,x2 = math.floor(W/2),math.ceil(W/2)
    y1,y2 = math.floor((2*H)/3),math.ceil((2*H)/3)

    ans2 = min(cal(x1,y1),cal(x2,y1),cal(x1,y2),cal(x2,y2))

    if H ==2 or W == 2:
        print(min(ans1,ans2,max(H,W)))
    else:
        print(min(ans1,ans2,H,W))

Buggy submission (verdict: Runtime Error):
import math
H,W = map(int,input().split())

if H%3==0 or W%3==0:
    print(0)
elif H==2 and W==2:
    print(1)
else:
    def cal2(h,w):
        x1,x2 = math.floor(w/2),math.ceil(w/2)
        y1,y2 = math.floor((2*h)/3),math.ceil((2*h)/3)
        return min(cal(x1,y1),cal(x2,y1),cal(x1,y2),cal(x2,y2))
        def cal(x,y):
            return max(x*y,(w-x)*y,(h-y)*w) - min(x*y,(w-x)*y,(h-y)*w)

    if H==2 or W ==2:
        print(min(cal2(H,W),cal2(W,H),max(H,W)))
    else:
        print(min(cal2(H,W),cal2(W,H),H,W))

Buggy submission (verdict: Runtime Error):
import math
H,W = map(int,input().split())

if H%3==0 or W%3==0:
    print(0)
elif H==2 and W==2:
    print(1)
else:
    def cal(x,y):
        return max(x*y,(W-x)*y,(H-y)*W) - min(x*y,(W-x)*y,(H-y)*W)

    def cal2(H,W):
        x1,x2 = math.floor(W/2),math.ceil(W/2)
        y1,y2 = math.floor((2*H)/3),math.ceil((2*H)/3)
        return min(cal(x1,y1),cal(x2,y1),cal(x1,y2),cal(x2,y2),H,W)

    print(min(cal2(H,W),cal2(W,H))
Problem p02663 (python)

Fixed submission:
H1, M1, H2, M2, K = (int(x) for x in input().split())
if H1 > H2: 
    H1 -= 24

before = H1 * 60 + M1
after = H2 * 60 + M2
after -= K

time = after - before
print(time)

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv

H1 = int(args[1])
M1 = int(args[2])
H2 = int(args[3])
M2 = int(args[4])
K = int(args[5])

if H1 > H2: 
    H1 -= 24

before = H1 * 60 + M1
after = H2 * 60 + M2
after -= K

time = after - before
print(time)

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv

H1 = int(args[1])
M1 = int(args[2])
H2 = int(args[3])
M2 = int(args[4])
K = int(args[5])

if H1 > H2: 
    H1 -= 24

before = H1 * 60 + M1
after = H2 * 60 + M2
after -= K

time = after - before
print(time)
Problem p02555 (python)

Fixed submission:
from scipy.special import comb

s = int(input())
maxcount = int(s / 3)
amari = s % 3
count = 0
if amari == 0 and maxcount > 0:
    count = 1

for i in range(maxcount):
    amari = s - (i + 1) * 3
    if amari != 0:
        count += comb(amari + i, i, exact=True)
    count %= 1000000007
print(count)

Buggy submission (verdict: Runtime Error):
s = int(input())
maxcount = int(s / 3)
amari = s % 3
count = 0
if amari == 0 and maxcount > 0:
    count = 1

for i in range(maxcount):
    amari = s - (i + 1) * 3
    count += comb(amari + i, i, exact=True)
    count %= 1000000007
print(count)
Problem p02612 (python)

Fixed submission:
n = int(input())
ans = (1000-(n%1000))%1000
print(ans)

Buggy submission (verdict: Runtime Error):
int a = input()
print((1000-(a%1000))%1000)

Buggy submission (verdict: Runtime Error):
a = int(input())
print((1000-(N%1000))%1000)