ZhenlongDai/ACPR huggingface dataset:
Problem: p02260
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(0, element_num - 1):
    max_val = elements[i + 1]
    max_index = i + 1
    for j in range(i + 1, element_num):
      if max_val < elements[j]:
        max_val = elements[j]
        max_index = j
    if elements[i] > elements[max_index]:
      elements[i], elements[max_index] = elements[max_index], elements[i]
      swap_count += 1

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

  return 0


if __name__ == '__main__':
  main()

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

Expected output:
-3 0 0 0 0 1
3


Actual output:
0 0 0 0 -3 1
1


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(0, element_num - 1):
    min_val = elements[i + 1]
    min_index = i + 1
    for j in range(i + 1, element_num):
      if elements[j] < min_val:
        min_val = elements[j]
        min_index = j
    if elements[i] > elements[min_index]:
      elements[i], elements[min_index] = elements[min_index], elements[i]
      swap_count += 1

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

  return 0


if __name__ == '__main__':
  main()

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

Failing test case input:
6
8 18 4 1 1 -1

Expected output:
-1 1 1 4 8 18
5


Actual output:
1 1 4 8 18 -1
5


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(N):
    m = i
    for j in range(i, N):
        if (A[j] < A[m]):
            m = j
    if (m != i):
        A[i], A[m] = A[m], A[i]
        count += 1
print(*A)
print(count)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n-1):
 for j in range(n-1,i,-1):
  if a[j-1]>a[j]:a[j-1],a[j]=a[j],a[j-1];c+=1
print(*a)
print(c)


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

Expected output:
0 2 3 3 5 6
4


Actual output:
0 2 3 3 5 6
10


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n-1):
 m=a.index(min(a[i:]),i)
 if a[i]>a[m]:
  a[i],a[m]=a[m],a[i];c+=1
print(*a)
print(c)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionSort(A, N):
    s = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        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()]

selectionSort(a, n)

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

Expected output:
-4 -1 -1 -1 0 1
4


Actual output:
-4 -1 -1 -1 0 1
6


Fixed submission (verdict: Accepted):
def selectionSort(A, N):
    s = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        if i != minj:
            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()]

selectionSort(a, n)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionsort(l,n):
    c=0
    for i in range(n):
        minj=i
        for j in range(i,n):
            if int(l[i])<int(l[minj]):
               minj=j
        l[i],l[minj]=l[minj],l[i]
        if i!=minj:
          c+=1
    print(" ".join(l))
    print(c)
n=int(input())
l=list(input().split())
selectionsort(l,n)


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

Expected output:
-1 1 1 4 6 9
5


Actual output:
6 9 4 1 1 -1
0


Fixed submission (verdict: Accepted):
def selectionsort(l,n):
    c=0
    for i in range(n):
        minj=i
        for j in range(i,n):
            if int(l[j])<int(l[minj]):
               minj=j
        l[i],l[minj]=l[minj],l[i]
        if i!=minj:
          c+=1
    print(" ".join(l))
    print(c)
n=int(input())
l=list(input().split())
selectionsort(l,n)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
data = [int(s) for s in input().split()]

change = 0
new = []
for idx in range(n):
	idx_min = data.index(min(data[idx:]))
	if idx_min > idx:
		data[idx],data[idx_min] = data[idx_min],data[idx]
		change += 1

print(' '.join([str(d) for d in data]))
print(change)

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

Expected output:
0 0 2 4 6 6
4


Actual output:
0 2 4 6 6 0
1


Fixed submission (verdict: Accepted):
n = int(input())
data = [int(s) for s in input().split()]

change = 0
new = []
for idx in range(n):
	idx_min = data[idx:].index(min(data[idx:])) + idx
	if idx_min > idx:
		data[idx],data[idx_min] = data[idx_min],data[idx]
		change += 1

print(' '.join([str(d) for d in data]))
print(change)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
s = input()
A = list(map(int,s.split()))
flag = 1
cnt = 0


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


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

Failing test case input:
6
38 44 0 -1 1 -4

Expected output:
-4 -1 0 1 38 44
4


Actual output:
-4 -1 0 1 38 44
6


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


for i in range(0,n):
    minj = i
    for j in range(i,n):
        if A[j] < A[minj]:
            minj = j
    if(A[i] != A[minj]):
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
        cnt += 1


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

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(0,n-1):
    for j in range(i+1,n-1):
        if a[i]>a[j]:
            a[i],a[j]=a[j],a[i]
            b+=1
print(*a)
print(b)


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

Expected output:
1 3 4 4 5 6
2


Actual output:
1 4 4 5 6 3
7


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[minj]>a[j]:
            minj=j
    if i!=minj:
        a[i],a[minj]=a[minj],a[i]
        b+=1
print(*a)
print(b)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionSort(A,N):
  
    count = 0
    for i in range(N):
        
        minj = i
        
        for j in range(i,N,1):
           
            if A[j] < A[minj]:
                minj = j
                
        
        if minj != i:
            count = count + 1
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
            print(' '.join(map(str,A)))
    print(count)
    
