import java.util.*;
import java.io.*;
import java.lang.*;


public class five11 { 
    /*==========================================================================*/
    
    private byte[] buf;								/*1*/
    
    private int offset;								/*2*/

    
    private class cons {							/*3*/
	public int car;								/*4*/
	public cons cdr;							/*5*/
	public cons(int hd, cons tl){						/*6*/
	    car = hd;								/*7*/
	    cdr = tl;								/*8*/
	}
    }
    private class cons2 {							/*9*/
	public cons car;							/*10*/
	public cons2 cdr;							/*11*/
	public cons2(cons hd, cons2 tl){					/*12*/
	    car = hd;								/*13*/
	    cdr = tl;								/*14*/
	}
    }
    public five11(String filename) throws IOException {				/*15*/
	FileInputStream fis = new FileInputStream(filename);			/*16*/
	int bytesize;								/*17*/
	buf = new byte[150000];							/*18*/
	bytesize = fis.read(buf, 0, 150000);					/*19*/
	offset = 0;								/*20*/
    }

    private int read_x_bits(int x) {						/*21*/
	int byte_offset, bit_offset,present,initbits,res;			/*22*/
	byte_offset = offset >> 3;						/*23*/
	bit_offset = offset & 7;						/*24*/
	initbits = 8-bit_offset;						/*25*/
	present = ((int)buf[byte_offset] & 255);				/*26*/
	res = present & ((1 << initbits) - 1);					/*27*/
	while (x > initbits) {							/*28*/
	    byte_offset++;							/*29*/
	    present = ((int)buf[byte_offset] & 255);				/*30*/
	    res = (res << 8) | present;						/*31*/
	    initbits+=8;							/*32*/
	}
	return res >>> (initbits-x);						/*33*/
    }
    
    private int read_11_bits(int offset) {					/*34*/
	int byte_offset, ioffset,present,initbits,res;				/*35*/
	int b0,b1,b2;								/*36*/
	byte_offset = offset >> 3;						/*37*/
	ioffset = (8-(offset & 7));						/*38*/
	b0 = ((int)buf[byte_offset] & 255);					/*39*/
	b1 = ((int)buf[byte_offset+1] & 255); 					/*40*/
	res = b0 << (11-ioffset);						/*41*/
	if (ioffset >= 3) {							/*42*/
	    return  (res | (b1 >> (ioffset-3)))  &  ((1 << 11) - 1);		/*43*/
	}						
	else {
	    b2 = ((int)buf[byte_offset+2] & 255);				/*44*/
	    return (res | (b1 << (3-ioffset)) | b2 >> (ioffset+5)) &  		/*45*/
		((1 << 11) - 1);						/*46*/
	}
    }

    private int pad_size(int nof_channels) {					/*47*/
	int bits = 5+nof_channels*11;						/*48*/
	return ((8 - (bits & 7)) & 7);						/*49*/
    }
    
    private cons decode() {							/*50*/
	int nof_channels;							/*51*/
	cons res = null;							/*52*/
	nof_channels=read_x_bits(5);						/*53*/
	offset+=5;								/*54*/
	for(int i=0;i<nof_channels;i++){					/*55*/
	    res = new cons(read_11_bits(offset),res);				/*56*/
	    offset+=11;								/*57*/
	}
	offset+=pad_size(nof_channels);						/*58*/
	return res;								/*59*/
    }
    
    private cons2 run_all() {							/*60*/
	cons2 res = null;							/*61*/
	int nof_packets = read_x_bits(16);					/*62*/
	offset += 16;								/*63*/
	for(int i=0;i<nof_packets;i++){						/*64*/
	    res = new cons2(decode(),res);					/*65*/
	}
	return res;								/*66*/
    }

    private static int sum_all(cons2 list_of_lists) {				/*67*/
	int sum = 0;								/*68*/
	while (list_of_lists != null) {						/*69*/
	    sum+=five11.sum_cons(list_of_lists.car); 				/*70*/
	    list_of_lists=list_of_lists.cdr;					/*71*/
	}
	return sum;								/*72*/
    }
    
    private static int sum_cons(cons list) {					/*73*/
	int sum = 0;								/*74*/
	while (list != null) {							/*75*/
	    sum+=list.car; 							/*76*/
	    list=list.cdr;							/*77*/
	}
	return sum;								/*78*/
    }
    /*==========================================================================*/
    
    private void write_file(String filename, int sum) throws IOException {
	FileOutputStream fos = new FileOutputStream(filename+".java");
	ObjectOutputStream oos = new ObjectOutputStream(fos);
	oos.writeInt(sum);
    }

    public void reset() {							
	offset = 0;
    }

    public static void main(String[] args) throws IOException{
	five11 bin;
	cons2 res;
	int sum=0;
	long time;
	bin = new five11(args[0]);
	long start = System.currentTimeMillis();
	for(int i=0; i<10000; i+=1){
	    res = bin.run_all();
	    bin.reset();
	    sum=five11.sum_all(res);
	}
	long end = System.currentTimeMillis();
	bin.write_file(args[0],sum);
	time = end-start;
	System.out.print("" + (float)time/1000.0);
    }

}

