ZhenlongDai/ACPR huggingface dataset:
Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
print((str(abs(a)+abs(b)),str(a*b))[a*b>abs(a)+abs(b)])

Failing test case input:
-13 3

Expected output:
-10

Actual output:
16


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

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = [int(x) for x in input().split()]
max(a + b, a - b, a * b)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
a, b = [int(x) for x in input().split()]
print(max(a + b, a - b, a * b))

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
n_l = [a+b,a-b,a*b]
max(n_l)


Failing test case input:
-13 3

Expected output:
-10

Actual output:

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

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
print(a,b)
n = a + b
m = a - b
l = a*b
print(max(n, m, l))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-13 3
-10


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

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input().split()
A = int(S[0])
B = int(S[1])
maxval = 0

add = A + B
diff = A - B
mul = A * B

if add > maxval:
    maxval = add
if diff > maxval:
    maxval = diff
if mul > maxval:
    maxval = mul

print(maxval)

Failing test case input:
-13 3

Expected output:
-10

Actual output:
0


Fixed submission (verdict: Accepted):
import sys

S = input().split()
A = int(S[0])
B = int(S[1])
maxval = -sys.maxsize

add = A + B
diff = A - B
mul = A * B

if add > maxval:
    maxval = add
if diff > maxval:
    maxval = diff
if mul > maxval:
    maxval = mul

print(maxval)

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


Failing test case input:
-13 3

Expected output:
-10

Actual output:
-10 -16 -39


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

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y = list(map(int, input().split(" ")))

if x < 0:
    if y < 0:
        print(x*y)
    else:
        print(x*y)
else:
    if y < 0:
        print(x-y)
    else:
        ad = x+y
        mu = x*y
        if ad < mu:
            print(mu)
        else:
            print(ad)



Failing test case input:
-13 3

Expected output:
-10

Actual output:
-39


Fixed submission (verdict: Accepted):
x,y = list(map(int, input().split(" ")))

if x < 0:
    if y < 0:
        print(x*y)
    else:
        print(x+y)
else:
    if y < 0:
        print(x-y)
    else:
        ad = x+y
        mu = x*y
        if ad < mu:
            print(mu)
        else:
            print(ad)
Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B=map(int,input().split())
x_list=[A+B,A-B,A*B]
x_list.sort()
x_list[2]

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
A,B=map(int,input().split())
x_list=[A+B,A-B,A*B]
x_list.sort()
print(x_list[2])

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

Failing test case input:
-13 3

Expected output:
-10

Actual output:

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

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
list = [a+b,a-b,a*b]
print(sum(list))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-65


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

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

n_list = []
c = a + b
d = a - c
e = a * b

n_list.append(c)
n_list.append(d)
n_list.append(e)

print(max(n_list))


Failing test case input:
-13 3

Expected output:
-10

Actual output:
-3


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

n_list = []
c = a + b
d = a - b
e = a * b

n_list.append(c)
n_list.append(d)
n_list.append(e)

print(max(n_list))

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

Failing test case input:
-13 3

Expected output:
-10

Actual output:

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

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

def fun(a,b):
    adds = a+b
    subs = a-b
    muls = a*b

    if adds > subs:
        if adds > muls:
            return adds
        else:
            return muls
    else:
        if subs > muls:
            return subs
        else:
            return muls



fun(a,b)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
a , b = map(int , input().split())
 
def fun(a,b):
    adds = a+b
    subs = a-b
    muls = a*b
 
    if adds > subs:
        if adds > muls:
            return adds
        else:
            return muls
    else:
        if subs > muls:
            return subs
        else:
            return muls
 

 
print(fun(a,b))

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
number = input().split(" ")
A = int(number[0])
B = int(number[1])
ans = []
ans.append(A - B)
ans.append(A - B)
ans.append(A * B)
ans.sort()
print(ans[-1])

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-16


Fixed submission (verdict: Accepted):


number = input().split(" ")
A = int(number[0])
B = int(number[1])
ans = []
ans.append(int(A + B))
ans.append(int(A - B))
ans.append(int(A * B))
ans.sort()
print(ans[-1])
Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
K = a+b
L = a-b
M = a*b
G = max(K,L)
ans = (G,M)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
K = a+b
L = a-b
M = a*b
G = max(K,L)
ans = max(G,M)
print(ans)

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
A=a*b
B=a-b
C=a*b
D=[A,B,C]
print(max(D))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-16


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
A=a*b
B=a-b
C=a+b
D=[A,B,C]
print(max(D))

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B = map(int, input().split())
l = sorted([A+B,A-B,A*B])
print(l[0])


Failing test case input:
-13 3

Expected output:
-10

Actual output:
-39


