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

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
a = [int(input()) for i in range(N)]
s = int(max(a)) // 2
a.remove(max(a)) #aの最大の要素を消去
print(sum(a) + s) #処理後のリストaにSを加えて足す

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
a = [input() for i in range(N)]
s = int(max(a)) // 2
a.remove(max(a)) #aの最大の要素を消去
print(sum(a) + s) #処理後のリストaにSを加えて足す

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
a = [input() for i in range(N)]
S = max(a) // 2
a.remove(max(a)) #aの最大の要素を消去
print(sum(a,S)) #処理後のリストaにSを加えて足す
Problem p03242 (python)

Fixed submission:
# -*- coding utf-8 -*-
n = str(input())
S = n.replace("1","8")
T = S.replace("9","1")
U = T.replace("8","9")
print(U)

Buggy submission (verdict: Runtime Error):
# -*- coding utf-8 -*-
n = str(input())
S = n.replace(1,8)
T = S.replace(9,1)
U = T.replace(8,9)
print(U)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
S = n.replace(1,9).replace(9,1)
print(S)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = str(input())
S = n.replace(1,9).replace(9,1)
print(S)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = str(input())
S = n.replace(1,9).replace(9,1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = str(input())
m.replace(1,9:9,1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n=int(input())
n.replace("1","9")and("9","1")
Problem p03250 (python)

Fixed submission:
# -*- coding: utf-8 -*-
A,B,C=map(int,input().split())
print(max(A*10+B+C, B*10+C+A,  C*10+A+B))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A,B,C=map(int,input().split())
print(max(A*10+B+C, B*10+C+A C*10+A+B))
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 + (y1 - y2)
y3 = y2 + (x2 - x1)
x4 = x1 + (y1 - y2)
y4 = y1 + (x2 - x1)
print(x3,y3,x4,y4)

Buggy submission (verdict: Runtime Error):
x1,x2,y1,y2 = map(int,input())
x3 = x2 + (y1 - y2)
y3 = y2 + (x2 - x1)
x4 = y1 + (x2 - x1)
y4 = x1 + (y1 - y2)
print(x3,y3,x4,y4)
Problem p03315 (python)

Fixed submission:
# -*- coding: utf-8 -*-
S = str(input())
P = S.count("+")
Q = S.count("-")
print("{}".format(P-Q))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A,B,C,D=map(str,input().split())
+ = "1"
- = "-1"
L = [+,-]
S = map(int,L.split())
print("{}".format(A+B+C+D))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A,B,C,D=map(int,input().split())
+ = 1
- = -1
print("{}".format(A+B+C+D))
Problem p03327 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
if N >=  1000:
  print("ABD")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
if N > 1000:
  print(ABD)
else:
  print(ABC)
Problem p02627 (python)

Fixed submission:
if input().isupper():
  print("A")
else:
  print("a")

Buggy submission (verdict: Runtime Error):
X=int(input())
n=26

a=[]
X_dumy = X
out = ''
while X_dumy>0:
  out = str(X_dumy%n)
  X_dumy = int(X_dumy/n)
  a.append(out)

l = list('abcdefghijklmnopqrstuvwxyz')
N=0
for x in a:
  a[N]=l[int(a[N])-1]
  N=N+1
pg = ''.join(a)
print(pg)
Problem p02723 (python)

Fixed submission:
s=input()

a=s[2]
b=s[3]
c=s[4]
d=s[5]

if a==b and c==d:
  print("Yes")
else :
  print("No")

Buggy submission (verdict: Runtime Error):
a=list.input()

if a[2]==a[3] and a[4]==a[5]:
  print("Yes")
else:
  print("No")
Problem p03013 (python)

Fixed submission:
import math
def fib(q):
   fibonacci = [0,1]
   for i in range(2,q):
       fibonacci.append(fibonacci[i-2]+fibonacci[i-1])
   return fibonacci[q-1]
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):   
    a.append(int(input()))
a.append(n+1)
out=1
c=10**9+7
for i in range(m+1):
    out*=int(fib(a[i+1]-a[i]))
out%=c
print(out)

Buggy submission (verdict: Runtime Error):
import sympy as sym 
def fib(n):
    x = sym.symbols('x', nonnegative=True, integer=True)
    Fib = 1 / sym.sqrt(5) * (((1+sym.sqrt(5))/2)**(n) - ((1-sym.sqrt(5))/2)**(n))
    result = Fib.subs(x, n) 
    result = sym.simplify(result) 
    return result
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):   
    a.append(int(input()))
