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

Fixed submission:
a,b,c = map(int, input().split())
if a + b < c:
	print("No")
else:
	print("Yes")

Buggy submission (verdict: Runtime Error):
a,b,c = input()
if(a + b < c):
    print(Yes)
else:
    print(No)
Problem p03415 (python)

Fixed submission:
r0 = input()
r1 = input()
r2 = input()
print(r0[0],end='')
print(r1[1],end='')
print(r2[2],end='')

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
print(a[0]+b[1]+c[2]
Problem p03433 (python)

Fixed submission:
n = int(input())
a = int(input())
if  n % 500 <= a:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input)
a = int(input)
if  n % 500 <= a:
    print("Yes")
else:
    print("No")
Problem p03448 (python)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
m = 0
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500*a + 100*b + 50*c == X:
                m+=1
print(m)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
for a in range(A + 1):
    for b in range(B + 1):
        for c in range(C + 1):
            if 500*a + 100*b + 50*c == X:
                m+=1
print(m)
Problem p03455 (python)

Fixed submission:
(a,b)=map(int,input().split())
if a*b%2==0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b = input().split()
if (a*b % 2 == 1):
    print("0dd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a,b = input().split()
if (a*b%2 = 1):
    print("0dd")
else:
    print("Even")
Problem p03463 (python)

Fixed submission:
n, a, b = map(int,input().split())
m = a + b
if (m % 2==1):
    print("Borys")
else:
    print("Alice")

Buggy submission (verdict: Runtime Error):
N,A,B = int.input()
M = A+B
if (M%2==1):
    print("Borys")
else:
    print("Alice")

Buggy submission (verdict: Runtime Error):
N,A,B = map(int.input())
M = N+A+B
if (M%2==1):
    print("Borys")
else:
    print("Alice")

Buggy submission (verdict: Runtime Error):
N,A,B = map(int.input())
if ((N+A+B)%2==1):
    print("Borys")
else:
    print("alice")
Problem p03469 (python)

Fixed submission:
print('2018'+input()[4:])

Buggy submission (verdict: Runtime Error):
N=int(input())
print(len(set([input() for n in range(N)])))

Buggy submission (verdict: Runtime Error):
N=int(input())
print(len(set([input() for n in range(N)]))
Problem p03470 (python)

Fixed submission:
N=int(input())
print(len(set([input() for n in range(N)])))

Buggy submission (verdict: Runtime Error):
N=int(input())
print(len(set(input() for n in range(N)])))
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split())
Y //= 1000
k = min((Y - N) // 4, Y // 5)
if 9 * k >= 2 * (Y - N):
    x = (Y - N) - 4 * k
    y = -2 * (Y - N) + 9 * k
    z = Y - 5 * k
    print(x, y, z)
else:
    print(-1, -1, -1)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
d = y
a = (d*7)%9
b = (d-a*4)
c = n-a-b
if c>=0 and b>=0:
    print(b,a,c)
else:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().sprit())
d = y
a = (d*7)%9
b = (d-a*4)
c = n-a-b
if c>=0 and b>=0:
    print(b,a,c)
else:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
x,y = map(int(input().sprit)
d = y
a = (d*7)%9
b = (d-a*4)
c = n-a-b
if c>=0 and b>=0:
    print(b,a,c)
else:
    print(-1,-1,-1)
Problem p03547 (python)

Fixed submission:
x,y = input().split(" ")
if x < y:
    print("<")
elif x > y:
    print(">")
else:
    print("=")

Buggy submission (verdict: Runtime Error):
x,y = input().split(" ")
if x < y:
    print("<")
elif x > y:
    print(">")
else x == y:
    print("=")

Buggy submission (verdict: Runtime Error):
x,y = input().split()
if x < y:
    print("<")
elif x > y:
    print(">")
else x == y:
    print("=")
Problem p02743 (python)

Fixed submission:
a,b,c = map(int,input().split())
print('Yes' if c-a-b>0 and 4*a*b<c**2+a**2+b**2-2*a*c-2*b*c+2*a*b else 'No')

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
a,b,c = map(int,input().split())
a2,b2,c2,2ab = a**2,b**2,c**2,2*Decimal(a**0.5)*Decimal(b**0.5)
print('Yes' if a2+2ab+b2<c2 else 'No')
Problem p03659 (python)

Fixed submission:
N = int(input())
card = [int(i) for i in input().split(" ")]
 
all = 0
for i in card:
    all += i
 
a = card[0]
mab = abs(a - (all - a))
for i in range(1,len(card) - 1):
    a += card[i]
    if mab > abs(a - (all - a)):
    	mab = abs(a - (all - a))
print(mab)

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

all = 0
for i in card:
    all += i

a = all
ab = all
for i in range(len(card),-1):
    b -= card[i]
    if abs(a - b) > ab:
        break
    a,ab = b,abs(a - b)
print(ab)
Problem p02760 (python)

Fixed submission:
import numpy as np

a = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

a = np.array(a)
b = np.array(b)

after = np.zeros((3,3))
for i in range(N):
    after += a == b[i]
    
bool1 = (np.sum(after, axis=0)==3).sum()
bool2 = (np.sum(after, axis=1)==3).sum()
bool3 = (after[0,0]+after[1,1]+after[2,2])==3
bool4 = (after[0,2]+after[1,1]+after[2,0])==3

if bool1+bool2+bool3+bool4>0:
    ans = 'Yes'
else:
    ans = 'No'
    
print(ans)

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]

a = np.array(a)
b = np.array(b)

after = np.zeros((3,3))
for i in range(N):
    after += a == b[i]
    
bool1 = (np.sum(after, axis=0)==3).sum()
bool2 = (np.sum(after, axis=1)==3).sum()
bool3 = (after[0,0]+after[1,1]+after[2,2])==3
bool4 = (after[0,2]+after[1,1]+after[2,0])==3

if bool1+bool2+bool3+bool4>0:
    ans = 'Yes'
else:
    ans = 'No'
    
print(ans)
Problem p02765 (python)

Fixed submission:
n, r = map(int, input().split())
 
if n>=10:
  inner_rate = r
else:
  inner_rate = r + 100*(10-n)
  
print(str(inner_rate))

Buggy submission (verdict: Runtime Error):
n, r = int(input().split())

if n>=10:
  inner_rate = r
else:
  inner_rate = r + 100*(10-n)
  
print(str(inner_rate))
Problem p02767 (python)

Fixed submission:
import numpy as np
n = int(input())
l = list(map(int, input().split()))

l = np.array(l)
ans = np.sum((l - round(np.mean(l)))**2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
l = np.array(map(int, input().split()))

ans = np.sum((l - round(np.mean(l)))**2)
print(ans)
Problem p02796 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)


def test(array, index, last_position, count, min_count):
    # 除去数が多いパターンは破棄する
    if min_count[0] != -1 and count >= min_count[0]:
        return
    if index + 1 == len(array):
        # print("count:{}".format(count))
        min_count[0] = count if min_count[0] == - \
            1 or count < min_count[0] else min_count[0]
        return
    current = array[index]

    # 前のと手がぶつかる場合は取り除く
    if last_position >= current[2]:
        test(array, index + 1, last_position, count + 1, min_count)
    # 前のとぶつからない場合は取り除かないパターンも
    else:
        test(array, index + 1, index, count, min_count)


N = int(input())
array = [list(map(int, input().split())) for i in range(N)]
for line in array:
    line.append(line[0] - line[1])
    line.append(line[0] + line[1])
array = sorted(array, key=lambda x: x[3])

count = 0
max_r = -float('inf')
for i in range(N):
    current = array[i]
    # print(max_r)
    # print(current[2])
    if current[2] >= max_r:
        # print("残す")
        count += 1
        max_r = current[3]
# test(array, 0, -1, 0, min_count)
print(count)