Fixed submission (verdict: Accepted):
A, B = map(int, input().split())
l = sorted([A+B,A-B,A*B])
print(l[2])

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B=map(int,input().split())
list_plumi=[A+B,A-B,A*B]
list_plumi.sort()
list_plumi[2]

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
A,B=map(int,input().split())
x_list=[A+B,A-B,A*B]
x_list.sort()
print(x_list[2])

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())

print(max(n*m,n+n,n-m))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-16


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())

print(max(n*m,n+m,n-m))

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B = list(map(int, input().split()))
print(min([A+B, A-B, A*B]))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-39


Fixed submission (verdict: Accepted):
A, B = list(map(int, input().split()))
print(max([A+B, A-B, A*B]))

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
x=max(a+b,a-b,a*b)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

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

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int,input().split()))
 
x = a[0] + a[1]
y = a[0] - a[1]
z = a[0] * a[1]
 
if x > y and x > z:
  print('x')
elif y > x and y > z:
  print('y')
else:
  print('z')
  

Failing test case input:
-13 3

Expected output:
-10

Actual output:
x


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

x = a[0] + a[1]
y = a[0] - a[1]
z = a[0] * a[1]

if x >= y and x >= z:
  print(x)
elif y >= x and y >= z:
  print(y)
else:
  print(z)
Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B = list(map(int,input().split()))
p = int(A + B)
m = int(A - B)
c = int(A * B)
s = [p,m,c]
max(s)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
A,B = list(map(int,input().split()))
p = int(A + B)
m = int(A - B)
c = int(A * B)
s = [p,m,c]
print(max(s))

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

if a-b > a+b:
    if a-b > a*b:
        print(a-b)
    else:
        print(a*b)
elif a*b > a+b:
    if a*b > a-b:
        print(a*b)
    else:
        print(a-b)

    

Failing test case input:
-13 3

Expected output:
-10

Actual output:

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

if a-b > a+b:
    if a-b > a*b:
        print(a-b)
    else:
        print(a*b)
elif a*b > a+b:
    if a*b > a-b:
        print(a*b)
    else:
        print(a-b)
else:
    print(a+b)

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B = map(int,input().split())
a = A+B
b = A-B
c = A*B
list = [a,b,c]
max(list)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
A,B = map(int,input().split())
a = A+B
b = A-B
c = A*B
List = [a,b,c]
print(max(List))

Problem: p02945
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a = input().split()
print(a)

n = int(a[0])
m = int(a[1])

l = [0, 0, 0]
l[0] = n + m
l[1] = n - m
l[2] = n * m

print(max(l))


Failing test case input:
-13 3

Expected output:
-10

Actual output:
['-13', '3']
-10


Fixed submission (verdict: Accepted):
a = input().split()

n = int(a[0])
m = int(a[1])

l = [0, 0, 0]
l[0] = n + m
l[1] = n - m
l[2] = n * m

print(max(l))

Problem: p02945
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a, b = map(int, input().split())
max(a+b, a-b, a*b )

Failing test case input:
-13 3

Expected output:
-10

Actual output:

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

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B = map(int, input().split())
plus = A + B
minus = A - B
mult = A * B
ans = max(plus, minus, mult)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
A, B = map(int, input().split())
plus = A + B
minus = A - B
mult = A * B
ans = max(plus, minus, mult)
print(ans)

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
x = a + b
y = a * b
z = a - b
if x >= b and x >= z:
    print(x)
elif y >= z:
    print(y)
else:
    print(z)

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-16


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
x = a + b
y = a * b
z = a - b
if x >= y and x >= z:
    print(x)
elif y >= z:
    print(y)
else:
    print(z)
Problem: p02945
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a, b = map(int, input().split())
p = a + b
m = max(a - b, b - a)
d = a * b
print(max(p, m, d))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
16


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

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

Failing test case input:
-13 3

Expected output:
-10

Actual output:
[-10, -39, -16]
-10


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

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


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


x = [a*b, a+b, a-b]

print(x)

Failing test case input:
-13 3

Expected output:
-10

Actual output:
[-39.0, -10.0, -16.0]


Fixed submission (verdict: Accepted):


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


x = [a*b, a+b, a-b]

print(max(x))

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B = list(map(int, input().split()))
print(A,B)
x = int(A*B)
y = int(A+B)
z = int(A-B)
print(max(x,y,z))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-13 3
-10


Fixed submission (verdict: Accepted):
A,B = list(map(int, input().split()))
x = int(A*B)
y = int(A+B)
z = int(A-B)
print(max(x,y,z))

Problem: p02945
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
 a,b = map(int,input().split())
 print(min(a + b, a - b, a * b))
main()

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-39


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

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









