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 = []
for _ in range(N) :
    ll = list(map(int, input().split()))
    l.append(ll)

#print(l)

dic = {}

for i in range(1, N) :
    #subl.append([l[i][0] - l[i-1][0], l[i][1] - l[i-1][1]])
    #k = 1000000001*(l[i][0] - l[i-1][0]) + l[i][1] - l[i-1][1]
    k = str(l[i][0] - l[i-1][0]) + '+' + str(l[i][1] - l[i-1][1])

    if l[i][0] - l[i-1][0] == 0 and l[i][1] - l[i-1][1] == 0:
        continue

    if k not in dic :
        dic[k] = 1
    else :
        dic[k] += 1

print(dic)

if len(dic) == 0 :
    print(N)
else :
    print(N - max(dic.values()))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
if(k=0){
print(0)
}
print(n-k)

Submission status: Runtime Error

Solution code:
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
if N == 1:
    print(1)
    exit()
xy.sort(key = lambda x:x[0])
d = {}
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        tmp = (xy[i][0] - xy[j][0], xy[i][1] - xy[j][1])
        if not tmp in d:
            d[tmp] = 0
        d[tmp] += 1
        #print(xy[i][0] - xy[j][0], xy[i][1] - xy[j][1])
    #print()
d = sorted(d.items(), key = lambda x:-x[1])
print(N - d[0][1])

Submission status: Runtime Error

Solution code:
a,b=map(int, input().split())

if b = 0:
	return 0;
elif:
	return a - b;

Submission status: Runtime Error

Solution code:
if k==1:
    return 0
elif n==k:
    return 0
else:
    max_dif=(n-k-1)-1
    return max_dif

Submission status: Runtime Error

Solution code:
l = input()
N,K = l.strip().split(" ")
N = int(N)
K = int(K)

if N <= K: return 0
else: return int(N - K)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
if N >= 2:
    print(N - K)
