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):
N, M = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])
print(A)
for i in range(M):
    c, d = map(int, input().split())
    saitei = float("inf")
    for j in range(N):
        if abs(A[j][0]-c) + abs(A[j][1]-d) < saitei:
            saitei = abs(A[i][0]-c) + abs(A[i][1]-d)
            ans = j+1   
        else:
            continue
    print(ans) 

N, M = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

C=[]
for i in range(M):
    c, d = map(int, input().split())
    C.append([c, d])

for i in range(N):
    saitei = float("inf")
    ans = 0
    for j in range(M):
    if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei:
            saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1])
            ans = j+1   
    print(ans) 

N, M = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

C=[]
for i in range(M):
    c, d = map(int, input().split())
    C.append([c, d])

for i in range(N):
    saitei = float("inf")
    ans = 0
    for j in range(M):
    if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei:
            saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1])
            ans = j+1   
        else:
            continue
    print(ans) 

N, M = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

C=[]
for i in range(M):
    c, d = map(int, input().split())
    C.append([c, d])

for i in range(N):
    saitei = float("inf")
    ans = 0
    for j in range(M):
        if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei:
            saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1])
            ans = j+1   
    print(ans) 

N, M = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

B=[]
for i in range(M):
    c, d = map(int, input().split())
    C.append([c, d])

for i in range(N):
    saitei = float("inf")
    ans = 0
    for j in range(M):
        if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei:
            saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1])
            ans = j+1   
    print(ans) 

N, M = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

B=[]
for i in range(M):
    c, d = map(int, input().split())
    B.append([c, d])

for i in range(N):
    saitei = float("inf")
    ans = 0
    for j in range(M):
        if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei:
            saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1])
            ans = j+1   
    print(ans) 

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted