class PriorityQueue(object):
    
    '''Implementation of a Priority Queue using a Heap.'''
    
    def __init__(self):
        '''Create an empty heap.'''
        self.heap = []
        
       
    def insert(self, x):
        '''Add x to the heap.'''
        self.heap.append(x)
        i = len(self.heap) - 1
        # Fill in code here.
        
            
    def min(self):
        '''Return the smallest element in the heap.'''
        return self.heap[0]

    
    def extract_min(self):
        '''Return and remove the smallest element in the heap.'''
        ret = self.heap[0]
        # Move last node to the root.
        self.heap[0] = self.heap[-1]
        self.heap.pop()
        # Fix the heap.
        return ret
        
    def size(self):
        '''Return the size of the heap.'''
        return len(self.heap)