N = int(input())
A = input()
A = list(map(int,A.split()))   
selectionSort(A,N)


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

Expected output:
-3 -1 -1 0 0 1
4


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


Fixed submission (verdict: Accepted):
def selectionSort(A,N):
  
    count = 0
    for i in range(N):
        
        minj = i
        
        for j in range(i,N,1):
           
            if A[j] < A[minj]:
                minj = j
                
        
        if minj != i:
            count = count + 1
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
    print(' '.join(map(str,A)))
    print(count)
    
N = int(input())
A = input()
A = list(map(int,A.split()))   
selectionSort(A,N)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = [int(e) for e in input().split()]

def selection_sort(A, N):
    steps = 0
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[minj] > A[j]:
                minj = j
                steps += 1
        A[minj], A[i] = A[i], A[minj]

    print(A)
    print(steps)
    return A

selection_sort(A, N)


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

Expected output:
-1 -1 -1 -1 -1 1
2


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


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(e) for e in input().split()]

def selection_sort(A, N):
    steps = 0
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[minj] > A[j]:
                minj = j
        if i != minj:
            steps += 1
        A[minj], A[i] = A[i], A[minj]

    for e in A[:-1]:
        print(e, end=' ')
    print(A[-1])
    print(steps)
    return A

selection_sort(A, N)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
chge = 0
for i in range(N):
    mn = A[i]
    for j in range(i+1, N):
        print(mn, A[j])
        if mn > A[j]:
            mn = A[j]
            chge = 1
    if chge:
        idx = A.index(mn)
        A[idx] = A[i]
        A[i] = mn
        cnt += 1
        chge = 0

for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print(str(A[i]), end = " ")
print(cnt)

Failing test case input:
6
38 44 0 0 1 -4

Expected output:
-4 0 0 1 38 44
5


Actual output:
38 44
38 0
0 0
0 1
0 -4
44 0
0 0
0 1
0 38
44 0
0 1
0 38
0 1
0 38
1 38
-4 44 0 0 1 38
3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
chge = 0
for i in range(N):
    mn = A[i]
    for j in range(i+1, N):
        if mn > A[j]:
            mn = A[j]
            idx = j
            chge = 1
    if chge:
        A[idx] = A[i]
        A[i] = mn
        cnt += 1
        chge = 0

for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print(str(A[i]), end = " ")
print(cnt)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
cnt = 0
n = int(input())
lst = list(map(int, input().split()))
for i in range(n):
    m = i
    for j in range(i, n):
        if lst[j] < lst[m]:
            m = j
    lst[i], lst[m] = lst[j], lst[j-1]
    cnt += 1
print(*lst)
print(cnt)

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

Expected output:
-3 -1 -1 -1 0 1
3


Actual output:
-1 -1 -1 -1 -3 -3
6


Fixed submission (verdict: Accepted):
cnt = 0
n = int(input())
lst = list(map(int, input().split()))
for i in range(n):
    m = i
    for j in range(i, n):
        if lst[j] < lst[m]:
            m = j
    if m != i:
        lst[i], lst[m] = lst[m], lst[i]
        cnt += 1
print(*lst)
print(cnt)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selection_sort(A, N):
    sw = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
                sw += 1
        A[i], A[minj] = A[minj], A[i]
    return sw


def main():
    N = int(input().rstrip())
    A = list(map(int, input().rstrip().split()))
    
    sw = selection_sort(A, N)
    
    print(' '.join(map(str, A)))
    print(sw)
    
    
if __name__ == '__main__':
    main()

Failing test case input:
6
38 70 0 0 0 -2

Expected output:
-2 0 0 0 38 70
5


Actual output:
-2 0 0 0 38 70
6


Fixed submission (verdict: Accepted):
def selection_sort(A, N):
    sw = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            sw += 1
            A[i], A[minj] = A[minj], A[i]
    return sw


def main():
    N = int(input().rstrip())
    A = list(map(int, input().rstrip().split()))
    
    sw = selection_sort(A, N)
    
    print(' '.join(map(str, A)))
    print(sw)
    
    
if __name__ == '__main__':
    main()

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
cnt = 0

for i in range(N):
    
    minj = i
    for j in range(i, N):
        
        if A[j] < A[minj]:
            minj = j
    
    A[i], A[minj] = A[minj], A[i]
    cnt += 1

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

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

Expected output:
1 2 2 4 5 6
4


Actual output:
1 2 2 4 5 6
6


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

for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    if i is not minj:
        A[i], A[minj] = A[minj], A[i]
        cnt += 1

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

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

n = int(input())
a = list(map(int,input().split()))
count = 0

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


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




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

Expected output:
1 2 4 4 5 6
2


Actual output:
2 1 4 4 5 6
14


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

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

print(' '.join(map(str,a)))
print(count)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):




