ZhenlongDai/ACPR huggingface dataset:
Problem: p03211
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
c=0
for i in range(len(a)-2):
    b=int(a[i:i+3])
    if abs(753-c) > abs(753-b):
        c=b
print(753-c)

Failing test case input:
89141

Expected output:
138


Actual output:
-138


Fixed submission (verdict: Accepted):
a = input()
c=0
for i in range(len(a)-2):
    b=int(a[i:i+3])
    if abs(753-c) > abs(753-b):
        c=b
print(abs(753-c))

Problem: p03211
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
N = len(S)

ans = 753
for i in range(N - 3):
    ans = min(ans, abs(int(S[i:i + 3]) - 753))
print(ans)


Failing test case input:
1339

Expected output:
414


Actual output:
620


Fixed submission (verdict: Accepted):
S = input()
N = len(S)

ans = 753
for i in range(N - 2):
    ans = min(ans, abs(int(S[i:i + 3]) - 753))
print(ans)

Problem: p03211
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(map(int, input()))
print(min(abs(s[i+2]*100+s[i+1]*10+s[i]-753) for i in range(len(s)-2)))

Failing test case input:
391005951

Expected output:
157


Actual output:
158


Fixed submission (verdict: Accepted):
s = list(map(int, input()))
print(min(abs(s[i+2]+s[i+1]*10+s[i]*100-753) for i in range(len(s)-2)))

Problem: p03211
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S = input()

ans = 1000000

for i in range(len(S)-2):
    if(abs(753-int(S[i:i+3]) < ans)):
        ans = abs(753-int(S[i:i+3]))

print(ans)

Failing test case input:
79098

Expected output:
37


Actual output:
156


Fixed submission (verdict: Accepted):
S = input()

ans = 1000000

for i in range(len(S)-2):
    if(abs(753-int(S[i:i+3])) < ans):
        ans = abs(753-int(S[i:i+3]))

print(ans)

Problem: p03211
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
S = input()
ans = 1000
for i in range(len(S)-2):
  ans = min(ans, int(S[i:i+3]))
print(ans)

Failing test case input:
1335

Expected output:
418


Actual output:
133


Fixed submission (verdict: Accepted):
S = input()
ans = 1000
for i in range(len(S)-2):
  ans = min(ans, abs(753-int(S[i:i+3])))
print(ans)

Problem: p03211
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=input()
m=1000
for i in range (len(n)-2):
  k = abs(int(n[i:i+2]) - 753)
  m = min(m,k)
print(m)


Failing test case input:
391005951

Expected output:
157


Actual output:
658


Fixed submission (verdict: Accepted):
n=input()
m=1000
for i in range (len(n)-2):
  k = abs(int(n[i:i+3]) - 753)
  m = min(m,k)
print(m)

Problem: p03211
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
str = list(input())  
ans = float("inf")

for i in range(len(str)-1):
    sa = abs(int(str[i - 1]) * 100 + int(str[i]) * 10 + int(str[i + 1]) - 753)
    ans = min(ans, sa)

print(ans)


Failing test case input:
5348

Expected output:
219


Actual output:
100


Fixed submission (verdict: Accepted):
str = list(input())  
ans = 1000

for i in range(len(str) - 2):
    sa = abs(int(str[i]) * 100 + int(str[i+1]) * 10 + int(str[i + 2]) - 753)
    ans = min(ans, sa)

print(ans)
Problem: p03211
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
Smin = 753
for i in range(len(S)-2):
  if Smin > 753-int(S[i:i+3]):
    Smin = 753-int(S[i:i+3])
print(Smin)

Failing test case input:
2327659

Expected output:
12


Actual output:
-12


Fixed submission (verdict: Accepted):
S = input()
Smin = 753
for i in range(len(S)-2):
  if Smin > abs(753-int(S[i:i+3])):
    Smin = abs(753-int(S[i:i+3]))
print(Smin)

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

import sys

target = 753
num = input()

