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

Fixed submission:
# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Grand Contest 024 B問題 WA
Author     : Kitaura Hiromi
LastUpdate : 20180520
Since      : 20180520
"""
N = int(input())
p = [int(input()) for i in range(N)]
q = [0 for i in range(N)]
for i in range(N):
    q[p[i]-1] = i

cnt = 1
max_cnt = 1
for i in range(N-1):
    if q[i+1] > q[i]:
        cnt += 1
    else:
        max_cnt = max(max_cnt, cnt)
        cnt = 1
max_cnt = max(max_cnt, cnt)
print(N - max_cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Grand Contest 024 B問題 WA
Author     : Kitaura Hiromi
LastUpdate : 20180520
Since      : 20180520
"""
N = int(input())
p = [int(input()) for i in range(N)]
q = [0 for i in range(N)]
for i in range(N):
    q[p[i]-1] = i

cnt = 1
seq = []
for i in range(N-1):
    if q[i+1] - q[i] > 0:
        cnt += 1
    else:
        seq.append(cnt)
        cnt = 1
max_cnt = max(seq)
print(N - max_cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Grand Contest 024 B問題 WA
Author     : Kitaura Hiromi
LastUpdate : 20180520
Since      : 20180520
"""
N = int(input())
p = [int(input()) for i in range(N)]
q = [0] * N
for i in range(N):
    q[p[i]-1] = i

cnt = 1
for i in range(N-1):
    if q[i+1] - q[i] > 0:
        cnt += 1
    else:
        max_cnt = max(max_cnt, cnt)
        cnt = 1
print(N - max_cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Grand Contest 024 B問題 WA
Author     : Kitaura Hiromi
LastUpdate : 20180520
Since      : 20180520
"""
N = int(input())
p = []
q = [0] * N
for i in range(N):
    p.append(int(input()))
    q[p[i]-1] = i

cnt = 1
seq = []
for i in range(N-1):
    if q[i+1] - q[i] > 0:
        cnt += 1
    else:
        seq.append(cnt)
        cnt = 1
max_cnt = max(seq)
print(N - max_cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Grand Contest 024 B問題 WA
Author     : Kitaura Hiromi
LastUpdate : 20180520
Since      : 20180520
"""
N = int(input())
p = [0] * N
for i in range(N):
    p[i] = int(input())

q = [0] * N
for i in range(N):
    q[p[i]-1] = i

cnt = 1
seq = []
for i in range(N-1):
    if q[i+1] - q[i] > 0:
        cnt += 1
    else:
        seq.append(cnt)
        cnt = 1
max_cnt = max(seq)
print(N - max_cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Contents   : AtCoder Grand Contest 024 B問題 WA
Author     : Kitaura Hiromi
LastUpdate : 20180520
Since      : 20180520
"""
N = int(input())
p = []
for i in range(N):
    p.append(int(input()))

q = [0] * N
for i in range(N):
    q[p[i]-1] = i

cnt = 1
seq = []
for i in range(N-1):
    if q[i+1] - q[i] > 0:
        cnt += 1
    else:
        seq.append(cnt)
        cnt = 1
max_cnt = max(seq)
print(N - max_cnt)
Problem p02831 (python)

Fixed submission:
import fractions as f
A, B = map(int, input().split())
g = f.gcd(A, B)
ans = (A // g) * B
print(ans)

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
g = math.gcd(A, B)
ans = (A // g) * B
print(ans)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
a = int(input)
s = input
if a >= 3200:
  print(s)
else:
  print("red")
Problem p03053 (python)

Fixed submission:
H, W = map(int, input().split())
func = (lambda x: 1 if x == "#" else 0)
field = [[func(i) for i in input()] for _ in range(H)]
blackQ = []

for i, wField in enumerate(field):
    for j, w in enumerate(wField):
        if w == 1:
            blackQ.append((i, j))

ans = 0
while(True):
    bQ = []
    for _ in range(len(blackQ)):
        i, j = blackQ.pop()
        if i - 1 >= 0 and field[i-1][j] != 1:
            field[i-1][j] = 1
            bQ.append((i - 1, j))
        if i + 1 <= H - 1 and field[i+1][j] != 1:
            field[i+1][j] = 1
            bQ.append((i + 1, j))
        if j - 1 >= 0 and field[i][j-1] != 1:
            field[i][j-1] = 1
            bQ.append((i, j - 1))
        if j + 1 <= W - 1 and field[i][j + 1] != 1:
            field[i][j+1] = 1
            bQ.append((i, j + 1))

    if len(bQ) == 0:
        break

    ans += 1
    blackQ = bQ

print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
func = (lambda x: 1 if x == "#" else 0)
field = [[func(i) for i in input()] for _ in range(H)]
blackQ = []

for i, wField in enumerate(field):
    for j, w in enumerate(wField):
        if w == 1:
            blackQ.append((i, j))

ans = 0
while(True):
    bQ = []
    for _ in range(len(blackQ)):
        i, j = blackQ.pop()
        if i - 1 >= 0 and field[i-1][j] != 1:
            field[i-1][j] = 1
            bQ.append((i - 1, j))
        if i + 1 <= H - 1 and field[i+1][j] != 1:
            field[i+1][j] = 1
            bQ.append((i + 1, j))
        if j - 1 >= 0 and field[i][j-1] != 1:
            field[i][j-1] = 1
            bQ.append((i, j - 1))
        if j + 1 <= W - 1 and field[i][j + 1] != 1:
            field[i][j+1] = 1
            bQ.append((i, j + 1))

    if len(bQ) == 0:
        break

    ans += 1
    blackQ = bQ.copy()

print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
func = (lambda x: 1 if x == "#" else 0)
field = [[func(i) for i in input()] for _ in range(H)]
blackQ = []

for i, wField in enumerate(field):
    for j, w in enumerate(wField):
        if w == 1:
            blackQ.append((i, j))

ans = 0
while(True):
    bQ = []
    for _ in range(len(blackQ)):
        i, j = blackQ.pop()
        if i - 1 >= 0 and field[i-1][j] != 1:
            field[i-1][j] = 1
            bQ.append((i - 1, j))
        if i + 1 <= H - 1 and field[i+1][j] != 1:
            field[i+1][j] = 1
            bQ.append((i + 1, j))
        if j - 1 >= 0 and field[i][j-1] != 1:
            field[i][j-1] = 1
            bQ.append((i, j - 1))
        if j + 1 <= W - 1 and field[i][j + 1] != 1:
            field[i][j+1] = 1
            bQ.append((i, j + 1))

    if len(bQ) == 0:
        break

    ans += 1
    blackQ = bQ.copy()

print(ans)
Problem p02793 (python)

Fixed submission:
#E
mod=10**9+7
def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a

N=int(input())
A=list(map(int,input().split()))
Ainv=[]
for i in range(N):
    Ainv.append(pow(A[i],mod-2,mod))
SSS=0
for u in Ainv:
    SSS=(SSS+u)%mod
    
data=[0]*(max(A)+1)
for i in range(N):
    h=prime_factorize(A[i])
    cnt=1
    for i in range(1,len(h)):
        if h[i]==h[i-1]:
            cnt+=1
        else:
            data[h[i-1]]=max(data[h[i-1]],cnt)
            cnt=1
    if h:
        data[h[-1]]=max(data[h[-1]],cnt)
ans=1
for i in range(1,len(data)):
    if data[i]==0:
        continue
    else:
        ans=ans*pow(i,data[i],mod)%mod
print(ans*SSS%mod)

Buggy submission (verdict: Runtime Error):
#E

def prime_factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a

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

Ainv=[]
for i in range(N):
    Ainv.append(pow(A[i],mod-2,mod))
SSS=0
for u in Ainv:
    SSS=(SSS+u)%mod
    
data=[0]*(max(A)+1)
for i in range(N):
    h=prime_factorize(A[i])
    cnt=1
    for i in range(1,len(h)):
        if h[i]==h[i-1]:
            cnt+=1
        else:
            data[h[i-1]]=max(data[h[i-1]],cnt)
            cnt=1
    data[h[-1]]=max(data[h[-1]],cnt)
ans=1
for i in range(1,len(data)):
    if data[i]==0:
        continue
    else:
        ans=ans*pow(i,data[i],mod)%mod
print(ans*SSS%mod)
Problem p02863 (python)

Fixed submission:
n,t=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()
dp=[[-1]*t for i in range(n)]
for i in range(n):
    dp[i][0]=0
a,b=ab[0]
if a<t:
    dp[0][a]=b
for i in range(1,n):
    a,b=ab[i]
    for j in range(min(a,t)):
        dp[i][j]=dp[i-1][j]
    for j in range(a,t):
        if dp[i-1][j-a]==-1:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-a]+b)
table=[0]*n
table[n-1]=ab[n-1][1]
for i in range(n-2,-1,-1):
    table[i]=max(table[i+1],ab[i][1])
ans=0
for i in range(n-1):
    c=max(dp[i])
    ans=max(ans,c+table[i+1])
print(ans)

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()
dp=[[-1]*t for i in range(n)]
for i in range(n):
    dp[i][0]=0
a,b=ab[0]
dp[0][a]=b
for i in range(1,n):
    a,b=ab[i]
    for j in range(min(a,t)):
        dp[i][j]=dp[i-1][j]
    for j in range(a,t):
        if dp[i-1][j-a]==-1:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-a]+b)