class Solution:
    @staticmethod
    def selection_sort():
        
        array_length = int(input())
        unsorted_array = [int(x) for x in input().split()]

        count = 0
        for i in range(array_length):
            min_j = i
            for j in range(i, array_length):
                if unsorted_array[j] < unsorted_array[min_j]:
                    min_j = j
            unsorted_array[i], unsorted_array[min_j] = unsorted_array[min_j], unsorted_array[i]
            count += 1

        print(" ".join(map(str, unsorted_array)))
        print(str(count))


if __name__ == '__main__':
    solution = Solution()
    solution.selection_sort()

Failing test case input:
6
14 70 0 0 0 -1

Expected output:
-1 0 0 0 14 70
5


Actual output:
-1 0 0 0 14 70
6


Fixed submission (verdict: Accepted):




class Solution:
    @staticmethod
    def selection_sort():
        
        array_length = int(input())
        unsorted_array = [int(x) for x in input().split()]

        count = 0
        for i in range(array_length):
            min_j = i
            for j in range(i, array_length):
                if unsorted_array[j] < unsorted_array[min_j]:
                    min_j = j
            unsorted_array[i], unsorted_array[min_j] = unsorted_array[min_j], unsorted_array[i]
            if i != min_j:
                count += 1

        print(" ".join(map(str, unsorted_array)))
        print(str(count))


if __name__ == '__main__':
    solution = Solution()
    solution.selection_sort()

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0

    for i in range(n):
        tmp = i
        for j in range(i, n):
            if a[j] < a[tmp]:
                tmp = j
        a[i], a[tmp] = a[tmp], a[i]
        ans += 1

    print(*a)
    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
6
74 44 0 0 1 -4

Expected output:
-4 0 0 1 44 74
4


Actual output:
-4 0 0 1 44 74
6


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

    for i in range(n):
        tmp = i
        for j in range(i, n):
            if a[j] < a[tmp]:
                tmp = j
        if i != tmp:
            a[i], a[tmp] = a[tmp], a[i]
            ans += 1

    print(*a)
    print(ans)


if __name__ == '__main__':
    main()
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
arr = [int(n) for n in input().split()]

swap_cnt = 0
for i in range(0, N):
    minj = i
    for j in range(i, N - 1):
        if arr[j] < arr[minj]:
            minj = j
        if (i != minj):
            arr[i], arr[minj] = arr[minj], arr[i]
            swap_cnt += 1

print(' '.join(map(str, arr)))
print(swap_cnt)



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

Expected output:
-1 0 0 2 2 3
4


Actual output:
-1 0 2 2 3 0
7


Fixed submission (verdict: Accepted):
N = int(input())
arr = [int(n) for n in input().split()]

swap_cnt = 0
for i in range(0, N):
    minj = i
    for j in range(i + 1, N):
        if arr[j] < arr[minj]:
            minj = j
    if (i != minj):
        arr[i], arr[minj] = arr[minj], arr[i]
        swap_cnt += 1

print(' '.join(map(str, arr)))
print(swap_cnt)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionSort(A,N):
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        A[i],A[minj] = A[minj],A[i]
        count += 1
    return (count)

if __name__ == '__main__':
    n = int(input())
    data = [int(i) for i in range(n)]
    result = selectionSort(data,n)
    print(" ".join(map(str,data)))
    print(result)

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

Expected output:
1 3 3 3 6 6
4


Actual output:
0 1 2 3 4 5
6


Fixed submission (verdict: Accepted):
def selection_Sort(A,N):
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i],A[minj] = A[minj],A[i]
            count += 1
    return (count)

if __name__ == '__main__':
    n = int(input())
    data = [int(i) for i in input().split()]
    result = selection_Sort(data,n)
    print(" ".join(map(str,data)))
    print(result)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
i=input
N=int(i())
A=list(map(int,i().split()))
r = range
c=0
for i in r(N):
    minj=i
    for j in r(i,N):
        if A[j] < A[minj]:
            minj = j
            c+=1
        A[i],A[minj] = A[minj],A[i]
print(*A)
print(c)

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

Expected output:
-1 0 0 4 6 8
4


Actual output:
-1 0 0 4 6 8
12


Fixed submission (verdict: Accepted):
i=input
N=int(i())
A=list(map(int,i().split()))
r = range
c=0
for i in r(N):
    minj=i
    for j in r(i,N):
        if A[j] < A[minj]:
            minj = j
    if i !=minj:
        c+=1
    A[i],A[minj] = A[minj],A[i]
print(*A)
print(c)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
length = int(input())
targ = [int(n) for n in input().split(' ')]
ans = 0
for l in range(length):
    value = l
    for init in range(l + 1,length):
        if targ[value] > targ[init]:
            value = init
    if value != l:
        disp = targ[l]
        targ[l] = targ[value]
        targ[value] = disp
        ans += 1
print(targ)
print(ans)

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

Expected output:
-3 -1 -1 -1 -1 1
3


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


