qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a, b = map(int, input().split())
sum(map(lambda i: 1 if str(i) == str(i)[::-1] else 0, range(a, b+1)))

Fixed code:
a, b = map(int, input().split())
print(sum(map(lambda i: 1 if str(i) == str(i)[::-1] else 0, range(a, b+1))))
Buggy code:
a,b = map(int,input().split())
ans = 0
for i in range(a,b):
    if str(i[0]) == str(i[4]) and str(i[1]) == str(i[3]):
        ans += 1
print(ans)

Fixed code:
a,b=map(int,input().split())
ans=0
for i in range(a,b+1):
  if str(i)[0]==str(i)[4] and str(i)[1]==str(i)[3]:
    ans+=1
print(ans)
Buggy code:
a,b=int(input().split())
c=0
while a<=b:
  s=str(a)
  if s==s[::-1]:
    c+=1
  a+=1
print(c)

Fixed code:
a,b=map(int, input().split())
c=0
while a<=b:
  s=str(a)
  if s==s[::-1]:
    c+=1
  a+=1
print(c)
Buggy code:
def Is_cyc(x):
  s = str(x)
  for i in range(len(s)):
    if s[i] != s[-i-1]:
      return False
  return True

def main():
  a,b = map(int,input().split())
  ans = 0
  for i in range(a,b+1):
    if Is_cyc(i):
      ans += 1
  print(ans)

Fixed code:
def Is_cyc(x):
  s = str(x)
  for i in range(len(s)):
    if s[i] != s[-i-1]:
      return False
  return True

def main():
  a,b = map(int,input().split())
  ans = 0
  for i in range(a,b+1):
    if Is_cyc(i):
      ans += 1
  print(ans)
  return

if __name__ == "__main__":
  main()
Buggy code:
a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
  s = str(i)
  if s[0] == s[4] and s[1] == s[2]:
    ans += 1
print(ans)

Fixed code:
a,b = map(int,input().split())
ans = 0
for i in range(a,b+1):
  s = str(i)
  if s[0] == s[4] and s[1] == s[3]:
    ans += 1
print(ans)
Buggy code:
A,B = map(int,input().split())
ans = 0
for i in range(A,B+1):
    i = str(i)
    if i[0] == i[4]:
        if i[1] == i[3]:
            ans += 1
            print(i)
        else:
            ans += 0
    else:
        ans += 0
print(ans)

Fixed code:
A,B = map(int,input().split())
ans = 0
for i in range(A,B+1):
    i = str(i)
    if i[0] == i[4]:
        if i[1] == i[3]:
            ans += 1
        else:
            ans += 0
    else:
        ans += 0
print(ans)
Buggy code:
a,b = map(int,input().split())
ans = 0
def kai(s):
 for j in range(len(s)):
  if s[j] != s[len(s)-j-1]:
   return(0)
  return(1)
for i in range(a,b+1):
 ans += kai(str(i))
print(ans)

Fixed code:
a,b = map(int,input().split())
ans = 0
def kai(s):
 for j in range(len(s)):
  if s[j] != s[len(s)-j-1]:
   return(0)
 return(1)
for i in range(a,b+1):
 ans += kai(str(i))
print(ans)
Buggy code:
a,b = map(int,input().split())
t = 0
for i in range(a,b+1):
    if i % 100 == i // 1000 or i % 100 * 10 == i // 1000:
        t += 1

print(t)

Fixed code:
a,b = map(int,input().split())
t = 0

for i in range(a,b+1):
    m = i // 1000
    n = i % 10 * 10 + i % 100 // 10
    if n == m:
        t += 1

print(t)
Buggy code:
A, B = map(int , input())
res = 0
for(n in range of (A, B+1)):
    lst = []
    while(n > 0):
        l.append(n%10)
        n //= 10
    if (l[0]==l[4] and l[1]==l[3]):
        res += 1
print(res)

Fixed code:
A, B = map(int , input().split())
res = 0
for n in range(A, B+1):
    l = []
    while(n > 0):
        l.append(n%10)
        n //= 10
    if (l[0]==l[4] and l[1]==l[3]):
        res += 1
print(res)
Buggy code:
A, B = map(int, input().split())

res = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            cand = int(''.join([str(i), str(j), str(k), str(j), str(i)]))
            if A <= cand <= B:
                print(cand)
                res += 1

print(res)

Fixed code:
A, B = map(int, input().split())

res = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            cand = int(''.join([str(i), str(j), str(k), str(j), str(i)]))
            if A <= cand <= B:
                res += 1

print(res)
Buggy code:
def is_palindromic(n):
    if str(n) == str(n)[::-1]:
        True
    else:
        False

res = 0
A,B = map(int, input().split())
for i in range(A, B):
    if is_palindromic(i):
       res += 1 
print(res)

Fixed code:
def is_palindromic(n):
    if str(n) == str(n)[::-1]:
        return True
    else:
        return False

res = 0
A,B = map(int, input().split())
for i in range(A, B+1):
    if is_palindromic(i):
       res += 1 
print(res)
Buggy code:
# -*- coding: utf-8 -*-
"""
B - Palindromic Numbers
https://beta.atcoder.jp/contests/abc090/tasks/abc090_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A, B):
    ans = 0
for i in range(A, B+1):
        s1 = str(i)
        s2 = s1[::-1]
        if s1 == s2:
            ans += 1
    return ans


def main(args):
    A, B = map(int, input().split())
    ans = solve(A, B)
    print(ans)

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


Fixed code:
# -*- coding: utf-8 -*-
"""
B - Palindromic Numbers
https://beta.atcoder.jp/contests/abc090/tasks/abc090_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A, B):
    ans = 0
    for i in range(A, B+1):
        s1 = str(i)
        s2 = s1[::-1]
        if s1 == s2:
            ans += 1
    return ans


def main(args):
    A, B = map(int, input().split())
    ans = solve(A, B)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])
Buggy code:
def is_kaibun(n):
    ns = [int(v) for v in str(n)]

    i = 0
    j = len(ns) - 1
    while i < j:
        if ns[i] != ns[j]:
            return False
        i += 1
        j -= 1

    return True


A, B = map(int, input().split())

count = 0
for i in range(A, B + 1):
    if is_kaibun(i):
        print(i)
        count += 1

print(count)


Fixed code:
def is_kaibun(n):
    ns = [int(v) for v in str(n)]

    i = 0
    j = len(ns) - 1
    while i < j:
        if ns[i] != ns[j]:
            return False
        i += 1
        j -= 1

    return True


A, B = map(int, input().split())

count = 0
for i in range(A, B + 1):
    if is_kaibun(i):
        count += 1

print(count)
Buggy code:
A,B = int(input().split())
count = 0
for i in range(A,B+1):
  if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]:
    count += 1
print(count)

Fixed code:
A,B = map(int,input().split())
count = 0
for i in range(A,B+1):
  if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]:
    count += 1
print(count)
Buggy code:
A = int(input())
B = int(input())
result = []
for i in range(A,B+1):
    if (str(i)[0] == str(i)[4]) & (str(i)[1] == str(i)[3]):
        result.append(i)
print(len(result))

Fixed code:
A,B =map(int,input().split())
result = []
for i in range(A,B+1):
    if (str(i)[0] == str(i)[4]) & (str(i)[1] == str(i)[3]):
        result.append(i)
print(len(result))
Buggy code:
a, b = map(int, input().split())
ans = 0
for i in range(1,10):
  for j in range(0,10):
    for k in range(0.10):
  x = 10000*i + 1000*j + 100*k + 10*j + i
  if a <= x <= b:
    ans += 1
print(ans)

Fixed code:
a, b = map(int, input().split())
ans = 0
for i in range(1,10):
  for j in range(0,10):
    for k in range(0,10):
      x = 10000*i + 1000*j + 100*k + 10*j + i
      if a <= x <= b:
        ans += 1
print(ans)
Buggy code:
N, K = map(int,input().split())
total = 0
num = 1
for i in range(K+1,N+1):
    total += N//i*num
    num += 1
    total += max(N%i-K+1,0)

print(total)

Fixed code:
N, K = map(int,input().split())
total = 0
num = 1
for i in range(K+1,N+1):
    total += N//i*num
    num += 1
    if K == 0:
        total += max(N%i-K,0)
    else:        
        total += max(N%i-K+1,0)

