qyliang/CodeNanoFix huggingface dataset:
Title: Sum of Integers

Find the number of combinations of <var>n</var> distinct numbers from 0 to 9 whose sum is <var>s</var>. For each dataset, the input consists of <var>n</var> (1 ≤ <var>n</var> ≤ 9) and <var>s</var> (0 ≤ <var>s</var> ≤ 100) separated by a single space. When both <var>n</var> and <var>s</var> are 0, it marks the end of input. The number of datasets does not exceed 50.

For each dataset, output the number of combinations of <var>n</var> integers whose sum is <var>s</var> on a single line.

Sample Input:
3 6
3 1
0 0

Output for the Sample Input:
3
0

# Buggy version:
import sys
f = sys.stdin

while True:
    n, s = map(int, f.readline().split())
    if n == 0:
        break
    print(sum(1 for nums in itertools.combinations([i for i in range(10)], n) if sum(nums) == s))

# Fixed version:
import sys
f = sys.stdin

import itertools

while True:
    n, s = map(int, f.readline().split())
    if n == 0:
        break
    print(sum(1 for nums in itertools.combinations([i for i in range(10)], n) if sum(nums) == s))

# Buggy version:
def f(n,s,x):
  if n == s == 0:
    return 1
  elif n == 0 or x == 0:
    return 0
  else:
    a = 0
    for i in range(x):
      a += f(n-1,s-i,i)
    return a
while True:
  n,s = map(int,raw_input().split())
  if n == s == 0:
    break
  print(f(n,s,10))

# Fixed version:
def f(n,s,x):
  if n == s == 0:
    return 1
  elif n == 0 or x == 0:
    return 0
  else:
    a = 0
    for i in range(x):
      a += f(n-1,s-i,i)
    return a
while True:
  n,s = map(int,input().split())
  if n == s == 0:
    break
  print(f(n,s,10))

# Buggy version:
def decSum(n, sm, mn):
    print(n,sm,mn)
    if mn + n > 10 :
        return 0
    elif sum(range(mn, mn + n)) > sm or sum(range(10 - n, 10)) < sm:
        return 0
    elif n == 1:
        return 1
    else:
        a = 0
        for i in range(mn, 10 if sm >= 10 else sm):
            a += decSum(n - 1, sm - i, i + 1)
        return a
while True:
    n, sm = map(int, input().split())
    if n == 0:
        break
    print(decSum(n, sm, 0))

# Fixed version:
def decSum(n, sm, mn):
    #print(n,sm,mn)
    if mn + n > 10 :
        return 0
    elif sum(range(mn, mn + n)) > sm or sum(range(10 - n, 10)) < sm:
        return 0
    elif n == 1:
        return 1
    else:
        a = 0
        for i in range(mn, 10 if sm >= 10 else sm):
            a += decSum(n - 1, sm - i, i + 1)
        return a
while True:
    n, sm = map(int, input().split())
    if n == 0:
        break
    print(decSum(n, sm, 0))

# Buggy version:
from itertools import combinations
while 1:
 n,s=map(int,input().split())
 if n+x==0:break
 print(sum(1 for p in combinations(range(10),n)if sum(p)==s))


# Fixed version:
from itertools import combinations

while True:
    n, s = map(int, input().split())
    if n == s == 0: break

    print(sum(1 for x in combinations(range(10), n) if sum(x) == s))
Affine Cipher: 

A simple encryption method called the affine cipher involves replacing letters with numbers (a=0, b=1, ..., z=25), and then using the formula $F(\gamma) = (\alpha \cdot \gamma + \beta)$ mod $26$ to substitute the original letters. Here, mod 26 represents the remainder when divided by 26. The values of $\alpha$ and $\beta$ are carefully chosen to ensure a one-to-one correspondence between $\gamma$ and $F(\gamma)$ (where $\alpha$ and 26 are coprime). For example, when $\alpha = 3$ and $\beta = 2$, 'a' (=0) becomes 'c' and 'n' (=13) becomes 'p'. Create a program to decrypt the encrypted string back to the original text, which always contains the keyword "that" or "this". 

Input:
Multiple datasets are provided. The first line contains the number of datasets, $n$ ($n \leq 30$). This is followed by $n$ lines of data, each containing an encrypted text of up to 256 characters, consisting of lowercase English letters and spaces.

Output:
For each dataset, output the decrypted original text on a single line.

