python counter
10
2 3 4 5 6 8 7 6 5 18
6
6 55
6 45
6 55
4 40
18 60
10 50# Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import Counter
X = int(raw_input().strip())
shoeSizeList = map(int,raw_input().strip().split(' '))
Cntr = Counter(shoeSizeList)
N = int(raw_input().strip())
#print 'list: ', shoeSizeList, type(shoeSizeList)
earnings = 0
for a0 in xrange(N):
shoeSize,price = map(int, raw_input().strip().split(' '))
if shoeSize in Cntr and Cntr[shoeSize] > 0:
earnings += price
Cntr[shoeSize] -= 1
#print 'earnings: ', earnings
print earningsLast updated