#!/usr/bin/perl use strict; use warnings; my $n = <>; my $total = 0; for(my $i = 0; $i < $n; $i++) { my ($c, $d) = split / /, <>; my $num = int((($c +1) / 2)) * $d; $total += $num; } $total = $total % (10**9 + 7); print "$total\n"; exit;