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

Fixed submission:
x, y  = map(int, input().split())
mod = 10 ** 9 + 7
if (x + y) % 3 != 0:
    ans = 0
else:
    n, m = (2 * x - y) / 3, (2 * y - x) / 3
    ans = 0
    if n >= 0 and m >= 0:
        n, m = int(n), int(m)
        ans = 1
        for i in range(min(m, n)):
            ans = ans * (n + m - i) % mod 
            ans *= pow(i + 1, mod - 2, mod)

print(ans % mod)

Buggy submission (verdict: Runtime Error):
x, y  = map(int, input().split())
mod = 10 ** 9 + 7
if (x + y) % 3 != 0:
    ans = 0
else:
    n, m = (2 * x - y) / 3, (2 * y - x) / 3
    if n >= 0 and m >= 0:
        n, m = int(n), int(m)
        ans = 1
        for i in range(min(m, n)):
            ans = ans * (n + m - i) % mod 
            ans *= pow(i + 1, mod - 2, mod)

print(ans % mod)

Buggy submission (verdict: Runtime Error):
x, y  = map(int, input().split())
mod = 10 ** 9 + 7
if (x + y) % 3 != 0:
    ans = 0
else:
    n, m = (2 * x - y) // 3, (2 * y - x) // 3
    if n >= 0 and m >= 0:
        ans = 1
        for i in range(min(m, n)):
            ans = ans * (n + m - i) % mod 
            ans *= pow(i + 1, mod - 2, mod)

print(ans % mod)
Problem p02891 (python)

Fixed submission:
s = list(input())
k = int(input())
x = []
ans = 0
cnt = 1
for i in range(len(s)):
    if i < len(s) - 1 and s[i] == s[i + 1]:
        cnt += 1
    else:
        ans += cnt // 2
        x.append(cnt)
        cnt = 1
cnt = 0
if s[0] == s[len(s) - 1]:
    cnt = x[0] // 2 + x[-1] // 2 - (x[0] + x[-1]) // 2

