TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i.  Snuke can apply the following operation to this grid any number of times:    * Choose two different rows and swap them. Or, choose two different columns and swap them.  Snuke wants this grid to be _symmetric_. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal.  Determine if Snuke can achieve this objective.

Submission attempts (in order):
h,w = list(map(int,input().split()))
s = []
for i in range(h):
    s.append(input())

con = []

for i in range(h):
    for j in range(i+1,h):
        ij = []
        ji = []
        for k in range(w):
            ij.append(s[i][k]+s[j][k])
            ji.append(s[j][k]+s[i][k])
        if sorted(ij) == sorted(ji):
            con.append([i,j])

rest = set()
for i in range(h):
    rest.add(i)
for x in con:
    if x[0] in rest and x[1] in rest:
        rest -= {x[0],x[1]}

if len(rest) <= 1:print('Yes')
else:print('No')


H, W = map(int, input().split())
S = [input() for i in range(H)]
 
def check(l):
    u = [0]*W
    mid = W % 2
    for i in range(W):
        if u[i]:
            continue
        for j in range(i+1, W):
            for p, q in l:
                sp = S[p]; sq = S[q]
                if sp[i] != sq[j] or sp[j] != sq[i]:
                    break
            else:
                u[j] = 1
                break
        else:
            if mid:
                for p, q in l:
                    sp = S[p]; sq = S[q]
                    if sp[i] != sq[i]:
                        break
                else:
                    mid = 0
                    continue
            break
    else:
        return 1
    return 0
 
def make(c, l, u, p):
    while c in u:
        c += 1
    if c == H:
        if check(l):
            print("YES")
            exit(0)
        return
    if p:
        l.append((c, c))
        make(c+1, l, u, 0)
        l.pop()
    for i in range(c+1, H):
        if i in u:
            continue
        u.add(i)
        l.append((c, i))
        make(c+1, l, u, p)
        l.pop()
        u.remove(i)
 
make(0, [], set(), H%2)
print("NO")

Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
# ANSHUL GAUTAM
# IIIT-D