Fixed submission (verdict: Accepted):
length = int(input())
targ = [int(n) for n in input().split(' ')]
ans = 0
for l in range(length):
    value = l
    for init in range(l + 1,length):
        if targ[value] > targ[init]:
            value = init
    if value != l:
        disp = targ[l]
        targ[l] = targ[value]
        targ[value] = disp
        ans += 1
print(' '.join([str(n) for n in targ]))
print(ans)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
chge = 0
for i in range(N):
    mn = A[i]
    for j in range(i+1, N):
        if mn > A[j]:
            mn = A[j]
            chge = 1
    if chge:
        idx = A.index(mn)
        A[idx] = A[i]
        A[i] = mn
        cnt += 1
        chge = 0

for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print(str(A[i]), end = " ")
print(cnt)

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

Expected output:
-1 -1 1 4 6 8
5


Actual output:
4 8 6 1 -1 -1
5


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
chge = 0
for i in range(N):
    mn = A[i]
    for j in range(i+1, N):
        if mn > A[j]:
            mn = A[j]
            idx = j
            chge = 1
    if chge:
        A[idx] = A[i]
        A[i] = mn
        cnt += 1
        chge = 0

for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print(str(A[i]), end = " ")
print(cnt)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
i=input
N=int(i())
A=list(map(int,i().split()))
r = range
c=0
for i in r(N):
    minj=i
    for j in r(i,N):
        if A[j] < A[minj]:
            minj = j
        A[i],A[minj] = A[minj],A[i]
        c+=1
print(*A)
print(c)

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

Expected output:
-3 -1 0 0 0 1
4


Actual output:
-1 0 0 0 -3 1
21


Fixed submission (verdict: Accepted):
i=input
N=int(i())
A=list(map(int,i().split()))
r = range
c=0
for i in r(N):
    minj=i
    for j in r(i,N):
        if A[j] < A[minj]:
            minj = j
    if i !=minj:
        c+=1
    A[i],A[minj] = A[minj],A[i]
print(*A)
print(c)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
A = input().split(' ')
count = 0

for i in range(0, n):
    minj = i

    for j in range(i, n):
        if int(A[j]) < int(A[minj]):
            minj = j

    (A[i], A[minj]) = (A[minj], A[i])
    count += 1

print(" ".join(A))
print(count)

Failing test case input:
6
8 35 0 0 0 -1

Expected output:
-1 0 0 0 8 35
5


Actual output:
-1 0 0 0 8 35
6


Fixed submission (verdict: Accepted):
n = int(input())
A = input().split(' ')
count = 0

for i in range(0, n):
    minj = i

    for j in range(i, n):
        if int(A[j]) < int(A[minj]):
            minj = j

    if i != minj:
        (A[i], A[minj]) = (A[minj], A[i])
        count += 1

print(" ".join(A))
print(count)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
chge = 0
for i in range(N):
    mn = A[i]
    for j in range(i+1, N):
        if mn >= A[j]:
            mn = A[j]
            chge = 1
    if chge:
        idx = A.index(mn)
        A[idx] = A[i]
        A[i] = mn
        cnt += 1
        chge = 0

for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print(str(A[i]), end = " ")
print(cnt)

Failing test case input:
6
8 27 4 1 1 -1

Expected output:
-1 1 1 4 8 27
5


Actual output:
-1 4 27 1 1 8
4


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
chge = 0
for i in range(N):
    mn = A[i]
    for j in range(i+1, N):
        if mn > A[j]:
            mn = A[j]
            idx = j
            chge = 1
    if chge:
        A[idx] = A[i]
        A[i] = mn
        cnt += 1
        chge = 0

for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print(str(A[i]), end = " ")
print(cnt)

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


for i in range(n):
    minj = k[i]

    for j in range(i,n):
        if minj > k[j]:
            minj = k[j]
            k[j]=k[i]

        t = k[i]
        k[i] = minj
    if t != minj:
        m += 1



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

Failing test case input:
6
23 60 0 0 0 -3

Expected output:
-3 0 0 0 23 60
5


Actual output:
-3 0 0 0 23 60
3


Fixed submission (verdict: Accepted):
n = int(input())
k = [int(i) for i in input().split()]
m = 0

for i in range(n):
    minj = i
    for j in range(i,n):
        if k[j] < k[minj]:
            minj = j
    x = k[i]
    k[i] = k[minj]
    k[minj]=x
    if k[i] != k[minj]:
        m += 1


print(' '.join(map(str, k)))
print(m)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionSort(nums):
    k=0
    for i,n in enumerate(nums):
        try:
            m=min(nums[i+1:])
            j=nums.index(m)
            if n>m:
                nums[i],nums[j]=nums[j],nums[i]
                k+=1
        except:
            continue
    return nums,k
    
n=int(input())
nums=list(map(int,input().split()))

nums,k=selectionSort(nums)
print(*nums)
print(k)

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

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


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


Fixed submission (verdict: Accepted):
def selectionSort(nums,n):
    k=0
    for i in range(n):
        minj=i
        for j in range(i,n):
            if nums[j]<nums[minj]:
                minj=j
        if nums[i]!=nums[minj]:
            nums[i],nums[minj]=nums[minj],nums[i]
            
            k+=1
    return nums,k
    
