Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque
import copy

swap = [[1, 4], [0, 2, 5], [1, 3, 6], [2, 7], [0, 5], [1, 4, 6], [2, 5, 7], [3, 6]]


def bfs():
    ia = list(range(8))
    count = {str(ia): 0}
    que = deque()
    que.append((ia, 0))
    while len(que) != 0:
        state, cnt = que.popleft()
        # pos:0?????????
        pos = state.index(0)
        swap_target = swap[pos]
        for i in swap_target:
            tmp_state = copy.copy(state)
            tmp_state[i], tmp_state[pos] = tmp_state[pos], tmp_state[i]
            if str(tmp_state) not in count:
                count[str(tmp_state)] = cnt + 1
                que.append((tmp_state, cnt + 1))
    return count


if __name__ == '__main__':
    count = bfs()
    while True:
        prob = list(map(int, input().split()))
        print(count[str(prob)])

Fixed submission:
from collections import deque
import copy

swap = [[1, 4], [0, 2, 5], [1, 3, 6], [2, 7], [0, 5], [1, 4, 6], [2, 5, 7], [3, 6]]


def bfs():
    ia = list(range(8))
    count = {str(ia): 0}
    que = deque()
    que.append((ia, 0))
    while len(que) != 0:
        state, cnt = que.popleft()
        # pos:0?????????
        pos = state.index(0)
        swap_target = swap[pos]
        for i in swap_target:
            tmp_state = copy.copy(state)
            tmp_state[i], tmp_state[pos] = tmp_state[pos], tmp_state[i]
            if str(tmp_state) not in count:
                count[str(tmp_state)] = cnt + 1
                que.append((tmp_state, cnt + 1))
    return count


if __name__ == '__main__':
    count = bfs()
    while True:
        try:
            prob = list(map(int, input().split()))
            print(count[str(prob)])
        except:
            break
Buggy python submission (verdict: Runtime Error):
from collections import deque

d = [(1, 0), (-1, 0), (0, 1), (0, -1)]


def bfs(n):
    global pos_x, pos_y
    while len(que) != 0:
        x, y = que.popleft()
        for dx, dy in d:
            if 0 <= x + dx < W and 0 <= y + dy < H:
                if meiz[x + dx][y + dy] == str(n):
                    pos_x = x + dx
                    pos_y = y + dy
                    # print(distance)
                    return distance[x][y] + 1
                elif meiz[x + dx][y + dy] != "X" and distance[x + dx][y + dy] == float("inf"):
                    distance[x + dx][y + dy] = distance[x][y] + 1
                    # print(distance)
                    que.append((x + dx, y + dy))


if __name__ == '__main__':
    H, W, N = list(map(int, input().split()))
    meiz = [input() for i in range(H)]

    pos_x = 0
    for tmp in meiz:
        if tmp.find("S") != -1:
            pos_y = tmp.find("S")
            break
        pos_x += 1

    ans = 0
    for i in range(1, N + 1):
        distance = [[float("inf") for i in range(W)] for i in range(H)]
        distance[pos_x][pos_y] = 0
        que = deque()
        que.append((pos_x, pos_y))
        # print(que)
        ans += bfs(i)

    print(ans)

Fixed submission:
from collections import deque

INF = 100000000
H, W, N = list(map(int, input().split()))
maze = [list(input()) for i in range(H)]

x = -1
for letters in maze:
    x += 1
    y = -1
    for letter in letters:
        y += 1
        if letter == "S":
            sx = x
            sy = y
        elif letter == str(N):
            gx = x
            gy = y

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


