Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03776 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10000)


def memoize(f):
    cache = {}

    def func(*args):
        if args not in cache:
            cache[args] = f(*args)
        return cache[args]

    return func


@memoize



def combi(n, r):
  if r == 0 or n == r:
    return 1
  return combi(n-1, r-1) + combi(n-1, r)

n, a, b = map(int, input().split())
items = sorted(map(int, input().split()), reverse=True)
max_ave_list = items[:a]
print(sum(max_ave_list)/len(max_ave_list))

m = max_ave_list.count(max_ave_list[-1])
l = items.count(max_ave_list[-1])
if l == m:
  print(1)
elif max_ave_list[0] != max_ave_list[-1]:
  print(combi(l, m))
else:
  print(sum(combi(l, k) for k in range(m, min(b, l) + 1)))

Buggy submission (verdict: Runtime Error):
def combi(n, r):
  if r == 0 or n == r:
    return 1
  return combi(n-1, r-1) + combi(n-1, r)

n, a, b = map(int, input().split())
items = sorted(map(int, input().split()), reverse=True)
max_ave_list = imtes[:a]
print(sum(max_ave_list)/len(max_ave_list))

m = max_ave_list.count(max_ave_list[-1])
l = items.count(max_ave_list[-1])
if l == m:
  print(1)
elif max_ave_list[0] != max_ave_list[-1]:
  print(combi(l, m))
else:
  print(sum(combi(l, k) for k in range(m, min(b, l) + 1)))

Buggy submission (verdict: Runtime Error):

def f1(i):
  if(i == 1):
    return 1
  return i*f1(i-1)

def f2(a, b):
  print(a, b)
  return f1(a)/(f1(b)*f1(a-b))
a = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]

sorted_v = sorted(v)

b = []
c = {}

sum = 0
count = 0
for i in range(a[1]):
  b.append(sorted_v[a[0] - i -1])
  if(not sorted_v[a[0] - i -1] in c):
    c[sorted_v[a[0] - i -1]] = 1
  else:
    c[sorted_v[a[0] - i -1]] += 1
  sum += sorted_v[a[0] - i -1]
  count += 1

pattern = 1
memory = count

max = max(b)

if(max == sorted_v[a[0] - memory -1] and count == c[sorted_v[a[0] - memory -1]] ):
   tmp = c[max]
   while(max == sorted_v[a[0] - memory -1]):
     c[max] += 1
     memory += 1
     if(a[0] - memory -1 == -1):
        break
   if(c[max] > a[2]):
      pattern = 0
      pattern = f2(c[max], a[2])
   else:
      pattern = 1
   for i in range(a[1], min(c[max], a[2])):
     pattern += f2(c[max], i)


else:
    if(sorted_v[a[0] - memory -1] == b[-1]):
      e = c[sorted_v[a[0] - memory -1]]
      while(sorted_v[a[0] - memory -1] == b[-1]):
        c[sorted_v[a[0] - memory -1]] += 1
        memory += 1
        if(a[0] - memory -1 == -1):
          memory -= 1
          break
      pattern = f2(c[sorted_v[a[0] - memory -1]], e)
    else:
      pattern = 1


print("{0:.7f}".format(sum/count))
print(pattern)
Problem p03768 (python)

Fixed submission:
n, m = map(int, input().split())
node = [[] for _ in range(n + 1)]
for i in range(m):
    a, b = map(int, input().split())
    node[a].append(b)
    node[b].append(a)

q = int(input())
node_color = [0 for _ in range(n + 1)]
vdc = [list(map(int, input().split())) for _ in range(q)]

vdc = vdc[::-1]
painted = set()
visited = [[0] * 11 for _ in range(n + 1)]


def dfs(now, dist, color):
    if dist < 0:
        return
    if visited[now][dist]:
        return

    visited[now][dist] += 1
    if not node_color[now]:
        node_color[now] = color

    for x in node[now]:
        dfs(x, dist - 1, color)


for i in vdc:
    v, d, c = i
    dfs(v, d, c)

for m in range(n):
    print(node_color[m + 1])

Buggy submission (verdict: Runtime Error):
q = int(input())
node_color = [0 for _ in range(n + 1)]
vdc = [list(map(int, input().split())) for _ in range(q)]

vdc = vdc[::-1]
painted = set()
visited = [[0] * 11 for _ in range(n + 1)]


def dfs(now, dist, color):
    if dist < 0:
        return
    if visited[now][dist]:
        return

    visited[now][dist] += 1
    if not node_color[now]:
        node_color[now] = color

    for x in node[now]:
        dfs(x, dist - 1, color)


for i in vdc:
    v, d, c = i
    dfs(v, d, c)

for m in range(n):
    print(node_color[m + 1])
Problem p03774 (python)

Fixed submission:
import math

n, m = map(int, input().split())

# student input
student = []
for i in range(n):
    a, b = map(int, input().split())
    student.append([a, b])

# check point input
check = []
for j in range(m):
    c, d = map(int, input().split())
    check.append([c, d])

# calc
for s in student:
    distance = 10e9
    near = 0
    for index, k in enumerate(check):
        v = math.fabs(s[0] - k[0]) + math.fabs(s[1] - k[1])
        if v < distance:
            distance = v
            near = index + 1
    print(near)

Buggy submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())

# student input
student = []
for i in range(n):
    a, b = map(int, input().split())
    student.append([a, b])

# check point input
check = []
for j in range(n):
    c, d = map(int, input().split())
    check.append([c, d])

# calc
for s in student:
    distance = 10e9
    near = 0
    for index, k in enumerate(check):
        v = math.fabs(s[0] - k[0]) + math.fabs(s[1] - k[1])
        if v < distance:
            distance = v
            near = index + 1
    print(near)
Problem p03803 (python)

Fixed submission:
A,B = map(int, input().split())

if A == 1:
    A = 14
if B == 1:
    B = 14

if A > B:
    print('Alice')
elif A == B:
    print('Draw')
else:
    print('Bob')

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
print('Alice' if cards.index(A) > cards.index(B) else 'Bob' if cards.index(A) < cards.index(B) else 'Draw' )
Problem p03723 (python)

Fixed submission:
### A - Cookie Exchanges
a = [ int(i) for i in input().split() ]

cnt=0
if a[0] % 2 == 1 or a[1] % 2 == 1 or a[2] % 2 == 1:
    pass
elif a[0] == a[1] and a[1] == a[2]:
    cnt=-1
else:
    while True:
        if a[0] % 2 == 1 or a[1] % 2 == 1 or a[2] % 2 == 1: break
        cnt += 1
        a[0], a[1], a[2] = (a[1]+a[2])/2 , (a[0]+a[2])/2, (a[0]+a[1])/2

print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
p2 = [ int(i) for i in input().split() ]
ps = sorted(p2)

cnt=0
while True:
    if p2 == ps: break
    cnt += 1
    high = []
    low = []
    for i in range(len(p2)):
        if p2[i] == max(p2[0:i+1]):
            high.append(p2[i])
        else:
            low.append(p2[i])
    p2 = low + high

print(cnt)
Problem p03767 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N = int(raw_input())
a = raw_input().split(" ")
output = 0

b = []

for i in a:
    b.append(int(i))

b.sort(reverse=True)

for i in range(N):
    output = output + int(b[2*i+1])

print output

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N = int(raw_input())
a = raw_input().split(" ")
output = 0

a.sort()

for i in a[N:2*N]:
    output = output + int(i)

print output
Problem p03774 (python)

Fixed submission:
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 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 submission (verdict: Runtime Error):
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()
Problem p03804 (python)

Fixed submission:
def main():
    n, m = map(int, input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]

    for row in range(n - m + 1):
        current_index = 0
        for index in range(n - m + 1):
            current_index = a[row].find(b[0], index)
            if current_index < 0:
                break

            for i in range(m):
                if a[row + i].find(b[i], current_index) != current_index:
                    break
            else:
                print('Yes')
                return

    print('No')


if __name__ == "__main__":

    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]

    for row in range(n - m + 1):
        current_index = 0
        for index in range(m - 1):
            current_index = a[row].find(b[row], index)
            if current_index < 0:
                break

            for i in range(m - 1):
                if a[row + i].find(b[row + i]) != current_index:
                    break
            else:
                print('Yes')
                return

    print('No')


if __name__ == "__main__":

    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]

    for row in range(n - m):
        current_index = 0
        for index in range(m - 1):
            current_index = a[row].find(b[row], index)
            if current_index < 0:
                break

            for i in range(row, n - m):
                if a[i].find(b[i]) != current_index:
                    break
            else:
                print('Yes')
                return

    print('No')


