Problem p02814 (python)

Fixed submission:
# define
a = [0] * int(1e5 + 100)
# functions
def _gcd(a, b):
    if a % b == 0 : return b
    if b % a == 0 : return a
    while a != 1 and b != 1:
        if a > b: a %= b
        else : b %= a
        if a % b == 0: return b
        if b % a == 0: return a
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(2, n + 1) :
    gcd = _gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > 2 * m):
        flag = True
        break

for i in range (1, n + 1):
    if int(lcm / a[i]) % 2 == 0 : flag = True

if flag : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Buggy submission (verdict: Runtime Error):
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(2, n + 1) :
    gcd = math.gcd(lcm, a[i])
    #lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Buggy submission (verdict: Runtime Error):
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(2, n + 1) :
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break
exit()
for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Buggy submission (verdict: Runtime Error):
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(1, n + 1) :
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break
exit()
for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Buggy submission (verdict: Runtime Error):
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]
for i in range(1, n + 1) : 
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Buggy submission (verdict: Runtime Error):
import math

# define
a = [0] * int(1e5 + 10)
# functions
# main
n, m = (int(s) for s in input().split())

inp = input()
for i in range(1, n + 1) :
    a[i] = int(inp.split()[i - 1])

flag = False
lcm = a[1]
for i in range(1, n + 1) : 
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Buggy submission (verdict: Runtime Error):
import math

# define
a = [0] * int(1e5 + 10)
# functions
# main
n, m = (int(s) for s in input().split())

inp = input()
for i in range(1, n + 1) :
    a[i] = int(inp.split()[i - 1])

lcm = a[1]
for i in range(1, n + 1) : 
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)

flag = False
for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)