def bfs():
    count = 0
    backup = []
    for tmp_goal in range(1, N + 1):
        d = [[INF for i in range(W)] for j in range(H)]
        if tmp_goal == 1:
            q = deque([[sx, sy]])
            d[sx][sy] = 0
        else:
            q = deque([backup])
            d[backup[0]][backup[1]] = count

        while len(q) != 0:
            tmp_x, tmp_y = q.popleft()
            if maze[tmp_x][tmp_y] == str(tmp_goal):
                count = d[tmp_x][tmp_y]
                backup = [tmp_x, tmp_y]
                q.clear()
                break
            for j in range(0, 4):
                nx = tmp_x + dx[j]
                ny = tmp_y + dy[j]
                if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] != "X" and d[nx][ny] == INF:
                    q.append([nx, ny])
                    d[nx][ny] = d[tmp_x][tmp_y] + 1
    return count


if __name__ == '__main__':
    ans = bfs()
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math

r = 100
n = input()
for i in range(n):
    r = math.ceil(r * 1.05)
print(r * 1000)


Fixed submission:
import math

r = 100
n = int(input())
for i in range(n):
    r = math.ceil(r * 1.05)
print(r * 1000)
Buggy python submission (verdict: Runtime Error):
import sys
import collections

while True:
    N, Q = map(int, sys.stdin.readline().split())
    if N == 0:
        break
    counter = collections.Counter()
    for i in xrange(N):
        date = map(int, sys.stdin.readline().split())
        if date[0] != 0:
            counter.update(date[1:])
    
    result = counter.most_common()
    largest = result[0][1]
    
    ret = -1
    if largest < Q:
        print 0
    else:
        smallest = 100
        for n, c in result:
            if c < largest:
                break
            if n < smallest:
                smallest = n
        print smallest

Fixed submission:
import sys
import collections

while True:
    N, Q = map(int, sys.stdin.readline().split())
    if N == 0:
        break
    counter = collections.Counter()
    for i in xrange(N):
        date = map(int, sys.stdin.readline().split())
        if date[0] != 0:
            counter.update(date[1:])
    
    if len(counter) == 0:
        print 0
        continue
    
    result = counter.most_common()
    largest = result[0][1]
    
    ret = -1
    if largest < Q:
        print 0
    else:
        smallest = 100
        for n, c in result:
            if c < largest:
                break
            if n < smallest:
                smallest = n
        print smallest
Buggy python submission (verdict: Runtime Error):
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    a = sorted(map(int, input().split()))
    index = bisect.bisect_left(a, m) - 1
    if index <= 0:
        print("NONE")
        continue
    ans = 0
    for i in range(index, 0, -1):
        for j in range(i-1, -1, -1):
            if a[i] + a[j] <= m:
                ans = max(ans, a[i] + a[j])
    if ans:
        print(ans)
    else:
        print("NONE")


Fixed submission:
while True:
    n, m = map(int, raw_input().split())
 
    if n == 0 and m == 0:
        break
 
    a = map(int, raw_input().split())
 
    ans = -1
 
    for i in range(n-1):
        for j in range(i+1, n):
            if a[i] + a[j] <= m:
                ans = max(ans, a[i] + a[j])
 
    print "NONE" if ans == -1 else ans
Buggy python submission (verdict: Runtime Error):

x = raw_input().split()

y = map(int,x)

a = y[0]
b = y[1]

c = a*b
d = (a+b)*2

print c, d


Fixed submission:
a, b= map(int, input().split())


c = (a*b)
d = (a+b)*2

print( c, d)

Buggy python submission (verdict: Runtime Error):
a, b= map(int, input().split())


c = (a*b)
d = (a+b)*2

print( c, d)


Fixed submission:
a, b= map(int, input().split())


c = (a*b)
d = (a+b)*2

print( c, d)
Buggy python submission (verdict: Runtime Error):
list = sorted(map(int,raw_input().split()))
strlist = map(str,list)
print strlist[0] + ' ' + strlist[1] + ' ' + strlist[2]


Fixed submission:
a, b, c= map(int, input().split())
if a<=b<=c:print(a, b, c)
if b<a<=c:print(b, a, c)
if a<=c<b:print(a, c, b)
if b<c<a:print(b, c, a)
if c<a<b:print(c, a, b)
if c<=b<=a:print(c, b, a)
Buggy python submission (verdict: Runtime Error):
#define MAXSIZE 1000
  
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
  