Buggy submission (verdict: Runtime Error):
def test(array, index, last_position, count, min_count):
    if index + 1 == len(array):
        # print("count:{}".format(count))
        min_count[0] = count if min_count[0] == - \
            1 or count < min_count[0] else min_count[0]
        return
    current = array[index]
    next = array[index + 1]

    # 前か次のと手がぶつかる場合は取り除く
    if last_position >= current[0] - \
            current[1] or current[0] + current[1] >= next[0] - next[1]:
        test(array, index + 1, last_position, count + 1, min_count)
    # 前のとぶつからない場合は取り除かないパターンも
    if last_position < current[0] - current[1]:
        test(array, index + 1, index, count, min_count)


N = int(input())
array = sorted([list(map(int, input().split()))
                for i in range(N)], key=lambda x: x[0])
min_count = [-1]
test(array, 0, -1, 0, min_count)
print(len(array) - min_count[0])
Problem p02844 (python)

Fixed submission:
def test(original: list, nums: str, index: int,
         remain_count: int, results: set, results_1, results_2):
    # 3桁抽出したら終了
    if len(nums) == 1:
        if nums in results_1:
            return
        results_1.add(nums)
    if len(nums) == 2:
        if nums in results_2:
            return
        results_2.add(nums)
    if len(nums) == 3:
        # print("".join(array))
        results.add(nums)
        return
    # 最終桁に到達したら終了
    if index == len(original):
        return
    for i in range(index, len(original), 1):
        test(
            original,
            nums + original[i],
            i + 1,
            remain_count,
            results,
            results_1,
            results_2)

    # この桁を抽出対象としないパターン
    # test(original, array[:], index + 1, remain_count - 1, results)


N = int(input())
S = list(input())

results = set()
results_1 = set()
results_2 = set()

# N個の要素
# N-3個を削除
# 3個の組み合わせが何通りあるか？
test(S, "", 0, N - 3, results, results_1, results_2)

print(len(results))

Buggy submission (verdict: Runtime Error):
def test(original: list, array: list, index: int,
         remain_count: int, results: set):
    # 3桁抽出したら終了
    if len(array) == 3:
        # print("".join(array))
        results.add("".join(array))
        return
    # 最終桁に到達したら終了
    if index == len(original):
        return
    # この桁を抽出対象とするパターン
    test(original, array[:], index + 1, remain_count - 1, results)

    # この桁を抽出対象としないパターン
    new_array = array[:]
    new_array.append(
        original[index])
    test(
        original,
        new_array,
        index + 1,
        remain_count,
        results)


N = int(input())
S = list(input())

results = set()

# N個の要素
# N-3個を削除
# 3個の組み合わせが何通りあるか？
test(S, [], 0, N - 3, results)

print(len(results))

Buggy submission (verdict: Runtime Error):
def test(original: list, array: list, index: int,
         remain_count: int, results: set):
    if index == len(original):
        if remain_count == 0:
            # print("".join(array))
            results.add("".join(array))
        return
    if remain_count > 0:
        test(original, array[:], index + 1, remain_count - 1, results)
    new_array = array[:]
    new_array.append(
        original[index])
    test(
        original,
        new_array,
        index + 1,
        remain_count,
        results)


N = int(input())
S = list(input())

results = set()

# N個の要素
# N-3個を削除
# 3個の組み合わせが何通りあるか？
test(S, [], 0, N - 3, results)

print(len(results))
Problem p02945 (python)

Fixed submission:
import sys

a, b = map(int, input().split())
 
sum = a + b
minus = a - b
sub = a * b
 
if (sum - minus) > 0:
  if (sum - sub) > 0:
    print(sum)
  else:
    print(sub)
else:
  if (minus - sub) > 0:
    print(minus)
  else:
    print(sub)

Buggy submission (verdict: Runtime Error):
import sys
 
args = sys.argv

print(args[0])
 
a = int(args[1])
b = int(args[2])
 
sum = a + b
minus = a - b
sub = a * b
 
