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:
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define reps(i, s, n) for (i64 i = s; i < (i64)(n); ++i)

void solve() {
    int n, k;
    cin >> n >> k;
    int ans = (k != 1 ? n - k : 0);
    cout << ans << "\n";
}
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Submission status: Runtime Error

Solution code:
from collections import defaultdict, deque
import sys
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
A = sorted(inpl())

print(sum(map(abs, A[1:])) - A[0])
for i in range(N-2, 0, -1):
  a = A[i]
  if a > 0:
    print(A[0], a)
    A[0] -= a
    else:
      print(A[-1], a)
      A[-1] -= a
      print(A[-1], A[0])

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:
n,k=map(int,input().split())

if k=1:
    print('0')

else:

    ans=n-k
    print(ans)

Submission status: Runtime Error

Solution code:
from itertools import combinations
from collections import Counter


def main():
    n = int(input())
    if n == 1:
        print(1)

    XY = [list(map(int, input().split())) for _ in range(n)]
    d = []
    for A, B in combinations(XY, 2):
        x1, y1 = A[0], A[1]
        x2, y2 = B[0], B[1]
        p, q = x2 - x1, y2 - y1
        d.append((p, q))
        d.append((-p, -q))

    # print(d)
    # print(Counter(d))

    C = Counter(d)
    ans = 0
    for v in C.values():
        ans = max(ans, v)
    print(n-ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n,k = int(input()),int(input())
if n == k or n == 1:
  print(0)
else:
  print(n-k)

Submission status: Runtime Error

Solution code:
from collections import defaultdict
n=int(input())
M=[]
for i in range(n):
    x,y=map(int,input().split())
    M.append([x,y])
M.sort(key=lambda x:(x[0],x[1]))
X=defaultdict(int)
for i in range(n-1):
    for j in range(i+1,n):
        a=M[i][0]-M[j][0]
        b=M[i][1]-M[j][1]
        X[(a,b)]+=1
print(n-max(X.values(),default=0))

Submission status: Runtime Error

Solution code:
n,k=gets.split.map(&:to_i);p k==1?0:n-k

Submission status: Runtime Error

Solution code:
n,k=gets.split.map &:to_i;p k==1?0:n-k

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

dp = [0] * (N + 1)
for i in range(N, -1, -1):
  for j in range(3):
    x = a[j]
    y = b[j]
    if i - x >= 0:
      dp[i - x] = max(dp[i - x], dp[i] + y)
for i in range(N + 1): dp[i] += i
#print(dp)
t = max(dp)
e = []
def check(x):
  tt = t - b[e[0]] * x
  return (tt // b[e[1]]) * a[e[1]] + tt % b[e[1]] + a[e[0]] * x

if t > N:
  for i in range(3):
    if b[i] < a[i]: e.append(i)
  if len(e) == 0:
    print(t)
  elif len(e) == 1:
    print(a[e[0]] * (t // b[e[0]]) + t % b[e[0]])
  else:
    if b[e[0]] < b[e[1]]: e[0], e[1] = e[1], e[0]
    x = e[0]
    res = 0
    for i in range(t // b[x] + 1): res = max(res, check(i))
    print(res)
else:
  dp = [0] * (N + 1)
  for i in range(N, -1, -1):
    for j in range(3):
      y = a[j]
      x = b[j]
    if i - x >= 0:
      dp[i - x] = max(dp[i - x], dp[i] + y)
  for i in range(N + 1): dp[i] += i
  print(max(dp))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

fn main() {
    let nk: Vec<u32> = read_vec();
    let (n, k) = (nk[0], nk[1]);
    
    let ans = n % k;
    println!("{}", ans);
}


// ########################################################################################### //

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0;
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}

Submission status: Runtime Error

Solution code:
package main

import "fmt"


func main() {
	var N, K int
	fmt.Scan(&N, &K)
	a := N % K
	if a == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(1)
	}
}

Submission status: Runtime Error

Solution code:
from collections import Counter
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]
xy.sort()

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

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

print(Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common())
print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])

Submission status: Runtime Error