a.append(n+1)
out=1
c=10**9+7
for i in range(m+1):
    out*=int(fib(a[i+1]-a[i]-1))
out%=c
print(out)

Buggy submission (verdict: Runtime Error):
import math
def fib(q):
    result = int(1 / math.sqrt(5) * (((1+math.sqrt(5))/2)**(q) - ((1-math.sqrt(5))/2)**(q)))
    return result
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):   
    a.append(int(input()))
a.append(n+1)
out=1
c=10**9+7
for i in range(m+1):
    out*=int(fib(a[i+1]-a[i]-1))
out%=c
print(out)

Buggy submission (verdict: Runtime Error):
import math
def fib(q):
    result = int(1 / math.sqrt(5) * (((1+math.sqrt(5))/2)**(q) - ((1-math.sqrt(5))/2)**(q)))
    return result
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):   
    a.append(int(input()))
a.append(n+1)
out=1
c=10**9+7
for i in range(m+1):
    out*=int(fib(a[i+1]-a[i]-1))
    out%=c
print(out)

Buggy submission (verdict: Runtime Error):
import math
def fib(q):
    result = int(1 / math.sqrt(5) * (((1+math.sqrt(5))/2)**(q) - ((1-math.sqrt(5))/2)**(q)))
    return result
def o():
    n,m = list(map(int, input("").split()))
    a=[]
    a.append(-1)
    d=0
    for i in range(m):   
        a.append(int(input()))
    a.append(n+1)
    out=1
    c=10**9+7
    for i in range(m+1):
        d=a[i+1]-a[i]-1
        if d==0:
            return 0
        out*=int(fib(d))
        out%=c
    return int(out)
print(o())

Buggy submission (verdict: Runtime Error):
import math
def fib(q):
    result = 1 / math.sqrt(5) * (((1+math.sqrt(5))/2)**(q) - ((1-math.sqrt(5))/2)**(q))
    return result
def o():
    n,m = list(map(int, input("").split()))
    a=[]
    a.append(-1)
    for i in range(m):   
        a.append(int(input()))
    a.append(n+1)
    out=1
    c=10**9+7
    for i in range(m+1):
        d=a[i+1]-a[i]-1
        if d==0:
            return 0
        out*=int(fib(d))
        out%=c
    return int(out)
print(o())
Problem p02711 (python)

Fixed submission:
s = input()
if '7' in s:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
if '7' in s:
  print("Yes)
else:
  print("No")
Problem p02793 (python)

Fixed submission:
def lcm(a, b):
    from fractions import gcd

    return a // gcd(a, b) * b


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    x = 1

    for e in a:
        x = lcm(x, e)

    ans = 0
    for e in a:
        ans += x // e

    print(ans % int(1e9 + 7))


main()

Buggy submission (verdict: Runtime Error):
def lcm(a, b):
    from math import gcd

    return a // gcd(a, b) * b


def main():
    _ = int(input())
    a = list(map(int, input().split()))
    x = 1

    for e in a:
        x = lcm(x, e)

    ans = 0
    for e in a:
        ans += x // e

    print(ans % int(1e9 + 7))


main()

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

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

MOD = 10**9 + 7

N = int(input())
a = [int(x) for x in input().split()]

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

ans = 0
for e in a:
    ans += m // e
    ans %= MOD

print(ans)
Problem p02793 (python)

Fixed submission:
def gcd(x, y): 

    while(y): 
        x, y = y, x % y 
    
    return x 

n = int(input())
a = list(map(int, input().split(' ')))
nok = a[0]
mod = int(1e9 + 7)
for i in range(1, n):
    nok = nok * a[i] // gcd(nok, a[i])
ans = 0
for i in range(0, n):
    ans += nok // a[i]
print (ans % mod)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int, input().split(' ')))
nok = a[0]
mod = int(1e9 + 7)
for i in range(1, n):
    nok = nok * a[i] // math.gcd(nok, a[i])
