Problem:


Score : 100 points

Problem Statement

Snuke has N integers: 1,2,\ldots,N.
He will choose K of them and give those to Takahashi.

How many ways are there to choose K consecutive integers?

Constraints

All values in input are integers.

1 \leq K \leq N \leq 50

Input

Input is given from Standard Input in the following format:

N K

Output

Print the answer.

Sample Input 1

3 2

Sample Output 1

2

There are two ways to choose two consecutive integers: (1,2) and (2,3).

Sample Input 2

13 3

Sample Output 2

11



Sample input:
3 2


Sample output:
2

Submission status: Accepted

Solution code:
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    n, k = map(int, input().split())
    print(n - k + 1)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

x = N - K + 1
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()

print(N-K+1)

Submission status: Accepted

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

Submission status: Runtime Error

Solution code:
a,b=map(int,input())
print(a-b+1)

Submission status: Runtime Error

Solution code:
R, G, B, N = map(int, input().split())

answer = 0
for r in range(N//R+1):
  for g in range(N//G+1):
    if r*R + g*G > N:
      break
    elif (N-r*R-g*G)%B != 0:
      continue
    else:
      answer += 1
print(answer)

Submission status: Runtime Error

Solution code:
[N,K]=L()

def L():
    return list(map(int, input().split()))
print(N-K+1)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
ans = 0
if N == K:
  print(1)
  exit()
for _ in range(N-K):
  ans++
print(ans)

Submission status: Runtime Error

Solution code:
a,b = map(in,input().split())
print(a-b+1)

Submission status: Runtime Error

Solution code:
n,k = map(int, raw_input())
print n - k +1

Submission status: Runtime Error

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    Ss = [input() for _ in range(N)]

    num_ab = 0
    num_a = 0
    num_b = 0
    num_b_a = 0
    # ３つの関係で解の条件分け
    

    for line in Ss:

        num_ab += line.count('AB')
        
        if line[0] == 'B' and line[-1] == 'A':
            num_b_a += 1
        elif line[-1] == 'A':
            num_a += 1
        elif line[0] == 'B':
            num_b += 1
        
    res = num_ab
    if num_b_a > 0:
        res += num_b_a -1

        if num_a > 0:
            res += 1
            num_a -= 1

        if num_b > 0:
            res += 1
            num_b -= 1

    res += min(num_a, num_b)
    print(res)

        




if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = 2*a + 1
print(c-a+b)

Submission status: Runtime Error

Solution code:
n = int(input())
s_ls = [0] * n
start_b = 0
end_a = 0
start_b_and_end_a = 0
internal_AB = 0
for i in range(n):
    s = input()
    s_ls[i] = s
    if s[0] == 'B' and s[-1] != 'A':
        start_b += 1
    elif s[0] != 'B' and s[-1] == 'A':
        end_a += 1
    elif s[0] == 'B' and s[-1] == 'A':
        start_b_and_end_a += 1
    for j in range(len(s)-1):
        if s[j:j+2] == 'AB':
            internal_AB += 1
ans = min(start_b,end_a)+internal_AB
diff = start_b_and_end_a - ans
if diff >= 0:
    ans += ans
    ans += max(0,diff-1)
else:
    ans += start_b_and_end_a
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
s = [input() for _ in range(n)]
a = 0
b = 0
ab = 0
for i in range(n):
    if s[i][0] == "B" and s[i][-1] == "A":
        ab += 1
    elif s[i][0] == "B":
        b += 1
    elif s[i][-1] == "A":
        a += 1
c = min(a, b)
ans = c
if ab > 0:
    ans += ab
if a== 0 and b==0:
    ans = ab - 1
for S in s:
    for i in range(len(S)-1):
        if S[i: i + 2] == "AB":
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
print(int(input())+1)

Submission status: Runtime Error

Solution code:
def solve():
    N = int(input())
    a = 0
    b = 0
    ab = 0
    ans = 0
    for _ in range(N):
        s = input()
        if s[-1] == 'A' and s[-1] == 'B':
            ab += 1
        elif s[-1] == 'A':
            a += 1
        elif s[0] == 'B':
            b += 1
        ans += s.count('AB')
        
    if ab == 0:
        ans += min(a, b)
    else:
        if a == 0 and b == 0:
            ans += ab - 1
        else:
            ans += ab + min(a, b)
            
    return ans
    
print(solve())

Submission status: Runtime Error

Solution code:
n = int(input())
s = list(input() for _ in range(n))
cou = 0
for i in s:
    cou += i.count('AB')
a = 0
b = 0
both = 0
for i in s:
    if i[0]=="B":
        b += 1
    if i[-1]=="A":
        a += 1
    if i[0]=="B" and i[-1]=="A":
        both += 1
if min(a,b)>=both  :
    print(cou+min(a,b)-1)
else:
    print(cou+min(a,b))

Submission status: Runtime Error

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

print(N-K+1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import collections

def useOne(a, b, c, n):
    count = 0
    if n%a == 0: count += 1
    if n%b == 0: count += 1
    if n%c == 0: count += 1
    return count

def useTwo(a, b, n):
    a, b = sorted([a, b])
    count = 0
    maxCountOfA = n//a
    maxCountOfB = n//b
    
    startCount = 1
    for i in range(maxCountOfA, 0, -1):
        for j in range(startCount, maxCountOfB+1):
            _sum = i*a + j*b
            if _sum == n:
                count += 1
                startCount = j+1
                break
            if _sum > n:
                startCount = j
                break
    return count

def useThree(a, b, c, n):
    a, b, c = sorted([a, b, c])
    maxCountOfA = n//a
    maxCountOfB = n//b
    maxCountOfC = n//c
    count = 0
    for i in range(1, maxCountOfA+1):
        startCountOfC = maxCountOfC
        for j in range(1, maxCountOfB+1):
            _sum = i*a + j*b
            if _sum >= n:
                maxCountOfB = j
                break
            for k in range(startCountOfC, 0, -1):
                _sum = i*a + j*b + k*c
                if _sum == n:
                    count += 1
                    startCountOfC = k-1
                    break
                if _sum < n:
                    startCountOfC = k
                    break
    return count

def answer(a, b, c, n):
    # useTwo(a, b, n)
    count = useOne(a, b, c, n)
    count += useTwo(a, b, n)
    count += useTwo(a, c, n)
    count += useTwo(b, c, n)
    count += useThree(a, b, c, n)
    return count
    
a, b, c, n = map(int, input().split())
print(answer(a, b, c, n))

Submission status: Runtime Error

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
r=0
while r*R <= N:
    g=0
    while r*R + g*G <= N:
        if (N - r*R - g*G) % B == 0:
            ans += 1
        g += 1
    r += 1
print(ans)

Submission status: Runtime Error

Solution code:
R, G, B, N = map(int, input().split())
cnt = 0
 
for i in range(N // R + 1):
    for j in range(N // G + 1):
        q, mod = divmod((N - R * i - G * j), B)
        if q >= 0 and mod == 0:
            cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
R, G, B, N = map(int, input().split())
cnt = 0

for i in range(N // R + 1):
    for j in range(N // G + 1):
        if (N - R * i - G * j) % B == 0:
            cnt += 1
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
R,G,B,N = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
ans = 0

for r in range(3001):
    for g in range(3001):
        b = (N - R*r - G*g) / B
        if b%1==0 and b>=0:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_d

from math import ceil, floor

def divisors(N):
    ans = []
    i = 1
    while i * i <= N:
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
        i += 1
    ans.sort()
    return ans

N = int(input())
# N = 1000000
fN = divisors(N)
total = 0
for i in range(len(fN) - 1):
    if fN[i + 1] - fN[i] == 1:
        continue
    mp = N // fN[i]
    mpp = N // fN[i + 1]
    # print(fN[i], fN[i + 1], " | [{},{}]".format(mpp, mp))
    for mm in range(mpp, mp):
        for rr in range(1, fN[i] + 1):
            # print(N - rr, floor((N - rr) / mm) == ceil((N - rr) / mm) and rr == mm)
            if floor((N - rr) / mm) == ceil((N - rr) / mm) and rr == mm:
                # print(rr, mm)
                total += (N - rr) // mm
            # print(mm, rr, floor((N - rr) / mm))
print(total)
    
# print()
# total2 = 0
# for m in range(1, N + 1):
#     f1 = floor(N / m)
#     f2 = N % m
#     if f1 == f2:
#         print(m, f1, f2, f1 == f2)
#         total2 += m
# print(total2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
r , g , b , n = map(int,input().split())
ans = 0
R = -(-n//r)
G = -(-n//g)
for i in range(R+1):
    for j in range(G+1):
        su = n-r*i-g*j
        if n-r*i-g*j < 0:
            break
        else:
            if (su/b).is_integer():
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
N = int(sys.stdin.readline())
ss = []
for i in range(N):
    ss.append(sys.stdin.readline().rstrip())

incount = 0
has_ba = 0
has_b = 0
has_a = 0
for s in ss:
    incount += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        has_ba += 1
    elif s[0] == 'B':
        has_b += 1
    elif s[-1] == 'A':
        has_a += 1

res = incount
if has_a:
    res += has_ba
elif has_ba:
    has_a += 1
    has_ba -= 1
    res += has_ba
res += min(has_a, has_b)

print(res)

Submission status: Runtime Error

Solution code:
a,b = mmap(int,input().split())
print(a-b+1)

Submission status: Runtime Error

Solution code:
a,b = int(input())
print(a-b+1)

Submission status: Runtime Error

Solution code:
N = int(input())
ans = 0

for i in range(int(N**0.5)):
    if N%(i+1) == 0 and (i+1) != N//(i+1) and (N**0.5) > (i+1):
        ans += ((N//(i+1))-1)

print(ans)

Submission status: Runtime Error

Solution code:
a=input()
b=input())
print(a+b-1)

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
print(int(a+b-1))

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
print(a+b-1)

Submission status: Runtime Error

Solution code:
n = int(input())
naibu = 0
head = 0
tail = 0
both = 0

for _ in range(n):
    s = str(input())
    naibu += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        both += 1
    elif s[0] == 'B':
        head += 1
    elif s[-1] == 'A':
        tail += 1

ans = min(head, tail) + both + naibu
if head == 0 and tail == 0:
    ans = max(both-1, 0) + naibu
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
ans=0
a=0;b=0;ab=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B":
    b+=1
    if s[-1]=="A":
      ab+=1
      b-=1
  elif s[-1]=="A":
    a+=1
if a+b==0:
    print(ans+max(ab-1,0))
else:
    print(ans+min(a,b)+ab)

Submission status: Runtime Error

Solution code:
n=int(input())
ans=0
a=0;b=0;ab=0
for i in range(n):
  s=input()
  ans+=s.count("AB")
  if s[0]=="B":
    b+=1
    if s[-1]=="A":
      ab+=1
      b-=1
  elif s[-1]=="A":
    a+=1
if a+b==0:
    print(ans+ab-1)
else:
    print(ans+min(a,b)+ab)

Submission status: Runtime Error

Solution code:
n = int(input())
y = 0
for i in range(1,int(n**0.5)+1):
    if (n-i)%i == 0 and n-i > i**2:
        y += (n-i)//i
print(y)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# 1. 両端にaもbも含まれないもしくは「先頭がaで末尾がb」は分けて考える 最後にテキトーに加えてやる
# 2. 「先頭がb」「末尾がa」「先頭がbで末尾がa」
# cca
# caa
# bac
# bbc
# bccca < -これは連結したほうがよさそう連結したあとに左にooa右にbooを加える
# あまったooaとbooで適当にくっつける
n = int(input())
ans = 0
both = 0
a, b = 0, 0
for _ in range(n):
    s = input()
    if s[0] != "B" and s[-1] != "A":
        ans += s.count("AB")
    else:
        if s[0] == "B" and s[-1] == "A":
            both += 1
            ans += s.count("AB")
        elif s[0] == "B":
            b += 1
            ans += s.count("AB")
        elif s[-1] == "A":
            a += 1
            ans += s.count("AB")
# 両脇にあるやつを連結
if both > 0:
    ans += both - 1
    # 連結したやつの先頭に加えられたら加える
    if a > 0:
        ans += 1
        a -= 1
    # 同じく末尾
    if b > 0:
        ans += 1
        b -= 1
# 余ったやつで作成
ans += min(a, b)
print(ans)

Submission status: Runtime Error

Solution code:
a,b = map(int, input())
print(a-b+1)

Submission status: Runtime Error

Solution code:
N=int(input())
s=''
point=0
q1,q2,q3=0,0,0 #q1はBA q2はAの末尾のみ q3はBの最初のみ
for j in range(N):
    n=str(input())
    point+=n.count("AB")
    if n[0]=="B" and n[len(n)-1]=="A":
      q1+=1  
    elif n[0]=="B":
      q2+=1
    elif n[len(n)-1]=="A":
      q3+=1
    else:
      pass
q1-=1
q2-=1
print(q1-1+2+min(q3,q2)+point)

Submission status: Runtime Error

Solution code:
n,k=input().split()
ans=n-k+1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
r,g,b,n=map(int,input().split())
ans=0
for i in range(3001):
	for j in range(3001):
		if (n-r*i-g*j)%b==0 and \
		n-r*i-g*j>=0:
			ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
r, g, b, n = map(int,input().split())
res = 0
for i in range(n // r + 1):
    for j in range((n-r*i) // g + 1):
        if (n - (i * r) - (g * j) ) % b == 0:
            #print("{0}, {1}, {2}".format(i, j, (n - (i * r) - (g * j) ) % g))
            res += 1

print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    print(N - K + 1)

Submission status: Runtime Error

Solution code:
import sys

def main():
    data = input()
    flds = data.split(" ")
    N = int(flds[0])
    K = int(flds[1])

    count = 0
    for i in range(1, N):
        if i + K - 1 <= N:
#           print("%d -  %d" %(i, i + K - 1))
            count += 1

#   print("resut = " %count)
   print(count)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
#m = int(input())
k = int(input())
#n, m = map(int, input().split())
#n, m, k = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
print(n-k+1)

Submission status: Runtime Error

Solution code:
N = int(input())
B_start, A_end, B__A, AB_in = 0, 0, 0, 0
for n in range(N) :
    star = input()
    if star[0] == "B" :
        B_start += 1
    if star[-1] == "A" :
        A_end += 1
        if star[0] == "B" :
            B__A += 1
    AB_in += star.count("AB")
    
if B_start == A_end and A_end == B__A :
    print(B__A+AB_in-1)
else :
    print(min(B_start, A_end)+AB_in)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

print(N-(K-1))

Submission status: Runtime Error

Solution code:
a,b=map(int, input().split())
c = a! / (b! * (a - b)!)
print(c)

Submission status: Runtime Error

Solution code:
a,b=

Submission status: Runtime Error

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N//R+1):
    for g in range((N-R*r)//G+1):
        if (N-R*r+G*g)%B == 0:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(N//R+1):
  for g in range((N-R*r)//G+1):
    if (N-R*r-G*g)%B == 0:
      cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
//Queueいらなくないですか

#include <stdio.h>
#include <stdlib.h>

int get_weight(){
    return rand() % 71 + 30;
}

int main(){
    int n = 500, m = 150, weight_limit = 500;
    int priority_limit = 4, general_limit = 4;
    int last_p, last_g;
    int i, j;
    int t = 0;

    while (n >= 0 || m >= 0){
        int S = 0, cnt = 0;
        for (i = 0;i < priority_limit; i++){
            if (m < 0)
                break;
            if (m == 0){
               print("if Takahiro get in the priority line: %d", t);
               m--;
               break;
            }

            if (if ){
                int w = top(P);
                if (S + w >= weight_limit)
                    break;
                m--;
                cnt++;
                S += w;
                break;
            }

            int w = get_weight();
            if (S + w >= weight_limit){
                push(P, w);
                break;
            }
            m--;
            S += w;
        }

        while (cnt < 8){
            if (n < 0)
                break;
            if (n == 0){
                printf("if Takahahiro get in the general line: %d", t);
                n--;
                break;
            }
            if (!is_empty(G)){
                int w = top(G);
                if (S + w >= weight_limit)
                    break;
                n--;
                cnt++;
                S += w;
                break;
            }

            int w = get_weight();
            if (S + w >= weight_limit){
                push(G, w);
                break;
            }
            n--;
            S += w;
        }
        t++;
    }
}

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int get_weight(){
    return rand() % 71 + 30;
}

typedef struct{
    int front;
    int rear;
    int *data;
}Queue;

void resize_array(int *p, int size){
    *p = (int *)malloc(size * sizeof(int)); 
}

void init_Queue(Queue *Q, int size){
    Q->front = 0;
    Q->rear = 0;
    resize_array(&(Q->data));
}

bool is_empty(Queue *Q){
    return Q->front == Q->rear;
}

int size(Queue *Q){
    return sizeof(Q->data) / sizeof(int);
}

bool is_full(Queue *Q){
    return (Q->front + 1) % size(Q) == Q->rear;
}

void push(Queue *Q, int value){
    if (is_full(Q))
        return;
    Q->data[Q->rear] = value;
    Q->rear = (Q->rear + 1) % size(Q);
}

int top(Queue *Q){
    if (is_empty())
        return;
    return Q->data[Q->front];
}

int pop(Queue *Q){
    if (is_empty())
        return;
    int res = Q->data[Q->front];
    Q->front = (Q->front + 1) % size(Q);

    return res;
}

int main(){
    int n = 500, m = 150, weight_limit = 500;
    int priority_limit = 4, general_limit = 4;
    Queue P, G;
    int i, j;
    int t = 0;
    init_Queue(&P, m);
    init_Queue(&G, n);

    for (i = 0; i < size(&P); i++)
        P.data[i] = get_weight();
    
    for (i = 0; i < size(&G); i++)
        P.data[i] = get_weight();

    while (n >= 0 || m >= 0){
        int S = 0, cnt = 0;
        for (i = 0;i < priority_limit; i++){
            if (m < 0)
                break;
            if (m == 0){
               print("if Takahiro get in the priority line: %d", t);
               m--;
               break;
            }

            int w = top(&P);
            if (S + w >= weight_limit)
                break;
            m--;
            S += w;
            pop(&P);
        }

        while (cnt < 8){
            if (n < 0)
                break;
            if (n == 0){
                printf("if Takahahiro get in the general line: %d", t);
                n--;
                break;
            }

            int w = top(&G);
            if (S + w >= weight_limit)
                break;
            n--;
            S += w;
            pop(&G);
        }
        t++;
    }
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
list = [int(x) for x in input().split()]
print(list[0] - list[1] + 1]

Submission status: Runtime Error

Solution code:
n=int(input())
k=int(input())
print(n-k+1)

Submission status: Runtime Error

Solution code:
n=input()
k=input()
print(n-k+1)

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
S = input()
h = 'o'
if S[k-1] == 'A':
  h = 'a'
elif S[k-1] == 'B':
  h = 'b'
else:
  h = 'c'
print(S[:k-1]+h+S[k:])

Submission status: Runtime Error

Solution code:

n = input()
N = int(n.split(' ')[0])
K = int(n.split(' ')[1])
 
ans=0
for x in range(K):
    ans += int(N//(x+1))

return ans

Submission status: Runtime Error

Solution code:
n = input()
N = n.split(' ')[0]
K = n.split(' ')[1]
 
ans=0
for x in range(K):
  ans += int(N/(x+1))
  
return ans

Submission status: Runtime Error

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

ans=0
for x in range(K):
  ans += int(N//(x+1))
  
return ans

Submission status: Runtime Error

Solution code:
R,G,B,N = map(int,input().split())
for r in range(N+1):
  for g in range(N+1):
    n=N-R*r-G*g
    if n>=0 and n%B==0:
      b=int(n/B)
      print(r,g,b)

Submission status: Runtime Error

Solution code:
R,G,B,N = map(int,input().split())
for r in range(N+1):
  for g in range(N+1):
    n = N-R*r-G*g
    if n >=0 and n%B==0:
      b=n/B
      print(r,g,b)

Submission status: Runtime Error

Solution code:
import sys

N = int(sys.stdin.readline())
print(N)

i = 1
s = 0

while i ** 2 <= N:
    if N % i == 0:
        k = N // i - 1
        if k > i:
            s += k
    i += 1
print(s)

Submission status: Runtime Error

Solution code:
import sys

N = int(sys.stdin.readline())

i = 1
s = 0

while i ** 2 <= N:
  if N // i == N % i:
    s += i
  i += 1
print(s)

Submission status: Runtime Error

Solution code:
a,b = map(int, input(),split())
print("{}".format(a-b+1))

Submission status: Runtime Error

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

ans = N - (K-1)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
print(N - M + 1)

Submission status: Runtime Error

Solution code:
a,b = input().split()
print(a - b + 1)

Submission status: Runtime Error

Solution code:
n=int(input())
r=int(input())
print(n-r+1)

Submission status: Runtime Error

Solution code:
print int(input())-int(input())+1

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split(','))
print(n*(n-1)/k/(k-1))

Submission status: Runtime Error

Solution code:
r, g, b, n = map(int, input().split())
counter = 0
for s in range(n+1):
    for t in range(n-i+1):
        u = n - r*s - g*t
        if u >= 0 and u % b == 0:
            counter += 1
print(counter)

Submission status: Runtime Error

Solution code:
include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int N = 0;
  int K = 0;
  int A = 1;
  std::cin >> N;
  std::cin >> K;
  for(int i;i<N;i++){
  A*=i
  }
  for(int i;i<K;i++){
  A/=i
  }
  for(int i;i<N-K;i++){
  A/=i
  }
  
  std::cout << A << std::endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
N,K = [int(x) for x in input().split(' ')]

return N - (K - 1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a, b=list(map(int, input().split))
print(a-b+1)

Submission status: Runtime Error

Solution code:
MAX = 10**9 + 7

def solve():
    N = int(raw_input())
    arr = [int(_) for _ in raw_input().split()]
    xor_acu = [0] * (N + 1)
    for i in range(1, N + 1):
        xor_acu[i] = xor_acu[i - 1] ^ arr[i - 1]
    if xor_acu[N] != 0: # search for 0, X, 0, X ..., 0, X type
        X = xor_acu[N]
        dp0 = [1] * (N + 1)
        dpX = [0] * (N + 1)
        for i in range(1,N+1):
            dp0[i] = dp0[i-1] + dpX[i-1] if xor_acu[i] == 0 else dp0[i - 1]
            dpX[i] = dp0[i-1] + dpX[i-1] if xor_acu[i] == X else dpX[i - 1]
        ret = dp0[N - 1]
    else: # search for 0, X, 0, X ..., X, 0 type
        # X == 0 case
        tmp = 1
        Not0Set = set()
        for i in range(1, N):
            if xor_acu[i] == 0:
                tmp *= 2
            else:
                Not0Set.add(xor_acu[i])
        ret = tmp
        if ret > MAX:
            ret = ret % MAX
        # X != 0 case
        for X in list(Not0Set):
            RLE = [] # Run Length Encoding
            _tmp = xor_acu[0]
            cnt = 1
            all_cnt = 1
            for i in range (1, N+1):
                if xor_acu[i] == 0 or xor_acu[i] == X:
                    if xor_acu[i] == _tmp:
                        cnt += 1
                    else:
                        RLE.append((_tmp, cnt))
                        _tmp = xor_acu[i]
                        cnt = 1
                    all_cnt += 1
            RLE.append((_tmp, cnt))
            lRLE = all_cnt
            Not0dp0 = [1] * lRLE
            Not0dpX = [0] * lRLE
            ind = 1
            for i in range(len(RLE)):
                start = 1 if i == 0 else 0
                if RLE[i][0] == 0:
                    for j in range(start, RLE[i][1]):
                        Not0dp0[ind] = Not0dp0[ind - 1] + Not0dpX[ind - 1]
                        Not0dpX[ind] = Not0dpX[ind - 1]
                        ind += 1
                else:
                    for j in range(start, RLE[i][1]):
                        Not0dp0[ind] = Not0dp0[ind - 1]
                        Not0dpX[ind] = Not0dp0[ind - 1] + Not0dpX[ind - 1]
                        ind += 1
            ret += Not0dpX[ind - 2]
            if ret > MAX:
                ret = ret % MAX
    print str(ret)

if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def prime_factors(n):
    i = 2
    factors = {}
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            if i in factors.keys():
                factors[i] += 1
            else:
                factors[i] = 1
    if n > 1:
        if n in factors.keys():
            factors[n] += 1
        else:
            factors[n] = 1
    return factors

i  = lambda: int(input())

N = i()

pfd = prime_factors(N)

check_num = []

for pf in pfd.keys():
    tmp_num = []
    for i in range(1, pfd[pf] + 1):
        tmp_num.append(pf ** i)
        for n in check_num:
            tmp_num.append(n * (pf ** i))
    check_num += tmp_num

count = 0
for n in check_num:
    if N // (n-1) == N % (n-1):
        count += n-1

print(count)

Submission status: Runtime Error

Solution code:
n = int(input())

ans = 0
x = 1

while x < n:
    if n % x == 0:
        m = n // x - 1
        if m <= x:
            break
        else:
            ans += m
    x += 1

print(ans)

Submission status: Runtime Error

Solution code:
def all_divisor(n):
  small = [1]
  large = [n]
  for i in range(2, int(n ** 0.5)+1):
    if n % i == 0:
      small.append(i)
      large.append(n//i)
  large.reverse()
  divisor = small + large
  return divisor


n = int(input())
n_divisor = all_divisor(n)
ans = 0
for i in n_divisor:
  mini_ans = (n - i) // i
  if i >= mini_ans:
    break
  ans += mini_ans 
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
k=int(input())
z=n-k+1
print(z)

Submission status: Runtime Error

Solution code:
r, g, b, n = map(int, input().split())

ans = 0

for i in range(3001):
    if i*r > n:
        break
    for j in range(3001):
        value = r*i + g*j
        if (n - value) < 0:
            break
        elif (n - value) % b == 0:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
# BA=0, B=0, A=0, 0
# BA=2, B=0, A=0, 1
# BA=0, B=1, A=0, 0
# BA=0, B=0, A=1, 0
# BA=2, B=1, A=0, 2
# BA=2, B=0, A=1, 2
# BA=2, B=1, A=1, 2

n = int(input())
 
ans = 0
A = 0
B = 0
AB = 0
for _ in range(n):
    s = input()
    ans += s.count('AB')
    
    if s[-1] == 'A' and s[0] != 'B':
        A += 1 
    if s[0] == 'B' and s[-1] != 'A':
        B += 1
    if s[-1] == 'A' and s[0] == 'B':
        AB += 1
    
ans += min(A+AB, B+AB)


if AB>0 and A+B==0:
    ans -= 1

print(ans)