<?php
$acumulador = 0;
while(true) {
    $quantidade_de_conjuntos = (int) trim(fgets(STDIN));
    if($quantidade_de_conjuntos == 0) {
        break;
    }
    $contador = 0;
    while($quantidade_de_conjuntos > $contador) {
        if($quantidade_de_conjuntos == 0) {
        break;
        }
        fscanf(STDIN, "%d %d", $CiComprimento, $ViQuantidade);
        
        $acumulador = $acumulador + intdiv($ViQuantidade, 2);
        $retangulos = intdiv($acumulador,  2);
        $contador++;
    }
    $acumulador = 0;  
    echo $retangulos."\n";
}
?>

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: