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

Fixed submission:
n = input()
 
arr = list(n)
output = ""
for e in arr:
  if e == '1':
    output += '9'
  else:
    output += '1'
 
print(output)

Buggy submission (verdict: Runtime Error):
n = read()

arr = list(n)
output = ""
for e in arr
  if e == '1':
    output += '9'
  else:
    output += '1'

print(output)
Problem p03242 (python)

Fixed submission:
s = input()

r = ""
for i in s:
  if i =='1':
    r += '9'
  else:
    r += '1'
print(r)

Buggy submission (verdict: Runtime Error):
n = input('')
i == ''

if i == 1:
  i = 9
elsif i == 9:
  i = 1
  
print(n)

Buggy submission (verdict: Runtime Error):
n =input()
if 111 =< n <= 999:
Problem p03250 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a>=b and a>=c:
    print(a*10+b+c)
elif b>=a and b>=c:
    print(b*10+a+c)
elif c>=a and c>=b:
    print(c*10+a+b)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if a>=b and a>=c:
    print(10*a+b+c)
    
elif b>=a and b>=c:
    prnt(a+10*b+c)
    
elif c>=a and c>=b:
    print(a+b+10*c)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split)

if a+b>=b+c:
    print(10*a+b+c)
    
elif a+b<=b+c:
    prnt(a+10*b+c)
Problem p03250 (python)

Fixed submission:
a,b,c= map(int, input().split())

m=max(a,b,c)

if m==a:
    print(a*10+b+c)
elif m==b:
    print(b*10+a+c)
else:
    print(c*10+a+b)

Buggy submission (verdict: Runtime Error):
a,b,c= map(int, input().split())

m=max(a,b,c)

if m==a:
    print((a+10)+b+c)
elif:m==b:
    print((b+10)+a+c)
else:
    print((c+10)+a+b)
Problem p03242 (python)

Fixed submission:
N = int(input())
print(1110-N)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = [int(_) for _ in input().split()]
cnt = 0
for i in range(2, n):
  if v[i-2] != v[i]:
    cnt += 1
print(cnt)
Problem p03307 (python)

Fixed submission:
N = int(input())

if N % 2 == 0:
    print(N)
else:
    print(N * 2)

Buggy submission (verdict: Runtime Error):
import statistics
import math

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

B = []
C = []
D = []
E = []
ureshimi = []
k = 0
l = 0

for i in range(N-3):
    BC = A[0 : i + 2]
    s = 0
    for j in range(k, i + 2):
        s += BC[j]
        if j == i + 1:
            k = j 
            B = BC[0 : j ]
            C = BC[j  : N - i]
            break
        elif s + BC[j + 1] > sum(BC) / 2:
            k = j
            if BC[j + 1] / 2 >= sum(BC) / 2 - s:
                B = BC[0 : j + 1]
                C = BC[j + 1 : i + 2]
            else:
                B = BC[0 : j + 2]
                C = BC[j + 2 : i + 2]
            break
    DE = A[i + 2 : N + 1]
    s = sum(DE[0:l - i + 1 ])
    for j in range(l - i + 1 , N - i - 2):
        if j == N - i - 3:
            l = j + i 
            D = DE[0 : j ]
            E = DE[j  : N - i]
            break
        elif s + DE[j ] > sum(DE) / 2:
            l = j + i
            if DE[j ] / 2 >= sum(DE) / 2 - s:
                D = DE[0 : j ]
                E = DE[j : N - i]
            else:
                D = DE[0 : j + 1]
                E = DE[j + 1 : N - i]
            break
        s += DE[j]
    ureshimi.append(max(sum(B), sum(C), sum(D), sum(E)) - min(sum(B), sum(C), sum(D), sum(E)))



print(min(ureshimi))
Problem p03315 (python)

Fixed submission:
s=input()
a = 0

for i in range(0,4):
    if s[i] == '+':
        a = a + 1
    else:
        a = a - 1
print(a)

Buggy submission (verdict: Runtime Error):
s=input()
a = 1

for i in range(0..3):
    if s[i] == +:
        a = a + 1
    else:
        a = a - 1
Problem p03242 (python)

Fixed submission:
num=list(input())
ans=[]
for i in num:
    if i=="1":
        ans.append("9")
    else:
        ans.append("1")

