#ACSL Junior Division Problem 1: Time Sheets
#By Shreyan Jaiswal
#Stone Hill Middle School
#Python 2.7.2
def GetTime(s): #Function that gets the time based on the input (input is a STRING)
if s=="1": x=9
if s=="2": x=9.5
if s=="3": x=10
if s=="4": x=10.5
if s=="5": x=11
if s=="6": x=11.5
if s=="7": x=12
if s=="8": x=12.5
if s=="9": x=13
if s=="A": x=13.5
if s=="B": x=14
if s=="C": x=14.5
if s=="D": x=15
if s=="E": x=15.5
if s=="F": x=16
if s=="G": x=16.6
if s=="H": x=17
return x #returns the time in 24-hour decimal form (3:30 PM becomes 15.5)
def FindHours(x,y): return GetTime(y) - GetTime(x) #Gets the time worked between start and end time
a=[] #list for the first four outputs (daily pay)
for i in range(1,5): #loop to get inputs and convert them to daily pay
x = raw_input(str(i)+". ").replace(' ','').split(",") #asks for input then takes out the spaces. Then it turns it into a list of the three values/
t=int(x[0]) #Turns the first value, turns it into an integer, assigns it to variable 't'
y = FindHours(x[1],x[2]) #Gets the amount of time workedm assigns it to variable 'y'
if 0<t<10: u=10*y #Location 1-9 Get $10/hour
elif 10<=t<20:#Location 10-19
if y<=4: u=8*y #Get $8/hour
else: u=32+(y-4)*12#and $12/hour for hours worked over four.
elif 20<=t<30: #Location 20-29
if y<=4: u=12*y #get $12/hour
else: u=48+(y-4)*24 #and $24/hour for hours worked over four.
a+=[u] #add daily pay to list 'a'
for i,x in enumerate(a): #for each item in list a
print str(i+1) + ". $" + "%0.2f" % x #prints output in decimal form
print "5. $" + "%0.2f" % sum(a) #prints the sum of the outputs 1-4.