<?php
$vetor = [];
$tamanho = 0;

while (true) {
    $linha = trim(fgets(STDIN));
    
    if ($linha === "0" || $linha === "" || $linha === false) {
        break;
    }

    $comando = explode(" ", $linha);
    $op = $comando[0];

    if ($op == "1") {
        $x = $comando[1];
        $k = (int)$comando[2];
        $indice_real = $k - 1;

        if ($indice_real >= 0 && $indice_real <= $tamanho) {
            for ($i = $tamanho; $i > $indice_real; $i--) {
                $vetor[$i] = $vetor[$i - 1];
            }
            
            $vetor[$indice_real] = $x;
            $tamanho++;
        }
    }

    if ($op == "3") {
        for ($i = 0; $i < $tamanho; $i++) {
            echo $vetor[$i];
            if ($i < $tamanho - 1) {
                echo " ";
            }
        }
        echo "\n";
    }
}
?>

Embed on website

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