n=int(input())
nums=list(map(int,input().split()))

nums,k=selectionSort(nums,n)
print(*nums)
print(k)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
import sys

def selection_sort(nums, n):
    cnt = 0
    
    for i in range(n):
        minj = i
        for j in range(i, n):
            if nums[j] < nums[minj]:
                minj = j

        nums[i], nums[minj] = nums[minj], nums[i]
        if i != minj:
            cnt += 1

    print(cnt)
    
def main():
    n = int(sys.stdin.readline().strip())
    data = sys.stdin.readline().strip().split(' ')
    nums = [int(i) for i in data]
    selection_sort(nums, n)

if __name__ == '__main__':
    main()
    

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

Expected output:
-2 -2 -2 -2 0 0
2


Actual output:
2


Fixed submission (verdict: Accepted):
import sys

def selection_sort(nums, n):
    cnt = 0
    
    for i in range(n):
        minj = i
        for j in range(i, n):
            if nums[j] < nums[minj]:
                minj = j

        nums[i], nums[minj] = nums[minj], nums[i]
        if i != minj:
            cnt += 1

    print(' '.join([str(i) for i in nums]))
    print(cnt)
    
def main():
    n = int(sys.stdin.readline().strip())
    data = sys.stdin.readline().strip().split(' ')
    nums = [int(i) for i in data]
    selection_sort(nums, n)

if __name__ == '__main__':
    main()
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def SelectionSort(A):
    count = 0
    for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        count += 1
    print(" ".join(map(str, A)))
    print(count)


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

SelectionSort(A)

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

Expected output:
0 2 3 3 5 6
4


Actual output:
0 2 3 3 5 6
6


Fixed submission (verdict: Accepted):
def selectionSort(a):
    count = 0
    for i in range(len(a)):
        mini = i
        for j in range(i,len(a)):
            if a[j] < a[mini]:
                mini = j
        if i != mini:
            ret = a[i]
            a[i] = a[mini]
            a[mini] = ret
            count += 1
    print(" ".join(map(str,a)))
    print(count)
n = int(input())
a = list(map(int,input().split()))
selectionSort(a)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i+1,n-1):
        if a[minj]>a[j]:
            minj=j
        if i!=minj:
            a[i],a[minj]=a[minj],a[i]
            b+=1
print(*a)
print(b)


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

Expected output:
-4 -1 -1 -1 0 1
4


Actual output:
-4 -1 -1 0 1 -1
6


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[minj]>a[j]:
            minj=j
    if i!=minj:
        a[i],a[minj]=a[minj],a[i]
        b+=1
print(*a)
print(b)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[j]<a[minj]:
            minj=j
    a[i],a[minj]=a[minj],a[i]
    c+=1
print(*a)
print(c)


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

Expected output:
-1 2 2 3 3 5
4


Actual output:
-1 2 2 3 3 5
6


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[j]<a[minj]:
            minj=j
    a[i],a[minj]=a[minj],a[i]
    if i!=minj:c+=1
print(*a)
print(c)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionSort(A, N): 
    A = list(map(int, A.split(" ")))
    change_count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
            change_count+=1
    
    
    print(" ".join(map(str,A)))
    print(change_count)
    


N = int(input("数列の長さを表す整数を入力して下さい  "))  
A = input("N 個の整数が空白区切りで入力して下さい  ")   
selectionSort(A,N)



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

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


Actual output:
数列の長さを表す整数を入力して下さい  N 個の整数が空白区切りで入力して下さい  -2 -2 -1 0 0 1
4


Fixed submission (verdict: Accepted):
def selectionSort(A, N): 
    A = list(map(int, A.split(" ")))
    change_count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
            change_count+=1
    
    
    print(" ".join(map(str,A)))
    print(change_count)
    


N = int(input())  
A = input("")   
selectionSort(A,N)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
arr = [int(n) for n in input().split()]

swap_cnt = 0
for i in range(0, N):
    minj = i
    for j in range(i, N - 1):
        if arr[j] < arr[minj]:
            minj = j
        arr[i], arr[minj] = arr[minj], arr[i]
        swap_cnt += 1

print(' '.join(map(str, arr)))
print(swap_cnt)



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

Expected output:
-2 -2 -1 -1 0 0
3


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


Fixed submission (verdict: Accepted):
N = int(input())
arr = [int(n) for n in input().split()]

swap_cnt = 0
for i in range(0, N):
    minj = i
    for j in range(i + 1, N):
        if arr[j] < arr[minj]:
            minj = j
    if (i != minj):
        arr[i], arr[minj] = arr[minj], arr[i]
        swap_cnt += 1

print(' '.join(map(str, arr)))
print(swap_cnt)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def select_sort(array):
    N = len(array)
    count = 0
    
    for i in range(N - 1):
        min_i = array.index(min(array[i:]))
        if i != min_i:
            count += 1
        array[i], array[min_i] = array[min_i], array[i]
        
    return array, count

