Problem:


Score : 100 points

Problem Statement

Takahashi is distributing N balls to K persons.

If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?

Constraints

1 \leq K \leq N \leq 100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the maximum possible difference in the number of balls received.

Sample Input 1

3 2

Sample Output 1

1

The only way to distribute three balls to two persons so that each of them receives at least one ball is to give one ball to one person and give two balls to the other person.

Thus, the maximum possible difference in the number of balls received is 1.

Sample Input 2

3 1

Sample Output 2

0

We have no choice but to give three balls to the only person, in which case the difference in the number of balls received is 0.

Sample Input 3

8 5

Sample Output 3

3

For example, if we give 1, 4, 1, 1, 1 balls to the five persons, the number of balls received between the person with the most balls and the person with the fewest balls would be 3, which is the maximum result.



Sample input:
3 2


Sample output:
1

Submission status: Runtime Error

Solution code:
n = int(input())
l = []
l2 = []

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

for i in range(n-1):
    for j in range(i+1, n):
        dif1 = l[i][0] - l[j][0]
        dif2 = l[i][1] - l[j][1]
        l2.append(str(dif1) + ' ' + str(dif2))
##print(l2)

try:
    cnt = max(l2, key=l2.count)
except:
    cnt = 0
x, y = list(map(int, cnt.split()))

ans = 0

for i in range(len(l)):
    if [l[i][0] + x, l[i][1] + y] in l:
        ans += 1

print(n - ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A_lis = list(map(int, input().split()))
B_lis = list(map(int, input().split()))

f = [(B_lis[_]/A_lis[_], A_lis[_], B_lis[_]) for _ in range(3)]

f.sort()
f.reverse()

rest = N
gain = 0

for j in range(3):
  if f[j][0] > 1.0:
    g = rest // f[j][1]
    rest -= g * f[j][1]
    gain += g * f[j][2]

print(gain+rest)

Submission status: Runtime Error

Solution code:
input_sample=iter("""
1
0 0
""".split("\n")[1:-1])

#問題を解く
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]

from collections import Counter
list_=[]

for i in range(N):
    for j in range(i+1,N):
        if xy[i][0]-xy[j][0]<0:
            list_.append((abs(xy[i][0]-xy[j][0]),abs(xy[i][1]-xy[j][1])))
        else:
            list_.append((xy[i][0]-xy[j][0],xy[i][1]-xy[j][1]))

if N==1:
    print(1)
else:
    print(N-Counter(list_).most_common()[0][1])

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
xy.sort()
h = defaultdict(int)
for x, y in xy:
    h[(x, y)] = True
mx, my = xy[-1]
ans = 10**10
for i in range(n-1):
    x1, y1 = xy[i]
    for j in range(i+1, n):
        x2, y2 = xy[i+1]
        z1 = x2-x1
        z2 = y2-y1

        t = set()
        k = 0
        a = 0
        while k < n and len(t) < n:
            xk, yk = xy[k]
            if (xk, yk) not in t:
                a += 1
                while xk <= mx and yk <= my:
                    if (xk, yk) in h:
                        t.add((xk, yk))
                    xk += z1
                    yk += z2
            k += 1
        if a < ans:
            ans = a

print(ans)

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
xy.sort()
h = defaultdict(int)
for x, y in xy:
    h[(x, y)] = True
mx, my = xy[-1]
ans = 10**10
for i in range(n-1):
    x1, y1 = xy[i]
    for j in range(i+1, n):
        x2, y2 = xy[i+1]
        z1 = x2-x1
        z2 = y2-y1

        t = set()
        k = 0
        a = 0
        while k < n and len(t) < n:
            xk, yk = xy[k]
            if (xk, yk) not in t:
                a += 1
                while xk <= mx and yk <= my:
                    if (xk, yk) in h and (xk, yk) not in t:
                        t.add((xk, yk))
                    xk += z1
                    yk += z2
            k += 1
        if a < ans:
            ans = a

print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
point=[]
merge=0
for num in range(0,N):
    x,y=map(int,input().split())
    point.append([x,y])
p=0
q=0
point.sort()
ans=0
for i in range(0,N-1):
    for j in range(i+1,N):
        p=point[j][0]-point[i][0]
        q=point[j][1]-point[i][1]
        merge=0
        for k in range(0,N):
            if([point[k][0]+p,point[k][1]+q] in point):
                merge+=1
        ans=max(ans,merge)
print(N-ans)

Submission status: Runtime Error

Solution code:
n = int(input())

li = []

for _ in range(n):
    x, y = list(map(int, input().split(" ")))
    li.append([x, y])

li.sort()

def cal(li):
    n = len(li)
    Route = []
    for s in range(n-1):
        x1, y1 = li[s]
        route = {}
        for i in range(s+1,n):
            xi, yi = li[i]

            if xi != x1:
                diff = (yi - y1)/(xi - x1)
            else:
                diff = 10e10

            if diff in route.keys():
                route[diff].append([xi, yi])
            else:
                route[diff] = [[x1,y1], [xi, yi]]

        Route.extend(route.values())
    return Route

cost = 0
route = cal(li)

def check(A,B):
    for a in A:
        if a not in B:
            return False
    
    return True

def max_cal(route, li):
    n = len(li)
    l_max = 0
    max_li = []
    for r in route:
        if check(r,li):
            l = len(r)
            if l > l_max:
                 max_li = r
                 l_max = l
    return l_max, max_li

while True:
    l, cand = max_cal(route, li)
    if l == 0:
        cost += len(li)-1
        break
    else:
        route.remove(cand)
        for c in cand:
            li.remove(c)
        n -= l
        cost += 1

print(cost)

Submission status: Runtime Error

Solution code:
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

counter = 0
for i in range(N):
    a = x[i]-x[0]
    b = y[i]-y[0]
    for j in range(1,N):
        for k in range(j,N):
            if a == x[j]-x[k] and b == y[j]-y[k]:
                counter += 1
if N==2:
  print(1)
else:
  print(counter-1)

Submission status: Runtime Error

Solution code:
a = "3"
b = "2"
print ("a" - "b")

Submission status: Runtime Error

Solution code:
n = int(input())
a_l = list(map(int, input().split()))
a_l.sort()
b_l = list()

length = len(a_l)
k = 0
for i in range(length):
  if a_l[i] < 0:
    k = i
  else:
    break

b_l = a_l[:k+1]
a_l = a_l[k+1:]
fu = len(b_l)
sei = len(a_l)
ans_l = list()
ans_ll = list()
if sei > fu:
  sa = sei-fu-1
  ans_ll.append(a_l[-1])
  for i in range(fu):
    ans_l.append([b_l[i], a_l[-i-2]])
    ans_ll.append(b_l[i]-a_l[-i-2])
  aa_l = a_l[:sa]
  aa = 0
  for i in range(len(aa_l)-1):
    ans_l.append([aa_l[i], aa_l[i+1]])
    aa = aa_l[i] - aa_l[i+1]
  ans_ll.append(aa)
  ans_ll.sort()
  lent = len(ans_ll)
  for i in range(lent-1):
    ans_l.append([ans_ll[-1], ans_ll[i]])
    ans_ll[-1] = ans_ll[-1]-ans_ll[i]
elif sei < fu:
  sa = fu-sei+1
  ans_ll += b_l[:sa]
  ans_ll.append(a_l[-1])
  b_l = b_l[sa:]
  for i in range(len(b_l)):
    ans_l.append([b_l[i], a_l[-i-2]])
    ans_ll.append(b_l[i]-a_l[-i-2])
  ans_ll.sort()
  lent = len(ans_ll)  
  for i in range(lent-1):
    ans_l.append([ans_ll[-1], ans_ll[i]])
    ans_ll[-1] = ans_ll[-1]-ans_ll[i]
else:
  for i in range(sei):
    if i == 0:
      ans_l.append([a_l[-i-1], b_l[i]])
      ans_ll.append(a_l[-i-1]-b_l[i])
    else:
      ans_l.append([b_l[i], a_l[-i-1]])
      ans_ll.append(b_l[i]-a_l[-i-1])
  ans_ll.sort()
  lent = len(ans_ll)  
  for i in range(lent-1):
    ans_l.append([ans_ll[-1], ans_ll[i]])
    ans_ll[-1] = ans_ll[-1]-ans_ll[i]
    
