ZhenlongDai/ACPR huggingface dataset:
Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
k = int(input())

for i, s in enumerate(S):
    if s != "1":
        print(s)
        break
    elif i == k:
        print(1)
        break
else:
    print(1)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S = input()
k = int(input())

for i, s in enumerate(S):
    if s != "1":
        print(s)
        break
    elif i + 1 == k:
        print(1)
        break
else:
    print(1)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input().strip()
K = input().strip()

if len(S) == 1:
    print(S)

if len(S) == sum([int(i) for i in S]):
    print(1)

for i in S:
    if i != "1":
        print(i)
        break


Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S = input().strip()
K = input().strip()

if len(K) <= 3:
    k = int(K)
else:
    k = 1000

if len(S) == 1:
    print(S)
elif len(S) == sum([int(i) for i in S]):
    print(1)
else:
    for i in S:
        k -= 1
        if (k == 0) or (i != "1"):
            print(i)
            break

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()

K = int(input())

tmp = 0
index = 0
res = ""

while K > tmp and index < len(S):
    if S[index] == "1":
        res = "1"
    else:
        res = S[index]
        break;
    index += 1

print(res)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S = input()

K = int(input())

index = 0
res = ""

while K > index and index < len(S):
    if S[index] == "1":
        res = "1"
    else:
        res = S[index]
        break;
    index += 1

print(res)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k = int(input())
cnt = 0
ans = 1
for i in s:
    if i == 1:
        cnt += 1
    else:
        ans = i
        break

if k <= cnt:
    print(1)
else:
    print(ans)

Failing test case input:
1214
9

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
s = input()
k = int(input())
cnt = 0
ans = 1
for i in s:
    if i == "1":
        cnt += 1
    else:
        ans = i
        break

if k <= cnt:
    print(1)
else:
    print(ans)
Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y = map(int,input().split())
a=y-x
b=a*(a-1)/2
print(b-x)

Failing test case input:
-10 0

Expected output:
55


Actual output:
55.0


Fixed submission (verdict: Accepted):
x,y = map(int,input().split())
a=y-x
b=a*(a-1)/2
print(round(b-x))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())

def m(x):
    return x*(x+1)/2

print(m(b-a-1)-a)

Failing test case input:
1 72

Expected output:
2484


Actual output:
2484.0


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())

def m(x):
    return x*(x+1)/2

print(int(m(b-a-1)-a))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
n = b-a

print(n*(n+1)/2 - b)

Failing test case input:
0 25

Expected output:
300


Actual output:
300.0


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
n = b-a

print(int(n*(n+1)/2) - b)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

c = b - a
N = (1+c)*c/2
print(b-N)

Failing test case input:
0 -7

Expected output:
28


Actual output:
-28.0


Fixed submission (verdict: Accepted):

a, b = map(int, input().split())