if (sum - minus) > 0:
  print("足し算のが引き算より大きい")
  if (sum - sub) > 0:
    print("足し算のが掛け算より大きい")
    print(sum)
  else:
    print("掛け算のが足し算より大きい")
    print(sub)
else:
  print("引き算のが足し算より大きい")
  if (minus - sub) > 0:
    print("引き算のが掛け算より大きい")
    print(minus)
  else:
    print("掛け算のが引き算より大きい")
    print(sub)

Buggy submission (verdict: Runtime Error):
import sys
 
args = sys.argv

print(args[0])
 
a = int(args[1])
b = int(args[2])
 
sum = a + b
minus = a - b
sub = a * b
 
if (sum - minus) < 0:
  print("足し算のが引き算より小さい")
  if (sum - sub) < 0:
    print("足し算のが掛け算より小さい")
    print(sum)
  else:
    print("掛け算のが足し算より小さい")
    print(sub)
else:
  print("引き算のが足し算より小さい")
  if (minus - sub) < 0:
    print("引き算のが掛け算より小さい")
    print(minus)
  else:
    print("掛け算のが引き算より小さい")
    print(sub)

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv

a = args[0]
b = args[1]

sum = a + b
minus = a - b
sub = a * b

if sum - minus < 0:
  if sum - sub < 0:
    return sum
  return sub

if minus - sub < 0:
  return sub

return minus
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))

visited = set([1])
loop = [1]
now = 1

for _ in range(N):
    now = A[now]
    if now in visited:
        break
    else:
        loop.append(now)
        visited.add(now)

x = loop.index(now)

if K < x:
    print(loop[K])
else:
    K -= x
    loop = loop[x:]
    K %= len(loop)
    print(loop[K])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))

visited = set([1])
loop = [1]
now = 1

for _ in range(N):
    now = A[now]
    if now in visited:
        break
    else:
        loop.append(now)
        visited.add(now)

x = loop.index(now)

if K < x:
    print(loop[x+1])
else:
    K -= x
    loop = loop[x:]
    K %= len(loop)
    print(loop[K])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))

visited = set([1])
loop = [1]
now = 1

for _ in range(N):
    now = A[now]
    if now in visited:
        break
    else:
        loop.append(now)
        visited.add(now)

x = loop.index(now)

if K <= x:
    print(loop[x+1])
else:
    K -= x
    loop = loop[x:]
    K %= len(loop)
    print(loop[K])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))

visited = set([1])
loop = [1]
now = 1

for _ in range(N):
    now = A[now]
    if now in visited:
        break
    else:
        loop.append(now)
        visited.add(now)

x = loop.index(now)

if K < x:
    print(loop[x+1])
else:
    K -= x
    loop = loop[x:]
    K %= len(loop)
    print(loop[K])
Problem p02733 (python)

Fixed submission:
import itertools, copy

H, W, K = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(H)]

ans = float("inf")
for n_horizontal_cut in range(H):
    for horizontal_cut_idx in list(itertools.combinations(list(range(1,H)), n_horizontal_cut)):
        horizontal_cut_idx = [0] + list(horizontal_cut_idx) + [H]
        n_vertical_cut = 0
        n_white_choco = [0] * (n_horizontal_cut+1)
        for w in range(W):
            tmp_idx = 0
            tmp_n_white_choco = copy.copy(n_white_choco)
            for h in range(H):
                if h >= horizontal_cut_idx[tmp_idx+1]:
                    tmp_idx += 1
                if S[h][w] == 1:
                    n_white_choco[tmp_idx] += 1
            if max(n_white_choco) > K:
                n_vertical_cut += 1
                n_white_choco = [n_white_choco[i] - tmp_n_white_choco[i] for i in range(n_horizontal_cut+1)]
                if max(n_white_choco) > K: # 1列の区間でホワイトチョコ数がオーバーする場合
                    break
        else:
            ans = min(ans, n_horizontal_cut + n_vertical_cut)

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