diff = sys.maxsize

for pos in range(0, len(num)-3):
    diff = min(abs(753 - int(num[pos:pos+3])), diff)

print(diff)

Failing test case input:
3500

Expected output:
253


Actual output:
403


Fixed submission (verdict: Accepted):

import sys

target = 753
num = input()

diff = sys.maxsize

for pos in range(0, len(num)-2):
    diff = min(abs(753 - int(num[pos:pos+3])), diff)

print(diff)

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


s = input()

min = 999
i = 0
while i + 3 < len(s):
    t = s[i:i+3]
    n = int(t) - 753
    if n < 0:
        n = -n
    if min > n:
        min = n
    i = i + 1

print(min)


Failing test case input:
43594

Expected output:
159


Actual output:
318


Fixed submission (verdict: Accepted):


s = input()

min = 999
i = 0
while i + 3 <= len(s):
    t = s[i:i+3]
    n = int(t) - 753
    if n < 0:
        n = -n
    if min > n:
        min = n
    i = i + 1

print(min)

Problem: p03211
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
m=999
for i in range(len(S)-2):
  d=753-int(S[i:i+3])
  if d<m:
    m=d
    
print(m)

Failing test case input:
18506

Expected output:
97


Actual output:
-97


Fixed submission (verdict: Accepted):
S=input()
m=999
for i in range(len(S)-2):
  d=abs(753-int(S[i:i+3]))
  if d<m:
    m=d
print(m)
Problem: p02314
Buggy submission (Python3, verdict: Wrong Answer):
n,m = map(int, input().split())
d = list(map(int, input().split()))
inf = float('inf')
dp = [inf for i in range(n+1)]
dp[0] = 0
for i in range(m):
    print(dp)
    for j in range(d[i], n+1):
        dp[j] = min(dp[j], dp[j-d[i]]+1)

print(dp[-1])


Failing test case input:
55 4
1 5 10 50

Expected output:
2

Actual output:
[0, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf, inf]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]
[0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 6, 7, 8, 9, 10, 7, 8, 9, 10, 11, 8, 9, 10, 11, 12, 9, 10, 11, 12, 13, 10, 11, 12, 13, 14, 11]
[0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 6]
2


Fixed submission (verdict: Accepted):
n,m = map(int, input().split())
d = list(map(int, input().split()))
inf = float('inf')
dp = [inf for i in range(n+1)]
dp[0] = 0
for i in range(m):
    for j in range(d[i], n+1):
        dp[j] = min(dp[j], dp[j-d[i]]+1)

print(dp[-1])

Problem: p02314
Buggy submission (Python3, verdict: Wrong Answer):
n, m = input().split()
n, m = int(n), int(m)
C = [int(c) for c in input().split()]


INF = float('inf')
T = [INF] * n
T[0] = 0

for c in C:
    for j in range(c, n):
        T[j] = min(T[j], T[j - c] + 1)

print(T[-1])

Failing test case input:
55 4
1 5 10 50

Expected output:
2

Actual output:
5


Fixed submission (verdict: Accepted):
n, m = input().split()
n, m = int(n), int(m)
C = [int(c) for c in input().split()]


T = [0] + [float('inf')] * n

for c in C:
    for j in range(c, n+1):
        T[j] = min(T[j], T[j - c] + 1)

print(T[-1])
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def pretty_sequence(sequence):
    n = len(sequence)
    for i in range(n-1):
        print(format(sequence[i]) + ' ', end='')
    print(sequence[n - 1])

n = int(input())
sequence = [int(x) for x in input().split(' ')]


def selectionsort(seq, x):
    count = 0
    for i in range(x):
        minj = i
        for j in range(i, x):
            if seq[j] < seq[minj]:
                minj = j
        if seq[i] != seq[minj]:
            tmp_val = seq[i]
            seq[i] = seq[minj]
            seq[minj] = tmp_val
            count += 1
        pretty_sequence(seq)
    return seq, count