c = b - a
N = (1+c)*c/2
print(int(N-b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = [int(i) for i in input().split()]
n = b-a-1
print(n*(n+1)/2-a)

Failing test case input:
9 33

Expected output:
267


Actual output:
267.0


Fixed submission (verdict: Accepted):
a,b = [int(i) for i in input().split()]
n = b-a-1
print(int(n*(n+1)/2-a))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a,b=map(int,input().split())
d=b-a
b0=d*(d+1)/2
snow=b0-b
int(snow)

Failing test case input:
118 1322

Expected output:
724088


Actual output:

Fixed submission (verdict: Accepted):

a,b=map(int,input().split())
d=b-a
b0=d*(d+1)/2
snow=b0-b
print(int(snow))

Problem: p03328
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B = map(int, input().split())

print((B - A )*( B - A +1)/2 - B )

Failing test case input:
1 -11

Expected output:
77


Actual output:
77.0


Fixed submission (verdict: Accepted):
A, B = map(int, input().split())

print(int((B - A )*( B - A +1)/2 - B ))

Problem: p03328
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b=input().split()
a=int(a)
b=int(b)
print((b-a)*(b-a-1)/2-b)

Failing test case input:
64 1208

Expected output:
653732


Actual output:
652588.0


Fixed submission (verdict: Accepted):
a,b=input().split()
a=int(a)
b=int(b)
print(int((b-a)*(b-a-1)/2-a))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
print((b-a)*(b-a+1)/2-b)

Failing test case input:
118 2165

Expected output:
2093963


Actual output:
2093963.0


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
print(((b-a)**2-a-b)
Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a,b=map(int,input().split())
d=b-a
b0=d*(d+1)/2
snow=b0-b
print(snow)

Failing test case input:
96 816

Expected output:
258744


Actual output:
258744.0


Fixed submission (verdict: Accepted):

a,b=map(int,input().split())
d=b-a
b0=d*(d+1)/2
snow=b0-b
print(int(snow))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = [int(i) for i in input().split(' ')]
n=b-a
N=n-1
x=(1/2*N)*(N+1)
y= x - a
print(y)


Failing test case input:
5 33

Expected output:
373


Actual output:
373.0


Fixed submission (verdict: Accepted):
a,b = [int(i) for i in input().split(' ')]
n=b-a
N=n-1
x=(1/2*N)*(N+1)
y= x - a
print(int(y))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
print((b-a)*(b-a+1)/2-b)

Failing test case input:
105 65

Expected output:
715


Actual output:
715.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
print((b-a)*(b-a+1)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
print(((a-b)*(a-b)-(a+b))/2)

Failing test case input:
5 130

Expected output:
7745


Actual output:
7745.0


Fixed submission (verdict: Accepted):
import math

a, b = map(int, input().split())
print(math.floor(((a-b)*(a-b)-(a+b))/2))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

ans = (b-a)*(b-a-1)/2-a

print(ans)

Failing test case input:
-6 -2

Expected output:
12


Actual output:
12.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())

print(int(0.5*(b-a)*(b-a-1)-a))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = list(map(int, input().split()))
n = b-a
print(n*(n+1)/2 - b)

Failing test case input:
-6 -2

Expected output:
12


Actual output:
12.0


Fixed submission (verdict: Accepted):
a,b = list(map(int, input().split()))
n = b-a
print(int(n*(n+1)/2 - b))

Problem: p03328
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b=input().split()
a=int(a)
b=int(b)
print((b-a)*(b-a-1)/2-a)

Failing test case input:
118 4579

Expected output:
9947912


Actual output:
9947912.0


Fixed submission (verdict: Accepted):
a,b=input().split()
a=int(a)
b=int(b)
print(int((b-a)*(b-a-1)/2-a))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a ,b = map(int, input(). split())
x = (b - a)*(b - a - 1)/2 - a
print(x)

Failing test case input:
96 590

Expected output:
121675


Actual output:
121675.0


Fixed submission (verdict: Accepted):
a ,b = map(int, input(). split())
x = (b - a)*(b - a - 1)/2 - a
print(int(x))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=input().split(" ")
a=int(n[0])
b=int(n[1])
c=b-a
print(((c*(c+1))/2)-b)

Failing test case input:
120 3210

Expected output:
4772385


Actual output:
4772385.0


Fixed submission (verdict: Accepted):
n=input().split(" ")
a=int(n[0])
b=int(n[1])
c=b-a
print (int(((c*(c+1))/2)-b))
Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

print(0.5*(b-a)*(b-a-1)-a)


Failing test case input:
-4 -11

Expected output:
32


Actual output:
32.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())

print(int(0.5*(b-a)*(b-a-1)-a))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B = map(int,input().split())
Dif = B - A
Larger = (1+Dif)*Dif/2
DepthSnow = Larger - B
print(DepthSnow)

Failing test case input:
167 1322

Expected output:
666268


Actual output:
666268.0


Fixed submission (verdict: Accepted):
A,B = map(int,input().split())
Dif = B - A
Larger = int((1+Dif)*Dif/2)
DepthSnow = Larger - B
print(DepthSnow)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
n=b-a
print(n*(n+1)/2-b)

Failing test case input:
83 3210

Expected output:
4887418


Actual output:
4887418.0


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
n=b-a
print(int(n*(n+1)/2-b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
lst=list(map(int,input().split()))
a=lst[0]
b=lst[1]
print((b-a)*(b-a+1)/2-b)

Failing test case input:
83 2323

Expected output:
2507597


Actual output:
2507597.0


Fixed submission (verdict: Accepted):
lst=list(map(int,input().split()))
a=lst[0]
b=lst[1]
k=(b-a)*(b-a+1)/2-b
print(int(k))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
s = a-b
m = int(s*(s+1)/2)
print(m-b)

Failing test case input:
96 262

Expected output:
13599


Actual output:
13433


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
print(int((b-a)*(b-a+1)/2)-b)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
d = b - a
print((d*(d+1)/2)-b)

Failing test case input:
1 42

Expected output:
819


Actual output:
819.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
d = b - a
print(int((d*(d+1)/2)-b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
print((1+(b-a))*(b-a))

Failing test case input:
32 1322

Expected output:
831373


Actual output:
1665390


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
print(((1+(b-a))*(b-a))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
n=b-a-1
h=n*(n+1)/2
print(h-a)

Failing test case input:
57 1190

Expected output:
641221


Actual output:
641221.0


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
n=b-a-1
h=n*(n+1)/2
print(int(h-a))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b= map(int, input().split())
c = b-a
n = c*(c+1)/2
ans = n-b
print(ans)

Failing test case input:
64 1208

Expected output:
653732


Actual output:
653732.0


Fixed submission (verdict: Accepted):
a, b= map(int, input().split())
c = b-a
n = c*(c+1)/2
ans = n-b
print(int(ans))
Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
print(1/2*(a**2-a-2*a*b-b+b**2))


Failing test case input:
5 177

Expected output:
14701


Actual output:
14701.0


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
print(int(1/2*(a**2-a-2*a*b-b+b**2)))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

print((b-a)*(b-a + 1)/2 - b)


Failing test case input:
96 262

Expected output:
13599


Actual output:
13599.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())

print(int((b-a)*(b-a + 1)/2 - b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a,b=map(int,input().split())
d=b-a
b0=d*(d+1)/2
snow=b0-b
snow

Failing test case input:
64 816

Expected output:
282312


Actual output:

Fixed submission (verdict: Accepted):

a,b=map(int,input().split())
d=b-a
b0=d*(d+1)/2
snow=b0-b
print(int(snow))

Problem: p03328
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a,b = map(int,input().split())

s = b-a

y = s*(s-1)/2 - b

print(int(y)) 

Failing test case input:
2 -9

Expected output:
64


Actual output:
75


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())

s = b-a

y = s*(s-1)/2 - a

print(int(y))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
print(abs((b-a)*(b-a+1)/2-b))

Failing test case input:
1 -11

Expected output:
77


Actual output:
77.0


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
print(((b-a)**2-a-b)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int, input().split())
print(b*(b+1)/2-(b-a))

Failing test case input:
44 2323

Expected output:
2595737


Actual output:
2697047.0


Fixed submission (verdict: Accepted):
a,b=map(int, input().split())
print(int((b-a)*(b-a+1)/2-b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

c = b - a
N = (1+c)*c/2
print(N-b)


Failing test case input:
-4 -11

Expected output:
32


Actual output:
32.0


Fixed submission (verdict: Accepted):

a, b = map(int, input().split())

c = b - a
N = (1+c)*c/2
print(int(N-b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import sys




read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b = map(int, readline().split())
bt = (1 + (b - a)) 

print(bt - b)


Failing test case input:
118 1322

Expected output:
724088


Actual output:
-117


Fixed submission (verdict: Accepted):


import sys




read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

a, b = map(int, readline().split())

bt = (1 + (b - a)) / 2 * (b - a)

print(int(bt - b))
Problem: p03328
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a, b = map(int, input().split())

i = b - a
tall = i * (i + 1) / 2 - b
print(tall)

Failing test case input:
8 16

Expected output:
20


Actual output:
20.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
i = b - a
print(i * (i + 1)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
print((b - a) * (b - a - 1) / 2 - a)


Failing test case input:
196 147

Expected output:
1029


Actual output:
1029.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
ans = (b - a) * (b - a - 1) / 2 - a
print(int(ans))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=input().split(" ")
a=int(a)
b=int(b)
print((b-a)*(b-a+1)/2-b)

Failing test case input:
64 1208

Expected output:
653732


Actual output:
653732.0


Fixed submission (verdict: Accepted):
a,b=input().split(" ")
a=int(a)
b=int(b)
print(int((b-a)*(b-a+1)/2-b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

ans = (b-a)*(b-a-1)*0.5-a

print(ans)


Failing test case input:
1 33

Expected output:
495


Actual output:
495.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())

print(int(0.5*(b-a)*(b-a-1)-a))

Problem: p03328
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b=input().split()
a=int(a)
b=int(b)
print((b-a)*(b-a-1)/2)

Failing test case input:
96 590

Expected output:
121675


Actual output:
121771.0


Fixed submission (verdict: Accepted):
a,b=input().split()
a=int(a)
b=int(b)
print(int((b-a)*(b-a-1)/2-a))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
n = b - a
s = 1/2 * n * (1 + n)
print(s - b)

Failing test case input:
96 147

Expected output:
1179


Actual output:
1179.0


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
n = b - a
s = 1/2 * n * (1 + n)
x = s - b
print(int(x))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int, input().split())
print(b*(b+1)/2-b)

Failing test case input:
1 33

Expected output:
495


Actual output:
528.0


Fixed submission (verdict: Accepted):
a,b=map(int, input().split())
print(int((b-a)*(b-a+1)/2-b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


a, b = map(int, input().split())
n = b-a

print((n*(n+1))/2 - b)

Failing test case input:
3 -4

Expected output:
25


Actual output:
25.0


Fixed submission (verdict: Accepted):


a, b = map(int, input().split())
n = b-a

print((n*(n+1))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())

depth=(b-a)*(b-a+1)/2-b

print(depth)

Failing test case input:
120 3210

Expected output:
4772385


Actual output:
4772385.0


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())

depth=(b-a)*(b-a+1)/2-b

print(int(depth))
Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())

print((b-a)*(b-a+1)/2-b)

Failing test case input:
1 -11

Expected output:
77


Actual output:
77.0


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())

print(int((b-a)*(b-a+1)/2-b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
print(int(b-a*(b-a+1)/2)-b)


Failing test case input:
2 30

Expected output:
376


Actual output:
-29


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
print(int((b-a)*(b-a+1)/2)-b)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split());print((b-a)**2-a-b)

Failing test case input:
167 1322

Expected output:
666268


Actual output:
1332536


Fixed submission (verdict: Accepted):
a,b=map(int,input().split());print(((b-a)**2-a-b)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
diff = b - a
print((diff * (diff+1) )/ 2 - b)

Failing test case input:
96 336

Expected output:
28584


Actual output:
28584.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
diff = b - a
print((diff * (diff+1) )

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main2():
    strbuf = input("");
    strbufs = strbuf.split();
    buf = [];
    for i in range(2):
        buf.append(int(strbufs[i]));
    sa = buf[1] - buf[0];
    takasa = sa * (sa + 1) / 2;
    result = takasa - buf[1];
    print(result);


if __name__ == '__main__':
    main2()

Failing test case input:
46 130

Expected output:
3440


Actual output:
3440.0


Fixed submission (verdict: Accepted):
def main2():
    strbuf = input("");
    strbufs = strbuf.split();
    buf = [];
    for i in range(2):
        buf.append(int(strbufs[i]));
    sa = buf[1] - buf[0];
    takasa = sa * (sa + 1) / 2;
    result = takasa - buf[1];
    print(int(result));


if __name__ == '__main__':
    main2()

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())

print( ((b-a) * (b-a) - b - a) / 2)


Failing test case input:
1 42

Expected output:
819


Actual output:
819.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())

print( ((b-a) * (b-a) - b - a)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
b_index = b-a
a_index = b_index - 1
get_height = lambda n: n*(n+1)/2

a_height = get_height(a_index)
b_height = get_height(b_index)
snow_height = b_height - b
print(snow_height)

Failing test case input:
-6 -2

Expected output:
12


Actual output:
12.0


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
b_index = b-a
a_index = b_index - 1
get_height = lambda n: n*(n+1)/2

a_height = get_height(a_index)
b_height = get_height(b_index)
snow_height = b_height - b
print(int(snow_height))
Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
n = b-a
tower = ((n+1)*n)/2
print(tower-b)


Failing test case input:
4 14

Expected output:
41


Actual output:
41.0


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
n = b-a
tower = ((n+1)*n)/2
print(int(tower-b))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


a, b = [int(x) for x in input().split()]

print(a, b)

diff = b - a
b_height = diff * (diff + 1) / 2
snow_height = int(b_height - b)

print(snow_height)


Failing test case input:
105 65

Expected output:
715


Actual output:
105 65
715


Fixed submission (verdict: Accepted):


a, b = [int(x) for x in input().split()]

diff = b - a
b_height = diff * (diff + 1) / 2
snow_height = int(b_height - b)

print(snow_height)

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

a_b = input().split()
a = int(a_b[0])
b = int(a_b[1])
n = b - a

h = (n - 1) * n / 2 - a


Failing test case input:
105 147

Expected output:
756


Actual output:

Fixed submission (verdict: Accepted):

a_b = input().split()
a = int(a_b[0])
b = int(a_b[1])
n = b - a

h = (n - 1) * n / 2 - a

print(int(h))

Problem: p03328
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
print((b-a-1)*(b-a-2)/2)

Failing test case input:
105 88

Expected output:
48


Actual output:
171.0


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
print((b-a)*(b-a+1)
Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h, w = map(int, input().split())

s_org = h * w

answer = h * w
for i in range(2):
  if i == 1:
    h, w = w, h
  for height in range(1, h+1):
    s1 = height * w
    remain_height = h - height
    s2 = remain_height * int(w / 2)
    s3 = s_org - (s1 + s2)
    s_max = max([s1, s2, s3])
    s_min = min([s1, s2, s3])
    answer = min([answer, (s_max - s_min)])

    s1 = height * w
    s2 = (h - height) * w
    s3 = s_org - (s1 + s2)
    s_max = max([s1, s2, s3])
    s_min = min([s1, s2, s3])
    answer = min([answer, (s_max - s_min)])
  
print(answer)

Failing test case input:
000011 001101

Expected output:
0


Actual output:
554


Fixed submission (verdict: Accepted):
h, w = map(int, input().split())

s_org = h * w

answer = h * w
for i in range(2):
  if i == 1:
    h, w = w, h
  for height in range(1, h+1):
    s1 = height * w
    remain_height = h - height
    s2 = remain_height * int(w / 2)
    s3 = s_org - (s1 + s2)
    s_max = max([s1, s2, s3])
    s_min = min([s1, s2, s3])
    answer = min([answer, (s_max - s_min)])

    s1 = height * w
    s2 = int((h - height) / 2) * w
    s3 = s_org - (s1 + s2)
    s_max = max([s1, s2, s3])
    s_min = min([s1, s2, s3])
    answer = min([answer, (s_max - s_min)])
  
print(answer)

Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h, w = map(int,input().split())

if w % 3 == 0 or h % 3 == 0:
    print(0)

else:
    s = h * w
    l = []
    for i in range(0,2):
        a = (int(w/3) + i) * h
        b = (w - (int(w/3) + i)) * int(h/2)
        c = s - a - b
        l.append(max([a,b,c])-min([a,b,c]))
    for j in range(0,2):
        a = (int(h/3) + j) * w
        b = (h - (int(h/3) + j)) * int(w/2)
        c = s - a - b
        l.append(max([a,b,c])-min([a,b,c]))
    print(min(l))

Failing test case input:
101111 000101

Expected output:
101


Actual output:
50589


Fixed submission (verdict: Accepted):
h, w = map(int,input().split())

if w % 3 == 0 or h % 3 == 0:
    print(0)

else:
    s = h * w
    l = [h,w]
    for i in range(0,2):
        if w == 2 and i == 0:
            continue
        a = (int(w/3) + i) * h
        b = (w - (int(w/3) + i)) * int(h/2)
        c = s - a - b
        
        l.append(max([a,b,c])-min([a,b,c]))
    for j in range(0,2):
        if h == 2 and j == 0:
            continue
        a = (int(h/3) + j) * w
        b = (h - (int(h/3) + j)) * int(w/2)
        c = s - a - b
        
        l.append(max([a,b,c])-min([a,b,c]))
    print(min(l))
Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
    print(0)
    sys.exit()
S = H * W
ans = S
for h in range(H):
    a, b, c = int(h * W), int((H - h) * (W - int(W / 2))), int((H - h) * int(W / 2))
    S_max, S_min = max(max(a, b), c), min(min(a, b), c)
    ans = min(ans, abs(S_max - S_min))
print(ans)


Failing test case input:
101111 000001

Expected output:
1


Actual output:
50556


Fixed submission (verdict: Accepted):
H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
    print(0)
    exit()
ans = H * W
for i in range(2):
    for h in range(1, H):
        s = [h * W, W 
        s2 = [h * W, (H - h) 
        ans = min(ans, min(max(s) - min(s), max(s2) - min(s2)))
    H, W = W, H
print(ans)

Problem: p03713
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):



h,w = map(int,input().split())

def solve(H,W):
    mid = w
    ans = float('inf')
    for i in range(1,H):
        Smin = min(i*W,mid*(H-i),(W-mid)*(H-i))
        Smax = max(i*W,mid*(H-i),(W-mid)*(H-i))
        ans = min(ans,Smax-Smin)
    return ans
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    print(min(solve(h,w),solve(w,h)))


Failing test case input:
001000 110111

Expected output:
500


Actual output:
55055500


Fixed submission (verdict: Accepted):



import math
h,w = map(int,input().split())

def solve(H,W):
    mid = math.floor(W/2)
    ans = float('inf')
    for i in range(1,H):
        Smin = min(i*W,mid*(H-i),(W-mid)*(H-i))
        Smax = max(i*W,mid*(H-i),(W-mid)*(H-i))
        ans = min(ans,Smax-Smin)
    return min(ans,H)
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    print(min(solve(h,w),solve(w,h)))

Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h, w = map(int,input().split())

if w % 3 == 0 or h % 3 == 0:
    print(0)

else:
    s = h * w
    l = []
    for i in range(0,2):
        if w == 2 and i == 0:
            continue
        a = (int(w/3) + i) * h
        b = (w - (int(w/3) + i)) * int(h/2)
        c = s - a - b
        
        l.append(max([a,b,c])-min([a,b,c]))
    for j in range(0,2):
        if h == 2 and j == 0:
            continue
        a = (int(h/3) + j) * w
        b = (h - (int(h/3) + j)) * int(w/2)
        c = s - a - b
        
        l.append(max([a,b,c])-min([a,b,c]))
    print(min(l))

Failing test case input:
101111 000101

Expected output:
101


Actual output:
50589


Fixed submission (verdict: Accepted):
h, w = map(int,input().split())

if w % 3 == 0 or h % 3 == 0:
    print(0)

else:
    s = h * w
    l = [h,w]
    for i in range(0,2):
        if w == 2 and i == 0:
            continue
        a = (int(w/3) + i) * h
        b = (w - (int(w/3) + i)) * int(h/2)
        c = s - a - b
        
        l.append(max([a,b,c])-min([a,b,c]))
    for j in range(0,2):
        if h == 2 and j == 0:
            continue
        a = (int(h/3) + j) * w
        b = (h - (int(h/3) + j)) * int(w/2)
        c = s - a - b
        
        l.append(max([a,b,c])-min([a,b,c]))
    print(min(l))
Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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)))

Failing test case input:
000110 101000

Expected output:
55


Actual output:
110


Fixed submission (verdict: Accepted):
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))

Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

H,W = map(int,input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    if W < H:   H,W = W,H
    ans = 1e10
    Hp = [H, math.ceil(H/2), math.floor(H/2)]
    for x in range(1, W):
        S = [Hp[0]*x, Hp[1]*(W-x), Hp[2]*(W-x)]
        temp = max(S) - min(S)
        if ans > temp:  ans = temp
    print(ans)

Failing test case input:
000011 001100

Expected output:
11


Actual output:
712


Fixed submission (verdict: Accepted):
import math

H,W = map(int,input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    L = [[H,W], [W,H]]
    ans = 1e10
    for H,W in L: 
        Hp = [H, math.ceil(H/2), math.floor(H/2)]
        for x in range(1, W):
            S = [Hp[0]*x, Hp[1]*(W-x), Hp[2]*(W-x)]
            temp = max(S) - min(S)
            if ans > temp:  ans = temp

    ans = min([ans, W, H])
    print(ans)
Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import math

h, w = map(int, input().split())

if h > w:
    h, w = w, h

y = math.floor(h / 2)

x = 1
res = 10**12

while x < w:
    x2 = math.floor((w - x) / 2) + x
    areas = [x * h, (x2 - x) * h, (w - x2) * h]
    areas.sort()
    diff = areas[2] - areas[0]
    if diff < res:
        res = diff

    areas = [x * h, (w - x) * y, (w - x) * (h - y)]
    areas.sort()
    diff = areas[2] - areas[0]
    if diff < res:
        res = diff
    
    x += 1

print(res)


Failing test case input:
100001 111100

Expected output:
55550


Actual output:
87034


Fixed submission (verdict: Accepted):


import math

def solve(h, w):

    y = math.floor(h / 2)

    x = 1
    res = 10**12

    while x <= w / 2:
        x2 = math.floor((w - x) / 2) + x
        areas = [x * h, (x2 - x) * h, (w - x2) * h]
        areas.sort()

        diff = areas[2] - areas[0]
        if diff < res:
            res = diff

        areas = [x * h, (w - x) * y, (w - x) * (h - y)]
        areas.sort()

        diff = areas[2] - areas[0]

        if diff < res:
            res = diff
        
        x += 1

    return(res)


h, w = map(int, input().split())

print(min(solve(h, w), solve(w, h)))

Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

H,W = map(int,input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    L = [[H,W], [W,H]]
    ans = 1e10
    for H,W in L: 
        Hp = [H, math.ceil(H/2), math.floor(H/2)]
        for x in range(1, W):
            S = [Hp[0]*x, Hp[1]*(W-x), Hp[2]*(W-x)]
            temp = max(S) - min(S)
            if ans > temp:  ans = temp
            else:   break
    print(ans)

Failing test case input:
111101 110011

Expected output:
92039


Actual output:
92221


Fixed submission (verdict: Accepted):
import math

H,W = map(int,input().split())

if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    L = [[H,W], [W,H]]
    ans = 1e10
    for H,W in L: 
        Hp = [H, math.ceil(H/2), math.floor(H/2)]
        for x in range(1, W):
            S = [Hp[0]*x, Hp[1]*(W-x), Hp[2]*(W-x)]
            temp = max(S) - min(S)
            if ans > temp:  ans = temp

    ans = min([ans, W, H])
    print(ans)
Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h,w = map(int,input().split())
if h % 3 == 0 or w % 3 == 0:
  print(0)
  exit()
ans = 1000000000
for change in range(2): 
  
  for ty in range(1,h):
    ans = min(ans, max(ty*w, int(w/2)*(h-ty), (w-int(w/2))*(h-ty)) - min(ty*w, int(w/2)*(h-ty), (w-int(w/2))*(h-ty)))
  ans = min(ans, h*(max(int(w/3), w-int(w/3)*2) - min(int(w/3), w-int(w/3)*2)))
  temp = h
  h = w
  w = temp
print(ans)

Failing test case input:
000011 001100

Expected output:
11


Actual output:
22


Fixed submission (verdict: Accepted):
h,w = map(int,input().split())
if h % 3 == 0 or w % 3 == 0:
  print(0)
  exit()
ans = 10000000000
for change in range(2): 
  
  for ty in range(1,h):
    ans = min(ans, max(ty*w, int(w/2)*(h-ty), (w-int(w/2))*(h-ty)) - min(ty*w, int(w/2)*(h-ty), (w-int(w/2))*(h-ty)))
  a = round(w/3 + 0.1)
  ans = min(ans, h*(max(a, w-a*2) - min(a, w-a*2)))
  temp = h
  h = w
  w = temp
print(ans)

Problem: p03713
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from math import floor, ceil

H,W = map(int,input().split())
ans = float('inf')

if H%3==0 or W%3==0:
  print(0)
  exit()

for x in range(1,H):
  S = [W*x, (H-x)*floor(W/2), (H-x)*ceil(W/2)]
  ans = min(ans, abs(max(S)-min(S)))

for x in range(1,W):
  S = [H*x, (W-x)*floor(H/2), (W-x)*ceil(H/2)]
  ans = min(ans, abs(max(S)-min(S)))

print(ans)

Failing test case input:
011011 110111

Expected output:
11011


Actual output:
58726


Fixed submission (verdict: Accepted):
from math import floor, ceil

H,W = map(int,input().split())
ans = float('inf')

if H%3==0 or W%3==0:
  print(0)
  exit()

for x in range(1,H):
  S = [W*x, (H-x)*floor(W/2), (H-x)*ceil(W/2)]
  ans = min(ans, max(S)-min(S))

for x in range(1,W):
  S = [H*x, (W-x)*floor(H/2), (W-x)*ceil(H/2)]
  ans = min(ans, max(S)-min(S))

print(min(ans,H,W))

Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = input().split(" ")
a = int(a)
b = int(b)
if b > a:
    a, b = b, a
case1 = 0
case2 = 0
case3 = 0

if a % 3 == 0:
    case1 = 0
else:
    case1 = b

if b % 3 == 0:
    case2 = 0
else:
    case2 = a

if a % 2 == 0:
    con = a 
else:
    con = a 

sum1 = con * b

con1 = b 
sum2 = (a - con) * con1
if b % 2 != 0:
    sum3 = sum2 + con1
else:
    sum3 = sum2

case3 = max(sum3, max(sum2, sum1)) - min(sum3, min(sum2, sum1))

print(min(case3, min(case1, case2)))

Failing test case input:
100000 4

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a, b = input().split(" ")
a = int(a)
b = int(b)
if b > a:
    a, b = b, a
case1 = 0
case2 = 0
case3 = 0
case4 = 0
if a % 3 == 0:
    case1 = 0
else:
    case1 = b

if b % 3 == 0:
    case2 = 0
else:
    case2 = a

con1 = round(a / 3)
sum1 = con1 * b

con2 = a - con1
sum2 = b 
sum3 = (b - b 
case3 = (max(sum3, max(sum2, sum1)) - min(sum3, min(sum2, sum1)))

con1 = round(b / 3)
sum1 = con1 *a 

con2 = b - con1
sum2 = a 
sum3 = (a - a 
case4 = (max(sum3, max(sum2, sum1)) - min(sum3, min(sum2, sum1)))

print(min(min(case3,case4), min(case1, case2)))
Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h,w = map(int,input().split())
if h % 3 == 0 or w % 3 == 0:
  print(0)
  exit()
ans = 10000000000
for change in range(2): 
  
  for ty in range(1,h):
    ans = min(ans, max(ty*w, int(w/2)*(h-ty), (w-int(w/2))*(h-ty)) - min(ty*w, int(w/2)*(h-ty), (w-int(w/2))*(h-ty)))
  ans = min(ans, h*(max(int(w/3), w-int(w/3)*2) - min(int(w/3), w-int(w/3)*2)))
  temp = h
  h = w
  w = temp
print(ans)

Failing test case input:
101111 000001

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
h,w = map(int,input().split())
if h % 3 == 0 or w % 3 == 0:
  print(0)
  exit()
ans = 10000000000
for change in range(2): 
  
  for ty in range(1,h):
    ans = min(ans, max(ty*w, int(w/2)*(h-ty), (w-int(w/2))*(h-ty)) - min(ty*w, int(w/2)*(h-ty), (w-int(w/2))*(h-ty)))
  a = round(w/3 + 0.1)
  ans = min(ans, h*(max(a, w-a*2) - min(a, w-a*2)))
  temp = h
  h = w
  w = temp
print(ans)

Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H, W = map(int, input().split())

h = min(H, W)
w = max(H, W)
s = h*w

res = H*W

for i in range(w-1):
    a = h*i
    x = s-a
    b = x
    c = x-b

    res = min(max(a, b, c)-min(a, b, c), res)


for i in range(h-1):
    a = w*i
    x = s-a
    b = x
    c = x-b

    res = min(max(a, b, c)-min(a, b, c), res)

print(res)

Failing test case input:
010000 110110

Expected output:
5000


Actual output:
550550000


Fixed submission (verdict: Accepted):
H, W = map(int, input().split())

h = min(H, W)
w = max(H, W)
s = h*w

res = 10**10

for i in range(1, w):
    a = h*i
    b = (w-i)
    c = s-a-b
    res = min(max(a, b, c)-min(a, b, c), res)

    b = (w-i)*(h
    c = s-a-b
    res = min(max(a, b, c)-min(a, b, c), res)


for i in range(1, h):
    a = w*i
    
    b = (h-i)
    c = s-a-b
    res = min(max(a, b, c)-min(a, b, c), res)

    b = (h-i)*(w
    c = s-a-b
    res = min(max(a, b, c)-min(a, b, c), res)

print(res)
Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import math

h, w = map(int, input().split())

if h > w:
    h, w = w, h

y = math.floor(h / 2)

x = 1
res = 10**12

while x <= w / 2:
    x2 = math.floor((w - x) / 2) + x
    areas = [x * h, (x2 - x) * h, (w - x2) * h]
    areas.sort()
    diff = areas[2] - areas[0]
    if diff < res:
        res = diff

    areas = [x * h, (w - x) * y, (w - x) * (h - y)]
    areas.sort()
    diff = areas[2] - areas[0]
    if diff < res:
        res = diff
    
    x += 1

print(res)


Failing test case input:
111110 101101

Expected output:
55555


Actual output:
87587


Fixed submission (verdict: Accepted):


import math

def solve(h, w):

    y = math.floor(h / 2)

    x = 1
    res = 10**12

    while x <= w / 2:
        x2 = math.floor((w - x) / 2) + x
        areas = [x * h, (x2 - x) * h, (w - x2) * h]
        areas.sort()

        diff = areas[2] - areas[0]
        if diff < res:
            res = diff

        areas = [x * h, (w - x) * y, (w - x) * (h - y)]
        areas.sort()

        diff = areas[2] - areas[0]

        if diff < res:
            res = diff
        
        x += 1

    return(res)


h, w = map(int, input().split())

print(min(solve(h, w), solve(w, h)))

Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
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))

    print(min(cal2(H,W),cal2(W,H),W,H))

Failing test case input:
101011 110111

Expected output:
87209


Actual output:
88726


Fixed submission (verdict: Accepted):
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))
Problem: p03713
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from math import floor, ceil

H,W = map(int,input().split())
ans = float('inf')

if H%3==0 or W%3==0:
  print(0)
  exit()

for x in range(1,H+1):
  S = [W*x, (H-x)*floor(W/2), (H-x)*ceil(W/2)]
  ans = min(ans, abs(max(S)-min(S)))

for x in range(1,W+1):
  S = [H*x, (W-x)*floor(H/2), (W-x)*ceil(H/2)]
  ans = min(ans, abs(max(S)-min(S)))

print(ans)

Failing test case input:
000011 001000

Expected output:
11


Actual output:
500


Fixed submission (verdict: Accepted):
from math import floor, ceil

H,W = map(int,input().split())
ans = float('inf')

if H%3==0 or W%3==0:
  print(0)
  exit()

for x in range(1,H):
  S = [W*x, (H-x)*floor(W/2), (H-x)*ceil(W/2)]
  ans = min(ans, max(S)-min(S))

for x in range(1,W):
  S = [H*x, (W-x)*floor(H/2), (W-x)*ceil(H/2)]
  ans = min(ans, max(S)-min(S))

print(min(ans,H,W))

Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

H,W = map(int, input().split()) 

def func(h,w,ans):
    for i in range(1,h+1):
        a = i * w 
        w1 = int(w/2)
        b = (H-i)*w1
        c = (H-i)*(w-w1)
        M = max(a,b,c)
        m = min(a,b,c)
        s = M-m
        ans = min(s,ans) 
    return ans

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

ans = float('inf')

ans = func(H,W,ans)
ans = func(W,H,ans)

print(ans)

Failing test case input:
101011 101101

Expected output:
84206


Actual output:
84176


Fixed submission (verdict: Accepted):
import math

H,W = map(int, input().split()) 

def func(h,w,ans):
    for i in range(1,h+1):

        if((h-i) % 2 == 0): 
            a = i*w
            b = ( (h-i)
            s = abs(a-b)
            ans = min(s,ans)
    
        else:
            a = i * w 
            w1 = w
            b = (h-i)*w1
            c = (h-i)*(w-w1)
            M = max(a,b,c)
            m = min(a,b,c)
            s = M-m
            ans = min(s,ans)
    return ans

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

ans = float('inf')

ans = func(H,W,ans)
ans = func(W,H,ans)

print(ans)
Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h, w = map(int, input().split())

if h%3 == 0 or w%3 == 0:
    ans = 0
    
else:
    ans = float('inf')
    for x, y in [[h, w], [w, h]]:
        mid = x
        r = x%2
        temp = float('inf')
        for i in range(1, y):
            a, b, c = x*i, (mid+r)*(y-i), (mid)*(y-i)
            area = abs(max(a, b, c) - min(a, b, c))
            if area < temp:
                temp = area
            else:
                break
        ans = min(ans, temp)
    
print(ans)

Failing test case input:
011101 010111

Expected output:
8756


Actual output:
10111


Fixed submission (verdict: Accepted):
h, w = map(int, input().split())
 
if h%3 == 0 or w%3 == 0:
    ans = 0
    
else:
    ans = float('inf')
    
    
    for x, y in [[h, w], [w, h]]:
        mid = x
        r = x%2
        temp = float('inf')
        for i in range(1, y):
            a, b, c = x*i, (mid+r)*(y-i), (mid)*(y-i)
            area = abs(max(a, b, c) - min(a, b, c))
            if area < temp:
                temp = area
            else:
                break
        ans = min(ans, temp)
        
    
    for x, y in [[h, w], [w, h]]:
        ans = min(ans, x*(y
    
print(ans)

Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

H,W = map(int, input().split()) 

def func(h,w,ans):
    for i in range(1,h+1):
        a = i * w 
        w1 = int(w/2)
        b = (h-i)*w1
        c = (h-i)*(w-w1)
        M = max(a,b,c)
        m = min(a,b,c)
        s = M-m
        ans = min(s,ans) 
    return ans

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

ans = float('inf')

ans = func(H,W,ans)
ans = func(W,H,ans)

print(ans)

Failing test case input:
101111 000001

Expected output:
1


Actual output:
50556


Fixed submission (verdict: Accepted):
import math

H,W = map(int, input().split()) 

def func(h,w,ans):
    for i in range(1,h+1):

        if((h-i) % 2 == 0): 
            a = i*w
            b = ( (h-i)
            s = abs(a-b)
            ans = min(s,ans)
    
        else:
            a = i * w 
            w1 = w
            b = (h-i)*w1
            c = (h-i)*(w-w1)
            M = max(a,b,c)
            m = min(a,b,c)
            s = M-m
            ans = min(s,ans)
    return ans

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()

ans = float('inf')

ans = func(H,W,ans)
ans = func(W,H,ans)

print(ans)
Problem: p03713
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def rren(): return list(map(int, input().split()))


H, W = rren()
if(H % 3 == 0 or W % 3 == 0):
    print(0)
else:
    lis = []
    ans = 114514810
    for i in range(H-1):
        a = H - i
        b = W - a
        c = H 
        lis = [H*a, b*c, (H-c)*b]
        ans = min(ans, max(lis) - min(lis))
        lis.clear()
    for i in range(W-1):
        a = W - i
        b = H - a
        c = W 
        lis = [W*a, b*c, (W-c)*b]
        ans = min(ans, max(lis) - min(lis))
        lis.clear()
    print(ans)


Failing test case input:
010100 100010

Expected output:
5050


Actual output:
114514810


Fixed submission (verdict: Accepted):
def rren(): return list(map(int, input().split()))


H, W = rren()
if(H % 3 == 0 or W % 3 == 0):
    print(0)
else:
    lis = []
    ans = 114514810
    for i in range(H):
        a = H - i
        b = i
        c = W 
        lis = [W*a, b*c, (W-c)*b]
        ans = min(ans, max(lis) - min(lis))
        lis.clear()
    for i in range(W):
        a = W - i
        b = i
        c = H 
        lis = [H*a, b*c, (H-c)*b]
        ans = min(ans, max(lis) - min(lis))
        lis.clear()
    for i in range(W
        ans = min(ans, abs(i - (W-i*2))*H)
    for i in range(H
        ans = min(ans, abs(i - (H-i*2))*W)
    print(ans)

Problem: p03713
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):



import math
h,w = map(int,input().split())

def solve(H,W):
    mid = math.floor(W/2)
    ans = float('inf')
    for i in range(1,H):
        Smin = min(i*W,mid*(H-i),(W-mid)*(H-i))
        Smax = max(i*W,mid*(H-i),(W-mid)*(H-i))
        ans = min(ans,Smax-Smin)
    return ans
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    print(min(solve(h,w),solve(w,h)))


Failing test case input:
100111 000001

Expected output:
1


Actual output:
50056


Fixed submission (verdict: Accepted):



import math
h,w = map(int,input().split())

def solve(H,W):
    mid = math.floor(W/2)
    ans = float('inf')
    for i in range(1,H):
        Smin = min(i*W,mid*(H-i),(W-mid)*(H-i))
        Smax = max(i*W,mid*(H-i),(W-mid)*(H-i))
        ans = min(ans,Smax-Smin)
    return min(ans,H)
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    print(min(solve(h,w),solve(w,h)))