Problem: There are N students and M checkpoints on the xy-plane.   The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).   When the teacher gives a signal, each student has to go to the nearest checkpoint measured in _Manhattan distance_.   The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.   Here, |x| denotes the absolute value of x.   If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.   Which checkpoint will each student go to?

Submission attempts (in order):
m,n = map(int,input().split())
student = []
checkpoint = []
for i in range(n):
    student.append(list(map(int,input().split())))
for i in range(m):
    checkpoint.append(list(map(int,input().split())))

for i in range(m):
    ans = 0 
    tmp = 10000000000000
    for j in range(m):
        if tmp < abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1]):
            ans = i
            tmp = abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1])
    print(ans+1)




m,n = map(int,input().split())
student = []
checkpoint = []
for i in range(m):
    student.append(list(map(int,input().split())))
for i in range(n):
    checkpoint.append(list(map(int,input().split())))

for i in range(m):
    ans = 0 
    tmp = 1000000000
    for j in range(n):
        if tmp > abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1]):
            ans = i
            tmp = abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1])
    print(ans+1)



m,n = map(int,input().split())
student = []
checkpoint = []
for i in range(n):
    student.append(list(map(int,input().split())))
for i in range(m):
    checkpoint.append(list(map(int,input().split())))

for i in range(m):
    ans = 0 
    tmp = 10000000000000
    for j in range(n):
        if tmp > abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1]):
            ans = i
            tmp = abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1])
    print(ans+1)


m,n = map(int,input().split())
student = []
checkpoint = []
for i in range(n):
    student.append(list(map(int,input().split())))
for i in range(m):
    checkpoint.append(list(map(int,input().split())))

for i in range(m):
    ans = 0 
    tmp = 10000000000000
    for j in range(m):
        if tmp > abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1]):
            ans = i
            tmp = abs(student[i][0] - checkpoint[i][0]) + abs(student[i][1] - checkpoint[i][1])
    print(ans+1)

n,m = map(int,input().split())
student = []
checkpoint = []
for i in range(n):
    student.append(list(map(int,input().split())))
for i in range(m):
    checkpoint.append(list(map(int,input().split())))

for i in range(n):
    ans = 0 
    tmp = 100000000000 
    for j in range(m):
        if tmp > abs(student[i][0] - checkpoint[j][0]) + abs(student[i][1] - checkpoint[j][1]):
            ans = j
            tmp = abs(student[i][0] - checkpoint[j][0]) + abs(student[i][1] - checkpoint[j][1])
    print(ans+1)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted