Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())

highest = int(math.sqrt(n))
l = [0]*n
cal = 0

for x in range(1, highest+1):
  for y in range(1, highest+1):
    for z in range(1, highest+1):
      cal = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if cal > n+1:
        continue
      else:
        l[cal-1] += 1
        
for i in range(len(l)):
  print(l[i])

Fixed submission:
import math
n = int(input())

highest = int(math.sqrt(n))
l = [0]*n
cal = 0

for x in range(1, highest+1):
  for y in range(1, highest+1):
    for z in range(1, highest+1):
      cal = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if cal > n:
        continue
      else:
        l[cal-1] += 1
        
for i in range(len(l)):
  print(l[i])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
q = int(input())

l = [0] * 100000
m = list(range(1,100001))

for i in range(n):
  l[a[i]-1] += 1
  
for j in range(q):
  b = list(map(int,input().split()))
  l[b[1]-1] += l[b[0]-1]
  l[b[0]-1] = 0
  print(sum(list(map(lambda x,y: x*y, l, m))))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
ans = sum(a)

l = [0] * 100001

for i in a:
  l[i] += 1
  
for j in range(q):
  b, c = map(int,input().split())
  l[c] += l[b]
  ans += l[b] * (c-b)
  l[b] = 0
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = [list(map(int,input().split())) for i in range(q)]

l = [0] * 100000
m = list(range(1,100001))

for i in range(n):
  l[a[i]-1] += 1
  
for j in range(q):
  l[b[j][1]-1] += l[b[j][0]-1]
  l[b[j][0]-1] = 0
  print(sum(list(map(lambda x,y: x*y, l, m))))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
ans = sum(a)

l = [0] * 100001

for i in a:
  l[i] += 1
  
for j in range(q):
  b, c = map(int,input().split())
  l[c] += l[b]
  ans += l[b] * (c-b)
  l[b] = 0
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

import numpy as np

n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = [list(map(int,input().split())) for i in range(q)]

l = np.array([0] * 100000)
m = np.array(list(range(1,100001)))

for i in range(n):
  l[a[i]-1] += 1
  
for j in range(q):
  l[b[j][1]-1] += l[b[j][0]-1]
  l[b[j][0]-1] = 0
  print(sum(l*m))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
q = int(input())
ans = sum(a)

l = [0] * 100001

for i in a:
  l[i] += 1
  
for j in range(q):
  b, c = map(int,input().split())
  l[c] += l[b]
  ans += l[b] * (c-b)
  l[b] = 0
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)


Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))

#print("c:",c)
#print(p)
#print("s:",s)

for x in s:
#    print(x)
    t = x * 2
#    print("t:",t)
    while t <= 10 ** 6:
        p[t] = False
        t += x
#        print("t_inner:",t)
ans = 0

#print("a:",a)
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse=True)

vote = sum(a)

if a[m-1] => vote*1/(4*m):
  print('Yes')
else:
  print('No')


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

a.sort(reverse=True)

vote = sum(a)

if a[m-1] >= vote*1/(4*m):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)

