<?php
$v = [];

while (($linha = fgets(STDIN)) !== false) {
    $linha = trim($linha);
    if ($linha == "") continue;
    
    $partes = explode(" ", $linha);
    $op = intval($partes[0]);
    
    if ($op == 0) {
        break;
    } elseif ($op == 1) {
        $x = intval($partes[1]);
        $n = count($v);
        $pos = 0;
        
        while ($pos < $n && $v[$pos] < $x) {
            $pos++;
        }
        
        for ($i = $n; $i > $pos; $i--) {
            $v[$i] = $v[$i - 1];
        }
        
        $v[$pos] = $x;
        
    } elseif ($op == 3) {
        $n = count($v);
        for ($i = 0; $i < $n; $i++) {
            if ($i > 0) {
                echo " ";
            }
            echo $v[$i];
        }
        echo PHP_EOL;
    }
}
?>

Embed on website

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