Problem p02900 (python)

Fixed submission:
import sys
input = sys.stdin.readline

_a, _b = map(int, input().split())


def gcd(a, b):
    while b:
        a, b = b, a % b

    return a


def get_divisor(a):
    dvlist = []
    for i in range(1, int(a ** 0.5) + 1):
        if a % i == 0:
            dvlist.append(i)
            if i != a // i:
                dvlist.append(a // i)

    return sorted(dvlist)


def chker(a, b):
    a, b = min(a, b), max(a, b)
    mindiv = get_divisor(a)
    shdvlist = [item for item in mindiv if b % item == 0]
    if len(shdvlist) < 3:
        print(len(shdvlist))
        return

    slist, shdvlist = [shdvlist[1]], shdvlist[1:]
    for item1 in shdvlist:
        flg = 0
        for item2 in slist:
            if item1 % item2 == 0:
                flg = 1
                break

        if flg == 0:
            slist.append(item1)

    print(len(slist) + 1)


chker(_a, _b)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

_a, _b = map(int, input().split())


def gcd(a, b):
    while b:
        a, b = b, a % b

    return a


def chker(a, b):
    if gcd(a, b) == 1:
        print(1)
        return

    if min(a, b) == 2:
        print(2)
        return

    klist = [item for item in range(1, int(min(_a, _b) ** (1 / 2)) + 1) if _a % item == 0 and _b % item == 0]
    slist, klist = [klist[1]], klist[1:]
    for item1 in klist:
        tag = 0
        for item2 in slist:
            if item1 % item2 == 0:
                tag = 1
                break

        if tag == 0:
            slist.append(item1)

    print(len(slist) + 1)


chker(_a, _b)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

_a, _b = map(int, input().split())


def gcd(a, b):
    while b:
        a, b = b, a % b

    return a


def chker(a, b):
    if gcd(a, b) == 1:
        print(1)
        return

    klist = [item for item in range(1, int(min(_a, _b) ** (1 / 2)) + 1) if _a % item == 0 and _b % item == 0]
    slist, klist = [klist[1]], klist[1:]
    for item1 in klist:
        tag = 0
        for item2 in slist:
            if item1 % item2 == 0:
                tag = 1
                break

        if tag == 0:
            slist.append(item1)

    print(len(slist) + 1)


chker(_a, _b)

Buggy submission (verdict: Runtime Error):
import sys
# import math
import fractions as math
input = sys.stdin.readline

_a, _b = map(int, input().split())


def chker(a, b):
    if math.gcd(a, b) == 1:
        print(1)
        return

    klist = [item for item in range(1, int(math.sqrt(min(_a, _b))) + 1) if _a % item == 0 and _b % item == 0]
    slist, klist = [klist[1]], klist[1:]
    for item1 in klist:
        tag = 0
        for item2 in slist:
            if item1 % item2 == 0:
                tag = 1
                break

        if tag == 0:
            slist.append(item1)

    print(len(slist) + 1)


chker(_a, _b)

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

_a, _b = map(int, input().split())


def chker(a, b):
    if math.gcd(a, b) == 1:
        print(1)
        return

    klist = [item for item in range(1, int(math.sqrt(min(_a, _b))) + 1) if _a % item == 0 and _b % item == 0]
    slist, klist = [klist[1]], klist[1:]
    for item1 in klist:
        tag = 0
        for item2 in slist:
            if item1 % item2 == 0:
                tag = 1
                break

        if tag == 0:
            slist.append(item1)

    print(len(slist) + 1)


chker(_a, _b)