qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,M = map(int,input().split())
sts = [list(map(int, input().split())) for i in range(N)]
checkp = [[i+1]+list(map(int, input().split())) for i in range(M)]
rt = [None] * N
distances = [2*(10**8)] * N
for s in range(N):
  for c in checkp:
    dist = abs(sts[s][0]-c[1]) + abs(sts[s][1]-c[2])
    if rt[s] is None:
      rt[s] = c[0]
      distances[s] = dist
    else:
      if distances[s] > dist:
        rt[s] = c[0]
        distances[s] = dist
print(rt)

Fixed code:
N,M = map(int,input().split())
sts = [list(map(int, input().split())) for i in range(N)]
checkp = [[i+1]+list(map(int, input().split())) for i in range(M)]
rt = [None] * N
distances = [2*(10**8)] * N
for s in range(N):
  for c in checkp:
    dist = abs(sts[s][0]-c[1]) + abs(sts[s][1]-c[2])
    if rt[s] is None:
      rt[s] = c[0]
      distances[s] = dist
    else:
      if distances[s] > dist:
        rt[s] = c[0]
        distances[s] = dist
for i in rt:
  print(i)
Buggy code:
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append(x,y)
for i in range(m):
  x,y=map(int,input().split())
  b.append(x,y)
for i in a:
  ans=10**18
  t=0
  for j in b:
    if abs(i[0]-j[0])+abs(i[1]-j[1])<ans:
      t=j+1
      ans=abs(i[0]-j[0])+abs(i[1]-j[1])
  print(t)

Fixed code:
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append([x,y])
for i in range(m):
  x,y=map(int,input().split())
  b.append([x,y])
for i in a:
  ans=10**18
  t=0
  for j in range(m):
    if abs(i[0]-b[j][0])+abs(i[1]-b[j][1])<ans:
      t=j+1
      ans=abs(i[0]-b[j][0])+abs(i[1]-b[j][1])
  print(t)
Buggy code:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    tmp = float("inf")
    ans = 0
    y = float("inf")
    for j in range(m):
        x = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if x < tmp or x == tmp and abs(i - j) < y:
            tmp = x
            ans = j + 1
            y = abs(i - j)
    print(ans)

Fixed code:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    tmp = float("inf")
    ans = 0
    y = float("inf")
    for j in range(m):
        x = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if x < tmp or x == tmp and i < y:
            tmp = x
            ans = j + 1
            y = i
    print(ans)
Buggy code:
[n,m]=list(map(int,input().split()))
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
cd=[]
for i in range(m):
    cd.append(list(map(int,input().split())))
ans=[]
for i in range(n):
    kyorimin=10**9
    for j in range(m):
        kyori=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if kyorimin>kyori:
            goal=j+1
    ans.append(goal)
for i in range(len(ans)):
    print(ans[i])

Fixed code:
[n,m]=list(map(int,input().split()))
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
cd=[]
for i in range(m):
    cd.append(list(map(int,input().split())))
ans=[]
for i in range(n):
    kyorimin=10**9
    for j in range(m):
        kyori=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if kyorimin>kyori:
            goal=j+1
            kyorimin=kyori
    ans.append(goal)
for i in range(len(ans)):
    print(ans[i])
Buggy code:
n,m = map(int,input().split())
a,b = [[] for i in range(n)],[[] for i in range(n)]
c,d = [[] for i in range(m)],[[] for i in range(m)]
for i in range(n):
    a[i],b[i] = map(int,input().split())
for i in range(m):
    c[i],d[i] = map(int,input().split())

check = [[] for i in range(m)]
for i in range(n):
    for j in range(m):
        check[j] = abs(a[i]-c[j])+abs(b[i]-d[j])
    print(min(check))

Fixed code:
n,m = map(int,input().split())
a,b = [[] for i in range(n)],[[] for i in range(n)]
c,d = [[] for i in range(m)],[[] for i in range(m)]
for i in range(n):
    a[i],b[i] = map(int,input().split())
for i in range(m):
    c[i],d[i] = map(int,input().split())

check = [[] for i in range(m)]
for i in range(n):
    for j in range(m):
        check[j] = abs(a[i]-c[j])+abs(b[i]-d[j])
    print(check.index(min(check))+1)
Buggy code:
n,m=map(int,input().split())