import sys
inf = float("inf")





mod,MOD=1000000007,998244353










def get_array(): return list(map(float , sys.stdin.readline().strip().split()))
def get_ints(): return map(float, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

a,b=get_ints()
print(max(a+b,a-b,a*b))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-10.0


Fixed submission (verdict: Accepted):









import sys
inf = float("inf")





mod,MOD=1000000007,998244353










def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

a,b=get_ints()
print(max(a+b,a-b,a*b))

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
fs= [float(f) for f in input().split()]
a,b = fs[0],fs[1]
print(max(a+b,a*b,a-b))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-10.0


Fixed submission (verdict: Accepted):
fs= [int(f) for f in input().split()]
a,b = fs[0],fs[1]
print(max(a+b,a*b,a-b))
Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B = map(int, input().split())
a=A*B
b=A-B
c=A*B
if a>=b and a>=c:
  print(a)
elif b>=a and b>=c:
  print(b)
else:
  print(c)

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-16


Fixed submission (verdict: Accepted):
A, B = map(int, input().split())
a=A+B
b=A-B
c=A*B
if a>=b and a>=c:
  print(a)
elif b>=a and b>=c:
  print(b)
else:
  print(c)

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
K = a+b
L = a-b
M = a*b
G = max(K,L)
ans = (G,M)
print(ans)

Failing test case input:
-13 3

Expected output:
-10

Actual output:
(-10, -39)


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
K = a+b
L = a-b
M = a*b
G = max(K,L)
ans = max(G,M)
print(ans)

Problem: p02945
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
A,B = map(int,input().split())
print(A+B,A-B,A*B)

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-10 -16 -39


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

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
number = input().split(" ")
A = int(number[0])
B = int(number[1])
ans = []
ans.append(int(A - B))
ans.append(int(A - B))
ans.append(int(A * B))
ans.sort()
print(ans[-1])

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-16


Fixed submission (verdict: Accepted):


number = input().split(" ")
A = int(number[0])
B = int(number[1])
ans = []
ans.append(int(A + B))
ans.append(int(A - B))
ans.append(int(A * B))
ans.sort()
print(ans[-1])

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B=map(int,input().split())
max(A+B,A-B,A*B)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
A,B=map(int,input().split())
print(max(A+B,A-B,A*B))

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int, input().split())
res = []
res.append(a+b)
res.append(a-b)
res.append(a*b)
res.sort(reverse=True)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

Fixed submission (verdict: Accepted):
a,b=map(int, input().split())
res = []
res.append(a+b)
res.append(a-b)
res.append(a*b)
res.sort(reverse=True)
print(res[0])

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
t = a * b
h = a - b
k = a * b
l = [t, h, k]
print(max(l))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-16


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
t = a + b
h = a - b
k = a * b
l = [t, h, k]
print(max(l))

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int,input().split()))
ans = sorted([a[0] + a[1],a[0] - a[1],a[0] * a[1]])
print(ans)

Failing test case input:
-13 3

Expected output:
-10

Actual output:
[-39, -16, -10]


Fixed submission (verdict: Accepted):
a = list(map(int,input().split()))
ans = sorted([a[0] + a[1],a[0] - a[1],a[0] * a[1]])
print(ans[2])
Problem: p02945
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b=map(int,input().split())
max(a+b,a-b,a*b)

Failing test case input:
-13 3

Expected output:
-10

Actual output:

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

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = [int(x) for x in input().split()]
res = sorted([a+b,a-b,a*b])
print(res[0])

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-39


Fixed submission (verdict: Accepted):
a,b = [int(x) for x in input().split()]
res = sorted([a+b,a-b,a*b])
print(res[2])

Problem: p02945
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main(text):
    a = list(map(int, text.split()))
    print(a)
    print(max([a[0]+a[1], a[0]-a[1], a[0]*a[1]]))


main(input())


Failing test case input:
-13 3

Expected output:
-10

Actual output:
[-13, 3]
-10


Fixed submission (verdict: Accepted):
def main(text):
    a = list(map(int, text.split()))
    print(max([a[0]+a[1], a[0]-a[1], a[0]*a[1]]))


main(input())

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


tasu = A+B
hiku = A-B
kakeru = A*B




if tasu >= hiku and tasu >= kakeru:
    print("1",tasu)
elif hiku >= tasu and hiku >= kakeru:
    print("2",hiku)
else:
    print("3",kakeru)




Failing test case input:
-13 3

Expected output:
-10

Actual output:
1 -10


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


tasu = A+B
hiku = A-B
kakeru = A*B




if tasu >= hiku and tasu >= kakeru:
    print(tasu)
elif hiku >= tasu and hiku >= kakeru:
    print(hiku)