mojiretu = ' '
for x in ans:
    mojiretu += x

print(mojiretu)

Buggy submission (verdict: Runtime Error):
num=input()
n=len(num)
ans=[]
for i in range(n):
    if num[i]=="1":
        num[i] = "9"
    else:
        num[i] = "1"
print(num)
Problem p03327 (python)

Fixed submission:
N = int(input())
if N <= 999:
    print("ABC")
else:
    print("ABD")

Buggy submission (verdict: Runtime Error):
N = input()
if N >1000:
    print("ABC")
else:
    print("ABD")

Buggy submission (verdict: Runtime Error):
N = input
if N >1000:
    print("ABC")
else:
    print("ABD")

Buggy submission (verdict: Runtime Error):
N = input
if n >1000:
    print("ABC")
else:
    print("ABD")
Problem p03242 (python)

Fixed submission:
N=input()
 
for i in range(len(N)):
  if(N[i]=="1"):
     print("9", end="")
  if(N[i]=="9"):
     print("1", end="")

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

for i in range(len(N)):
  if(N[i]=="1!):
     print("9", end="")
  if(N[i]=="9!):
     print("1", end="")
Problem p03250 (python)

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

li=[A,B,C]

max_num=max(li)
max_num2=min(li)

for i in li:
    if max_num!=i and max_num2<i:
        max_num2=i
        
num1=int(str(max_num)+str(max_num2))
li.remove(max_num)
li.remove(max_num2)

print(int(num1)+li[0])

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

li=[A,B,C]

max_num=max(li)
max_num2=-10000

for i in li:
    if max_num!=i and max_num2<i:
        max_num2=i
        
num1=int(str(max_num)+str(max_num2))
li.remove(max_num)
li.remove(max_num2)

print(int(num1)+li[0])

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

li=[A,B,C]

max_num=max(li)
max_num2=-10000

for i in range(3):
    if max_num!=i and max_num2<i:
        max_num2=i
        
num1=str(max_num)+str(max_num2)
li.remove(max_num)
li.remove(max_num2)

print(int(num1)+li[0])
Problem p03307 (python)

Fixed submission:
N = int(input())
result = N if N&1==0 else N<<1
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().strip().split()))
min_n = max_n = A[0]
for i in range(1, N):
	num = A[i]
	if min_n > num:
		min_n = num
	if max_n < num:
		max_n = num
result = max_n - min_n
print(result)
Problem p03295 (python)

Fixed submission:
def main():
    in1 = input().split(" ")
    n, m = [int(c) for c in in1]

    arr = []
    for i in range(m):
        _in = input().split(" ")
        a, b = [int(c) for c in _in]
        arr.append((a, b))

    sorted_arr = sorted(arr, key=lambda x: x[0])

    n = 1

    mi, ma = sorted_arr[0]
    mi, ma = (mi, ma) if mi < ma else (ma, mi)
    for a, b in sorted_arr[1:]:
        a, b = (a, b) if a < b else (b, a)
        if ma <= a:
            n += 1
            mi, ma = a, b
        if mi < a:
            mi = a
        if ma > b:
            ma = b
    print(n)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    in1 = input()
    n, m = [int(c) for c in in1]

    arr = []
    for i in range(m):
        _in = input()
        a, b = [int(c) for c in _in]
        arr.append((a, b))

    sorted_arr = sorted(arr, key=lambda x: x[0])

    n = 0

    mi, ma = sorted_arr[0]
    for a, b in sorted_arr[1:]:
        if ma < a:
            n += 1
            mi, ma = a, b
        if mi < a:
            mi = a
        if ma > b:
            ma = b
    print(n)

if __name__ == "__main__":
    main()
Problem p03327 (python)

Fixed submission:
def read():
    return raw_input()


def write(message):
    import sys
    print message
    sys.stdout.flush()


if __name__ == '__main__':
    N = int(read())
    write("ABD" if N > 999 else "ABC")

Buggy submission (verdict: Runtime Error):
def read():
    return raw_input()


def write(message):
    import sys
    print(message)
    sys.stdout.flush()


if __name__ == '__main__':
    N = int(read())
    write("ABD" if N > 999 else "ABC")
Problem p03776 (python)