ans = 0
for i in range(0, n):
    ans += nok // a[i]
print (ans % mod)
Problem p02570 (python)

Fixed submission:
D, T, S = map(int,input().split())

if(D/S <= T):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
D = int(input())
T = int(input())
S = int(input())

res = D/S
if(res <= T):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
D = int(input())
T = int(input())
S = int(input())

res = S*T
if(res >= D):
    print("Yes")
else:
    print("No")
Problem p02659 (python)

Fixed submission:
from decimal import Decimal

a, b = [Decimal(str(x)) for x in input().split()]

c = a * b

print(int(c))

Buggy submission (verdict: Runtime Error):
import sys
import math

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

ans = a[0]

for i in range(1, n):
    ans *= a[i]
    if math.log10(ans) > 18:
        print("-1")
        sys.exit()


print(ans)
Problem p02701 (python)

Fixed submission:
N = int(input())
s = [input() for i in range(N)]

print(len(set(s)))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [input() for i in range(N)]
memo = []

for i in range(s):
    r = s.random.choice()
    if r not in memo:    
        memo.append(r)    

print(len(memo))
Problem p02549 (python)

Fixed submission:
# D - Leaping Tak
n,k = map(int,input().split())
lr = [tuple(map(int,input().split())) for _ in range(k)]
MOD = 998244353

# 累積和を使ってもらうdpを効率よく実現する。

dp = [0 for _ in range(n+1)]
dpsum = [0 for _ in range(n+1)]
dp[1] = 1
dpsum[1] = 1
for i in range(2,n+1):
  for li,ri in lr:
    r = i-li
    if r < 1:
      continue
    l = max(i-ri-1,0)
    dp[i] += dpsum[r]-dpsum[l]
    dp[i] %= MOD
  dpsum[i] += dpsum[i-1]+dp[i]
  dpsum[i] %= MOD
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
s = []
for i in range(k):
  l,r = map(int,input().split())
  s.append((l,r))
MOD = 998244353

memo = [-1 for _ in range(n+1)]

def f(x):
  if x < 1:
    return 0
  if x == 1:
    return 1
  if memo[x] != -1:
    return memo[x]
  res = 0
  for l,r in s:
    for i in range(l,r+1):
      res += f(x-i)
      res %= MOD
  memo[x] = res
  return res

print(f(n))
Problem p02834 (python)

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

N,u,v = map(int,input().split())
u -= 1
v -= 1
E = [set() for _ in range(N)]
for _ in range(N-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)

DU = [-1 for _ in range(N)]  
DV = [-1 for _ in range(N)]
def dfs(p,c,D):
  D[p] = c
  for q in E[p]:
    if D[q] == -1:
      dfs(q,c+1,D)
dfs(u,0,DU)
dfs(v,0,DV)
#print(DU)
#print(DV)
mx = 0
for du,dv in zip(DU,DV):
  if du < dv:
    mx = max(dv,mx)
print(mx-1)

Buggy submission (verdict: Runtime Error):
N,u,v = map(int,input().split())
u -= 1
v -= 1
E = [set() for _ in range(N)]
for _ in range(N-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)

DU = [-1 for _ in range(N)]  
DV = [-1 for _ in range(N)]
def dfs(p,c,D):
  D[p] = c
  for q in E[p]:
    if D[q] == -1:
      dfs(q,c+1,D)
