Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for i in range(n)]
#wv[i][0]:i番目の品物の重さ
#wv[i][1]:i番目の品物の価値

dp = [0]*(w+1)#dp[i]:重さiにおける最大価値
for i in range(n):#あるi番目の品物について
    for j in range(w,wv[i][0]-1, -1):
        dp[j] = max( dp[j], dp[j-wv[i][0]]+wv[i][1] )#i番目の品物を使うほうが良い場合は値を更新

print(max(dp))

Fixed submission:
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for i in range(n)]
#wv[i][0]:i番目の品物の重さ
#wv[i][1]:i番目の品物の価値

dp = [0]*(w+1)#dp[i]:重さiにおける最大価値
for i in range(n):#あるi番目の品物について
    for j in range(w,wv[i][0]-1, -1):
        dp[j] = max( dp[j], dp[j-wv[i][0]]+wv[i][1] )#i番目の品物を使うほうが良い場合は値を更新

print(max(dp))
Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for i in range(n)]
#wv[i][0]:i番目の品物の重さ
#wv[i][1]:i番目の品物の価値

dp = [0]+[float"inf"]*(10**5)#dp[k]:価値kにおける最小重さ
for i in range(n):#あるi番目の品物について
    for j in range(10**5,wv[i][1]-1, -1):#ある価値jについて
        dp[j] = min( dp[j], dp[j-wv[i][1]]+wv[i][0] )
        #重さwv[i][0]であるi番目の品物を使うほうが価値jでの最小重さdp[j]が小さい場合は値を更新

res = 0
for v,e in enumerate(dp):#インデックスv(=ある価値j)における最小重さeについて
    if e <= w:
        res = v#最小重さが重さ制限を超えないならres更新
print(res)

Fixed submission:
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for i in range(n)]
#wv[i][0]:i番目の品物の重さ
#wv[i][1]:i番目の品物の価値

dp = [0]+[float("inf")]*(10**5)#dp[k]:価値kにおける最小重さ
for i in range(n):#あるi番目の品物について
    for j in range(10**5,wv[i][1]-1, -1):#ある価値jについて
        dp[j] = min( dp[j], dp[j-wv[i][1]]+wv[i][0] )
        #重さwv[i][0]であるi番目の品物を使うほうが価値jでの最小重さdp[j]が小さい場合は値を更新

res = 0
for v,e in enumerate(dp):#インデックスv(=ある価値j)における最小重さeについて
    if e <= w:
        res = v#最小重さが重さ制限を超えないならres更新
print(res)

Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for i in range(n)]
#wv[i][0]:i番目の品物の重さ
#wv[i][1]:i番目の品物の価値

dp = [0]*(w+1)#dp[i]:重さiにおける最大価値
for i in range(n):#あるi番目の品物について
    for j in range(w,wv[i][0]-1, -1):#ある重さjについて
        dp[j] = max( dp[j], dp[j-wv[i][0]]+wv[i][1] )#i番目の品物を使うほうが重さjでの価値が高い場合は値を更新

print(max(dp))

Fixed submission:
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for i in range(n)]
#wv[i][0]:i番目の品物の重さ
#wv[i][1]:i番目の品物の価値

dp = [0]+[float("inf")]*(10**5)#dp[k]:価値kにおける最小重さ
for i in range(n):#あるi番目の品物について
    for j in range(10**5,wv[i][1]-1, -1):#ある価値jについて
        dp[j] = min( dp[j], dp[j-wv[i][1]]+wv[i][0] )
        #重さwv[i][0]であるi番目の品物を使うほうが価値jでの最小重さdp[j]が小さい場合は値を更新