n = int(input())
array = [int(i) for i in input().split()]
result = select_sort(array)

print(*result[0])
print(result[1])

Failing test case input:
6
8 27 0 1 -1 -1

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


Actual output:
27 0 1 8 -1 -1
5


Fixed submission (verdict: Accepted):
def select_sort(array):
    N = len(array)
    count = 0
    
    for i in range(N - 1):
        min_i = i + array[i:].index(min(array[i:]))
        if i != min_i:
            count += 1
        array[i], array[min_i] = array[min_i], array[i]
        
    return array, count

n = int(input())
array = [int(i) for i in input().split()]
result = select_sort(array)

print(*result[0])
print(result[1])
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):


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


count = 0
for i in range(N):

    if N == 1:
        break

    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    A[i], A[minj] = A[minj], A[i]
    count += 1


for i in range(N):
    if i == N - 1:
        print("{0}".format(A[i]))
    else:
        print("{0} ".format(A[i]), end="")

print(count)


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

Expected output:
-1 1 1 3 5 6
4


Actual output:
-1 1 1 3 5 6
6


Fixed submission (verdict: Accepted):


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


count = 0
flag = 0
for i in range(N):

    if N == 1:
        break

    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
            flag = 1

    if flag == 1:
        A[i], A[minj] = A[minj], A[i]
        count += 1

    flag = 0


for i in range(N):
    if i == N - 1:
        print("{0}".format(A[i]))
    else:
        print("{0} ".format(A[i]), end="")

print(count)

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


for i in range(n):
    minj = k[i]

    for j in range(i,n):
        if minj > k[j]:
            minj = k[j]
            k[j]=k[i]
            m += 1
        k[i] = minj


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

Failing test case input:
6
74 44 0 0 2 -4

Expected output:
-4 0 0 2 44 74
4


Actual output:
-4 0 0 2 44 74
11


Fixed submission (verdict: Accepted):
n = int(input())
k = [int(i) for i in input().split()]
m = 0

for i in range(n):
    minj = i
    for j in range(i,n):
        if k[j] < k[minj]:
            minj = j
    x = k[i]
    k[i] = k[minj]
    k[minj]=x
    if k[i] != k[minj]:
        m += 1


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

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in a:
    for j in range(i+1,n-1):
        if a[i]>a[j]:
            a[i],a[j]=a[j],a[i]
            b+=1
print(*a)
print(b)


Failing test case input:
6
38 70 0 0 0 -2

Expected output:
-2 0 0 0 38 70
5


Actual output:
0 70 38 0 -2 0
2


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[minj]>a[j]:
            minj=j
    if i!=minj:
        a[i],a[minj]=a[minj],a[i]
        b+=1
print(*a)
print(b)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionSort(A, N):
    swap_count = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        swap_count += 1
    return swap_count

n = int(input())
A = list(map(int, input().split()))
count = selectionSort(A, n)
print(*A)
print(count)

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

Expected output:
-1 2 2 3 3 5
4


Actual output:
-1 2 2 3 3 5
6


Fixed submission (verdict: Accepted):
def selectionSort(A, N):
    swap_count = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            swap_count += 1
    return swap_count

n = int(input())
A = list(map(int, input().split()))
count = selectionSort(A, n)
print(*A)
print(count)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
cnt = 0
n = int(input())
a = list(map(int,input().split()))
for i in range(0,n):
	mini = i
	for j in range(i,n):
		if a[j]<a[mini]:
			mini = j
			cnt += 1
	a[j],a[mini] = a[mini],a[j]	
print(" ".join(map(str,a)))
print(cnt)

Failing test case input:
6
74 44 0 0 2 -4

Expected output:
-4 0 0 2 44 74
4


Actual output:
74 44 0 0 2 -4
8


Fixed submission (verdict: Accepted):
cnt = 0
n = int(input())
a = list(map(int,input().split()))
for i in range(0,n):
	mini = i
	for j in range(i,n):
		if a[j]<a[mini]:
			mini = j
	a[i],a[mini] = a[mini],a[i]	
	if i!=mini:
		cnt += 1
print(" ".join(map(str,a)))
print(cnt)

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





def formatting(nums):
    for i in range(len(nums)):
        if i != len(nums) - 1:
            print(nums[i], end=' ')
        else:
            print(nums[i])


def selectionSort(A, N):
    count = 0
    for i in range(N - 1):
        minJ = i
        for j in range(i, N):
            if A[j] < A[minJ]:
                minJ = j
        A[i], A[minJ] = A[minJ], A[i]
        count += 1

    formatting(A)
    print(count - 1)



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

selectionSort(inputList, N)



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

Expected output:
-3 -1 -1 -1 0 1
3


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


Fixed submission (verdict: Accepted):





def formatting(nums):
    for i in range(len(nums)):
        if i != len(nums) - 1:
            print(nums[i], end=' ')
        else:
            print(nums[i])


