Buggy python submission (verdict: Runtime Error):

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools




def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]
    mod = 10 ** 6 + 3

    origin = [0 for i in range(mod + 1)]
    origin[1] = 1
    for i in range(2, mod + 1):
        origin[i] = origin[i - 1] * i
        origin[i] %= mod

    for i in range(num):
        x, d, n = data[i]
        if d == 0:
            ans = pow(x, n, mod)
        else:
            t = x * pow(d, mod - 2, mod)
            t %= mod
            ans = origin[t + n - 1] * pow(origin[t - 1], mod - 2, mod)
            ans %= mod
            ans *= pow(d, n, mod)
            ans %= mod
        print(ans)

if __name__ == '__main__':
    main()



Fixed submission:

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools




def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]
    mod = 10 ** 6 + 3

    origin = [0 for i in range(mod + 1)]
    origin[1] = 1
    for i in range(2, mod + 1):
        origin[i] = origin[i - 1] * i
        origin[i] %= mod

    for i in range(num):
        x, d, n = data[i]
        if d == 0:
            ans = pow(x, n, mod)
        else:
            t = x * pow(d, mod - 2, mod)
            t %= mod
            if t == 0 or t + n - 1 >= mod:
                ans = 0
            else:
                ans = origin[t + n - 1] * pow(origin[t - 1], mod - 2, mod)
                ans %= mod
                ans *= pow(d, n, mod)
                ans %= mod
        print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):

from collections import defaultdict

from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


def main():
    mod = 10 ** 6 + 3
    num = int(input())
    for _ in range(num):
        x, d, n = map(int, input().split())
        if x == 0:
            print(0)
            continue
        ans = 1
        kari = x
        for i in range(n):
            ans *= kari
            kari += d
            ans %= mod
        print(ans % mod)



if __name__ == '__main__':
    main()
    # mod = 10 ** 9 + 7
    # print((71 * 312500008) % mod)

Fixed submission:

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools




def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]
    mod = 10 ** 6 + 3

    origin = [0 for i in range(mod + 1)]
    origin[1] = 1
    for i in range(2, mod + 1):
        origin[i] = origin[i - 1] * i
        origin[i] %= mod

    for i in range(num):
        x, d, n = data[i]
        if d == 0:
            ans = pow(x, n, mod)
        else:
            t = x * pow(d, mod - 2, mod)
            t %= mod
            if t == 0 or t + n - 1 >= mod:
                ans = 0
            else:
                ans = origin[t + n - 1] * pow(origin[t - 1], mod - 2, mod)
                ans %= mod
                ans *= pow(d, n, mod)
                ans %= mod
        print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):

from collections import defaultdict

from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))


def main():
    mod = 10 ** 6 + 3
    num = int(input())
    for _ in range(num):
        x, d, n = map(int, input().split())
        ans = 1
        kari = x
        for i in range(n):
            ans *= kari
            kari += d
            ans %= mod
        print(ans % mod)



if __name__ == '__main__':
    main()
    # mod = 10 ** 9 + 7
    # print((71 * 312500008) % mod)

Fixed submission:

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools




def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]
    mod = 10 ** 6 + 3

    origin = [0 for i in range(mod + 1)]
    origin[1] = 1
    for i in range(2, mod + 1):
        origin[i] = origin[i - 1] * i
        origin[i] %= mod

    for i in range(num):
        x, d, n = data[i]
        if d == 0:
            ans = pow(x, n, mod)
        else:
            t = x * pow(d, mod - 2, mod)
            t %= mod
            if t == 0 or t + n - 1 >= mod:
                ans = 0
            else:
                ans = origin[t + n - 1] * pow(origin[t - 1], mod - 2, mod)
                ans %= mod
                ans *= pow(d, n, mod)
                ans %= mod
        print(ans)

if __name__ == '__main__':
    main()