Sample Input:
1
y eazqyp pnop pngtg ye obmpngt xmybp mr lygw

Output for the Sample Input:
i submit that there is another point of view

# Buggy version:
for _ in[0]*int(input()):
 e=input()
 for i in range(26,2):
  for j in range(26):
   a=''.join([c,chr(((ord(c)-97)*i+j)%26+97)][c.islower()]for c in e)
   if('that'or'this')in a:print(a);break


# Fixed version:
for _ in[0]*int(input()):
 e=input()
 for i in range(26):
  for j in range(26):
   a=''.join([c,chr(((ord(c)-97)*i+j)%26+97)][c.islower()]for c in e)
   if'that'in a or'this'in a:print(a);break
Title: Puzzle

There is a puzzle to complete by combining 14 numbers from 1 to 9. Given 13 numbers, add one more to complete the puzzle.

Completion conditions:
- Two of the same number are required.
- The remaining 12 numbers are combined into four sets of three numbers.
- The combination is either three of the same number or three consecutive numbers, excluding sequences like 9 1 2.
- The same number can be used up to 4 times.

Create a program that reads a string of 13 numbers and outputs all the numbers in ascending order that can complete the puzzle. Output 0 if no number can complete the puzzle.

For example, given the string 3456666777999:
- If "2" is added: 234 567 666 77 999
- If "3" is added: 33 456 666 777 999
- If "5" is added: 345 567 666 77 999
- If "8" is added: 345 666 678 77 999

Input:
Multiple datasets, each with 13 numbers on a single line. No more than 50 datasets.

Output:
For each dataset, output the numbers that can complete the puzzle in ascending order, separated by a space.

Sample Input:
3649596966777
6358665788577
9118992346175
9643871425498
7755542764533
1133557799246

Output for the Sample Input:
2 3 5 8
3 4
1 2 3 4 5 6 7 8 9
7 8 9
1 2 3 4 6 7 8
0

# Buggy version:
import sys
def f(c,h=0):
 if 2 in c and sum(c)==2:return 1
 if 5 in c:return 0  # sum(c)==2
 if 4 in c:
     k=c.index(4);c[k]-=3
     if f(c,h+1):return 1
     c[k]+=3
 if 3 in c:
     k=c.index(3);c[k]-=3
     if f(c,h+1):return 1
     c[k]+=3
 for i in range(7):
  if c[i]and c[i+1]and c[i+2]:
      c[i]-=1;c[i+1]-=1;c[i+2]-=1
      if f(c,h+1):return 1
      c[i]+=1;c[i+1]+=1;c[i+2]+=1
n='123456789'
for e in sys.stdin:
 e=list(e.strip())
 a=[i for i in n if f([(e+[i]).count(j)for j in n])]
 print(*a if a else 0)


# Fixed version:
import sys
def f(c,h=0):
 if 2 in c and sum(c)==2:return 1
 if 5 in c:return 0  # sum(c)==2
 if 4 in c:
     k=c.index(4);c[k]-=3
     if f(c,h+1):return 1
     c[k]+=3
 if 3 in c:
     k=c.index(3);c[k]-=3
     if f(c,h+1):return 1
     c[k]+=3
 for i in range(7):
  if c[i]and c[i+1]and c[i+2]:
      c[i]-=1;c[i+1]-=1;c[i+2]-=1
      if f(c,h+1):return 1
      c[i]+=1;c[i+1]+=1;c[i+2]+=1
n='123456789'
for e in sys.stdin:
 e=list(e)
 a=[i for i in n if f([(e+[i]).count(j)for j in n])]
 if a:print(*a)
 else:print(0)
Title: Prime Numbers II

Prime numbers are integers greater than 1 that can only be divided by 1 and themselves. For example, 2 is a prime number because it can only be divided by 2 and 1, whereas 12 can be divided by 2, 3, 4, and 6 in addition to 12 and 1, so it is not a prime number.

Given an integer n, create a program to output the largest prime number smaller than n and the smallest prime number larger than n.

Input:
Multiple datasets are provided. Each dataset contains an integer n (3 <= n <= 50,000) on a single line. The number of datasets does not exceed 50.

Output:
For each dataset, output the largest prime number smaller than n and the smallest prime number larger than n separated by a single space on a single line.

Sample Input:
19
3517

Output for the Sample Input:
17 23
3511 3527