if __name__ == "__main__":

    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]

    for row in range(n - m):
        current_index = 0
        for index in range(n - m):
            current_index = a[row].find(b[row], index)
            if current_index < 0:
                break

            for i in range(row, n - m):
                if a[i].find(b[i]) != current_index:
                    break
            else:
                print('Yes')
                return

    print('No')


if __name__ == "__main__":

    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    a = [input() for i in range(n)]
    b = [input() for i in range(m)]

    for row in range(n - m):
        current_index = 0
        for index in range(n - m):
            current_index = a[row].find(b[row], index)
            if current_index < 0:
                break

            for i in range(row + 1, n - m):
                if a[i].find(b[i]) != current_index:
                    break
            else:
                print('Yes')
                return

    print('No')


if __name__ == "__main__":

    main()
Problem p03723 (python)

Fixed submission:
A, B, C = map(int, raw_input().split())
[A, B, C] = sorted([A, B, C])
ans = 0
while A%2==0 and B%2==0 and C%2==0:
	ans += 1
	new1, new2, new3 = B/2 + C/2, A/2 + C/2, A/2 + B/2
	if new1 == new3:
		ans = -1
		break
	else:
		A, B, C = new1, new2, new3
print ans

Buggy submission (verdict: Runtime Error):
def isOdd(num):
	if num % 2 == 0:
		return False
	else:
		return True

A, B, C = map(int, raw_input().split())
ans = 0
while not isOdd(A) and not isOdd(B) and not isOdd(C):
	ans += 1
	new1, new2, new3 = B/2 + C/2, A/2 + C/2, A/2 + B/2
	if set(A, B, C) == set(new1, new2, new3):
		print -1
	else:
		A, B, C = new1, new2, new3
print ans
Problem p03723 (python)

Fixed submission:
import pdb
a,b,c = map(int, raw_input().strip().split(' '))
if a==b==c:
    if a%2==0:
        print -1
    else:
        print 0
elif a%2!=0 or b%2!=0 or c%2!=0:
    print 0
else:
    Flag = True
    cnt = 0
    for i in range(100000):
        tmp1,tmp2=a,b
        a = b/2+c/2
        b = tmp1/2+c/2
        c = tmp1/2+tmp2/2
        cnt += 1
#         pdb.set_trace()
        if a%2!=0 or b%2!=0 or c%2!=0:
            Flag = False
            break
    if Flag:
        print -1
    else:
        print cnt

Buggy submission (verdict: Runtime Error):
import pdb
a,b,c = map(int, raw_input().strip().split(' '))
if a==b==c:
    if a%2==0:
        print '-1'
    else
        print '0'
elif a%2!=0 or b%2!=0 or c%2!=0:
    print '0'
else:
    Flag = True
    cnt = 0
    for i in range(100000):
        tmp1,tmp2=a,b
        a = b/2+c/2
        b = tmp1/2+c/2
        c = tmp1/2+tmp2/2
        cnt += 1
#         pdb.set_trace()
        if a%2!=0 or b%2!=0 or c%2!=0:
            Flag = False
            break
    if Flag:
        print '-1'
    else:
        print cnt
Problem p03723 (python)

Fixed submission:
# coding: utf-8

a, b, c = map(int, input().rstrip().split())
count = 0

while True:
    if a == b and b == c and c == a :
        count = -1 if a % 2 == 0 else 0
        break
    elif a % 2 == 0 and b % 2 == 0 and c % 2 == 0 :
        a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
        count += 1
    else:
        break
print(count)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

a, b, c = map(int, input().rstrip().split())
count = 0

while True:
    elif a == b and b == c and c == a :
        count = -1 if a % 2 == 1 else 0
        break
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 :
        a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
        count += 1
    else:
        break
print(count)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

a, b, c = map(int, input().rstrip().split())
count = 0

while True:
    elif a == b and b == c and c == a :
        count = -1 if a % 2 == 1 else 0
        break
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 :
        a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
        count += 1
    else:
        break
print(count)
Problem p03774 (python)

Fixed submission:
# -*- coding: utf-8 -*-


def solve(s_pp, p_pp):
    p_nums = []
    for x, y in s_pp:
        distance = []
        for xx, yy in p_pp:
            n = abs(x - xx) + abs(y - yy)
            distance.append(n)
        min_distance_idx = distance.index(min(distance))
        p_nums.append(min_distance_idx + 1)
    return p_nums