a_lis=[list(map(int,input())) for i in range(n)]
c_lis=[list(map(int,input())) for i in range(m)]

for i in range(n):
  num=0
  ans=10**8
  for j in reversed(range(m)):
    a=a_lis[i]
    c=c_lis[j]
    num=abs(a[0]-c[0])+abs(a[1]-c[1])
    ans=min(ans,num)
    if num==ans:
      cnt=j+1
  print(cnt)
    

Fixed code:
n,m=map(int,input().split())

a_lis=[list(map(int,input().split())) for i in range(n)]
c_lis=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
  num=0
  ans=10**10
  for j in reversed(range(m)):
    a=a_lis[i]
    c=c_lis[j]
    num=abs(a[0]-c[0])+abs(a[1]-c[1])
    ans=min(ans,num)
    if num==ans:
      cnt=j+1
  print(cnt)
Buggy code:
def main():
    n, m = map(int, input().split())
    students = [tuple(map(int, input().split())) for i in range(n)]
    check_points = [tuple(map(int, input().split())) for i in range(m)]

    for a, b in students:
        dist = [abs(a - c) + abs(b - d) for c, d in check_points]
        print(check_points.index(min(dist) + 1))
        
    # for st in students:
    #     min_pt = check_points[0]
    #     for pt in check_points:
    #         if abs(pt[0] - st[0]) + abs(pt[1] - st[1]) < \
    #            abs(min_pt[0] - st[0]) + abs(min_pt[1] - st[1]):
    #             min_pt = pt
    #     print(check_points.index(min_pt) + 1)


if __name__ == "__main__":

    main()


Fixed code:
def main():
    n, m = map(int, input().split())
    students = [tuple(map(int, input().split())) for i in range(n)]
    check_points = [tuple(map(int, input().split())) for i in range(m)]

    for a, b in students:
        dist = [abs(a - c) + abs(b - d) for c, d in check_points]
        print(dist.index(min(dist)) + 1)

    # for st in students:
    #     min_pt = check_points[0]
    #     for pt in check_points:
    #         if abs(pt[0] - st[0]) + abs(pt[1] - st[1]) < \
    #            abs(min_pt[0] - st[0]) + abs(min_pt[1] - st[1]):
    #             min_pt = pt
    #     print(check_points.index(min_pt) + 1)


if __name__ == "__main__":

    main()
Buggy code:
N, M = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(N)]
c = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
    m = 0
    for j in range(M):
        if abs(s[i][0]-c[m][0]) + abs(s[i][1]-c[m][1]) > abs(s[i][0]-c[j][0]) + abs(s[i][1]-c[j][1]):
            m = j
    print(j+1)


Fixed code:
N, M = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(N)]
c = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
    m = 0
    for j in range(M):
        if abs(s[i][0]-c[m][0]) + abs(s[i][1]-c[m][1]) > abs(s[i][0]-c[j][0]) + abs(s[i][1]-c[j][1]):
            m = j
    print(m+1)
Buggy code:
N, M = map(int, input().split())

nodes, checks = [], []
for i in range(N):
    nodes.append(map(int, input().split()))
for j in range(M):
    checks.append(map(int, input().split()))

for i in range(N):
    argMin, distMin = None, float('inf')
    for j in range(M):
        dist = abs(nodes[i][0] - checks[j][0]) + abs(nodes[i][1] - checks[j][1])
        if dist < distMin: argMin, distMin = j, dist
    print(j)

Fixed code:
N, M = map(int, input().split())

nodes, checks = [], []
for i in range(N):
    nodes.append(list(map(int, input().split())))

for j in range(M):
    checks.append(list(map(int, input().split())))

for i in range(N):
    argMin, distMin = None, float('inf')
    for j in range(M):
        dist = abs(nodes[i][0] - checks[j][0]) + abs(nodes[i][1] - checks[j][1])
        if dist < distMin: argMin, distMin = j, dist
    print(argMin + 1)
Buggy code:
# B - Checkpoints
def main():
    n, m = map(int, input().split())
    a_b = [input().split() for i in range(n)]
    c_d = [input().split() for i in range(m)]

    for i in range(m):
        temp = []
        for j in range(n):
            temp.append(abs(int(a_b[j][0])-int(c_d[i][0]))+abs(int(a_b[j][1])-int(c_d[i][1])))
        else:
            print(temp.index(min(temp))+1)


        
