Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N,M = map(int,input().split())
list_A = list(map(lambda x: int(x)*(-1),input().split()))	

#print(list_A)

for i in range(M):
  heapq.heapify(list_A)
  target = heapq.heappop(list_A)
  #print("after heappop",list_A)
  
  '''負の要素の切り捨て除算は切り捨てがマイナスの方に
  行くため少しだけややこしい。'''
  heapq.heappush(list_A, (-1)*((-target) // 2))  # 要素の挿入
  #print("No.",i,"change finished",list_A)

print(-sum(list_A))




Fixed submission:
import heapq
N,M = map(int,input().split())
list_A = list(map(lambda x: int(x)*(-1),input().split()))	

#print(list_A)
heapq.heapify(list_A)
for i in range(M):
  
  target = heapq.heappop(list_A)
  #print("after heappop",list_A)
  
  '''負の要素の切り捨て除算は切り捨てがマイナスの方に
  行くため少しだけややこしい。'''
  heapq.heappush(list_A, (-1)*((-target) // 2))  # 要素の挿入
  #print("No.",i,"change finished",list_A)

print(-sum(list_A))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N,M = map(int,input().split())
list_A = list(map(lambda x: int(x)*(-1),input().split()))	

#print(list_A)

for i in range(M):
  heapq.heapify(list_A)
  target = heapq.heappop(list_A)
  #print("after heappop",list_A)
  
  '''負の要素の切り捨て除算は切り捨てがマイナスの方に
  行くため少しだけややこしい。'''
  target = -1*((-1 *target) // 2)
  
  heapq.heappush(list_A, target)  # 要素の挿入
  #print("No.",i,"change finished",list_A)

print(sum(list_A)*-1)




Fixed submission:
import heapq
N,M = map(int,input().split())
list_A = list(map(lambda x: int(x)*(-1),input().split()))	

#print(list_A)
heapq.heapify(list_A)
for i in range(M):
  
  target = heapq.heappop(list_A)
  #print("after heappop",list_A)
  
  '''負の要素の切り捨て除算は切り捨てがマイナスの方に
  行くため少しだけややこしい。'''
  heapq.heappush(list_A, (-1)*((-target) // 2))  # 要素の挿入
  #print("No.",i,"change finished",list_A)

print(-sum(list_A))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N,M = map(int,input().split())
list_A = list(map(int,input().split()))	

list_A = list(map(lambda x: x*(-1), list_A))

#print(list_A)

for i in range(M):
  heapq.heapify(list_A)
  target = heapq.heappop(list_A)
  #print("after heappop",list_A)
  
  '''負の要素の切り捨て除算は切り捨てがマイナスの方に
  行くため少しだけややこしい。'''
  target = -1*((-1 *target) // 2)
  
  heapq.heappush(list_A, target)  # 要素の挿入
  #print("No.",i,"change finished",list_A)

print(sum(list_A)*-1)




Fixed submission:
import heapq
N,M = map(int,input().split())
list_A = list(map(lambda x: int(x)*(-1),input().split()))	

#print(list_A)
heapq.heapify(list_A)
for i in range(M):
  
  target = heapq.heappop(list_A)
  #print("after heappop",list_A)
  
  '''負の要素の切り捨て除算は切り捨てがマイナスの方に
  行くため少しだけややこしい。'''
  heapq.heappush(list_A, (-1)*((-target) // 2))  # 要素の挿入
  #print("No.",i,"change finished",list_A)

print(-sum(list_A))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
N = int(input())
S = str(input())
K = int(input())
#rint(N,S,K)

WRITE = list(S)
CHARA = S[K]
#print(CHARA)

for i in range(N):
    if S[i] != CHARA:
        S = S[:i] + '*' + S[i+1:]

print(S)

Fixed submission:
# coding: utf-8
# Your# coding: utf-8
# Your code here!
N = int(input())
S = str(input())
K = int(input())
#rint(N,S,K)
 
WRITE = list(S)
CHARA = S[K-1]
#print(CHARA)
 
for i in range(N):
    if S[i] != CHARA:
        S = S[:i] + '*' + S[i+1:]
 
print(S)
Buggy python submission (verdict: Runtime Error):
import bisect
N = int(input())
top = list(map(int,input().split()))
middle = list(map(int,input().split()))	
bottom = list(map(int,input().split()))	

top.sort()
middle.sort()
bottom.sort()

ans = 0
for i in middle:
  can_put_upstair = bisect.bisect_left(top,i)
  can_put_donwstair = N - bisect.bisect_right(bottom,i)
  ans += can_put_upstair*can_put_downstair

print(ans)
  

Fixed submission:
import bisect
N = int(input())
top = list(map(int,input().split()))
middle = list(map(int,input().split()))	
bottom = list(map(int,input().split()))	

top.sort()
middle.sort()
bottom.sort()

ans = 0
for i in middle:
  can_put_upstair = bisect.bisect_left(top,i)
  can_put_downstair = N - bisect.bisect_right(bottom,i)
  #print(can_put_upstair,can_put_downstair)
  ans += can_put_upstair*can_put_downstair

print(ans)
Buggy python submission (verdict: Runtime Error):
import copy
N,K = map(int,input().split())
A_list = list(map(int,input().split()))	
###########
can_see = [0]
max_building = A_list[0]
for i in range(0,N-1):
  
  if max_building < A_list[i+1]:
    can_see.append(i+1)
    max_building = A_list[i+1]

#print("can_see",can_see)
need_to_build = K-len(can_see)
#print("NTB",need_to_build)

#1つ目のタワーは足すことがないので抜かしてビット全探索。
#need_to_buildと同じフラグが立ったものだけ、Ｂｕｉｌｄして値段を検索
min_money = 100000000000000000
samebuilding_flag = False
for i in range(2**(N-1)):
  #print("roop start")
  bit_box = [0] * (N-1)
  for j in range(N-1):
    if (i>>j)&1:
      bit_box[N-1-1-j] = 1
      if N-1-j in can_see:
        #print("flag apeeard")
        samebuilding_flag = True
        
  #print(bit_box)
  if bit_box.count(1) != need_to_build:
    #print("not match")
    #print(bit_box)
    pass
    
  elif samebuilding_flag == True:
    samebuilding_flag = False
    pass
  
  else:
    #試すものがここに残る。
    #print("try parameters")
    #print(bit_box)
    building_list = copy.deepcopy(A_list)
    use_money = 0
    
    bit_box_start = bit_box.index(1)
   #print("BBS",bit_box_start)
    for _ in range(0,len(can_see))[::-1]:
      if can_see[_] < bit_box_start+1:
        highest_building = building_list[can_see[_]]
        break
    
    
    
    for k in range(0,N-1):
      if bit_box[k] == 1:
        #print("build start building No.",k+2)
        
        if highest_building >= building_list[k+1]:
          #print("make higher")
          use_money += (highest_building-building_list[k+1]+1)
          #print("use_money",use_money)
          #print(f"change {building_list[k+1]} to {highest_building+1} ")
          building_list[k+1] = highest_building+1
          highest_building = building_list[k+1]
          #print("building now",building_list)
        else:
          #print("stay")
          #print("building now",building_list)
          pass
          
    #print("use_money",use_money)
    min_money = min(min_money,use_money)
    #print("result",min_money)
    del building_list
    
print(min_money)

      
      
    

Fixed submission:
def LI(): return list(map(int,input().split()))
N,K = LI()
a = LI()
ans = float('INF')
for i in range(2**(N-1)):
    bit = [i>>j&1 for j in range(N-1)]
    if K-1!=sum(bit):
        continue
    #print("bit",bit)
    cost,kijun = 0,a[0]
    for k in range(N-1):
        if bit[k]==0:
            kijun = max(kijun,a[k+1])
            continue
        if a[k+1]>=kijun+1:
            kijun = a[k+1]
            continue
        cost += (kijun+1)-a[k+1]
        kijun += 1
    ans = min(ans,cost)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = [int(input()) for i in range(n)]
ans = -10000000000

for j in range(n-1, 0, -1):
    for i in range(j-1,-1, -1):
        ans = max(ans, (nums[j] - nums[i]))
print(ans)

Fixed submission:
N = int(input())
R0 = int(input())
R1 = int(input())
max_profit = R1 - R0
min_R = min(R0, R1)

for i in range(N-2):
    R = int(input())
    max_profit = max(max_profit, R - min_R)
    min_R = min(min_R, R)

print(max_profit)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = [int(input()) for i in range(n)]
ans = -10000000000

for j in range(n-1, 0, -1):
    for i in range(j-1,-1, -1):
        ans = max(ans, (nums[j] - nums[i]))
print(ans)

Fixed submission:
N = int(input())
R0 = int(input())
R1 = int(input())
max_profit = R1 - R0
min_R = min(R0, R1)

for i in range(N-2):
    R = int(input())
    max_profit = max(max_profit, R - min_R)
    min_R = min(min_R, R)

print(max_profit)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nums = [int(input()) for i in range(n)]
ans = -10000000000

for i in range(1, n):
    temp_max = nums[i:n+1]
    temp_min = nums[0:i]
    ans = max(ans, max(temp_max) - min(temp_min))
print(ans)	

Fixed submission:
N = int(input())
R0 = int(input())
R1 = int(input())
max_profit = R1 - R0
min_R = min(R0, R1)

for i in range(N-2):
    R = int(input())
    max_profit = max(max_profit, R - min_R)
    min_R = min(min_R, R)

print(max_profit)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li1 = list(map(int,input().split()))
m = int(input())
li2 = list(map(int,input().split()))
cnt = 0

for i in li2:
	if i in li1:
		cnt +=1
print(cnt)

Fixed submission:
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

sum = 0

for i in T:
    if i in S:
        sum +=1
        
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li1 = list(map(int,input().split()))
m = int(input())
li2 = list(map(int,input().split()))
cnt = 0
 
for i in li2:
    if i in li1:
        cnt +=1
print(cnt)

Fixed submission:
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

sum = 0

for i in T:
    if i in S:
        sum +=1
        
print(sum)
Buggy python submission (verdict: Runtime Error):
import sys

NIL = -1

def set_depth(v, depth):
    tree[v][2] = depth
    
    if child in tree[v][1]:
        set_depth(child, depth + 1)

N = int(input())
tree = [[NIL, [], 0, 'leaf'] for _ in range(N)]

for _ in range(N):
    line = [int(i) for i in sys.stdin.readline().split()]
    t_id = line[0]
    children = line[2:]
    tree[t_id][1] = children
    
    if children:
        tree[t_id][3] = 'internal node'
    
    for child in children:
        tree[child][0] = t_id
        
for t_id in range(N):
    if tree[t_id][0] == NIL:
        tree[t_id][3] = 'root'
        r = t_id
        break

set_depth(r, 0)

for t_id in range(N):
    parent = tree[t_id][0]
    depth = tree[t_id][2]
    children = tree[t_id][1]
    type_t = tree[t_id][3]
    
    print('node {}: parent = {}, depth = {}, {}, {}'.format(t_id, parent, depth, type_t, children))

Fixed submission:
import sys

NIL = -1

def set_depth(v, depth):
    tree[v][2] = depth
    
    for child in tree[v][1]:
        set_depth(child, depth + 1)

N = int(input())
tree = [[NIL, [], 0, 'leaf'] for _ in range(N)]

for _ in range(N):
    line = [int(i) for i in sys.stdin.readline().split()]
    t_id = line[0]
    children = line[2:]
    tree[t_id][1] = children
    
    if children:
        tree[t_id][3] = 'internal node'
    
    for child in children:
        tree[child][0] = t_id
        
for t_id in range(N):
    if tree[t_id][0] == NIL:
        tree[t_id][3] = 'root'
        r = t_id
        break

set_depth(r, 0)

for t_id in range(N):
    parent = tree[t_id][0]
    depth = tree[t_id][2]
    children = tree[t_id][1]
    type_t = tree[t_id][3]
    
    print('node {}: parent = {}, depth = {}, {}, {}'.format(t_id, parent, depth, type_t, children))
Buggy python submission (verdict: Runtime Error):
import math

while True:
	cnt = int(input())
	li = list(map(int, input().split()))
	
	if cnt == 0:
		break
	
	ave = sum(li) / cnt
	n_var = 0.0
	for i in range(cnt):
		n_var += ( li[i] - ave )**2
		
	var = n_var / cnt
	#print(n_var)
	print('{0:.8f}'.format(math.sqrt(var)))

Fixed submission:
import math

while True:
	cnt = int(input())
	if cnt == 0:
		break
	
	li = list(map(int, input().split()))

	ave = sum(li) / cnt
	n_var = 0.0
	
	for i in range(cnt):
		n_var += ( li[i] - ave )**2
	
	var = n_var / cnt
	
	print('{0:.8f}'.format(math.sqrt(var)))
Buggy python submission (verdict: Runtime Error):
input()
print(*sorted(input().split()))

Fixed submission:
print(*sorted(input().split()))
Buggy python submission (verdict: Runtime Error):
cnt = 1
while True:
	a = input()
	if a == '0':
		break
	cnt += 1
        print('Case {0}:{1}'.format(cnt, a))

Fixed submission:
cnt = 0
while True:
	a = input()
	if a == '0':
		break
	cnt += 1
	print('Case {0}: {1}'.format(cnt,a))
Buggy python submission (verdict: Runtime Error):
import math
r = int(input())
print("{0:.6f} {1:.6f}".format(math.pi * r ** 2, 2* math.pi * r))

Fixed submission:
import math
r = float(input())
print("{0:.6f} {1:.6f}".format(math.pi * r ** 2, 2* math.pi * r))
Buggy python submission (verdict: Runtime Error):
cnt = int(input())
a,b,c,d,e = map(int, input().split())
li = [a,b,c,d,e]
print(min(li), max(li), sum(li))

Fixed submission:
cnt = int(input())
li = list(map(int, input().split()))
print(min(li), max(li), sum(li))

Buggy python submission (verdict: Runtime Error):
cnt = int(input())
a,b,c,d,e = map(int, input().split())
li = [a,b,c,d,e]
print(min(li), max(li), sum(li))

Fixed submission:
cnt = int(input())
li = list(map(int, input().split()))
print(min(li), max(li), sum(li))
Buggy python submission (verdict: Runtime Error):
a = []; b = []; c = []
n, m = map(int, input().split())

for i in range(n):
	row = map(int, input().split())
	a.append(list(row))

for j in range(m):
	col = int(input())
	b.append(col)

for k in range(n):
	temp = 0
	for l in range(m):
		temp += a[k][l] * b[l] 
	c.append(temp)

print(c[0])
print(c[1])
print(c[2])

Fixed submission:
n, m = map(int, input().split())

a = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for j in range(m)]

for a_row in a:
	print(sum(a_row[k] * b[k] for k in range(m)))
Buggy python submission (verdict: Time Limit Exceeded):
C = 10**9 + 7
m, n = map(int, input().split())
print(pow(m, n)%C)

Fixed submission:
def new_pow(x, n):
    C = 10**9+7
    
    if n == 0:
        return 1
    
    if n:
        return new_pow(x*x%C, n//2) * (x if n % 2 else 1) % C
    
m, n = map(int,input().split())
print(new_pow(m,n))
Buggy python submission (verdict: Time Limit Exceeded):
def fibonacci(n):
    if n == 0 or n == 1:
        return 1
    else:
        return fibonacci(n-1) + fibonacci(n-2)

if __name__ == '__main__':
    n = int(input())
    print(fibonacci(n))

Fixed submission:
def fibonacci(n):
    a, b = 1, 1
    for i in range(n-1):
        a, b = b, a+b

    return b

if __name__ == '__main__':
    n = int(input())
    print(fibonacci(n))
Buggy python submission (verdict: Runtime Error):
def is_prime(x):
    if x == 2:
        return True

    if (x == 1) or (x % 2 == 0):
        return False

    for i in range(3, sqrt(x), 2):
        if x % i == 0:
            return False

    return True
    
if __name__ == '__main__':
    element_number = int(input())
    input_array = [int(input()) for i in range(element_number)]

    output = 0
    for x in input_array:
        if(is_prime(x)):
            output += 1

    print(output)

Fixed submission:
import sys
import math

def is_prime(x):
    if x == 2:
        return True

    if (x == 1) or (x % 2 == 0):
        return False

    for i in range(3, math.ceil(math.sqrt(x))+1, 2):
        if x % i == 0:
            return False

    return True
    
if __name__ == '__main__':
    element_number = int(input())

    output = 0
    for x in map(int, sys.stdin.readlines()):
        if(is_prime(x)):
            output += 1

    print(output)

Buggy python submission (verdict: Runtime Error):
import math

def is_prime(x):
    if x == 2:
        return True

    if (x == 1) or (x % 2 == 0):
        return False

    for i in range(3, math.ceil(math.sqrt(x))+1, 2):
        if x % i == 0:
            return False

    return True
    
if __name__ == '__main__':
    element_number = int(input())

    output = 0
    for x in map(int, sys.stdin.readlines()):
        if(is_prime(x)):
            output += 1

    print(output)

Fixed submission:
import sys
import math

def is_prime(x):
    if x == 2:
        return True

    if (x == 1) or (x % 2 == 0):
        return False

    for i in range(3, math.ceil(math.sqrt(x))+1, 2):
        if x % i == 0:
            return False

    return True
    
if __name__ == '__main__':
    element_number = int(input())

    output = 0
    for x in map(int, sys.stdin.readlines()):
        if(is_prime(x)):
            output += 1

    print(output)
Buggy python submission (verdict: Runtime Error):
import sys

def get_maximum_profit:
    element_number = int(input())
    v0 = int(input())
    v1 = int(input())

    min_v = v0
    max_profit = v1-v0

    for i in map(int, sys.stdin.readlines()):
        min_v = min(min_v, i)
        max_profit = max(max_profit, i-min_v)

if __name__ == '__main__':
    get_maximum_profit()

Fixed submission:
import sys

def get_maximum_profit():
    element_number = int(input())
    v0 = int(input())
    v1 = int(input())

    min_v = min(v0, v1)
    max_profit = v1-v0

    for v in map(int, sys.stdin.readlines()):
        max_profit = max(max_profit, v-min_v)
        min_v = min(min_v, v)

    print(max_profit)

if __name__ == '__main__':
    get_maximum_profit()
Buggy python submission (verdict: Runtime Error):
from collections import deque

def doubly_lined_list(n, A):
	Q = deque()

	for i in range(n):
		if A[i][0] == 'insert':
			Q.appendleft(A[i][1])
		elif A[i][0] == 'delete':
			Q.remove(A[i][1])
		elif A[i][0] == 'deleteFirst':
			Q.popleft()
		elif A[i][0] == 'deleteLast':
			Q.pop()

	print(' '.join(Q))

if __name__ == '__main__':
	n = int(input())
	A = []

	for i in range(n):
		A.append(input().split())

	doubly_lined_list(n, A)

Fixed submission:
import sys
from collections import deque

def doubly_lined_list():
	n = int(input())
	Q = deque()

	for i in range(n):
		line = sys.stdin.readline()
		command = line.split()[0]

		if command == 'insert':
			Q.appendleft(line.split()[1])
		elif command == 'delete':
			try:
				Q.remove(line.split()[1])
			except:
				pass
		elif command == 'deleteFirst':
			Q.popleft()
		elif command == 'deleteLast':
			Q.pop()

	print(' '.join(Q))

if __name__ == '__main__':
	doubly_lined_list()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def doubly_lined_list(n, A):
	Q = deque()

	for i in range(n):
		if A[i][0] == 'insert':
			Q.appendleft(A[i][1])
		elif A[i][0] == 'delete':
			try:
				Q.remove(A[i][1])
			except:
				pass
		elif A[i][0] == 'deleteFirst':
			Q.popleft()
		elif A[i][0] == 'deleteLast':
			Q.pop()

	print(' '.join(Q))

if __name__ == '__main__':
	n = int(input())
	A = []

	for i in range(n):
		A.append(input().split())

	doubly_lined_list(n, A)

Fixed submission:
import sys
from collections import deque

def doubly_lined_list():
	n = int(input())
	Q = deque()

	for i in range(n):
		line = sys.stdin.readline()
		command = line.split()[0]

		if command == 'insert':
			Q.appendleft(line.split()[1])
		elif command == 'delete':
			try:
				Q.remove(line.split()[1])
			except:
				pass
		elif command == 'deleteFirst':
			Q.popleft()
		elif command == 'deleteLast':
			Q.pop()

	print(' '.join(Q))

if __name__ == '__main__':
	doubly_lined_list()
Buggy python submission (verdict: Runtime Error):
def binary_search():
	input()
	s = set(input().split())
	input()
	t = set(input().split())
	print(len(s & t))	

if __name__ == '__main__':
	linear_search()

Fixed submission:
def binary_search():
	input()
	s = set(input().split())
	input()
	t = set(input().split())
	print(len(s & t))	

if __name__ == '__main__':
	binary_search()
Buggy python submission (verdict: Runtime Error):
n = int(input())
fib = [1, 1]
for i in range(n):
    fib[i] = fib[i-1] + fib[i-2]
print(fib[n])

Fixed submission:
n = int(input())
fib = [1, 1] + [0] * n
for i in range(2, n+1):
    fib[i] = fib[i-1] + fib[i-2]
print(fib[n])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while((j <= 0) and A(j) > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(A)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while((j >= 0) and A[j] > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while((j >= 0) and A(j) > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(A)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
    v = A[i]
    j = i - 1
    while((j >= 0) and A[j] > v):
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(math.gcd(a, b))

Fixed submission:
x, y = map(int, input().split())
while y > 0 :
    x, y = y, x % y
print(x)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a, b != 0:
    print(math.gcd(a, b))

Fixed submission:
x, y = map(int, input().split())
while y > 0 :
    x, y = y, x % y
print(x)

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

Fixed submission:
x, y = map(int, input().split())
while y > 0 :
    x, y = y, x % y
print(x)

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

Fixed submission:
x, y = map(int, input().split())
while y > 0 :
    x, y = y, x % y
print(x)

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
while x > 0 :
    x, y = y, x % y
print(x)

Fixed submission:
x, y = map(int, input().split())
while y > 0 :
    x, y = y, x % y
print(x)
Buggy python submission (verdict: Runtime Error):
N = innt(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)

Fixed submission:
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)
Buggy python submission (verdict: Runtime Error):
N = int(input())
C = input().split()
_C = C.copy()

for i in range(N):
    for j in range(N-1, i, -1):
        if (C[j][1] < C[j-1][1]):
            C[j][1], C[j-1][1] = C[j-1][1], C[j][1]
print(*C)
print("Stable")

for j in range(N):
    m = i
    for j in range(i, N):
        if (_C[j][1] < _C[j-1][1]):
            m = j
    _C[i][1], _C[m][1] = _C[m][1], _C[i][1]
print(*_C)
if(C ==_C):
    print("Stable")
else:
    print("Not stable")

Fixed submission:
N = int(input())
C = list(input().split())
_C = C.copy()

for i in range(N):
    for j in range(N-1, i, -1):
        if (C[j][1] < C[j-1][1]):
            C[j], C[j-1] = C[j-1], C[j]
print(*C)
print("Stable")

for i in range(N):
    m = i
    for j in range(i, N):
        if (_C[j][1] < _C[m][1]):
            m = j
    _C[i], _C[m] = _C[m], _C[i]
print(*_C)
if(C ==_C):
    print("Stable")
else:
    print("Not stable")
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = map(int, input().split())
q = int(input())
T = map(int, input().split())
print(len(S & T)

Fixed submission:
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = set(map(int, input().split()))
print(len(S & T))

Buggy python submission (verdict: Runtime Error):
n = int(input())
S = map(int, input().split())
q = int(input())
T = map(int, input().split())
print(len(S & T))

Fixed submission:
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = set(map(int, input().split()))
print(len(S & T))

Buggy python submission (verdict: Runtime Error):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
print(len(S & T))

Fixed submission:
n = int(input())
S = set(map(int, input().split()))
q = int(input())
T = set(map(int, input().split()))
print(len(S & T))
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

print(len(S&T))

Fixed submission:
n = int(input())
S = set(input().split())
q = int(input())
T = set(input().split())

print(len(S&T))

Buggy python submission (verdict: Runtime Error):
n = int(input())
S = set(int, input().split())
q = int(input())
T = set(int, input().split())

print(len(S&T))

Fixed submission:
n = int(input())
S = set(input().split())
q = int(input())
T = set(input().split())

print(len(S&T))