H, W, K = map(int, input().split())
S = [list(map(int, list(input()))) for _ in range(H)]

ans = float("inf")
for n_horizontal_cut in range(H):
    for horizontal_cut_idx in list(itertools.combinations(list(range(1,H)), n_horizontal_cut)):
        horizontal_cut_idx = [0] + list(horizontal_cut_idx) + [H]
        n_vertical_cut = 0
        n_white_choco = [0] * (n_horizontal_cut+1)
        for w in range(W):
            tmp_idx = 0
            tmp_n_white_choco = n_white_choco.copy()
            for h in range(H):
                if h >= horizontal_cut_idx[tmp_idx+1]:
                    tmp_idx += 1
                if S[h][w] == 1:
                    n_white_choco[tmp_idx] += 1
            if max(n_white_choco) > K:
                n_vertical_cut += 1
                n_white_choco = [n_white_choco[i] - tmp_n_white_choco[i] for i in range(n_horizontal_cut+1)]
        ans = min(ans, n_horizontal_cut + n_vertical_cut)

print(ans)
Problem p02900 (python)

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

# 最大公約数
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

GCD = gcd(A, B)

# 最大公約数の素因数を求める
prime_factor = []

# 素因数で可能な限り割る
def divide_by_prime_factor(GCD, p):
    if GCD%p == 0:
        prime_factor.append(p)
        while GCD%p == 0:
            GCD /= p
    return GCD, prime_factor

GCD, prime_factor = divide_by_prime_factor(GCD, 2)

for i in range(3, int(GCD**0.5)+1, 2):
    GCD, prime_factor = divide_by_prime_factor(GCD, i)

# GCDそれ自身が素数の場合を考慮。GCD==1の場合を除くことに注意
if GCD > 2:
    GCD, prime_factor = divide_by_prime_factor(GCD, GCD)

# 素因数の数+1を出力
print(len(prime_factor)+1)

Buggy submission (verdict: Runtime Error):
import numpy as np

A, B = map(int, input().split())

def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

n = gcd(A, B)

is_prime = np.array([True] * (n + 1))
is_prime[0] = False
is_prime[1] = True

for i in range(2, int(n**0.5) + 1):
    if is_prime[i]:
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

take_l = [i for i in range(1, n + 1) if is_prime[i] and n%i == 0]
print(len(take_l))

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())

def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x

n = gcd(max(A,B),min(A,B))

is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = True

for i in range(2, int(n**0.5) + 1):
    if is_prime[i]:
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

take_l = [i for i in range(1, n + 1) if all([is_prime[i], A%i == 0, B%i == 0])]
print(len(take_l))

Buggy submission (verdict: Runtime Error):
A, B = map(int,input().split())

def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x

n = gcd(A,B)

is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = True

for i in range(2, int(n**0.5) + 1):
    if is_prime[i]:
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False

take_l = [i for i in range(1, n + 1) if all([is_prime[i], A%i == 0, B%i == 0])]
print(len(take_l))
Problem p02903 (python)

Fixed submission:
H, W, A, B = map(int, input().split())

if H == 1:
    ans = "1"*A + "0"*(W-A)
    print(ans)
    exit()

if W == 1:
    for _ in range(B):
        print(1)
    for _ in range(H-B):
        print(0)
    exit()

ans = [[0]*W for _ in range(H)]

for i in range(B):
    for j in range(A):
        ans[i][j] = 1

for i in range(B, H):
    for j in range(A, W):
        ans[i][j] = 1

for a in ans:
    t = list(map(str, a))
    print("".join(t))

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

if H == 1:
    ans = "1"*A + "0"*(W-A)
    print(ans)
    exit()

if W == 1:
    for _ in range(B):
        print(1)
    for _ in range(H-B):
        print(0)
    exit()

ans = [[0]*W for _ in range(H)]

for i in range(A):
    for j in range(B):
        ans[i][j] = 1

for i in range(A, H):
    for j in range(B, W):
        ans[i][j] = 1