Fixed submission:
import numpy as np
import math
def ncm(n,m):
    return math.factorial(n)/(math.factorial(m) * math.factorial(n-m))

N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
v = np.array(v)
##print(v)
ansarray = v[0:A]
##print(ansarray)
ave = np.mean(ansarray)
print(float(ave))
mi = min(ansarray)
ma = max(ansarray)
biggerarray = v[v>mi]
m = len(biggerarray)
numminarray = v[v==mi]
a = len(numminarray)
##print(nummin)
##print(num_kouho)
ans = 0
if ma == mi:
    if m+a <= B:
        for i in range(A-m,a+1):
            ans+=ncm(a,i)
    else:
        for i in range(A-m,B-m+1):
            ans+=ncm(a,i)

else:
    ans = ncm(a,A-m)
#print('a=',a)
#print('m=',m)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
import scipy.special as ss
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
v = np.array(v)
##print(v)
ansarray = v[0:A]
##print(ansarray)
ave = np.mean(ansarray)
print(float(ave))
mi = min(ansarray)
ma = max(ansarray)
biggerarray = v[v>mi]
m = len(biggerarray)
numminarray = v[v==mi]
a = len(numminarray)
##print(nummin)
##print(num_kouho)
ans = 0
if ma == mi:
    if m+a <= B:
        for i in range(A-m,a+1):
            ans+=ss.comb(a,i)
    else:
        for i in range(A-m,B-m+1):
            ans+=ss.comb(a,i)

else:
    ans = a
#print('a=',a)
#print('m=',m)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np
import scipy.special as ss
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
v = np.array(v)
##print(v)
ansarray = v[0:A]
##print(ansarray)
ave = np.mean(ansarray)
print(ave)
mi = min(ansarray)
ma = max(ansarray)
biggerarray = v[v>mi]
m = len(biggerarray)
numminarray = v[v==mi]
a = len(numminarray)
##print(nummin)
##print(num_kouho)
ans = 0
if ma == mi:
    if m+a <= B:
        for i in range(A-m,a+1):
            ans+=ss.comb(a,i)
    else:
        for i in range(A-m,B-m+1):
            ans+=ss.comb(a,i)

else:
    ans = a
#print('a=',a)
#print('m=',m)
print(int(ans))
Problem p03805 (python)

Fixed submission:
nmax = 8
def dfs(v, N, visited):
    all_visited=True
    for i in range(N):
        if visited[i]==False:
            all_visited=False

    if all_visited==True:
        return 1

    ret=0
    for i in range(N):
        if graph[v][i]==False:
            continue
        if visited[i]==True:
            continue

        visited[i]=True
        ret+=dfs(i,N,visited)
        visited[i]=False

    return ret

