Title: Sum and Average

Please create a program that reads unit price and quantity sold, and outputs the total sales amount and the average quantity sold.

Input:
The input is given in the following format:
Unit price, quantity sold
Unit price, quantity sold
...

Multiple lines of comma-separated unit prices and quantities sold are provided. All input values are between 0 and 1,000, and the number of unit price and quantity sold pairs does not exceed 100.

Output:
Output the total sales amount (an integer) on the first line and the average quantity sold (an integer) on the second line. If there are decimal points in the average quantity sold, please round to the nearest tenth.

Sample Input:
100,20
50,10
70,35

Output for the Sample Input:
4950
22

# Buggy version:
import sys
f = sys.stdin

sum_price = sum_amount = kind = 0
for line in f:
    price, amount = map(int, line.split(','))
    sum_price += price * amount
    sum_amount += amount
    kind += 1
    
print(sum_price, round(sum_amount / kind))

# Fixed version:
import sys
f = sys.stdin


sum_price = sum_amount = kind = 0
for line in f:
    price, amount = map(int, line.split(','))
    sum_price += price * amount
    sum_amount += amount
    kind += 1
    
print(sum_price)
print(int(sum_amount / kind + 0.5))

# Buggy version:
A = []
B = []
while True:
    try:
        x,y = map(int,input().split(','))
        A.append(x)
        B.append(y)
    except EOFError:
        break

N = len(A)
print(sum(A [i] * B [i] for i in range(N)),sum(B) * 2 // N - sum(B) // N)

# Fixed version:
A = []
B = []
while True:
    try:
        x,y = map(int,input().split(','))
        A.append(x)
        B.append(y)
    except EOFError:
        break

N = len(A)
print(sum(A [i] * B [i] for i in range(N)))
print(sum(B) * 2 // N - sum(B) // N)

# Buggy version:
Sum, Ave, Cou = 0, 0, 0
while True :
    try :
        a, b = input().split(',')
        Sum += int(a) * int(b)
        Ave += int(b)
        Cou += 1
    except : break
if Ave / Cou - Ave // Cou > 0.5 : print(Sum, Ave // Cou+1)
else : print(Sum,Ave//Cou)

# Fixed version:
Sum, Ave, Cou = 0, 0, 0
while True :
    try :
        a, b = input().split(',')
        Sum += int(a) * int(b)
        Ave += int(b)
        Cou += 1
    except : break
print(Sum)
if Ave / Cou - Ave // Cou >= 0.5 : print(Ave // Cou+1)
else : print(Ave//Cou)

# Buggy version:
import sys
s=[list(map(int,e.split(',')))for e in sys.stdin]
print(sum(a*n for a,n in s),int([sum(x)for x in zip(*s)][1]/len(s)+.5))


# Fixed version:
import sys
s=[list(map(int,e.split(',')))for e in sys.stdin]
print(sum(a*n for a,n in s))
print(int([sum(x)for x in zip(*s)][1]/len(s)+.5))

# Buggy version:
from decimal import Decimal, ROUND_HALF_UP
c = p = 0
while 1:
    try:
        n, v = map(int, input().split(","))
        c += n
        p += n * v
    except:break
print(p)
print(Decimal(p / c).quantize(Decimal('0'), rounding=ROUND_HALF_UP))


# Fixed version:
from decimal import Decimal, ROUND_HALF_UP
c = p = i = 0
while 1:
    try:
        v, n = map(int, input().split(","))
        i += 1
        c += n
        p += n * v
    except:break
print(p)
print(Decimal(c / i).quantize(Decimal('0'), rounding=ROUND_HALF_UP))