dfs(u,0,DU)
dfs(v,0,DV)
#print(DU)
#print(DV)
mx = 0
for du,dv in zip(DU,DV):
  if du < dv:
    mx = max(dv,mx)
print(mx-1)

Buggy submission (verdict: Runtime Error):
N,u,v = map(int,input().split())
u -= 1
v -= 1
E = [set() for _ in range(N)]
for _ in range(N-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)

DU = [-1 for _ in range(N)]  
DV = [-1 for _ in range(N)]
def dfs(p,c,D):
  D[p] = c
  for q in E[p]:
    if D[q] == -1:
      dfs(q,c+1,D)
dfs(u,0,DU)
dfs(v,0,DV)
#print(DU)
#print(DV)
DX = []
for du,dv in zip(DU,DV):
  DX.append(dv-du)
#print(DX)
#print(max(max(DX)-1,0))
mx = max(DX)
#print(DX.index(mx))
if DU[DX.index(mx)]%2 == 1:
  print(max(mx,0))
else:
  print(max(mx-1,0))
Problem p02990 (python)

Fixed submission:
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, K = map(int, input().split())
mod_num = 10 ** 9 + 7
for i in range(1, K + 1):
  if i > N - K + 1:
    print(0)
  else:
    print(comb(N - K + 1, i) * comb(K - 1, i - 1) % mod_num)

Buggy submission (verdict: Runtime Error):
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, K = map(int, input().split())
mod_num = 10 ** 9 + 7
for i in range(1, K + 1):
  print(comb(N - K + 1, i) * comb(K - 1, i - 1) % mod_num)
Problem p03038 (python)

Fixed submission:
import bisect

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = []
for i in range(M):
  B,C = map(int,input().split())
  BC.append([B,C])
BC.sort(key = lambda val: val[1], reverse = True)
#print(A)
#print(BC)

ans = 0
j = 0
count = BC[j][0]
for i in range(N):
  #print(ans)
  if A[i] < BC[j][1]:
    ans += BC[j][1]
    count -= 1
    if count == 0:
      j += 1
      if j >= M:
        if i < N-1:
          ans += sum(A[i+1:])
        break
      count = BC[j][0]
  else:
    ans += sum(A[i:])
    break
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = []
for i in range(M):
  B,C = map(int,input().split())
  BC.append([B,C])
BC.sort(key = lambda val: val[1], reverse = True)
#print(A)
#print(BC)

ans = 0
j = 0
count = BC[j][0]
for i in range(N):
  #print(ans)
  if A[i] < BC[j][1]:
    ans += BC[j][1]
    count -= 1
    if count == 0:
      j += 1
      count = BC[j][0]
      if j >= M:
        break
  else:
    break
if i < N:
  ans += sum(A[i:])
print(ans)
Problem p03253 (python)

Fixed submission:
import collections
import math

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

def nCr(n,r):
  #print(n,r)
  return (FAC[n]*INV[n-r]*INV[r])%MOD

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

MOD = 10**9 + 7
FAC = [1]
INV = [1]
N = int(math.log(m,2))+n+1
for i in range(1,N+1):
  FAC.append((FAC[i-1]*i) % MOD)
  INV.append(pow(FAC[-1],MOD-2,MOD))

c = collections.Counter(prime_factorize(m))
#print(c)
ans = 1
for k,v in c.items():
  #print(k,v)
  ans *= nCr(v+n-1,v)
  ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
import collections

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

def nCr(n,r):
  return (FAC[n]*INV[n-r]*INV[r])%MOD

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

MOD = 10**9 + 7
FAC = [1]
INV = [1]
N = 2*n
for i in range(1,N+1):
  FAC.append((FAC[i-1]*i) % MOD)
  INV.append(pow(FAC[-1],MOD-2,MOD))

c = collections.Counter(prime_factorize(m))
#print(c)
ans = 1
for k,v in c.items():
  ans *= nCr(v+n-1,v)
  ans %= MOD
print(ans)
Problem p03634 (python)

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