N, M = map(int, input().split())
graph = [[False]*N for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    graph[A-1][B-1]=True
    graph[B-1][A-1]=True

visited = [False]*N

visited[0]=True
print(dfs(0,N,visited))

Buggy submission (verdict: Runtime Error):
nmax = 8
def dfs(v, N, visited):
    all_visited=True
    for i in range(N):
        if visited[i]==False:
            all_visited=False

    if all_visited==True:
        return 1

    ret=0
    for i in range(N):
        if graph[v][i]==False:
            continue
        if visited[i]==True:
            continue

        visited[i]=True
        ret+=dfs(i,N,visited)
        visited[i]=False

    return ret

N, M = map(int, input().split())
graph = [[False]*M for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    graph[A-1][B-1]=True
    graph[B-1][A-1]=True

visited = [False]*N

visited[0]=True
print(dfs(0,N,visited))
Problem p03272 (python)

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

print(N-i+1)

Buggy submission (verdict: Runtime Error):
N,i = map(int,input(),split())

print(N-i+1)
Problem p03631 (python)

Fixed submission:
s=input()
print("Yes" if s[0]==s[2] else "No")

Buggy submission (verdict: Runtime Error):
s=(input)
print("YES" if s[0]==s[2] else "No")

Buggy submission (verdict: Runtime Error):
s=(input)
print("YES" if s[0]==s[2] else "No")

Buggy submission (verdict: Runtime Error):
print("YES" if input()[0]==input()[2] else "No")
Problem p03250 (python)

Fixed submission:
A, B, C = map(int, input().split())
number = []
number.append(A)
number.append(B)
number.append(C)

number.sort()
print(number[2]*10 + number[1] + number[0])

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
print(A, B, C)
number = []
number.append([A, B, C])

number.sort()
print(number[2]*10 + number[1] + number[0])
Problem p03250 (python)

Fixed submission:
from sys import stdin
a, b, c = [int(i) for i in stdin.readline().rstrip().split()]

print(max([10 * a + b + c, a + 10 * b + c, a + b + 10 * c]))

Buggy submission (verdict: Runtime Error):
from sys import stdin
a, b, c = [int(i) for i in stdin.readline().rstrip().split()]

print(max([10 * a + b + c, a + 10 * b + c, a + b + 10 * c])
Problem p03250 (python)

Fixed submission:
a = input().split()
a = [int(i) for i in a]
amax = a[0]
count = 0
for i in range(1,3):
    if a[i] > amax:
        amax = a[i]
        count = i
    else:
        pass
a.pop(count)
print(amax*10+a[0]+a[1])

Buggy submission (verdict: Runtime Error):
a = input().split()
a = [int(i) for i in a]
print(a)
amax = a[0]
for i in range(1,3):
    if a[i] > amax:
        amax = a[i]
        count = i
    else:
        pass
a.pop(count)
print(amax*10+a[0]+a[1])
Problem p03265 (python)

Fixed submission:
xy=input().split()
x1=int(xy[0])
y1=int(xy[1])
x2=int(xy[2])
y2=int(xy[3])
a=x2-x1
b=y2-y1
print(x2-b,y2+a,x1-b,y1+a)

Buggy submission (verdict: Runtime Error):
xy=input().split()
x1=int(hw[0])
y1=int(hw[1])
x2=int(hw[2])
y2=int(hw[3])
a=x2-x1
b=y2-y1
print(x2-b,y2+a,x1-b,y1+a)
Problem p03250 (python)

Fixed submission:
def main():
    nums = sorted([int(i) for i in input().split()], reverse=True)
    max_num = 10 * nums[0] + nums[1] + nums[2]
    print(max_num)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    nums = sorted([int(i) for i in input().split()], reverse=True)
    max_num = 10 * nums[0] + nums[1] + nums[2]
    print(max_num)


if __name__ == '__main__':
    main()
Fujitakes-MacBook-Pro:tmp mas
Problem p03307 (python)

Fixed submission:
N = int(input())
if N%2==0:
    print(N)
elif N%2!=0:
    print(2*N)

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

a = 2 * N / math.gcd(2, N)

print(a)
Problem p03315 (python)

Fixed submission:
N = list(input())
sum=0
for i in N:
    if i == '+':
        sum+=1
    elif i == '-':
        sum-=1
print(sum)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    del A[0:K]
print(sum)
Problem p03317 (python)

Fixed submission:
import math
N,K = map(int,input().rstrip().split())
print(math.ceil((N-1)/(K-1)))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    print(A)
    del A[0:K]
print(sum)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    print(A)
    del A[0:K]
print(sum)
Problem p03464 (python)

Fixed submission:
from math import floor,ceil
K = int(input())
A = [int(x) for x in input().split()]
A.reverse()
jmax, jmin = 2,2

for i in range(0,K):
    mmax,mmin = jmax,jmin
    if mmin % A[i] != 0:
        if (mmin + (A[i] - (mmin % A[i]))) > mmax:
            print(-1)
            exit()

    jmin = ceil(jmin / A[i]) * A[i]
    jmax = floor(jmax / A[i]) * A[i] + A[i] -1

print(jmin, jmax)

#計算量はO(3K)すなわちO(K)

Buggy submission (verdict: Runtime Error):
import sys
K = int(input())
A = [int(x) for x in input().split()]
A.reverse()
jmax, jmin = 2,2

if A[0] != 2:
    print(-1)
    sys.exit()

for i in range(0,K-1):  # 0<=i<=K-2 A[K-2]は2ラウンドの組．Kラウンドから2ラウンドまで
    Round = list(range(jmin,jmax+1))
    if not(0 in Round % A[i]):
        print(-1)
        sys.exit()
    jmin = (int(jmin/A[i])+1)*A[i]
    jmax = (int(jmax/A[i]))*A[i] +A[i]-1

jmax = jmax + A[K-1] -1

print(jmin, jmax)

Buggy submission (verdict: Runtime Error):
import sys
K = int(input())
A = [int(x) for x in input().split()]
A.reverse()
jmax, jmin = 2,2
#print(A)

for h in range(0,K):
    if A[h] <= A[h+1]:
        print(-1)
        sys.exit()

if A[0] != 2:
    print(-1)
    sys.exit()



for i in range(0,K-1):  # 0<=i<=K-2 A[K-2]は2ラウンドの組．Kラウンドから2ラウンドまで
    drop_num = []
    for j in range(0,A[i]):  #脱落者数の候補を入れていく
        if ( jmax + j ) % A[i+1] == 0:
            drop_num.append(j)
        if ( jmin + j ) % A[i+1] == 0:
            drop_num.append(j)
    if drop_num == []:  #A[i]について一通り調べたのち脱落者数の候補がなければ終わる
        print(-1)
        sys.exit()
    max_drop = max(drop_num)
    jmax = jmax + max_drop
    min_drop = min(drop_num)
    jmin = jmin + min_drop


jmax = jmax + A[K-1] -1

print(jmin, jmax)
Problem p03835 (python)

Fixed submission:
import sys

K, S = [int(_) for _ in sys.stdin.readlines()[0].strip().split(' ')]
total_pattern = 0

for x in range(K+1):
  for y in range(K+1):
    if 0 <= S - (x + y) <= K:
      total_pattern += 1
      
print(total_pattern)

Buggy submission (verdict: Runtime Error):
import sys

K, S = sys.stdin.readlines()[0].strip().split(' ')
total_pattern = 0

def recursive_solver(state):
  for k in K:
    s = recursive_solver(state - k)
    if s == 0:
      total_pattern += 1
    elif s < 0:
      return -1
    else:
      return recursive_solver(s)

recursive_solver(S)
print(total_patter)
Problem p03346 (python)

Fixed submission:
N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N+1)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]] = chain[a[i]-1]+1
print(N-max(chain))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N+1)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]+1] = chain[a[i]]+1
print(max(chain))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [0 for i in range(N)]
chain = [0 for i in range(N)]
for i in range(N):
  a[i] = int(input())
  chain[a[i]] = chain[a[i]-1]+1