table=[0]*n
table[n-1]=ab[n-1][1]
for i in range(n-2,-1,-1):
    table[i]=max(table[i+1],ab[i][1])
ans=0
for i in range(n-1):
    c=max(dp[i])
    ans=max(ans,c+table[i+1])
print(ans)
Problem p02912 (python)

Fixed submission:
#D heapq
import heapq
def mainasu(n):
    return n*(-1)
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(mainasu,a))
b.sort()
for i in range(m):
    c=heapq.heappop(b)
    if c%2==0:
        heapq.heappush(b,c//2)
    else:
        heapq.heappush(b,c//2+1)
print((-1)*sum(b))

Buggy submission (verdict: Runtime Error):
#D
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
i=0
l=0
for k in range(m-1):
    if i==n-1:
        for j in range(n):
            a[j]=a[j]//2
    elif a[i]//2<a[i+1]:
        i+=1
    else:
        for j in range(i+1):
            a[j]=a[j]//2
            l+=1
for j in range(m-l):
    a[j]=a[j]//2
print(sum(a))
Problem p02990 (python)

Fixed submission:
#D
from scipy.misc import comb
n,k=map(int,input().split())
mod=10**9+7
for i in range(1,k+1):
    print(int(comb(k-1,i-1,exact=True)*comb(n-k+1,i,exact=True))%mod)

Buggy submission (verdict: Runtime Error):
#D
from scipy.misc import comb
n,k=map(int,input().split())
mod=10**9+7
for i in range(1,k+1):
    print(int(comb(k-1,i-1,exact=True)*comb(n-k+1,i,exact=True))%mod)

Buggy submission (verdict: Runtime Error):
#D
from scipy.misc import comb
n,k=map(int,input().split())
mod=10**9+7
for i in range(1,k+1):
    print((comb(k-1,i-1,exact=True)*comb(n-k+1,i,exact=True))%mod)
Problem p03013 (python)

Fixed submission:
#C
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    b=1
    c=1
    if x==1 or x==0:
        return 1
    else:
        for i in range(x-1):
            b,c=(b+c)%mod,b
        return b
if m>=1:
    s=f(a[0]-1)
    for i in range(1,m):
        if a[i]-a[i-1]==1:
            print(0)
            break
        s=(s*f(a[i]-a[i-1]-2))%mod
    else:
        s=(s*f(n-a[m-1]-1))%mod
        print(s)
else:
    print(f(n))

Buggy submission (verdict: Runtime Error):
#C
import sys
sys.setrecursionlimit(1000000)
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    b=1
    c=1
    if x==1 or x==0:
        return 1
    else:
        for i in range(x-1):
            b,c=(b+c)%mod,b
        return b
s=f(a[0]-1)
for i in range(1,m):
    if a[i]-a[i-1]==1:
        print(0)
        break
    s=(s*f(a[i]-a[i-1]-2))%mod
else:
    s=(s*f(n-a[m-1]-1))%mod
    print(s)

Buggy submission (verdict: Runtime Error):
#C
import sys
sys.setrecursionlimit(1000000)
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    if x==1 or x==0:
        return 1
    else:
        return (f(x-1)+f(x-2))
s=f(a[0]-1)
for i in range(1,m):
    if a[i]-a[i-1]==1:
        print(0)
        break
    s=(s*f(a[i]-a[i-1]-2))%mod
else:
    s=(s*f(n-a[m-1]-1))%mod
    print(s)

Buggy submission (verdict: Runtime Error):
#C
import sys
sys.setrecursionlimit(1000000)
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    if x==1 or x==0:
        return 1
    else:
        return (f(x-1)+f(x-2))%mod
s=f(a[0]-1)
for i in range(1,m):
    if a[i]-a[i-1]==1:
        print(0)
        break
    s=(s*f(a[i]-a[i-1]-2))%mod
else:
    s=(s*f(n-a[m-1]-1))%mod
    print(s)

Buggy submission (verdict: Runtime Error):
#C
import sys
sys.setrecursionlimit(100000)
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    if x==1 or x==0:
        return 1
    else:
        return (f(x-1)+f(x-2))%mod
s=f(a[0]-1)
for i in range(1,m):
    if a[i]-a[i-1]==1:
        print(0)
        break
    s=(s*f(a[i]-a[i-1]-2))%mod
else:
    s=(s*f(n-a[m-1]-1))%mod
    print(s)

Buggy submission (verdict: Runtime Error):
#C
mod=10**9+7
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
def f(x):
    if x==1 or x==0:
        return 1
    else:
        return (f(x-1)+f(x-2))%mod
s=f(a[0]-1)
for i in range(1,m):
    if a[i]-a[i-1]==1:
        print(0)
        break
    s=(s*f(a[i]-a[i-1]-2))%mod
else:
    s=(s*f(n-a[m-1]-1))%mod
    print(s)
Problem p03127 (python)

Fixed submission:
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x%y)       
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in range(1,n):
    ans=gcd(a[i],a[i-1])
    a[i]=ans
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
n=int(input())
a=list(map(int,input().split()))
ans=a[0]
for i in range(1,n):
    ans=gcd(a[i],a[i-1])
    a[i]=ans
print(ans)
Problem p03253 (python)

Fixed submission:
n,m=map(int,input().split())
mod=10**9+7
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
lst=prime_factorize(m)
if m!=1:
    li=[1]
else:
    li=[0]
for i in range(1,len(lst)):
    if lst[i]==lst[i-1]:
        li[-1]+=1
    else:
        li.append(1)
ans=1
for u in li:
    a=n-1+u
    x=cmb(a,u)%mod
    ans=(ans*x)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
lst=prime_factorize(m)
if m!=1:
    li=[1]
for i in range(1,len(lst)):
    if lst[i]==lst[i-1]:
        li[-1]+=1
    else:
        li.append(1)
ans=1
for u in li:
    a=n-1+u
    x=cmb(a,u)%mod
    ans=(ans*x)%mod
print(ans)
Problem p03776 (python)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
ans=0
for i in range(a):
    ans+=v[i]
ans/=a
print(ans)
if v[0]==v[a-1]:
    count=0
    for i in range(n):
        if v[i]==v[0]:
            count+=1
    cnt=0
    for i in range(a,min(b,count)+1):
        cnt+=cmb(count,i)
    print(cnt)
else:
    count=0
    for i in range(n):
        if v[i]==v[a-1]:
            count+=1
    for i in range(n):
        if v[i]==v[a-1]:
            l=i
            break
    cnt=cmb(count,a-l)
    print(cnt)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
v=list(map(int,input().split()))
v.sort(reverse=True)
ans=0
for i in range(a):
    ans+=v[i]
ans/=a
k=a-1
count=1
while k<=n-2:
    if v[k]==v[k+1]:
        count+=1
        k+=1
        continue
    else:
        break
k=a-1
cnt=1
while k>=1:
    if v[k]==v[k-1]:
        count+=1
        cnt+=1
        k-=1
        continue
    else:
        break
print(ans)

l=n
for i in range(1,n):
    if v[i]==v[0]:
        continue
    else:
        l=i
        break
        
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
print(l)
if l<a:
    print(cmb(count,cnt))
if a<=l<=b:
    x=0
    for i in range(a,l+1):
        x+=cmb(l,i)
    print(x)
else:
    x=0
    for i in range(a,b+1):
        x+=cmb(l,i)
    print(x)
Problem p02831 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

a, b = map(int, input().split())
print((a * b) // gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
print((a*b) // math.gcd(a, b))
Problem p03127 (python)

Fixed submission:
from fractions import gcd

n = int(input())
A = [int(i) for i in input().split()]

a = A[0]
for i in range(1,n):
    a=gcd(a, A[i])

print(a)

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

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

a = A[0]
for i in range(1, n):
    a = gcd(a, A[i])

print(a)

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

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

print(reduce(math.gcd, A))
Problem p02793 (python)

Fixed submission:
import fractions
import functools
import sys

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

def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)
"""
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
"""
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

lcm_A = functools.reduce(lcm_base, A, 1)
B = [None]*N
B = [lcm_A//a for a in A]
#B[i] = lcm_A//A[i]

print(sum(B)%(10**9+7))

Buggy submission (verdict: Runtime Error):
import fractions
import functools
import sys

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

def lcm(*numbers):
    return functools.reduce(lcm_base, numbers, 1)
"""
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
"""
N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

lcm_A = functools.reduce(lcm_base, A, 1)
B = [None]*N
for i in xrange(N):
    B[i] = lcm_A//A[i]

print(sum(B)%(10**9+7))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm_A = lcm_list(A)
B = [None]*N
for i in range(N):
    B[i] = lcm_A/A[i]
print(1)
"""
print(int(sum(B)%(10**9+7)))
"""

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

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm_A = float(lcm_list(A))

B = [None]*N
for i in range(N):
    B[i] = lcm_A/A[i]

print(int(sum(B)%(10**9+7)))

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

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm_A = lcm_list(A)

B = [None]*N
for i in range(N):
    B[i] = lcm_A/A[i]

print(int(sum(B)%(10**9+7)))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm_A = lcm_list(A)

B = [None]*N
for i in range(N):
    B[i] = lcm_A/A[i]

print(int(sum(B)%(10**9+7)))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

lcm_A = lcm_list(A)

B = [None]*N
for i in range(N):
    B[i] = lcm_A/A[i]

print(sum(B)%(10**9+7))
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())
print(6-A-B)

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
print(6-A-B)
Problem p02832 (python)

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

A = []
i = 1
j = 0
while j != N:
    if a[j] == i:
        i += 1
    j += 1
else:
    if i == 1:
        print(-1)
    else:
        print(N-(i-1))

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

i = 0
count = 0
while True:
    if i == N-1:
        break
    if a[i] != i+1:
        del a[i]
        N-1
        i -= 1
        count += 1
    i += 1

b = len(a) + 1

if a == list(range(1, b)):
    print(count)
else:
    print(-1)
Problem p02833 (python)

Fixed submission:
from math import factorial

N = int(input())

if N%2 == 0:
    ans = 0
    devisor = 10
    while devisor <= N:
        ans += N//devisor
        devisor *= 5
    print(ans)   
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**15)

N = int(input())

def DoubleFactorial(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n*DoubleFactorial(n-2)

num = float(DoubleFactorial(N))

count = -1
while num.is_integer():
    num /= 10
    count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

N = int(input())

def DoubleFactorial(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n*DoubleFactorial(n-2)

num = float(DoubleFactorial(N))

count = -1
while num.is_integer():
    num /= 10
    count += 1

print(count)
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb
#from scipy.special import comb

N, K = map(int, input().split())
B = K
R = N - K
for i in range(1, K+1):
    # R+i C i
    #tmp1 = comb(R+1, i, exact = True)%10000000007
    tmp1 = comb(N-K+1, i, exact=True)
    rest = B - i
    # i H rest
    #tmp2 = comb(B-1, i-1, exact = True)%10000000007
    tmp2 = comb(K-1, i-1, exact=True)

    ans = (tmp1*tmp2)%1000000007
    print(int(ans))

Buggy submission (verdict: Runtime Error):
#from scipy.misc import comb
from scipy.special import comb

N, K = map(int, input().split())
B = K
R = N - K
for i in range(1, K+1):
    # R+i C i
    tmp1 = comb(R+1, i, exact = True)%10000000007
    rest = B - i
    # i H rest
    tmp2 = comb(i+rest-1, rest, exact = True)%10000000007
    ans = (tmp1*tmp2)%1000000007
    print(int(ans))

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb
#from scipy.special import comb

N, K = map(int, input().split())
B = K
R = N - K
for i in range(1, K+1):
    ans = (comb(R+1, i, exact = True)*comb(i+(B-i)-1, B-i))%(10**9+7)
    print(int(ans))

Buggy submission (verdict: Runtime Error):
#from scipy.misc import comb
from scipy.special import comb

N, K = map(int, input().split())
B = K
R = N - K
for i in range(1, K+1):
    ans = (comb(R+1, i, exact = True)*comb(i+(B-i)-1, B-i))%(10**9+7)
    print(int(ans))