import java.io.*;

class TripSegment
{
  public int miles;
  public double gallons;
  TripSegment(int Miles, double Gallons)
  {
     miles = Miles;
     gallons = Gallons;
  }
}

class Trip
{
  TripSegment[] TripSegments;
  int NumSegments;

  Trip() 
  {
     NumSegments = 0;
     TripSegments = new TripSegment[2000];
  }

  public void AddSegment(int Miles, double Gallons)
  {
     TripSegments[NumSegments++] = new TripSegment(Miles,Gallons);
  }

  public int TotalMiles()
  {
     int i, tot=0;
     for (i=0; i< NumSegments; i++)
        tot += TripSegments[i].miles;
     return tot;
  }

  public double TotalGallons()
  {
     int i; 
     double tot=0;
     for (i=0; i< NumSegments; i++)
        tot += TripSegments[i].gallons;
     return tot;
  }

  public double MPG()
  {
     return TotalMiles()/TotalGallons();
  }
}

class mileage
{
  public static void main(String[] Args)
  throws IOException 
  {
     int miles=0;
     double gallons=0;
     Trip MyTrip = new Trip();
     if (Args.length < 1)
        return;
     BufferedReader infile = 
        new BufferedReader( 
        new InputStreamReader(
        new FileInputStream(Args[0])));
     while (infile.ready())
     {
        miles = Integer.valueOf(infile.readLine()).intValue();
        gallons = Double.valueOf(infile.readLine()).doubleValue();
        MyTrip.AddSegment(miles,gallons);
     }
     System.out.println("Total miles: " + MyTrip.TotalMiles());
     System.out.println("Total gallons: " + MyTrip.TotalGallons());
     System.out.println("Average MPG: " + MyTrip.MPG());
  }
}