# Buggy version:
n = 50000
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j <= n:
        c[j - 1] = 0
        j += i
    i += 1

while True:
    try:
        n = int(input())
        i, a, b = 0, 0, 0
        while a == 0 and b == 0:
            i += 1
            if n - i >= 0 and a == 0 and c[n - i] == 1:
                a = n - i
            if n + i < 50000 and b == 0 and c[n + i] == 1:
                b = n + i
        print(a,b)
    except:
        break



# Fixed version:
n = 50021
c = [1 for i in range(n)]
c[0] = 0
i = 2
while i**2 <= n:
    j = i*2
    while j <= n:
        c[j - 1] = 0
        j += i
    i += 1

while True:
    try:
        n = int(input())
        i, a, b = 0, 0, 0
        while a == 0 or b == 0:
            i += 1
            if n - i - 1 >= 0 and a == 0 and c[n - i - 1] == 1:
                a = n - i
            if n + i - 1 < 50021 and b == 0 and c[n + i - 1] == 1:
                b = n + i
        print(a,b)
    except:
        break
Blood Type

Read data containing the attendance numbers and ABO blood types of students in a class, and create a program to output the number of individuals for each blood type. The ABO blood types include A, B, AB, and O.

Input

Multiple lines containing comma-separated pairs of attendance numbers and blood types. The attendance numbers are integers between 1 and 50, and the blood types are strings "A", "B", "AB", or "O". The number of students does not exceed 50.

Output

Output the number of individuals for each blood type in the following order:
1st line: Number of individuals with blood type A
2nd line: Number of individuals with blood type B
3rd line: Number of individuals with blood type AB
4th line: Number of individuals with blood type O

Sample Input

1,B
2,A
3,B
4,AB
5,B
6,O
7,A
8,O
9,AB
10,A
11,A
12,B
13,AB
14,A

Output for the Sample Input

5
4
3
2

# Buggy version:
a={'A':0,'B':0,'O':0,'AB':0}
while 1:
    try:
        _,b=input().split(",")
        a[b]+=1
    except:
        for i in a:print(a[i])
        break

# Fixed version:
a={'A':0,'B':0,'O':0,'AB':0}
while 1:
    try:
        _,b=input().split(",")
        a[b]+=1
    except:
        for i in ['A','B','AB','O']:print(a[i])
        break

# Buggy version:
a = 0
b = 0
o = 0
ab = 0
while True:
    try:
        n, bt = input().split(",")
        if bt =="A":
            a += 1
        elif bt =="B":
            b += 1
        elif bt =="O":
            o += 1
        elif bt =="AB":
            ab += 1
    except:
        break
print(a, b, o, ab, sep="\n")



# Fixed version:
a = 0
b = 0
o = 0
ab = 0
while True:
    try:
        n, bt = input().split(",")
        if bt =="A":
            a += 1
        elif bt =="B":
            b += 1
        elif bt =="O":
            o += 1
        elif bt =="AB":
            ab += 1
    except:
        break
print(a, b, ab, o, sep="\n")

# Buggy version:
ac = bc = oc = abc = 0
while 1:
	try: n, bt = input().split(",")
	except: break
	if bt == "A": ac += 1
	elif bt == "B": bc += 1
	elif bt == "O": oc += 1
	elif bt == "AB": abc +=1
print(ac)
print(bc)
print(oc)
print(abc)


# Fixed version:
ac = bc = oc = abc = 0
while 1:
	try: n, bt = input().split(",")
	except: break
	if bt == "A": ac += 1
	elif bt == "B": bc += 1
	elif bt == "O": oc += 1
	elif bt == "AB": abc +=1
print(ac)
print(bc)
print(abc)
print(oc)
Factorial II

n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1

This is called the factorial of n. For example, the factorial of 12 is 479001600, which ends with two consecutive zeros.

Create a program that takes an integer n as input and outputs the number of consecutive zeros at the end of n!.

Input
Multiple data sets are provided. Each data set contains n (n ≤ 20000) on a single line. The input ends when n is 0.

There are no more than 20 data sets.

Output
For each data set, output the number of consecutive zeros at the end of n! on a single line.

Sample Input
2
12
10000
0

Output for the Sample Input
0
2
2499