print(ans * k - cnt * (k - 1) if len(set(s)) != 1 else len(s) * k // 2)

Buggy submission (verdict: Runtime Error):
s = list(input())
k = int(input())
x = []
ans = 0
cnt = 1
for i in range(len(s)):
    if i < len(s) - 1 and s[i] == s[i + 1]:
        cnt += 1
    else:
        ans += cnt // 2
        x.append(cnt)
        cnt = 1
cnt = 0
if s[0] == s[len(s) - 1]:
    cnt = x[0] // 2 + x[-1] // 2 - (x[0] + x[1]) // 2

print(ans * k - cnt * (k - 1) if len(set(s)) != 1 else len(s) * k // 2)
Problem p02912 (python)

Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(a)

for i in range(m):
    x = heapq.heappop(a)
    heapq.heappush(a, -1 * ((-x) // 2))
print(-sum(a))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in range(m):
    while a[-1] >= a[-2]:
        a[-1] //= 2
    a.sort()
print(sum(a))
Problem p02990 (python)

Fixed submission:
from math import factorial

n, k = map(int, input().split())
def fac(n, r):
    return factorial(n) // (factorial(max(0, n - r)) * factorial(r))
for i in range(1, k + 1):
    print( (fac(n - k + 1, i) * fac(k - 1, i - 1)) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
from math import factorial

n, k = map(int, input().split())
def fac(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
for i in range(1, k + 1):
    print( (fac(n - k + 1, i) * fac(k - 1, i - 1)) % (10 ** 9 + 7))

Buggy submission (verdict: Runtime Error):
from math import factorial

n, k = map(int, input().split())
p = factorial(n - k + 1)

def fac(n, r):
    return factorial(n) // factorial(n - r) * factorial(r)
for i in range(1, k + 1):
    print( (fac(n - k + 1, i) * fac(k - 1, i - 1)) % (10 ** 9 + 7))
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
flag = [True] * (n + 1)
cnt = [0] * (n + 1)
for i in range(m):
    a = int(input())
    flag[a] = False

for i in range(n, -1, -1):
    if flag[i]:
        if i == n or i == n - 1:
            cnt[i] = 1
        else:
            cnt[i] = (cnt[i + 1] + cnt[i + 2]) % (10 ** 9 + 7)
    else:
        cnt[i] = 0
print (cnt[0])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
flag = [True] * n
cnt = [0] * n
for i in range(m):
    a = int(input())
    flag[a - 1] = False

for i in range(n - 1, -1, -1):
    if flag[i]:
        if i == n - 1 or i == n - 2:
            cnt[i] = 1
        else:
            cnt[i] = (cnt[i + 1] + cnt[i + 2]) % (10 ** 9 + 7)
    else:
        cnt[i] = 0
print (cnt[0]+ cnt[1])
Problem p03017 (python)

Fixed submission:
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
    flag = "##" not in s[b: d] and "##" not in s[a: c]
else:
    flag = "..." in s[b - 2: d + 1]

print("Yes" if flag else "No")

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c
    flag = "##" not in s[b: d] and "##" not in s[a: c]
else:
    flag = "..." in s[b: d]

print("Yes" if flag else "No")
Problem p03107 (python)

Fixed submission:
s = list(input())
n = len(s)
i = 0
cnt = 0
while i < n - 1:
    if n == 1:
        break
    if (s[i] == '0' and s[i + 1] == '1') or (s[i] == '1' and s[i + 1] == '0'):
        s[i:i + 2] = []
        i = max(i - 1, 0)
        cnt += 2
        n = len(s)
    else:
        i += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
s = list(input())
n = len(s)
i = 0
cnt = 0
while i != n - 1:
    if (s[i] == '0' and s[i + 1] == '1') or (s[i] == '1' and s[i + 1] == '0'):
        s[i:i + 2] = []
        i -= 1
        cnt += 2
        n = len(s)
    else:
        i += 1

print(cnt)
Problem p03137 (python)

Fixed submission:

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

x = list(map(int, input().split()))
if n >= m:
    print(0)
    exit()
x.sort()
dis = [0] * (m - 1)
for i in range(m - 1):
    dis[i] = x[i + 1] - x[i]

dis.sort()
ans = x[m - 1] - x[0]
for i in range(len(dis) - 1, len(dis)- n, -1):
    ans -= dis[i]

print(ans)

Buggy submission (verdict: Runtime Error):

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

x = list(map(int, input().split()))
x.sort()
dis = [0] * (m - 1)
for i in range(m - 1):
    dis[i] = x[i + 1] - x[i]

dis.sort()
ans = x[m - 1] - x[0]
for i in range(len(dis) - 1, len(dis)- n, -1):
    ans -= dis[i]

print(ans)
Problem p03209 (python)

Fixed submission:

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

a, p = [1], [1]

for i in range(n):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def cnt_p(n, x):
    if n == 0:
        if x <= 0:
            return 0
        return 1
    elif x <= 1 + a[n - 1]:
        return cnt_p(n - 1, x - 1)
    else:
        return p[n - 1] + 1 + cnt_p(n - 1, x - 2 - a[n - 1])


print(cnt_p(n, x))

Buggy submission (verdict: Runtime Error):

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

def make_burger(n):
    if n == 0:
        return "P"
    else:
        L = make_burger(n - 1)
        return "B" + L + "P" + L + "B"
    

b = make_burger(n)
ans = 0
for i in range(len(b) - 1, len(b) - x - 1, -1):
    if b[i] == "P":
        ans += 1
print(ans)
Problem p03804 (python)

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

a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0] and i + m - 1 < n and j + m - 1 < n:
            flag = 1
            for y in range(m):
                for x in range(m):
                    if a[i + y][j + x] != b[y][x]:
                        flag = 0
                        break
                
            if flag == 1:
                print("Yes")
                exit()

print("No")

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

a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0] and i + m - 1 < n and j + m - 1 < n:
            flag = 1
            for y in range(i, i + m):
                for x in range(j, j + m):
                    if a[i + y][j + x] != b[y][x]:
                        flag = 0
                        break
                
            if flag == 1:
                print("Yes")
                exit()

print("No")

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

a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0] and i + m <= n and j + m <= n:
            flag = 1
            for y in range(i, i + m):
                for x in range(j, j + m):
                    if a[i + y][j + x] != b[y][x]:
                        flag = 0
                        break
                
            if flag == 1:
                print("Yes")
                exit()

print("No")
Problem p02623 (python)

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

A_sum = [0]
for i in range(N):
    A_sum.append(A_sum[i] + A[i])
B_sum = [0]
for i in range(M):
    B_sum.append(B_sum[i] + B[i])
B_sum.append(10**10)

res = 0
for i in range(len(A_sum)):
    low = 0
    high = len(B_sum)
    while high - low > 1:
        mid = (low + high) // 2
        if A_sum[i] + B_sum[mid] <= K:
            low = mid
        else:
            high = mid
    if A_sum[i] + B_sum[low] <= K:
        res = max(res, i + low)

print(res)

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

A_sum = [0]
for i in range(N):
    A_sum.append(A_sum[i] + A[i])
B_sum = [0]
for i in range(N):
    B_sum.append(B_sum[i] + B[i])
B_sum.append(10**10)

res = 0
for i in range(len(A_sum)):
    low = 0
    high = len(B_sum)
    while high - low > 1:
        mid = (low + high) // 2
        if A_sum[i] + B_sum[mid] <= K:
            low = mid
        else:
            high = mid
    if A_sum[i] + B_sum[low] <= K:
        res = max(res, i + low)

print(res)
Problem p02546 (python)

Fixed submission:
n=input()
if n[-1]=="s":
  print(n+"es")
else:
  print(n+"s")

Buggy submission (verdict: Runtime Error):
from itertools import product
N=int(input())
count=0
lis=[i for i in range(1,N+1)]
x=list(itertools.product(lis,repeat=3))
for i in x:
  if y[0]*y[1]+y[2]==N:
    count+=1

print(count)
Problem p02699 (python)

Fixed submission:
S,W=map(int,input().split())
if W>=S:
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
S,W=map(int,input().split())
if W>=s:
  print("unsafe")
else:
  print("safe")
Problem p02773 (python)

Fixed submission:
from collections import Counter
N=int(input())
lis=list(input() for _ in range(N))
ans=[]

counter=Counter(lis)
high=counter.most_common()[0][1]

for k,v in counter.most_common():
  if v==high:
    ans.append(k)
  else:
    break
ans.sort()
for i in ans:
  print(i)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
lis=list(input() for _ in range(N))
ans=[]
high=0

counter=Counter(lis)
high=counter.most_common()[0][1]

for  j in se:
  if lis.count(j)==high:
    ans.append(j)
ans.sort()

for k in ans:
  print(k)
Problem p02829 (python)

Fixed submission:
A=["1","2","3"]
A.pop(A.index(input()))
A.pop(A.index(input()))
print(A[0])

Buggy submission (verdict: Runtime Error):
A=[1,2,3]
A.pop(A.insert(input()))
A.pop(A.insert(input()))
print(A[-1])
Problem p02836 (python)

Fixed submission:
x=[i for i in input()]
count=0

if len(x)%2!=0:
  x.pop(len(x)//2)

P =[p for p in range(0,len(x)//2)]
Q =[q for q in range(len(x)//2,len(x))]
Q.sort(reverse=True)
for a,b in zip(P,Q):
  if x[a]!=x[b]:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
x=[i for i in input()]
count=0

if len(x)%2!=0:
  x.pop(len(x)//2+1)

P =[p for p in range(0,len(x)//2)]
Q =[q for q in range(len(x)//2,len(x))]
Q.sort(reverse=True)
for a,b in zip(P,Q):
  if x[a]!=x[b]:
    count+=1
print(count)
Problem p02879 (python)

Fixed submission:
a,b = map(int,input().split())
if a<10 and b<10:
  print(a*b)
else:
  print("-1")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a<10 nad b<10:
  print(a*b)
else:
  print("-1")
Problem p02951 (python)

Fixed submission:
x = input().split()


d = int(x[2])-(int(x[0])-int(x[1]))

if d>=0:
  print(d)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
x = int(input())
 
if x <=9:
  print(x)
elif x<=99:
  print(9)
elif x<=999:
  print(9+(x-99))
elif x<=9999:
  print(909)
elif x<=99999:
  print(909+(x-9999))
elif x ==100000:
  print(90909)

Buggy submission (verdict: Runtime Error):
x = int(input())

if x <10:
  print(x)
elif x<99:
  print(9)
elif x<999:
  print(9+(x-99))
elif x<9999:
  print(909)
elif x<99999:
  print(909+(x-9999))
elif x==100000:
  print(90909)

Buggy submission (verdict: Runtime Error):
x = int(input())

if x <10:
  print(x)
elif x<99:
  print(9)
elif x<999:
  print(9+(x-99))
elif x<9999:
  print(909)
elif x<99999:
  print(909+(x-9999))
else:
  print(90909)
Problem p02970 (python)

Fixed submission:
N,D = map(int,input().split())
x = N//(D*2+1)
if N%(D*2+1)!=0:
  print(x+1)
else:
  print(x)

Buggy submission (verdict: Runtime Error):
N,D = map(int,input().split())
x = N//(D*2+1)
if N%(D*2+1)1=0:
  print(x+1)
else:
  print(x)
Problem p03012 (python)

Fixed submission:
N = int(input())
x = list(map(int,input().split()))
ans = []
for i in range(1,N):
  s1 = sum(x[0:i])
  s2 = sum(x[i::])
  ans.append(abs(s1-s2))
ans.sort()
print(ans[0])

Buggy submission (verdict: Runtime Error):
N = int(input())
x = list(map(int,input().split()))
middle = sum(x)/2
tol = 0
ans = []

for i in range(4):
  tol += x[i]
  re_new  =abs(tol-middle)
  ans.append(re_new)

t = ans.index(min(ans))
print(sum(x[0:t+1])-sum(x[t+1::]))
Problem p03327 (python)

Fixed submission:
x = int(input())

if x < 1000:
  print("ABC")
else:
  print("ABD")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
t = b - a
n = [1]
x = 1

for i in range(2,999):
  x = i + x
  n.append(x)

else:
  for j in range(0,len(n)):
    if n[j+1] - n[j] == t:
      break
print(n[j] - a)
Problem p03631 (python)

Fixed submission:
x=input()
if x[0]==x[2]:print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
x=int(input())
if x[0]==x[2]:print("Yes")
else:
  print("No")
Problem p02550 (python)

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

a = x
li = [a]
exists = dict()
i = 1
for i in range(2, n + 1):
    a = a * a % m
    if a in exists:
        break
    li.append(a)
    exists[a] = i

ans = sum(li)
if i != n:
    loop, left = divmod(n - i + 1, i - exists[a])
    ans += loop * sum(li[exists[a]-1:]) + sum(li[exists[a]-1:exists[a]-1+left])
print(ans)

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

a = x
li = [a]
exists = dict()
for i in range(2, n + 1):
    a = a * a % m
    if a in exists:
        break
    li.append(a)
    exists[a] = i

ans = sum(li)
if i != n:
    loop, left = divmod(n - i + 1, i - exists[a])
    ans += loop * sum(li[exists[a]-1:]) + sum(li[exists[a]-1:exists[a]-1+left])
print(ans)
Problem p02557 (python)

Fixed submission:
from collections import Counter, defaultdict

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

ca = Counter(a)
cb = Counter(b)

for ka, va in ca.items():
    vb = cb[ka]
    if va + vb > n:
        print("No")
        exit()

print("Yes")
end = defaultdict(int)
for i, e in enumerate(a):
    end[e] = i

mx = 0
for i, e in enumerate(b):
    diff = end[e] - i + 1
    mx = max(mx, diff)

ans = b[-mx:] + b[:-mx]
print(*ans)

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

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

ca = Counter(a)
cb = Counter(b)

for ka, va in ca.items():
    vb = cb[ka]
    if va + vb > n:
        print("No")
        exit()

print("Yes")
ans = [0] * n
i = 0
for j, e in enumerate(b):
    while i < n and a[i] == e:
        i += 1

    if i == n:
        break

    ans[i] = e
    i += 1

i = 0
for e in b[j:]:
    while ans[i] != 0:
        i += 1
    ans[i] = e
print(*ans)

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

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

ca = Counter(a)
cb = Counter(b)

for ka, va in ca.items():
    vb = cb[ka]
    if va + vb > n:
        print("No")
        exit()

raise Exception
Problem p02580 (python)

Fixed submission:
H, W, M = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(M)]

h_cnt = [0] * (H + 1)
w_cnt = [0] * (W + 1)

for h, w in hw:
    h_cnt[h] += 1
    w_cnt[w] += 1

h_mx = max(h_cnt)
w_mx = max(w_cnt)

cnt = h_cnt.count(h_mx) * w_cnt.count(w_mx)
for h, w in hw:
    val = h_cnt[h] + w_cnt[w]
    if val == h_mx + w_mx:
        cnt -= 1

if cnt:
    ans = h_mx + w_mx
else:
    ans = h_mx + w_mx - 1

print(ans)

Buggy submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(M)]

board = [[0] * (W + 1) for _ in range(H + 1)]

h_cnt = [0] * (H + 1)
w_cnt = [0] * (W + 1)

for h, w in hw:
    h_cnt[h] += 1
    w_cnt[w] += 1
    board[h][w] = 1

h_mx = max(h_cnt)
w_mx = max(w_cnt)

cnt = h_cnt.count(h_mx) * w_cnt.count(w_mx)
for h, w in hw:
    val = h_cnt[h] + w_cnt[w]
    if val == h_mx + w_mx:
        cnt -= 1

if cnt:
    ans = h_mx + w_mx
else:
    ans = h_mx + w_mx - 1

print(ans)

Buggy submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(M)]

board = [[0] * (W + 1) for _ in range(H + 1)]

h_cnt = [0] * (H + 1)
w_cnt = [0] * (W + 1)

for h, w in hw:
    h_cnt[h] += 1
    w_cnt[w] += 1
    board[h][w] = 1

mx = 0
for h in range(1, H + 1):
    for w in range(1, W + 1):
        val = h_cnt[h] + w_cnt[w] - board[h][w]
        mx = max(mx, val)

print(mx)
Problem p02707 (python)

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

cnt = [0] * (n + 1)
for e in a:
    cnt[e] += 1

print(*cnt[1:], sep="\n")

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline

import numpy as np

n = int(readline())
a = np.array(readline().split(), np.int16)

a -= 1
ans = np.bincount(a, minlength=n)
print(*ans, sep="\n")
Problem p02763 (python)

Fixed submission:
from bisect import bisect_left, insort_left


def main():
    n = int(input())
    s = list(input())
    q = int(input())
    qs = [input().split() for _ in range(q)]

    abc = [[] for _ in range(26)]
    for i, e in enumerate(s):
        j = ord(e) - ord("a")
        abc[j].append(i)

    for t, e1, e2 in qs:
        if t == "1":
            i = int(e1) - 1
            c = e2

            let = s[i]

            if let == c:
                continue

            idx = ord(let) - ord("a")
            popi = bisect_left(abc[idx], i)
            abc[idx].pop(popi)

            idx = ord(c) - ord("a")
            insort_left(abc[idx], i)

            s[i] = c

        else:
            l = int(e1) - 1
            r = int(e2) - 1

            cnt = 0
            for i in range(26):
                li = bisect_left(abc[i], l)
                if li >= len(abc[i]):
                    continue
                if abc[i][li] <= r:
                    cnt += 1

            print(cnt)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right, insort_left

n = int(input())
s = input()
q = int(input())
qs = [list(input().split()) for _ in range(q)]

abc = [[-1, n] for _ in range(26)]
for i, e in enumerate(s):
    j = ord(e) - ord("a")
    abc[j].append(i)

for i in range(26):
    abc[i].sort()

for t, e1, e2 in qs:
    if t == "1":
        i = int(e1) - 1
        c = e2

        let = s[i]

        idx = ord(let) - ord("a")
        popi = bisect_left(abc[idx], i)
        abc[idx].pop(popi)

        idx = ord(c) - ord("a")
        insort_left(abc[idx], i)

    else:
        l = int(e1) - 1
        r = int(e2) - 1

        cnt = 0
        for i in range(26):
            li = bisect_left(abc[i], l)
            ri = bisect_right(abc[i], r)
            if li != ri:
                cnt += 1

        print(cnt)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right, insort_left

n = int(input())
s = input()
q = int(input())
qs = [list(input().split()) for _ in range(q)]

abc = [[-1, n] for _ in range(26)]
for i, e in enumerate(s):
    j = ord(e) - ord("a")
    abc[j].append(i)

for i in range(26):
    abc[i].sort()

for t, e1, e2 in qs:
    if t == "1":
        i = int(e1) - 1
        c = e2

        let = s[i]

        idx = ord(let) - ord("a")
        popi = bisect_left(abc[idx], i)
        abc[idx].pop(popi)

        idx = ord(c) - ord("a")
        insort_left(abc[idx], i)

    else:
        l = int(e1) - 1
        r = int(e2) - 1

        cnt = 0
        for i in range(26):
            li = bisect_left(abc[i], l)
            ri = bisect_right(abc[i], r)
            if li != ri:
                cnt += 1

        print(cnt)
Problem p02793 (python)

Fixed submission:
from fractions import gcd


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


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

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

l %= mod

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

print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readline

    from fractions import gcd

    def lcd(x, y):
        g = gcd(x, y)
        return x * y // g

    n = int(input())
    a = tuple(map(int, input().split()))
    mod = 10 ** 9 + 7

    a.sort(reverse=True)
    l = 1
    for e in a:
        l = lcd(l, e)

    ans = 0
    for e in a:
        ans += (l // e) % mod
        ans %= mod

    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

from numpy import lcm

l = lcm.reduce(a)

ans = 0
for e in a:
    add = l // e
    ans += add
    ans %= mod

print(ans)
Problem p02925 (python)

Fixed submission:
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]


def match2int(x, y):
    x, y = min(x, y), max(x, y)
    return (2 * n - 1 - x) * x // 2 + y - x - 1


match_sm = n * (n - 1) // 2

adj = [[] for _ in range(match_sm)]
in_deg = [0] * match_sm
for i, li in enumerate(a):
    for j, k in zip(li, li[1:]):
        j -= 1
        k -= 1
        match1 = match2int(i, j)
        match2 = match2int(i, k)
        adj[match1].append(match2)
        in_deg[match2] += 1

cnd = [i for i, e in enumerate(in_deg) if e == 0]
day = 0
while cnd:
    nxt_cnd = []
    for u in cnd:
        for v in adj[u]:
            in_deg[v] -= 1
            if in_deg[v] == 0:
                nxt_cnd.append(v)

    cnd = nxt_cnd
    day += 1

if in_deg.count(0) != match_sm:
    day = -1

print(day)

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

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


def match2int(x, y):
    x, y = min(x, y), max(x, y)
    return (2 * n - 1 - x) * x // 2 + y - x - 1


match_sm = n * (n - 1) // 2

adj = [[] for _ in range(match_sm)]
in_deg = np.zeros(match_sm, dtype=np.int16)
for i, li in enumerate(a):
    for j, k in zip(li, li[1:]):
        j -= 1
        k -= 1
        match1 = match2int(i, j)
        match2 = match2int(i, k)
        adj[match1].append(match2)
        in_deg[match2] += 1

cnd = [i for i, e in enumerate(in_deg) if e == 0]
day = 0
while cnd:
    in_deg[cnd] -= 1
    for u in cnd:
        in_deg[adj[u]] -= 1

    cnd = np.where(in_deg == 0)[0]
    day += 1

if not in_deg.all(0):
    day = -1

print(day)