qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a,b,k = map(int,input().split())
l=[]
for i in range(k+1):
    if a+i not in l and a+i<=b:
        l.append(a+i)
for i in range(k+1):
    if b-k+i not in l and b-k+i>=a:
        l.append(b-k+i)
for i in range(len(l)):
    print(l[i])

Fixed code:
a,b,k = map(int,input().split())
l=[]
for i in range(k):
    if a+i not in l and a+i<=b:
        l.append(a+i)
for i in range(k):
    if b-k+1+i not in l and b-k+1+i>=a:
        l.append(b-k+1+i)
m=sorted(l)
for i in range(len(m)):
    print(m[i])
Buggy code:
a,b,k=map(int,input().split())
ab_min=[]
ab_max=[]
for i in range(a,a+k):
    ab_min.append(i)
for j in range(b+1-k,b+1):
    ab_max.append(j)

ans=list(set(ab_min)|set(ab_max))
ans.sort()

for k in range(len(ans)):
    print(ans[k])

Fixed code:
a,b,k=map(int,input().split())
ab_min=[]
ab_max=[]
for i in range(a,min(b+1,a+k)):
    ab_min.append(i)
for j in range(max(a,b+1-k),b+1):
    ab_max.append(j)

ans=list(set(ab_min)|set(ab_max))
ans.sort()

for k in range(len(ans)):
    print(ans[k])
Buggy code:
A,B,K = map(int, input().split())
if 2*K < B-A+1:
    for i in range(K):
        print(A+i)
    for i in range(K):
        print(B-i)
else:
    for i in range(B-A+1):
        print(A+i)

Fixed code:
A,B,K = map(int, input().split())
if 2*K < B-A+1:
    for i in range(K):
        print(A+i)
    for i in range(K):
        print(B-K+i+1)
else:
    for i in range(B-A+1):
        print(A+i)
Buggy code:
# coding:utf-8
a, b, k = map(int, input().split())

for i in range(a, min(a + k, b)):
    print(i)

for i in range(max(b - k + 1, a + k), b + 1):
    print(i)


Fixed code:
# coding:utf-8
a, b, k = map(int, input().split())

for i in range(a, min(a + k, b + 1)):
    print(i)

for i in range(max(b - k + 1, a + k), b + 1):
    print(i)
Buggy code:
A, B, K = map(int, input().split())
arr = range(A, B + 1)
ans = []
for i in range(K):
    ans.append(A + i)
for j in range(K):
    ans.append(B + 1 - K + j)

anset = list(set(ans))
if A+K<=B+1:
    for ele in range(len(anset)):
        print(anset[ele])
else:
    for ele in range(A,B+1):
        print(ele)


Fixed code:
A, B, K = map(int, input().split())
arr = range(A, B + 1)
ans = []
for i in range(K):
    ans.append(A + i)
for j in range(K):
    ans.append(B + 1 - K + j)

anset = list(set(ans))
anset.sort()
if A+K<=B+1:
    for ele in range(len(anset)):
        print(anset[ele])
else:
    for ele in range(A,B+1):
        print(ele)
Buggy code:
A, B, K = map(int, input().split())

s = set()

for i in range(A, A + K):
    s.add(i)

for i in range(B, B - K, -1):
    s.add(i)

s = sorted(s)

for i in s:
    print(i)


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

s = set()

for i in range(A, min(A + K, B + 1)):
    s.add(i)

for i in range(B, max(A - 1, B - K), -1):
    s.add(i)

s = sorted(s)

for i in s:
    print(i)
Buggy code:
a, b, k = map(int, input().split())
for i in range(a, min(a + k, b + 1)):
    print(i)
for j in range(max(i + 1, b - k + 1), b + 1):
    print(i)

Fixed code:
a, b, k = map(int, input().split())
for i in range(a, min(a + k, b + 1)):
    print(i)
for j in range(max(i + 1, b - k + 1), b + 1):
    print(j)
Buggy code:
a,b,k=list(map(int,input().split()))
for i in range(a,a+k):
  if i<=b:
    print(i)