print(total)
Buggy code:
N,K=[int(x) for x in input().split()]
counter=0
for b in range(max(1,K+1),N+1):
	tobeadded=(N//b)*(b-K) + max(0,N%b+1-K)
	counter+=tobeadded
print(counter)

Fixed code:
N,K=[int(x) for x in input().split()]
counter=0
for b in range(max(1,K),N+1):
	tobeadded=(N//b)*(b-K) + max(0,N%b+1-K)
	counter+=tobeadded
if K==0:
	counter-=N
print(counter)
Buggy code:
import sys
n,k = map(int,input().split())
ans = 0
if k == 0:
    print(n**2)
    sys.exit()
for b in range(k+1,n+1):
    ans_per_loop = b - k
    loop, r = divmod(n,b)
    new = ans_per_loop*loop
    if r >= k:
        new += r-k+1
    print(new)
    ans += new
print(ans)


Fixed code:
import sys
n,k = map(int,input().split())
ans = 0
if k == 0:
    print(n**2)
    sys.exit()
for b in range(k+1,n+1):
    ans_per_loop = b - k
    loop, r = divmod(n,b)
    new = ans_per_loop*loop
    if r >= k:
        new += r-k+1
    ans += new
print(ans)
Buggy code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()

ans = 0
for b in range(K+1, N+1):
    cnt = 0
    while b*(cnt+1)<=N:
        ans += b*(cnt+1)-(b*cnt+K)
        cnt += 1
    ans += max(0, N-b*cnt-K+1)
print(ans)

Fixed code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()

ans = 0
for b in range(K+1, N+1):
    cnt = 0
    while b*(cnt+1)<=N:
        ans += b*(cnt+1)-(b*cnt+K)
        cnt += 1
    if K!=0:
        ans += max(0, N-b*cnt-K+1)
    else:
        ans += max(0, N-b*cnt-K)
print(ans)
Buggy code:
n,k=map(int,input().split())
b=[i for i in range(k+1,n+1)]
ans=0
if k==0:
    for i in range(len(b)):
    t=b[i]
    j=t-k
    ii=n//t
    ans+=ii*j
    ans+=max(n-ii*t-k,0)
    print(ans)
    exit()
for i in range(len(b)):
    t=b[i]
    j=t-k
    ii=n//t
    ans+=ii*j
    ans+=max(n-ii*t-k+1,0)
print(ans)

Fixed code:
n,k=map(int,input().split())
b=[i for i in range(k+1,n+1)]
ans=0
if k==0:
    for i in range(len(b)):
        t=b[i]
        j=t-k
        ii=n//t
        ans+=ii*j
        ans+=max(n-ii*t-k,0)
    print(ans)
    exit()
for i in range(len(b)):
    t=b[i]
    j=t-k
    ii=n//t
    ans+=ii*j
    ans+=max(n-ii*t-k+1,0)
print(ans)
Buggy code:
n,k = map(int,input().split())
print(sum([(i-k)*(n//i)+max(0,n%i-k+1) for i in range(k+1,n+1)]))

Fixed code:
n,k = map(int,input().split())
print(sum([(i-k)*(n//i)+max(0,n%i-max(0,k-1)) for i in range(k+1,n+1)]))
Buggy code:
n , k = map(int,input().split())
ans = 0
if k == 0:
    ans = n**2
else:
    for b in range(k+1,n+1):
        ans += ((n-b+1)//b + 1)*(b-k)
        if k - 1 < n % b < b-1:
            ans += n % b - k + 1
        print(str(b) +" to " + str(ans))
print(ans)

Fixed code:
n , k = map(int,input().split())
ans = 0
if k == 0:
    ans = n**2
else:
    for b in range(k+1,n+1):
        ans += ((n-b+1)//b + 1)*(b-k)
        if k - 1 < n % b < b-1:
            ans += n % b - k + 1
print(ans)
Buggy code:
import sys
sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    N,K=MI()
    ans=0
    for b in range(K+1,N+1):
        ans+=((N+1)//b)*(b-K)
        ans+=max((N+1)%b-K,0)
        #print(b,((N+1)//b)*(b-K),max((N+1)%b-K,0))
        
        
    print(ans)
    
            
    


main()

Fixed code:
import sys
sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    N,K=MI()
    ans=0
    for b in range(K+1,N+1):
        ans+=((N+1)//b)*(b-K)
        ans+=max((N+1)%b-K,0)
        #print(b,((N+1)//b)*(b-K),max((N+1)%b-K,0))
    if K==0:
        ans=N*N
        
        
    print(ans)
    
            
    


main()
Buggy code:
N,K=map(int,input().split());print(sum(N//b*(b-K)+max(N%b+1-K,0)-(K<1)for b in range(N+1)))

Fixed code:
N,K=map(int,input().split());print(sum(N//b*(b-K)+max(N%b+1-K,0)-(K<1)for b in range(K+1,N+1)))
Buggy code:
import sys
n,k = map(int,input().split())
if k == 0:
    print(n**2)
    sys.exit
count = 0
for i in range(1,n+1):
    tmp_count = max(0,i - k)
    #print(i,n // i,tmp_count,(n // i)* tmp_count + max(0,(n % k)-k+1),max(0,(n % i)-k+1),n % i)
    count += (n // i)* tmp_count + max(0,(n % i)-k+1)
print(count)

Fixed code:
import sys
n,k = map(int,input().split())
#if k == 0:
#    print(n**2)
 #   sys.exit
count = 0
for i in range(1,n+1):
    tmp_count = max(0,i - k)
    #print(i,n // i,tmp_count,(n // i)* tmp_count + max(0,(n % k)-k+1),max(0,(n % i)-k+1),n % i)
    count += (n // i)* tmp_count + max(0,(n % i)-k+1)

if k == 0:
  count -= n
print(count)
Buggy code:
n,k = [int(i) for i in input().split()]
ans = 0
for i in range(k+1,n+1):
  m = (n+1)//i
  ans += (i-k)*m
  if m*i+k <= n:
    ans += n+1
    ans -= m*i
    ans -= k
print(ans)

Fixed code:
n,k = [int(i) for i in input().split()]
ans = 0
if k != 0:
  for i in range(k+1,n+1):
    m = (n+1)//i
    ans += (i-k)*m
    if m*i+k <= n:
      ans += n+1
      ans -= m*i
      ans -= k
else:
  ans = n**2
print(ans)
Buggy code:
n,k = map(int,input().split())
point = 0
for b in range(1,n+1):
    kaisu = n//b
    kosuu = max(0,b-k)
    point += kaisu*kosuu
    point += max(0,n%b+1-k)
if k == 0:
    point -= n

Fixed code:
n,k = map(int,input().split())
point = 0
for b in range(1,n+1):
    kaisu = n//b
    kosuu = max(0,b-k)
    point += kaisu*kosuu
    point += max(0,n%b+1-k)
if k == 0:
    point -= n
print(point)
Buggy code:
N,K=map(int,input().split())
res=0
for b in range(1,N+1):
    if(b<=K):
        continue
    res+=(N//b)*(b-K)
    res+=max(0,N%b-(K-1))
print(res)

Fixed code:
N,K=map(int,input().split())
res=0
for b in range(1,N+1):
    if(b<=K):
        continue
    res+=(N//b)*(b-K)
    if(K!=0):
        res+=max(0,N%b-(K-1))
    else:
        res+=N%b
print(res)
Buggy code:
N, K = map(int, raw_input().split())

ans = 0
for i in range(K + 1, N+1):
    ans += max(N % i - K + 1, 0) + (N / i) * (i - K)
    print i, ans

print ans


Fixed code:
N, K = map(int, input().split())
ans = 0
for i in range(K+1, N+1):
    ans += (N // i)*(i - K) + max(0, (N % i - max(0, (K - 1))))
print(ans)
Buggy code:
n,k = map(int,input().split())
ret = 0
for b in range(1, n+1):
    if b<k+1:
        continue
    else:
        m = n//b
        l = n%b
        ret += (b-k)*m
        if l!=0 and l>=k:
            ret += l-k+1
        elif l==0:
            ret += l
print(ret)

Fixed code:
n,k = map(int,input().split())
ret = 0
for b in range(1, n+1):
    if b<k+1:
        continue
    else:
        m = n//b
        l = n%b
        ret += (b-k)*m
        if k!=0 and l>=k:
            ret += l-k+1
        elif k==0:
            ret += l
print(ret)
Buggy code:
n, k = map(int,input().split())
a=0
for i in range(1,n):
  a+=max(0,i-k)*(n//i)+max(0,n%i-k+1)
if k==0:
  a-=n
print(a)


Fixed code:
n,k=map(int,input().split())
a=0
if k==0:
    print(n**2)
    exit()
for i in range(n):
    a+=max((n+1)//(i+1)*(i-k+1),0)+max((n+1)%(i+1)-k,0)
print(a)
Buggy code:
n, k = [int(i) for i in input().split()]
ans = 0
for i in range(1, n + 1):
    ans += (n // i) * (max(0, i - k))
    ans += max(n % i- k + 1, 0)
print(ans)


Fixed code:
n, k = [int(i) for i in input().split()]
ans = 0
for i in range(1, n + 1):
    ans += (n // i) * (max(0, i - k))
    ans += max(n % i- k + 1, 0)
print(ans - (n if k==0 else 0))
Buggy code:
,K=map(int,input().split())
def f(b):
  d=max(b-K,0)*(N//b)+max(N%b-K+1,0)
  return d
ans=0
if K==0:
  print(N**2)
  exit()
  
for i in range(1,N+1):
  ans+=(f(i))
print(ans)

Fixed code:
N,K=map(int,input().split())
def f(b):
  d=max(b-K,0)*(N//b)+max(N%b-K+1,0)
  return d
ans=0
if K==0:
  print(N**2)
  exit()
  
for i in range(1,N+1):
  ans+=(f(i))
print(ans)
Buggy code:
n,k=map(int,input().split())
ans=0
for b in range(1,N+1):
  p = N//b
  r = N%b
  ans+=p*max(0,b-K)
  ans+=max(0,r-K+1)
print(ans)


Fixed code:
n, k = map(int, input().split())
ans = 0
for b in range(1, n+1):
    p = n // b
    r = n % b
    ans += p * max(0, b - k) + max(0, r - k + 1)
if k == 0:
    ans -= n
print(ans)
Buggy code:
n,k = map(int, input().split())

ans=0
for b in range(1,n+1):
    if b<=k:
        continue
    num = n//b
    add=num * (b-k)

    nokori = n-b*num
    if nokori-k+1 > 0:
       add+= nokori - k+1

#    print("  ",b,num,add)
    ans+=add
print(ans)

Fixed code:
n,k = map(int, input().split())

if k==0:
    print(n*n)
    exit()

ans=0
for b in range(k+1,n+1):
    num = n//b
    add=num * (b-k)

    nokori = n-b*num
    if nokori-k+1 > 0:
       add+= nokori - k+1

#    print("  ",b,num,add)
    ans+=add
print(ans)
Buggy code:
n,k=map(int,input().split())
cnt=0
if k==0:
    print(n**2)
    exit()

for b in range(1,n+1):
    if b-1>=k:
        num=(n-n//b)//(b-1)
        cnt+=num*(b-k)
        #print(cnt,num)
print(cnt)

Fixed code:
n,k=map(int,input().split())
cnt=0
if k==0:
    print(n**2)
    exit()

for b in range(1,n+1):
    p=n//b
    r=n-p*b

    if b-1>=k:
        cnt+=p*(b-k)+max(r-k+1,0)
        #print(cnt,num)
print(cnt)
Buggy code:
n,k=map(int,input().split())
ans=0
if k==0:
    print(n*n)
for i in range(k+1,n+1):
    ans+=(i-k)*(n//i)
    if n-i*(n//i)-k+1>0:
        ans+=n-i*(n//i)-k+1
    # print(ans,i)
print(ans)

Fixed code:
n,k=map(int,input().split())
ans=0
if k==0:
    print(n*n)
    exit()
for i in range(k+1,n+1):
    ans+=(i-k)*(n//i)
    if n-i*(n//i)-k+1>0:
        ans+=n-i*(n//i)-k+1
    # print(ans,i)
print(ans)
Buggy code:
N, K = map(int, input().split())

def f(x, y):
    a, b = divmod(x,y)
#    print("aa",b*(a+1))
    return y*a*(a+1)//2 + (b+1)*(a+1)

r = 0
for b in range(K+1, N+1):
#    print(f(N-K, b), f(N-b, b))
    r += f(N-K, b)- f(N-b, b)
#    print(b, N-b+1, N-K+1)
#    print(b, (N-K)//b, (N-b)//b, (N-K)%b, (N-b)%b, b-K)
#    for j in range(N-b+1,N-K+1):
#        r += j//b + 1
print(r)


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

def f(x, y):
    a, b = divmod(x,y)
#    print("aa",b*(a+1))
    return y*a*(a+1)//2 + (b+1)*(a+1)

r = 0
for b in range(K+1, N+1):
#    print(f(N-K, b), f(N-b, b))
    r += f(N-K, b)- f(N-b, b)
    if K == 0:
        r -= 1
#    print(b, N-b+1, N-K+1)
#    print(b, (N-K)//b, (N-b)//b, (N-K)%b, (N-b)%b, b-K)
#    for j in range(N-b+1,N-K+1):
#        r += j//b + 1
print(r)
Buggy code:
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, K = rl()
answer = 0
for b in range(K+1, N+1):
    x = N // b
    answer += x * (b-K) + max(0, (N-(x*b))-K+1)
    #print(answer)

print(answer)
#59


Fixed code:
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, K = rl()
answer = 0
if K == 0:
    print(N**2)
    exit()
for b in range(K+1, N+1):
    x = N // b
    answer += x * (b-K) + max(0, (N-(x*b))-K+1)
    #print(answer)

print(answer)
#59
Buggy code:
import sys
N,K=map(int,input().split())
if K==0:
  print(N)
  sys.exit()
ans=0
for b in range(1,N+1):
  v=N//b
  r=N-b*v
  ans+=(v*(max(0,b-K))+max(0,r-K+1))
print(ans)

Fixed code:
import sys
N,K=map(int,input().split())
if K==0:
  print(N**2)
  sys.exit()
ans=0
for b in range(1,N+1):
  v=N//b
  r=N-b*v
  ans+=(v*(max(0,b-K))+max(0,r-K+1))
print(ans)
Buggy code:
def main():
    n,k = map(int,input().split())
    res = 0

    if k == 0:
        print(n ** 2)
    else:
        for b in range(k+1,n+1):
            res += (b-k) * (n//b)
            if n % b != 0:
                res +=max(0, n - ((n//b)*b+k) +1)
    print(res)
main()

Fixed code:
def main():
    n,k = map(int,input().split())
    res = 0

    if k == 0:
        print(n ** 2)
    else:
        for b in range(k+1,n+1):
            res += (b-k) * (n//b)
            if n % b != 0:
                res +=max(0, n - ((n//b)*b+k) +1)
        print(res)
main()
Buggy code:
def main():
    n, k = map(int, input().split(' '))
    result = [n//i*max(0,i-k) + max(0, n%i-k+1) for i in range(1, n+1)]
    if k == 0:
        result -= n
    print(result)
main()

Fixed code:
def main():
    n, k = map(int, input().split(' '))
    result = 0
    for i in range(1, n+1):
        result += n//i*max(0,i-k) + max(0, n%i-k+1)
    if k == 0:
        result -= n
    print(result)
main()
Buggy code:
n, k = map(int, input().split(' '))
result = 0
for i in range(1, n+1):
    p = n//i
    result += p*max(0, i-k)
    result += max(0, n%i-k+1)
print(result)

Fixed code:
n, k = map(int, input().split(' '))
result = 0
for i in range(1, n+1):
    p = n//i
    result += p*max(0,i-k)
    result += max(0, n%i-k+1)
    if k == 0:
        result -= 1
print(result)
Buggy code:
N,K=map(int,input().split())

ans=0
for i in range(K+1,N+1):
  ans+=(N-N%i)//i*(i-K)
  ans+=N%i-K+1if N%i>=K else 0
print(ans)

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

if K==0:
  print(N**2)
else:
  ans=0
  for i in range(K+1,N+1):
    ans+=(N-N%i)//i*(i-K)
    ans+=N%i-K+1if N%i>=K else 0
  print(ans)
Buggy code:
n,k=map(int,input().split());print(sum(n//b*(b-k)+max(n%b-k+(k>0),0)for b in range(k,n+1)))

Fixed code:
n,k=map(int,input().split());print(sum(n//b*(b-k)+max(n%b-k+(k>0),0)for b in range(k+1,n+1)))
Buggy code:
n, k = map(int,input().split())
for i in range(1,n):
  a=max(0,i-k)*(n//b)+max(0,n%i-k+1)
if k==0:
  a-=n
print(a)

Fixed code:
n,k=map(int,input().split())
a=0
for b in range(k+1,n+1):a+=(b-k)*(n//b)+max(0,n%b-k+1)-1*(k==0)
print(a)
Buggy code:
n,k=map(int,input().split())
a=0
for b in range(1,n+1):
    if b>k:
        a+=(b-k)*(n//b)+(n%b-k+1)*(n%b>k-1)
print(a)
    

Fixed code:
n,k=map(int,input().split())
a=0
for b in range(1,n+1):
    if b>k:
        a+=(b-k)*(n//b)+(n%b-k+1)*(n%b>k-1)-1*(k==0)
print(a)
Buggy code:
N,K=map(int,input().split())
 
# if K == 0:
#     print(N**2)
#     exit()
 
b = K + 1
s = 0
while b <= N:
    c = N % b
    s += (N//b)*(b-K) + max(0,c-K+1)
    b += 1

print(s)


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

if K == 0:
    print(N**2)
    exit()

b = K + 1
s = 0
while b <= N:
    c = N % b
    s += (N//b)*(b-K) + max(0,c-K+1)
    b += 1

print(s)
Buggy code:
N, K = map(int, input().split())

res = 0
    
for b in range(1, N + 1):
    res += max(b - K, 0) * (N  // b)
    res += max(N % b - K + 1, 0)
 
if k == 0:
    res -= 10
print(res)

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

res = 0
    
for b in range(1, N + 1):
    res += max(b - K, 0) * (N  // b)
    res += max(N % b - K + 1, 0)
 
if K == 0:
    res -= N
print(res)
Buggy code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())

ans = 0
for b in range(K+1, N+1):
    tmp = 0
    tmp += (N//b)*(b-K)
    r = N % b
    tmp += max(0, r-K+1)
    ans += tmp
print(ans)


Fixed code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())

ans = 0
if K == 0:
    ans = N*N
else:
    for b in range(K+1, N+1):
        ans += (N//b)*(b-K)
        r = N % b
        if K <= r < b:
            ans += max(0, r-K+1)
print(ans)
Buggy code:
N, K = [int(_) for _ in input().split()]
ans = 0
for i in range(K + 1, N + 1):
    ans += (i - K) * (N // i) + max(N % i - (K - 1), 0)
print(ans)


Fixed code:
N, K = [int(_) for _ in input().split()]
ans = 0
for mod in range(K + 1, N + 1):
    ans += (mod - K) * (N // mod) + max(N % mod - max(K - 1, 0), 0)
print(ans)
Buggy code:
N,K = map(int,input().split())
ans = 0
for b in range(K+1,N+1):
    p = N // b
    r = N % b
    ans += p*(b-K)+max(0,r-K+1)

print(ans)


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

if K == 0:
    print(N**2)
    exit()
ans = 0
for b in range(1,N+1):
    p = N//b
    r = N%b
    ans += p*max(0,b-K) + max(0,r-K+1)

print(ans)
Buggy code:
ans = 0
N,K = list(map(int,input().split()))
for i in range(N):
    b=i+1
    p=int(N/b)

    ans+=max(0,b-K)*p+max(0,N-p*b-K+1)
    

print(ans)

Fixed code:

N,K = list(map(int,input().split()))
ans = 0

for i in range(N):
    b=i+1
    p=int(N/b)
    
    ans+=max(0,b-K)*p+max(0,N-p*b-K+1)
    if K==0:
        ans-=1

print(ans)
Buggy code:
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
  ans+=(n//i)*max(0,i-k)
  ans+=max(0,(n%i+1)-k)
print(ans)

Fixed code:
n,k = list(map(int,input().split()))
ans = 0
for i in range(k+1,n+1):
    ans += (n//i)*(i-k)+max(n%i-k+1,0)
if k==0: ans-=n
print(ans)