<?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];
        $vetor[$tamanho] = $x;
        $tamanho++;
    }

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

            if ($indice_real >= 0 && $indice_real < $tamanho) {
                echo $vetor[$indice_real] . "\n";
            }
        }
    }
}
?>

Embed on website

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