print(max(chain))
Problem p03803 (python)

Fixed submission:
table = {'2': 0,
         '3': 1,
         '4': 2,
         '5': 3,
         '6': 4,
         '7': 5,
         '8': 6,
         '9': 7,
         '10': 8,
         '11': 9,
         '12': 10,
         '13': 11,
         '1': 12, }
ary = [table[i] for i in input().strip().split()]
if (ary[1] - ary[0]) > 0:
    print('Bob')
elif ary[1] == ary[0]:
    print('Draw')
else:
    print('Alice')

Buggy submission (verdict: Runtime Error):
from itertools import product


n, m = [int(i) for i in input().rstrip().split()]
AA = [[0 if i == '.' else 1 for i in input().rstrip()] for _ in range(n)]
BB = [[0 if i == '.' else 1 for i in input().rstrip()] for _ in range(m)]

for i_r, i_c in product(range(n - m + 1), range(n - m + 1)):
    i_r -= 1
    i_c -= 1
    for k_r, k_c in product(range(m), range(m)):
        if AA[i_r + k_r][i_c + k_c] == BB[k_r][k_c]:
            continue
        else:
            break
    else:
        print('Yes')
        break
else:
    print('No')
Problem p03315 (python)

Fixed submission:
S=input()
         
j=0
for i in range(4):
	if S[i]=="+":
		j=j+1
	else:
		j=j-1
print(j)

Buggy submission (verdict: Runtime Error):
    S=input()
     
    j=0
    for i in range(4):
     if S[i]=="+":
      j=j+1
     else:
      j=j-1
    print(j)

Buggy submission (verdict: Runtime Error):
S=input()

j=0
for i in range(4):
 if S[i]=="+":
  j=j+1
 else
  j=j-1
print(j)
Problem p03272 (python)

Fixed submission:
n,i=map(int,input().split())
print(n+1-i)

