ZhenlongDai/ACPR huggingface dataset:
Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
print(n*(n-1)/2)

Failing test case input:
-121

Expected output:
7381


Actual output:
7381.0


Fixed submission (verdict: Accepted):
n=int(input())
print(n*(n-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

print((n*(n-1)/2))

Failing test case input:
-118

Expected output:
7021


Actual output:
7021.0


Fixed submission (verdict: Accepted):
n = int(input())

print((n*(n-1)

Problem: p02924
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
print(n*(n-1)/2)

Failing test case input:
-174

Expected output:
15225


Actual output:
15225.0


Fixed submission (verdict: Accepted):
n = int(input())
print(n*(n-1)

Problem: p02924
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
print(n*(n-1)/2)

Failing test case input:
-121

Expected output:
7381


Actual output:
7381.0


Fixed submission (verdict: Accepted):
n = int(input())
print(n*(n-1)

Problem: p02924
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
print(N*(N-1)/2)

Failing test case input:
-174

Expected output:
15225


Actual output:
15225.0


Fixed submission (verdict: Accepted):
N = int(input())
print(N*(N-1)

Problem: p02924
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
print(N * (N - 1))

Failing test case input:
-174

Expected output:
15225


Actual output:
30450


Fixed submission (verdict: Accepted):
N = int(input())
print(N * (N - 1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
print(N*(N-1)/2)

Failing test case input:
-174

Expected output:
15225


Actual output:
15225.0


Fixed submission (verdict: Accepted):
N =int(input())
print(int(N*(N-1)

Problem: p02924
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
print(N * (N - 1) / 2)

Failing test case input:
-121

Expected output:
7381


Actual output:
7381.0


Fixed submission (verdict: Accepted):
N = int(input())
print(N * (N - 1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = (n-1)/2
print(n*a)

Failing test case input:
-121

Expected output:
7381


Actual output:
7381.0


Fixed submission (verdict: Accepted):
n = int(input())
print(n*(n-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
print((n-1)*n/2)

Failing test case input:
-158

Expected output:
12561


Actual output:
12561.0


Fixed submission (verdict: Accepted):
n = int(input())
print((n-1)*n

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())

print((n - 1 + 1) * (n - 1) / 2)


Failing test case input:
-174

Expected output:
15225


Actual output:
15225.0


Fixed submission (verdict: Accepted):
n = int(input())

print(n * (n - 1)

Problem: p02924
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
print( (n*(n-1)) / 2 )

Failing test case input:
-128

Expected output:
8256


Actual output:
8256.0


Fixed submission (verdict: Accepted):
n = int(input())
print( int((n*(n-1))
Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
if n % 2 == 0:
    sum = n/2
    sum = sum *(n-1)

else:
    sum = (n-1)/2
    sum = sum * n

print(sum)


Failing test case input:
-158

Expected output:
12561


Actual output:
12561.0


Fixed submission (verdict: Accepted):
n = int(input())
if n % 2 == 0:
    sum = int(n/2)
    sum = sum *(n-1)

else:
    sum = int((n-1)/2)
    sum = sum * n

print(int(sum))

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
print(N*(N-1)/2)

Failing test case input:
-128

Expected output:
8256


Actual output:
8256.0


Fixed submission (verdict: Accepted):
N=int(input())
print(N*(N-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
print(n*(n-1)/2)

Failing test case input:
-128

Expected output:
8256


Actual output:
8256.0


Fixed submission (verdict: Accepted):
n = int(input())-1
print(n*(n+1)

Problem: p02924
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
print(N * (N-1) / 2)


Failing test case input:
-158

Expected output:
12561


Actual output:
12561.0


Fixed submission (verdict: Accepted):
N = int(input())
print(N * (N-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


N=int(input())
    
print(N*(N-1)/2)


Failing test case input:
-202

Expected output:
20503


Actual output:
20503.0


Fixed submission (verdict: Accepted):


N=int(input())
 
print(int(N*(N-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())

s=n*(n-1)/2
    
print(s)

Failing test case input:
-128

Expected output:
8256


Actual output:
8256.0


Fixed submission (verdict: Accepted):
n=int(input())

s=int(n*(n-1)
    
print(s)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
 
print(int(n * (n -1)) / 2)

Failing test case input:
-202

Expected output:
20503


Actual output:
20503.0


Fixed submission (verdict: Accepted):
n = int(input())
 
print(n * (n-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
print( int((N+1)*N/2) )

Failing test case input:
-174

Expected output:
15225


Actual output:
15051


Fixed submission (verdict: Accepted):
N = int(input())
print((N-1)*N

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
print((n*(n-1))/2)

Failing test case input:
-110

Expected output:
6105


Actual output:
6105.0


Fixed submission (verdict: Accepted):
n = int(input())
print((n*(n-1))

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
print((n-1)*n/2)


Failing test case input:
-158

Expected output:
12561


Actual output:
12561.0


Fixed submission (verdict: Accepted):
n = int(input().strip())
print(((n-1)*n)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
print(N*(N-1)/2)

Failing test case input:
-202

Expected output:
20503


Actual output:
20503.0


Fixed submission (verdict: Accepted):
N = int(input())
print(int(N*(N-1)
Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
print(N*(N-1)/2)

Failing test case input:
-110

Expected output:
6105


Actual output:
6105.0


Fixed submission (verdict: Accepted):
N = int(input())
print(N*(N-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())

print(1/2 * N * (N+1))

Failing test case input:
-174

Expected output:
15225


Actual output:
15051.0


Fixed submission (verdict: Accepted):
N = int(input())

print(((N-1) * N)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

print(int(N*(N+1)/2)-1)

Failing test case input:
-174

Expected output:
15225


Actual output:
15050


Fixed submission (verdict: Accepted):
N=int(input())

print(int(N*(N-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


n=int(input())

if n%2==0:
    a=int(n/2)
    print(a)
    print(a*(n-1))
else:
    a=int((n-1)/2)
    print(a)
    print(a*n)



Failing test case input:
-121

Expected output:
7381


Actual output:
-61
7381


Fixed submission (verdict: Accepted):


n=int(input())

if n%2==0:
    a=int(n/2)
    print(a*(n-1))
else:
    a=int((n-1)/2)
    print(a*n)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

n = int(stdin.readline().rstrip())
if n > 0: print(int(((n-1)*n)/2))
else: print(0)

Failing test case input:
-128

Expected output:
8256


Actual output:
0


Fixed submission (verdict: Accepted):
from sys import stdin

n = int(stdin.readline().rstrip())
print(((n-1)*n)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

print(N*(N-1)/2)

Failing test case input:
-202

Expected output:
20503


Actual output:
20503.0


Fixed submission (verdict: Accepted):
N=int(input())

print(  N*( N-1 )

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
print((N - 1) * N / 2)


Failing test case input:
-128

Expected output:
8256


Actual output:
8256.0


Fixed submission (verdict: Accepted):
N = int(input())
print(((N - 1) * N

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
print(N*(N-1)/2)

Failing test case input:
-202

Expected output:
20503


Actual output:
20503.0


Fixed submission (verdict: Accepted):

N=int(input())
print(N*(N-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
 
print(n*(n-1)/2)

Failing test case input:
-158

Expected output:
12561


Actual output:
12561.0


Fixed submission (verdict: Accepted):
n = int(input())
 
print(int(n*(n-1)

Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n = int(input())
    print(n * (n - 1) / 2)


main()


Failing test case input:
-118

Expected output:
7021


Actual output:
7021.0


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    print((n - 1) * n 


main()
Problem: p02924
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
N = int(input())

N -= 1
if N == 1:
    print(1)
    sys.exit()

if N % 2 == 0:
    ans = (N + 1) * N / 2
else:
    ans = (N + 1) * (N-1) / 2 + (N-1)
print(int(ans))


Failing test case input:
-110

Expected output:
6105


Actual output:
6048


Fixed submission (verdict: Accepted):
N = int(input())
N -= 1

ans = 0

if N % 2 == 0:
    ans = int(N + 1) * int(N / 2)
else:
    ans = int(N + 1) * int((N-1) / 2) + int((N+1)/2)
print(ans)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))[::-1]
flag=1
count=0
while flag:
    flag=0
    for i in range(N-1):
        if A[i]<A[i+1]:
            A[i],A[i+1]=A[i+1],A[i]
            flag=1
            count+=1

print(A[::-1],count,sep='\n')


Failing test case input:
6
0 1 5 6 3 5

Expected output:
0 1 3 5 5 6
3


Actual output:
[0, 1, 3, 5, 5, 6]
3


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))[::-1]
flag=1
count=0
while flag:
    flag=0
    for i in range(N-1):
        if A[i]<A[i+1]:
            A[i],A[i+1]=A[i+1],A[i]
            flag=1
            count+=1

print(*A[::-1])
print(count)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def insertionSort(A,input_num):
    for i in range(input_num):
        v = A[i]
        j = i - 1
        while(j >= 0 and A[j] > v):
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(*A)
        print(i)
        
input_num = int(input())
A = list(map(int, input().split()))

insertionSort(A,input_num)


Failing test case input:
5
4 23 -3 2 -1

Expected output:
-3 -1 2 4 23
7


Actual output:
4 23 -3 2 -1
0
4 23 -3 2 -1
1
-3 4 23 2 -1
2
-3 2 4 23 -1
3
-3 -1 2 4 23
4


Fixed submission (verdict: Accepted):
def bubbleSort(A,N):  
    flag = 1
    i = 0  
    while flag == 1:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                flag = 1
                i += 1
    print(*A)
    print(i)

N = int(input())
A = list(map(int,input().split()))

bubbleSort(A,N)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubbleSort(A, N): 
    print(A)
    A = list(map(int, A.split()))
    flag = 1 
    count = 0  
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
            count += 1
    print(count)

N = int(input())
A = input()
bubbleSort(A, N)


Failing test case input:
6
-1 1 5 6 3 2

Expected output:
-1 1 2 3 5 6
5


Actual output:
-1 1 5 6 3 2
15


Fixed submission (verdict: Accepted):
def bubbleSort(A, N): 
    A = list(map(int, A.split()))
    flag = 1 
    count = 0  
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
    print(" ".join(map(str,A)))
    print(count)

N = int(input())
A = input()
bubbleSort(A, N)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):


x = int(input())
y = list(map(int,input().split()))
z = 0

flag = 1
while flag:
	flag = 0
	i = x - 1
	while i > 0:
		if y[i] < y[i - 1]:
			y[i], y[i - 1] = y[i - 1], y[i]
			flag = 1
			z += 1
		i -= 1

print(z)
print(" ".join(list(map(str,y))))

Failing test case input:
5
7 3 4 3 0

Expected output:
0 3 3 4 7
8


Actual output:
8
0 3 3 4 7


Fixed submission (verdict: Accepted):


x = int(input())
y = list(map(int,input().split()))
z = 0

flag = 1
while flag:
	flag = 0
	i = x - 1
	while i > 0:
		if y[i] < y[i - 1]:
			y[i], y[i - 1] = y[i - 1], y[i]
			flag = 1
			z += 1
		i -= 1

print(" ".join(list(map(str,y))))
print(z)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
k = [int(i) for i in input().split()]

for i in range(n-1):
    for l in range(n-i-1):

        if k[n-2-l] > k[n-1-l]:
            v = k[n-1-l]
            k[n - 1 - l]=k[n-2-l]
            k[n - 2 - l]=v

        else:
            pass


print(k)

Failing test case input:
6
2 1 -1 9 1 0

Expected output:
-1 0 1 1 2 9
9


Actual output:
[-1, 0, 1, 1, 2, 9]


Fixed submission (verdict: Accepted):
n = int(input())
k = [int(i) for i in input().split()]
M = 0
for i in range(n-1):
    for l in range(n-i-1):

        if k[n-2-l] > k[n-1-l]:
            v = k[n-1-l]
            k[n - 1 - l]=k[n-2-l]
            k[n - 2 - l]=v
            M+=1
        else:
            pass

print(' '.join(map(str, k)))
print(M)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):

def bubbleSort(A,N):
    flag=1
    while flag:
        flag=0
        j=N-1
        while j>0:
            if(int(A[j])<int(A[j-1])):
                A[j],A[j-1]=A[j-1],A[j]
                flag=1
            j-=1

N=int(input())
A=input().split()
bubbleSort(A,N)
S=""
for i in range(N-1):
    S+=A[i]+" "
S+=str(A[-1])
print(S)

Failing test case input:
6
1 1 -1 9 1 0

Expected output:
-1 0 1 1 1 9
7


Actual output:
-1 0 1 1 1 9


Fixed submission (verdict: Accepted):

def bubbleSort(A,N):
    c=0
    flag=1
    while flag:
        flag=0
        j=N-1
        while j>0:
            if(int(A[j])<int(A[j-1])):
                c+=1
                A[j],A[j-1]=A[j-1],A[j]
                flag=1
            j-=1
    return c

N=int(input())
A=input().split()
c=bubbleSort(A,N)
S=""
for i in range(N-1):
    S+=A[i]+" "
S+=str(A[-1])
print(S)
print(c)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
s = input()
A = list(map(int,s.split()))
flag = 1

while(flag == 1):
    for k in range(0,len(A)-1):
        print(A[k],end=" ")
    print(A[len(A)-1])
    flag = 0
    for j in range(n-1,0,-1):
        if A[j] < A[j-1]:
            tmp = A[j]
            A[j] = A[j-1]
            A[j-1] = tmp
            flag = 1

for k in range(0,len(A)-1):
    print(A[k],end=" ")
print(A[len(A)-1])

Failing test case input:
6
1 1 5 6 3 5

Expected output:
1 1 3 5 5 6
3


Actual output:
1 1 5 6 3 5
1 1 3 5 6 5
1 1 3 5 5 6
1 1 3 5 5 6


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
A = list(map(int,s.split()))
flag = 1
cnt = 0

while(flag == 1):
    flag = 0
    for j in range(n-1,0,-1):
        if A[j] < A[j-1]:
            tmp = A[j]
            A[j] = A[j-1]
            A[j-1] = tmp
            flag = 1
            cnt += 1

for k in range(0,len(A)-1):
    print(A[k],end=" ")
print(A[len(A)-1])
print (cnt)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubble_sort(ls):
    flag=True
    i=0
    ch=0
    while flag:
        flag = False
        for j in reversed(range(i+1,len(ls))):
            if ls[j] < ls[j-1]:
                ls[j],ls[j-1] = ls[j-1],ls[j]
                flag = True
                ch += 1
        i += 1
    return ch

if __name__ == "__main__":
    ls=[]
    n=int(input())
    ls = list(map(int,input().split()))
    ch=bubble_sort(ls)
    for i in ls:
        if i == ls[-1]:
            print(i)
        else:
            print(i,end=" ")
    print(ch)



Failing test case input:
6
6 1 3 6 1 3

Expected output:
1 1 3 3 6 6
7


Actual output:
1 1 3 3 6
6
7


Fixed submission (verdict: Accepted):
def bubble_sort(ls):
    flag=True
    i=0
    ch=0
    while flag:
        flag = False
        for j in reversed(range(i+1,len(ls))):
            if ls[j] < ls[j-1]:
                ls[j],ls[j-1] = ls[j-1],ls[j]
                flag = True
                ch += 1
        i += 1
    return ch

if __name__ == "__main__":
    ls=[]
    n=int(input())
    ls = list(map(int,input().split()))
    ch=bubble_sort(ls)
    for i in range(len(ls)):
        if i == len(ls)-1:
            print(ls[i])
        else:
            print(ls[i],end=" ")
    print(ch)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubble_sort(target):
    flag = True
    while flag:
        flag = False
        for i in range(len(target)-1, 0, -1):
            if target[i] < target[i-1]:
                target[i-1], target[i] = target[i], target[i-1]
                flag = True
    return target

N = int(input())
A = [int(s) for s in input().split()]
print(' '.join(str(s) for s in bubble_sort(A)))

Failing test case input:
5
4 10 5 3 0

Expected output:
0 3 4 5 10
8


Actual output:
0 3 4 5 10


Fixed submission (verdict: Accepted):
def bubble_sort(target):
    global cnt
    flag = True
    while flag:
        flag = False
        for i in range(len(target)-1, 0, -1):
            if target[i] < target[i-1]:
                target[i-1], target[i] = target[i], target[i-1]
                flag = True
                cnt += 1
    return target

N = int(input())
A = [int(s) for s in input().split()]
cnt = 0
print(' '.join(str(s) for s in bubble_sort(A)))
print(cnt)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):




N = int(input()) 
A = list(map(int,input().split())) 





flag = 1
i = 0
cnt = 0


while flag:
    flag = 0
    for j in reversed(range(i+1,N)):
        if A[j] < A[j-1]:
            tmp = A[j-1]
            A[j-1] = A[j]
            A[j] = tmp
            flag = 1
            cnt += 1
    i += 1


print(A)
print(cnt)



Failing test case input:
6
1 1 0 2 0 0

Expected output:
0 0 0 1 1 2
8


Actual output:
[0, 0, 0, 1, 1, 2]
8


Fixed submission (verdict: Accepted):




N = int(input()) 
A = list(map(int,input().split())) 





flag = 1
i = 0
cnt = 0


while flag:
    flag = 0
    for j in reversed(range(i+1,N)):
        if A[j] < A[j-1]:
            tmp = A[j-1]
            A[j-1] = A[j]
            A[j] = tmp
            flag = 1
            cnt += 1
    i += 1



print(' '.join(map(str,A)))
print(cnt)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubbleSort(A, N): 
    A = list(map(int, A.split()))
    flag = 1 
    count = 0  
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
    print(A)
    print(count)

N = int(input())
A = input()
bubbleSort(A, N)


Failing test case input:
5
1 83 -3 1 1

Expected output:
-3 1 1 1 83
4


Actual output:
[-3, 1, 1, 1, 83]
4


Fixed submission (verdict: Accepted):
def bubbleSort(A, N): 
    A = list(map(int, A.split()))
    flag = 1 
    count = 0  
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
    print(" ".join(map(str,A)))
    print(count)

N = int(input())
A = input()
bubbleSort(A, N)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def main():
  element_num = int(input())
  elements = [int(s) for s in input().split()]
  swap_count = 0

  for i in range(1, element_num):
    for j in reversed(range(i, element_num)):
      if elements[j-1] > elements[j]:
        elements[j-1], elements[j] = elements[j], elements[j-1]
        swap_count += 1

  print(elements)
  print(swap_count)
  return 0

Failing test case input:
5
4 6 5 3 0

Expected output:
0 3 4 5 6
8


Actual output:

Fixed submission (verdict: Accepted):
def main():
  element_num = int(input())
  elements = [int(s) for s in input().split()]
  swap_count = 0

  for i in range(1, element_num):
    for j in reversed(range(i, element_num)):
      if elements[j-1] > elements[j]:
        elements[j-1], elements[j] = elements[j], elements[j-1]
        swap_count += 1

  print(' '.join(list(map(str, elements))))
  print(swap_count)
  return 0

if __name__ == '__main__':
  main()

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubbleSort(A, N):
    flag = True
    count = 0
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
    print(A)
    print(count)


arr_length = int(input())
arr_num = [int(i) for i in input().split(" ")]

bubbleSort(arr_num, arr_length)

Failing test case input:
6
4 1 -1 3 0 0

Expected output:
-1 0 0 1 3 4
10


Actual output:
[-1, 0, 0, 1, 3, 4]
10


Fixed submission (verdict: Accepted):
def bubbleSort(A, N):
    flag = True
    count = 0
    while flag:
        flag = 0
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                tmp = A[j]
                A[j] = A[j-1]
                A[j-1] = tmp
                flag = 1
                count += 1
    print(*A)
    print(count)


arr_length = int(input())
arr_num = [int(i) for i in input().split(" ")]

bubbleSort(arr_num, arr_length)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):

A = []



LENGTH =int(input())
A = input().split()


N = 0
M = LENGTH - 1
CHANGE = 0



while N <= LENGTH -1 :
    M = LENGTH - 1


    while M >= N + 1:


        if A[M] < A[M-1] :
            tmp = A[M-1]
            A[M-1] = A[M]
            A[M] = tmp
            CHANGE += 1
        M -= 1
    N += 1

print(" ".join(map(str,A)))
print (CHANGE)




Failing test case input:
5
4 23 -3 2 -1

Expected output:
-3 -1 2 4 23
7


Actual output:
-1 -3 2 23 4
9


Fixed submission (verdict: Accepted):

A = []



LENGTH =int(input())
A = input().split()


N = 0
M = LENGTH - 1
CHANGE = 0



while N <= LENGTH -1 :
    M = LENGTH - 1


    while M >= N + 1:


        if int(A[M]) < int(A[M-1]) :
            tmp = A[M-1]
            A[M-1] = A[M]
            A[M] = tmp
            CHANGE += 1
        M -= 1
    N += 1

print(" ".join(map(str,A)))
print (CHANGE)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):


import sys
import math

class Algo:
  @staticmethod
  def bubbleSort(r, n):
    flag = 1
    count = 0
    while flag:
      flag = 0
      for j in range(n-1, 0, -1):
        if r[j] < r[j-1]:
          r[j], r[j-1] = r[j-1], r[j]
          count += 1
          flag = 1

    for v in r:
      if v==r[len(r)-1]:
        print(v)
      else:
        print(v, " ", sep="", end="")
    print(count)

N = int(input())
R= list(map(int, input().split()))
Algo.bubbleSort(R, N)

Failing test case input:
6
0 1 5 5 3 2

Expected output:
0 1 2 3 5 5
5


Actual output:
0 1 2 3 5
5
5


Fixed submission (verdict: Accepted):


import sys
import math

class Algo:
  @staticmethod
  def bubbleSort(r, n):
    flag = 1
    count = 0
    while flag:
      flag = 0
      for j in range(n-1, 0, -1):
        if r[j] < r[j-1]:
          r[j], r[j-1] = r[j-1], r[j]
          count += 1
          flag = 1

    for i in range(0, n):
      if i == n-1:
        print(r[i])
      else:
        print(r[i], " ", sep="", end="")
    print(count)

N = int(input())
R= list(map(int, input().split()))
Algo.bubbleSort(R, N)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
nums = list(map(int, input().split()))
count = 0

for i in range(n):
    for j in range(i + 1, n - i):
        if (nums[j] < nums[i]):
            temp = nums[j]
            nums[j] = nums[i]
            nums[i] = temp
            count += 1

print(' '.join([str(i) for i in nums]))
print(count)



Failing test case input:
5
1 10 1 4 0

Expected output:
0 1 1 4 10
6


Actual output:
0 1 10 4 1
2


Fixed submission (verdict: Accepted):
n = int(input())
nums = list(map(int, input().split()))
count = 0


while True:
    flag = 0

    for j in range(n - 1):
        if (nums[j + 1] < nums[j]):
            temp = nums[j]
            nums[j] = nums[j + 1]
            nums[j + 1] = temp
            count += 1
            flag = 1

    if flag != 1:
        break

print(' '.join([str(i) for i in nums]))
print(count)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubbleSort(A, N):
    t = 0
    flag = 0
    while flag == 0:
        flag = 1
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 0
                t += 1
    print(A)
    print(t)

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

bubbleSort(a, n)

Failing test case input:
6
3 1 -1 4 -1 -1

Expected output:
-1 -1 -1 1 3 4
9


Actual output:
[-1, -1, -1, 1, 3, 4]
9


Fixed submission (verdict: Accepted):
def bubbleSort(A, N):
    s = 0
    flag = 0
    while flag == 0:
        flag = 1
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 0
                s += 1
    t = str(A[0])
    for i in range(1,N):
        t = t + " " + str(A[i])
    print(t)
    print(s)

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

bubbleSort(a, n)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(N):
    for j in range(i, N):
        if(A[j] < A[j-1]):
            temp = A[j-1]
            A[j-1] = A[j]
            A[j] = temp
            count += 1
print(*A)
print(count)
            

Failing test case input:
6
2 1 -1 11 1 0

Expected output:
-1 0 1 1 2 11
9


Actual output:
-1 1 0 1 2 11
8


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = [int(i) for i in input().split()]
def bubblesort(list):
    flag = 1
    count = 0
    while flag:
        flag = 0
        for i in range(n-1,0,-1):
            if list[i]<list[i-1]:
                list[i],list[i-1] = list[i-1],list[i]
                flag = 1
                count+=1
    print(count)
bubblesort(a)




Failing test case input:
5
0 13 -3 3 1

Expected output:
-3 0 1 3 13
5


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
flag = 1
count = 0
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1] = a[i-1],a[i]
            flag = 1
            count+=1
print(*a)
print(count)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubbleSort(A, N):
      ctn = 0
      for i in range(0,N):
            for j in range(0,N-i-1):
                  if int(A[j]) > int(A[j+1]):
                        print(i)
                        print(A[j],A[j+1])
                        t = A[j]
                        A[j] = A[j+1]
                        A[j+1] = t
                        ctn = ctn + 1
      for i in range(0,N):
            if i < N-1:
                  print(A[i],end=' ')
            else:
                  print(A[i])
      print(ctn)

if __name__ == "__main__":
      N = int(input())
      A = input()
      A = A.split()
      bubbleSort(A, N)

Failing test case input:
6
0 1 5 3 3 2

Expected output:
0 1 2 3 3 5
5


Actual output:
0
5 3
0
5 3
0
5 2
1
3 2
2
3 2
0 1 2 3 3 5
5


Fixed submission (verdict: Accepted):
def bubbleSort(A, N):
      ctn = 0
      for i in range(0,N):
            for j in range(0,N-i-1):
                  if int(A[j]) > int(A[j+1]):
                        t = A[j]
                        A[j] = A[j+1]
                        A[j+1] = t
                        ctn = ctn + 1
      for i in range(0,N):
            if i < N-1:
                  print(A[i],end=' ')
            else:
                  print(A[i])
      print(ctn)

if __name__ == "__main__":
      N = int(input())
      A = input()
      A = A.split()
      bubbleSort(A, N)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
s=input().split(' ')

flag=1
m=0

while flag:
    flag=0
    for j in range(1,n):
        j=n-j
        if s[j]<s[j-1]:
            a=s[j]
            s[j]=s[j-1]
            s[j-1]=a
            m+=1
            flag=1

print(' '.join(s))
print(m)


Failing test case input:
5
4 39 -1 1 0

Expected output:
-1 0 1 4 39
7


Actual output:
-1 0 1 39 4
8


Fixed submission (verdict: Accepted):
n=int(input())
s=input().split(' ')

flag=1
m=0

while flag:
    flag=0
    for j in range(1,n):
        j=n-j
        if int(s[j])<int(s[j-1]):
            a=s[j]
            s[j]=s[j-1]
            s[j-1]=a
            m+=1
            flag=1

print(' '.join(s))
print(m)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):

A = []



LENGTH =int(input())
A = input().split()


N = 0
M = LENGTH - 1
CHANGE = 0



while N <= LENGTH -1 :
    M = LENGTH - 1


    while M >= N + 1:


        if A[M] < A[M-1] :
            tmp = A[M-1]
            A[M-1] = A[M]
            A[M] = tmp
            CHANGE += 1
        M -= 1
    N += 1

print(" ".join(map(str,A)))
print (CHANGE)



Failing test case input:
5
0 13 -3 3 1

Expected output:
-3 0 1 3 13
5


Actual output:
-3 0 1 13 3
4


Fixed submission (verdict: Accepted):

A = []



LENGTH =int(input())
A = input().split()


N = 0
M = LENGTH - 1
CHANGE = 0



while N <= LENGTH -1 :
    M = LENGTH - 1


    while M >= N + 1:


        if int(A[M]) < int(A[M-1]) :
            tmp = A[M-1]
            A[M-1] = A[M]
            A[M] = tmp
            CHANGE += 1
        M -= 1
    N += 1

print(" ".join(map(str,A)))
print (CHANGE)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 1, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)
            

Failing test case input:
6
0 1 0 2 -1 -1

Expected output:
-1 -1 0 0 1 2
9


Actual output:
0 -1 -1 0 1 2
7


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):



import math

def bSort(A, N):
    cnt = 0
    f = True
    s = N-1
    e = 0
    while f == True:

        for j in range(s, e, -1):
            f = False
            x = A[j]
            y = A[j-1]


            if x < y:

                A[j] = y
                A[j-1] = x
                f = True
                cnt += 1
        e += 1
        if e > s:
            break
    return cnt


N = int(input().strip())
A = list(map(int,input().strip().split()))
cnt = bSort(A,N)
print(" ".join(map(str,A)))
print(cnt)

Failing test case input:
6
0 1 3 5 3 2

Expected output:
0 1 2 3 3 5
4


Actual output:
0 1 2 3 5 3
3


Fixed submission (verdict: Accepted):



import math

def bSort(A, N):
    cnt = 0
    f = True
    s = N-1
    e = 0
    while f == True:
        f = False

        for j in range(s, e, -1):
            x = A[j]
            y = A[j-1]


            if x < y:

                A[j] = y
                A[j-1] = x
                f = True
                cnt += 1
        e += 1
        if e > s:
            break
    return cnt


N = int(input().strip())
A = list(map(int,input().strip().split()))
cnt = bSort(A,N)
print(" ".join(map(str,A)))
print(cnt)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
flag = True
c = 0
while flag:
    flag = False
    for j in range(n-1,1,-1):
        if(a[j] < a[j-1]):
            a[j],a[j-1] = a[j-1],a[j]
            flag = True
            c += 1
print(*a)
print(c)


Failing test case input:
6
0 1 0 2 -1 -1

Expected output:
-1 -1 0 0 1 2
9


Actual output:
0 -1 -1 0 1 2
7


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
flag = True
c = 0
while flag:
    flag = False
    for j in range(n-1,0,-1):
        if(a[j] < a[j-1]):
            a[j],a[j-1] = a[j-1],a[j]
            flag = True
            c += 1
print(*a)
print(c)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
flag = 1
count = 0
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1] = a[i-1],a[i]
            flag = 1
            count+=1
print(count)



Failing test case input:
6
0 1 5 6 3 5

Expected output:
0 1 3 5 5 6
3


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
flag = 1
count = 0
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if a[i]<a[i-1]:
            a[i],a[i-1] = a[i-1],a[i]
            flag = 1
            count+=1
print(*a)
print(count)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = map(int,input().split())
flag = False
while flag:
    for j in range(n-1,1,-1):
        if(a[j] < a[j-1]):
            a[j],a[j-1] = a[j-1],a[j]
            flag = 1


Failing test case input:
5
1 83 -3 1 1

Expected output:
-3 1 1 1 83
4


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
flag = True
c = 0
while flag:
    flag = False
    for j in range(n-1,0,-1):
        if(a[j] < a[j-1]):
            a[j],a[j-1] = a[j-1],a[j]
            flag = True
            c += 1
print(*a)
print(c)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(0, n):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            a[i], a[j] = a[j], a[i]
            count += 1

print(' '.join(list(map(str, a))))
print(count)

Failing test case input:
6
2 1 -1 2 -1 0

Expected output:
-1 -1 0 1 2 2
9


Actual output:
-1 -1 0 1 2 2
7


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

count = 0
flag = True
while flag:
    flag = False
    for j in range(n - 1, 0, -1):
        if a[j] < a[j - 1]:
            a[j], a[j - 1] = a[j - 1], a[j]
            count += 1
            flag = True

print(' '.join(list(map(str, a))))
print(count)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
z=list(map(int,input().split()))
flag=1
a=0
cnt=0
while flag:
    flag=0

    for i in reversed(range(a,n)):
        if i ==0:
            break
        if z[i]<z[i-1]:
            tmp=z[i]
            z[i]=z[i-1]
            z[i-1]=tmp
            flag=1
            cnt+=1
        print(z)
    a+=1
print(' '.join(list(map(str,z))))
print(cnt)

Failing test case input:
6
5 2 4 6 1 3

Expected output:
1 2 3 4 5 6
9

Actual output:
[5, 2, 4, 6, 1, 3]
[5, 2, 4, 1, 6, 3]
[5, 2, 1, 4, 6, 3]
[5, 1, 2, 4, 6, 3]
[1, 5, 2, 4, 6, 3]
[1, 5, 2, 4, 3, 6]
[1, 5, 2, 3, 4, 6]
[1, 5, 2, 3, 4, 6]
[1, 2, 5, 3, 4, 6]
[1, 2, 5, 3, 4, 6]
[1, 2, 5, 3, 4, 6]
[1, 2, 5, 3, 4, 6]
[1, 2, 3, 5, 4, 6]
[1, 2, 3, 5, 4, 6]
[1, 2, 3, 5, 4, 6]
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]
1 2 3 4 5 6
9


Fixed submission (verdict: Accepted):
n=int(input())
z=list(map(int,input().split()))
flag=1
a=0
cnt=0
while flag:
    flag=0

    for i in reversed(range(a,n)):
        if i ==0:
            break
        if z[i]<z[i-1]:
            tmp=z[i]
            z[i]=z[i-1]
            z[i-1]=tmp
            flag=1
            cnt+=1
        
    a+=1
print(' '.join(list(map(str,z))))
print(cnt)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=input().split()
flag=True;count=0
while flag:
    flag=False
    for i in range(1,n):
        if a[i]<a[i-1]:
            key=a[i]
            a[i]=a[i-1]
            a[i-1]=key
            count+=1
            flag=True
print(' '.join(a))
print(count)


Failing test case input:
5
1 19 -3 -1 2

Expected output:
-3 -1 1 2 19
5


Actual output:
-1 -3 1 19 2
5


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
flag=True
count=0
while flag:
    flag=False
    for i in range(1,n):
        if a[i]<a[i-1]:
            key=a[i]
            a[i]=a[i-1]
            a[i-1]=key
            count+=1
            flag=True
a=list(map(str,a))
print(' '.join(a))
print(count)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
input()
arr = list(map(int, input().split()))
flag = False
count = 0
while not flag:
    flag = True
    for i in range(len(arr)-1):
        if arr[i] > arr[i+1]:
            count + 1
            flag = False
            t = arr[i+1]
            arr[i+1] = arr[i]
            arr[i] = t  
print(" ".join(map(str, arr)))
print(count)


Failing test case input:
6
2 2 -1 4 -1 0

Expected output:
-1 -1 0 2 2 4
8


Actual output:
-1 -1 0 2 2 4
0


Fixed submission (verdict: Accepted):
input()
arr = list(map(int, input().split()))
flag = False
count = 0
while not flag:
    flag = True
    for i in range(len(arr)-1):
        if arr[i] > arr[i+1]:
            count += 1
            flag = False
            t = arr[i+1]
            arr[i+1] = arr[i]
            arr[i] = t  
print(" ".join(map(str, arr)))
print(count)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def main() :
    n = int(input())
    nums = [int(i) for i in input().split()]

    flag = True
    count = 0
    i = 0
    while flag :
        flag = False
        for i in reversed(range(i, n)) :
            if nums[i-1] > nums[i] :
                nums[i-1], nums[i] = nums[i], nums[i-1]
                count += 1
                flag = True
        i += 1

    nums_str = [str(i) for i in nums]
    print(" ".join(nums_str))
    print(count)

if __name__ == '__main__' :
    main()

Failing test case input:
5
4 6 5 3 0

Expected output:
0 3 4 5 6
8


Actual output:
0 3 4 5 6
10


Fixed submission (verdict: Accepted):
def main() :
    n = int(input())
    nums = [int(i) for i in input().split()]

    flag = True
    count = 0
    index = 0
    while flag :
        flag = False
        for i in reversed(range(index+1, n)) :
            if nums[i-1] > nums[i] :
                nums[i-1], nums[i] = nums[i], nums[i-1]
                count += 1
                flag = True
        index += 1

    nums_str = [str(i) for i in nums]
    print(" ".join(nums_str))
    print(count)

if __name__ == '__main__' :
    main()
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)
            

Failing test case input:
6
2 1 -1 2 -1 0

Expected output:
-1 -1 0 1 2 2
9


Actual output:
2 1 -1 2 -1 0
0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
count = 0
Flag = True
while Flag:
    Flag = False
    for i in range(N-1, 1):
        if(A[i] < A[i-1]):
            temp = A[i-1]
            A[i-1] = A[i]
            A[i] = temp
            Flag = True
            count += 1
print(*A)
print(count)
            

Failing test case input:
6
3 2 -1 4 0 0

Expected output:
-1 0 0 2 3 4
9


Actual output:
3 2 -1 4 0 0
0


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
flag = True
c = 0
while flag:
    flag = False
    for j in range(n-1,1,-1):
        if(a[j] < a[j-1]):
            a[j],a[j-1] = a[j-1],a[j]
            flag = 1
            c += 1
print(*a)
print(c)


Failing test case input:
6
8 1 3 6 1 3

Expected output:
1 1 3 3 6 8
8


Actual output:
8 1 1 3 3 6
3


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
flag = True
c = 0
while flag:
    flag = False
    for j in range(n-1,0,-1):
        if(a[j] < a[j-1]):
            a[j],a[j-1] = a[j-1],a[j]
            flag = True
            c += 1
print(*a)
print(c)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):


import sys
import math

class Algo:
  @staticmethod
  def bubble(r, n):
    flag = 1
    count = 0
    while flag:
      flag = 0
      for j in range(n-1, 0, -1):
        if r[j] < r[j-1]:
          r[j], r[j-1] = r[j-1], r[j]
          count += 1
          flag = 1

    for v in r:
      if v==r[len(r)-1]:
        print(v)
      else:
        print(v, " ", sep="", end="")
    print(count)

N = int(input())
R= list(map(int, input().split()))
Algo.bubble(R, N)

Failing test case input:
6
1 1 3 3 2 3

Expected output:
1 1 2 3 3 3
2


Actual output:
1 1 2 3
3
3
2


Fixed submission (verdict: Accepted):


import sys
import math

class Algo:
  @staticmethod
  def bubbleSort(r, n):
    flag = 1
    count = 0
    while flag:
      flag = 0
      for j in range(n-1, 0, -1):
        if r[j] < r[j-1]:
          r[j], r[j-1] = r[j-1], r[j]
          count += 1
          flag = 1

    for i in range(0, n):
      if i == n-1:
        print(r[i])
      else:
        print(r[i], " ", sep="", end="")
    print(count)

N = int(input())
R= list(map(int, input().split()))
Algo.bubbleSort(R, N)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
s = list(map(int, input().strip().split(' ')))
e = int()
e = 0
flag = True
while flag:
        flag = False
        for i in range(n - 1, 0, -1):
            if s[i] < s[i - 1]:
                s[i - 1], s[i] = s[i], s[i - 1]
                e = e + 1
                flag = True

for i in range(0 , len(s)):
    if i != 4:
        print(s[i], end=" ")
    else:
        print(s[i])

print(e)


Failing test case input:
6
2 1 -1 2 -1 0

Expected output:
-1 -1 0 1 2 2
9


Actual output:
-1 -1 0 1 2
2 9


Fixed submission (verdict: Accepted):
n = int(input())
s = list(map(int, input().strip().split(' ')))
e = int()
e = 0
flag = True
while flag:
        flag = False
        for i in range(n - 1, 0, -1):
            if s[i] < s[i - 1]:
                s[i - 1], s[i] = s[i], s[i - 1]
                e = e + 1
                flag = True

for i in range(0 , len(s)):
    if i != len(s) - 1:
        print(s[i], end=" ")
    else:
        print(s[i])

print(e)
Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):

def BS(N,A):
    count=0
    flag=True
    while flag==True:
        flag=False
        for i in range(1,N):
            if A[N-i]<A[N-i-1]:
                swap=A[N-i]
                A[N-i]=A[N-i-1]
                A[N-i-1]=swap
                flag=True
                count+=1
    print(" ".join(A))
    print(count)

if __name__=="__main__":
    N=int(input())
    a=input()
    A=a.split(" ")
    BS(N,A)

Failing test case input:
5
4 10 5 4 0

Expected output:
0 4 4 5 10
7


Actual output:
0 10 4 4 5
6


Fixed submission (verdict: Accepted):

def BS(N,A):
    count=0
    flag=True
    while flag==True:
        flag=False
        for i in range(1,N):
            if A[N-i]<A[N-i-1]:
                swap=A[N-i]
                A[N-i]=A[N-i-1]
                A[N-i-1]=swap
                flag=True
                count+=1
    for i in range(len(A)):
        A[i]=str(A[i])
    print(" ".join(A))
    print(count)

if __name__=="__main__":
    N=int(input())
    a=input()
    A=a.split(" ")
    for i in range(len(A)):
        A[i]=int(A[i])
    BS(N,A)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
nums=list(map(int,input().split()))

k=0
for i in range(len(nums)-1):
    for j in range(len(nums)-1,i,-1):
        print(i,j)
        if nums[j]<nums[j-1]:
            nums[j],nums[j-1]=nums[j-1],nums[j]
            k+=1

print(*nums)
print(k)

Failing test case input:
5
0 26 -3 3 1

Expected output:
-3 0 1 3 26
5


Actual output:
0 4
0 3
0 2
0 1
1 4
1 3
1 2
2 4
2 3
3 4
-3 0 1 3 26
5


Fixed submission (verdict: Accepted):
n=int(input())
nums=list(map(int,input().split()))

k=0
for i in range(len(nums)-1):
    for j in range(len(nums)-1,i,-1):
        if nums[j]<nums[j-1]:
            nums[j],nums[j-1]=nums[j-1],nums[j]
            k+=1

print(*nums)
print(k)

Problem: p02259
Buggy submission (Python3, verdict: Wrong Answer):
def bubble(A, N):
    count = 0
    flag = True
    while flag == True:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j - 1]:
                A[j -1],A[j] = A[j], A[j - 1]
                count += 1
                flag = True
        print(" ".join(map(str, A)))
        print(count)

if __name__ == "__main__":
    N = int(input())
    A = [int(i) for i in input().split(" ")]
    print(bubble(A, N))

Failing test case input:
6
0 1 3 5 3 2

Expected output:
0 1 2 3 3 5
4


Actual output:
0 1 2 3 5 3
3
0 1 2 3 3 5
4
0 1 2 3 3 5
4
None


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))


def bubble_sort(A, N):
    cnt = 0
    flag = True
    while(flag):
        flag = False
        for i in range(N-1, 0, -1):
            if(A[i-1] > A[i]):
                A[i-1], A[i] = A[i], A[i-1]
                cnt += 1
                flag = True

    print(" ".join(list(map(str, A))))
    print(cnt)

bubble_sort(A, N)