for i in range(b-k+1,b+1):
  if i>=a:
    print(i)


Fixed code:
a,b,k=list(map(int,input().split()))
for i in range(a,a+k):
  if i<=b:
    print(i)

for i in range(b-k+1,b+1):
  if i>=a+k:
    print(i)
Buggy code:


def main():
    a,b,k = map(int,input().split())
    ansSet = set()


    if a+k > b:
        c = b
    else:
        c = a+k

    for i in range(a,c):
        ansSet.add(i)
    
    if b-k < a:
        c = a
    else:
        c = b-k

    for i in range(b,c,-1):
        ansSet.add(i)

    print(sorted(list(ansSet)))


if __name__== "__main__":
    main() 






Fixed code:


def main():
    a,b,k = map(int,input().split())
    ansSet = set()


    if a+k > b:
        c = b
    else:
        c = a+k
    
    if a == c:
        c += 1

    for i in range(a,c):
        ansSet.add(i)
    
    if b-k < a:
        c = a
    else:
        c = b-k

    for i in range(b,c,-1):
        ansSet.add(i)

    for i in sorted(list(ansSet)):
        print(i)


if __name__== "__main__":
    main()
Buggy code:
a, b, k = map(int, input().split())
ans = set()
for i in range(a,a+k):
    if i <= b:
        ans.add(i)
for i in range(b-k+1,b+1):
    if i >= a:
        ans.add(i)
ans = list(ans)
for i in range(len(ans)):
    print(ans[i])
    

Fixed code:
a, b, k = map(int, input().split())
ans = set()
for i in range(a,a+k):
    if i <= b:
        ans.add(i)
for i in range(b-k+1,b+1):
    if i >= a:
        ans.add(i)
ans = list(ans)
ans.sort()
for i in range(len(ans)):
    print(ans[i])
Buggy code:
a, b, k = map(int, input().split())

t = []

for i in range(k):
    t.append(i+a)

for i in range(k):
    t.append(b-i)

y = list(set(t))

for x in sorted(y):
    print(x)


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

t = []

for i in range(k):
    if i+a <= b:
        t.append(i+a)

for i in range(k):
    if b-i >= a:
        t.append(b-i)

y = list(set(t))

for x in sorted(y):
    print(x)
Buggy code:
A, B, K = map(int, input().split())

ans_array = []

for i in range(A, A + K if B > (A + K) else B):
    ans_array.append(i)

for i in range(B, B - K if A < (B - K) else A, -1):
    ans_array.append(i)

ans_array = sorted(list(set(ans_array)))

print(ans_array)


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

ans_array = []

for i in range(A, A + K if B > (A + K) else (B+1)):
    ans_array.append(i)

for i in range(B, B - K if A < (B - K) else (A-1), -1):
    ans_array.append(i)

ans_array = sorted(list(set(ans_array)))

for i in ans_array:
    print(i)
Buggy code:
A, B, K= map(int, input().split())
ans={}
for i in range(A,min([A+K+1,B-K-1]),1):
  if i<A+K:
    print(i)
    
    
for i in range(max([A, B-K-1]),B+1,1):
  if i>B-K:
    print(i)

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

for i in range(A,min([A+K+1,B+1]),1):
  if i<A+K:
    print(i)
    
for i in range(max([A+K, B-K-1]),B+1,1):
  if i>B-K:
    print(i)
Buggy code:
a, b, k = map(int, input().split())
if b - a + 1 <= k:
    for i in range(a, b+1):
        print(i):
else:
    for i in range(a, a+k-1):
        print(i)
    for i in range(b-k+1, b):
        print(i)

Fixed code:
a, b, k=map(int, input().split())
if a+k-1>=b-k+1:
  for i in range(a, b+1):
    print(i)
else:
  for i in range(a, a+k):
    print(i)
  for i in range(b-k+1, b+1):
    print(i)
Buggy code:
a,b,k=map(int,input().split())
l=sorted(list(set([i for i in range(a,a+k)]+[i for i in range(b-k+1,b+1)])))
for i in l:
  print(i)