def selectionSort(A, N):
    count = 0
    for i in range(N - 1):
        minJ = i
        for j in range(i, N):
            if A[j] < A[minJ]:
                minJ = j

        if i != minJ:
            A[i], A[minJ] = A[minJ], A[i]
            count += 1

    formatting(A)
    print(count)



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

selectionSort(inputList, N)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n-1):
    minj=i
    for j in range(i+1,n-1):
        if a[i]>a[j]:
            minj=i
        if i!=minj:
            a[i],a[minj]=a[minj],a[i]
            b+=1
print(*a)
print(b)


Failing test case input:
6
38 44 0 0 1 -4

Expected output:
-4 0 0 1 38 44
5


Actual output:
38 44 0 0 1 -4
0


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[minj]>a[j]:
            minj=j
    if i!=minj:
        a[i],a[minj]=a[minj],a[i]
        b+=1
print(*a)
print(b)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectsort(A):
	t=0
	for i in range(0,len(A)):
		mini=i
		for j in range(i, len(A)):
			if A[j]<A[mini]:
				mini=j
		if i!=mini:
			temp=A[i]
			A[i]=A[mini]
			A[mini]=temp
			t+=1
	return t		

input=input()
A=[int(s) for s in input.split(' ')]
t=selectsort(A)
print (A,t)

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

Expected output:
-1 -1 1 4 6 8
5


Actual output:
[6] 0


Fixed submission (verdict: Accepted):
def selectsort(A):
	t=0
	for i in range(0,len(A)):
		mini=i
		for j in range(i, len(A)):
			if A[j]<A[mini]:
				mini=j
		if i!=mini:
			temp=A[i]
			A[i]=A[mini]
			A[mini]=temp
			t+=1
	return t		

input()
input=input()
A=[int(s) for s in input.split(' ')]
t=selectsort(A)
print (' '.join(map(str,A)))
print(t)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionSort(a, n):
  count = 0
  for i in range(0, n):
    minj = i
    for j in range(i, n):
      if a[j] < a[minj]:
        minj = j
    w = a[i]
    a[i] = a[minj]
    a[minj] = w
    count += 1
  print(' '.join(map(str, a)))
  print(count)

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


Failing test case input:
6
8 27 4 1 1 -1

Expected output:
-1 1 1 4 8 27
5


Actual output:
-1 1 1 4 8 27
6


Fixed submission (verdict: Accepted):
def selectionSort(a, n):
  count = 0
  for i in range(0, n):
    minj = i
    for j in range(i, n):
      if a[j] < a[minj]:
        minj = j
    if i != minj:
      w = a[i]
      a[i] = a[minj]
      a[minj] = w
      count += 1
  print(' '.join(map(str, a)))
  print(count)

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

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if (A[j] < A[minj]):
            minj = j
            if (minj != i):
                A[i], A[minj] = A[minj], A[i]
                count += 1
print(*A)
print(count)

Failing test case input:
6
23 60 0 0 0 -3

Expected output:
-3 0 0 0 23 60
5


Actual output:
-3 0 0 0 23 60
12


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
count = 0
for i in range(N):
    m = i
    for j in range(i, N):
        if (A[j] < A[m]):
            m = j
    if (m != i):
        A[i], A[m] = A[m], A[i]
        count += 1
print(*A)
print(count)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i+1,n-1):
        if a[minj]>a[j]:
            minj=i
        if i!=minj:
            a[i],a[minj]=a[minj],a[i]
            b+=1
print(*a)
print(b)


Failing test case input:
6
14 70 0 0 0 -1

Expected output:
-1 0 0 0 14 70
5


Actual output:
14 70 0 0 0 -1
0


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[minj]>a[j]:
            minj=j
    if i!=minj:
        a[i],a[minj]=a[minj],a[i]
        b+=1
print(*a)
print(b)

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

n = int(input())
a = list(map(int,input().split()))
count = 0

for i in range(n):
    minij =i
    for j in range(i,n):
        if a[j] < a[minij]:
            minij = j
            a[i],a[minij] = a[minij],a[i]
            count+=1
for i in range(n):
    if i != n-1:
        print("{0} ".format(a[i]),end="")
    else:
        print("{0}".format(a[i]))


print(count)




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

Expected output:
-1 0 0 1 2 2
4


Actual output:
-1 0 0 1 2 2
6


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

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

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

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionSort(A,N):
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i],A[minj] = A[minj],A[i]
            count += 1
    return (count)

if __name__ == '__main__':
    n = int(input())
    data = [int(i) for i in range(n)]
    result = selectionSort(data,n)
    print(" ".join(map(str,data)))
    print(result)

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

Expected output:
-1 0 2 2 3 5
2


Actual output:
0 1 2 3 4 5
0


Fixed submission (verdict: Accepted):
def selection_Sort(A,N):
    count = 0
    for i in range(N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i],A[minj] = A[minj],A[i]
            count += 1
    return (count)