elif:
    print(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:
l = input()
N,K = l.strip().split(" ")
N = int(N)
K = int(K)

if N <= K: return 1
else: return int(N % K)

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
for i in range(n):
	x, y = map(int, input().split())
	a.append((x, y))
d = {}
if n == 1:
	print(1)
	exit()
a = sorted(a)
for i in range(n):
	tc = a[i]
	for j in range(i + 1, n):
		nd = a[j]
		x1, y1, = tc[0], tc[1]
		x2, y2, = nd[0], nd[1]
		rz1 = x1 - x2
		rz2 = y1 - y2
		d[(rz1, rz2)] = d.get((rz1,rz2), 0) + 1
print(n - max(d.values()))

Submission status: Runtime Error

Solution code:

data = []

data.extend(list(map(int, input().split(str))))
N = data[0]
K = data[1]

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

Submission status: Runtime Error

Solution code:

data = []

data.extend(list(map(int, input().split(str))))
N = data[0]
K = data[1]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = (int(i) for i in input().split())

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

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
print((n-K)+1)

Submission status: Runtime Error

Solution code:
#n:balls 

n, k = (int(i) for i in input().split()) 

if k==1:
	dif=0

if k>1:
	dif=n-k:

print(dif)

Submission status: Runtime Error

Solution code:
import sys
line = sys.stdin.readline().strip("\n").split(" ")
print(line[0]%line[1])

Submission status: Runtime Error

Solution code:
import sys
line = sys.stdin.readline().strip("\n").split(" ")
return line[0]%line[1]

Submission status: Runtime Error

Solution code:
s = input().split()

n = s[0]
k = s[1]

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

Submission status: Runtime Error

Solution code:
input = input().split()

n = s[0]
k = s[1]

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iterator>
#include <cmath>

using namespace std;

template<class A0>
void input(A0 &a0) { cin>>a0; }
template<class A0, class A1>
void input(A0 &a0, A1 &a1) { cin>>a0>>a1; }
template<class A0, class A1, class A2>
void input(A0 &a0, A1 &a1, A2 &a2) { cin>>a0>>a1>>a2; }
template<class A0, class A1, class A2, class A3>
void input(A0 &a0, A1 &a1, A2 &a2, A3 &a3) { cin>>a0>>a1>>a2>>a3; }
template<class A0, class A1, class A2, class A3, class A4>
void input(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4) { cin>>a0>>a1>>a2>>a3>>a4; }
template<class C,class T,class Arr>
basic_istream<C,T>&operator>>(basic_istream<C,T>&is,Arr&arr){for(auto&e:arr)is>>e;return is;}

template<class A0>
void print(A0 const &a0) {cout<<a0<<endl;}
template<class A0, class A1>
void print(A0 const&a0,A1 const&a1) {cout<<a0<<" ";print(a1);}
template<class A0, class A1, class A2>
void print(A0 const &a0, A1 const&a1, A2 const&a2) {cout<<a0<<" ";print(a1,a2);}
template<class A0,class A1,class A2,class A3>
void print(A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3){cout<<a0<<" ";print(a1,a2,a3);}
template<class A0,class A1,class A2,class A3, class A4>
void print(A0 const&a0,A1 const&a1,A2 const&a2,A3 const&a3, A4 const&a4){cout<<a0<<" ";print(a1,a2,a3,a4);}
template<class C,class T,class Arr>
basic_ostream<C,T>& operator<<(basic_ostream<C,T>& os,Arr const&arr) {
  os<<"[";for(auto i=arr.begin(),e=arr.end();i!=e;os<<((++i!=e)?",":"]"))os<<*i;return os;
}

using lli = long long int;
lli gcd(lli const p, lli const q) { return q == 0 ? p : gcd(q, p%q); }
lli pow(lli const a, lli const n, lli const m){return(!n)?1:(n&1)?(((a%m)*pow(a,n-1,m))%m):[=](){lli b=pow(a,n/2,m);return(b*b)%m;}();}
lli inv(lli const a, lli const p) { return pow(a, p-2, p); }



int main()
{
  int N,K;
  input(N,K);
  if (1 == K) 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:
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:
    print(N-K

Submission status: Runtime Error

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

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:
a , b =input().split()
print(a-b)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
splited = input().split(' ')
N = int(splited[0])
K = int(splited[1])
 
if(K == 1):
    print(0)
else
    print(N - K)

Submission status: Runtime Error

Solution code:
n, k = input.split(' ')
n, k = int(n), int(k)
maxval = k - n
minval = k / n
print(maxval - minval)

Submission status: Runtime Error

Solution code:
N,K=list(map(int,input().split()))
dis =N-K+1
if K >=2:
    print(dism-1)
elif K ==1:
    print(0)

Submission status: Runtime Error

Solution code:
N, K = map(int, raw_input().split())
if K == 1:
    print(0)
    exit()

print(N-K)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
splited = input().split(' ')
N = int(splited[0])
K = int(splited[1])

if(K == 1):
    return 0
else
    return 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:
N, K = [int(x) for x in input().split(' ')]
if K == 1:
    print(0)
    return
min = 1
max = N - (K - 1)
print(max - min)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n,k;
    cin >> n >> k;
    if(k==1){
        cout << 0 << endl;
    }
    else{
        cout << n-k << endl;
    }
    
    
    return 0;
}

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
if k!=1:
    print(n-k)
else:
    pritn(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,m=map(int(input().split()))
if m=1:
    print(0)
else:
    print(n-m)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

a=n-k

print(a)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

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:
    print(n-k)

Submission status: Runtime Error

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

if k != 1:
    print(n-k)
else:
    print('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=[int(i) for i in input().spit(" ")]
if K==1:
    print(0)
else:
    print(N-K)

Submission status: Runtime Error

Solution code:
N,K=list(map(int,input().split())
dismax = N-K+1
print(dismax-1)

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
print(N-K)

Submission status: Runtime Error

Solution code:
a,b=int(input())
if(b==1):
  print(0)
else:
  print(a-b)

Submission status: Runtime Error

Solution code:
N, K = inpl()
if K == 1:
    print(0)
else:
    print(N-K)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split(' '))
if not K==1:
    print(H-K)
else:
    print(0)

Submission status: Runtime Error

Solution code:
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  if(k == 1) cout << 0 << endl;
  else cout << (n - k) << endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
import Foundation
import CoreFoundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    func reversed() -> Array {
        return self.reverse()
    }
    func enumerated() -> EnumerateSequence<[Element]> {
        return self.enumerate()
    }
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}
//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}
//func lcm(x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** テストスペース ***************/

//arr.sort{$0.0==$1.0 ? $0.1<$1.1 : $0.0<$1.0}  // 2つの条件に優先順位をつけてソート

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, K) = (input[0], input[1])
print(K==1 ? 0 : N-K)

Submission status: Runtime Error

Solution code:
N,K+map(int, input().split())
print(N%K)