Buggy submission (verdict: Runtime Error):
import numpy as np
h,w=map(int,input().split())
icon=list()
for i in range(h):
    icon.append(list(input().split()))

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if icon[i][j]=='#':
            row[i]=True
            col[j]=True

for  i in range(h):
    if row[i]==True:
        for j in range(w):
            if col[j]==True:
                print(icon[i][j],end='')
        print()
Problem p03631 (python)

Fixed submission:
N = int (input( ))

N_100 = N // 100
N = N - 100 * N_100
N_10 = N // 10
N = N - 10 * N_10
N_1 = N

if  N_100 == N_1:
    print ('Yes')
else :
    print ('No')

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

N_100 = N // 100
N = N - 100 * N_100
N_10 = N // 10
N = N - 10 * N_10
N_1 = N

if  N_100 == N_1:
    print ('Yes')
else :
    print ('No')
Problem p03774 (python)

Fixed submission:
import math;

n, m = map(int, input().split(" "));
ab = [];
for i in range(0, n):
    ab.append(input().split(" "));

cd = [];
for i in range(0, m):
    cd.append(input().split(" "));

for i in range(0, n):
    dist=9999999999999
    nearm=0;
    for j in range(0, m):
         dist2 = math.fabs(int(ab[i][0]) - int(cd[j][0])) + math.fabs(int(ab[i][1]) - int(cd[j][1]));
         if dist2 < dist:
            dist = dist2;
            nearm=j;
    print(nearm+1);

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

def abs(n):
    return n if n>0 else -n


for i in range(1, n+1):
    ab = list(map(int, input().split(" ")))
for j in range(1, m+1):
    cd = list(map(int, input().split(" ")))

for i in range(0, n):
    delta = 999999999999
    ans=0
    for j in range(0, m):
        newdelta = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if delta>newdelta:
            delta=newdelta
            ans=j+1
    print(ans)
Problem p03326 (python)

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

r = [[0]*n for _ in range(8)]
for i in range(n):
    x, y, z = map(int, input().split())
    r[0][i] = x+y+z
    r[1][i] = x+y-z
    r[2][i] = x-y+z
    r[3][i] = x-y-z
    r[4][i] = -x+y+z
    r[5][i] = -x+y-z
    r[6][i] = -x-y+z
    r[7][i] = -x-y-z

print(max(sum(sorted(r[i])[-m:]) for i in range(8)) if m != 0 else 0)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

d = [
        [
            [
                [
                    [None] * 2 for _ in range(2)
                ] for _ in range(2)
            ] for _ in range(m+1)
        ] for _ in range(n)
    ]

def rec(i, j, p):
    if i >= n or j <= 0:
        return 0

    if d[i][j][p[0]][p[1]][p[2]]:
        return d[i][j][p[0]][p[1]][p[2]]

    res1 = rec(i+1, j, p)
    res2 = rec(i+1, j-1, p)
    res2 += a[i][0] * (-1 if p[0] else 1)
    res2 += a[i][1] * (-1 if p[1] else 1)
    res2 += a[i][2] * (-1 if p[2] else 1)

    res = max(res1, res2)
    d[i][j][p[0]][p[1]][p[2]] = res
    return res

res = 0
for p0 in range(2):
    for p1 in range(2):
        for p2 in range(2):
            t = rec(0, m, [p0, p1, p2])
            if t > res:
                res = t
print(res)

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

d = [
        [
            [
                [
                    [None] * 2 for _ in range(2)
                ] for _ in range(2)
            ] for _ in range(m+1)
        ] for _ in range(n)
    ]

def rec(i, j, p):
    if i >= n or j <= 0:
        return 0

    if d[i][j][p[0]][p[1]][p[2]]:
        return d[i][j][p[0]][p[1]][p[2]]

    res1 = rec(i+1, j, p)
    res2 = rec(i+1, j-1, p)
    res2 += a[i][0] * (-1 if p[0] else 1)
    res2 += a[i][1] * (-1 if p[1] else 1)
    res2 += a[i][2] * (-1 if p[2] else 1)

    res = max(res1, res2)
    d[i][j][p[0]][p[1]][p[2]] = res
    return res

results = []

for p0 in range(2):
    for p1 in range(2):
        for p2 in range(2):
            results.append(rec(0, m, [p0, p1, p2]))
print(max(results))