char init_str[MAXSIZE]={};
  
  
int main()
{
    char str[MAXSIZE];
    int sum;
  
    while(1){
        strcpy(str,init_str);
        scanf("%s",&str);
        if((int)(str[0]-'0')!=0){
            sum=0;
            for(int i=0;(i<MAXSIZE&&(str[i]!='\0'));i++){
                sum += (int)(str[i]-'0');
            }
            cout << sum << endl;
        }
        else break;
    }
    return 0;
}


Fixed submission:
while True :
  a = input()
  if(a == "0") :
    break
  else :
    b = list(map(int, a))  #1文字ずつ数値化して配列にする
    print(sum(b))

Buggy python submission (verdict: Runtime Error):
#define MAXSIZE 1000
  
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
  
char init_str[MAXSIZE]={};
  
  
int main()
{
    char str[MAXSIZE];
    int sum;
  
    while(1){
        strcpy(str,init_str);
        scanf("%s",&str);
        if((int)(str[0]-'0')!=0){
            sum=0;
            for(int i=0;(i<MAXSIZE&&(str[i]!='\0'));i++){
                sum += (int)(str[i]-'0');
            }
            cout << sum << endl;
        }
        else break;
    }
    return 0;
}


Fixed submission:
while True :
  a = input()
  if(a == "0") :
    break
  else :
    b = list(map(int, a))  #1文字ずつ数値化して配列にする
    print(sum(b))
Buggy python submission (verdict: Runtime Error):
list = map(int,raw_input().split())
W = list[0] 
H = list[1] 
x = list[2]
y = list[3]
r = list[4]

if x-r < 0:
    print "No"
elif x + r > W:
    print "No"
elif y-r < 0:
    print "No"
elif y+r > H:
    print "No"
else:
    print "Yes"


Fixed submission:
W,H,x,y,r = map(int, input().split())
if x-r < 0 or x+r > W or y-r < 0 or y+r > H:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
list = map(int,raw_input().split())

if x-r < 0:
    print "No"
elif x + r > W:
    print "No"
elif y-r < 0:
    print "No"
elif y+r > H:
    print "No"
else:
    print "Yes"


Fixed submission:
W,H,x,y,r = map(int, input().split())
if x-r < 0 or x+r > W or y-r < 0 or y+r > H:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
W, H, x, y, = map(int,input().split())


if x-r :
    print("No")
elif x + r :
    print ("No")
elif y-r :
    print ("No")
elif y+r :
    print ("No")
else:
    print ("Yes")


Fixed submission:
W,H,x,y,r = map(int, input().split())
if x-r < 0 or x+r > W or y-r < 0 or y+r > H:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
W, H, x, y,r = map(int,input().split())


if x-r :
    print("No")
elif x + r :
    print ("No")
elif y-r :
    print ("No")
elif y+r :
    print ("No")