else:
    print(kakeru)

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

Failing test case input:
-13 3

Expected output:
-10

Actual output:

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

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


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


x = [a*b, a+b, a-b]

print(max(x))

Failing test case input:
-13 3

Expected output:
-10

Actual output:
-10.0


Fixed submission (verdict: Accepted):


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


x = [a*b, a+b, a-b]

print(max(x))
Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g)

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, d, g))

    else:
        s = div(x, d)
        x, y = (s+n-1)%g, (s-1)%g
        if x!=0 and y!=0 and x >= y :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Failing test case input:
2
23 0 5
13865 376063 2019

Expected output:
436325
361248


Actual output:
1
361248


Fixed submission (verdict: Accepted):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, n, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
Q = int(input())
mod = 1000003
frac = [1]*1000003
for i in range(2,1000003):
    frac[i] = i * frac[i-1]%mod
for _ in range(Q):
    x, d, n = map(int, sys.stdin.readline().split())
    p = pow(d, mod-2, mod)*x % mod
    if p == 0:
        print(0)
        continue
    if p + n - 1 >= mod:
        print(0)
        continue
    print(frac[p+n-1]*pow(frac[p-1], mod-2, mod)*pow(d, n, mod)%mod)

Failing test case input:
2
27 0 5
23772 376063 2019

Expected output:
348865
755257


Actual output:
0
755257


Fixed submission (verdict: Accepted):
import sys
Q = int(input())
mod = 1000003
frac = [1]*1000003
for i in range(2,1000003):
    frac[i] = i * frac[i-1]%mod
for _ in range(Q):
    x, d, n = map(int, sys.stdin.readline().split())
    p = pow(d, mod-2, mod)*x % mod
    if d == 0:
        print(pow(x, n, mod))
        continue
    elif x == 0:
        print(0)
        continue
    elif p == 0:
        print(0)
        continue
    elif p + n - 1 >= mod:
        print(0)
        continue
    
    print(frac[p+n-1]*pow(frac[p-1], mod-2, mod)*pow(d, n, mod)%mod)
Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g)

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, d, g))

    else:
        s = div(x, d)
        x, y = (s+n-1)%g, (s-1)%g
        if x != 0 and x + n < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Failing test case input:
2
12 0 4
23706 239950 2019

Expected output:
20736
315745


Actual output:
1
315745


Fixed submission (verdict: Accepted):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, n, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Problem: p03027
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
mod=1000003
Q=int(input())
kaijo=[1]*mod
for i in range(1,mod):
    kaijo[i]=kaijo[i-1]*i%mod
gyaku=[0]*mod
gyaku[mod-1]=pow(kaijo[mod-1],mod-2,mod)
for i in range(mod-1,0,-1):
    gyaku[i-1]=gyaku[i]*i%mod
for q in range(Q):
    x,d,n=map(int,input().split())
    if d==0:
        print(pow(x,n,mod))
    s=x*pow(d,mod-2,mod)%mod
    if s+n-1>=mod:
        print(0)
    else:
        print(pow(d,n,mod)*kaijo[s+n-1]*gyaku[s-1]%mod)

Failing test case input:
2
10 0 1
9796 17991 1485

Expected output:
10
424707


Actual output:
10
0
424707


Fixed submission (verdict: Accepted):
Q=int(input())
mod=1000003
def calc():
    x,d,n=map(int,input().split())
    if x==0:
        return 0
    elif d==0:
        return pow(x,n,mod)
    else:
        revd=pow(d,mod-2,mod)
        start=x*revd%mod
        if start+n-1>=mod:
            return 0
        else:
            
            return kaijo[(x*revd+(n-1))%mod]*gyaku[(x*revd-1)%mod]*pow(d,n,mod)%mod
kaijo=[0]*mod
kaijo[0]=1
for i in range(1,mod):
    kaijo[i]=kaijo[i-1]*i%mod
gyaku=[0]*mod
gyaku[mod-1]=pow(kaijo[mod-1],mod-2,mod)
for i in range(mod-1,0,-1):
    gyaku[i-1]=gyaku[i]*i%mod
for i in range(Q):
    print(calc())
Problem: p03027
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
mod=1000003
Q=int(input())
kaijo=[1]*mod
for i in range(1,mod):
    kaijo[i]=kaijo[i-1]*i%mod
gyaku=[0]*mod
gyaku[mod-1]=pow(kaijo[mod-1],mod-2,mod)
for i in range(mod-1,0,-1):
    gyaku[i-1]=gyaku[i]*i%mod