sequence, count = selectionsort(sequence, n)
pretty_sequence(sequence)
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 60 0 0 0 23
-3 0 60 0 0 23
-3 0 0 60 0 23
-3 0 0 0 60 23
-3 0 0 0 23 60
-3 0 0 0 23 60
-3 0 0 0 23 60
5


Fixed submission (verdict: Accepted):
def pretty_sequence(sequence):
    n = len(sequence)
    for i in range(n-1):
        print(format(sequence[i]) + ' ', end='')
    print(sequence[n - 1])

n = int(input())
sequence = [int(x) for x in input().split(' ')]


def selectionsort(seq, x):
    count = 0
    for i in range(x):
        minj = i
        for j in range(i, x):
            if seq[j] < seq[minj]:
                minj = j
        if seq[i] != seq[minj]:
            tmp_val = seq[i]
            seq[i] = seq[minj]
            seq[minj] = tmp_val
            count += 1
    return seq, count

sequence, count = selectionsort(sequence, n)
pretty_sequence(sequence)
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):
    minj = i
    for j in range(i,n):
        if A[j] < A[minj]:
            minj = j
        t = A[i]
        A[i] = A[minj]
        A[minj] = t
        c += 1
	
print("".join(map(str,A)))
print(c)

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

Expected output:
1 2 3 3 6 6
4


Actual output:
323166
21


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
    if minj != i:
        t = A[i]
        A[i] = A[minj]
        A[minj] = t
        c += 1
	
print(" ".join(map(str,A)))
print(c)
Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):


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

swapCount = 0
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
23 60 0 0 1 -3

Expected output:
-3 0 0 1 23 60
5


Actual output:
23 0 0 1 -3 60
6


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):
def selectionSort(A, N):
    swap_count = 0
    if N < 2:
        return swap_count
    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
-2 -1 1 -2 0 -1

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


Actual output:
-2 -2 -1 -1 0 1
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):
def selections(N):
    count = 0
    for i in range(len(N)):
        mini = i
        for j in range(i+1, len(N)):
            if N[mini] > N[j]:
                mini = j
        if i != mini:
            N[mini], N[i] = N[i], N[mini]
    c = 1
    for i in N:
        print(i, end='')
        if c < len(N):
            print(' ', end='')
            c += 1
    print('')
    print(count)

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

selections(numbers)

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
0


Fixed submission (verdict: Accepted):
def selections(N):
    count = 0
    for i in range(len(N)):
        mini = i
        for j in range(i+1, len(N)):
            if N[mini] > N[j]:
                mini = j
        if i != mini:
            N[mini], N[i] = N[i], N[mini]
            count += 1
    c = 1
    for i in N:
        print(i, end='')
        if c < len(N):
            print(' ', end='')
            c += 1
    print('')
    print(count)
    
n = int(input())
numbers = list(map(int, input().split()))

selections(numbers)
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
        if i != minj:
            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
-2 -1 0 -2 0 -2

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


Actual output:
[-2, -2, -2, -1, 0, 0]
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())
li = list(map(int, input().split()))
cnt = 0

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

print(li)
print(cnt)

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

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


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


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

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

print(*li)
print(cnt)

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 + 1, N - 1):
        if arr[j] < arr[minj]:
            minj = j
        arr[i], arr[minj] = arr[minj], arr[i]
        swap_cnt += 1 if i != minj else 0

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



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

Expected output:
-1 0 0 0 8 35
5


Actual output:
0 0 0 8 35 -1
9


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):
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
    t = A[i]
    A[i] = A[minj]
    A[minj] = t
    c += 1
	
print("".join(map(str,A)))
print(c)

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

Expected output:
-1 0 0 1 8 27
4


Actual output:
-1001827
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
    if minj != i:
        t = A[i]
        A[i] = A[minj]
        A[minj] = t
        c += 1
	
print(" ".join(map(str,A)))
print(c)

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)



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
5


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()))
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 3

Expected output:
1 2 3 4 5 6
4