N = int(input())
E = [set() for _ in range(N)]
C = {}
for i in range(N-1):
  a,b,c = map(int,input().split())
  E[a-1].add(b-1)
  E[b-1].add(a-1)
  C[min(a-1,b-1)*N+max(a-1,b-1)] = c
  
Q,K = map(int,input().split())
K -= 1
#print(E)
#print(C)
#print(K)

Kcost = [0 for _ in range(N)]
def dfs(u,v):
  if v != -1:
    Kcost[u] = Kcost[v] + C[min(u,v)*N+max(u,v)]
  for t in E[u]:
    if t != K and Kcost[t] == 0:
      dfs(t,u)
dfs(K,-1)

for i in range(Q):
  x,y = map(int,input().split())
  print(Kcost[x-1]+Kcost[y-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
E = [set() for _ in range(N)]
C = {}
for i in range(N-1):
  a,b,c = map(int,input().split())
  E[a-1].add(b-1)
  E[b-1].add(a-1)
  C[min(a-1,b-1)*N+max(a-1,b-1)] = c
  
Q,K = map(int,input().split())
K -= 1
Query = []
for i in range(Q):
  x,y = map(int,input().split())
  Query.append([x-1,y-1])
#print(E)
#print(C)
#print(K)
#print(Query)

Kcost = [0 for _ in range(N)]
def dfs(u,v):
  if v != -1:
    Kcost[u] = Kcost[v] + C[min(u,v)*N+max(u,v)]
  for t in E[u]:
    if t != K and Kcost[t] == 0:
      dfs(t,u)
dfs(K,-1)

for x,y in Query:
  print(Kcost[x]+Kcost[y])
Problem p03724 (python)

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

V = {}
v = [0,0]
for v[0],v[1] in AB:
  for i in range(2):
    if v[i] in V:
      V[v[i]] += 1
    else:
      V[v[i]] = 1
for val in V.values():
  if val % 2 == 1:
    print('NO')
    exit()
print('YES')

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

E = [set() for _ in range(N)]
for a,b in AB:
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)

visited = [0] * N
def dfs(u,v,count):
  visited[u] = count
  count += 1
  res = False
  for t in E[u]:
    if t != v:
      #print(t,u,visited[t],count)
      if visited[t] == 1:
        if count == M + 1:
          return True
        else:
          return False
      res |= dfs(t,u,count)
  return res

print('YES' if dfs(AB[0][0],-1,1) else 'NO')
Problem p02754 (python)

Fixed submission:
n,a,b= map(int,input().split())
ans = (n//(a+b))*a
rem = (n%(a+b))
ans += min(rem,a)
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b= map(int,input().split())
ans = (n//(a+b))*a
rem += (n%(a+b))
ans = min(rem,a)
print(ans)
Problem p02777 (python)

Fixed submission:
s,t=input().split()  
a,b= map(int,input().split())
u=input()

if s==u:
    a =a-1
else:
    b =b-1
print(str(a)+" "+str(b))

Buggy submission (verdict: Runtime Error):
s,t=input().split()  
a,b= map(int,input().split())
u=input()

if s==u:
    a -=1
else:
    b -=1
print(str(a)+" "+str(b)
Problem p02831 (python)

Fixed submission:
import fractions 
a,b=map(int, input().split())

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

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int, input().split())

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

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int, input().split())

print(int((a * b)/math.gcd(a,b)))
Problem p02572 (python)

Fixed submission:
import itertools
#h,w=map(int,input().split())
#S=[list(map(int,input().split())) for _ in range(h)]
n=int(input())
A=list(map(int,input().split()))
Ar=list(itertools.accumulate(A))
ans=0
for i in range(n-1):
    ans+=A[i]*(Ar[n-1]-Ar[i])
    ans%=10**9+7
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
Ar=list(itertools.accumulate(A))
ans=0
for i in range(n-1):
    ans+=A[i]*(Ar[n-1]-Ar[i])
    ans%=10**9+7
print(ans)
Problem p03077 (python)

Fixed submission:
import math
n=int(input())
l=[int(input()) for i in range(5)]
print(math.ceil(n/min(l))+4)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
l=[input() for i in range(5)]
print(math.ceil(n/min(l))+4)
Problem p02793 (python)

Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
if n == 1:
	print(1)
else:
	lcm = a[0] * a[1] // gcd(a[0], a[1])
	for x in a[2:]:
		lcm = lcm * x // gcd(lcm, x)
	lcm %= MOD
	ans = 0
	for x in a:
		ans += lcm * pow(x, MOD-2, MOD)
		ans %= MOD
	print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7
if n == 1:
	print(1)
else:
	lcm = a[0] * a[1] // gcd(a[0], a[1])
	for x in a[2:]:
		lcm = lcm * x // gcd(lcm, x)
	print(sum([(lcm//x)%MOD for x in a])%MOD)
Problem p02925 (python)

Fixed submission:
import sys, time
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
a = [list(map(int, input().split()))[::-1] for _ in range(n)]
#print(*a, sep="\n")
opponent = [-1 for _ in range(n)]
match = 0
day = 0
start_time = time.time()
while match < n*(n-1)//2:
	approved = False
	for i in range(n):
		if a[i] != [] and opponent[i] == -1:
			opponent[i] = a[i].pop()-1
	#print(opponent)
	for i in range(n):
		if opponent[i] != -1 and opponent[opponent[i]] == i:
			approved = True
			match += 1
			opponent[opponent[i]] = -1
			opponent[i] = -1
	#print(opponent)
	if not approved:
		print(-1)
		sys.exit()
	now = time.time()
	#print(start_time, now, now - start_time)
	if now-start_time > 1.6:
		print(n*(n-1)//2)
		sys.exit()
	day += 1
print(day)

Buggy submission (verdict: Runtime Error):
import sys, time
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
a = [list(map(int, input().split()))[::-1] for _ in range(n)]
#print(*a, sep="\n")
opponent = [-1 for _ in range(n)]
played = list(range(n))
match = 0
day = 0
while match < n*(n-1)//2:
	approved = False
	for i in played:
		if a[i] != []:
			opponent[i] = a[i].pop()-1
	played = []
	#print(opponent)
	for i in range(n):
		if opponent[i] != -1 and opponent[opponent[i]] == i:
			approved = True
			match += 1
			played.append(i, opponent[i])
			opponent[opponent[i]] = -1
			opponent[i] = -1
	#print(opponent)
	if not approved:
		print(-1)
		sys.exit()
	day += 1
print(day)
Problem p02955 (python)

Fixed submission:
from math import sqrt
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
div = []
for i in range(1, int(sqrt(s)+1)):
	if s%i == 0:
		if i*i != s:
			div.append(s//i)
		div.append(i)
div.sort(reverse=True)
#print(div)

for d in div:
	b = [x%d for x in a if x%d != 0]
	if not b:
		print(d)
		break
	b.sort(key=lambda x: x%d)
	y, z = 0, d*len(b)-sum(b)
	res = 10**30
	for x in b:
		y += x
		z -= d-x
		res = min(res, max(y, z))
	if res <= k:
		print(d)
		break

Buggy submission (verdict: Runtime Error):
from math import sqrt
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
div = []
for i in range(1, int(sqrt(s)+1)):
	if s%i == 0:
		if i*i != s:
			div.append(s//i)
		div.append(i)
div.sort(reverse=True)
#print(div)

for d in div:
	plus, minus = [], []
	for x in a:
		if x%d == 0:
			continue
		plus.append(d-(x%d))
		minus.append(x%d)
	if min(sum(plus)-max(plus), sum(minus)-max(minus)) <= k:
		print(d)
		break
Problem p03127 (python)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
b=a[0]
for x in a[1:]:
  b=gcd(b,x)
print(b)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
print(gcd(a))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n=int(input())
a=list(map,input().split())
print(gcd(a))