for q in range(Q):
    x,d,n=map(int,input().split())
    if d==0:
        print(pow(x,n,mod))
    s=x*pow(d,mod-2,mod)%mod
    if s+n>=mod:
        print(0)
    else:
        print(pow(d,n,mod)*kaijo[s+n-1]*gyaku[s-1]%mod)

Failing test case input:
2
23 0 5
8593 376063 1254

Expected output:
436325
786574


Actual output:
436325
0
786574


Fixed submission (verdict: Accepted):
Q=int(input())
mod=1000003
def calc():
    x,d,n=map(int,input().split())
    if x==0:
        return 0
    elif d==0:
        return pow(x,n,mod)
    else:
        revd=pow(d,mod-2,mod)
        start=x*revd%mod
        if start+n-1>=mod:
            return 0
        else:
            
            return kaijo[(x*revd+(n-1))%mod]*gyaku[(x*revd-1)%mod]*pow(d,n,mod)%mod
kaijo=[0]*mod
kaijo[0]=1
for i in range(1,mod):
    kaijo[i]=kaijo[i-1]*i%mod
gyaku=[0]*mod
gyaku[mod-1]=pow(kaijo[mod-1],mod-2,mod)
for i in range(mod-1,0,-1):
    gyaku[i-1]=gyaku[i]*i%mod
for i in range(Q):
    print(calc())

Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
mod = 1000003

q = int(input())
fct = [0]
tmp = 1
for i in range(1,mod+3):
    tmp *=i
    tmp%=mod
    fct.append(tmp)
for i in range(q):
    x,d,n = map(int, input().split( ))
    if d%mod == 0:
        print(pow(x,mod-2,mod))
        continue
    if n>=mod:
        print(0)
        continue
    rev_d = pow(d,mod-2,mod)
    x*=rev_d
    x%=mod
    tmp = pow(d,n,mod)
    try:
        tmp*=fct[x+n-1]
    except:
        print(0)
        continue
    if x>=2:
        tmp*=pow(fct[x-1],mod-2,mod)
    tmp%=mod
    print(tmp)
    
    
            

Failing test case input:
2
23 0 5
8593 376063 2019

Expected output:
436325
829032


Actual output:
217392
829032


Fixed submission (verdict: Accepted):
mod = 1000003

q = int(input())
fct = [0]
tmp = 1
for i in range(1,mod+3):
    tmp *=i
    tmp%=mod
    fct.append(tmp)
for i in range(q):
    x,d,n = map(int, input().split( ))
    if d%mod == 0:
        print(pow(x,n,mod))
        continue
    if n>=mod:
        print(0)
        continue
    rev_d = pow(d,mod-2,mod)
    x*=rev_d
    x%=mod
    tmp = pow(d,n,mod)
    try:
        tmp*=fct[x+n-1]
    except:
        print(0)
        continue
    if x>=2:
        tmp*=pow(fct[x-1],mod-2,mod)
    tmp%=mod
    print(tmp)
Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g)

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, d, g))

    else:
        s = div(x, d)
        x, y = (s+n-1)%g, (s-1)%g
        if y != 0 and y + n < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Failing test case input:
2
23 0 5
4114 376063 2019

Expected output:
436325
690022


Actual output:
1
690022


Fixed submission (verdict: Accepted):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, n, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
Q = int(input())
mod = 1000003
frac = [1]*1000003
for i in range(2,1000003):
    frac[i] = i * frac[i-1]%mod
for _ in range(Q):
    x, d, n = map(int, sys.stdin.readline().split())
    p = pow(d, mod-2, mod)*x % mod
    if d == 0:
        print(pow(x, n, mod))
    if p == 0:
        print(0)
        continue
    if p + n - 1 >= mod:
        print(0)
        continue
    
    print(frac[p+n-1]*pow(frac[p-1], mod-2, mod)*pow(d, n, mod)%mod)

Failing test case input:
2
23 0 5
23772 376063 2019

Expected output:
436325
755257


Actual output:
436325
0
755257


Fixed submission (verdict: Accepted):
import sys
Q = int(input())
mod = 1000003
frac = [1]*1000003
for i in range(2,1000003):
    frac[i] = i * frac[i-1]%mod
for _ in range(Q):
    x, d, n = map(int, sys.stdin.readline().split())
    p = pow(d, mod-2, mod)*x % mod
    if d == 0:
        print(pow(x, n, mod))
        continue
    elif x == 0:
        print(0)
        continue
    elif p == 0:
        print(0)
        continue
    elif p + n - 1 >= mod:
        print(0)
        continue
    
    print(frac[p+n-1]*pow(frac[p-1], mod-2, mod)*pow(d, n, mod)%mod)
Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
mod = 1000003

q = int(input())
fct = [0]
tmp = 1
for i in range(1,mod):
    tmp *=i
    tmp%=mod
    fct.append(tmp)