Actual output:
1 2 3 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())
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 if i != minj else 0

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



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

Expected output:
-1 0 0 1 6 27
4


Actual output:
0 0 1 6 27 -1
9


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 sel_sort(A, N):
    
    count = 0
    for n in range(N):
        minm = n
        for m in range(n, N):
            if A[m] < A[minm]:
                minm = m
            
        if minm != n:
            A[n], A[minm] = A[minm], A[n]
            count += 1
    
    return (A, count)


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))

    ans = sel_sort(A, N)

    print(ans[0])
    print(ans[1])


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

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


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


Fixed submission (verdict: Accepted):
def sel_sort(A, N):
    
    count = 0
    for n in range(N):
        minm = n
        for m in range(n, N):
            if A[m] < A[minm]:
                minm = m
            
        if minm != n:
            A[n], A[minm] = A[minm], A[n]
            count += 1
    
    return (A, count)


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split(' ')))

    ans = sel_sort(A, N)

    print(' '.join([str(x) for x in ans[0]]))
    print(ans[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
            count += 1
    A[i], A[minj] = A[minj], A[i]


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
1 3 2 2 -1 5

Expected output:
-1 1 2 2 3 5
2


Actual output:
-1 1 2 2 3 5
3


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):
count = int(input());
data = [int(n) for n in input().split(" ")];

def selection_sort(data):
    count = len(data);
    o = 0;
    for i in range(count):
        minI = i;
        for j in range(i + 1, count):
            if data[j] < data[minI]:
                minI = j;
        temp = data[i];
        data[i] = data[minI];
        data[minI] = temp;
        o += 1;
    show(data);
    print(o);

def show(data):
    print(" ".join(str(n) for n in data));

selection_sort(data);


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):
count = int(input());
data = [int(n) for n in input().split(" ")];

def selection_sort(data):
    count = len(data);
    o = 0;
    for i in range(count):
        minI = i;
        for j in range(i + 1, count):
            if data[j] < data[minI]:
                minI = j;
        if minI != i:
            temp = data[i];
            data[i] = data[minI];
            data[minI] = temp;
            o += 1;
    show(data);
    print(o);

def show(data):
    print(" ".join(str(n) for n in data));

selection_sort(data);

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


def selectionSort(nums,n):
    count=0
    for i in range(n):
        minj=i
        for j in range(i+1,n):
            if nums[j]<nums[minj]:
                minj=j
        if i!=minj:          
            tmp=nums[minj]
            nums[minj]=nums[i]
            nums[i]=tmp
            count+=1
    print(' '.join(nums))
    print(count)


selectionSort(nums,n)


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

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


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


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


def selectionSort(nums):
    count=0
    for i in range(len(nums)):
        minj=i
        for j in range(i,len(nums)):
            if int(nums[j])<int(nums[minj]):
                minj=j
        if i!=minj:          
            tmp=nums[minj]
            nums[minj]=nums[i]
            nums[i]=tmp
            count+=1
    print(' '.join(nums))
    print(count)


selectionSort(nums)

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[i],a[mini] = a[mini],a[i]	
print(" ".join(map(str,a)))
print(cnt)

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

Expected output:
-1 0 0 1 8 27
4


Actual output:
-1 0 0 1 8 27
6


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):
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
print(*A)
print(count)

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

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


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


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):

A = []



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


i = 0
CHANGE_COUNT = 0

while i <= LENGTH -1:
    print(" ".join(map(str, A)))
    print(CHANGE_COUNT)
    j = i + 1
    mini = i
    while j <= LENGTH -1:
        if int(A[j]) < int(A[mini]) :
            mini = j
        j += 1
    if mini != i:
        tmp = A[i]
        A[i] = A[mini]
        A[mini] = tmp
        CHANGE_COUNT += 1
    i += 1

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


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

Expected output:
-1 2 3 3 5 5
3


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


Fixed submission (verdict: Accepted):









A = []



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


