main = getContents >>= print . sum . map ((\[c,d] -> div (c+1) 2 * d) . map read . words) . tail . init . lines