Problem p03774 (python)

Fixed submission:
if __name__ == '__main__':
    student_count, checkpoint_count = map(int, input().split())
    student_points = [list(map(int, input().split())) for i in range(1, student_count + 1)]
    check_points = [list(map(int, input().split())) for i in range(1, checkpoint_count + 1)]
 
    for student_point_x, student_point_y in student_points:
        point_number = 0
        shortest_distance = float('inf')
        manhattan_distance = 0
 
        for i in range(len(check_points)):
            diff_x = abs(student_point_x - check_points[i][0])
            diff_y = abs(student_point_y - check_points[i][1])
            manhattan_distance = diff_x + diff_y
 
            if manhattan_distance < shortest_distance:
                shortest_distance = manhattan_distance
                point_number = i + 1
 
        print(point_number)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [[int(a) for a in input().split()] for _ in range(N)]
cd = [[int(a) for a in input().split()] for _ in range(M)]
for i in range(N):
    min_distance = 99999
    for j in range(M):
        manhattan_distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if min_distance > manhattan_distance:
            min_distance = manhattan_distance
            check_point = j
    print(check_point+1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [[int(a) for a in input().split()] for _ in range(N)]
cd = [[int(a) for a in input().split()] for _ in range(M)]
for i in range(N):
    min_distance = 99999
    for j in range(M):
        manhattan_distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if min_distance > manhattan_distance:
            min_distance = manhattan_distance
            check_point = j+1
    print(check_point)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [[int(a) for a in input().split()] for _ in range(N)]
cd = [[int(a) for a in input().split()] for _ in range(M)]
for i in range(N):
    min_distance = 99999
    for j in range(M):
        manhattan_distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if min_distance > manhattan_distance:
            min_distance = manhattan_distance
            check_point = j+1
    print(check_point)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [input().split() for a in range(M)]
cd = [input().split() for a in range(M)]


for y in range(M):
    min_p = 999
    point = 1
    for x in range(M):
        distance = abs(int(ab[y][0]) - int(cd[x][0])) + abs(int(ab[y][1]) - int(cd[x][1]))
        if min_p == distance:
            continue
        elif min_p > distance:
            min_p = distance
            point += 1
    print(point)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ab = [input().split() for a in range(M)]
cd = [input().split() for a in range(M)]


for y in range(M):
    min_p = 999
    for x in range(M):
        distance = abs(int(ab[y][0]) - int(cd[x][0])) + abs(int(ab[y][1]) - int(cd[x][1]))
        if min_p == distance:
            continue
        elif min_p > distance:
            min_p = distance
            point = x + 1
    print(point)