:- prompt(_, '').
:- use_module(library(readutil)).
main:-
process,
/* Leitura da entrada */
ler_chars(S) :-
ler_resto(C,S).
ler_resto(end_of_file, []).
ler_resto(C, [C|R]) :-
ler_resto(C2, R).
ler_lista(L) --> ['('], pares(L), [')'].
pares([]) --> [].
pares([Par|R]) --> par(Par), pares(R).
par([Linha,Pontos]) --> ['('], numero(CLinha), [' ', '.', ' '], numero(CPontos), [')'],
numero([]) --> [].
numero([C|R]) --> [C], { is_digit(C) }, numero(R).
/* Exemplo de relação maior/2 */
maior(A,B) :- A > B.
/***** Código *****/
lista_maiores(L, Valor, Maiores) :-
findall(Linha
, (member
([Linha
,Pontos
], L
), maior
(Pontos
, Valor
)), Maiores
).
/***** Fim código *****/
process:-
ler_chars(Chars),
ler_lista(L, Chars, []),
lista_maiores(L, 2, Maiores),
:- main.
Oi0gc2V0X3Byb2xvZ19mbGFnKHZlcmJvc2Usc2lsZW50KS4KOi0gcHJvbXB0KF8sICcnKS4KOi0gdXNlX21vZHVsZShsaWJyYXJ5KHJlYWR1dGlsKSkuCgptYWluOi0KCXByb2Nlc3MsCgloYWx0LgoJCi8qIExlaXR1cmEgZGEgZW50cmFkYSAqLwoJCmxlcl9jaGFycyhTKSA6LQogICAgZ2V0X2NoYXIoQyksCiAgICBsZXJfcmVzdG8oQyxTKS4KCmxlcl9yZXN0byhlbmRfb2ZfZmlsZSwgW10pLgpsZXJfcmVzdG8oQywgW0N8Ul0pIDotCiAgICBnZXRfY2hhcihDMiksCiAgICBsZXJfcmVzdG8oQzIsIFIpLgoKbGVyX2xpc3RhKEwpIC0tPiBbJygnXSwgcGFyZXMoTCksIFsnKSddLgoJCnBhcmVzKFtdKSAtLT4gW10uCnBhcmVzKFtQYXJ8Ul0pIC0tPiBwYXIoUGFyKSwgcGFyZXMoUikuCgpwYXIoW0xpbmhhLFBvbnRvc10pIC0tPiBbJygnXSwgbnVtZXJvKENMaW5oYSksIFsnICcsICcuJywgJyAnXSwgbnVtZXJvKENQb250b3MpL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