i = 0
CHANGE_COUNT = 0

while i <= LENGTH -1:
    j = i + 1
    mini = i
    while j <= LENGTH -1:
        if int(A[j]) < int(A[mini]) :
            mini = j
        j += 1
    if mini != i:
        tmp = A[i]
        A[i] = A[mini]
        A[mini] = tmp
        CHANGE_COUNT += 1
    i += 1

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

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selectionSort(A, N): 
    A = 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)
    return True


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



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

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


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


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):
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
        A[i], A[minj] = A[minj], A[i]
        sw += 1
    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
-1 -1 -1 1 -1 -1

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


Actual output:
-1 -1 -1 -1 -1 1
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 = [int(i) for i in input().split()]

cnt = 0

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

print(' '.join([str(i) for i in A]))
print(cnt)

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

Expected output:
-1 1 1 5 6 8
4


Actual output:
-1 1 1 5 6 8
5


Fixed submission (verdict: Accepted):

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

cnt = 0

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

print(' '.join([str(i) for i in 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-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
print(*A)
print(count)

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
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):
dummy = input()

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

print(s_list)

count = 0
for i in range(len(s_list)-1):

    min_i = i

    for j in range(i,len(s_list)):

        if s_list[j] < s_list[min_i]:
            min_i = j

    if s_list[i] != s_list[min_i]:
        count += 1
        min_num = s_list[min_i]

        s_list[min_i] = s_list[i]
        s_list[i]     = min_num

for i,row in enumerate(s_list):
    if i == 0:
        print(row,end='')
    else:
        print('',row,end='')
print()
print(count)

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

Expected output:
-1 0 0 1 6 27
4


Actual output:
[6, 27, 0, 1, 0, -1]
-1 0 0 1 6 27
4


Fixed submission (verdict: Accepted):
dummy = input()

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



count = 0
if len(s_list) == 1:
    for i,row in enumerate(s_list):
        if i == 0:
            print(row,end='')
        else:
            print('',row,end='')
    print()
    print(count)

else:
    for i in range(len(s_list)-1):

        min_i = i

        for j in range(i,len(s_list)):

            if s_list[j] < s_list[min_i]:
                min_i = j

        if s_list[i] != s_list[min_i]:
            count += 1
            min_num = s_list[min_i]

            s_list[min_i] = s_list[i]
            s_list[i]     = min_num

    for i,row in enumerate(s_list):
        if i == 0:
            print(row,end='')
        else:
            print('',row,end='')
    print()
    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-1):
    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 -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):
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 selection_sort(A):
    n = len(A)
    swap_cnt = 0
    for i in range(n):
        mini = i
        for j in range(i, n):
            if A[j] < A[mini]:
                mini = j
        A[i], A[mini] = A[mini], A[i]
        swap_cnt += 1
    return A, swap_cnt

n = int(input())
A = list(map(int, input().split()))
A, swap_cnt = selection_sort(A)
print(' '.join(list(map(str, A))))
print(swap_cnt)


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

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


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


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

n = int(input())
A = list(map(int, input().split()))
A, swap_cnt = selection_sort(A)
print(' '.join(list(map(str, A))))
print(swap_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
for i in range(n):
    print("{0} ".format(a[i]),end="")
print()

print(count)



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

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


Actual output:
-4 -1 1 0 38 44 
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):
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
5 2 4 6 1 0

Expected output:
0 1 2 4 5 6
5


Actual output:
0 2 4 6 1 5
0 1 4 6 2 5
0 1 2 6 4 5
0 1 2 4 6 5
0 1 2 4 5 6
0 1 2 4 5 6
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):
def selectionSort(A, N): 
    A = 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
    
    return A, change_count


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


print(" ".join(map(str,sorted_list)))
print(change_count)


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

Expected output:
-1 0 0 0 2 2
3


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


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())
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
-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):


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):
def selectionSort(A, N): 
    A = 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)
    return True


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



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

Expected output:
-1 0 1 4 8 27
4