Fixed code:
a,b,k=map(int,input().split())
l=sorted(list(set([i for i in range(a,min(a+k,b+1))]+[i for i in range(max(b-k+1,a),b+1)])))
for i in l:
  print(i)
Buggy code:
a,b,k = map(int,input().split())
for i in range(a,a+k):
    if i > b:
        break
    print(i)
for i in range(b-k+1,b+1):
    if i <= a+k:
        continue
    print(i)


Fixed code:
a,b,k = map(int,input().split())
for i in range(a,a+k):
    if i > b:
        break
    print(i)
for i in range(b-k+1,b+1):
    if i < a+k:
        continue
    print(i)
Buggy code:
A,B,K=map(int,input().split())
C=set()
for i in range(A,min(A+K,B+1)):
  C.add(i)
for i in range(max(B-K+1,A),B+1):
  C.add(i)
for x in C:
  print(x)

Fixed code:
A,B,K=map(int,input().split())
C=set()
for i in range(A,min(A+K,B+1)):
  C.add(i)
for i in range(max(B-K+1,A),B+1):
  C.add(i)
for x in sorted(list(C)):
  print(x)
Buggy code:
a,b,k = map(int,input().split())

for i in range(a,a+k):
  print(i)

for i in range(b-k-1,b):
  print(i)

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

for i in range(a, min(a + k, b + 1)):
    print(i)
for i in range(max(a + k, b + 1 - k), b + 1):
    print(i)
Buggy code:
a,b,k = map(int,input().split())

li1 = [i for i in range(a,a+k) if i <= b]
li2 = [i for i in range(b+1-k,b+1) if i >= a]

li1.extend(li2)
li1 = set(li1)

for i in li1:
    print(i)



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

li1 = [i for i in range(a,a+k) if i <= b]
li2 = [i for i in range(b+1-k,b+1) if i >= a]

li1.extend(li2)
li1 = set(li1)

for i in sorted(li1):
    print(i)
Buggy code:
A,B,K = map(int, input().split())

if (B-A)>2*K:
    for i in range(A,A+K,1):
        print(i)
    for j in range(B-K,B,1):
        print(j)

else:
    for k in range(A,B+1,1):
        print(k)



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

if (B-A)>=2*K:
    for i in range(A,A+K,1):
        print(i)
    for j in range(B-K+1,B+1,1):
        print(j)

else:
    for k in range(A,B+1,1):
        print(k)
Buggy code:
a,b,k = map(int,input().split())

lst1 = [i for i in range(a,a+k)]
lst2 = [i for i in range(b-k+1,b+1)]

lst = sorted(list(set(lst1 + lst2)))

for i in lst:
    print(i)

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

if (b-a+1) < k:
    for i in range(a,b+1):
        print(i)
else:  
    lst1 = [i for i in range(a,a+k)]
    lst2 = [i for i in range(b-k+1,b+1)]

    lst = sorted(list(set(lst1 + lst2)))

    for i in lst:
        print(i)
Buggy code:
a,b,k = map(int,input().split())
x = []
for i in range(k):
    x.append(a+i)
    x.append(b-i)
x = sorted(list(set(x)))
for i in x:
    print(i)


Fixed code:
a,b,k = map(int,input().split())
x=[]
for i in range(k):
    if a<=a+i<=b:
        x.append(a+i)
        x.append(b-i)
x = sorted(list(set(x)))
for i in x:
    print(i)
Buggy code:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if (a+c-1)>(b-c-1):
  for i in range(c):
    print(a+i)
  for i in range(c):
    print(b-c+1+i)
else:
  for i in range(a,b+1):
    print(i)

Fixed code:
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if (a+c-1)<(b-c+1):
  for i in range(c):
    print(a+i)
  for i in range(c):
    print(b-c+1+i)
else:
  for i in range(a,b+1):
    print(i)
Buggy code:
#56
a,b,k = map(int,input().split())
num = []

if b-a <= k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        num.append(i)
    for i in range(b-k+1,b+1):
        num.append(i)

    num = set(num)

    for i in num:
        print(i)

