Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == "__main__":
    A, B, C = map(int, input().split())
    
    max_v = max(A, B, C)
    min_v = min(A, B, C)
    
    num_list = [A, B, C]
    num_list.remove(max_v)
    if len(num_list) == 2:
        num_list.remove(min_v)
        if len(num_list) == 1:
            mid_v = num_list[0]
        else:
            mid_v = min_v
    else:
        mid_v = max_v
    
    ans = 0
    while True:
        if mid_v < max_v:
            ans += max_v - mid_v
            min_v += max_v - mid_v
            mid_v = max_v
            #print("aaa", min_v, mid_v, max_v)
        else:#mid_v = max_v
            if min_v < max_v:
                if (max_v - min_v) % 2 == 0:
                    #min_v = max_v
                    ans += (max_v - min_v) / 2
                    #print("bbb", min_v, mid_v, max_v)
                    break
                else:
                    #min_v = max_v
                    #max_v += 1
                    #mid_v += 1
                    ans += (max_v + 1 - min_v) / 2
                    ans += 1
                    #print("ccc", min_v, mid_v, max_v)
                    break
    
    print(int(ans))

Fixed submission:
if __name__ == "__main__":
    A, B, C = map(int, input().split())
    
    max_v = max(A, B, C)
    min_v = min(A, B, C)
    
    num_list = [A, B, C]
    num_list.remove(max_v)
    if len(num_list) == 2:
        num_list.remove(min_v)
        if len(num_list) == 1:
            mid_v = num_list[0]
        else:
            mid_v = min_v
    else:
        mid_v = max_v
    
    ans = 0
    while True:
        if mid_v < max_v:
            ans += max_v - mid_v
            min_v += max_v - mid_v
            mid_v = max_v
            #print("aaa", min_v, mid_v, max_v)
        else:#mid_v = max_v
            if min_v < max_v:
                if (max_v - min_v) % 2 == 0:
                    #min_v = max_v
                    ans += (max_v - min_v) / 2
                    #print("bbb", min_v, mid_v, max_v)
                    break
                else:
                    #min_v = max_v
                    #max_v += 1
                    #mid_v += 1
                    ans += (max_v + 1 - min_v) / 2
                    ans += 1
                    #print("ccc", min_v, mid_v, max_v)
                    break
            else:
                break
    
    print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == "__main__":
    A, B, C = map(int, input().split())
    
    max_v = max(A, B, C)
    min_v = min(A, B, C)
    
    num_list = [A, B, C]
    num_list.remove(max_v)
    if len(num_list) == 2:
        num_list.remove(min_v)
        if len(num_list) == 1:
            mid_v = num_list[0]
        else:
            mid_v = min_v
    else:
        mid_v = max_v
    
    ans = 0
    while True:
        if mid_v < max_v:
            ans += max_v - mid_v
            min_v += max_v - mid_v
            mid_v = max_v
            #print("aaa", min_v, mid_v, max_v)
        else:#mid_v = max_v
            if min_v < max_v:
                if (max_v - min_v) % 2 == 0:
                    #min_v = max_v
                    ans += (max_v - min_v) / 2
                    #print("bbb", min_v, mid_v, max_v)
                    break
                else:
                    #min_v = max_v
                    #max_v += 1
                    #mid_v += 1
                    ans += (max_v + 1 - min_v) / 2
                    ans += 1
                    #print("ccc", min_v, mid_v, max_v)
                    break
    
    print(int(ans))

Fixed submission:
if __name__ == "__main__":
    A, B, C = map(int, input().split())
    
    max_v = max(A, B, C)
    min_v = min(A, B, C)
    
    num_list = [A, B, C]
    num_list.remove(max_v)
    if len(num_list) == 2:
        num_list.remove(min_v)
        if len(num_list) == 1:
            mid_v = num_list[0]
        else:
            mid_v = min_v
    else:
        mid_v = max_v
    
    ans = 0
    while True:
        if mid_v < max_v:
            ans += max_v - mid_v
            min_v += max_v - mid_v
            mid_v = max_v
            #print("aaa", min_v, mid_v, max_v)
        else:#mid_v = max_v
            if min_v < max_v:
                if (max_v - min_v) % 2 == 0:
                    #min_v = max_v
                    ans += (max_v - min_v) / 2
                    #print("bbb", min_v, mid_v, max_v)
                    break
                else:
                    #min_v = max_v
                    #max_v += 1
                    #mid_v += 1
                    ans += (max_v + 1 - min_v) / 2
                    ans += 1
                    #print("ccc", min_v, mid_v, max_v)
                    break
            else:
                break
    
    print(int(ans))