A,B,C = map(int, input().split())
m = max(A,B,C)
s = sum(m-A,m-B,m-C)
if(s%2 == 0):
	print(s//2)
else:
	print(s//2 + 2)






# ANSHUL GAUTAM
# IIIT-D

A,B,C = map(int, input().split())
m = max(A,B,C)
s = sum((m-A,m-B,m-C))
if(s%2 == 0):
	print(s//2)
else:
	print(s//2 + 2)






Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
from math import sqrt 
Q = int(input())
table=[]
for i in range(Q):
    A,B=map(int,input().split())
    if A>B:
        table.append([B,A])
    else:
        table.append([A,B])
def f(a,b):
    if a==b:
        return 2*a-2
    if a+1==b:
        return 2*a-2
    m = int(sqrt(a*b))
    if m**2 ==a*b:
        return 2*m-3
    if m*(m+1) >= a*b:
        return 2*m -2
    return 2*m-1

ans = []
for a,b in table:
    ans.append(f(a,b))
print('\n'.join(map(str,ans)))

A,B,C=map(int,input().split())
L=[A,B,C]
L.sort()
ans=0
s=(L[-1]-L[0])//2
L[0]=L[0]+2*s
t=(L[-1]-L[1])//2
L[1]=L[1]+2*t
L.sort()
a=0
if L[0]!=L[1]:
    a=2
elif L[1]!=L[2]:
    a=1
print(s+t+a)

Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
# D
import math
Q = int(input())
A_list = []
B_list = []
for _ in range(Q):
    A, B = map(int, input().split())
    A_list.append(min(A, B))
    B_list.append(max(A, B))
    
for i in range(Q):
    A = A_list[i]
    B = B_list[i]
        
    if A == B:
        print(A+B-2)
        continue
        
    R = int(math.sqrt(A*B-1))
    Q = (A*B-1) // R
    
    if Q <= R+1:
        add = min(Q - A - 1, B - R - 1)    
    elif (Q - R)**2 - 4*(A*B-Q*R) > 0:
        add = int(((Q - R) - math.sqrt((Q - R)**2 - 4*(A*B-Q*R))) / 2)
        if (R + add)*(Q-add) == A*B:
            add -= 1
    else:
        add = 0
    print((A-1) + R + add)
    

# C
ABC = sorted(list(map(int, input().split())))

res = 0

res += ABC[2] - ABC[1]
ABC[0] += ABC[2] - ABC[1]
ABC[1] = ABC[2]

if (ABC[2] - ABC[0]) % 2 == 0:
    res += (ABC[2] - ABC[0]) // 2
else:
    res += (ABC[2] - ABC[0]) // 2 + 2
    
print(res)

Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
a=int(input())
b=int(input())
c=int(input())
num=[a,b,c]
num.sort()
ans=((num[2]*3)-(num[0]+num[1]+num[2]))/2
print(ans)


a,b,c=map(int,input().split())
num=[a,b,c]
num.sort()
ans=((num[2]*3)-(num[0]+num[1]+num[2]))/2
print(ans)


import math

a,b,c=map(int,input().split())
num=[a,b,c]
num.sort()
if (num[1]+num[0])%2==0:
	ans=((num[2]*3)-(num[0]+num[1]+num[2]))/2
else :
	ans=(((num[2]+1)*3)-(num[0]+num[1]+num[2]))/2
ans=math.floor(ans)
print(ans)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
lst = list(map(int,input().split()))
print(lst)
lst.sort()
count = 0
while len(set(lst)) != 1:
    for i in range(len(lst)-2):
        if lst[i] <= lst[i+1]-2:
            lst[i] += 2
        elif lst[i] <= lst[i+2] and lst[i+1] <= lst[i-1]:
            lst[i] += 1
            lst[i+1] += 1
    count += 1
    lst.sort()
    #print(lst)
print(count)



lst = list(map(int,input().split()))
#print(lst)
lst.sort()
count = 0
while len(set(lst)) != 1:
    for i in range(len(lst)-2):
        if lst[i] <= lst[i+1]-2:
            lst[i] += 2
        elif lst[i] <= lst[i+2] and lst[i+1] <= lst[i-1]:
            lst[i] += 1
            lst[i+1] += 1
    count += 1
    lst.sort()
    #print(lst)
print(count)


Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
a=list(map(int,input().split()))
cnt=0
for i in range(3):
  if a[i]%2==1:
    cnt+=1
if cnt==0 or cnt==3:
  print((3*max(a)-sum(a))//2)
else:
  print((max(a)+1-a[0])//2+(max(a)+1-a[1])//2+(max(a)+1-a[2])//2+1)


a=list(map(int,input().split()))
cnt=0
for i in range(3):
  if a[i]%2==1:
    cnt+=1
if cnt==0 or cnt==3:
  print((3*max(a)-sum(a))//2)
elif cnt==1 and max(a)%2==1 or cnt==2 and max(a)%2==0:
  print((max(a)-a[0])//2+(max(a)-a[1])//2+(max(a)-a[2])//2+1)
else:  
  print((max(a)+1-a[0])//2+(max(a)+1-a[1])//2+(max(a)+1-a[2])//2+1)


Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
li = [int(i) for i in input().split()]
count = 0
while True:
    li.sort(reverse=True)
    dif_1 = li[0] - li[1]
    dif_2 = li[1] - li[2]
    if dif_1 == 0 and dif_2 == 0:
        break
    if dif_1 == 1 and dif_2 == 0:
        li[1] += 1
        li[2] += 1
        count += 1
        continue
    else:
        li[2] += 2
        count += 1
print(li)


li = list(map(int, input().split()))
li.sort(reverse=True)
count, mod = divmod(li[0] * 2 - li[1] - li[2], 2)
if mod == 1:
    count += 2

print(count)

Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
s=list(map(int,input().split()))
a=max(s)*3-sum(s)
if a%2==1
    a+=3
print(a//2)

s=list(map(int,input().split()))
a=max(s)*3-sum(s)
if a%2==1:
    a+=3
print(a//2)

Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
x = sorted(list(map(int, input().split())))
count = 0
while(x[0] != x[2]):
    if(x[1] != x[2]):
        x[0] += 1
        x[1] += 1
    else:
        x[0] += 2
    count += 1
    x = sorted(x)


x = sorted(list(map(int, input().split())))
count = 0
while(x[0] != x[2]):
    if(x[1] != x[2]):
        x[0] += 1
        x[1] += 1
    else:
        x[0] += 2
    count += 1
    x = sorted(x)
print(count)


Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
from collections import Counter
def getinputdata():

    array_result = []
    
    array_result.append(input().split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

arr = sorted([int(x) for x in arr_data[0]])

mindata = int(arr[0])
middledata = int(arr[1])
maxdata = int(arr[2])

sabun01 = middledata-mindata
sabun02 = maxdata-middledata
sabun03 = maxdata-mindata

print(sabun01,sabun02,sabun03)


if sabun01 % 2 == 0 and sabun02 % 2 == 0:
    
    cnt01 = (sabun01 // 2) + sabun02
    
elif sabun01 % 2 == 0 and sabun02 % 2 != 0:
    
    cnt01 = (sabun01 // 2) + sabun02 

elif sabun01 % 2 != 0 and sabun02 % 2 != 0:

    cnt01 = (sabun01 // 2) + 1 + 2 + sabun02-1

elif sabun01 % 2 != 0 and sabun02 % 2 == 0:
    
    cnt01 = (sabun01 // 2) + 1 + 1 + sabun02



if sabun02 % 2 == 0 and sabun03 % 2 == 0:
    cnt02 = (sabun02 // 2) + sabun03
    
elif sabun02 % 2 == 0 and sabun03 % 2 != 0:
    cnt02 = (sabun02 // 2) + sabun03
    
    
elif sabun02 % 2 != 0 and sabun03 % 2 != 0:
    
    cnt02 = (sabun02 // 2) + 1  + 2 + sabun03-1
    
elif sabun02 % 2 != 0 and sabun03 % 2 == 0:
    
    cnt02 = (sabun02 // 2) + 1 + 1+ sabun03

print(min(cnt01,cnt02))    
    

from collections import Counter
def getinputdata():

    array_result = []
    
    array_result.append(input().split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

arr = sorted([int(x) for x in arr_data[0]])

mindata = int(arr[0])
middledata = int(arr[1])
maxdata = int(arr[2])

sabun01 = middledata-mindata
sabun02 = maxdata-middledata
sabun03 = maxdata-mindata


if sabun01 % 2 == 0 :
    
    cnt01 = (sabun01 // 2) + sabun02 

elif sabun01 % 2 != 0 and sabun02 % 2 != 0:

    cnt01 = (sabun01 // 2) + 1 + 2 + sabun02-1

elif sabun01 % 2 != 0 and sabun02 % 2 == 0:
    
    cnt01 = (sabun01 // 2) + 1 + 1 + sabun02



if sabun02 % 2 == 0 and sabun03 % 2 == 0:
    
    cnt02 = (sabun02 // 2) + sabun03
    
elif sabun02 % 2 == 0 and sabun03 % 2 != 0:
    
    cnt02 = (sabun02 // 2) + sabun03 + 2
    
elif sabun02 % 2 != 0:
    
    cnt02 = (sabun02 // 2) + 1  + 2 + sabun03-1
    
print(min(cnt01,cnt02))    
    

Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
a, b, c = sorted(map(int, input().split()))
a = c-a; b = c-b
p = a%2; q = b%2
if p and q:
    print(a//2+b//2)
elif p or q:
    print(a//2+b//2+2)
else:
    print(a//2+b//2)


a, b, c = sorted(map(int, input().split()))
a = c-a; b = c-b
p = a%2; q = b%2
if p and q:
    print(a//2+b//2+1)
elif p or q:
    print(a//2+b//2+2)
else:
    print(a//2+b//2)


Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
def twoNumIncrement(n, m):
    return n+1, m+1

def doubleIncrement(n):
    return n+1

def equal(A, B, C):
    return A==B and B==C

def evenEven(d1, d2):
    return d1//2 + d2//2

# tmpInput = "2 6 3\n"

inDatas = input().strip('\n').split(' ')

inDatas = list(map(int, inDatas))
inDatas.sort()
A = inDatas[0]
B = inDatas[1]
C = inDatas[2]

diff1 = C - A
diff2 = C - B

procCount = 0

if not diff1%2 and not diff2%2:
    print(evenEven(diff1, diff2))
elif diff1%2 or diff2%2:
    print(2+evenEven(diff1, diff2))
else:
    print(1+evenEven(diff1, diff2))



def evenEven(d1, d2):
    return d1//2 + d2//2

# tmpInput = "2 6 3\n"

inDatas = input().strip('\n').split(' ')

inDatas = list(map(int, inDatas))
inDatas.sort()
A = inDatas[0]
B = inDatas[1]
C = inDatas[2]

diff1 = C - A
diff2 = C - B

if not diff1%2 and not diff2%2:
    print(evenEven(diff1, diff2))
elif (diff1%2 and not diff2%2) or (not diff1%2 and diff2%2):
    print(2+evenEven(diff1, diff2))
else:
    print(1+evenEven(diff1, diff2))

Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
def main():
    num = [int(i) for i in input().split()]
    num.sort()
    ans = 0
    ans+=((num[2]-num[1])//2)
    num[1]+=(num[2]-num[1])//2*2
    ans+=((num[2]-num[0])//2)
    num[0]+=(num[2]-num[0])//2*2
    if not (num[0]==num[1] and num[1]==num[2] and num[0]==num[2]):
        ans += 2
    print(ans)

if __name__ == '__main__':
    main()

def main():
    num = [int(i) for i in input().split()]
    num.sort()
    ans = 0
    ans += (num[2]-num[1])
    ans+=(num[1]-num[0])//2
    if (num[1]-num[0])%2==1:
        ans+=2
    print(ans)


if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
N = int(input())
c = -1
s = 0
for i in range(N):
    ai,bi = map(int,input().split())
    s += ai
    if ai > bi:
        if c == -1:
            c = bi
        if bi < c:
            c = bi
if c == -1:
    print(0)
else:
    print(s-c)


x = list(map(int,input().split()))
x.sort()
a = x[2]-x[0]
b = x[2]-x[1]

if a%2 == 0 and b%2 == 0:print(a//2+b//2)
if a%2 == 0 and b%2 == 1:print(a//2+(b+1)//2+1)
if a%2 == 1 and b%2 == 0:print((a+1)//2+b//2+1)
if a%2 == 1 and b%2 == 1:print((a-1)//2+(b-1)//2+1)

Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
A,B,C = map(int,input().split())

M = sorted([A,B,C])
ans = 0

#Step 1
ans += M[2]-M[1]
M[0] += M[2]-M[1]
M[1] += M[2]-M[1]

#Step 2
ans += (M[2]-M[0])//2
if (M[2]-M[0])%2==0:
    M[0] += M[2]-M[0]
else:
    M[0] += M[2]-M[0]+1
    M[1] += 1
    M[2] += 1
    ans += 2
    
print(M,ans)

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

M = sorted([A,B,C])
ans = 0

#Step 1
ans += M[2]-M[1]
M[0] += M[2]-M[1]
M[1] += M[2]-M[1]

#Step 2
ans += (M[2]-M[0])//2
if (M[2]-M[0])%2==0:
    M[0] += M[2]-M[0]
else:
    M[0] += M[2]-M[0]+1
    M[1] += 1
    M[2] += 1
    ans += 2
    
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
l = list(map(int, input().split()))
l.sort()
a,b,c = l[0],l[1],l[2]
if (a-b)%2 == 1:
    print(c-a+1)
else:
    print(c-a+2)


l = list(map(int, input().split()))
l.sort()
a,b,c = l[0],l[1],l[2]
if (a-b)%2 == 0:
    print(c-b+(b-a)//2)
else:
    print(c-b+(b-a)//2+2)


Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
import math

def slv(A, B):
    A, B = (A, B) if A > B else (B, A)
    
    s = A * B
    c = math.floor(math.sqrt(A * B))
    
    if A == B:
        return 2 * c - 2
    elif c * c < s:
        return 2 * c - 2
    elif c * (c - 1) < s:
        return 2 * c - 3

Q = int(input())
for q in range(Q):
    A, B = map(int, input().split())
    print(slv(A, B))

lst = list(map(int, input().split()))

lst.sort()

mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av
ans1 = 0
mini += d
d2 = max - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans1 += 1

else:
    d2 = d2 // 2

ans1 += d + d2

ans2 = 0
mini = lst[0]
av = lst[1]
max = lst[2]

d = max - av

mini += d

d2 = max + 1 - mini

if d2 % 2:
    d2 = (d2 + 1) // 2
    ans2 += 1
else:
    d2 = d2 // 2

ans2 += d + d2 + 1

print(min(ans1, ans2))





Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
*a=map(int,open(0))
m=max(a)
t=m*3-sum(a)
if t%2==1:t+=3
print(t//2)

a,b,c=map(int,input().split())
a,b,c=sorted([a,b,c])

#parity=set(list(map(lambda x: x % 2,[a,b,c])))
parity=list(map(lambda x: x % 2,[a,b,c]))

if len(set(parity))==1:
    print(int((3*max(a,b,c)-a-b-c)/2))
else:
    if (b-c)%2==0:
        ex=1
    else:
        ex=2
    print(int((max(a,b,c)-a)/2)+int((max(a,b,c)-b)/2)+int((max(a,b,c)-c)/2) + ex)
    

a,b,c=map(int,input().split())

#parity=set(list(map(lambda x: x % 2,[a,b,c])))
parity=list(map(lambda x: x % 2,[a,b,c]))

if len(set(parity))==1:
    print(int((3*max(a,b,c)-a-b-c)/2))
else:
    if len(set(list(map(lambda x: x % 2,  set([a,b,c])-set([max(a,b,c)]) ))))==1:
        ex=1
    else:
        ex=2
    print(int((3*max(a,b,c)-a-b-c)/2) + ex)
    

a,b,c=map(int,input().split())
a,b,c=sorted([a,b,c])

#parity=set(list(map(lambda x: x % 2,[a,b,c])))
parity=list(map(lambda x: x % 2,[a,b,c]))

if len(set(parity))==1:
    print(int((3*max(a,b,c)-a-b-c)/2))
else:
    if (b-a)%2==0:
        ex=1
    else:
        ex=2
    print(int((max(a,b,c)-a)/2)+int((max(a,b,c)-b)/2)+int((max(a,b,c)-c)/2) + ex)
    

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
A = list(map(int, input().split()))
M = max(A)
S = sum(A)
M += M % 2 != S % 2
print((3 * M - sum) // 2)

A = list(map(int, input().split()))
M = max(A)
S = sum(A)
M += M % 2 != S % 2
print((3 * M - S) // 2)

Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10**6)

debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == "-d" else False
if debug_mode:
    import os
    infile = open(os.path.basename(__file__).replace(".py", ".in"))

    def input():
        return infile.readline()


# ==============================================================


def main():
    a, b, c = list(map(int, input().strip().split()))
    s = sum(a, b, c)
    x = min(a, b, c)
    steps = 0
    while True:
        if s + steps * 2 == 3 * x:
            break
        elif s + steps * 2 < 3 * x:
            steps += 1
        elif s + steps * 2 > 3 * x:
            x += 1
    print(steps)


main()

# ==============================================================

if debug_mode:
    infile.close()


import sys
sys.setrecursionlimit(10**6)

debug_mode = True if len(sys.argv) > 1 and sys.argv[1] == "-d" else False
if debug_mode:
    import os
    infile = open(os.path.basename(__file__).replace(".py", ".in"))

    def input():
        return infile.readline()


# ==============================================================


def main():
    a, b, c = list(map(int, input().strip().split()))
    s = sum((a, b, c))
    x = max(a, b, c)
    steps = 0
    while True:
        if s + steps * 2 == 3 * x:
            break
        elif s + steps * 2 < 3 * x:
            steps += 1
        elif s + steps * 2 > 3 * x:
            x += 1
    print(steps)


main()

# ==============================================================

if debug_mode:
    infile.close()


Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
a,b,c=sorted(map(int,input().split()));d,e=c-a,c-b;print(d//2+e//2+(3-d%2+e%2)%3)

a,b,c=sorted(map(int,input().split()));d,e=c-a,c-b;print(d//2+e//2+(3-d%2-e%2)%3)

Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
import numpy as np

a=np.vectorize(int)(input().split())

cnt2=np.vectorize(lambda x: int((np.max(a)-x)/2))(a)
cnt1=np.max(a)-a-2*cnt2
print(a)
print(sum(cnt2)+[0,2,1][sum(cnt1)])

import numpy as np

a=np.vectorize(int)(input().split())

cnt2=np.vectorize(lambda x: int((np.max(a)-x)/2))(a)
cnt1=np.max(a)-a-2*cnt2
print(sum(cnt2)+[0,2,1][sum(cnt1)])

Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
# -*- coding: utf-8 -*-
from math import sqrt
def inpl(): return map(int, input().split())
Q = int(input())

def check(X, m):
    if X//m > m:
        return True
    else:
        return False

for q in range(Q):
    A, B = inpl()
    if A > B:
        A, B = B, A

    X = A*B
    if X <= 2:
        print(0)
        continue
    elif X == 3:
        print(1)
        continue
    
    L = int(sqrt(X))
    if L*L == X:
        L -= 1

    ok, ng = 1, X+1
    while ng - ok > 1:
        m = (ok+ng)//2
        if check(X-1, m):
            ok = m
        else:
            ng = m
    
    tmp = L + ok
    
    if A == B:
        print(tmp)
    else:
        if A>1 and X-1//(A-1) == B and X-1//A == B-1:
            print(tmp-2)
        elif (X-1)//A == A:
            print(tmp-2)
        else:
            print(tmp-1)

# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
A, B, C = sorted(list(inpl()))
res = 0
res += (C-B)
A += res
B += res
d, m = divmod(B-A, 2)
res += d+2*m
print(res)

Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
ABC=list(map(int,input().split()))
ABC.sort()
ans=0
ans+=(ABC[2]-ABC[0])//2
if (ABC[2]-ABC[0])%2==1:
  ans+=(ABC[2]-ABC[0])//2
  ABC[0]=ABC[2]-1
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=1
  else:
    ans+=2  
else:
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=2

print(ans)


ABC=map(int,input().split())
ABC.sort()
ans=0
ans+=(ABC[2]-ABC[0])//2
if (ABC[2]-ABC[0])%2==1:
  ans+=(ABC[2]-ABC[0])//2
  ABC[0]=ABC[2]-1
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=1
  else:
    ans+=2  
else:
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=2
  else:
    ans+=1
print(ans)

ABC=list(map(int,input().split()))
ABC.sort()
ans=0
ans+=(ABC[2]-ABC[0])//2
if (ABC[2]-ABC[0])%2==1:
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=1
  else:
    ans+=2  
else:
  ans+=(ABC[2]-ABC[1])//2
  if (ABC[2]-ABC[1])%2 == 1:
    ans+=2

print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
s = list(input())

n = len(s)

a = [0] * n

MOD = 998244353

for i in range(n):
    a[i] = ord(s[i]) - ord('a')

if max(a) == min(a):
    print(1)
    exit()
elif n == 3:
    def solver(m):
        x = m // 100
        y = ( m % 100 ) // 10
        z = m % 10
        if x != y:
            c = (3 - x - y) % 3
            temp = c * 110 + z
            if temp not in ans:
                ans.add(temp)
                solver(temp)
        if y != z:
            c = (3 - y - z) % 3
            temp = x * 100 + c * 11
            if temp not in ans:
                ans.add(temp)
                solver(temp)

    t = a[0] * 100 + a[1] * 10 + a[2]
    ans = set()
    ans.add(t)
    solver(t)
    print(len(ans))
    exit()
elif n == 2:
    print(2)
    exit()

dp = [[0,0,0] for _ in range(3)]

dp[0][0] = 1
dp[1][1] = 1
dp[2][2] = 1

for i in range(n-1):
    T = [[0,0,0] for _ in range(3)]
    T[0][0] = (dp[1][0] + dp[2][0]) % MOD
    T[0][1] = (dp[1][1] + dp[2][1]) % MOD
    T[0][2] = (dp[1][2] + dp[2][2]) % MOD
    T[1][0] = (dp[0][2] + dp[2][2]) % MOD
    T[1][1] = (dp[0][0] + dp[2][0]) % MOD
    T[1][2] = (dp[0][1] + dp[2][1]) % MOD
    T[2][0] = (dp[0][1] + dp[1][1]) % MOD
    T[2][1] = (dp[0][2] + dp[1][2]) % MOD
    T[2][2] = (dp[0][0] + dp[1][0]) % MOD
    dp, T = T, dp

m = sum(a) % 3

ans = 3 ** (n-1) - (dp[0][m] + dp[1][m] + dp[2][m])

check = 1
for i in range(n-1):
    if a[i] == a[i+1]:
        check = 0
        break

ans += check

#print(dp, 2 ** (n-1))

print(ans % MOD)


a = list(map(int, input().split()))

a.sort()

temp = a[2] * 2 - a[1] - a[0]

if temp % 2 == 0:
    print(temp // 2)
else:
    print(temp // 2 + 2)


Verdicts: Wrong Answer

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
A, B, C = map(int, input().split(" "))
cnt = 0

if (A%2 == B%2) and (B%2 == C%2):
    pass
else:
    if A%2 == B%2:
        A += 1
        B += 1
        cnt += 1
    elif A%2 == C%2:
        A += 1
        C += 1
        cnt += 1
    else:
        B += 1
        C += 1
        cnt += 1

ABC = sorted([A, B, C])
cnt += (ABC[0] - ABC[1]) / 2
cnt += (ABC[0] - ABC[2]) / 2
print cnt

# -*- coding: utf-8 -*-


A, B, C = map(int, input().split(" "))
cnt = 0

if (A%2 == B%2) and (B%2 == C%2):
    pass
else:
    if A%2 == B%2:
        A += 1
        B += 1
        cnt += 1
    elif A%2 == C%2:
        A += 1
        C += 1
        cnt += 1
    else:
        B += 1
        C += 1
        cnt += 1

ABC = sorted([A, B, C])
cnt += (ABC[2] - ABC[1]) // 2
cnt += (ABC[2] - ABC[0]) // 2
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
n=int(input())
a=[0 for i in range(n)]
b=[0 for i in range(n)]
c=[0 for i in range(n)]
for i in range(n):
    a[i],b[i]=[int(i) for i in input().split()]
    c[i]=a[i]*b[i]
#print(a,b)

def keisan(d,e,f):
    count=0
    old_value=10**20
    for j in range(int(d)):
        value=min(old_value,int((d-1)/(j+1)))

#        print(value)

        if old_value==value:
            value-=1

        if value>0:
            if e!=j+1 and f!=value:
                count+=1
                old_value=value
            elif e==j+1:
               pass
            elif f==value:
               pass
        else:
            break
    print(count)

for i in range(n):        
    keisan(c[i],a[i],b[i])


a=[int(i) for i in input().split()]

a.sort()

if a[0]%2==0 and  a[1]%2==0 and  a[2]%2==0:
    print(int((3*max(a)-sum(a))/2))  
elif a[0]%2==1 and  a[1]%2==1 and  a[2]%2==1:
    print(int((3*max(a)-sum(a))/2))  

else:
    count=0
    for i in range(3):
        if a[i]%2==0:
            count+=1

    if count==2:
        for i in range(3):
            if a[i]%2==0:
                a[i]=a[i]+1
        print(int((3*max(a)-sum(a))/2)+1)  
        
    if count==1:
        for i in range(3):
            if a[i]%2==1:
                a[i]=a[i]+1
        print(int((3*max(a)-sum(a))/2)+1)  




Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
in = [int(i) for i in input().split(' ')]
A,B,C = in[0],in[1],in[2]
if (A+B+C - max(A,B,C)) % 2 == 0:
  print((3*max(A,B,C) - A - B - C)/2)
else:
  print((3*max(A,B,C) - A - B - C - 1)/2) + 2

tin = [int(i) for i in input().split(' ') ]
A,B,C = tin[0],tin[1],tin[2]
if (A+B+C - max(A,B,C)) % 2 == 0:
  print(int((3*max(A,B,C) - A - B - C)/2))
else:
  print( int( (3*max(A,B,C) - A - B - C - 1)/2 + 2 ) )

Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
Q = int(input())
for i in range(Q):
	A,B = map(int,input().split())
	if A == 1 and B == 1:
		print(0)
		continue
	score = A * B
	root = int((score-1) ** 0.5)
	ans = 2 * root
	if root >= A:
		ans -= 1
	if root >= B:
		ans -= 1
	if (score - 1) // root == root:
		ans -= 1
	print(ans)

l = sorted(list(map(int,input().split())))
C,B,A = l[0],l[1],l[2]
cnt = 0
while A != B or B != C or C != A:
	if A == B:
		if C < A:
			C += 2
			cnt += 1
		elif C > A:
			A += 1
			B += 1
			cnt += 1
	else:
		B += 1
		C += 1
		cnt += 1
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:    * Choose two among A, B and C, then increase both by 1.   * Choose one among A, B and C, then increase it by 2.  It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.

Submission attempts (in order):
lst = list(map(int, input().split()))

mval = max(lst)
sval = sum(lst)
cn = mval + sval % 2
n = (cn * 3 - sval-mval) // 2
print(n)



lst = list(map(int, input().split())).sort()

mval = lst[-1]
sval = sum(lst)
cn = mval + (sval-mval) % 2
n = (cn * 3 - sval) // 2
print(n)



# A, B, C = [11, 12, 15]
lst = list(map(int, input().split()))

mval = max(lst)
sval = sum(lst)
cn = mval + sval % 2
n = (cn * 3 - sval) // 2
print(n)




lst = sorted(list(map(int, input().split())))

mval = lst[-1]
sval = sum(lst)
cn = mval + (sval-mval) % 2
n = (cn * 3 - sval) // 2
print(n)



Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.  The _score_ of a participant is the product of his/her ranks in the two contests.  Process the following Q queries:    * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.

Submission attempts (in order):
import math 
Q=int(input())
table=[]
for i in range(Q):
    a,b=map(int,input().split())
    if a>b:
        table.append([b,a])
    else:
        table.append([a,b])
ans=[]
for a,b in table:
    s = int(math.sqrt(a*b))
    num=2*s-2
    if s-1>=a:
        num-=1
    if s*(s+1)<a*b:
        num+=2
    elif s*s<a*b:
        num+=1
    ans.append(num)
print('\n'.join(map(str,ans)))

from math import sqrt 
Q = int(input())
table=[]
for i in range(Q):
    A,B=map(int,input().split())
    if A>B:
        table.append([B,A])
    else:
        table.append([A,B])
def f(a,b):
    if a==b:
        return 2*a-2
    if a+1==b:
        return 2*a-2
    m = int(sqrt(a*b))
    if m**2 ==a*b:
        return 2*m-3
    if m*(m+1) >= a*b:
        return 2*m -2
    return 2*m-1

ans = []
for a,b in table:
    ans.append(f(a,b))
print('\n'.join(map(str,ans)))

Verdicts: Wrong Answer

Accepted
Problem: 10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.  The _score_ of a participant is the product of his/her ranks in the two contests.  Process the following Q queries:    * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.

Submission attempts (in order):
# D
import math
Q = int(input())
A_list = []
B_list = []
for _ in range(Q):
    A, B = map(int, input().split())
    A_list.append(min(A, B))
    B_list.append(max(A, B))
    
for i in range(Q):
    A = A_list[i]
    B = B_list[i]
        
    if A == B:
        print(A+B-2)
        continue
        
    R = int(math.sqrt(A*B-1))
    Q = (A*B-1) // R
    
    if Q <= R+1:
        add = min(Q - A - 1, B - R - 1)  
    elif Q == R+2 and (R+1)**2 == A*B:
        add = 1
    elif (Q - R)**2 - 4*(A*B-Q*R) >= 0:
        add = int(((Q - R) - math.sqrt((Q - R)**2 - 4*(A*B-Q*R))) / 2)
        if (R + add)*(Q-add) == A*B:
            add -= 1
    else:
        print(xxxx)
    print((A-1) + R + add)
    

# D
import math
Q = int(input())
A_list = []
B_list = []
for _ in range(Q):
    A, B = map(int, input().split())
    A_list.append(min(A, B))
    B_list.append(max(A, B))
    
for i in range(Q):
    A = A_list[i]
    B = B_list[i]
    R = int(math.sqrt(A*B))
    
    
    if A >= B - 1:
        print(2*A-2)
    elif R*R == A*B:
        print(2*R-3)
    elif R*(R+1) >= A*B:
        print(2*R-2)
    else:
        print(2*R-1)
    

Verdicts: Wrong Answer

Accepted
Problem: 10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.  The _score_ of a participant is the product of his/her ranks in the two contests.  Process the following Q queries:    * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.

Submission attempts (in order):
from math import sqrt

def func(a, b):
	if a == b:
		return (a - 1) * 2
	else:
		sq = int(sqrt(a * b))
		if a * b == sq ** 2:
			return (sq - 1) * 2 - 1
		elif sq * (sq + 1) >= a * b:
            return (sq - 1) * 2
		else:
			return sq * 2 - 1

q = int(input())
for _ in range(q):
	a, b = map(int, input().split())
	print(func(a, b))

from math import sqrt

def func(a, b):
	if a == b:
		return (a - 1) * 2
	else:
		sq = int(sqrt(a * b))
		if a * b == sq ** 2:
			return (sq - 1) * 2 - 1
		elif sq * (sq + 1) >= a * b:
			return (sq - 1) * 2
		else:
			return sq * 2 - 1

q = int(input())
for _ in range(q):
	a, b = map(int, input().split())
	print(func(a, b))

Verdicts: Runtime Error

Accepted
Problem: 10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.  The _score_ of a participant is the product of his/her ranks in the two contests.  Process the following Q queries:    * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.

Submission attempts (in order):
from math import sqrt

q = int(input())
for _ in range(q):
    a, b = map(int, input().split())
    m = a * b
    s = int(sqrt(m - 1))
    ans = 2 * s
    if s * (s + 1) > m:
        ans -= 1
    if a != b:
        ans -= 1
    print(ans)


from math import sqrt

q = int(input())
for _ in range(q):
    a, b = map(int, input().split())
    m = a * b
    s = int(sqrt(m))
    ans = 2 * s - 1
    if s * (s + 1) >= m:
        ans -= 1
    if s * s == m and a != b:
        ans -= 1
    print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.  The _score_ of a participant is the product of his/her ranks in the two contests.  Process the following Q queries:    * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.

Submission attempts (in order):
# import sys
# argv = sys.argv
# with open(argv[1], 'r') as f:


Q = int(input().strip('\n'))
A = list()
B = list()
for i in range(Q):
    inDatas = input().strip('\n').split(' ')
    a, b = list(map(int, inDatas))
    score = a*b
    pa = 1
    pb = score
    count = 0
    while pb >= 1:
        if pa == a: pa += 1
        else:
            while pa*pb >= score or pb == b:
                pb -= 1
            count += 1
            pa += 1
            pb -= 1
    print(count)



Q = int(input().strip('\n'))
for i in range(Q):
    inDatas = input().strip('\n').split(' ')
    a, b = list(map(int, inDatas))
    score = a*b
    if a < b:
        tmp = a
        a = b
        b = tmp
    pa = b
    pb = a - 1
    count = b - 1 + b - 1
    while pb >= b+1:
        if pa == a: pa += 1
        elif pb == b: pb -= 1
        else:
            while pa*pb >= score or pb == b:
                pb -= 1
            if pb >= 1:
                count += 1
                pa += 1
                pb -= 1
    print(count)

import math

if __name__ == '__main__':
    q = int(input())
    for i in range(q):
        a, b = list(map(int, input().split()))
        prod = a*b
        rootInt = int(math.sqrt(prod))
        if a == b: print((a-1)*2)
        elif math.sqrt(prod) == rootInt:
            print((rootInt-2)*2+1)
        else:
            if rootInt*(rootInt+1) < prod:
                print((rootInt-1)*2+1)
            else:
                print((rootInt-1)*2)

Verdicts: Wrong Answer

Time Limit Exceeded

Accepted
Problem: 10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th.  The _score_ of a participant is the product of his/her ranks in the two contests.  Process the following Q queries:    * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.

Submission attempts (in order):
def inpl(): return [int(i) for i in input().split()]
Q = int(input())
for _ in range(Q):
    A, B = sorted(inpl())
    c = int((A*B-1)**0.5//1)
    ans = c-1+(A*B-1)//(c+1)
    print(ans + ((A*B)//1 == -((-A*B)//1)))

def inpl(): return [int(i) for i in input().split()]
Q = int(input())
for _ in range(Q):
    A, B = sorted(inpl())
    c = int(-(-(A*B)**0.5//1)-1)
    ans = A-1 + max(0, c-A) + (-(-A*B)//(c+1)-1)
    print(ans)

def inpl(): return [int(i) for i in input().split()]
Q = int(input())
for _ in range(Q):
    A, B = sorted(inpl())
    c = int(-(-(A*B)**0.5//1)-1)
    ans = A-1 + max(0, c-A) + (-((-A*B)//(c+1))-1)
    print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted