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

Fixed submission:
def main():
    N, A, B = map(int, input().split(" "))
    if (A + B) == 0:
        print(0)
        return
    amari = N % (A+B)
    kaisuu = N // (A+B)
    print(kaisuu*A+min(amari, A))
main()

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


balls = ''
for i in range(N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]

# print(bakks)
count = 0
for x in balls:
    if x == 'b':
        count += 1
print(count)

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


balls = ''
for i in range(N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
print(balls.count('b'))

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


balls = ''
for i in range(2*N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
print(balls.count('b'))

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


balls = ''
for i in range(2*N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
print(balls)
print(balls.count('b'))

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


balls = ''
for i in range(1000):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
# print(balls)
print(balls.count('b'))
Problem p02831 (python)

Fixed submission:
import fractions

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

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

print(lcm(A, B))

Buggy submission (verdict: Runtime Error):
import math

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

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

print(lcm(A, B))
Problem p02833 (python)

Fixed submission:
def main():
    I = int(input())

    if not I % 2 == 0:
        return 0
    
    I //= 2

    counter = 0
    while I > 0:
        I //= 5
        counter += I
    return counter

print(str(main()))

Buggy submission (verdict: Runtime Error):
def f(n):
    if n < 2:
        return 1
    else:
        return n * f(n-2)

N = int(input())
result = str(f(N))[::-1]
print(result)

count = 0
for n in result:
    if n != 0:
        break
    else:
        count += 1
print(count)
Problem p03127 (python)

Fixed submission:
from fractions import gcd
import numpy as np

N = int(input())
A = np.array([int(i) for i in input().split()])

a = A[0]
for b in A[1:]:
  # print(a)
  a = gcd(a, b)

print(a)

Buggy submission (verdict: Runtime Error):

def is_include_0(x):
  if 0 in x:
    x.remove(0)


  if 0 in x:
    return is_include_0(x)
  else:
    return x
  

def main():
  N = int(input())
  monsters = list(map(int, input().split()))

  monsters = sorted(monsters)
  # print(monsters)

  last = 10000
  while True:
    # print('==============================')
    # print(monsters)
    for i in range(1, len(monsters)):
      monsters[i] = monsters[i] % monsters[0]

    # print(monsters)
    if 0 in monsters:
      # monsters.remove(0)
      monsters = is_include_0(monsters)
      monsters = sorted(monsters)

    # print(monsters)
    if len(monsters) == 2:
      # print('a')
      last = int(abs(monsters[1] - monsters[0]))
      monsters[0] = last
      monsters.remove(monsters[1])
      # print(monsters)

    if len(monsters) == 1:
      break
  print(monsters[0])

main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  monsters = list(map(int, input().split()))

  monsters = sorted(monsters)
  # print(monsters)

  last = 10000
  while True:
    # print('==============================')
    # print(monsters)
    for i in range(1, len(monsters)):
      monsters[i] = monsters[i] % monsters[0]

    # print(monsters)
    if 0 in monsters:
      monsters.remove(0)
      monsters = sorted(monsters)

    # print(monsters)
    if len(monsters) == 2:
      last = int(abs(monsters[1] - monsters[0]))
      monsters.remove(monsters[1])

    if len(monsters) == 1:
      break
  print(last)

  

main()
Problem p03135 (python)

Fixed submission:
def main():
  t, x = map(int, input().split())
  print(float(t) / float(x))


main()

Buggy submission (verdict: Runtime Error):
def main():
  t, x = map(int, input())
  print(float(t) / float(x))


main()
Problem p03208 (python)

Fixed submission:
def main():
  N, K = map(int, input().split(' '))
  # N本の木があって，i本目の木はh_i[m]
  # K本選んで電飾する.
  # 木の内一番高いのをh_max[m], 低いものをh_min[m]
  # min(h_max - h_min)をしたい.
  trees = [int(input()) for _ in range(N)]
  trees.sort()
  trees = [n - trees[0] for n in trees]
  # print(trees[K-1] - trees[0]) -> これだと，最初の方はかなり分散が大きい配列で，後ろの方が分散が小さい配列だとダメ
  # 例[0, 100, 101, 102] から2個選ぶ時, 上記だと100が帰ってくる.
  # MIN = 100000000000000
  # print(trees)
  # for n in range(K):
  # for n in range(N - K + 1):
  #   t = trees[n+K-1] - trees[n]
  #   MIN = min(t, MIN)
  MIN = min([trees[n+K-1] - trees[n] for n in range(N-K+1)])
  print(MIN)

main()

Buggy submission (verdict: Runtime Error):
def main():
  N, K = map(int, input().split(' '))
  # N本の木があって，i本目の木はh_i[m]
  # K本選んで電飾する.
  # 木の内一番高いのをh_max[m], 低いものをh_min[m]
  # min(h_max - h_min)をしたい.
  trees = [int(input()) for _ in range(N)]
  trees.sort()
  trees = [n - trees[0] for n in trees]
  # print(trees[K-1] - trees[0]) -> これだと，最初の方はかなり分散が大きい配列で，後ろの方が分散が小さい配列だとダメ
  # 例[0, 100, 101, 102] から2個選ぶ時, 上記だと100が帰ってくる.
  MIN = 100000000000000
  # print(trees)
  for n in range(K):
    t = trees[n+K-1] - trees[n]
    MIN = min(t, MIN)
  print(MIN)
main()

Buggy submission (verdict: Runtime Error):
def main():
  N, K = map(int, input().split(' '))
  # N本の木があって，i本目の木はh_i[m]
  # K本選んで電飾する.
  # 木の内一番高いのをh_max[m], 低いものをh_min[m]
  # min(h_max - h_min)をしたい.
  trees = [int(input()) for _ in range(N)]
  trees.sort()
  trees = [n - trees[0] for n in trees]
  # print(trees[K-1] - trees[0]) -> これだと，最初の方はかなり分散が大きい配列で，後ろの方が分散が小さい配列だとダメ
  # 例[0, 100, 101, 102] から2個選ぶ時, 上記だと100が帰ってくる.
  MIN = 100000000000000
  # print(trees)
  for n in range(K):
    t = trees[n+K-1] - trees[n]
    print(trees[n], trees[n+K-1])
    MIN = min(t, MIN)
  print(MIN)
main()
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
iPY = []
 
for i in range(M):
    p, y = map(int, input().split())
    iPY.append([i, p, y])
 
city_count = {}
order = {}
 
for i, p, y in sorted(iPY, key=lambda x: x[2]):
    if not p in city_count:
        city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
for i, p, y in iPY:
    print('{:06}{:06}'.format(p, order[p, i]))

Buggy submission (verdict: Runtime Error):
def main():
  # N個の県，M個の市，
  # 市iが誕生したのはY_i年で県P_iに属す
  # 市iが県P_iの中でx番目にできた市だと、市iの認識番号の上6桁はP_i,下6桁はx
  # 6桁以下だと6桁になるように左に0詰める

  N, M = map(int, input().split())
  iPY = []
  for i in enumerate(range(M)):
    p, y = map(int, input().split())
    iPY.append([i, p, y])
  # PY = [list(map(int, input().split())) for _ in range(M)]
  iPY_sorted = sorted(iPY, key=lambda x: x[2])

  city_count = {}
  order = {}
  for i, p, y in iPY_sorted:
    if not p in city_count:
      city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
  for i, p, y in enumerate(iPY):
    print('{:06}{:06}'.format(p, order[p, i]))

main()

Buggy submission (verdict: Runtime Error):
def main():
  # N個の県，M個の市，
  # 市iが誕生したのはY_i年で県P_iに属す
  # 市iが県P_iの中でx番目にできた市だと、市iの認識番号の上6桁はP_i,下6桁はx
  # 6桁以下だと6桁になるように左に0詰める

  N, M = map(int, input().split())
  # PY = []
  # for _ in range(M):
  #   a = list(map(int, input().split()))
  #   PY.append(a)
  PY = [list(map(int, input().split())) for _ in range(M)]
  PY_sorted = sorted(PY, key=lambda x: x[1])

  city_count = {}
  order = {}
  for i, (p, y) in enumerate(PY_sorted):
    if not p in city_count:
      city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
  for i, (p, y) in enumerate(PY):
    print('{:06}{:06}'.format(p, order[p, i]))

main()

Buggy submission (verdict: Runtime Error):
def main():
  # N個の県，M個の市，
  # 市iが誕生したのはY_i年で県P_iに属す
  # 市iが県P_iの中でx番目にできた市だと、市iの認識番号の上6桁はP_i,下6桁はx
  # 6桁以下だと6桁になるように左に0詰める

  N, M = map(int, input().split())
  PY = []
  for _ in range(M):
    a = list(map(int, input().split()))
    PY.append(a)
  PY_sorted = sorted(PY, key=lambda x: x[1])

  city_count = {}
  order = {}
  for i, (p, y) in enumerate(PY_sorted):
    if not p in city_count:
      city_count[p] = 0
    city_count[p] += 1
    order[p, i] = city_count[p]
    
  for i, (p, y) in enumerate(PY):
    print('{:06}{:06}'.format(p, order[p, i]))

main()
Problem p03242 (python)

Fixed submission:
n = list(input())

result = ""

for a in n:
  if a == '1':
    result += '9'
  else:
    result += '1'


print(result)

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


def main():
    n = int(input())
    v_n = input().split(' ')
    
    guusuu = Counter(v_n[::2])
    kisuu = Counter(v_n[1::2])

    guusuu = guusuu.most_common()
    kisuu = kisuu.most_common()


    if guusuu[0][0]==kisuu[0][0]:
        if len(guusuu)==1 and len(kisuu)==1:
            print(guusuu)
        else:
            print(min(n - guusuu[0][1] - kisuu[1][1], n- guusuu[1][1] - kisuu[0][1]))
    else:
        print(n - guusuu[0][1] - kisuu[0][1])
        
main()
Problem p02831 (python)

Fixed submission:
import fractions

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


a, b = map(int, input().split())
c = lcm(a, b)
print(c)

Buggy submission (verdict: Runtime Error):
import math

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


a, b = map(int, input().split())
c = lcm(a, b)
print(c)
Problem p03017 (python)

Fixed submission:
n, a,b,c,d = map(int, input().split())
s = input()

def check_twice(left, right, l):
    for i in range(left-1, right):
        if l[i] == '#' and l[i+1] == '#':
            return False
    return True

def check_triple(left, right, l):
    f = False
    for i in range(left-1, right-2):
        if l[i] == '.' and l[i+1] == '.' and l[i+2] == '.':
            f = True
            break
        else:
            continue
    return f

if c < d:
    flg = check_twice(a, c, s) & check_twice(b, d, s)
    if flg is True:
        print('Yes')
    else:
        print('No')

else:
    flg = check_twice(a, c, s) & check_triple(b-1, d+1, s)
    if flg is True:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = map(int, input().split())
s = list(input())

def check():
    for i in range(a-1, d):
        if s[i-1] == s[i] == '#':
            return False
    return True


def check_2():
    for i in range(b-1, c):
        if s[i-1] == s[i] == s[i+1] == ".":
            return True
    return False


if check() is True:
    if c < d:
        print('Yes')
        exit()
    else:
        if check_2() is True:
            print('Yes')
            exit()
print('No')
Problem p03038 (python)

Fixed submission:
from operator import itemgetter

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    change = []
    process = []
    p_append = process.append

    for i in range(m):
        array = list(map(int, input().split()))
        p_append(array)

    process.sort(key = itemgetter(1),reverse=True)

    for i in range(len(process)):
        change += [process[i][1]] * process[i][0]
        if len(change) >= n:
            break

    a = a + change
    a.sort(reverse=True)
    a = a[:n]
    print(sum(a))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import bisect
import sys
input = sys.stdin.readline
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = []
    min_num = min(a)
    process = []
    p_append = process.append

    for i in range(m):
        array = list(map(int, input().split()))
        p_append(array)

    a.sort()
    process = sorted(process, key=lambda x: -x[1])

    for i in range(len(process)):
        index = bisect.bisect_left(a, process[i][1])
        ooo = min(index, process[i][0])
        if ooo == 0:
            continue
        else:
            a = a[ooo:]
            b.append(process[i][1] * ooo)
        if a[0] > process[i][1]:
            break

    print(sum(a)+sum(b))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import bisect
import sys
input = sys.stdin.readline
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = []
    min_num = min(a)
    process = []
    p_append = process.append

    for i in range(m):
        array = list(map(int, input().split()))
        if array[1] > min_num:
            p_append(array)

    a.sort()
    process = sorted(process, key=lambda x: -x[1])

    for i in range(len(process)):
        index = bisect.bisect_left(a, process[i][1])
        ooo = min(index, process[i][0])
        if ooo == 0:
            continue
        else:
            a = a[ooo:]
            b.append(process[i][1] * ooo)
        if a[0] > process[i][1]:
            break

    print(sum(a)+sum(b))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import bisect
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = []
    min_num = min(a)
    process = []
    p_append = process.append

    for i in range(m):
        array = list(map(int, input().split()))
        if array[1] > min_num:
            p_append(array)

    a.sort()
    process = sorted(process, key=lambda x: -x[1])

    for i in range(len(process)):
        index = bisect.bisect_left(a, process[i][1])
        ooo = min(index, process[i][0])
        if ooo == 0:
            continue
        else:
            a = a[ooo:]
            b.append(process[i][1] * ooo)
        if a[0] > process[i][1]:
            break

    print(sum(a)+sum(b))

if __name__ == '__main__':
    main()
Problem p03108 (python)

Fixed submission:
n, m = map(int, input().split())
bridges = []
island_connection = [1] * n
unconfortable = (n * (n - 1)) // 2
unconfortable_list = [unconfortable]


class UnionFind():
    def __init__(self, n):
        self.parent = [-1 for _ in range(n)]
        # 正==子: 根の頂点番号 / 負==根: 連結頂点数

    def find(self, x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        else:
            if self.size(x) < self.size(y):
                x, y = y, x
            self.parent[x] += self.parent[y]
            self.parent[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        x = self.find(x)
        return -self.parent[x]

    def is_root(self, x):
        return self.parent[x] < 0


connection = UnionFind(n)

for i in range(m):
    array = list(map(int, input().split()))
    array[0] -= 1
    array[1] -= 1
    bridges.append(array)

bridges = bridges[::-1]

for i, j in bridges:
    if connection.same(i,j) == 0:
        p = connection.size(i)
        q = connection.size(j)
        if p == 1 and q == 1:
            unconfortable -= 1
            connection.unite(i, j)
        else:
            unconfortable -= (p * q)
            connection.unite(i, j)
    unconfortable_list.append(unconfortable)

for i in range(1, m+1):
    print(unconfortable_list[-1-i])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
bridges = []
island_connection = [[i] for i in range(n)]
unconfortable = (n * (n - 1)) // 2
unconfortable_list = [unconfortable]

for i in range(m):
    array = list(map(int, input().split()))
    array[0] -= 1
    array[1] -= 1
    bridges.append(array)

bridges = bridges[::-1]

for i, j in bridges:
    if unconfortable != 0:
        if len(island_connection[i]) == 1 and len(island_connection[j]) == 1:
            unconfortable -= 1
            island_connection[i].append(j)
            island_connection[j].append(i)
        else:
            unconfortable -= (len(island_connection[i]) * len(island_connection[j]))
            plus_list_1 = island_connection[i].copy()
            plus_list_2 = island_connection[j].copy()
            for island in plus_list_1:
                island_connection[island].extend(plus_list_2)
            for island in plus_list_2:
                island_connection[island].extend(plus_list_1)

    unconfortable_list.append(unconfortable)

for i in range(1, m+1):
    print(unconfortable_list[-1-i])
Problem p03127 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))

hp = max(l)

l.sort()

while hp > 1 and len(l) != 1:
    a = l[0]
    for i in range(1, len(l)):
        l[i] %= a
    l.sort()
    while l[0] == 0:
        l.remove(0)
    if l[0] < hp:
        hp = l[0]

print(hp)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())
x = list(map(int, input().split()))

print(gcd_list(x))
Problem p03137 (python)

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

if n >= m:
    print(0)
    exit()

x = list(map(int, input().split()))
x = sorted(x)
diff = [x[i+1] - x[i] for i in range(0, m-1)]

sort_diff = sorted(diff, reverse=True)

sum = 0

if len(sort_diff) == 0:
    print(0)
    exit()

for i in range(n-1):
    sort_diff.pop(0)

for i in range(len(sort_diff)):
    sum += sort_diff[i]
print(sum)

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

x = list(map(int, input().split()))
x = sorted(x)
diff = [x[i+1] - x[i] for i in range(0, m-1)]

sort_diff = sorted(diff, reverse=True)

sum = 0

if len(sort_diff) == 0:
    print(0)
    exit()

for i in range(n-1):
    sort_diff.pop(0)

for i in range(len(sort_diff)):
    sum += sort_diff[i]
print(sum)

Buggy submission (verdict: Runtime Error):

n, m = map(int, input().split())

x = list(map(int, input().split()))
x = sorted(x)
diff = [x[i+1] - x[i] for i in range(0, m-1)]

sort_diff = sorted(diff, reverse=True)

sum = 0
for i in range(n-1):
    sort_diff.pop(0)

for i in range(len(sort_diff)):
    sum += sort_diff[i]
print(sum)

Buggy submission (verdict: Runtime Error):
import itertools

n, m = map(int, input().split())

x = list(map(int, input().split()))

x = sorted(x)
sum = 0
min = 1000000
flag = False
if m == 1:
    flag = True
    min = 0

l = list(range(1, m))

for i in itertools.combinations(l, n-1): # Change the conbination mCn
    if flag == True:
        break
    sum = 0
    for j in range(0, n):
        if j == 0:
            sum += x[i[0]-1] - x[0]
        elif j == n-1:
            sum += x[-1] - x[i[-1]]
        else:
            sum += x[i[j]-1] - x[i[j-1]]
    if sum < min:
        min = sum

print(min)
Problem p03329 (python)

Fixed submission:
n = int(input())
num_list = [1]
dp = [0] * (n+1)
dp[1] = 1


def recursion(n, li):
    min_n = 10**9
    for i in li:
        if n - i < 0:
            continue
        num = dp[n - i]
        if min_n > num:
            min_n = num
    return min_n + 1


for i in range(1, 9):
    a = 6 ** i
    b = 9 ** i
    if a <= n:
        num_list.append(a)
    if b <= n:
        num_list.append(b)

for i in range(2, n+1):
    dp[i] = recursion(i, num_list)

print(dp[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
num_list = [1]
dp = [0] * (n+1)
dp[1] = 1
dp[2] = 2
dp[3] = 3
dp[4] = 4
dp[5] = 5
dp[6] = 1


def recursion(n, li):
    min_n = 10**9
    for i in li:
        if n - i < 0:
            break
        num = dp[n - i]
        if min_n > num:
            min_n = num
    return min_n + 1


for i in range(1, 7):
    a = 6 ** i
    b = 9 ** i
    if a <= n:
        num_list.append(a)
    if b <= n:
        num_list.append(b)

for i in range(7, n+1):
    dp[i] = recursion(i, num_list)

print(dp[n])
Problem p03038 (python)

Fixed submission:
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
BC = [0]*M
for i in range(M):
    BC[i] = tuple(map(int, input().split()))

BC.sort(key=lambda x: x[1], reverse=True)

idx, flg = 0, 0
for i in BC:
    B, C = i
    for i in range(B):
        if idx > N-1:
            flg = 1
            break
        if A[idx] >= C:
            flg = 1
            break
        else:
            A[idx] = C
            idx += 1
            B -= 1
            if B == 0:
                break
    if flg:
        break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
BC = [0]*M
for i in range(M):
    BC[i] = tuple(map(int, input().split()))

BC.sort(key=lambda x: x[1], reverse=True)

idx, flg = 0, 0
for i in BC:
    B, C = i
    for i in range(B):
        if A[idx] >= C:
            flg = 1
            break
        else:
            A[idx] = C
            idx += 1
            B -= 1
            if B == 0:
                break
    if flg:
        break

print(sum(A))
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

dif = []
for i in range(M-1):
    dif.append(A[i+1] - A[i])

dif.sort(reverse=True)
dif = dif[N-1:]

print(sum(dif))

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

dif = []
for i in range(M-1):
    dif.append(A[i+1] - A[i])

for i in range(N-1):
    dif.remove(max(dif))

print(sum(dif))
Problem p02685 (python)

Fixed submission:

from collections import defaultdict

MOD = 998244353

def combination(a, b):
    if b > a - b:
        return combination(a, a - b)
    return fact[a] * ifact[b] * ifact[a-b]


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

# 階乗を前処理
fact = defaultdict(int)
fact[0] = 1
for i in range(1, N+1):
    fact[i] = fact[i-1] * i
    fact[i] %= MOD
# 階乗の逆元を前処理
ifact = defaultdict(int)
ifact[N] = pow(fact[N], MOD-2, MOD)
for i in reversed(range(1, N + 1)):
    ifact[i-1] = ifact[i] * i
    ifact[i-1] %= MOD

ans = 0
color = M
for x in reversed(range(N)):
    now = color
    now *= combination(N-1, x)
    now %= MOD
    if x <= K:
        ans += now
        ans %= MOD
    color *= M - 1
    color %= MOD

print(ans)

Buggy submission (verdict: Runtime Error):

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

ans = 0

for i in range(K+1):
    ans += M ** (i+1) * (M-1) ** (N-i-1)
    ans %= MOD

print(ans)
Problem p02793 (python)

Fixed submission:
from fractions import gcd

mod = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))

lcm = 1
for s in A:
    lcm = s * lcm // gcd(lcm, s)

ans = lcm * sum([pow(s, mod - 2, mod) for s in A]) % mod

print(int(ans % mod))

Buggy submission (verdict: Runtime Error):
import numpy


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

lcm = 1
for a in A:
    lcm = numpy.lcm(lcm, a)
lcm %= MOD

ans = 0
for a in A:
    ans += lcm * pow(a, MOD - 2, MOD) % MOD
    ans %= MOD

print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd


def lcm(a, b):
    return a * b / gcd(a, b)
 

N = int(input())
A = list(map(int, input().split()))

l = 1
for a in A:
    l = lcm(l, a)

l %= MOD

ans = 0
for a in A:
    ans += l * pow(a, MOD-2, MOD)
    ans %= MOD

print(int(ans))

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))

l = 1
for a in A:
    l = lcm(l, a)

l %= MOD

ans = 0
for a in A:
    ans += l * pow(a, MOD-2, MOD)
    ans %= MOD

print(int(ans))