Fixed code:
#56
a,b,k = map(int,input().split())
num = []

if b-a <= k:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        num.append(i)
    for i in range(b-k+1,b+1):
        num.append(i)
        
    num = list(set(num))
    num.sort()
    
    for i in num:
        print(i)
Buggy code:
#Small and Large Integers
A,B,K = map(int,input().split())
L = []
for i in range(K):
    if A+i <= B: 
        L.append(A+i)
    if A <= B-i:
        L.append(B-i)

S = set(L)
L = list(S)
for i in range(len(L)):
    print(L[i])

Fixed code:
#Small and Large Integers
A,B,K = map(int,input().split())
L = []
for i in range(K):
    if A+i <= B: 
        L.append(A+i)
    if A <= B-i:
        L.append(B-i)

S = set(L)
L = list(S)
L.sort()
for i in range(len(L)):
    print(L[i])
Buggy code:
A, B, K = map(int, input().split())
ret = set(range(A, A + K))
ret.update(range(B - K+1, B+1))

for r in sorted(ret):
    print(r)

Fixed code:
A, B, K = map(int, input().split())
ret = set(range(A, min(A + K, B)))
ret.update(range(max(A, B - K + 1), B + 1))

for r in sorted(ret):
    print(r)
Buggy code:
import numpy as np
a,b,k = map(int,input().split())
data = [i for j in (range(a,a+k),range(b-k+1,b+1)) for i in j]
data = np.unique(data)
for i in data:
    print(i)


Fixed code:
import numpy as np
a,b,k = map(int,input().split())
data = [i for j in (range(a,min(a+k,b)),range(max(b-k+1,a),b+1)) for i in j]
data = np.unique(data)
for i in data:
    print(i)
Buggy code:
A, B, K = map(int, input().split())
x = A
while x < A+K and x <= B:
    print(x)
    x += 1
for y in range(max(x+1, B-K+1), B+1):
    print(y)

Fixed code:
A, B, K = map(int, input().split())
x = A
while x < A+K and x <= B:
    print(x)
    x += 1
for y in range(max(x, B-K+1), B+1):
    print(y)
Buggy code:
A,B,K=map(int,input().split())
ans=[]
for i in range(A,B+1):
  if i <= A+K:
    ans.append(i)
  if i >= B-K:
    ans.append(i)
    
for i in sorted(set(ans)):
    print(i)

Fixed code:
A,B,K=map(int,input().split())
ans=[]
for i in range(K):
  if A+i <= B:
    ans.append(A+i)
  if B-i >= A:
    ans.append(B-i)

for i in sorted(set(ans)):
  print(i)
Buggy code:
A, B, K = map(int, input().split())

if B - A + 1 < K:
    for i in range(A, B + 1):
        print(i)

else:
    for i in range(A, A + K):
        print(i)

    for i in range(B - K + 1, B + 1):
        print(i)

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

if B - A + 1 < 2*K:
    for i in range(A, B + 1):
        print(i)

else:
    for i in range(A, A + K):
        print(i)

    for i in range(B - K + 1, B + 1):
        print(i)
Buggy code:
a,b,c  = map(int,input().split())
li = []
for i in range(c):
    if(a+i < b-i):
        li.extend([a+i,b-i])
    else:
        break
for i in sorted(li):
    print(i)

Fixed code:
a,b,c  = map(int,input().split())
li = []
for i in range(c):
    if(a+i <= b-i):
        li.extend([a+i,b-i])
    else:
        break
for i in sorted(set(li)):
    print(i)
Buggy code:
import math
q=int(input())
for i in range(q):
 a,b=map(int,input().split())
 if abs(a-b)<2:print(min(a,b)*2-2)
 else:
  s=int(math.sqrt(a*b))
  if s**2+2>=a*b:print(2*s-2)
  else:print(2*s-1)

