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

Fixed submission:
n,a,b = map(int,input().split())
print(max(0,(n - 2) * (b - a) + 1))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if a > b:
    print(0)
elif a == b:
    print(1)
else:
    print((n - 2) * (b - a) + 1))

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if a > b:
    print(0)
elif a == b:
    print(1)
else:
    pritn((n - 2) * (b - a) + 1)
Problem p03723 (python)

Fixed submission:
a,b,c = map(int,input().split())
if a == b and b == c:
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
        print(-1)
    else:
        print(0)
else:
    ans = 0
    while True:
        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            ans += 1
            A = b / 2 + c / 2
            B = c / 2 + a / 2
            C = a / 2 + b / 2
            a = A
            b = B
            c = C
        else:
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if a == b and b == c:
    print(-1)
else:
    ans = 0
    while True:
        if a % 2 == 0 and b % 2 -= 0 and c % 2 == 0:
            ans += 1
            A = b / 2 + c / 2
            B = c / 2 + a / 2
            C = a / 2 + b / 2
            a = A
            b = B
            c = C
        else:
            break
    print(ans)
Problem p03745 (python)

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

ans = 1
status = 0
prev = a[0]

for i in a:
    diff = i - prev

    if diff == 0:
        pass
    elif diff > 0:
        if status >= 0:
            status = diff
        else:
            ans += 1
            status = 0
    else:
        if status <= 0:
            status = diff
        else:
            ans += 1
            status = 0

    prev = i

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if a[-1] >= a[-2]:
    a.append(float('inf'))
else:
    a.append(-float('inf'))
ans = 1
i = 0
while i < n-1:
    if a[i] < a[i+1] > a[i+2]:
        ans += 1
        i += 2
    elif a[i] > a[i+1] < a[i+2]:
        ans += 1
        i += 2
    else:
        i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
if l[-1] > l[-2]:
    l += [float('Inf')]
else:
    l += [-float('Inf')]
ans = 1
i = 1
while i <= n - 1:
    if l[i-1] <= l[i] and l[i] <= l[i+1]:
        i += 1
    elif l[i-1] >= l[i] and l[i] >= l[i+1]:
        i += 1
    else:
        #print(l[i-1],l[i],l[i+1])
        ans += 1
        i += 2
        
print(ans)
Problem p03805 (python)

Fixed submission:
def dfs(v,been):
    if len(been) == n:
        ans.append(1)
        #print(been)
        return
    for i in graph[v]:
        if i in been:
            pass
        else:
            been.add(i)
            dfs(i,been)
            been.remove(i)
    return

n,m = map(int,input().split())
graph = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
#print(graph)

ans = []

dfs(1,set([1]))
print(sum(ans))

Buggy submission (verdict: Runtime Error):
def dfs(v,been):
    if len(been) == n:
        ans.append(1)
        #print(been)
        return
    for i in graph[v]:
        if i in been:
            pass
        else:
            been.add(i)
            dfs(i,been)
            been.remove(i)
    return

n,m = map(int,input().split())
graph = [[] for _ in range(m+1)]
for _ in range(m):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)
#print(graph)

ans = []

dfs(1,set([1]))
print(sum(ans))
Problem p03834 (python)

Fixed submission:
S = str(input())
print(S[:5]+" "+S[6:13]+" "+S[14:])