if __name__ == '__main__':
    main()

Fixed code:
# B - Checkpoints
def main():
    n, m = map(int, input().split())
    a_b = [input().split() for i in range(n)]
    c_d = [input().split() for i in range(m)]

    for i in range(n):
        temp = []
        for j in range(m):
            temp.append(abs(int(a_b[i][0])-int(c_d[j][0]))+abs(int(a_b[i][1])-int(c_d[j][1])))
        else:
            print(temp.index(min(temp))+1)


        
if __name__ == '__main__':
    main()
Buggy code:
N,M = (int(i) for i in input().split())
a=[]
b=[]
c=[]
d=[]

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

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


closest = N*[0]

for i in range(N):
    minimum = abs(a[i]-c[0])+abs(b[i]-d[0])
    number = 1
    for j in range(1,M):
        distance = abs(a[i]-c[j])+abs(b[i]-d[j])
        if distance < minimum:
            number = j+1
    closest[i] = number

for i in range(N):
    print(closest[i])

Fixed code:
N,M = (int(i) for i in input().split())
a=[]
b=[]
c=[]
d=[]

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

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


closest = N*[0]

for i in range(N):
    minimum = abs(a[i]-c[0])+abs(b[i]-d[0])
    number = 1
    for j in range(1,M):
        distance = abs(a[i]-c[j])+abs(b[i]-d[j])
        if distance < minimum:
            minimum = distance
            number = j+1
    closest[i] = number

for i in range(N):
    print(closest[i])
Buggy code:
N, M = list(map(int, input().split()))
students = list()
checkpoints = list()

for i in range(N):
	students.append(list(map(int, input().split())))

for i in range(M):
	checkpoints.append(list(map(int, input().split())))

ans = [0] * N

for i in range(N):
	mindif = 4 * 10**8 + 1
	for j in range(M):
		dif = abs(students[i][0] - checkpoints[j][0]) + abs(students[i][1] - checkpoints[j][1])
		if dif < mindif:
			mindif = dif
			ans[i] = j

for i in range(M):
	print(ans[i])


Fixed code:
N, M = list(map(int, input().split()))
students = list()
checkpoints = list()

for i in range(N):
	students.append(list(map(int, input().split())))

for i in range(M):
	checkpoints.append(list(map(int, input().split())))

ans = [0] * N

for i in range(N):
	mindif = 4 * 10**8 + 1
	for j in range(M):
		dif = abs(students[i][0] - checkpoints[j][0]) + abs(students[i][1] - checkpoints[j][1])
		if dif < mindif:
			mindif = dif
			ans[i] = j + 1

for i in range(N):
	print(ans[i])
Buggy code:
n,m=map(int,input().split())
st=[]
ch=[]
def mht(ax,ay,bx,by):
  return abs(ax-bx)+abs(ay-by)

for i in range(n):
  st.append(list(map(int,input().split())))
for i in range(m):
  ch.append(list(map(int,input().split())))
  
for i in st:
  ax=i[0]
  ay=i[1]
  mn=100000000
  for (j,k) in zip(ch,len(ch)):
    bx=j[0]
    by=j[1]
    mh=mht(ax,ay,bx,by)
    if mh<mn:
      mn=mh
      nm=k
  print(nm)


Fixed code:
n,m=map(int,input().split())
st=[]
ch=[]
def mht(ax,ay,bx,by):
  return abs(ax-bx)+abs(ay-by)

for i in range(n):
  st.append(list(map(int,input().split())))
for i in range(m):
  ch.append(list(map(int,input().split())))
  
for i in st:
  ax=i[0]
  ay=i[1]
  mn=1000000000
  for (j,k) in zip(ch,range(len(ch))):
    bx=j[0]
    by=j[1]
    mh=mht(ax,ay,bx,by)
    if mh<mn:
      mn=mh
      nm=k
  print(nm+1)
Buggy code:
a = []
b = []
c = []
d = []
n,m = list(map(int,input().split()))
for i in range(n):
    e,f = list(map(int,input().split()))
    a.append(e)
    b.append(f)
for i in range(m):
    e,f = list(map(int,input().split()))
    c.append(e)
    d.append(f)

ans = 50
distance = 0

