Problem p03231 (python)

Fixed submission:
import fractions


def two_abbreviation(n, m, s, t):
    common = int(fractions.gcd(n, m) + 10 ** -6)
    s_common = [a for i, a in enumerate(zip(s)) if i % int(n / common + 10 ** -6) == 0]
    t_common = [a for i, a in enumerate(zip(t)) if i % int(m / common + 10 ** -6) == 0]
    ret = int(n * m / common + 10 ** -6) if s_common == t_common else -1
    return ret


N, M = [int(a) for a in input().split()]
S = str(input())
T = str(input())

print(str(two_abbreviation(N, M, S, T)))

Buggy submission (verdict: Runtime Error):
import math
def removing_blocks(n, a_list):
    mod = 10 ** 9 + 7
    freq_list = [int(sum([int(math.factorial(n) / (int(abs(i - j) + 10 ** -6) + 1)) % mod for i in range(n)]) + 10 ** -6) % mod for j in range(n)]
    ret = int(sum([int((a * f) % mod) for a, f in zip(a_list, freq_list)]) % mod)
    return ret


N = int(input())
A_list = [int(a) for a in input().split()]
print(str(removing_blocks(N, A_list)))

Buggy submission (verdict: Runtime Error):
def two_abbreviation(n, m, s, t):
    common = int(fractions.gcd(n, m) + 10 ** -6)
    s_common = [a for i, a in enumerate(zip(s)) if i % int(n / common + 10 ** -6) == 0]
    t_common = [a for i, a in enumerate(zip(t)) if i % int(m / common + 10 ** -6) == 0]
    if s_common == t_common:
        ret = int(n * m / common + 10 ** -6)
    else:
        ret = -1
    return ret


N, M = [int(a) for a in input().split()]
S = input()
T = input()

print(str(two_abbreviation(N, M, S, T)))

Buggy submission (verdict: Runtime Error):
import fractions


def two_abbreviation(n, m, s, t):
    common = int(fractions.gcd(n, m) + 10 ** -6)
    s_common = [a for i, a in enumerate(zip(s)) if i % int(n / common + 10 ** -6) == 0]
    t_common = [a for i, a in enumerate(zip(t)) if i % int(m / common + 10 ** -6) == 0]
    if s_common == t_common:
        ret = int(n * m / common + 10 ** -6) 
    else:
        ret = -1
    return ret


N, M = [int(a) for a in input().split()]
S = int(input())
T = int(input())

print(str(two_abbreviation(N, M, S, T)))

Buggy submission (verdict: Runtime Error):
import fractions


def two_abbreviation(n, m, s, t):
    common = int(fractions.gcd(n, m) + 10 ** -6)
    s_common = [a for i, a in enumerate(zip(s)) if i % int(n / common + 10 ** -6) == 0]
    t_common = [a for i, a in enumerate(zip(t)) if i % int(m / common + 10 ** -6) == 0]
    ret = int(n * m / common + 10 ** -6) if s_common == t_common else -1
    print(str(ret))


N, M = [int(a) for a in input().split()]
S = int(input())
T = int(input())
two_abbreviation(N, M, S, T)

Buggy submission (verdict: Runtime Error):
import fractions
def two_avvreviation(n, m, s, t):
    common = int(fractions.gcd(n, m) + 10 ** -6)
    s_common = [a for i, a in enumerate(zip(s)) if i % int(n / common + 10 ** -6) == 0]
    t_common = [a for i, a in enumerate(zip(t)) if i % int(m / common + 10 ** -6) == 0]
    ret = int(n * m / common + 10 ** -6) if s_common == t_common else -1
    return ret


N, M = [int(a) for a in input().split()]
S = int(input())
T = int(input())

print(str(two_avvreviation(N, M, S, T)))

Buggy submission (verdict: Runtime Error):
import fractions
def two_avvreviation(n, m, s, t):
    common = fractions.gcd(n, m)
    s_common = [a for i, a in enumerate(zip(s)) if i % int(n / common + 10 ** -6) == 0]
    t_common = [a for i, a in enumerate(zip(t)) if i % int(m / common + 10 ** -6) == 0]
    ret = int(n * m / common + 10 ** -6) if s_common == t_common else -1
    return ret


N, M = [int(a) for a in input().split()]
S = int(input())
T = int(input())

print(str(two_avvreviation(N, M, S, T)))

Buggy submission (verdict: Runtime Error):
import fraction
def two_avvreviation(n, m, s, t):
    common = fraction.gcd(n, m)
    s_common = [a for i, a in enumerate(zip(s)) if i % int(n / common + 10 ** -6) == 0]
    t_common = [a for i, a in enumerate(zip(t)) if i % int(m / common + 10 ** -6) == 0]
    ret = int(n * m / common + 10 ** -6) if s_common == t_common else -1
    return ret


N, M = [int(a) for a in input().split()]
S = int(input())
T = int(input())

print(str(two_avvreviation(N, M, S, T)))

Buggy submission (verdict: Runtime Error):
import math
def two_avvreviation(n, m, s, t):
    common = math.gcd(n, m)
    s_common = [a for i, a in enumerate(zip(s)) if i % int(n / common + 10 ** -6) == 0]
    t_common = [a for i, a in enumerate(zip(t)) if i % int(m / common + 10 ** -6) == 0]
    ret = int(n * m / common + 10 ** -6) if s_common == t_common else -1
    return ret


N, M = [int(a) for a in input().split()]
S = int(input())
T = int(input())

print(str(two_avvreviation(N, M, S, T)))