for i in range(q):
    x,d,n = map(int, input().split( ))
    if d%mod == 0:
        print(pow(x,mod-2,mod))
        continue
    if n>=mod:
        print(0)
        continue
    rev_d = pow(d,mod-2,mod)
    x*=rev_d
    x%=mod
    tmp = pow(d,n,mod)
    try:
        tmp*=fct[x+n-1]
    except:
        print(0)
        continue
    if x>=1:
        tmp*=pow(fct[x-1],mod-2,mod)
    tmp%=mod
    print(tmp)
    
    
            

Failing test case input:
2
23 0 5
4114 376063 2019

Expected output:
436325
690022


Actual output:
217392
690022


Fixed submission (verdict: Accepted):
mod = 1000003

q = int(input())
fct = [0]
tmp = 1
for i in range(1,mod+3):
    tmp *=i
    tmp%=mod
    fct.append(tmp)
for i in range(q):
    x,d,n = map(int, input().split( ))
    if d%mod == 0:
        print(pow(x,n,mod))
        continue
    if n>=mod:
        print(0)
        continue
    rev_d = pow(d,mod-2,mod)
    x*=rev_d
    x%=mod
    tmp = pow(d,n,mod)
    try:
        tmp*=fct[x+n-1]
    except:
        print(0)
        continue
    if x>=2:
        tmp*=pow(fct[x-1],mod-2,mod)
    tmp%=mod
    print(tmp)

Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, d, g))

    else:
        s = div(x, d)
        x, y = (s+n-1)%g, (s-1)%g
        if s + n - 1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Failing test case input:
2
23 0 5
8593 376063 1254

Expected output:
436325
786574


Actual output:
1
786574


Fixed submission (verdict: Accepted):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, n, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)
Problem: p03027
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
mod = 10**6+3

Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

T = [1]
for n in range(1, mod+1):
    T.append(T[-1]*n%mod)

for x, d, n in Query:
    start = x*pow(d, mod-2, mod)%mod
    if start == 0 or start + n-1 >= mod:
        ans = -1
    else:
        ans = pow(d, n, mod) * pow(T[start-1], mod-2, mod) * T[start+n-1] % mod
    print(ans)

Failing test case input:
2
23 0 5
13865 376063 2019

Expected output:
436325
361248


Actual output:
-1
361248


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
mod = 10**6+3


Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

T = [1]
for n in range(1, mod+1):
    T.append(T[-1]*n%mod)

for x, d, n in Query:
    start = x*pow(d, mod-2, mod)%mod
    if d == 0:
        ans = pow(x, n, mod)
    elif start == 0 or start + n-1 >= mod:
        ans = 0
    else:
        ans = pow(d, n, mod) * pow(T[start-1], mod-2, mod) * T[start+n-1] % mod
    print(ans)

Problem: p03027
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
mod = 10**6+3

Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

T = [1]
for n in range(1, mod+1):
    T.append(T[-1]*n%mod)

for x, d, n in Query:
    start = x*pow(d, mod-2, mod)%mod
    if start == 0 or start + n-1 >= mod:
        ans = 0
    else:
        ans = pow(d, n, mod) * pow(T[start-1], mod-2, mod) * T[start+n-1] % mod
    print(ans)

Failing test case input:
2
23 0 5
23772 376063 2019

Expected output:
436325
755257


Actual output:
0
755257


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
mod = 10**6+3


Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

T = [1]
for n in range(1, mod+1):
    T.append(T[-1]*n%mod)

for x, d, n in Query:
    start = x*pow(d, mod-2, mod)%mod
    if d == 0:
        ans = pow(x, n, mod)
    elif start == 0 or start + n-1 >= mod:
        ans = 0
    else:
        ans = pow(d, n, mod) * pow(T[start-1], mod-2, mod) * T[start+n-1] % mod
    print(ans)

Problem: p03027
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
mod=10**6+3

MUL=[0,1]
for i in range(2,mod):
    MUL.append(MUL[-1]*i%mod)

Q=int(input())
for i in range(Q):
    x,d,n=map(int,input().split())
    start=x*pow(d,mod-2,mod)%mod
    if start+n-1>=mod:
        print(0)
    else:
        print(MUL[start+n-1]*pow(MUL[start-1],mod-2,mod)%mod*pow(d,n,mod)%mod)


Failing test case input:
2
23 0 5
4114 376063 2019

Expected output:
436325
690022


Actual output:
0
690022


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
mod=10**6+3

MUL=[1]
for i in range(1,mod):
    MUL.append(MUL[-1]*i%mod)