Solution code:
def sub(A, D):
    A.sort()
    for i in range(len(A)):
        D[tuple([i])] = (A[i], None), (A[i], None)
    stuff = [[i for i in range(j)] for j in range(2, len(A) + 1)]
    for key in stuff:
        min_sub_list = []
        max_sub_list = []
        key_i = list(key)
        index = key_i.pop()
        ikey = tuple(key_i)
        res_min_i, res_max_i = D[ikey]
        a_i = A[index]
        b_i_min, pair_i_min = res_min_i
        b_i_max, pair_i_max = res_max_i
        min_sub_list.append((-abs(a_i - b_i_min), (a_i, b_i_min, pair_i_min)))
        min_sub_list.append((-abs(a_i - b_i_max), (a_i, b_i_max, pair_i_max)))
        max_sub_list.append((abs(a_i - b_i_min), (a_i, b_i_min, pair_i_min)))
        max_sub_list.append((abs(a_i - b_i_max), (a_i, b_i_max, pair_i_max)))
        res_min = min(min_sub_list)
        res_max = max(max_sub_list)
        D[tuple(key)] = res_min, res_max


def pair_extract(p, pair_list):
    while p is not None:
        a = p[0]
        b = p[1]
        p_next = p[2]
        pair_list.append((a, b))
        p = p_next


N = int(input())
A_temp = map(int, input().split())
A = list(A_temp)
D = {}
sub(A, D)
res_max = D[tuple([i for i in range(len(A))])][1]
max_val = res_max[0]
pair_list = []
pair_extract(res_max[1], pair_list)
pair_list.reverse()
print(max_val)
for p in pair_list:
    print(p[0], p[1])

Submission status: Runtime Error

Solution code:
import itertools


def comb_gen(stuff, k, n):
    for L in range(k, min(n + 1, len(stuff) + 1)):
        for subset in itertools.combinations(stuff, L):
            yield subset


def sub(A, D):
    for i in range(len(A)):
        D[tuple([i])] = (A[i], None), (A[i], None)
    stuff = [[i for i in range(j)] for j in range(3, len(A) + 1)]
    for key in stuff:
        min_sub_list = []
        max_sub_list = []
        for i in range(len(key)):
            key_i = list(key)
            index = key_i.pop(i)
            ikey = tuple(key_i)
            res_min_i, res_max_i = D[ikey]
            a_i = A[index]
            b_i_min, pair_i_min = res_min_i
            b_i_max, pair_i_max = res_max_i
            min_sub_list.append((-abs(a_i - b_i_min), (a_i, b_i_min, pair_i_min)))
            min_sub_list.append((-abs(a_i - b_i_max), (a_i, b_i_max, pair_i_max)))
            max_sub_list.append((abs(a_i - b_i_min), (a_i, b_i_min, pair_i_min)))
            max_sub_list.append((abs(a_i - b_i_max), (a_i, b_i_max, pair_i_max)))
        res_min = min(min_sub_list)
        res_max = max(max_sub_list)
        D[tuple(key)] = res_min, res_max


def pair_extract(p, pair_list):
    if p is not None:
        a = p[0]
        b = p[1]
        p_next = p[2]
        pair_list.append((a, b))
        pair_extract(p_next, pair_list)


N = int(input())
A_temp = map(int, input().split())
A = list(A_temp)
D = {}
sub(A, D)
res_max = D[tuple([i for i in range(len(A))])][1]
max_val = res_max[0]
pair_list = []
pair_extract(res_max[1], pair_list)
pair_list.reverse()
print(max_val)
for p in pair_list:
    print(p[0], p[1])

Submission status: Runtime Error

Solution code:
def sub(A):
    if len(A) == 1:
        return (A[0], None), (A[0], None)
    min_sub_list = []
    max_sub_list = []
    for i in range(len(A)):
        A_i = A.copy()
        a_i = A_i.pop(i)
        res_min_i, res_max_i = sub(A_i)
        b_i_min, pair_i_min = res_min_i
        b_i_max, pair_i_max = res_max_i
        min_sub_list.append((-abs(a_i - b_i_min), (a_i, b_i_min, pair_i_min)))
        min_sub_list.append((-abs(a_i - b_i_max), (a_i, b_i_max, pair_i_max)))
        max_sub_list.append((abs(a_i - b_i_min), (a_i, b_i_min, pair_i_min)))
        max_sub_list.append((abs(a_i - b_i_max), (a_i, b_i_max, pair_i_max)))
    res_min = min(min_sub_list)
    res_max = max(max_sub_list)
    return res_min, res_max


def pair_extract(p, pair_list):
    if p is not None:
        a = p[0]
        b = p[1]
        p_next = p[2]
        pair_list.append((a, b))
        pair_extract(p_next, pair_list)


N = int(input())
A_temp = map(int, input().split())
A = list(A_temp)
_, res_max = sub(A)
max_val = res_max[0]
pair_list = []
pair_extract(res_max[1], pair_list)
pair_list.reverse()
print(max_val)
for p in pair_list:
    print(p[0], p[1])

Submission status: Runtime Error

Solution code:
def perm_generate(p, a, k=0):
  if k == len(a):
    p.append(a)
  else:
    for i in range(k, len(a)):
      a[k], a[i] = a[i], a[k]
      perm_generate(p, a, k + 1)
      a[k], a[i] = a[i], a[k]

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


def cost_pq(p, q, x, y, perm):
  cost_list = []
  for k in perm:
    cost = 0
    for j in k:
      existed = False
      for i in range(j):
        if x[j] - p == x[i] and y[j] - q == y[i]:
          existed = True
          break
      if not existed:
        cost = cost + 1
    cost_list.append((cost, k))
  return min(cost_list)


def min_cost(x, y, perm):
  min_cost_list = []
  for p in range(-max(x), max(x)):
    for q in range(-max(y), max(y)):
      c_pq, k_pq = cost_pq(p, q, x, y, perm)
      min_cost_list.append((c_pq, (p, q, k_pq)))
  return min(min_cost_list)


result = min_cost(x, y, perm)
print(result[0])

Submission status: Runtime Error

Solution code:
from itertools import permutations

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


def cost_pq(p, q, x, y, perm):
  cost_list = []
  for k in perm:
    cost = 0
    for j in k:
      existed = False
      for i in range(j):
        if x[j] - p == x[i] and y[j] - q == y[i]:
          existed = True
          break
      if not existed:
        cost = cost + 1
    cost_list.append((cost, k))
  return min(cost_list)


def min_cost(x, y, perm):
  min_cost_list = []
  for p in range(-max(x), max(x)):
    for q in range(-max(y), max(y)):
      c_pq, k_pq = cost_pq(p, q, x, y, perm)
      min_cost_list.append((c_pq, (p, q, k_pq)))
  return min(min_cost_list)


