#!/usr/bin/perl
while ($line = <STDIN>) {
if(not $line) {
exit;
}
($col1,$col2) = split(/\s/, $line);
$count1 = 0;
$count2 = 1;
$old_col1 = $col1;
$old_col2 = $col2;
while($line = <STDIN>) {
($col1,$col2) = split(/\s/, $line);
if ($col1 ne $old_col1 || $col2 ne $old_col2 ) {
print " small total $count2 $old_col1 $old_col2\n";
$count1 += $count2;
$count2 = 1;
$old_col2 = $col2;
if ($col1 ne $old_col1) {
print " big total $count1 $old_col1\n";
$count1 = 0;
$old_col1 = $col1;
}
} else {
$count2++;
}
}
}
print " small total $count2 $old_col1 $old_col2\n";
$count1 += $count2;
print " big total $count1 $old_col1\n";
#!/usr/bin/perl
@c = split //, shift ;
@state_table = (
[ -2, 1, 2, -2],
[ -2, -2, 2, -2],
[ -2, -2, 2, -1]
);
@char_num{('+', '-', '0'..'9', '')} = ((1)x2, (2)x10, 3);
$s = 0;
while ($s >= 0) {
$s = $state_table[$s][$char_num{shift @c} || 0];
}
exit($s == -2);