Q=int(input())
for i in range(Q):
    x,d,n=map(int,input().split())

    if d==0:
        print(pow(x,n,mod))
        continue
    start=x*pow(d,mod-2,mod)%mod
    if start+n-1>=mod:
        print(0)
    else:
        print(MUL[start+n-1]*pow(MUL[start-1],mod-2,mod)%mod*pow(d,n,mod)%mod)
Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, d, g))

    else:
        s = div(x, d)
        x, y = (s+n-1)%g, (s-1)%g
        if y != 0 and s + n - 1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Failing test case input:
2
23 0 5
4114 376063 2019

Expected output:
436325
690022


Actual output:
1
690022


Fixed submission (verdict: Accepted):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, n, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
mod = 1000003

q = int(input())
fct = [0]
tmp = 1
for i in range(1,mod):
    tmp *=i
    tmp%=mod
    fct.append(tmp)
for i in range(q):
    x,d,n = map(int, input().split( ))
    if d%mod == 0:
        print(pow(x,mod-2,mod))
        continue
    if n>=mod:
        print(0)
        continue
    rev_d = pow(d,mod-2,mod)
    x*=rev_d
    x%=mod
    tmp = pow(d,n,mod)
    try:
        tmp*=fct[x+n-1]
    except:
        print(0)
        continue
    if x>=2:
        tmp*=pow(fct[x-1],mod-2,mod)
    tmp%=mod
    print(tmp)
    
    
            

Failing test case input:
2
10 0 1
9796 17991 1485

Expected output:
10
424707


Actual output:
300001
424707


Fixed submission (verdict: Accepted):
mod = 1000003

q = int(input())
fct = [0]
tmp = 1
for i in range(1,mod+3):
    tmp *=i
    tmp%=mod
    fct.append(tmp)
for i in range(q):
    x,d,n = map(int, input().split( ))
    if d%mod == 0:
        print(pow(x,n,mod))
        continue
    if n>=mod:
        print(0)
        continue
    rev_d = pow(d,mod-2,mod)
    x*=rev_d
    x%=mod
    tmp = pow(d,n,mod)
    try:
        tmp*=fct[x+n-1]
    except:
        print(0)
        continue
    if x>=2:
        tmp*=pow(fct[x-1],mod-2,mod)
    tmp%=mod
    print(tmp)
Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, d, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s != 0 and s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Failing test case input:
2
27 0 5
23772 376063 2019

Expected output:
348865
755257


Actual output:
1
755257


Fixed submission (verdict: Accepted):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, n, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    q = int(input())
    mod = 1000003
    fact = [1, 1]
    for i in range(2, mod+1):
        fact.append(fact[-1]*i % mod)

    for i in range(q):
        x, d, n = map(int, input().split())
        if d == 0:
            print(pow(d, n, mod))
            continue
        elif n >= mod:
            print(0)
            continue
        b = -x*pow(d, mod-2, mod) % mod
        if b >= n:
            print(pow(fact[b-n], mod-2, mod)*fact[b]*pow(-d, n, mod) % mod)
        else:
            print(0)


main()

Failing test case input:
2
23 0 5
13865 376063 2019

Expected output:
436325
361248


Actual output:
0
361248


Fixed submission (verdict: Accepted):
def main():
    q = int(input())
    mod = 1000003
    fact = [1, 1]
    for i in range(2, mod+1):
        fact.append(fact[-1]*i % mod)

    for i in range(q):
        x, d, n = map(int, input().split())
        if d == 0:
            print(pow(x, n, mod))
            continue
        elif n >= mod:
            print(0)
            continue
        b = -x*pow(d, mod-2, mod) % mod
        if b >= n:
            print(pow(fact[b-n], mod-2, mod)*fact[b]*pow(-d, n, mod) % mod)
        else:
            print(0)


main()
Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
Q = int(input())
mod = 1000003
frac = [1]*1000003
for i in range(2,1000003):
    frac[i] = i * frac[i-1]%mod
for _ in range(Q):
    x, d, n = map(int, sys.stdin.readline().split())
    p = pow(d, mod-2, mod)*x % mod
    if p == 0:
        print(0)
        continue
    if p + n - 1 >= mod:
        print(0)
        continue
    print(frac[(p+n-1)%mod]*pow(frac[p-1], mod-2, mod)*pow(d, n, mod)%mod)

Failing test case input:
2
10 0 1
9796 17991 1485

Expected output:
10
424707


Actual output:
0
424707


Fixed submission (verdict: Accepted):
import sys
Q = int(input())
mod = 1000003
frac = [1]*1000003
for i in range(2,1000003):
    frac[i] = i * frac[i-1]%mod