result = min_cost(x, y, perm)
print(result[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def dfs():
    n = int(input())
    weight = list(map(int, input().split()))
    value = list(map(int, input().split()))
    
    
    def knapsack(n, weight, value):
        dp = [i for i in range(n+1)]
        for i in range(3):
            for j in range(weight[i], n+1):
                dp[j] = max(dp[j], dp[j-weight[i]] + value[i])
        return(dp[-1])
    
    
    new_n=knapsack(n=n, weight=weight, value=value)
    print(knapsack(n=new_n, weight=value, value=weight))
 
    
dfs()

Submission status: Runtime Error

Solution code:
def dfs():
    n = int(input())
    weight = list(map(int, input().split()))
    value = list(map(int, input().split()))

    dp = [i for i in range(n+1)]

    for i in range(3):
        for j in range(weight[i], n+1):
            max(dp[j], dp[j-weight[i]] + value[i])
    return (dp[-1])
  
  
  dfs()

Submission status: Runtime Error

Solution code:
S = input()

S = list(map(int, input().split()))

N = S[0]
K = S[1]


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

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
input = sys.stdin.readline

def F(N,A,B):
    AB = list(zip(A,B))
    AB = [(a,b) for a,b in AB if a < b] # 有用なやつだけ
    AB.sort(key = lambda x: x[1]/x[0], reverse = True)
    if len(AB) == 0:
        return N
    if len(AB) == 1:
        a,b = AB[0]
        x = N//a
        return N + (b-a) * x
    if len(AB) == 2:
        (a,b),(c,d) = AB
        # 2種類目の硬価はa回未満しか使わない：ac個はa優先なので
        return max(N + (N - i * c) // a * (b-a) + i * (d-c) for i in range(M))
    # 効率の良いものから並んでいる
    dp = [0] * (N+1)
    for n in range(N+1):
        x = n
        for a,b in AB:
            if n >= a:
                y = dp[n-a] + b
                if x < y:
                    x = y
        dp[n] = x
    return dp[N]

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

answer = F(F(N,A,B),B,A)
print(answer)

Submission status: Runtime Error

Solution code:
N, L = [int(_) for _ in raw_input()]
if L == 1:
  print 0
else:
  print N - L

Submission status: Runtime Error

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

if a[0]>=0:
    g=sum(a[1:])-a[0]
    print(g)
    for i in range(n-1):
        if len(a)>2:
            print(str(a[0])+" "+str(a[-1]))
            a[0]-=a[-1]
            a.remove(a[-1])
        else:
            print(str(a[1])+" "+str(a[0]))
    
elif a[-1]<=0:
    g=a[-1]-sum(a[:-1])
    print(g)
    for i in range(n-1):
        print(str(a[-1])+" "+str(a[0]))
        a[-1]-=a[0]
        a.remove(a[0])
else:
    g=0 
    for i in range(n):
        g+=abs(a[i])
    print(g)
    for _ in range(n-1):
        if a[-2]>=0:
            print(str(a[0])+" "+str(a[-1]))
            a[0]-=a[-1]
            a.remove(a[-1])
        else:
            print(str(a[-1])+" "+str(a[0]))
            a[-1]-=a[0]
            a.remove(a[0])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fractions
N = int(input())
sheet = []
for i in range(N):
  line = input().split()
  sheet+=[(int(line[0]), int(line[1]))]
dic = {}
for i in range(N):
  start = sheet[i]
  for j in range(i+1, N):
    vec = [(sheet[j][0]-start[0]), (sheet[j][1]-start[1])]
    size = fractions.gcd(vec[0],vec[1])
    vec[0] = vec[0]//size
    vec[1] = vec[1]//size
    vec = tuple(vec)
    if vec not in dic.keys():
      dic[vec] = set([j])
    else:
      dic[vec].add(j)
m = 1
for s in dic.values():
  if len(s)>m:
    m = len(s)
print(N-m)

Submission status: Runtime Error

Solution code:
function a(N,K){
 if K==1
  return N
 return N-K
}

Submission status: Runtime Error

Solution code:
from sys import stdin
l = stdin.readline().rstrip().split()

n = int(l[0])
k=int(l[1])

if k == 1:
    print 0;
else:
    print n-k

Submission status: Runtime Error

Solution code:
s = input().split(",")
n = int(s[0])
k=int(s[1])

if k == 1:
    return 0;
else:
    return n-k

Submission status: Runtime Error

Solution code:
(lambda n,k: print(0 if k==1 else n-k))(*map(int,input().split())

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
if k == 1:
  print(0)
else:
  print(x-y)

Submission status: Runtime Error

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

print(N - K)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
anslist = []

for i in range(1,n-1):
  if a[i] < 0:
    anslist.append([a[-1], a[i]])
    a[-1] -= a[i]
  else:
    anslist.append([a[0], a[i]])
    a[0] -= a[i]
anslist.append([a[-1], a[0]])
ans = a[-1]-a[0]
print(ans)
for i in range(len(anslist)):
  print(anslist[i][0], anslist[i][1])

Submission status: Runtime Error

Solution code:
n = int(input())
cost = 0
points = []
for i in range(n):
    xy = input().split()
    x = int(xy[0])
    y = int(xy[1])
    points.append((x,y))
#points.sort()
while len(points) != 0:
    p = points[-1][0] - points[-2][0]
    q = points[-1][1] - points[-2][1]
    xn = points[-1][0] - p
    yn = points[-1][1] - q
    cost +=1
    points.pop()
    print(p, " ", q)
    while len(points) != 0:
        if points[-1][0] == xn and points[-1][1] == yn:
            xn = points[-1][0] - p
            yn = points[-1][1] - q
            points.pop()
        else:
            break

print(cost)

Submission status: Runtime Error

Solution code:
x = input()
(N, K) = (int(x[0]), int(x[2]))
max_distribution = N - K
if K == 1:
    max_distribution = 0
print(max_distribution)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if(K==1 or N==K):
  return 0
return N-K

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())

if k == 1:
    print("0")

else:
    print(n - k)

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())

diff = n - k

if k == 1:
    print("0")

print(diff)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

if K==1 or N < K or N==K :
  print("0")
else : 
  print(N % K)

Submission status: Runtime Error

Solution code:
N,K = input.split()
if K==1 :
  print("0")
else : 
  print(N%K)

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

N = sys.argv[1]
K = sys.arge[2]

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

Submission status: Runtime Error

Solution code:
from itertools import combinations
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
X, Y = list(map(list, zip(*XY)))

P = [abs(x1 - x2) for x1, x2 in combinations(X, 2)]
P = list(set(P))
Q = [abs(y1 - y2) for y1, y2 in combinations(Y, 2)]
Q = list(set(Q))
ans = 10**10
XY.sort()
for p in P:
    for q in Q:
        S = set()
        la = 0
        for x, y in XY:
            if (x, y) not in S:
                la += 1
            S.add((x+p, y+q))
        ans = min(ans, la)
        S = set()
        la = 0
        for x, y in XY:
            if (x, y) not in S:
                la += 1
            S.add((x+p, y-q))
        ans = min(ans, la)
print(ans)

Submission status: Runtime Error

Solution code:
a,b=[int(i) for i in input().split()]
if b=1:
  print(0)
else:
  print(a-b)

Submission status: Runtime Error

Solution code:
import math

#n = int(input())
n, k = [int(i) for i in input().split()]
#table = [[i for i in input().split()] for n in range(h)]
#table = [list(input()) for n in range(h)]
#list = [int(i) for i in input().split()]
#s = input()
#list = list(s)

#s = [int(input()) for i in range(m)] #m行1列入力

if (k = 1) :
    kotae = 0
else :
    kotae = n - k

print(kotae)

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 = sorted(a)
a_sorted_reverse = sorted(a_sorted, reverse=True)
x = a_sorted_reverse[0]
a_sorted_reverse.remove(x)
a_sorted = sorted(a_sorted_reverse)
y = a_sorted[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:
N = int(input())
xy = []
x = []
y = []
for i in range(N):
  xi,yi = map(int,input().split())
  xy.append([xi,yi])
  x.append(xi)
  y.append(yi)

res = []
count = 0
for i in range(N):
  for j in range(i+1,N):
#コストの和の最小値を求める
#これ以上進めない点が何個あるか数えれば良い
    p = x[i] - x[j]
    q = y[i] - y[j]
    count = 0
    for item in xy:
      if [item[0]+p,item[1]+q] not in xy:
        count += 1
    if count != 0: res.append(count)


print(min(res))

Submission status: Runtime Error

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

A = sorted(A)

count_m = 0
count_z = 0
count_p = 0
sum_abs = 0

for i in range(N):
    if A[i] < 0:
        count_m += 1
        sum_abs -= A[i]
    elif A[i] == 0:
        count_z += 1
    else:
        count_p += 1
        sum_abs += A[i]

if count_m + count_z == 0:
    print(sum_abs-2*min(A))
    tmp = A[0]
    for i in range(N-2):
        print(tmp, A[i+1])
        tmp -= A[i+1]
    print(A[-1], tmp)

elif count_p + count_z == 0:
    print(sum_abs+2*max(A))
    tmp = A[-1]
    for i in range(N-1):
        print(tmp, A[i])
        tmp -= A[i]

elif count_p + count_m == 0:
    print(0)
    for i in range(N-1):
        print(0, 0)

elif count_z > 0:
    print(A[2*N])
    print(sum_abs)
    cmz = count_m + count_z
    tmp = A[-1]
    for i in range(cmz - 1):
        print(tmp, A[i])
        tmp -= A[i]
    tmp_2 = A[cmz-1]
    for i in range(count_p-1):
        print(tmp_2, A[i+cmz])
        tmp_2 -= A[i+cmz]
    print(tmp, tmp_2)

elif count_z == 0:
    print(sum_abs)
    cmz = count_m + count_z
    tmp = A[-1]
    for i in range(cmz - 1):
        print(tmp, A[i])
        tmp -= A[i]
    tmp_2 = A[cmz-1]
    for i in range(count_p-1):
        print(tmp_2, A[i+cmz])
        tmp_2 -= A[i+cmz]
    print(tmp, tmp_2)

Submission status: Runtime Error

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

A = sorted(A)

count_m = 0
count_z = 0
count_p = 0
sum_abs = 0

for i in range(N):
    if A[i] < 0:
        count_m += 1
        sum_abs -= A[i]
    elif A[i] == 0:
        count_z += 1
    else:
        count_p += 1
        sum_abs += A[i]

if count_m + count_z == 0:
    print(sum_abs-2*min(A))
    tmp = A[0]
    for i in range(N-2):
        print(tmp, A[i+1])
        tmp -= A[i+1]
    

elif count_p + count_z == 0:
    print(sum_abs+2*max(A))
    tmp = A[-1]
    for i in range(N-1):
        print(tmp, A[i])
        tmp -= A[i]

elif count_p + count_m == 0:
    print(0)
    for i in range(N-1):
        print(0, 0)

else:
    print(A[2*N])
    print(sum_abs)
    cmz = count_m + count_z
    tmp = A[-1]
    for i in range(cmz - 1):
        print(tmp, A[i])
        tmp -= A[i]
    tmp_2 = A[cmz-1]
    for i in range(count_p-1):
        print(tmp_2, A[i+cmz])
        tmp_2 -= A[i+cmz]
    print(tmp, tmp_2)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
dp=[N]*(N+1)
#dp[i];=i個目まで選んで交換したときの最大
C=[B[i]-A[i] for i in range(3)]
for i in range(N):
    dp[i+1]=max(dp[i+1],dp[i])
    for j in range(3):
        if i+1-A[j]>=0:
            dp[i+1]=max(dp[i+1],dp[i+1-A[j]]+C[j])
M=dp[N]
dp=[0]*(M+1)
C=[A[i]-B[i] for i in range(3) if A[i]-B[i]>=0]
for i in range(M):
    dp[i+1]=max(dp[i+1],dp[i])
    for j in range(len(C)):
        if i+1-B[j]>=0:
            dp[i+1]=max(dp[i+1],dp[i+1-B[j]]+C[j])
print(M+dp[M])

Submission status: Runtime Error

Solution code:
def func(a,b):
  # a = N > b = K
  if b <= 1
  	return 0
  else:
    return a-b

  
i = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる
func(i[0], i[1])

Submission status: Runtime Error

Solution code:
N = int(input())
x = []
y = []
for _ in range(N):
  inp = input().split(' ')
  x += inp[0]
  y += inp[1]
x = list(map(int, x))
y = list(map(int, y))

pq = {}
for i in range(N):
  for j in range(N):
    if i == j:
      break
    
    xydif = (x[i]-x[j], y[i]-y[j])
    
    if xydif not in pq:
      pq[xydif] = 1
    else:
      pq[xydif] += 1

print(N - max(pq.values()))

Submission status: Runtime Error

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import copy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():

    N = I()
    XY = LLIN(N)
    XY.sort()
    if N == 1:
        print(1)
        exit()
    
    count = defaultdict(int)
    for i, (x1, y1) in enumerate(XY):
        for j, (x2, y2) in enumerate(XY[i+1:]):
            dx, dy = x1 - x2, y1 - y2
            count[(dx, dy)] += 1
    print(N - max(count.values()))
    
    
                        
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))


ups = []
downs = []
eqs = []
for i in range(3):
    if A[i] < B[i]:
        ups.append((A[i], B[i]))
    elif A[i] == B[i]:
        eqs.append((A[i], B[i]))
    else:
        downs.append((A[i], B[i]))
ans = N

if len(eqs) == 3:
    print(N)
    exit()

if len(ups) == 0:
    tmp = A
    A = B
    B = tmp
    tmp = ups
    ups = downs
    downs = tmp

if len(ups) == 3:
    gold_diff = B[0]-A[0]
    silver_diff = B[1]-A[1]
    cupper_diff = B[2]-A[2]
    for gold in range(N//A[0]+1):
        left = N - gold*A[0]
        for silver in range(left//A[1]+1):
            cupper = (left - silver*A[1])//A[2]
            tmp_ans = (N
                       + gold*gold_diff
                       + silver*silver_diff
                       + cupper*cupper_diff)
            ans = max(ans, tmp_ans)
    print(ans)
elif len(ups) == 2:
    gold_diff = ups[0][1]-ups[0][0]
    silver_diff = ups[1][1]-ups[1][0]
    for gold in range(N//ups[0][0]+1):
        left = N - gold*ups[0][0]
        silver = left // ups[1][0]
        tmp_ans = (N
                   + gold*gold_diff
                   + silver*silver_diff)
        ans = max(ans, tmp_ans)
    if len(downs) == 1:
        diff = downs[0][0]-downs[0][1]
        ans += (ans // downs[0][1]) * diff
    print(ans)
elif len(ups) == 1:
    bbans = N + (N//ups[0][0])*(ups[0][1]-ups[0][0])
    if len(downs) == 2:
        tmp_ans = bbans
        gold_diff = downs[0][0]-downs[0][1]
        silver_diff = downs[1][0]-downs[1][1]
        for gold in range(bbans//downs[0][1]+1):
            left = bbans - gold*downs[0][1]
            silver = left // downs[1][1]
            tmp_ans = (bbans
                       + gold*gold_diff
                       + silver*silver_diff)
            ans = max(ans, tmp_ans)
    elif len(downs) == 1:
        ans =bbans + (bbans//downs[0][1])*(downs[0][0]-downs[0][1])
    eise:
        ans = bbans
    print(ans)

Submission status: Runtime Error

Solution code:
import statistics
N = int(input())

x = []
sub_x=[]
sub_y=[]

for i in range(N):
  x.append(list(map(int, input().split())))
  
x.sort()
for i in range(len(x)-1,0, -1):
  mysub_x = [(x[i][0] - x[i-1][0])]
  mysub_y = [(x[i][1] - x[i-1][1])]
  if mysub_x != [0]:
    sub_x += mysub_x
  if mysub_y != [0]:
    sub_y += mysub_y
p = statistics.mode(sub_x)
q = statistics.mode(sub_y)

ans = 0
for i in range(N-1):
    if abs(x[i][0] - x[i+1][0]) != abs(p) or abs(x[i][1] - x[i+1][1]) != abs(q):
      ans += 1
if ans == 0:
  print(1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:

# -*- coding: utf-8 -*-
# @Date    : 2019-06-15 20:02:29
# @Author  : raj lath (oorja.halt@gmail.com)
# @Link    : link
# @Version : 1.0.0

import sys
sys.setrecursionlimit(10**5+1)

inf     =  int(10 ** 20)
max_val =  inf
min_val = -inf

RW  = lambda : sys.stdin.readline().strip()
RI  = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]
from collections import defaultdict

nb_points = RI()
points    = [RMI() for _ in range(nb_points)]
pq = defaultdict(int)
for i in range(nb_points):
    for j in range(nb_points):
        if i == j : continue
        p1 = points[i][0] - points[j][0]
        q1 = points[i][1] - points[j][1]
        pq[(p1, q1)]  = pq.get((p1, q1), 0) + 1
print(nb_points - max(pq.values()))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().sprit())
print(N%K)

Submission status: Runtime Error

Solution code:
N,K = map(int,input())
print(N%K)

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])
l.sort()

for i in range(len(l)-1):
    for j in range(i+1, len(l)):
        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 = "1000000 1000000"
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, K = map(int, input().split())
ans = N - K
ans += 1 if k == 1 else 0
print(ans)