else:
    print ("Yes"


Fixed submission:
W,H,x,y,r = map(int, input().split())
if x-r < 0 or x+r > W or y-r < 0 or y+r > H:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
from math import pi
r = float(input())
area = r * r * pi
cir =(r+r) * pi
print(f'{(area):.6f}{(cir):.6f}')



Fixed submission:
from math import pi
r = float(input())
area = r * r * pi
cir =(r+r) * pi
print(f'{(area):.6f} {(cir):.6f}')

Buggy python submission (verdict: Runtime Error):
from math import pi
r = float(input())
area = r * r * pi
cir =(r+r) * pi
print(f'{(area):.6 f}{(cir):.6 f}')



Fixed submission:
from math import pi
r = float(input())
area = r * r * pi
cir =(r+r) * pi
print(f'{(area):.6f} {(cir):.6f}')
Buggy python submission (verdict: Runtime Error):
n = int(input())
cards ={}
for i in rang(n):
  card = input()
  cards[card] =1
 
for c in ['S','H','C','D']:
  for c in range(1,13):
    card = c + ' ' + str(n)
    if not card in cards:
      print(card)


Fixed submission:
n = int(input())
cards = {}
for i in range(n):
    card = input()
    cards[card] = 1
      
#print(cards)
  
for c in ['S', 'H', 'C', 'D']:
    for n in range(1, 14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)

Buggy python submission (verdict: Runtime Error):
47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13


Fixed submission:
n = int(input())
cards = {}
for i in range(n):
    card = input()
    cards[card] = 1
      
#print(cards)
  
for c in ['S', 'H', 'C', 'D']:
    for n in range(1, 14):
        key = c + ' ' + str(n)
        if not key in cards:
            print(key)
Buggy python submission (verdict: Runtime Error):
cond = [int(n) for n in input().split(" ")]

while True:
    case = []
    cards = [n for n in range(1,cond[0] + 1)]
    for c in range(cond[1]):
        case = ([int(n) for n in input().split(" ")]
        disp = cards[case[0]:case[0]+case[1]]
        cards[case[0]:case[0]+case[1]] = cards[case[0]-case[1]:case[0]]
        cards[case[0]-case[1]:case[0]] = disp
    else:
        print(cards[0])
        cond = [int(n) for n in input().split(" ")]
        if cond[0] == 0 and cond[1] == 0:
            break
        else:
            continue

Fixed submission:
cards,trial = (int(n) for n in input().split(" "))
while True:
    cards = list(reversed([int(n) for n in range(1,(cards)+1)]))
    for n in range(trial):
        num,change = (int(n) for n in input().split(" "))
        num -= 1
        disp = cards[num:num+change]
        cards[change:change+num] = cards[:num]
        cards[:change] = disp
    print(cards[0])
    cards,trial = (int(n) for n in input().split(" "))
    if cards == 0 and trial == 0:
        break

Buggy python submission (verdict: Runtime Error):
cond = [int(n) for n in input().split(" ")]

while True:
    case = []
    cards = [n for n in range(1,cond[0] + 1)]
    for c in range(cond[1]):
        case = [int(n) for n in input().split(" ")]
        disp = cards[case[0]:case[0]+case[1]]
        cards[case[0]:case[0]+case[1]] = cards[case[0]-case[1]:case[0]]
        cards[case[0]-case[1]:case[0]] = disp
    else:
        print(cards[0])
        cond = [int(n) for n in input().split(" ")]
        if cond[0] == 0 and cond[1] == 0:
            break
        else:
            continue

Fixed submission:
cards,trial = (int(n) for n in input().split(" "))
while True:
    cards = list(reversed([int(n) for n in range(1,(cards)+1)]))
    for n in range(trial):
        num,change = (int(n) for n in input().split(" "))
        num -= 1
        disp = cards[num:num+change]
        cards[change:change+num] = cards[:num]
        cards[:change] = disp
    print(cards[0])
    cards,trial = (int(n) for n in input().split(" "))
    if cards == 0 and trial == 0:
        break
Buggy python submission (verdict: Runtime Error):
def getter(targ,x,y):
    #print(x,y,len(targ[0]),len(targ))
    if 0 > x or x >= len(targ) or 0 > y or y >= len(targ[0]) or targ[x][y] == '#':
        return 0
    else:
        targ[x][y] = '#'
        return 1 + getter(targ,x+1,y) + getter(targ,x-1,y) + getter(targ,x,y+1) + getter(targ,x,y-1)
with open("input1.txt") as f:
    width,height = [int(n) for n in f.readline().split(" ")]
    global lab
    while True:
        lab,start = [],[]
        for a in range(height):
            disp = [n for n in f.readline().rstrip('\n')]
            if '@' in disp:
                start.extend([disp.index('@'),a])
            lab.append(disp)
        else:
            a,b = start
            print(getter(lab,b,a))
            width,height = [int(n) for n in f.readline().split(" ")]
            if width == 0 and height == 0:
                break

Fixed submission:
def getter(targ,x,y):
    #print(x,y,len(targ[0]),len(targ))
    if 0 > x or x >= len(targ) or 0 > y or y >= len(targ[0]) or targ[x][y] == '#':
        return 0
    else:
        targ[x][y] = '#'
        return 1 + getter(targ,x+1,y) + getter(targ,x-1,y) + getter(targ,x,y+1) + getter(targ,x,y-1)
width,height = [int(n) for n in input().split(" ")]
global lab
while True:
    lab,start = [],[]
    for a in range(height):
        disp = [n for n in input().rstrip('\n')]
        if '@' in disp:
            start.extend([disp.index('@'),a])
        lab.append(disp)
    else:
        a,b = start
        print(getter(lab,b,a))
        width,height = [int(n) for n in input().split(" ")]
        if width == 0 and height == 0:
            break
Buggy python submission (verdict: Runtime Error):
roadcnt,money = (int(n) for n in input().split(" "))
while True:
    road = []
    for r in range(roadcnt):
        road.append([int(n) for n in input().split(" ")])
    road = sorted(road,key=lambda x:x[1])
    while money > 0:
        if road[-1][0] - money < 0:
            money -= road[-1][0]
            road.pop()
        else:
            road[-1][0] -= money
            break
    ans = 0
    for ro in road:
        ans += ro[0] * ro[1]
    print(ans)
    roadcnt,money = (int(n) for n in input().split(" "))
    if roadcnt == 0 and money == 0:
        break

Fixed submission:
roadcnt,money = (int(n) for n in input().split(" "))
while True:
    road = []
    for r in range(roadcnt):
        road.append([int(n) for n in input().split(" ")])
    road = sorted(road,key=lambda x:x[1])
    while money > 0 and len(road) > 0:
        if road[-1][0] - money < 0:
            money -= road[-1][0]
            road.pop()
        else:
            road[-1][0] -= money
            break
    ans = 0
    for ro in road:
        ans += ro[0] * ro[1]
    print(ans)
    roadcnt,money = (int(n) for n in input().split(" "))
    if roadcnt == 0 and money == 0:
        break
Buggy python submission (verdict: Runtime Error):
trial = int(input())
for t in range(trial):
    housecnt,elec = (int(n) for n in input().split(" "))
    house = [int(n) for n in input().split(" ")]
    maxlist = []
    for h in range(housecnt-1):
        maxlist.append(house[h+1]-house[h])
    for p in range(elec-1):
        maxlist.pop()
    print(sum(maxlist))

Fixed submission:
trial = int(input())
for t in range(trial):
    housecnt,elec = (int(n) for n in input().split(" "))
    house = [int(n) for n in input().split(" ")]
    maxlist = []
    for h in range(housecnt-1):
        maxlist.append(house[h+1]-house[h])
    maxlist.sort()
    for p in range(min(housecnt-1,elec-1)):
        maxlist.pop()
    print(sum(maxlist))

Buggy python submission (verdict: Runtime Error):
trial = int(input())
for t in range(trial):
    housecnt,elec = (int(n) for n in input().split(" "))
    house = [int(n) for n in input().split(" ")]
    maxlist = []
    for h in range(housecnt-1):
        maxlist.append(house[h+1]-house[h])
    maxlist.sort()
    for p in range(min(housecnt,elec-1)):
        maxlist.pop()
    print(sum(maxlist))

Fixed submission:
trial = int(input())
for t in range(trial):
    housecnt,elec = (int(n) for n in input().split(" "))
    house = [int(n) for n in input().split(" ")]
    maxlist = []
    for h in range(housecnt-1):
        maxlist.append(house[h+1]-house[h])
    maxlist.sort()
    for p in range(min(housecnt-1,elec-1)):
        maxlist.pop()
    print(sum(maxlist))
Buggy python submission (verdict: Runtime Error):
v_num = int(input())
adjacent = [[0 for n in range(v_num)] for m in range(v_num)]
for _ in range(v_num):
    inp = (int(n) for n in input().split(" "))
    for i in inp[2:]:
        adjacent[inp[0] - 1][i - 1] = 1
for i in range(v_num):
    print(*adjacent[i])

Fixed submission:
v_num = int(input())
adjacent = [[0 for n in range(v_num)] for m in range(v_num)]
for _ in range(v_num):
    inp = [int(n) for n in input().split(" ")]
    for i in inp[2:]:
        adjacent[inp[0] - 1][i - 1] = 1
for i in range(v_num):
    print(*adjacent[i])
Buggy python submission (verdict: Runtime Error):
import heapq
from collections import defaultdict
v_num = int(input())
edges = defaultdict(list)
for i in range(v_num):
    data = [int(n) for n in input().split(" ")[1:]]
    for j in range(i + 1, v_num):
        if data[j] != -1:
            edges[i].append([data[j], j])
            edges[j].append([data[j], i])
queue = []
heapq.heapify(queue)
for c in edges[0]:
    heapq.heappush(queue, c)
visited = {0}
answer = 0
while len(visited) < v_num:
    q = heapq.pop(queue)
    weight, one = q[0], q[1]
    if one in visited:
        continue
    answer += weight
    for e in edges[one]:
        heapq.heappush(queue, e)
    visited |= {one}
print(answer)

Fixed submission:
import heapq
from collections import defaultdict
v_num = int(input())
edges = defaultdict(list)
for i in range(v_num):
    data = [int(n) for n in input().split(" ")[1:]]
    for j in range(i + 1, v_num):
        if data[j] != -1:
            edges[i].append([data[j], j])
            edges[j].append([data[j], i])
queue = []
heapq.heapify(queue)
for c in edges[0]:
    heapq.heappush(queue, c)
visited = {0}
answer = 0
while len(visited) < v_num:
    q = heapq.heappop(queue)
    weight, one = q[0], q[1]
    if one in visited:
        continue
    answer += weight
    for e in edges[one]:
        if e[1] not in visited:
            heapq.heappush(queue, e)
    visited |= {one}
print(answer)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
import heapq
v_num = int(input())
connect = defaultdict(list)

for _ in range(v_num):
    que = [int(n) for n in input().split(" ")]
    connect[que[0]] = [[v, w] for v, w in zip(que[2:len(que):2], que[3:len(que):2])
    # weight_edge[que[0]] = {k:v for k, v in zip(que[2:len(que):2], que[3:len(que):2])}
queue = []
heapq.heapify(queue)
heapq.heappush(queue, [0, 0])
distance = [-1 for n in range(v_num)]
went = 0
visited = set()
while went < v_num:
    q = heapq.heappop(queue)
    weight, here = q
    if here in visited:
        continue
    visited |= {here}
    went += 1
    distance[here] = weight
    for conn in connect[here]:
        if conn[0] not in visited:
            heapq.heappush(queue, [weight + conn[1], conn[0]])
for i in range(v_num):
    print(i, distance[i])

Fixed submission:
from collections import defaultdict
import heapq
v_num = int(input())
connect = defaultdict(list)

for _ in range(v_num):
    que = [int(n) for n in input().split(" ")]
    connect[que[0]] = [[v, w] for v, w in zip(que[2:len(que):2], que[3:len(que):2])]
    # weight_edge[que[0]] = {k:v for k, v in zip(que[2:len(que):2], que[3:len(que):2])}
queue = []
heapq.heapify(queue)
heapq.heappush(queue, [0, 0])
distance = [-1 for n in range(v_num)]
went = 0
visited = set()
while went < v_num:
    q = heapq.heappop(queue)
    weight, here = q
    if here in visited:
        continue
    visited |= {here}
    went += 1
    distance[here] = weight
    for conn in connect[here]:
        if conn[0] not in visited:
            heapq.heappush(queue, [weight + conn[1], conn[0]])
for i in range(v_num):
    print(i, distance[i])
Buggy python submission (verdict: Runtime Error):
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)''

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