ans_length = len(ans_l)
print(ans_ll[-1])
for i in range(ans_length):
  a = ans_l[i][0]
  b = ans_l[i][1]
  print(a, b)

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
num = []*n
numint = []
num = input().split(' ')
for i in range(len(num)):
    numint.append(int(num[i]))
i = 0
x, y = int, int
word = []

numint = sorted(numint)
x = numint[0]
y = numint[1]
word.append(str(x) + " " + str(y))
numint.append(x - y)
numint.pop(0)
numint.pop(0)
while len(numint) > 2:
    numint = sorted(numint)
    x = numint[0]
    y = numint[1]
    if x < y:
        a, b = x, y
        x, y = b,a
    word.append(str(x) + " " + str(y))
    numint.append(x - y)
    numint.pop(0)
    numint.pop(0)
print(numint[0])
for i in range(len(word)):
    print(word[i])

Submission status: Runtime Error

Solution code:
from collections import deque
plusQ = deque([]) 
minsQ = deque([])
 
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
 
for itr, val in enumerate(A):
  if itr + 1 <= (len(A) // 2) and val > 0:
    plusQ.append(val)
  else:
    minsQ.append(val)

p1 = plusQ.popleft()
 
ans = deque([])
while len(minsQ) > 0:
  if len(plusQ) > 0:
    p, m = plusQ.popleft(), minsQ.popleft()
    ans.append([m, p])
    minsQ.append(m - p)    
  else:
    m = minsQ.popleft()
    ans.append([p1, m])
    p1 = p1 - m

print(p1)
while len(ans) > 0:
  hoge = ans.popleft()
  print(hoge[0],hoge[1])

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
minus=sum(a[0:n//2])
plus=sum(a)-minus
print(plus-minus)
if n%2==0:
 s=a[0]
 for i in range(1,n//2):
  print(a[n-i],s)
  s=a[n-i]-s
  print(a[i],s)
  s=a[i]-s
 print(a[n//2],s)
else:
 s=a[n-1]
 for i in range(n//2):
  print(a[i],s)
  s=a[i]-s
  print(a[n-(i+2)],s)
  s=a[n-(i+2)]-s

Submission status: Runtime Error

Solution code:
n = input()
n = int(n)
num = []*n
numint = []
num = input().split(' ')
for i in range(len(num)):
    numint.append(int(num[i]))
i = 0
x, y = int, int
word = []

numint = sorted(numint)
x = numint[0]
y = numint[1]
word.append(str(x) + " " + str(y))
numint.append(x - y)
numint.pop(0)
numint.pop(0)
while len(numint) > 1:
    numint = sorted(numint)
    x = numint[0]
    y = numint[1]
    if x < y:
        a, b = x, y
        x, y = b,a
    word.append(str(x) + " " + str(y))
    numint.append(x - y)
    numint.pop(0)
    numint.pop(0)
print(numint[0])
for i in range(len(word)):
    print(word[i])

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
A = sorted(A)
removeNums = []
for i in range(len(A)-1):
    newValue = A[0] - A[-1]
    removeNums.append((A[0], A[-1]))
    A.remove(A[0])
    A.remove(A[-1])
    A.insert(0, newValue)

print(-1*A[0])
for i in range(len(removeNums)-1):
    print(removeNums[i][0], removeNums[i][1])

print(removeNums[-1][1], removeNums[-1][0])

Submission status: Runtime Error

Solution code:
from collections import deque
def resolve():
    N = int(input())
    As = list(map(int, input().split(" ")))
    pos = []
    neg = []
    for a in As:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(a)
    pos = deque(sorted(pos))
    neg = deque(sorted(neg))
    x = 0
    y = 0
    ops = []
    while True:
        if len(pos) > 0 and len(neg) > 0:
            if len(pos) > len(neg):
                x = neg.popleft()
                y = pos.pop()
            else:
                x = pos.pop()
                y = neg.popleft()
        elif len(pos) > 1 and len(neg) == 0:
                x = pos.popleft()
                y = pos.pop()
        elif len(neg) > 1 and len(pos) == 0:
                x = pos.pop()
                y = pos.popleft()
        else:
            raise Exception("Unreachable?")
        
        ops.append("{} {}".format(x, y))
        xmy = x - y

        if len(pos) == 0 and len(neg == 0):
            print(xmy)
            break

        if xmy >= 0:
            pos.append(xmy)
        else:
            neg.appendleft(xmy)
        
    [print(i) for i in ops]

if '__main__' == __name__:
    resolve()

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
n = int(input())
a_l = list(map(int, input().split()))
a_l.sort()
b_l = list()

length = len(a_l)
k = 0
for i in range(length):
  if a_l[i] < 0:
    k = i
  else:
    break

b_l = a_l[:k+1]
a_l = a_l[k+1:]
fu = len(b_l)
sei = len(a_l)
ans_l = list()
ans_ll = list()
if sei > fu:
  sa = sei-fu-1
  ans_ll+= a_l[:sa]
  ans_ll.append(a_l[-1])
  for i in range(fu):
    ans_l.append([b_l[i], a_l[-i-2]])
    ans_ll.append(b_l[i]-a_l[-i-2])
  ans_ll.sort()
  lent = len(ans_ll)
  for i in range(lent-1):
    ans_l.append([ans_ll[-1], ans_ll[i]])
    ans_ll[-1] = ans_ll[-1]-ans_ll[i]
elif sei < fu:
  sa = fu-sei+1
  ans_ll += b_l[:sa]
  ans_ll.append(a_l[-1])
  for i in range(sei-1):
    ans_l.append([b_l[i], a_l[-i-2]])
    ans_ll.append(b_l[i]-a_l[-i-2])
  ans_ll.sort()
  lent = len(ans_ll)  
  for i in range(lent-1):
    ans_l.append([ans_ll[-1], ans_ll[i]])
    ans_ll[-1] = ans_ll[-1]-ans_ll[i]
else:
  for i in range(sei):
    if i == 0:
      ans_l.append([a_l[-i-1], b_l[i]])
      ans_ll.append(a_l[-i-1]-b_l[i])
    else:
      ans_l.append([b_l[i], a_l[-i-1]])
      ans_ll.append(b_l[i]-a_l[-i-1])
  ans_ll.sort()
  lent = len(ans_ll)  
  for i in range(lent-1):
    ans_l.append([ans_ll[-1], ans_ll[i]])
    ans_ll[-1] = ans_ll[-1]-ans_ll[i]
    
ans_length = len(ans_l)
print(ans_ll[-1])
for i in range(ans_length):
  a = ans_l[i][0]
  b = ans_l[i][1]
  print(a, b)

Submission status: Runtime Error

Solution code:
import collections
N = int(input())
x = []
for i in range(N):
	x.append(list(map(int, input().split())))
if N == 1:
	print(1)
else:
	L = []
	for i in range(N):
		a, b = x[i][0], x[i][1]
		for j in range(N):
			if a > x[j][0] or b > x[j][1]:
				L.append((a - x[j][0], b - x[j][1]))
	c = collections.Counter(L)
	max = c.most_common(1)[0][1]
	print(N - max)

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(n):
  a.append(input().split())
  a[i][0] = int(a[i][0])
  a[i][1] = int(a[i][1])
b = []
d = []
e = []
a.sort()
dic = {}
for i in range(n-1):
  if [a[i+1][0] - a[i][0], a[i+1][1] - a[i][1]] not in d:
    d.append([a[i+1][0] - a[i][0], a[i+1][1] - a[i][1]])
    e.append(1)
  else:
    e[d.index([a[i+1][0] - a[i][0], a[i+1][1] - a[i][1]])] += 1
# f = d[e.index(max(e))]
# p = f[0]
# q = f[1]
print(n-max(e))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
N = int(input())
A = [int(i) for i in input().split()]
if N == 2:
    print(max(A) - min(A))
    print(max(A), min(A))
else:
    A.sort()
    As = []
    t = A[0]
    for a in A[1:-1]:
        As.append([t, a])
        t = t - a
    ans = A[-1] - t
    As.append([A[-1], t])
    print(ans)
    for a in As:
        print(*a)

Submission status: Runtime Error

Solution code:
n=int(input())
p=[]
l=[]
for i in range(n):
    p.append(list(map(int,input().split())))
        


for i in range(n):
    for j in range(i+1,n):
        l.append([p[j][0]-p[i][0],p[j][1]-p[i][1],p[i][0],p[i][1]])

m=0
for i in range(len(l)):
    cnt=0
    acnt=0
    bcnt=0
    tmp=0
    for j in range(len(l)):
        if l[i][0]==0:
            tmp=l[i][3]
            if l[i][0]==l[j][0] and l[i][1]==l[j][1] and i!=j or l[i][0]==-l[j][0] and l[i][1]==-l[j][1] and i!=j:
                if tmp==l[j][3]:
                    acnt+=1
                    if acnt>m:
                        m=acnt
        if l[i][1]==0:
            tmp=l[i][2]
            if l[i][0]==l[j][0] and l[i][1]==l[j][1] and i!=j or l[i][0]==-l[j][0] and l[i][1]==-l[j][1] and i!=j:
                if tmp ==l[j][2]:
                    bcnt+=1
                    if bcnt>m:
                        m=bcnt
        if l[i][0]==l[j][0] and l[i][1]==l[j][1] and i!=j or l[i][0]==-l[j][0] and l[i][1]==-l[j][1] and i!=j:
            cnt+=1
            if cnt>m:
                m=cnt
        
ans=n
if m!=0:
    ans=n-m-1
if n==2:
    ans=1
print(ans)

Submission status: Runtime Error

Solution code:
# 残っているボールを1つ選んで回収、(a, b)
# (a-p, b-q) コスト0

import itertools

score = 1
p = 0
q = 0

n = int(input())
e = [[int(i) for i in input().split()] for i in range(n)]

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

arr = list(itertools.permutations(e))
for i, parent in enumerate(arr):
    if i == 0:
        for j, child in enumerate(parent):
            if j == 0:
                p = parent[j + 1][0] - child[0]
                q = parent[j + 1][1] - child[1]
                score = 1
                continue
            if not child[0] == parent[j-1][0] + p and not child[1] == parent[j - 1][1] + q:
                score += 1
    else:
        tmp_p = p
        tmp_q = q
        sc = score
        for j, child in enumerate(parent):
            if j == 0:
                p = parent[j + 1][0] - child[0]
                q = parent[j + 1][1] - child[1]
                score = 1
                continue
            if not child[0] == parent[j-1][0] + p and not child[1] == parent[j - 1][1] + q:
                score += 1
            if score > sc:
                p = tmp_p
                q = tmp_q
                score = sc
                continue

print(score)

Submission status: Runtime Error

Solution code:
n=int(input())
p=[]
l=[]
for i in range(n):
    p.append(list(map(int,input().split())))
        


for i in range(n):
    for j in range(i+1,n):
        l.append([p[j][0]-p[i][0],p[j][1]-p[i][1]])

m=0
for i in range(len(l)):
    cnt=0
    acnt=0
    bcnt=0
    tmp=0
    for j in range(len(l)):
        if l[i][0]==0:
            tmp=l[i][1]
            if l[i][0]==l[j][0] and l[i][1]==l[j][1] and i!=j or l[i][0]==-l[j][0] and l[i][1]==-l[j][1] and i!=j:
                if tmp==l[j][1]:
                    acnt+=1
                    if acnt>m:
                        m=acnt
        if l[i][1]==0:
            tmp=l[i][0]
            if l[i][0]==l[j][0] and l[i][1]==l[j][1] and i!=j or l[i][0]==-l[j][0] and l[i][1]==-l[j][1] and i!=j:
                if tmp ==l[j][0]:
                    bcnt+=1
                    if bcnt>m:
                        m=bcnt
        if l[i][0]==l[j][0] and l[i][1]==l[j][1] and i!=j or l[i][0]==-l[j][0] and l[i][1]==-l[j][1] and i!=j:
            cnt+=1
            if cnt>m:
                m=cnt
        
ans=n
if m!=0:
    ans=n-m-1
if n==2:
    ans=1
print(ans)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
if K = 1:
  print(0)
else:
  print(N - K)

Submission status: Runtime Error

Solution code:
import sys

def main(argv):
    result = 0
    ball = int(argv[0])
    people = int(argv[1])

    if people <= 1:
        return 0

    if ball > people:
        result = ball - people
        result += 1
        
    else:
        return 0

    result -= 1

    return result


if __name__ == '__main__':
    print(main(sys.argv[1:]))

Submission status: Runtime Error

Solution code:
a = 3,2
print "1"

Submission status: Runtime Error

Solution code:
    n,k = map(int,input().split())
    if k == 1:
      print(0)
    elif  k >= 2:
      print(n-k)

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np
costs = []
N = int(input())
x, y = [], []
# (x,y)の値を取得
for n in range(N):
    temp = list(map(int, input().split()))
    x.append(temp[0])
    y.append(temp[1])
# コスト計算
for n, perm in enumerate(itertools.permutations(zip(x,y), N)):
    sol = 0
    cost = 1
    for i in range(1, N):
        if i == 1:
            sol = [perm[i][0] - perm[i-1][0], perm[i][1] - perm[i-1][1]]
        else:
            if perm[i][0] - sol[0] == perm[i-1][0] and perm[i][1] - sol[1] == perm[i-1][1]:
                cost += 0
            else:
                cost += 1
    costs.append(cost)
print(np.min(costs))

Submission status: Runtime Error

Solution code:
from collections import Counter
N = int(input())
answer = []
answer2 = []
lis = []
lis2 = []
for i in range(N):
    x, y = map(int, input().split())
    lis.append([x, y])
    lis2.append([y, x])
sort_lis = sorted(lis)
sort_lis2 = sorted(lis2)

if N == 1:
    print(1)
    exit()
for i in range(N-1):
    answer.append([sort_lis[i][0] -sort_lis[i+1][0],sort_lis[i][1]-sort_lis[i+1][1]])
    answer2.append([sort_lis2[i][0] -sort_lis2[i+1][0],sort_lis2[i][1]-sort_lis2[i+1][1]])
ans = list(map(tuple,answer))
#print(ans)
ans2 = list(map(tuple,answer2))
#print(ans2)
a = Counter(ans).most_common()
#print(a)
a2 = Counter(ans2).most_common()
#print(a2)
if a[0][1] > a2[0][1]:
    c = 1
    for i in range(1,len(a)):
        c += a[i][1]
else:
    c = 1
    for i in range(1,len(a2)):
        c += a2[i][1]
print(c)

Submission status: Runtime Error

Solution code:

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

cross = []

##計算量に余裕があるので全探索します
for i in range(N):
    for j in range (i+1, N):
        a = [li[j][0]-li[i][0],li[j][1]-li[i][1]]
        cross.append(a) 

lencross = len(cross)

res = 0
ans = []

for i in range (lencross):
    res = 0
    for j in range (lencross):
        if cross[i] == cross[j]:
            res += 1
    ans.append(res)
if N-1 < max(ans):
    reduce = N-1
else:
    reduce = max(ans)

if N != 1:
    print(N - reduce)
else:
    print(1)

Submission status: Runtime Error

Solution code:
n,k= [int(i) for i in input().split()]
if k==1:
    return 0
else:
    return n-k

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
c=a-b
if k != 1:
	print(c)
else:
	print(0)

Submission status: Runtime Error

Solution code:
n = int(input())
a = input().split()

for i in range(len(a)):
    a[i] = int(a[i])

x = 0
y = 0

operations = []

for i in range(n-2):
    a_sorted = sorted(a)
    x = a_sorted[0]
    y = a_sorted[1]

    a.remove(x)
    a.remove(y)
    a.append(x-y)
    operations.append(str(x) + " " + str(y))

a_sorted_reverse = sorted(a_sorted, reverse=True)
x = a_sorted_reverse[0]
a.remove(x)
y = sorted(a)[0]
operations.append(str(x) + " " + str(y))


a.remove(x)
if y in a:
    a.remove(y)
a.append(x-y)

print(sorted(a, reverse=True)[0])
for i in operations:
    print(i)

Submission status: Runtime Error

Solution code:
i=True
while i:
  
  N,K=map(int,input().split())
  
  if N > K:
  
  	wide = N - K
  
  elif N = K:
    
    wide = 0
    
  else:
    
    wide = 1
    
print(wide)

Submission status: Runtime Error

Solution code:
import sys
from fractions import gcd
N = int(input())
arr = []

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

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

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

C = []
for i in range(N):
    for j in range(N):
        if i < j:
            x = arr[i][0]-arr[j][0]
            y = arr[i][1]-arr[j][1]
            g = gcd(x, y)
            x = int(x / g)
            y = int(y / g)
            C.append([x, y])

C = get_unique_list(C)
S = [0 for i in range(len(C))]

for c in range(len(C)):
    tmp = [[arr[0][0], arr[0][1]]]
    for i in range(1, N):
        l = len(tmp)
        for j in range(l):
            if C[c][0] == 0:
                if (tmp[j][1] - arr[i][1])%C[c][1] == 0:
                    pass
                else:
                    tmp.append([arr[i][0], arr[i][1]])

            elif C[c][1] == 0:
                if (tmp[j][0] - arr[i][0])%C[c][0] == 0:
                    pass
                else:
                    tmp.append([arr[i][0], arr[i][1]])
            else:
                if (tmp[j][0] - arr[i][0])%C[c][0] == 0 and (tmp[j][1] - arr[i][1])%C[c][1] == 0:
                    pass
                else:
                    tmp.append([arr[i][0], arr[i][1]])
    S[c] = len(tmp)

print(min(S))

Submission status: Runtime Error

Solution code:
n=list(map(int,input().split(" ")))

if n[1]==1:
    return 0
else:
    return n[0]-n[1]

Submission status: Runtime Error

Solution code:
i=True

while i:
  
  N,K=map(int,input().split())
  
  if N > K:
  
  	wide = N - K
  
  elif N = K:
    
    wide = 0
    
  else:
    
    wide = 1
    
  print(wide)

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
a = list()
for _ in range(n):
    a.append(list(map(int, input().split())))
if n in [1,2]:
    print(1)
else:
    a.sort()
    diff = list()
    for i in range(len(a) - 1):
        for j in range(i+1, len(a)):
            x = a[j][0]-a[i][0]
            y = a[j][1]-a[i][1]
            if x<0 and y<0:
                z = (-x,-y)
            elif x<0 and y>0:
                z = (-x,-y)
            else:
                z = (x,y)
            diff.append(z)
    t_diff = Counter(diff).most_common(1)[0][1]
    print(n-t_diff)

Submission status: Runtime Error

Solution code:
n=int(input().split(" "))

if n[1]==1:
    return 0
else:
    return n[0]-n[1]

Submission status: Runtime Error

Solution code:
from collections import Counter
n = int(input())
a = list()
for _ in range(n):
    a.append(list(map(int, input().split())))
if n in [1,2]:
    print(1)
else:
  a.sort()
    diff = list()
    for i in range(len(a) - 1):
        for j in range(i+1, len(a)):
            x = a[j][0]-a[i][0]
            y = a[j][1]-a[i][1]
            if x<0 and y<0:
                z = (-x,-y)
            elif x<0 and y>0:
                z = (-x,-y)
            else:
                z = (x,y)
            diff.append(z)
    t_diff = Counter(diff).most_common(1)[0][1]
    print(n-t_diff)

Submission status: Runtime Error

Solution code:
N = int(raw_input())
K = int(raw_input())

if K ==1:
      print(0)
else:
      print(N-K)

Submission status: Runtime Error

Solution code:
N = int(input())

if N == 1:
    print(1)
else:
    point = []
    for i in range(N):
        x,y = map(int,input().split())
        point.append([x,y])

    vec = []
    for i in range(N):
        for j in range(i+1,N,1):
            vec.append([point[i][0]-point[j][0],point[i][1]-point[j][1]])

    N2 = len(vec)
    check = [0 for i in range(N2)]

    for i in range(N2):
        for j in range(N2):
            minus = [-vec[j][0],-vec[j][1]]
            if vec[i] == vec[j] or vec[i] == minus:
                check[i] += 1

    print(N-max(check))

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())

if N > K:
  
  wide = N - K
  
elif N = K:
  
  wide = 0
  
else:
  wide = 1
  
print(wide)

Submission status: Runtime Error

Solution code:
N = int(raw_input())
K = int(raw_input())

if K ==1:
      print(0)
else:
      print(N-K)

Submission status: Runtime Error

Solution code:
n,k=input().split(" ")
n,k_int=map(int,n,k)
if k==1:
    return 0
else:
    return n-k

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    n = int(input())
    ball = [list(map(int, input().split(' '))) for i in range(n)]
    ball = np.array(ball, dtype=int)
    # print(ball)

    l1 = []
    l2 = []
    for i in range(n):
        for j in range(i, n):
            if i == j: continue
            dis1 = ball[i] - ball[j]
            dis2 = ball[j] - ball[i]
            l1.append(list(dis1))
            l2.append(list(dis2))
    # print(l1, l2)
    # c1 = collections.Counter(l1)
    # c2 = collections.Counter(l2)

    c1 = []
    c2 = []
    for i in range(len(l1)):
        c1.append(l1.count(l1[i]))
        c2.append(l2.count(l2[i]))
    m1 = np.max(np.array(c1, dtype=int))
    m2 = np.max(np.array(c2, dtype=int))

    print(max(1,n-max(m1,m2)))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split(" ")
if k==1:
    return 0
else:
    return n-k

Submission status: Runtime Error

Solution code:
import numpy as np
import collections

def main():
    n = int(input())
    ball = [list(map(int, input().split(' '))) for i in range(n)]
    ball = np.array(ball, dtype=int)
    # print(ball)

    l1 = []
    l2 = []
    for i in range(n):
        for j in range(i, n):
            if i == j: continue
            dis1 = ball[i] - ball[j]
            dis2 = ball[j] - ball[i]
            l1.append(list(dis1))
            l2.append(list(dis2))
    # print(l1, l2)
    # c1 = collections.Counter(l1)
    # c2 = collections.Counter(l2)

    c1 = []
    c2 = []
    for i in range(len(l1)):
        c1.append(l1.count(l1[i]))
        c2.append(l2.count(l2[i]))
    m1 = np.max(np.array(c1, dtype=int))
    m2 = np.max(np.array(c2, dtype=int))

    print(max(1,n-max(m1,m2)))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
if k==1:
    return 0
else:
    return n-k

Submission status: Runtime Error

Solution code:
n,k=input().split(" ")
if k==1:
    return 0
else:
    return n-k

Submission status: Runtime Error

Solution code:
s = list(map(int, input().split()))
if (s[1] == 1:
    ans = s[0] - s[1]
    print(ans)
else:
    print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[1] >= 0:
	print(sum(A) - 2 * A[0])
	y = A[0]
	for i in range(N - 2):
		print(y, A[i + 1])
		y -= A[i + 1]
	print(A[-1], y)
elif A[-1] < 0:
	print(-sum(A) + 2 * A[-1])
	y = A[-1]
	for i in range(N - 1):
		print(y, A[i])
		y -= A[i]
else:
	for i in range(N - 1):
		if A[i] < 0 and A[i + 1] >= 0:
			n = i
	print(-sum(A[:i]) + sum(A[i:]))
	y = A[0]
	for i in range(N - n - 2):
		print(y, A[-i - 2])
		y -= A[-i - 2]
	print(A[-1], y)
	y = A[-1] - y
	for i in range(n):
		print(y, A[i + 1])

Submission status: Runtime Error

Solution code:
import collections
N = int(input())
A = []
B = []
YHASHNUM = 1000000000
for i in range(N):
    A.append(list(map(int, input().split())))
#print(N, A)
if N == 1:
    print(1)
else:
    for i in A:
        #print(i[0], i[1])
        for j in A:
            if i == j:
                continue
            B.append(i[0] - j[0] + (i[1] - j[1]) * YHASHNUM)
    #print(B)
    C = collections.Counter(B)
    print(N - C.most_common()[0][1])