front = s[:(n-1)//2]
rear = s[(n+1)//2:]

if s == s[::-1] and front == front[::-1] ans rear == rear[::-1]:
  print('Yes')
else:
  print('No')

Fixed submission:
S = str(input())
N = len(S)
 
head = round((N-1)/2)
end = round((N+3)/2-1)

headS = S[:head]
endS = S[end:]

if S==S[::-1] and headS == headS[::-1] and endS == endS[::-1]:
	print('Yes')
else:
  	print('No')

Buggy python submission (verdict: Runtime Error):
S = str(input())
N = len(S)

small = round((N-1)/2)
big = round((N+3)/2)-1
smallS = S[0:small]
bigS = S[big:N]

if L > 5:
    if smallS == bigS:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Fixed submission:
S = str(input())
N = len(S)
 
head = round((N-1)/2)
end = round((N+3)/2-1)

headS = S[:head]
endS = S[end:]

if S==S[::-1] and headS == headS[::-1] and endS == endS[::-1]:
	print('Yes')
else:
  	print('No')

Buggy python submission (verdict: Runtime Error):
if L > 5:
    small = round((N-1)/2)
    big = round((N+3)/2)-1
    smallS = S[0:small]
    bigS = S[big:N]

    if smallS == bigS:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Fixed submission:
S = str(input())
N = len(S)
 
head = round((N-1)/2)
end = round((N+3)/2-1)

headS = S[:head]
endS = S[end:]

if S==S[::-1] and headS == headS[::-1] and endS == endS[::-1]:
	print('Yes')
else:
  	print('No')

Buggy python submission (verdict: Runtime Error):
S = str(input())
N = len(S)

if L > 5:
    small = round((N-1)/2)
    big = round((N+3)/2)-1
    smallS = S[0:small]
    bigS = S[big:N]

    if smallS == bigS:
        print('Yes')
    else:
        print('No')

Fixed submission:
S = str(input())
N = len(S)
 
head = round((N-1)/2)
end = round((N+3)/2-1)

headS = S[:head]
endS = S[end:]

if S==S[::-1] and headS == headS[::-1] and endS == endS[::-1]:
	print('Yes')
else:
  	print('No')
Buggy python submission (verdict: Runtime Error):
L = str(input())
HWL = L/3

print(HWL ** 3)

Fixed submission:
L = int(input())
HWL = L/3

print(HWL ** 3)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import itemgetter

n = int(input())
a = [input() for i in range(n)]
b = list(set(a))
b.sort()
c = []

max = a.count(b[0])

for i in range(len(b)):
	c.append(a.count(b[i]))

unique_count = list(zip(b, c))
unique_count.sort(key = itemgetter(1), reverse=True)

for j in range(len(unique_count)):
	if unique_count[j][1] == unique_count[0][1]:
		print(unique_count[j][0])

Fixed submission:
import collections

n = int(input())
a = [input() for i in range(n)]
c = collections.Counter(a)

i = 0

common = c.most_common()
common.sort(key = lambda x: x[1], reverse=True)

ans = []

while common[i][1] >= common[0][1]:
	ans.append(common[i][0])

	if i < len(common)-1:
		i += 1
	else:
		break

ans.sort()

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

# xは最初の位置
# nは目的地
# aは料金所（コスト1）

cost = 0
cost2 = 0

for i in range(len(a)):
  if a[i] > x and a[i] < n:
    cost += 1
for j in range(x):
  if a[j] > 0 and a[j] < x :
    cost2 += 1
    
if cost < cost2:
  print(cost)
else:
  print(cost2)

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

# xは最初の位置
# nは目的地
# aは料金所（コスト1）

cost = 0
cost2 = 0

for i in a:
  if i > x:
    cost += 1
  else:
    cost2 += 1
    
if cost < cost2:
  print(cost)
else:
  print(cost2)
Buggy python submission (verdict: Runtime Error):
A = list(map(int, input().sprit()))
ans = sorted(A)
if ans == [5,5,7]:
  print('YES')
else:
  print('NO')

Fixed submission:
A=list(map(int,input().split()))
ans=sorted(A)
if ans==[5,5,7]:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
y=[]
for i in range(a-1):
    v=list(map(int,input().split()))
    y.append(v)
y.sort(key=lambda net:net[0])
ans=[0]*a
for j in range(b):
    c,d=map(int,input().split())
    ans[c-1]=ans[c-1]+d
for k in range(a-1):
    ans[zz]=ans[y[k][1]-1]+ans[y[k][0]-1]
print(*ans,sep=" ")


Fixed submission:
a,b=map(int,input().split())
y=[]
for i in range(a-1):
    v=list(map(int,input().split()))
    y.append(v)
y.sort(key=lambda n:n[0])
ans=[0]*a
for j in range(b):
    c,d=map(int,input().split())
    ans[c-1]=ans[c-1]+d
for k in range(a-1):
    ans[y[k][1]-1]=ans[y[k][1]-1]+ans[y[k][0]-1]
print(*ans,sep=" ")

Buggy python submission (verdict: Time Limit Exceeded):

a,b=map(int,input().split())
y=[]
for i in range(a-1):
    v=list(map(int,input().split()))
    y.append(v)
y.sort(key=lambda net:net[0])
ans=[0]*a
for j in range(b):
    c,d=map(int,input().split())
    ans[c-1]=ans[c-1]+d
for k in range(a-1):
    yy=y[k][0]-1
    zz=y[k][1]-1
    ans[zz]=ans[zz]+ans[yy]
print(*ans,sep=" ")


Fixed submission:
a,b=map(int,input().split())
y=[]
for i in range(a-1):
    v=list(map(int,input().split()))
    y.append(v)
y.sort(key=lambda n:n[0])
ans=[0]*a
for j in range(b):
    c,d=map(int,input().split())
    ans[c-1]=ans[c-1]+d
for k in range(a-1):
    ans[y[k][1]-1]=ans[y[k][1]-1]+ans[y[k][0]-1]
print(*ans,sep=" ")
Buggy python submission (verdict: Runtime Error):
import math

A,B = input().split()
iA = int(A)
fB = float(B)
iB = math.floor(fB)
fB100 = math.floor(fB*100 - iB*100)

ans = iA * iB
ans += (fB100 * iA) // 100
print(ans

Fixed submission:
A,B = input().split()
iA = int(A)
iB = int(float(B) * 100 + 0.5)

ans = (iA * iB) // 100
print(ans)

Buggy python submission (verdict: Runtime Error):
A,B = input().split()
iA = int(A)
iB = int(B)
fB100 = int(float(B)*100 - iB*100)

ans = iA * iB
ans += (fB100 * iA) // 100
print(ans)

Fixed submission:
A,B = input().split()
iA = int(A)
iB = int(float(B) * 100 + 0.5)

ans = (iA * iB) // 100
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n,k = map(int, input().split())
p_list = np.fromstring(input(), int, sep=' ')

Cumulative_sum = np.zeros(n+1)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

print((length_k_sum_list.max()+k)/2)


Fixed submission:
import sys
import numpy as np

val = np.fromstring(sys.stdin.buffer.read(), np.int64, sep=' ')
n,k = val[:2]
p_list = val[2:]

S = np.zeros(n+1, np.int64)
S[1:] = p_list.cumsum()

KS = S[k:] - S[0:-k]
print((KS.max()+k)/2)

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np

n,k = map(int,input().split())
p_list = np.fromstring(input(),int,sep=' ')

Cumulative_sum = np.zeros(n+1, int)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = S[k:] - S[0:-k]

print((length_k_sum_list.max()+k)/2)


Fixed submission:
import sys
import numpy as np

val = np.fromstring(sys.stdin.buffer.read(), np.int64, sep=' ')
n,k = val[:2]
p_list = val[2:]

S = np.zeros(n+1, np.int64)
S[1:] = p_list.cumsum()

KS = S[k:] - S[0:-k]
print((KS.max()+k)/2)

Buggy python submission (verdict: Runtime Error):
import numpy as np

n,k = map(int,input().split())
p_list = np.fromstring(input(), int)

Cumulative_sum = np.zeros(n+1, np.int64)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

ans = (length_k_sum_list.max() + k) / 2

print(ans)


Fixed submission:
import sys
import numpy as np

val = np.fromstring(sys.stdin.buffer.read(), np.int64, sep=' ')
n,k = val[:2]
p_list = val[2:]

S = np.zeros(n+1, np.int64)
S[1:] = p_list.cumsum()

KS = S[k:] - S[0:-k]
print((KS.max()+k)/2)

Buggy python submission (verdict: Runtime Error):
import numpy as np

n,k = map(int,input().split())
p_list = np.fromstring(input(), np.int64, sep=' ')

Cumulative_sum = np.zeros(n+1, np.int64)
Cumulative_sum[1:] = p_list.cumsum()

length_k_sum_list = Cumulative_sum[k:] - Cumulative_sum[0:-k]

ans = (length_k_sum.max() + k) / 2

print(ans)


Fixed submission:
import sys
import numpy as np

val = np.fromstring(sys.stdin.buffer.read(), np.int64, sep=' ')
n,k = val[:2]
p_list = val[2:]

S = np.zeros(n+1, np.int64)
S[1:] = p_list.cumsum()

KS = S[k:] - S[0:-k]
print((KS.max()+k)/2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    H,N = LI()
    M = []
    for i in range(N):
        M.append(LI())

    dp = {0:H}
    h = []
    heapq.heappush(h,0)
    nxt = -1

    for i in range(10**9):
        if dp.get(i,-1) == -1:
            continue
        if dp[i] == 0:
            print(i)
            return
        for j in range(N):
            dp[i+M[j][1]] = min(dp.get(i+M[j][1],H),max(0,dp[i]-M[j][0]))

if __name__ == "__main__":
    main()


Fixed submission:
import sys
import heapq
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    H,N = LI()
    M = []
    for i in range(N):
        M.append(LI())

    dp = [10**10] * (H+1)
    dp[0] = 0

    for i in range(H):
        for j in range(N):
            HP = min(H,i+M[j][0])
            dp[HP] = min(dp[HP],dp[i]+M[j][1])
    print(dp[H])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
mod = 10**9+7

def gcm(a,b):
    while(a%b!=0):
        a,b = b,a%b
    return b


def main():
    N = I()
    A = LI()

    LLCM = [0]*N
    LLCM[0] = A[0]

    for i in range(1,N):
        LLCM[i] = LLCM[i-1]*A[i] // gcm(LLCM[i-1],A[i])

    B = [0]*N
    for i in range(N):
        B[i] = LLCM[N-1] * pow(A[i],mod-2,mod)
        B[i] %= mod

    ans = 0
    for i in range(N):
        ans += B[i]
        ans %= mod

    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
mod = 10**9+7

def gcm(a,b):
    while(a%b!=0):
        a,b = b,a%b
    return b


def main():
    N = I()
    A = LI()

    l = A[0]

    for i in range(1,N):
        l = l*A[i] // gcm(l,A[i])
        
    B = [0]*N
    for i in range(N):
        B[i] = l * pow(A[i],mod-2,mod)

    ans = 0
    for i in range(N):
        ans += B[i]

    print(ans%mod)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
int(input())

if ((x%100)+4)//5 > x//100:
    print(0)
else:
    print(1)



Fixed submission:
x = int(input())
while(x>=0):
    if x%100==0:
        print("1")
        break
    elif x<100:
        print("0")
        break
    elif x%100>=5:
        x -= 105
        continue
    else:
        x-=(x%100)+100
        continue

Buggy python submission (verdict: Runtime Error):
nt(input())

if ((x%100)+4)//5 > x//100:
    print(0)
else:
    print(1)



Fixed submission:
x = int(input())
while(x>=0):
    if x%100==0:
        print("1")
        break
    elif x<100:
        print("0")
        break
    elif x%100>=5:
        x -= 105
        continue
    else:
        x-=(x%100)+100
        continue
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
a=""
for c in s:
  a+=chr((ord(c)-ord(a)+n)%26+ord(a))
print(a)
  

Fixed submission:
n=int(input())
s=list(input())
a=""
for c in s:
  a+=chr((ord(c)-ord("A")+n)%26+ord("A"))
print(a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = [int(a) for a in input().split()]

ans_r = 0
for a in A:
  ans_r += 1/a

print(1/ans)


Fixed submission:
n = int(input())
A = [int(a) for a in input().split()]

ans_r = 0
for a in A:
  ans_r += 1/a

print(1/ans_r)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

shift = [(i*10)%13 for i in range(10)]

def main():
    S_tmp = input()
    N = len(S_tmp)-1
    S = [S_tmp[i] for i in range(N)]                          
    
    ans = [0]*13
    ans[0] = 1
    
    for i in range(N):
        ans_pre = [x for x in ans]
        ans = [0]*13
        
        if S[i] == "?":                   
            for j in range(13):                   
                for k in range(10):                           
                    ans[(j*10+k)%13] += ans_pre[j]
        else:       
            for j in range(13):
                ans[(j*10+int(S[i]))%13] += ans_pre[j]
                
        for j in range(13):
            ans[j] %= 10**9+7
            
    print(ans[5])
                
    

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline

shift = [(i*10)%13 for i in range(10)]

def main():
    S_tmp = input()
    N = len(S_tmp)-1
    S = [S_tmp[i] for i in range(N)]                          
    
    ans = [0]*13
    ans[0] = 1
    
    for i in range(N):
        ans_pre = [x for x in ans]
        ans = [0]*13
        
        if S[i] == "?":                   
            for j in range(13):                   
                for k in range(10):                           
                    ans[(j*10+k)%13] += ans_pre[j]
        else:       
            for j in range(13):
                ans[(j*10+int(S[i]))%13] += ans_pre[j]
                
        for j in range(13):
            ans[j] %= 10**9+7
            
    print(ans[5])
                
    

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

def main():
    S = int(input())
    X1 = 0
    Y1 = 0
    X2 = int(math.sqrt(S))
    Y3 = S//X2
    if X2*Y3==S:
        X3=0
        Y2=0
    else:
        Y3+=1  
        if Y3>10**9:
            X2=10**9
            Y3=10**9
        X3 = 1
        Y2 = (X2*Y3-S) 
    print(X1,Y1,X2,Y2,X3,Y3)
if __name__ == '__main__':
    test()


Fixed submission:
import sys
import math
input = sys.stdin.readline

def main():
    S = int(input())
    X1 = 0
    Y1 = 0
    X2 = int(math.sqrt(S))
    Y3 = S//X2
    if X2*Y3==S:
        X3=0
        Y2=0
    else:
        Y3+=1
        if Y3>10**9:
            X2=10**9
            Y3=10**9
        X3 = 1
        Y2 = (X2*Y3-S)
    print(X1,Y1,X2,Y2,X3,Y3)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
mod_num = 10**9+7

ans = N-K+1
ans %= mod_num
print(ans)

for i in range(1,K):
    if N-K+1-i>0:
        ans = ans*(K-i)*(N-K+1-i)%mod_num   
        ans = ans*pow(b,mod_num-2)%mod_num
        print(ans)
    else:
        print(1)


Fixed submission:
N,K = map(int,input().split())
mod_num = 10**9+7

def mul(a,b):
    return ((a % mod_num) * (b % mod_num)) % mod_num

def power(x,y):
    if y==0:                 
        return 1     
    elif y==1:                    
        return x % mod_num
    elif y%2 == 0:
        return power(x, y//2)**2 % mod_num
    else:
        return power(x, y//2)**2 * x % mod_num
    
def div(a,b):
    return mul(a, power(b, mod_num-2))


ans = N-K+1
ans %= mod_num
print(ans)

for i in range(1,K):
    if N-K+1-i>0:
        ans = mul(ans,K-i)
        ans = mul(ans,N-K+1-i)
        ans = div(ans,i)
        ans = div(ans,i+1)
        print(ans)
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
W,H,x,y = map(int,input())

menseki = W*H/2
if x==W/2 and y==H/2:
    ans = 1
else:
    ans = 0
print(menseki,ans)


Fixed submission:
W,H,x,y = map(int,input().split())

menseki = W*H/2
if x==W/2 and y==H/2:
    ans = 1
else:
    ans = 0
print(menseki,ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]
def gdb(a,b):
    a,b = abs(a),abs(b)
    while b:
        a,b = b,a%b
    return a
def make_slope(a,b):
    if a==0:
        print("error")
    elif a>0:
        return(a//gdb(a,b),b//gdb(a,b))
    elif a<0:
        return(-1*a//gdb(a,b),-1*b//gdb(a,b))


slope_list = []
for i in range(1,N):
    for j in range(i):
        x1,y1 = XY[i]
        x2,y2 = XY[j]
        d_x = x2-x1
        d_y = y2-y1
        if d_x != 0:
            d_x,d_y = make_slope(d_x,d_y)
            if not([d_x,d_y] in slope_list):
                slope_list.append([d_x,d_y])

if N <= 2:
    print(1)
else:
    tmp = []
    for x,y in XY:
        if not (x in tmp):
            tmp.append(x)
    ans = len(tmp)

    for d_x,d_y in slope_list:
        XY_list = []
        for x1,y1 in XY:
            if XY_list == []:
                XY_list.append([x1,y1])
            else:
                for x2,y2 in XY_list:
                    d_x_tmp = x2-x1
                    d_y_tmp = y2-y1
                    if d_x_tmp == 0:
                        break
                    d_x_tmp,d_y_tmp = make_slope(d_x_tmp,d_y_tmp)
                    if d_x_tmp==d_x and d_y_tmp==d_y:
                        break
                else:
                    XY_list.append([x1,y1])
        ans = min(ans,len(XY_list))
    print(ans)


Fixed submission:
N,K = map(int,input().split())
if K==1:
    print(0)
else:          
    print(N-K)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
uvw = [[int(x) for x in input().split()] for _ in range(N-1)]

path = [[] for _ in range(N)]

ans = [-1]*N
ans[0] = 0

for u,v,w in uvw:
    path[u-1].append([v-1,w%2])
    path[v-1].append([u-1,w%2])
    
Q = [0]     
while Q:
    v = Q.pop(0)
    for p,d in path[v]:
        if ans[p] == -1:
            ans[p] = (ans[v]+d)%2
            Q.append(p)
            
for a in ans:
    print(a)


Fixed submission:
N = int(input())
uvw = [[int(x) for x in input().split()] for _ in range(N-1)]

path = [[] for _ in range(N)]

ans = [-1]*N
ans[0] = 0

for u,v,w in uvw:
    path[u-1].append([v-1,w%2])
    path[v-1].append([u-1,w%2])
    
Q = [0]     
while Q:
    v = Q.pop(-1)
    for p,d in path[v]:
        if ans[p] == -1:
            ans[p] = (ans[v]+d)%2
            Q.append(p)
            
for a in ans:
    print(a)

Buggy python submission (verdict: Runtime Error):
N = int(input())
uvw = [[int(x) for x in input().split()] for _ in range(N-1)]

par = [i for i in range(N)]
dist = [0]*N

def root(x):
    if(par[x]==x):
        return x
    else:
        return root(par[x])

def unite(x,y,z):
    rx = root(x)
    ry = root(y)
    if rx==ry:
        return
    else:
        par[rx] = ry
        dist[rx] = z%2

def dist_type(x):
    if(par[x]==x):
        return 0
    else:
        return (dist_type(par[x])+dist[x])%2

for u,v,w in uvw:
    unite(u-1,v-1,w%2)

for i in range(N):
    print(dist_type(i))


Fixed submission:
N = int(input())
uvw = [[int(x) for x in input().split()] for _ in range(N-1)]

path = [[] for _ in range(N)]

ans = [-1]*N
ans[0] = 0

for u,v,w in uvw:
    path[u-1].append([v-1,w%2])
    path[v-1].append([u-1,w%2])
    
Q = [0]     
while Q:
    v = Q.pop(-1)
    for p,d in path[v]:
        if ans[p] == -1:
            ans[p] = (ans[v]+d)%2
            Q.append(p)
            
for a in ans:
    print(a)