def main():
    students, points = [int(e) for e in input().split()]
    students_ps = []
    points_ps = []

    for _ in range(students):
        x, y = [int(e) for e in input().split()]
        students_ps.append([x, y])
    for _ in range(points):
        x, y = [int(e) for e in input().split()]
        points_ps.append([x, y])
    
    for answer in solve(students_ps, points_ps):
        print(answer)


main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-


def solve(s_pp, p_pp):
    p_nums = []
    for x, y in s_pp:
        distance = []
        for xx, yy in p_pp:
            n = abs(x - xx) + abs(y - yy)
            distance.append(n)
        min_distance_idx = distance.index(min(distance))
        p_nums.append(min_distance_idx + 1)
    return p_nums


def main():
    students, points = [int(e) for e in input().split()]
    students_ps = []
    points_ps = []

    for _ in range(students):
        x, y = [int(e) for e in input().split()]
        students_ps.append([x, y])
    for _ in range(points):
        x, y = [int(e) for e in input().split()]
        points_ps.append([x, y])
    
    for answer in solve(students_ps, points_ps):
        print(answer)


m

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-


def solve(s_pp, p_pp):
    p_nums = []
    for x, y in s_pp:
        distance = []
        for xx, yy in p_pp:
            n = abs(x, xx) + abs(y, yy)
            distance.append(n)
        p_nums.append(min(distance))
    return p_nums


def main():
    students, points = [int(e) for e in input().split()]
    students_ps = []
    points_ps = []

    for _ in range(students):
        x, y = [int(e) for e in input().split()]
        students_ps.append([x, y])
    for _ in range(points):
        x, y = [int(e) for e in input().split()]
        points_ps.append([x, y])
    
    for answer in solve(students_ps, points_ps):
        print(answer)


main()
Problem p03775 (python)

Fixed submission:
N = int(input())

score = len(str(N))

i = 2
while i ** 2 <= N:
    a, b = divmod(N, i)
    if b == 0:
        score = min(score, len(str(a)))
    i += 1
print(score)

Buggy submission (verdict: Runtime Error):
N = int(input())

score = len(str(N))

i = 2
while i ** 2 < N:
    a, b = divmod(N, i)
    if b == 0:
        score = len(str(a))
	i += 1
print(score)

Buggy submission (verdict: Runtime Error):
N = int(input())

score = len(str(N))

i = 2
while i ** 2 < N:
    a, b = divmod(N, i)
    if b == 0:
        score = len(str(a))
	"""
        if score == len(str(i)):
            break
        i = max(N // (10 ** (score - 1)), i+1)
    """
	i += 1
print(score)
Problem p03745 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int,input().split()))

if N == 1:
    print(1)
    quit()

if A[0] < A[1]:
    tend = 1
elif A[0] > A[1]:
    tend = -1
else:
    tend = 0

count = 1
prev = A[1]

for a in A[2:]:
    if prev < a and tend < 0:
        tend = 0
        count += 1
    elif prev > a and tend > 0:
        tend = 0
        count += 1
    elif tend == 0:
        if prev < a:
            tend = 1
        elif prev > a:
            tend = -1
        else:
            tend = 0

    prev = a

print(count)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-


N,M = map(int,input().split())
G = [[] for i in range(N)]
visited = [False for i in range(N)]

for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    G[a].append(b)
    G[b].append(a)


s = 0
t = G[s][0]

path = [s,t]
solved = [False, False]
visited[s] = True
visited[t] = True

while(True):
    if not solved[0]:
        for n in G[s]:
            if visited[n]:
                continue
            visited[n] = True
            s = n
            path = [s] + path
            break
        else:
            if solved[1]:
               break 
            solved[0] = True

    if not solved[1]:
        for n in G[t]:
            if visited[n]:
                continue
            visited[n] = True
            t = n
            path = path + [t]
            break
        else:
            if solved[0]:
                break
            solved[1] = True
print(len(path))
print(' '.join((map(lambda x:str(x+1), path))))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int,input().split()))

tend = 1 if A[0] < A[1] else -1
count = 1
prev = A[1]

for a in A[2:]:
    if prev < a and tend < 0:
        tend = 0
        count += 1
    elif prev > a and tend > 0:
        tend = 0
        count += 1
    elif tend == 0:
        if prev < a:
            tend = 1
        elif prev > a:
            tend = -1
        else:
            tend = 0

    prev = a

print(count)
Problem p03745 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

if N == 1:
    print(1)
    exit()

if A[0] > A[1]:
    status = 'dec'