Actual output:
数列の長さを表す整数を入力して下さい  N 個の整数が空白区切りで入力して下さい  -1 0 1 27 4 8
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())
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)



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

Expected output:
0 2 3 3 6 6
4


Actual output:
0 6 2 3 6 3
0 2 6 3 6 3
0 2 3 6 6 3
0 2 3 3 6 6
4


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 bubbleSort(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[j], A[minj] = A[minj], A[j]
                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)

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

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


Actual output:
-1 0 -1 1 -4 -1
5


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):
times = int(input())
numbers = list(map(int, input().split()))
count = 0
minj = 0

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

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



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

Expected output:
-1 1 2 2 3 3
2


Actual output:
-1 1 2 2 3 3
3


Fixed submission (verdict: Accepted):
times = int(input())
numbers = list(map(int, input().split()))
count = 0
minj = 0

for i in range(times):
    minj = i
    for j in range(i, times, 1):
        if numbers[j] < numbers[minj]:
            minj = j

    if i != minj:
        numbers[i], numbers[minj] = numbers[minj], numbers[i]
        count += 1

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

Problem: p02260
Buggy submission (Python3, verdict: Wrong Answer):
def selection(A,n):
  count = 0
  for i in range(0,n-1):
    min = i
    for j in range(i,n):
      if(A[j] < A[min]):
        min = j
    if(min!=i):
      A[i], A[min] = A[min], A[i]
      count+=1
  print(count)

def printList(A):
  print(" ".join(str(x) for x in A))

n = int(input())
A = [int(x) for x in input().split()]
selection(A,n)
printList(A)

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

Expected output:
-1 0 0 0 14 70
5


Actual output:
5
-1 0 0 0 14 70


Fixed submission (verdict: Accepted):
def selection(A,n):
  count = 0
  for i in range(0,n-1):
    min = i
    for j in range(i,n):
      if(A[j] < A[min]):
        min = j
    if(min!=i):
      A[i], A[min] = A[min], A[i]
      count+=1
  printList(A)
  print(count)

def printList(A):
  print(" ".join(str(x) for x in A))

n = int(input())
A = [int(x) for x in input().split()]
selection(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):
        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)

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
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):
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

        if i != minj:
            nums[i], nums[minj] = nums[minj], nums[i]
            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
5 2 4 6 1 0

Expected output:
0 1 2 4 5 6
5


Actual output:
5


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):
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]
            if (minj != i):
                count += 1
print(*A)
print(count)

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

Expected output:
-1 0 2 2 3 5
2


Actual output:
-1 0 2 2 3 5
7


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())
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
9 6 2 2 1 3

Expected output:
1 2 2 3 6 9
5


Actual output:
1 2 2 6 9 3
3


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 print_list(A):
    print(*A, sep=" ")

def swap(a, b):
    return b, a

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

def selection_sort(A, n):
    replace_num = 0
    for i in range(0, n):
        minj = find_minj(A, i, n)
        A[i], A[minj] = swap(A[i], A[minj])
        replace_num += 1
    print_list(A)
    print(replace_num)

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

selection_sort(A, n)


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 print_list(A):
    print(*A, sep=" ")

def swap(a, b):
    return b, a

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

def selection_sort(A, n):
    replace_num = 0
    for i in range(0, n):
        minj = find_minj(A, i, n)
        if A[i] > A[minj]:
            A[i], A[minj] = swap(A[i], A[minj])
            replace_num += 1
    print_list(A)
    print(replace_num)

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

selection_sort(A, n)

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
    if i !=minj:
        c+=1
    A[i],A[minj] = A[minj],A[i]
    print(*A)
print(c)

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

Expected output:
-4 0 0 2 41 44
5


Actual output:
-4 44 0 0 2 41
-4 0 44 0 2 41
-4 0 0 44 2 41
-4 0 0 2 44 41
-4 0 0 2 41 44
-4 0 0 2 41 44
5


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)