Buggy submission (verdict: Runtime Error):
K,S = map(int,input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i+j+k == S:
                count += 1
print(count)
Problem p02570 (python)

Fixed submission:
d, s, t = [int(i) for i in input().split()]
if s * t >= d:
  	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
d, s, t = [int(i) for i in input().split()]
if s * t >= d:
  	print("Yes")
else
	print("No")
Problem p02577 (python)

Fixed submission:
num = input()
total = 0
for char in num:
    total = (total + int(char)) % 9
if total == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
total = 0
for char in n:
	total = (total + int(char)) % 9
if !total:
	print("Yes")
else:
  	print("No")
Problem p02793 (python)

Fixed submission:
import fractions
from functools import reduce

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


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


n = int(input())
l = [int(_) for _ in input().split()]
x = lcm_list(l)
ans = 0
for i in range(n):
    ans += x // l[i]
ans %= (10**9 + 7)
print(ans)

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


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


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


n = int(sys.stdin.readline())
l = [int(_) for _ in sys.stdin.readline().split()]
x = lcm_list(l)
ans = 0
for i in range(n):
    ans += x // l[i]
    ans %= (10**9 + 7)
print(ans)

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

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

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

def lcm_list(numbers):
    a = lcm(numbers[0], numbers[1])
    for i in range(2, len(numbers)):
        b = numbers[i]
        a = lcm(a, b)
    return a

n = int(input())
l = [int(_) for _ in input().split()]
x = lcm_list(l)
ans = 0
for i in range(n):
    ans += x // l[i]
    ans %= (10**9 + 7)
print(ans)
Problem p02815 (python)

Fixed submission:
import sys


n = int(input())
c = sorted([int(_) for _ in input().split()], reverse=True)
mod = 10**9+7
ans = 0
if n == 1:
    ans += c[0] * 2
    ans %= mod
    print(ans)
    sys.exit()
for i in range(n):
    ans += (c[i] * (pow(2, n-1, mod) + pow(2, n-2, mod) * i)) % mod
    ans %= mod
ans *= pow(2, n, mod)
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
c = sorted([int(_) for _ in input().split()], reverse=True)
ans = 0
mod = 10**9+7
for i in range(n):
    ans += (c[i] * (pow(2, n-1, mod) + pow(2, n-2, mod) * i)) % mod
    ans %= mod
ans *= pow(2, n, mod)
ans %= mod
print(ans)
Problem p02984 (python)

Fixed submission:
n = int(input())
a = [2*int(_) for _ in input().split()]
t = a[-1]
x = [0 for _ in range(n)]
for i in range(-2, -n-1, -1):
    t = a[i] - t
x[0] = t // 2
for i in range(0, n-1):
    x[i+1] = a[i] - x[i]
for i in range(len(x)):
    print(x[i])

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


n = int(input())
a = [2*int(_) for _ in input().split()]
s = []
for i in range(n):
    l = [0 for _ in range(n)]
    l[i] = 1
    if i+1 != n:
        l[i+1] = 1
    else:
        l[0] = 1
    s.append(l)
A = np.array(s)
b = np.array(a)
Ainv = np.linalg.inv(A)
x = np.dot(Ainv, b)
for i in range(len(x)):
    print(int(x[i]))
Problem p03232 (python)

Fixed submission:
n = int(input())
a_i = [int(_) for _ in input().split()]

mod = 1000000007
fact = 1
for i in range(n):
    fact = (fact * (i + 1)) % mod

s = [0] * n
s[0] = 1 * fact
for i in range(n-1):
    s[i+1] = (s[i] + (fact * pow(i+2, mod-2, mod)) % mod) % mod

ans = 0
for j in range(n):
    p = (s[j] + s[n-j-1] - fact) % mod
    ans += (p * a_i[j]) % mod
    ans = ans % mod

print(ans)

Buggy submission (verdict: Runtime Error):
import math


n = int(input())
a_i = [int(_) for _ in input().split()]

s = [0] * n
s[0] = 1
for i in range(n-1):
    s[i+1] += s[i] + 1.0 / (i+2)

ans = 0
m = 10**9 + 7
f = math.factorial(n)
for j in range(n):
    p = s[j] + s[n-j-1] - 1
    ans = (ans + p * f * a_i[j]) % m

print(round(ans))
Problem p03291 (python)

Fixed submission:
s = input()

dp = [[0 for _ in range(4)] for _ in range(len(s) + 1)]
dp[len(s)][3] = 1
n = 10 ** 9 + 7

for i in reversed(range((len(s)))):
    m = 1
    m1 = 1
    m2 = 0
    m3 = 0
    m4 = 0
    if s[i] == '?':
        m = 3
        m1 = 3
        m2 = 1
        m3 = 1
        m4 = 1

    if s[i] == 'C':
        m2 = 1

    if s[i] == 'B':
        m3 = 1

    if s[i] == 'A':
        m4 = 1

    dp[i][3] = (m * dp[i+1][3]) % n
    dp[i][2] = (m1 * dp[i+1][2] + m2 * dp[i+1][3]) % n
    dp[i][1] = (m1 * dp[i+1][1] + m3 * dp[i+1][2]) % n
    dp[i][0] = (m1 * dp[i+1][0] + m4 * dp[i+1][1]) % n

ans = dp[0][0]
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()

dp3 = 1
dp2 = 0
dp1 = 0
dp0 = 0

for i in reversed(range((len(s)))):
    m = 1
    m1 = 1
    m2 = 0
    m3 = 0
    m4 = 0
    if s[i] == '?':
        m = 3
        m1 = 3
        m2 = 1
        m3 = 1
        m4 = 1

    if s[i] == 'C':
        m2 = 1

    if s[i] == 'B':
        m3 = 1

    if ss[i] == 'A':
        m4 = 1

    t_dp3 = m * dp3
    t_dp2 = m1 * dp2 + m2 * dp3
    t_dp1 = m1 * dp1 + m3 * dp2
    t_dp0 = m1 * dp0 + m4 * dp1
    dp3 = t_dp3
    dp2 = t_dp2
    dp1 = t_dp1
    dp0 = t_dp0

n = 10 ** 9 + 7
ans = dp0 % n
print(ans)
Problem p03054 (python)

Fixed submission:
from sys import exit
from collections import defaultdict
H,W,N = [int(n) for n in input().split()]
Sr,Sc = [int(n) for n in input().split()]
#上に
Dout = H-Sr + 1
#下に
Uout = Sr
#右に落とすのに必要な歩数
Rout = W - Sc + 1
#左に
Lout = Sc
# print(Uout, Dout,Rout, Lout)
S = str(input())
T = str(input())
ptrC = defaultdict(int)
ptrA = defaultdict(int)
for s,t in zip(S,T):
    ptrC[s]+=1
    ptrA[t]+=1
# print(ptrC,ptrA)
# if ptrC["R"] - ptrA["L"] >= Rout or ptrC["L"] - ptrA["R"] >= Lout or ptrC["D"] - ptrA["U"] >= Dout or ptrC["U"] - ptrA["D"] >= Uout:
#     print("NO")
#     exit()
def check(outcnt, C, A, lim, B):
    backed = 0
    for s,t in zip(S,T):
        if s == B and outcnt == lim -1 and backed > 0:
            outcnt -= 1
            backed -= 1
        if( s == C ):
            outcnt -= 1
        if( outcnt == 0 ):
            print("NO")
            exit()
        if( t == A and outcnt < lim ):
            outcnt += 1
            backed += 1

check(Rout, "R", "L", W, "L")
check(Lout, "L", "R", W, "R")
check(Uout, "U", "D", H, "D")
check(Dout, "D", "U", H, "U")
print("YES")

Buggy submission (verdict: Runtime Error):
from sys import exit
from collections import defaultdict
import itertools
H,W,N = [int(n) for n in input().split()]
Sr,Sc = [int(n) for n in input().split()]
#上に
Uout = H-Sr + 1
#下に
Dout = Sr
#右に落とすのに必要な歩数
Rout = W - Sc + 1
#左に
Lout = Sc
S = str(input())
T = str(input())

def check(outcnt, C, A, lim, B):
    re = False
    for s,t in zip(S,T):
        if s == B and outcnt == lim -1:
            re = True
            break
        if( s == C):
            outcnt -= 1
        if(outcnt == 0 ):
            print("NO")
            exit()
        if(t == A and outcnt < lim):
            outcnt += 1
    if(re):
        check(outcnt, C, A, lim-1, B)
check(Rout, "R", "L", W, "L")
check(Lout, "L", "R", W, "R")
check(Uout, "U", "D", H, "D")
check(Dout, "D", "U", H, "U")
print("YES")
Problem p03222 (python)

Fixed submission:


H,W,K = [int(n) for n in input().split()]
memo = [[0 for _ in range(W)] for __ in range(H+1)]
memo[0][0] = 1
MOD = 10**9 + 7
for h in range(1,H+1):
    for pt in range((1 << W-1)):#1 == 線あり 0 == 線なし　とする
        # pts = bin(pt)[2:]
        # pts = pts[::-1]#反転
        if "11" in bin(pt): continue
        #各パターンの時の各線の計算
        goto = [i for i in range(W)]
        for i in range(W):
            if (1 << i) & pt:
                goto[i], goto[i + 1] = goto[i + 1], goto[i]
        for i in range(W):
            memo[h][goto[i]] += memo[h-1][i]
            memo[h][goto[i]] %= MOD


print(memo[H][K-1])

Buggy submission (verdict: Runtime Error):
from sys import exit
H,W,K = [int(n) for n in input().split()]
memo = [[0 for _ in range(H+1)] for __ in range(W)]
memo[0][0] = 1
for h in range(1,H+1):
    for pt in range((1 << W-1)):#1 == 線あり 0 == 線なし　とする
        pts = bin(pt)[2:]
        pts = pts[::-1]#反転
        if "11" in pts: continue
        # print(pts)
        #各パターンの時の各線の計算
        for i in range(W):
            if i < len(pts) and pts[i] == "1":
                # print(i)
                memo[i][h] += memo[i+1][h-1]
                memo[i+1][h] += memo[i][h-1]
                i+=1#よみとばす
            else:
                memo[i][h] += memo[i][h-1]
        for wt in range(0,W):
            # print(memo[wt])
print(memo[K-1][H])
    # for wt in range(0,W):
    #     print(memo[wt])
        # for i in range(0,N):
        #     if(bit & (1 << i)):#1が一本たっていて、iだけ横にシフトするものとマスクとの共通部分
        #         print(i)
            # print("BIT:", end="")
            # print(bin(1 << i))
exit()
Problem p02699 (python)

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

if S>W:
    print('safe')
else:
    print('unsafe')

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

if len(S)<=200000:
    for i in range(len(S)-4):
        for j in range(i+5, len(S)+1):
            tmp = int(S[i:j])
            if tmp%2019==0:
                count += 1

print(count)

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

for i in range(len(S)-3):
    for j in range(i+3, len(S)+1):
        tmp = int(S[i:j])
        if tmp%2019==0:
            print(i, j)
            count += 1

print(count)
Problem p02862 (python)

Fixed submission:
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

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

n = int(((x + y) / 3))
r = min(x, y) - n

if (min(x, y)<n)or((x + y)%3!=0):   
    print(0)
else:
    a = cmb(n, r)%(10**9 + 7)
    print(int(a))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
x, y = map(int, input().split())

n = ((x + y) / 3)
r = min(x, y) - n

a = comb(n, r, exact=True)
print(a)
Problem p02879 (python)

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

if a>9 or b>9:
    print("-1")
else:
    print(a * b)

Buggy submission (verdict: Runtime Error):
n = int(input())
min = n+1
kaisu = int((n/4)-1)

for i in range(kaisu):
    if n%(i+1)==0:
        tmp = i+(n/(i+1))-1
        if min > tmp:
            min = tmp
    if (i+1)**2>n:
        break

print(int(min))
Problem p02881 (python)

Fixed submission:
n = int(input())
min = n+1
kaisu = int(n-1)

for i in range(kaisu):
    if n%(i+1)==0:
        tmp = i+(n/(i+1))-1
        if min > tmp:
            min = tmp
    if (i+1)**2>n:
        break

print(int(min))

Buggy submission (verdict: Runtime Error):
n = int(input())
min = n+1
kaisu = int(n-1)
if 
for i in range(kaisu):
    if n%(i+1)==0:
        tmp = i+(n/(i+1))-1
        if min > tmp:
            min = tmp
    if (i+1)**2>n:
        break

print(int(min))
Problem p02547 (python)

Fixed submission:
n = int(input())
count = 0
t = 1
for _ in range(n):
  a, b = map(int,input().split())
  if a==b:
    count += 1
  if a!=b:
    count = 0
  if count == 3:
    t = 0
if t:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
t = 1
for _ in range(n):
  x = list(map(int,input().split())
  l.append(x)
count = 0
for i, j in l:
  if i == j:
    count += 1
  if i!=j:
    count = 0
  if count == 3:
  	t = 0
    print("Yes")
    break
if t:
  print("No")
Problem p02572 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
x = [*l]
ans = 0
mod = 1000000007
for i in range(1,n):
  l[i] += l[i-1]
i = 0
while i<n-1:
  ans += (x[i])*(l[n-1] - l[i])
  i += 1
print(ans%mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(1,n):
  l[i] += l[i-1]
i = 0
while i<n-1:
  ans += l[i]*(l[n] - l[i])
  i += 1
print(ans)
Problem p02580 (python)

Fixed submission:
x, y, m = map(int,input().split())
mat = set()
r = [0]*x
c = [0]*y
smx = 0
smy = 0
for _ in range(m):
    p, q = map(int,input().split())
    p -= 1
    q -= 1
    mat.add((p,q))
    r[p] += 1
    c[q] += 1
    smx = max(smx,r[p])
    smy = max(smy,c[q])
xs = []
ys = []
for i in range(x):
    if smx == r[i]: xs.append(i)
for i in range(y):
    if smy == c[i]: ys.append(i)

ans = smx + smy - 1

for h in xs:
    for w in ys:
        if (h, w) in mat: continue
        print(ans + 1)
        exit()
print(ans)

Buggy submission (verdict: Runtime Error):
x, y, m = map(int,input().split())
mat = []
r = [0]*x
c = [0]*y
smx = 0
smy = 0
for _ in range(m):
    p, q = map(int,input().split())
    p -= 1
    q -= 1
    mat.append((p,q))
    r[p] += 1
    c[q] += 1
    smx = max(smx,r[p])
    smy = max(smy,c[q])
xs = []
ys = []
for i in range(x):
    if smx == r[i]: xs.append(i)
for i in range(y):
    if smy == c[i]: ys.append(i)

ans = smx + smy - 1

for h in xs:
    for w in ys:
        if (h, w) in mat: continue
        print(ans + 1)
        end()
print(ans)
Problem p02729 (python)

Fixed submission:
from scipy.misc import comb
n, m = [int(x) for x in input().split()]



print(int(comb(n, 2, exact=True) + comb(m, 2, exact=True)))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n, m = [int(x) for x in input().split()]



print(int(comb(n, 2, exact=True) + comb(m, 2, exact=True)))
Problem p02831 (python)

Fixed submission:
a, b = [int(x) for x in input().split()]
# a = [int(input()) for _ in range(m)]
# a = [int(x) for x in input().split()]

from fractions import gcd



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

Buggy submission (verdict: Runtime Error):
a, b = [int(x) for x in input().split()]
# a = [int(input()) for _ in range(m)]
# a = [int(x) for x in input().split()]

import math


print((a*b)//(math.gcd(a, b)))

Buggy submission (verdict: Runtime Error):
a, b = [int(x) for x in input().split()]
# a = [int(input()) for _ in range(m)]
# a = [int(x) for x in input().split()]

import math


print((a*b)//math.gcd(a, b))

Buggy submission (verdict: Runtime Error):
a, b =[int(x) for x in input().split()]
 
import numpy as np
n=a*b
A = np.array(a)
B = np.array(b)
if np.gcd(A, B) == 1:
  print(n)
else:
  for i in range(1, n+1):
      if i % a == 0 and i % b == 0 :
          print(i)
          break

Buggy submission (verdict: Runtime Error):
a, b =[int(x) for x in input().split()]
 
import numpy as np
n=a*b
A = np.array(a)
B = np.array(b)
if np.gcd(A, B) == 1:
  print(n)
elif a > b:
  for i in range(a, n+1):
    if i % a == 0 and i % b == 0 :
      print(i)
      break
else:
  for i in range(b, n+1):
    if i % a == 0 and i % b == 0 :
      print(i)
      break

Buggy submission (verdict: Runtime Error):
a, b =[int(x) for x in input().split()]
 
import numpy as np
n=a*b
A = np.array(a)
B = np.array(b)
if np.gcd(A, B) == 1:
  print(n)

elif a > b :
  for i in range(a, n+1):
    if (i % a == 0)and(i % b == 0):
      print(i)
      break

else:
  for i in range(b, n+1):
    if (i % a == 0)and(i % b == 0):
      print(i)
      break

Buggy submission (verdict: Runtime Error):
a, b =[int(x) for x in input().split()]

import numpy as np
import sys
n=a*b

A = np.array(a)
B = np.array(b)
if np.gcd(A, B) == 1:
  print(n)
  sys.exit()

elif a > b:
  for i in range(a, n+1):
    if (i % a == 0)and(i % b == 0):
      print(i)
      sys.exit()
else:
  for i in range(b, n+1):
    if (i % a == 0)and(i % b == 0):
      print(i)
      sys.exit()

Buggy submission (verdict: Runtime Error):
a, b =[int(x) for x in input().split()]

import numpy as np

n=a*b

A = np.array(a)
B = np.array(b)
if np.gcd(A, B) == 1:
  print(n)

elif a > b:
  for i in range(a, n+1):
    if (i%a == 0)and(i%b == 0):
      print(i)
      quit()
else:
  for i in range(b, n+1):
    if (i%a == 0)and(i%b == 0):
      print(i)
      quit()

Buggy submission (verdict: Runtime Error):
a, b =[int(x) for x in input().split()]
import numpy as np
n=a*b
A = np.array(a)
B = np.array(b)
if np.gcd(A, B) == 1:
  print(n)

elif a > b:
  for i in range(a, n+1):
    if (i%a == 0)and(i%b == 0):
      print(i)
      break
else:
  for i in range(b, n+1):
    if (i%a == 0)and(i%b == 0):
      print(i)
      break

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

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

n=a*b
A = np.array(a)
B = np.array(b)
if np.gcd(A, B) == 1:
  print(n)

elif a > b:
  for i in range(a, n+1):
    if (i%a == 0)and(i%b == 0):
      print(i)
      break
else:
  for i in range(b, n+1):
    if (i%a == 0)and(i%b == 0):
      print(i)
      break
Problem p02897 (python)

Fixed submission:
n = int(input())
 
if n == 1:
  print(1)
 
elif n == 2:
  print(0.5)
  
elif n%2 == 0:
  print(0.5)
  
else:
  print((n+1)/2/n)

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

if n == 1:
  print(1)

elif n == 2:
  print(0.5)
  
elif n%2 == 0:
  print(0.5)
  
else:
  print((n+1)/2n)
Problem p02831 (python)

Fixed submission:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect
import itertools
import heapq


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(input):
    nums = string_to_int(input)

    def euclid(large, small):
        if small == 0:
            return large
        l = large % small
        return euclid(small, l)

    nums.sort(reverse=True)
    eee = euclid(nums[0], nums[1])
    return int((nums[0] * nums[1]) / eee)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(input())
    print(ret)

Buggy submission (verdict: Runtime Error):
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect
import itertools
import heapq


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(input):
    [A, B] = string_to_int(input)
    return A*B


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)