elif A[1] > A[0]:
    status = 'inc'

else:
    status = 'equal'


cnt = 0

for i in range(2,N):
    if status == 'dec' and A[i] > A[i-1]:
        cnt += 1
        status = 'none'
    
    elif status == 'inc' and A[i] < A[i-1]:
        cnt += 1
        status = 'none'
    
    elif status == 'equal' and A[i] > A[i-1]:
        status = 'inc'
    
    elif status == 'equal' and A[i] < A[i-1]:
        status = 'dec'
    
    elif status == 'none' and A[i] < A[i-1]:
        status = 'dec'
    
    elif status == 'none' and A[i] > A[i-1]:
        status = 'inc'
    
    elif status == 'none' and A[i] == A[i-1]:
        status = 'equal'

print(cnt+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))



if A[0] > A[1]:
    status = 'dec'

elif A[1] > A[0]:
    status = 'inc'

else:
    status = 'equal'


cnt = 0

for i in range(2,N):
    if status == 'dec' and A[i] > A[i-1]:
        cnt += 1
        status = 'none'
    
    elif status == 'inc' and A[i] < A[i-1]:
        cnt += 1
        status = 'none'
    
    elif status == 'equal' and A[i] > A[i-1]:
        status = 'inc'
    
    elif status == 'equal' and A[i] < A[i-1]:
        status = 'dec'
    
    elif status == 'none' and A[i] < A[i-1]:
        status = 'dec'
    
    elif status == 'none' and A[i] > A[i-1]:
        status = 'inc'
    
    elif status == 'none' and A[i] == A[i-1]:
        status = 'equal'

print(cnt+1)
Problem p03745 (python)

Fixed submission:
def cutter(nums, idx):
    if len(nums) - idx <= 2:
        return len(nums)
    
    for i in xrange(idx+1, len(nums)):
        if int(nums[i]) != int(nums[i-1]):
            pos = i
            flag = int(nums[i]) > int(nums[i-1])  # is asc?
            # print flag
            break
    else:
        return len(nums)

    for i in xrange(pos, len(nums)):

        if flag:
            if int(nums[i]) < int(nums[i-1]):
                return i
        else:
            if int(nums[i]) > int(nums[i-1]):
                return i
    return len(nums)


n = int(raw_input())
idx = 0
arr = raw_input().split()
if n < 2:
    print n
else:
    count = 0
    while idx < n:
        # print arr[idx:]
        count += 1
        idx = cutter(arr, idx)

    print count

Buggy submission (verdict: Runtime Error):
def cutter(nums):
    if len(nums) < 2:
        return []
    
    for i in xrange(1, len(nums)):
        if int(nums[i]) != int(nums[i-1]):
            pos = i
            flag = int(nums[i]) > int(nums[i-1])  # is asc?
            # print flag
            break
    else:
        return []

    for i in xrange(pos, len(nums)):

        if flag:
            if int(nums[i]) < int(nums[i-1]):
                return nums[i:]
        else:
            if int(nums[i]) > int(nums[i-1]):
                return nums[i:]
    return []


n = int(raw_input())
arr = raw_input().split()
if n < 2:
    print n
else:
    count = 0
    while arr:
        print arr
        count += 1
        arr = cutter(arr)

    print count
Problem p03774 (python)

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

a = []
b = []

for i in range(n):
    tmp1, tmp2 = list(map(int, input().split()))
    a.append(tmp1)
    b.append(tmp2)

c = []
d = []

for i in range(m):
    tmp1, tmp2 = list(map(int, input().split()))
    c.append(tmp1)
    d.append(tmp2)

for i in range(n):
    tmp = abs(a[i] - c[0]) + abs(b[i] - d[0])
    s = 1
    for j in range(m):
        tmp3 = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if tmp3 < tmp:
            tmp = tmp3
            s = j + 1
    print(s)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))

a = []
b = []

for i in range(n):
    tmp1, tmp2 = list(map(int, input().split()))
    a.append(tmp1)
    b.append(tmp2)

c = []
d = []

for i in range(m):
    tmp1, tmp2 = list(map(int, input().split()))
    c.append(tmp1)
    d.append(tmp2)

for i in range(n):
    tmp = abs(a[n] - c[0]) + abs(b[n] - d[0])
    s = 1
    for j in range(m):
        tmp3 = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if tmp3 < tmp:
            tmp = tmp3
            s = j + 1
    print(s)