Fixed code:
import math
q=int(input())
for i in range(q):
 a,b=map(int,input().split())
 if abs(a-b)<2:print(min(a,b)*2-2)
 else:
  s=int(math.ceil(math.sqrt(a*b)))-1
  if s**2+s<a*b:print(2*s-1)
  else:print(2*s-2)
Buggy code:
def main():
    n = int(input())
    for _ in range(n):
        a, b = map(int, input().split())
        ref = a * b
        rng = int(ref ** 0.5) - 1
        if rng == 0:
            print(0)
        elif a == b or abs(a - b) == 1:
            print(2 * a - 2)
        elif rng * (rng + 1) >= a * b:
            print(2 * rng - 2)
        else:
            print(2 * rng - 1)
if __name__ == '__main__':
    main()

Fixed code:
def main():
    n = int(input())
    for _ in range(n):
        a, b = map(int, input().split())
        ref = a * b - 1
        rng = int(ref ** 0.5) - 2
        while rng ** 2 < a * b:
            rng += 1
        rng -= 1
        if a == b or abs(a - b) == 1:
            print(2 * min(a, b) - 2)
        elif rng * (rng + 1) >= a * b:
            print(2 * rng - 2)
        else:
            print(2 * rng - 1)
if __name__ == '__main__':
    main()
Buggy code:
from math import sqrt

q = int(input())
query = [tuple(map(int, input().split())) for _ in range(q)]


def sqrtfloor(x):
    s = int(sqrt(x))
    if s ** 2 == x:
        s -= 1
    return s


def solve(a, b):
    a, b = min(a, b), max(a, b)
    if a == b or a + 1 == b:
        return 2 * a - 1
    else:
        s = sqrtfloor(a * b)
        if s * (s + 1) < a * b:
            return 2 * s - 1
        else:
            return 2 * s - 2


for a, b in query:
    print(solve(a, b))


Fixed code:
from math import sqrt

q = int(input())
query = [tuple(map(int, input().split())) for _ in range(q)]


def sqrtfloor(x):
    s = int(sqrt(x))
    if s ** 2 == x:
        s -= 1
    return s


def solve(a, b):
    a, b = min(a, b), max(a, b)
    if a == b or a + 1 == b:
        return 2 * a - 2
    else:
        s = sqrtfloor(a * b)
        if s * (s + 1) < a * b:
            return 2 * s - 1
        else:
            return 2 * s - 2


for a, b in query:
    print(solve(a, b))
Buggy code:
Q = int(input())
for i in range(Q):
    a,b = (map(int, input().split()))
    if(a == b or a+1 == b):
        print(2*a -2)
    else:
        c = int((a*b) ** 0.5)
        if(c*(c+1) > a*b):
            print(2*c-2)
        else:
            print(2*c-1)


Fixed code:
n = int(input())
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        print(2*a-2)
    else:
        c = int((a*b)**0.5)
        if c**2 == a*b:
            c -= 1
        if c*(c+1) >= a*b:
            print(2*c-2)
        else:
            print(2*c-1)
Buggy code:
import math,bisect
q = int(input())
for i in range(q):
  a,b = map(int,input().split())
  y = max(a,b)
  z = min(a,b)
  ind = int(math.sqrt(a*b-1))
  cnt = 0
  if ind*(ind+1) < a*b:
    if ind >= z:
      cnt = 1
    if ind+1 >= y:
      cnt = 2
    print(2*ind-cnt)
  else:
    if ind >= z:
      cnt = 1
    if ind >= y:
      cnt = 2
    print(2*ind-1-cnt)

Fixed code:
import math
q = int(input())
for i in range(q):
  a,b = map(int,input().split())
  if a == b:
    print(a*2-2)
    continue
  y = max(a,b)
  z = min(a,b)
  ind = math.sqrt(a*b)
  d = int(ind)
  if ind.is_integer():
    d -= 1
  cnt = 0
  if d*(d+1) < a*b:
    if d >= z:
      cnt = 1
    if d+1 >= y:
      cnt = 2
    print(2*d-cnt)
  else:
    if d >= z:
      cnt = 1
    print(2*d-1-cnt)
Buggy code:
Q = int(input())