for i in range(n):
    for j in range(m):
        e = abs(a[i]-c[j])+abs(b[i]-d[j])
        if distance == 0:
            distance = e
            ans = j
        elif distance > e:
            distance = e
            ans = j
    print(ans+1)
    ans = 50
    distance = 0

Fixed code:
a = []
b = []
c = []
d = []
n,m = list(map(int,input().split()))
for i in range(n):
    e,f = list(map(int,input().split()))
    a.append(e)
    b.append(f)
for i in range(m):
    e,f = list(map(int,input().split()))
    c.append(e)
    d.append(f)

ans = 50
distance = 'a'

for i in range(n):
    for j in range(m):
        e = abs(a[i]-c[j])+abs(b[i]-d[j])
        if distance == 'a':
            distance = e
            ans = j
        elif distance > e:
            distance = e
            ans = j
    print(ans+1)
    ans = 50
    distance = 'a'
Buggy code:
n,m=map(int,input().split())
stu=[]
far=[]
for i in range(n):
    a,b=map(int,input().split())
    stu.append([a,b])
for i in range(m):
    c,d=map(int,input().split())
    far=[]
    ans=0
    for j in range(n):
        far.append(abs(stu[j][0]-c)+abs(stu[j][1]-d))
    print(far.index(min(far))+1)

Fixed code:
n,m=map(int,input().split())
stu=[]
far=[]
plc=[]
for i in range(n):
    a,b=map(int,input().split())
    stu.append([a,b])
for i in range(m):
    c,d=map(int,input().split())
    plc.append([c,d])
for i in range(n):
    far=[]
    for j in range(m):
        far.append(abs(stu[i][0]-plc[j][0])+abs(stu[i][1]-plc[j][1]))
    print(far.index(min(far))+1)
Buggy code:
n, m = map(int, input().split())
s = []
d = []
for i in range(n):
    x, y = map(int, input().split())
    s.append([x, y])
for i in range(m):
    x, y = map(int, input().split())
    d.append([x, y])
for i in s:
    a = m
    c = abs(i[0] - x) + abs(i[1] - y)
    for j in range(m):
        c_t = abs(i[0] - d[j][0]) + abs(i[1] - d[j][1])
        if c_t < c:
            c = min(c, c_t)
            a = j
    print(a)

Fixed code:
n, m = map(int, input().split())
s = []
d = []
for i in range(n):
    x, y = map(int, input().split())
    s.append([x, y])
for i in range(m):
    x, y = map(int, input().split())
    d.append([x, y])
for i in s:
    a = 1
    c = abs(i[0] - d[0][0]) + abs(i[1] - d[0][1])
    for j in range(1, m):
        c_t = abs(i[0] - d[j][0]) + abs(i[1] - d[j][1])
        if c_t < c:
            c = min(c, c_t)
            a = j + 1
    print(a)
Buggy code:
n, m = map(int, input().split())
p = [list(map(int, input().split())) for i in range(n + m)]
for a, b in p[:n]:
  x = [abs(a - c) + abs(b - d) for c, d in p[n:]]
print(x.index(min(x)) + 1)

Fixed code:
n, m = map(int, input().split())
p = [list(map(int, input().split())) for i in range(n + m)]
for a, b in p[:n]:
  x = [abs(a - c) + abs(b - d) for c, d in p[n:]]
  print(x.index(min(x)) + 1)
Buggy code:
N, M = map(int, input().split())

a_b = [list(map(int, input().split())) for _ in range(N)]
c_d = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    ans = 0
    a = a_b[i][0]
    b = a_b[i][1]

    c_ans = c_d[ans][0]
    d_ans = c_d[ans][1]

    for j in range(M):
        c = c_d[j][0]
        d = c_d[j][1]
        
        if abs(a-c) + abs(b-d) < abs(a-c_ans) + abs(b-d_ans):
             ans = j
        elif abs(a-c) + abs(b-d) == abs(a-c_ans) + abs(b-d_ans):
            ans = j if j<ans else ans
    print(ans+1)

Fixed code:
N, M = map(int, input().split())

a_b = [list(map(int, input().split())) for _ in range(N)]
c_d = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    ans = 0
    a = a_b[i][0]
    b = a_b[i][1]

    for j in range(M):
        c_ans = c_d[ans][0]
        d_ans = c_d[ans][1]
        c = c_d[j][0]
        d = c_d[j][1]
        
        if abs(a-c) + abs(b-d) < abs(a-c_ans) + abs(b-d_ans):
             ans = j
    print(ans+1)