# Buggy version:
while 1:
    try:
        zero=0
        number=1
        n=int(input())
        for i in range(1,n+1):
            number*=i
            while len(str(number))>7:number=int(str(number)[1:])
            while number%10==0:
                zero+=1
                number=int(number/10)
        print(zero)
    except:break


# Fixed version:
while 1:
    zero=0
    number=1
    n=int(input())
    if n==0:break
    for i in range(1,n+1):
        number*=i
        while len(str(number))>7:number=int(str(number)[1:])
        while number%10==0:
            zero+=1
            number=int(number/10)
    print(zero)

# Buggy version:
def fac(a):
    i=0
    b=5
    c=1
    while b<=a:
       i+=c*(a//b)
       b*=5
       c+=1
    return i
while True:
    a=int(input())
    if a!=0:
        print(fac(a))
    else:
        break

# Fixed version:
def fac(a):
    i=0
    b=5
    while b<=a:
       i+=(a//b)
       b*=5
    return i
while True:
    a=int(input())
    if a!=0:
        print(fac(a))
    else:
        break
You are given a positive integer D. Determine how many positive integers N satisfy the equation rev(N) = N + D, where rev(N) denotes the integer obtained by reversing the decimal notation of N (without leading zeroes). The input is a single integer D, and the output should be the number of positive integers N that satisfy the given equation.

# Buggy version:
from collections import deque
D=int(input())
def f(d,k):
  if 0<=k<=1:
    if d!=0:
      return "Unko"
    if k==1:
      return deque([0])
    else:
      return deque([])
  s=10-(d%10)
  if s==10:
    A=f(d//10,k-2)
    s=0
  #print(d,s,d-s*(10**(k-1))+s)
  else:
    A=f((d-s*(10**(k-1))+s)//10,k-2)
  if A=="Unko":
    return "Unko"
  A.appendleft(s)
  A.append(-s)
  return A
ans=0
for k in range(1,50):
  A=f(D,k)
  if A=="Unko":
    continue
  print(A)
  res=1
  for j in range((k+1)//2):
    if j==0:
      res*=9-abs(A[j])
    else:
      if A[j]==0:
        res*=10
      else:
        res*=9-abs(A[j]-1)
  ans+=res
print(ans)

# Fixed version:
from collections import deque
D=int(input())
def f(d,k):
  if 0<=k<=1:
    if d!=0:
      return "Unko"
    if k==1:
      return deque([0])
    else:
      return deque([])
  if d>=0:
    s=10-(d%10)
  else:
    s=-(d%10)
  if s==10:
    A=f(d//10,k-2)
    s=0
  #print(d,s,d-s*(10**(k-1))+s)
  else:
    A=f((d-s*(10**(k-1))+s)//10,k-2)
    
  if A=="Unko":
    return "Unko"
  A.appendleft(s)
  A.append(-s)

  return A
ans=0
for k in range(1,50):
  A=f(D,k)
  if A=="Unko":
    continue
 # print(A)
  res=1
  for j in range((k+1)//2):
    if j==0:
      res*=9-abs(A[j])
    else:
      if A[j]==0:
        res*=10
      else:
        res*=10-abs(A[j])
  ans+=res
print(ans)
Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). The task is to find the number of possible candidates for the value of Nukes's integer. The input consists of two integers, A and B, and the output should be the number of possible candidates for the value of Nukes's integer.

# Buggy version:
a=int(input())
b=int(input())
if a==b:
  print(1)
  exit()
abin=bin(a)[2:]
bbin=bin(b)[2:]
la=len(abin)
lb=len(bbin)
if la==lb:
  while abin[0]==bbin[0]:
    del abin[0]
    del bbin[0]
  while abin[0]=="0":
    del abin[0]
cbin=bbin[1:]
while cbin[0]=="0":
  del cbin[0]
c=2**(len(cbin))
a=int(abin,2)
lbnd=2**(lb-1)+c
hbnd=2**(lb-1)+a
if lbnd>=hbnd:
  print(lbnd-a+1)
else:
  print(2**(lb-1)-a+lbnd-a+1)

# Fixed version:
a=int(input())
b=int(input())
if a==b:
  print(1)
  exit()
abin=bin(a)[2:]
bbin=bin(b)[2:]
la=len(abin)
lb=len(bbin)
if la==lb:
  while abin[0]==bbin[0]:
    abin=abin[1:]
    bbin=bbin[1:]
  while len(abin)>1 and abin[0]=="0":
    abin=abin[1:]
cbin=bbin[1:]
while cbin and cbin[0]=="0":
  cbin=cbin[1:]
c=2**(len(cbin))-1
a=int(abin,2)
b=int(bbin,2)
lb=len(bbin)
lbnd=2**(lb-1)+c
hbnd=2**(lb-1)+a
if lbnd>=hbnd:
  print(2**lb-a)
else:
  print(2**(lb-1)-a+lbnd-a+1)

# Buggy version:

import math
A = int(input())
B = int(input())
if B < A: A,B = B,A

if A == B:
    print(1)
else:
    t = int(math.floor(math.log2(B)))
    while (A & 2**t) == (B & 2**t):
        if A & 2**t:
            A -= 2**t
            B -= 2**t
        t-=1
    ans = 2**t - A              # [A,2^t-1]
    r = t-1
    while 2**t + 2**r > B and r>=0:
        r-=1
    print(r)
    # [2^t,2^t+2^{r+1}-1] \cup [2^t+A,2^{t+1}-1]
    C = 2**(r+1)
    if C < A:
        ans += C + 2**t - A
    else:
        ans += 2**t
    print(ans)


# Fixed version:

import math
A = int(input())
B = int(input())
if B < A: A,B = B,A

if A == B:
    print(1)
else:
    t = int(math.floor(math.log2(B)))
    while (A & 2**t) == (B & 2**t):
        if A & 2**t:
            A -= 2**t
            B -= 2**t
        t-=1
    ans = 2**t - A              # [A,2^t-1]
    r = t-1
    while 2**t + 2**r > B and r>=0:
        r-=1
    # [2^t,2^t+2^{r+1}-1] \cup [2^t+A,2^{t+1}-1]
    C = 2**(r+1)
    if C < A:
        ans += C + 2**t - A
    else:
        ans += 2**t
    print(ans)
Alice lives on a line and will travel to a destination using a vehicle. Initially, the distance between Alice and her destination is D. When she inputs a number x to the vehicle, it will travel in the direction of the destination by a distance of x if this move would shorten the distance, and it will stay at its position otherwise. The vehicle may go past the destination when the distance between the vehicle and the destination is less than x. Alice has a list of N numbers, and she will insert these numbers to the vehicle one by one. A mischievous witch wants to rewrite one number in the list so that Alice will not reach the destination after N moves. The program should determine whether each plan is feasible. Constraints: 1≤N≤5*10^5, 1≤Q≤5*10^5, 1≤D≤10^9, 1≤d_i≤10^9(1≤i≤N), 1≤q_i≤N(1≤i≤Q). The input is given in the format: N D, followed by N numbers, then Q, and finally Q numbers. The output should contain Q lines, each indicating whether the corresponding plan is feasible (YES) or not (NO).

# Buggy version:
N, D = map(int, input().split())
d = list(map(int, input().split()))
Q = int(input())
q = list(map(lambda x : int(x)-1 , input().split()))

dis = [0 for i in range(N+1)]
dis[0] = D
for i in range(0, N):
    dis[i+1] = min(dis[i], abs(dis[i] - d[i]))

dp = [0 for i in range(N+1)]
dp[N] = 1
for i in range(N-1, -1, -1):
    if d[i] // 2 >= dp[i+1]:
        dp[i] = dp[i+1]
    else:
        dp[i] = dp[i+1] + d[i]

for i in range(Q):
    print(["YES", "NO"][dis[q[i]] <= dp[q[i] + 1]])

# Fixed version:
N, D = map( int, input().split() )
d = list( map( int, input().split() ) )
Q = int( input() )
q = list( map( int, input().split() ) )

dis = [ 0 for i in range( N + 1 ) ]
dis[ 0 ] = D
for i in range( N ):
  dis[ i + 1 ] = min( dis[ i ], abs( dis[ i ] - d[ i ] ) )

dp = [ 0 for i in range( N + 1 ) ]
dp[ N ] = 1
for i in range( N - 1, -1, -1 ):
  if dp[ i + 1 ] <= d[ i ] // 2:
    dp[ i ] = dp[ i + 1 ]
  else:
    dp[ i ] = dp[ i + 1 ] + d[ i ]

for qi in range( Q ):
  print( [ "NO", "YES" ][ dis[ q[ qi ] - 1 ] >= dp[ q[ qi ] ] ] )
Max Score: 250 Points
Problem Statement:
Mr.X, whose handle name is T, looked at a list containing N handle names, S_1, S_2, ..., S_N. However, some parts of the list are invisible and denoted by "?". Calculate all possible indices of Mr.X's handle name when sorting N+1 handle names (S_1, S_2, ..., S_N, and T) in lexicographical order. Note: If there are people with the same handle name, either one may come first.
Input:
The input is given from standard input in the following format:
N
S_1
S_2
...
S_N
T
Output:
Calculate the possible indices and print them in sorted order. The output should be separated by a space. Put a line break at the end.
Constraints:
1 ≤ N ≤ 10000
1 ≤ |S_i|, |T| ≤ 20 (|A| is the length of A.)
S_i consists of lowercase alphabets and "?".
T consists of lowercase alphabets.
Scoring:
Subtask 1 [130 points]: No "?"s.
Subtask 2 [120 points]: No additional constraints.
Sample Input 1:
2
tourist
petr
e
Sample Output 1:
1
There are no invisible parts, so there is only one possibility. The sorted handle names are "e", "petr", "tourist", so "e" comes first.
Sample Input 2:
2
?o?r?s?
?et?
e

# Buggy version:
n = int(input())
s_list = list()
for i in range(n):
    s_list.append(input())
t = input()

s_list_a = [s.replace("?","a") for s in s_list]
s_list_a.append(t)
s_list_a.sort()
index_a = [i+1 for i,x in enumerate(s_list_a) if x == t]

s_list_z = [s.replace("?","z") for s in s_list]
s_list_z.append(t)
s_list_z.sort()
index_z = [i+1 for i,x in enumerate(s_list_z) if x == t]

indexes = [i for i in range(index_z[0],index_a[-1]+1)]

print(indexes)

# Fixed version:
n = int(input())
s_list = list()
for i in range(n):
    s_list.append(input())
t = input()

s_list_a = [s.replace("?","a") for s in s_list]
s_list_a.append(t)
s_list_a.sort()
index_a = [i+1 for i,x in enumerate(s_list_a) if x == t]

s_list_z = [s.replace("?","z") for s in s_list]
s_list_z.append(t)
s_list_z.sort()
index_z = [i+1 for i,x in enumerate(s_list_z) if x == t]

indexes = [str(i) for i in range(index_z[0],index_a[-1]+1)]

answer = ' '.join(indexes)

print(answer)
You are given a problem to find the number of infinite sequences consisting of {1, 2, ..., n} that satisfy certain conditions. The conditions are that the n-th and subsequent elements are all equal, and for every integer i, the elements immediately following the i-th element are all equal. You need to find the count of such sequences modulo 10^9+7. The input is an integer n, and the output should be the count of sequences satisfying the conditions, modulo 10^9+7. For example, if the input is 2, the output should be 4, and for input 654321, the output should be 968545283.

# Buggy version:
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+10)
dp_cum = [0] * (N+10)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[-1] + 1
answer %= MOD
print(answer)

# Fixed version:
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+10)
dp_cum = [0] * (N+10)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[N] + 1
answer %= MOD
print(answer)
Title: Frog's Straight Return

A frog is trying to return to its burrow. The burrow is located <var>D</var> centimeters ahead, and the frog moves straight towards it. The frog has two possible actions:
- Big jump (moves <var>L</var> centimeters forward)
- Small jump (moves 1 centimeter forward)

The frog aims to land exactly at the burrow without jumping over it.

Create a program to determine the minimum number of jumps the frog needs to make to return to the burrow.

Input:
The input is given in the following format:
<var>D</var> <var>L</var>

The input consists of a single line, providing the distance to the burrow <var>D</var> (1 ≤ <var>D</var> ≤ 10000) and the distance the frog moves with a big jump <var>L</var> (2 ≤ <var>L</var> ≤ 10000).

Output:
Output the minimum number of jumps the frog needs to make on a single line.

Sample Input 1:
10 5

Sample Output 1:
2

Sample Input 2:
7 4

Sample Output 2:
4

# Buggy version:
a,b=map(int,input().split())
c=a//b
d=a%b
e=c+b
print(e)


# Fixed version:
a,b=map(int,input().split())
c=a//b
d=a%b
e=c+d
print(e)

# Buggy version:
print(sum(divmod(map(int, input().split())))

# Fixed version:
print(sum(divmod(*map(int,input().split()))))