Problem p03135 (python)

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

Buggy submission (verdict: Runtime Error):
import math

def main():
    data_num, max_num_10 = list(map(int, input().split()))
    data = list(map(int, input().split()))

    max_num_2 = bin(max_num_10)[2:]
    ketasuu = len(max_num_2)
    # keta_count = [0 for i in range(ketasuu)]

    max_ketasuu = ketasuu
    for point_10 in data:
        point_2 = bin(point_10)[2:]
        # print(point_2)
        if max_ketasuu < len(point_2):
            max_ketasuu = len(point_2)

    keta_count = [0 for i in range(max_ketasuu)]

    for point_10 in data:
        point_2 = bin(point_10)[2:][::-1]
        # print(point_2)
        for i in range(len(point_2)):
            if point_2[i] == '1':
                    keta_count[i] += 1
        # print(keta_count)

    ans = ''
    for i in range(ketasuu):
        if keta_count[i] >= math.ceil(data_num / 2):
            ans += '0'
        else:
            ans += '1'
    ans = ans[::-1]


    if max_num_10 < int(ans, 2):
        for i in range(ketasuu):
            if ans[i] == '1':
                # print(ans)
                ans = list(ans)
                # print(ans)
                ans[i] = '0'
                # print(ans)
                ans = ''.join(ans)
                # print(ans)
                break

    ans = ans[::-1]

    ans_count = 0
    now_point = 1

    for i in range(max_ketasuu):
        if i >= ketasuu:
            count_number = keta_count[i]
        else:
            if ans[i] == '1':
                count_number = data_num - keta_count[i]
            else:
                count_number = keta_count[i]
            # print(ans_count, now_point, count_number)
        ans_count += now_point * count_number
        now_point *= 2

    print(ans_count)



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    data_num, max_num_10 = list(map(int, input().split()))
    data = list(map(int, input().split()))

    max_num_2 = bin(max_num_10)[2:]
    ketasuu = len(max_num_2)

    max_ketasuu = ketasuu
    for point_10 in data:
        point_2 = bin(point_10)[2:]
        if max_ketasuu < len(point_2):
            max_ketasuu = len(point_2)

    keta_count = [0 for i in range(max_ketasuu)]

    for point_10 in data:
        point_2 = bin(point_10)[2:][::-1]
        # print(point_2)
        for i in range(len(point_2)):
            if point_2[i] == '1':
                    keta_count[i] += 1
        # print(keta_count)

    ans = ''
    for i in range(ketasuu):
        if keta_count[i] >= math.ceil(data_num / 2):
            ans += '0'
        else:
            ans += '1'
    ans = ans[::-1]

    # asn = '1100'
    # max_num_2 = '1001'
    # ketasuu = 4


    if max_num_10 < int(ans, 2):
        # print('yyy')
        count = 1
        for i in range(ketasuu)[::-1]:
            if ans[i] == '1' and max_num_2[i] == '0':
                # print('uyt', count)
                if max_num_10 >= int(ans, 2) - count:
                    # print('uuuuu')
                    # print(ans)
                    ans = list(ans)
                    # print(ans)
                    ans[i] = '0'
                    # print(ans)
                    ans = ''.join(ans)
                    # print(ans)
                    break
        if max_num_10 < int(ans, 2)
            ans = list(ans)
            # print(ans)
            ans[0] = '0'
            # print(ans)
            ans = ''.join(ans)
            # count *= 2

    ans = ans[::-1]

    ans_count = 0
    now_point = 1

    for i in range(max_ketasuu):
        if i >= ketasuu:
            count_number = keta_count[i]
        else:
            if ans[i] == '1':
                count_number = data_num - keta_count[i]
            else:
                count_number = keta_count[i]
            # print(ans_count, now_point, count_number)
        ans_count += now_point * count_number
        now_point *= 2

    print(ans_count)

def test():
    ans = '1110'
    max_num_2 = '1011'
    ketasuu = 4
    max_num_10 = 11

    if max_num_10 < int(ans, 2):
        # print('yyy')
        count = 1
        for i in range(ketasuu)[::-1]:
            if ans[i] == '1' and max_num_2[i] == '0':
                print('uyt', count)
                if max_num_10 >= int(ans, 2) - count:
                    print('uuuuu')
                    # print(ans)
                    ans = list(ans)
                    # print(ans)
                    ans[i] = '0'
                    # print(ans)
                    ans = ''.join(ans)
                    # print(ans)
                    break
            count *= 2

    # ans = ans[::-1]
    print(ans)

if __name__ == '__main__':
    main()
    # test()