Buggy code:
n,m=map(int,input().split())
student=[]
man=[]
for i in range(n):
  x,y=map(int,input().split())
  student.append([x,y])
for i in range(m):
  x,y=map(int,input().split())
  man.append([x,y])
for i in student:
  ans=[]
  for j in man:
    ans.append(abs(i[0]-j[0])+abs(i[1]-j[1]))
  print(ans.index(max(ans)))

Fixed code:
n,m=map(int,input().split())
student=[]
man=[]
for i in range(n):
  x,y=map(int,input().split())
  student.append([x,y])
for i in range(m):
  x,y=map(int,input().split())
  man.append([x,y])
for i in student:
  ans=[]
  for j in man:
    ans.append(abs(i[0]-j[0])+abs(i[1]-j[1]))
  print(ans.index(min(ans))+1)
Buggy code:
N,M = map(int,input().split())
student = [list(map(int,input().split())) for _ in range(N)]
cpoint = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
    mannmn = 10**8
    for j in range(M):
        mann = abs(student[i][0] - cpoint[j][0])+abs(student[i][1] - cpoint[j][1])
        if mann <= mannmn:
            mannmn = mann
            ref = j
    print(ref+1)

Fixed code:
N,M = map(int,input().split())
student = [list(map(int,input().split())) for _ in range(N)]
cpoint = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
    mannmn = 10**10
    mann = 10**10
    for j in range(M):
        mann = abs(student[i][0] - cpoint[j][0])+abs(student[i][1] - cpoint[j][1])
        if mann < mannmn:
            mannmn = mann
            ref = j
    print(ref+1)
Buggy code:
n,m=map(int,input().split())
a_b=[list(map(int,input().split()) for _ in range(n)]
c_d=sorted([list(map(int,input().split()) for _ in range(m)])
for i in range(n):
  res=1
  d=abs(a_b[i][0]-c_d[0][0])+abs(a_b[i][1]-c_d[0][1])
  for j in range(m):
    t=abs(a_b[i][0]-c_d[j][0])+abs(a_b[i][1]-c_d[j][1])
    if t<d:
      d=t
      res=j+1
  print(res)
    
  

Fixed code:
n,m=map(int,input().split())
a_b=[list(map(int,input().split())) for _ in range(n)]
c_d=[list(map(int,input().split())) for _ in range(m)]
for i in range(n):
  res=1
  d=abs(a_b[i][0]-c_d[0][0])+abs(a_b[i][1]-c_d[0][1])
  for j in range(1,m):
    t=abs(a_b[i][0]-c_d[j][0])+abs(a_b[i][1]-c_d[j][1])
    if t<d:
      d=t
      res=j+1
  print(res)
Buggy code:
N, M = list(map(int, input().split()))

a = []
c = []
for i in range(0, N + M):
    s = list(map(int, input().split()))
    if  i < N:
        a.append(s)
    else:
        c.append(s)

print (a)
print (c)

for i in range(0, N):
    min_idx = 0
    min_dis = 999999999999
    for j in range(0, M):
        dis = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if min_dis > dis:
            min_dis = dis
            min_idx = j + 1
    print(str(min_idx))

Fixed code:
N, M = list(map(int, input().split()))

a = []
c = []
for i in range(0, N + M):
    s = list(map(int, input().split()))
    if  i < N:
        a.append(s)
    else:
        c.append(s)

for i in range(0, N):
    min_idx = 0
    min_dis = 999999999999
    for j in range(0, M):
        dis = abs(a[i][0] - c[j][0]) + abs(a[i][1] - c[j][1])
        if min_dis > dis:
            min_dis = dis
            min_idx = j + 1
    print(str(min_idx))
Buggy code:
MM = input().split()
N = int(MM[0])
M = int(MM[1])
list1 = []
list2 = []
for i in range(N):
  LL = input().split()
  list1.append(LL)
print(list1)
for i in range(M):
  MM = input().split()
  list2.append(MM)
print(list2)
for i in list1:
  mini = 40**8
  ans = 0
  for j in range(len(list2)):
    x = int(i[0]) - int(list2[j][0])
    y = int(i[1]) - int(list2[j][1])
    xx = abs(x) + abs(y)
    if xx < mini:
      mini = xx
      ans = j+1
  print(ans)
      

Fixed code:
MM = input().split()
N = int(MM[0])
M = int(MM[1])
list1 = []
list2 = []
for i in range(N):
  LL = input().split()
  list1.append(LL)

for i in range(M):
  MM = input().split()
  list2.append(MM)

for i in list1:
  mini = 40**8
  ans = 0
  for j in range(len(list2)):
    x = int(i[0]) - int(list2[j][0])
    y = int(i[1]) - int(list2[j][1])
    xx = abs(x) + abs(y)
    if xx < mini:
      mini = xx
      ans = j+1
  print(ans)
Buggy code:
n, m = map(int, input().split())

student = list()

for x in range(n):
    student.append(list(map(int, input().split())))

checkpoint = list()

for y in range(m):
    checkpoint.append(list(map(int, input().split())))

tmp = 10**8+1

for x in range(n):
    for y in range(m-1, -1, -1):
        distance = abs(student[x][0] - checkpoint[y][0]) + \
            abs(student[x][1] - checkpoint[y][1])
        if tmp >= distance:
            tmp = distance
            ans = y
    print(ans+1)


Fixed code:
n, m = map(int, input().split())

student = list()

for x in range(n):
    student.append(list(map(int, input().split())))

checkpoint = list()

for y in range(m):
    checkpoint.append(list(map(int, input().split())))

INF = 4*(10**8) + 1
tmp = INF
ans = 51

for x in range(n):
    for y in range(m-1, -1, -1):
        distance = abs(student[x][0] - checkpoint[y][0]) + \
            abs(student[x][1] - checkpoint[y][1])

        if tmp >= distance:
            tmp = distance
            ans = y
    print(ans+1)
    tmp = INF
Buggy code:
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) 

Fixed code:
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)
Buggy code:
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(n)]
CD = [[int(i) for i in input().split()] for i in range(m)]

for a, b in AB:
    dist = 10 ** 12
    for i, cd in enumerate(CD):
        tmp = abs(a - cd[0]) + abs(b - cd[1])
        if tmp < dist:
            dist = tmp
            ans = i + 1
            
print(ans)

Fixed code:
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(n)]
CD = [[int(i) for i in input().split()] for i in range(m)]

for a, b in AB:
    dist = 10 ** 12
    for i, cd in enumerate(CD):
        tmp = abs(a - cd[0]) + abs(b - cd[1])
        if tmp < dist:
            dist = tmp
            ans = i + 1
    print(ans)
Buggy code:
n, m = map(int,input().split())
student_list = [list(map(int,input().split())) for _ in range(n)]
print(student_list)
check_list = [list(map(int,input().split())) for _ in range(m)]
print(check_list)
for s in student_list:
    tmp = []
    for c in check_list:
        tmp.append(abs(s[0]-c[0]) + abs(s[1]-c[1]))
    print(tmp.index(min(tmp))+1)

Fixed code:
n, m = map(int,input().split())
student_list = [list(map(int,input().split())) for _ in range(n)]

check_list = [list(map(int,input().split())) for _ in range(m)]

for s in student_list:
    tmp = []
    for c in check_list:
        tmp.append(abs(s[0]-c[0]) + abs(s[1]-c[1]))
    print(tmp.index(min(tmp))+1)
Buggy code:
N, M = map(int, input().split())
ab = []
cd = []
for i in range(N):
  tmp = list(map(int, input().split()))
  ab.append(tmp)
for j in range(M):
  tmp = list(map(int, input().split()))
  cd.append(tmp)
tmp = 2*(10**8)+2
for i in range(N):
  tmp2 = 0
  for j in range(M):
    if tmp > abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
      tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
      tmp2 = j
  print(tmp2+1)

Fixed code:
N, M = map(int, input().split())
ab = []
cd = []
for i in range(N):
  tmp = list(map(int, input().split()))
  ab.append(tmp)
for j in range(M):
  tmp = list(map(int, input().split()))
  cd.append(tmp)
for i in range(N):
  tmp = 10**10
  tmp2 = 0
  for j in range(M):
    if tmp > abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
      tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
      tmp2 = j
  print(tmp2+1)