for _ in range(Q):
    x, d, n = map(int, sys.stdin.readline().split())
    p = pow(d, mod-2, mod)*x % mod
    if d == 0:
        print(pow(x, n, mod))
        continue
    elif x == 0:
        print(0)
        continue
    elif p == 0:
        print(0)
        continue
    elif p + n - 1 >= mod:
        print(0)
        continue
    
    print(frac[p+n-1]*pow(frac[p-1], mod-2, mod)*pow(d, n, mod)%mod)

Problem: p03027
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
mod=10**6+3

MUL=[1]
for i in range(1,mod):
    MUL.append(MUL[-1]*i%mod)

Q=int(input())
for i in range(Q):
    x,d,n=map(int,input().split())
    start=x*pow(d,mod-2,mod)%mod
    if start+n-1>=mod:
        print(0)
    else:
        print(MUL[start+n-1]*pow(MUL[start-1],mod-2,mod)%mod*pow(d,n,mod)%mod)


Failing test case input:
2
23 0 5
8593 376063 2019

Expected output:
436325
829032


Actual output:
0
829032


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
mod=10**6+3

MUL=[1]
for i in range(1,mod):
    MUL.append(MUL[-1]*i%mod)

Q=int(input())
for i in range(Q):
    x,d,n=map(int,input().split())

    if d==0:
        print(pow(x,n,mod))
        continue
    start=x*pow(d,mod-2,mod)%mod
    if start+n-1>=mod:
        print(0)
    else:
        print(MUL[start+n-1]*pow(MUL[start-1],mod-2,mod)%mod*pow(d,n,mod)%mod)
Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
Q = int(input())
mod = 10**6+3

fact_memo = [0]*mod
fact_memo[0] = 1
for n in range(mod-1):
    fact_memo[n+1] = (n+1)*fact_memo[n]%mod

def fact(n):
    if n>=mod:
        return 0
    else:
        return fact_memo[n]

def inv(n):
    n %= mod
    return pow(n,mod-2,mod)

def cal(x,d,n):
    ans = pow(d,n,mod)
    y = x*inv(d)%mod
    ans *= fact(y+n-1)
    ans %= mod
    ans *= inv(fact(y-1))
    ans %= mod
    print(ans)

for i in range(Q):
    cal(*map(int,input().split()))

Failing test case input:
2
27 0 5
23772 376063 2019

Expected output:
348865
755257


Actual output:
0
755257


Fixed submission (verdict: Accepted):
Q = int(input())
mod = 10**6+3

fact_memo = [0]*mod
fact_memo[0] = 1
for n in range(mod-1):
    fact_memo[n+1] = (n+1)*fact_memo[n]%mod

def fact(n):
    if n>=mod:
        return 0
    else:
        return fact_memo[n]

def inv(n):
    n %= mod
    return pow(n,mod-2,mod)

def cal(x,d,n):
    if x == 0:
        print(0)
        return
    if d == 0:
        print(pow(x,n,mod))
        return
    ans = pow(d,n,mod)
    y = x*inv(d)%mod
    ans *= fact(y+n-1)
    ans %= mod
    ans *= inv(fact(y-1))
    ans %= mod
    print(ans)

for i in range(Q):
    cal(*map(int,input().split()))

Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g)

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, d, g))

    else:
        s = div(x, d)
        print(div(fr[(s+n-1)%g], fr[(s-1)%g]) * pow(d, n, g) % g)


Failing test case input:
2
23 0 5
8593 376063 2019

Expected output:
436325
829032


Actual output:
1
829032


Fixed submission (verdict: Accepted):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, n, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)
Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g)

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, d, g))

    else:
        s = div(x, d)
        x, y = (s+n-1)%g, (s-1)%g
        if x >= y > 0:
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Failing test case input:
2
23 0 5
4114 376063 2019

Expected output:
436325
690022


Actual output:
1
690022


Fixed submission (verdict: Accepted):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, n, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Problem: p03027
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, d, g))

    else:
        s = div(x, d)
        x, y = (s+n-1)%g, (s-1)%g
        if s != 0 and s + n - 1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)

Failing test case input:
2
12 0 4
23706 239950 2019

Expected output:
20736
315745


Actual output:
1
315745


Fixed submission (verdict: Accepted):
import math
N = int(input())

g = 1000003

fr = [1] * g
for x in range(2, g):
    fr[x] = x * fr[x-1] % g

def div(a, b):
    return a * pow(b, g-2, g) % g

for x, d, n in (map(int, input().split()) for _ in range(N)):
    ans = 1

    if d == 0:
        print(pow(x, n, g))

    else:
        s = div(x, d)
        x, y = s+n-1, s-1
        if s+n-1 < g :
            print(div(fr[x], fr[y]) * pow(d, n, g) % g)
        else:
            print(0)