if __name__ == '__main__':
    n = int(input())
    data = [int(i) for i in input().split()]
    result = selection_Sort(data,n)
    print(" ".join(map(str,data)))
    print(result)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N = int(input())
A = [int(x) for x in input().split()]
cnt = 0

for i in range(N):
    mini = i
    for j in range(i, N):
        if A[j] < A[mini]:
            mini = j
    if i != mini:
        A[i], A[mini] = A[mini], A[i]
        cnt +=1

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



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

Expected output:
-1 0 1 4 6 8
4


Actual output:
4
-1 0 1 4 6 8


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(x) for x in input().split()]
cnt = 0

for i in range(N):
    mini = i
    for j in range(i, N):
        if A[j] < A[mini]:
            mini = j
    if i != mini:
        A[i], A[mini] = A[mini], A[i]
        cnt +=1

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

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(0,n-1):
    minj=i
    for j in range(i+1,n-1):
        if a[minj]>a[j]:
            a[minj],a[j]=a[j],a[minj]
            minj=j
            b+=1
print(*a)
print(b)


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

Expected output:
-2 -2 -1 -1 0 1
3


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


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[minj]>a[j]:
            minj=j
    if i!=minj:
        a[i],a[minj]=a[minj],a[i]
        b+=1
print(*a)
print(b)

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


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


count = 0
for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    A[i], A[minj] = A[minj], A[i]
    count += 1

for i in range(N):
    if i == N - 1:
        print("{0}".format(A[i]))
    else:
        print("{0} ".format(A[i]), end="")

print(count)


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

Expected output:
1 2 2 3 6 9
5


Actual output:
1 2 2 3 6 9
6


Fixed submission (verdict: Accepted):


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


count = 0
flag = 0
for i in range(N):

    if N == 1:
        break

    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
            flag = 1

    if flag == 1:
        A[i], A[minj] = A[minj], A[i]
        count += 1

    flag = 0


for i in range(N):
    if i == N - 1:
        print("{0}".format(A[i]))
    else:
        print("{0} ".format(A[i]), end="")

print(count)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=c=0
for i in range(n-1):
 m=a.index(min(a[i:]))
 if a[i]>a[m]:
  a[i],a[m]=a[m],a[i];c+=1
print(*a)
print(c)


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

Expected output:
-1 0 0 0 2 2
3


Actual output:
-1 2 2 0 0 0
3


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n-1):
 m=a.index(min(a[i:]),i)
 if a[i]>a[m]:
  a[i],a[m]=a[m],a[i];c+=1
print(*a)
print(c)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):


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

swapCount = 1
for i in range(0, N):
    minIndex = i
    for j in range(0, N):
        if a[j] < a[minIndex]:
            minIndex = j
    
    if i != minIndex:
        tmp = a[i]
        a[i] = a[minIndex]
        a[minIndex] = tmp
        swapCount += 1

print(' '.join(map(str, a)))
print(swapCount)

        

Failing test case input:
6
8 35 0 1 0 -1

Expected output:
-1 0 0 1 8 35
4


Actual output:
35 0 1 0 8 -1
7


Fixed submission (verdict: Accepted):


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

swapCount = 0
for i in range(0, N):
    minIndex = i
    for j in range(i, N):
        if a[j] < a[minIndex]:
            minIndex = j
    
    if i != minIndex:
        tmp = a[i]
        a[i] = a[minIndex]
        a[minIndex] = tmp
        swapCount += 1

print(' '.join(map(str, a)))
print(swapCount)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
N   = int(input())
A   = [int(temp) for temp in input().split()]
cou = 0

for i in range(N - 1) :
    minj = N - 1
    for j in range(i, N - 1) :
        if A[j] < A[minj] :
            minj = int(j)
    if A[i] != A[minj] :
        tem  = int(A[i])
        A[i] = int(A[minj])
        A[minj] = int(tem)
        cou = cou + 1
A   = [str(temp) for temp in A]
print(' '.join(A))
print(cou)

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

Expected output:
0 0 2 6 6 8
3


Actual output:
0 0 2 6 6 8
4


Fixed submission (verdict: Accepted):
N, A, cou   = int(input()), [int(temp) for temp in input().split()], 0

for i in range(N) :
    minj = i
    for j in range(i, N) :
        if A[j] < A[minj] :
            minj = int(j)
    if A[i] != A[minj] :
        A[i], A[minj] = int(A[minj]), int(A[i])
        cou = cou + 1
print(*A)
print(cou)

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i+1,n-1):
        if a[i]>a[j]:
            minj=i
        if i!=minj:
            a[i],a[minj]=a[minj],a[i]
            b+=1
print(*a)
print(b)


Failing test case input:
6
23 87 3 0 -1 -1

Expected output:
-1 -1 0 3 23 87
3


Actual output:
23 87 3 0 -1 -1
0


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
b=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if a[minj]>a[j]:
            minj=j
    if i!=minj:
        a[i],a[minj]=a[minj],a[i]
        b+=1
print(*a)
print(b)