res = 0
for v,e in enumerate(dp):#インデックスv(=ある価値j)における最小重さeについて
    if e <= w:
        res = v#最小重さが重さ制限を超えないならres更新
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
def divisor(x):
    if x==1:
        return 1
    if x==2 or x==3:
        return 2
    count=0
    for i in range(1,(x//2)+1):
        if x%i==0:
            count+=1
    return count+1

n = int(input())
ans=0
for num in range(1,n+1):
    a = 0
    divisors = divisor(num)
    a = num* divisors 
    ans+=a
print(ans)

Fixed submission:
import numpy as np
n=int(input())
num=np.array(list(range(1,n+1)))

x=n//num
ans=num*(x+1)*x/2
print(int(np.sum(ans)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
C = 10 ** 9 + 7
B = 0
A = list(map(int, input().split()))
for i in range(N-1):
    for j in range(i+1, N):
        B += A[i] * A[j]        
print(B % C)        



Fixed submission:
N = int(input())
C = 10 ** 9 + 7
B = 0
a = 0
ans = 0
A = list(map(int, input().split()))
for i in range(N):
    a += A[i]
for i in range(N-1):
    a -= A[i]
    B = A[i] * a
    ans += B
    B = 0    
print(ans % C)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
C = 10 ** 9 + 7
B = 0
A = list(map(int, input().split()))
for i in range(N):
    for j in range(i+1, N):
        B += A[i] * A[j]        
print(B % C)        



Fixed submission:
N = int(input())
C = 10 ** 9 + 7
B = 0
a = 0
ans = 0
A = list(map(int, input().split()))
for i in range(N):
    a += A[i]
for i in range(N-1):
    a -= A[i]
    B = A[i] * a
    ans += B
    B = 0    
print(ans % C)
Buggy python submission (verdict: Runtime Error):
x = int(input())
if x >= 30:
    print("Yes")
    else:
        print("No")

Fixed submission:
x = int(input())
if x >= 30:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
[N, D] = input().split()
s = 0
D = int(D)
D = D**2
for i in range(N):
    [X, Y] = input().split()
    X = int(X)
    Y = int(Y)
    Z = X**2 + Y**2
    if Z <= D:
        s += 1
print(s)        

Fixed submission:
[N, D] = input().split()
s = 0
N = int(N)
D = int(D)
D = D**2
for i in range(N):
    [X, Y] = input().split()
    X = int(X)
    Y = int(Y)
    Z = X**2 + Y**2
    if Z <= D:
        s += 1
print(s)

Buggy python submission (verdict: Runtime Error):
[N, D] = input().split()
s = 0
D = int(D)
for i in range(N):
    [X, Y] = input().split()
    X = int(X)
    Y = int(Y)
    Z = X**2 + Y**2
    if Z <= D**2:
        s +=1
print(s)        

Fixed submission:
[N, D] = input().split()
s = 0
N = int(N)
D = int(D)
D = D**2
for i in range(N):
    [X, Y] = input().split()
    X = int(X)
    Y = int(Y)
    Z = X**2 + Y**2
    if Z <= D:
        s += 1
print(s)

Buggy python submission (verdict: Runtime Error):
[N, D] = input().split()
s = 0
D = int(D)
for i in range(N):
    [X, Y] = input().split()
    X = int(X)
    Y = int(Y)
    Z = X**2 + Y**2
    if Z <= D:
        s +=1
print(s)        

Fixed submission:
[N, D] = input().split()
s = 0
N = int(N)
D = int(D)
D = D**2
for i in range(N):
    [X, Y] = input().split()
    X = int(X)
    Y = int(Y)
    Z = X**2 + Y**2
    if Z <= D:
        s += 1
print(s)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for i in range(A + 1):
  for j in range(B + 1):
    if X - i * 500 - j * 100 % 50 == 0 and X - i * 500 - j * 100 <= 50 * C
        cnt += 1
        
print(cnt)

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

workX = X

for i in range(A + 1):
    if workX > 500 * i:
        workX -= 500 * i
    elif workX == 500 * i:
        cnt += 1
        continue
    else:
        break

    for j in range(B + 1):
        if workX > 100 * j:
            workX -= 100 * j
        elif workX == 100 * j:
            cnt += 1
            break
        else:
            break

        if workX % 50 == 0 and workX <= 50 * C:
            cnt += 1
            workX += 100 * j
            continue
        else:
            workX += 100 * j

    workX = X


print(cnt)
Buggy python submission (verdict: Runtime Error):
line = input()
count  = 0

for i in range(3):
  if line[i] == '1':
    count += 1

return count

Fixed submission:
line = input()
count  = 0

for i in range(3):
  if line[i] == '1':
    count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
str = input()
cnt = 0
for i in range(3):
    if str[i] == '1':
        cnt += 1

return cnt

Fixed submission:
line = input()
count  = 0

for i in range(3):
  if line[i] == '1':
    count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
line = input()
count = 0

for i in range(3):
  if line[i] == 1:
    count += 1

return line

Fixed submission:
line = input()
count  = 0

for i in range(3):
  if line[i] == '1':
    count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
list = [int(i) for i in input().split()]
count = 0
flg = False

while True:
    for num in list:
        if num % 2 != 0:
            flg = True
            break
    if flg:
        break
    else:
        #奇数がなければリスト丸ごと半分にする
        count += 1
        list = map(lambda x: x / 2, list)
print(count)

Fixed submission:
n = input()
list = [int(i) for i in input().split()]
min_count = 1000000000
tmp = 0

for num in list:
    tmp = 0
    while True:
        if num % 2 != 0:
          break
        else:
          tmp += 1
          num = num / 2
    if min_count > tmp:
        min_count = tmp  
          
print(min_count)
Buggy python submission (verdict: Runtime Error):
s = input()
midLen = len(s) - 2

print(s[0] + midLen + s[-1])

Fixed submission:
s = input()
midLen = len(s) - 2
 
print(s[0] + str(midLen) + s[-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
exp = 0

for N >= 2:
  N = N // 2
  exp += 1
  
print(2 ** exp)

Fixed submission:
N = int(input())
exp = 0
 
while N >= 2:
  N = N // 2
  exp += 1
  
print(2 ** exp)
Buggy python submission (verdict: Time Limit Exceeded):
cnt = 0

l = []
l = input().split()
k = int(l[0])
s = int(l[1])

for x in range(k + 1):
  for y in range(k + 1):
    for z in range(k + 1):
      if x + y + z == s:
        cnt += 1
        
print(cnt)

Fixed submission:
cnt = 0
l = []
l = input().split()
k = int(l[0])
s = int(l[1])

for x in range(k + 1):
  for y in range(k + 1):
      if 0 <= s - (x + y) <= k:
        cnt += 1
        
print(cnt)
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout

INF = float('inf')
s = stdin.readline().strip()
f = stdin.readline().strip()

n, m = len(s), len(f)
dp = [[0 for i in range(n + 5)] for j in range(m + 5)]

for i in range(n):
    for j in range(m):
        if s[i] == f[j]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

n -= 1
m -= 1
ans = ''

while n >= 0 and m >= 0:
    if s[n] == f[m]:
        ans += s[n]
        n -= 1
        m -= 1
    elif dp[n - 1][m] > dp[n][m - 1]:
        n -= 1
    else:
        m -= 1
        
stdout.write(ans[::-1])

Fixed submission:
from sys import stdin, stdout

INF = float('inf')
s = stdin.readline().strip()
f = stdin.readline().strip()

n, m = len(s), len(f)
dp = [[0 for i in range(m + 5)] for j in range(n + 5)]


for i in range(n):
    for j in range(m):
        if s[i] == f[j]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

n -= 1
m -= 1
ans = ''

while n >= 0 and m >= 0:
    if s[n] == f[m]:
        ans += s[n]
        n -= 1
        m -= 1
    elif dp[n - 1][m] > dp[n][m - 1]:
        n -= 1
    else:
        m -= 1
        
stdout.write(ans[::-1])
Buggy python submission (verdict: Runtime Error):
ans = False
for i in range(n):
  d1,d2 = map(int,input().split())
  if d1 == d2:
    conseq += 1
    if conseq >= 3:
      ans = True
  else:
    conseq = 0

if ans:
  print('Yes')
else:
  print('No')

Fixed submission:
n = int(input())
conseq = 0
ans = False
for i in range(n):
  d1,d2 = map(int,input().split())
  if d1 == d2:
    conseq += 1
    if conseq >= 3:
      ans = True
  else:
    conseq = 0

if ans:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

mod = 10**9+7
sum_a = sum(a)%mod
sum_a2 = sum_a**2%mod

for i in range(n):
    sum_a2 -= (a[i]**2)
    sum_a2 %= mod
    
if sum_a2%2 == 0:
    ans = sum_a2//2
else:
    ans = ((ans+mod)//2)%mod

print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
 
mod = 10**9+7
sum_a = sum(a)%mod
sum_a2 = sum_a**2%mod
 
for i in range(n):
    sum_a2 -= (a[i]**2)%mod
    sum_a2 %= mod
    
if sum_a2%2 == 0:
    ans = sum_a2//2
else:
    ans = ((sum_a2+mod)//2)%mod

print(ans)
Buggy python submission (verdict: Runtime Error):
H,W,M = map(int,input().split())

horizontal = [[i,0] for i in range(H)]
vertical = [[i,0] for i in range(W)]
table = {}

for i in range(M):
    h,w = map(int,input().split())
    h -= 1
    w -= 1
    table[(h,w)] = True
    vertical[w][1] += 1
    horizontal[h][1] += 1

vertical.sort(key=lambda x:-x[1])
horizontal.sort(key=lambda x:-x[1])

h_max = horizontal[0][1]
v_max = vertical[0][1]
    
for i in range(H):
    if horizontal[i][1]<h_max:
        break
for j in range(W):
    if vertical[j][1]<v_max:
        break

flag = False
for h in horizontal[:i]:
    for v in vertical[:j]:
        if table.get((h[0],v[0]))==None:
            flag = True
            break
    if flag:
        break

if flag:
    print(h_max+v_max)
else:
    print(h_max+v_max-1)

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

c = n//x
if n%x == 0:
    print(c*t)
else:
    print((c+1)*t)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
p = [i-1 for i in p]


groups = []
is_appear = [False]*n
group_size = [0]*n
for i in range(n):
    if is_appear[i]:
        continue
    group = []
    group.append(i)
    is_appear[i] = True
    j = p[i]
    while j != i:
        group.append(j)
        is_appear[j] = True
        j = p[j]
        
    groups.append(group)
    
    for i in group:
        group_size[i] = len(group)


cycle_score = [0]*n
for g in groups:
    score = 0
    for i in range(len(g)):
        score += c[g[i]]
    
    for i in g:
        cycle_score[i] = score

best = 0        
for i in range(n):
    score = 0
    best_i = 0
    cyc_num = k//group_size[i]
    if cycle_score[i]>0 and cyc_num>=1:
        remain = k-group_size[i]*(cyc_num-1)
        score += cycle_score*(cyc_num-1)
        
    elif cycle_score[i]<=0:
        remain = group_size[i]
    elif cyc_num<1:
        remain = k
    
    j = i
    for _ in range(remain):
        j = p[j]
        score += c[j]
        best_i = max(best_i,score)
    best = max(best,best_i)
    
print(best)

Fixed submission:
n,k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))
p = [i-1 for i in p]


groups = []
is_appear = [False]*n
group_size = [0]*n
for i in range(n):
    if is_appear[i]:
        continue
    group = []
    group.append(i)
    is_appear[i] = True
    j = p[i]
    while j != i:
        group.append(j)
        is_appear[j] = True
        j = p[j]
        
    groups.append(group)
    
    for i in group:
        group_size[i] = len(group)


cycle_score = [0]*n
for g in groups:
    score = 0
    for i in range(len(g)):
        score += c[g[i]]
    
    for i in g:
        cycle_score[i] = score

best = -float('inf')        
for i in range(n):
    score = 0
    best_i = -float('inf')
    cyc_num = k//group_size[i]
    if cycle_score[i]>0 and cyc_num>=1:
        remain = k-group_size[i]*(cyc_num-1)
        score += cycle_score[i]*(cyc_num-1)
        
    elif cycle_score[i]<=0:
        remain = group_size[i]
    elif cyc_num<1:
        remain = k
    
    j = i
    for _ in range(remain):
        j = p[j]
        score += c[j]
        best_i = max(best_i,score)
    best = max(best,best_i)
    
print(best)
Buggy python submission (verdict: Runtime Error):
k = int(input())

import fractions

flag = False

for i in range(n):
    f = fractions.gcd(k,(10**n-1)/9*7)
    if f == k:
        flag = True
        break

if flag:
    print(i+1)
else:
    print(-1)

Fixed submission:
k = int(input())

flag = False

resid  = 7
if resid%k==0:
    i = -1
    flag = True
else:
    for i in range(k):
        resid = (resid*10+7)%k
        if resid == 0:
            flag = True
            break

if flag:
    print(i+2)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

dp = [None]*(n+1)
def p_factor(x):
  x_copy = x
  flag = False
  pf={}
  for i in range(2,int(x**0.5)+1):
    while x%i==0:
      pf[i]=pf.get(i,0)+1
      x//=i
      if dp[x]:
        flag = True
        break
    if flag:break        		
   
  if flag:
    for i in dp[x].keys():
      pf[i] = pf.get(i,0)+dp[x][i]
  else:
    if x>1:pf[x]=1
  dp[x_copy] = pf
  return pf

def divisor_count(x):
  factor = p_factor(x)
  primes = factor.keys()
  num_div = 1
  
  for p in primes:
    num_div *= factor[p]+1
  return num_div

sum_div = 1
for i in range(2,n+1):
  sum_div += i*divisor_count(i)
print(sum_div)

Fixed submission:
n = int(input())

dp = [0]*(n+1)

for i in range(1,n+1):
  x = n//i
  for j in range(1,x+1):
    dp[i*j]+=1
    
sum_div = 0
for i in range(1,n+1):
  sum_div += i*dp[i]
print(sum_div)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

def p_factor(x):
  factor = {}
  i = 2
  while x>1:
    if x%i == 0:
      x //= i
      if factor.get(i):
        factor[i] += 1
      else:
        factor[i] = 1
      continue
    else:
      i += 1
  return factor

def divisor_count(x):
  factor = p_factor(x)
  primes = factor.keys()
  num_div = 1
  
  for p in primes:
    num_div *= factor[p]+1
  return num_div

sum_div = 1
for i in range(2,n+1):
  sum_div += i*divisor_count(i)
print(sum_div)

Fixed submission:
n = int(input())

dp = [0]*(n+1)

for i in range(1,n+1):
  x = n//i
  for j in range(1,x+1):
    dp[i*j]+=1
    
sum_div = 0
for i in range(1,n+1):
  sum_div += i*dp[i]
print(sum_div)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

is_divided = [0]*n

for i in range(n):
  if is_divided[i]:
    continue
  for j in range(n):
    if j == i:
      continue
    if a[j]%a[i] == 0:
      is_divided[j] = 1
      if a[j] == a[i]:
        is_divided[i] = 1
      
print(n-sum(is_divided))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MAX = 10**6+1

is_divided = [0]*MAX 
is_appeared = [0]*MAX

for i in range(n):
  if not is_divided[a[i]]:
    if not is_appeared[a[i]]:
      is_appeared[a[i]] = 1
      k = a[i]*2
      while k < MAX:
        is_divided[k] = 1
        k += a[i]
    else:
      is_divided[a[i]] = 1
      
ans = 0      
for i in range(n):
  if not is_divided[a[i]]:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

a.sort()

divisors = {}

divisors[a[0]] = 1

for i in range(1,n):
  div_flag = False
  for div in divisors.keys():
    if a[i]%div == 0:
      div_flag = True
      if div%a[i] == 0:
        divisors[div] = 0
      break
  if div_flag:
    continue
  else:
    divisors[a[i]] = 1

ans = 0
for key in divisors.keys():
  ans += divisors[key]
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MAX = 10**6+1

is_divided = [0]*MAX 
is_appeared = [0]*MAX

for i in range(n):
  if not is_divided[a[i]]:
    if not is_appeared[a[i]]:
      is_appeared[a[i]] = 1
      k = a[i]*2
      while k < MAX:
        is_divided[k] = 1
        k += a[i]
    else:
      is_divided[a[i]] = 1
      
ans = 0      
for i in range(n):
  if not is_divided[a[i]]:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
a = int(a)
b = int(b*100)

print((a*b)//100)

Fixed submission:
a,b = input().split()
a = int(a)
b100 = int(b[0])*100+int(b[2])*10+int(b[3])

print((a*b100)//100)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

count = 0
ABC = [0]*3

for a in range(1,N+1):
  for b in range(1,N+1):
    D = b*a
    if D >= N:
      break
    else:
#      print(a, b, N-D)
      count = count + 1
print(count)

Fixed submission:
N = int(input())

count = 0
count2 = 0
ABC = [0]*3

for a in range(1,N):
  if N % a == 0:
    x = int(N/a)-1
  else:
    x = int(N/a)
  count = count + x
#  print(x)

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
row = input()
L = [""]*N
for i in range(N):
  L[i] = row[i]

count = 0
while(1):
  while(1):
    if len(L) == 0:
      break
    if L[0] == "R":
      del L[0]
    elif L[-1] == "W":
      del L[-1]
    else:
      break
      
  if len(L) == 0:
    break
  else:
    left = L[0]
    right = L[-1]
    L[0] = right
    L[-1] = left
    count = count + 1
    
print(count)

Fixed submission:
N = int(input())
stone = input()

R_count = 0
W_count = 0
for i in range(len(stone)):
  if stone[i] == "R":
    R_count = R_count + 1
  else:
    W_count = W_count + 1

W = 0
R = R_count
try_num_prev = -1
for i in range(N):
  if R_count == 0 or W_count == 0:
    try_num = 0
    break
  
  if W <= R:
    try_num = R
  else:
    try_num = W
  
  #print(try_num_prev, try_num)
  if try_num_prev >= 0 and try_num_prev < try_num:
    try_num = try_num_prev
    break
  else:
    try_num_prev = try_num
    if stone[i] == "R":
      R = R - 1
    else:
      W = W + 1
    
print(try_num)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce

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

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)

x = lcm_list(a)
ans = 0

for i in a:
    ans += (x//i)
    ans %= 1000000007

print(ans)

Fixed submission:
import fractions
from functools import reduce

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

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)

x = lcm_list(a)
ans = 0

for i in a:
    ans += (x//i)
ans %= 1000000007

print(ans)

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

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

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

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

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

x = lcm_list(a)
ans = 0

for i in a:
    ans += (x//i)
    ans %= 1000000007

print(ans)

Fixed submission:
import fractions
from functools import reduce

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

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)

x = lcm_list(a)
ans = 0

for i in a:
    ans += (x//i)
ans %= 1000000007

print(ans)

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

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

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

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

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

x = lcm_list(a)
ans = 0

for i in a:
    ans += (x//x)
    ans %= 1000000007

print(ans)

Fixed submission:
import fractions
from functools import reduce

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

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)

x = lcm_list(a)
ans = 0

for i in a:
    ans += (x//i)
ans %= 1000000007

print(ans)
Buggy python submission (verdict: Runtime Error):
import math


def read_ints():
    return [int(c) for c in input().split()]


def solve(a, b, c, d):
    if a < b:
        return False
    if d < b:
        return False
    if c >= b:
        return True
    e = a % b
    delta = d % b
    if delta == 0:
        return e <= c
    g = math.gcd(b, delta)
    maxv = b - g
    return maxv <= c


def main():
    n = int(input())
    for _ in range(n):
        print("Yes" if solve(*read_ints()) else "No")


if __name__ == '__main__':
    main()

Fixed submission:
import fractions as math


def read_ints():
    return [int(c) for c in input().split()]


def solve(a, b, c, d):
    if a < b:
        return False
    if d < b:
        return False
    if c >= b:
        return True
    e = a % b
    delta = d % b
    if delta == 0:
        return e <= c
    g = math.gcd(b, delta)
    maxv = b - g
    return maxv <= c


def main():
    n = int(input())
    for _ in range(n):
        print("Yes" if solve(*read_ints()) else "No")


if __name__ == '__main__':
    main()