for a in ans:
    t = list(map(str, a))
    print("".join(t))
Problem p02928 (python)

Fixed submission:
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    # sum[0:i+1]
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    # add x to i
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9 + 7

def inv(X):
    B = Bit(2000+1)
    inv = 0
    for i in range(len(X)):
        inv += i - B.sum(X[i])
        B.add(X[i], 1)
    return inv

A_inv = inv(A) % MOD
A2_inv = inv(A*2) % MOD

print((K*A_inv + ((K*(K-1))//2) * (A2_inv - 2*A_inv)) % MOD)

Buggy submission (verdict: Runtime Error):
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    # sum[0:i+1]
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    # add x to i
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9 + 7

def inv(X):
    B = Bit(len(X)+1)
    inv = 0
    for i in range(len(X)):
        inv += i - B.sum(X[i])
        B.add(X[i], 1)
    return inv

A_inv = inv(A) % MOD
A2_inv = inv(A*2) % MOD

print((K*A_inv + ((K*(K-1))//2) * (A2_inv - 2*A_inv)) % MOD)
Problem p03006 (python)

Fixed submission:
from collections import Counter

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

if N == 1:
    print(1)
    exit()

xy.sort(key=lambda x: x[1])
xy.sort(key=lambda x: x[0])

ans = N
diff = []

for i in range(N-1):
    for j in range(i+1, N):
        diff.append((xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]))

c = Counter(diff)
print(N - c.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

xy.sort(key=lambda x: x[1])
xy.sort(key=lambda x: x[0])

ans = N
diff = []

for i in range(N-1):
    for j in range(i+1, N):
        diff.append((xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]))

c = Counter(diff)
print(N - c.most_common()[0][1])
Problem p03027 (python)

Fixed submission:
# E - Product of Arithmetic Progression

import sys
input = sys.stdin.buffer.readline

Q = int(input())
MOD = 10**6 + 3

# a//b (MOD p)
def div_mod(a, b, p=MOD):
    return (a * pow(b, p-2, p)) % p

factorial_memo = [1, 1]
for i in range(2, MOD):
    factorial_memo.append((factorial_memo[-1] * i) % MOD)

def factorial(x, p=MOD):
    if x < p:
        return factorial_memo[x]
    else:
        return 0


for _ in range(Q):
    x, d, n = map(int, input().split())
    if x == 0 and d == 0:
        print(0)
    elif x == 0:
        ans = factorial(n-1)
        ans *= pow(d, n-1, MOD)
        ans %= MOD
        print(ans)
    elif d == 0:
        print(pow(x, n, MOD))
    else:
        ans = pow(d, n, MOD)
        x_divided_by_d = div_mod(x, d, MOD)
        ans *= factorial(x_divided_by_d + (n-1))
        ans %= MOD
        ans = div_mod(ans, factorial(x_divided_by_d - 1), MOD)
        print(ans)

Buggy submission (verdict: Runtime Error):
# E - Product of Arithmetic Progression

import sys
input = sys.stdin.buffer.readline

Q = int(input())
MOD = 10**6 + 3

# a//b (MOD p)
def div_mod(a, b, p = MOD):
    return (a * pow(b, p-2, p)) % p

factorial_memo = [1, 1]
for i in range(2, 10**5 + MOD):
    factorial_memo.append((factorial_memo[-1] * i) % MOD)

for _ in range(Q):
    x, d, n = map(int, input().split())
    if x == 0 and d == 0:
        print(0)
    elif x == 0:
        ans = factorial_memo[n-1]
        ans *= pow(d, n-1, MOD)
        ans %= MOD
        print(ans)
    elif d == 0:
        print(factorial_memo[x])
    else:
        ans = pow(d, n, MOD)
        x_divided_by_d = div_mod(x, d, MOD)
        ans *= factorial_memo[x_divided_by_d + (n-1)]
        ans %= MOD
        ans = div_mod(ans, factorial_memo[x_divided_by_d - 1], MOD)
        print(ans)