ans = []
for _ in range(Q):
    A, B = map(int, input().split())

    if A == B:
        ans.append(2 * A - 2)

    C = (A * B)**0.5
    D = int(C)

    if D**2 == A * B:
        D -= 1

    F = 2 * D - 1
    if D * (D + 1) >= A * B:
        F -= 1

    ans.append(F)

print(*ans, sep='\n')

Fixed code:
Q = int(input())

ans = []
for _ in range(Q):
    A, B = map(int, input().split())

    if A == B:
        ans.append(2 * A - 2)
        continue

    C = (A * B)**0.5
    D = int(C)

    if D**2 == A * B:
        D -= 1

    F = 2 * D - 1
    if D * (D + 1) >= A * B:
        F -= 1

    ans.append(F)

print(*ans, sep='\n')
Buggy code:
q = int(input())
ab = [list(map(int, input().split())) for _ in range(q)]

for a, b in ab:
    if a == b:
        print(2 * a - 2)
        continue

    l = 0
    r = 10 ** 10
    while r - l > 1:
        m = (l + r) // 2
        mx = (m + 1) // 2 * (m - (m + 1) // 2)
        if mx < a * b:
            l = m
        else:
            r = m

    print(l)


Fixed code:
q = int(input())
ab = [list(map(int, input().split())) for _ in range(q)]

for a, b in ab:
    if a == b:
        print(2 * a - 2)
        continue

    l = 1
    r = 10 ** 10
    while r - l > 1:
        m = (l + r) // 2
        mx = (m + 1) // 2 * (m + 1 - (m + 1) // 2)
        if mx < a * b:
            l = m
        else:
            r = m

    print(l - 1)
Buggy code:
def solve(A, B):
    from math import sqrt
    M = A * B
    cnt = 0

    x, y = A, B
    if y - x >= 1:
        z = int(sqrt(M))
        x = z
        y = M // x if M % x else M // x - 1
        cnt += z - x
    cnt += y - 1

    x, y = A, B
    if y - x >= 1:
        z = int(sqrt(M))
        x = z
        y = M // x if M % x else M // x - 1
        cnt += z - x
    cnt += y - 1
    
    return cnt


Q = int(input())
Query = [tuple(map(int, input().split())) for _ in range(Q)]

for A, B in Query:
    print(solve(A, B))


Fixed code:
def solve(A, B):
    from math import sqrt
    M = A * B
    cnt = 0

    x, y = A, B
    if y - x >= 1:
        z = int(sqrt(M))
        x = z
        y = M // x if M % x else M // x - 1
        cnt += z - A
    cnt += y - 1

    x, y = B, A
    if y - x >= 1:
        z = int(sqrt(M))
        x = z
        y = M // x if M % x else M // x - 1
        cnt += z - B
    cnt += y - 1

    return cnt


Q = int(input())
Query = [tuple(map(int, input().split())) for _ in range(Q)]

for A, B in Query:
    print(solve(A, B))
Buggy code:
q=int(input())
for _ in range(q):
  a,b=map(int,input().split())
  if a>b:
    a,b=b,a
  if a==b:
    print(2*a-1)
  elif a==b+1:
    print(2*a-2)
  else:
    c=int((a*b)**0.5)
    if c*(c+1)>=a*b:
      print(2*c-2)
    else:
      print(2*c-1)

Fixed code:
q=int(input())
for _ in range(q):
  a,b=map(int,input().split())
  if a>b:
    a,b=b,a
  if a==b:
    print(2*a-2)
  elif a==b+1:
    print(2*a-1)
  else:
    c=int((a*b)**0.5)
    if c*c==a*b:
      c-=1
    if c*(c+1)>=a*b:
      print(2*c-2)
    else:
      print(2*c-1)
Buggy code:
Q=int(input())
for i in range(Q):
    A,B=map(int,input().split())
    if A>B:
        A,B=B,A
    if A+1==B:
        print((A-1)*2)
    else:
        SQ=int(pow(A*B,0.5))
        if SQ**2==A*B:
            print((SQ-1)*2-1)
        elif SQ*(SQ+1)<A*B:
            print((SQ-1)*2+1)
        else:
            print((SQ-1)*2)


Fixed code:
Q=int(input())
for i in range(Q):
    A,B=map(int,input().split())
    if A>B:
        A,B=B,A
    if A==B:
        print((A-1)*2)
    elif A+1==B:
        print((A-1)*2)
    else:
        SQ=int(pow(A*B,0.5))
        if SQ**2==A*B:
            print((SQ-1)*2-1)
        elif SQ*(SQ+1)<A*B:
            print((SQ-1)*2+1)
        else:
            print((SQ-1)*2)
Buggy code:
q = int(input())
for _ in range(q):
    R = list(map(int, input().split()))
    a, b = min(R), max(R)
    if b - a <= 1:
        res = 2 * (a-1)

    else:
        c = int((a*b)**0.5)
        if c ** 2 == a * b:
            c -= 1
        if c * (c+1) < a * b:
            res = 2 * (c-1) + 1
        else:
            res = 2 * (c-1) - 1
    print(res)

Fixed code:
q = int(input())
for _ in range(q):
    R = list(map(int, input().split()))
    a, b = min(R), max(R)
    if b - a <= 1:
        res = 2 * (a-1)

    else:
        c = int((a*b)**0.5)
        if c ** 2 == a * b:
            c -= 1
        if c * (c+1) < a * b:
            res = 2 * (c-1) + 1
        else:
            res = 2 * (c-1)
    print(res)
Buggy code:
#Editorial
from math import floor,sqrt
Q = int(input())
for _ in range(Q):
    A,B = map(int,input().split())
    if A > B:
        A,B = B,A
    if A == B:
        print(2*A-2)
    if A+1 == B:
        print(2*A-2)
    else:
        C = floor(sqrt(A*B-1))
        if C*(C+1) >= A*B:
            print(2*C-2)
        else:
            print(2*C-1)


Fixed code:
#Editorial
from math import floor,sqrt
Q = int(input())
for _ in range(Q):
    A,B = map(int,input().split())
    if A > B:
        A,B = B,A
    if A == B:
        print(2*A-2)
        continue
    if A+1 == B:
        print(2*A-2)
        continue
    C = floor(sqrt(A*B))
    if C == sqrt(A*B):
        C -= 1
    if C*(C+1) >= A*B:
        print(2*C-2)
    else:
        print(2*C-1)
Buggy code:
Q=int(input())
ab=[list(map(int,input().split())) for _ in range(Q)]

for a,b in ab:
    
    if a>b:
        a,b=b,a
    if a==b:
        print(2*(a-1))
        continue
        
    c = math.ceil((a*b)**0.5-1)
    
    if c*(c+1)>=a*b:
        print(2*(c-1))
    else:
        print(2*c-1)

Fixed code:
import math
Q=int(input())
ab=[list(map(int,input().split())) for _ in range(Q)]

for a,b in ab:
    
    if a>b:
        a,b=b,a
    if a==b:
        print(2*(a-1))
        continue
        
    c = math.ceil((a*b)**0.5-1)
    
    if c*(c+1)>=a*b:
        print(2*(c-1))
    else:
        print(2*c-1)
Buggy code:
import sys
from math import floor
Q = int(input())
AB = [list(map(int, input().split())) for _ in range(Q)]

for A, B in AB:
  C = floor((A*B)**(1/2))
  if C == (A*B)**(1/2):
    C -= 1
  if C*(C+1) >= A*B:
    print(2*C-2)
  elif C*C < A*B:
    print(2*C-1)


Fixed code:
import sys
from math import floor
Q = int(input())
AB = [sorted(list(map(int, input().split()))) for _ in range(Q)]

for A, B in AB:
  if A == B or A+1 == B:
    print(2*A-2)
    continue
  C = floor((A*B)**(1/2))
  if C == (A*B)**(1/2):
    C -= 1
  if C*(C+1) >= A*B:
    print(2*C-2)
  elif C*C < A*B:
    print(2*C-1)