Repository: Universidade-Livre/rinha-de-algoritmos
Branch: main
Commit: f9a8dcbd4be9
Files: 131
Total size: 157.7 KB
Directory structure:
gitextract_f3v2cmdo/
├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── how_to_participate.md
├── resources/
│ └── instances/
│ ├── problem_01/
│ │ ├── exemplo_01.txt
│ │ ├── exemplo_02.txt
│ │ ├── exemplo_03.txt
│ │ └── resultados.txt
│ ├── problem_02/
│ │ ├── exemplo_01.txt
│ │ ├── exemplo_02.txt
│ │ ├── exemplo_03.txt
│ │ └── resultados.txt
│ └── problem_03/
│ └── results.txt
└── submissions/
├── .gitkeep
├── danielsalles/
│ ├── README.md
│ └── problema-1.cpp
├── devmessias_01_numba_AOT/
│ ├── Makefile
│ ├── README.md
│ ├── aot/
│ │ ├── knapsack.py
│ │ └── setup.py
│ ├── exemplo_01.txt
│ ├── exemplo_02.txt
│ ├── exemplo_03.txt
│ ├── problem_01.py
│ └── requirements.txt
├── diogosm/
│ ├── Dockerfile
│ ├── README.md
│ ├── exemplo_01.txt
│ ├── exemplo_02.txt
│ ├── exemplo_03.txt
│ ├── problema-1.py
│ ├── resultados.txt
│ └── run.sh
├── gabrielng-rj99/
│ ├── Problema_1/
│ │ ├── Python/
│ │ │ ├── Dockerfile
│ │ │ ├── ReadMe.md
│ │ │ ├── examples/
│ │ │ │ ├── exemplo_01.txt
│ │ │ │ ├── exemplo_02.txt
│ │ │ │ └── exemplo_03.txt
│ │ │ ├── handmade_tests/
│ │ │ │ ├── handmade_tests.txt
│ │ │ │ ├── longruntest.txt
│ │ │ │ ├── longruntest2.txt
│ │ │ │ ├── longruntest3.txt
│ │ │ │ ├── longruntest4.txt
│ │ │ │ ├── longruntest5.txt
│ │ │ │ ├── test01_03.txt
│ │ │ │ ├── test02_03.txt
│ │ │ │ ├── test03.1_03.txt
│ │ │ │ ├── test03_03.txt
│ │ │ │ ├── test04_03.txt
│ │ │ │ └── test05_03.txt
│ │ │ ├── problema-1.py
│ │ │ ├── run_commands.sh
│ │ │ ├── runtime.sh
│ │ │ └── test_hyperfine.sh
│ │ └── Rust/
│ │ ├── Cargo.toml
│ │ ├── Dockerfile
│ │ ├── ReadMe.md
│ │ ├── examples/
│ │ │ ├── exemplo_01.txt
│ │ │ ├── exemplo_02.txt
│ │ │ └── exemplo_03.txt
│ │ ├── handmade_tests/
│ │ │ ├── handmade_tests.txt
│ │ │ ├── longruntest.txt
│ │ │ ├── longruntest2.txt
│ │ │ ├── longruntest3.txt
│ │ │ ├── longruntest4.txt
│ │ │ ├── longruntest5.txt
│ │ │ ├── test01_03.txt
│ │ │ ├── test02_03.txt
│ │ │ ├── test03.1_03.txt
│ │ │ ├── test03_03.txt
│ │ │ ├── test04_03.txt
│ │ │ └── test05_03.txt
│ │ ├── run_commands.sh
│ │ └── src/
│ │ └── main.rs
│ └── Problema_2/
│ └── Python/
│ ├── Dockerfile
│ ├── ReadMe.md
│ ├── examples/
│ │ ├── exemplo_01.txt
│ │ ├── exemplo_02.txt
│ │ └── exemplo_03.txt
│ ├── problema-2.py
│ ├── run_commands.sh
│ └── runtime.sh
├── gbpagano/
│ ├── Cargo.toml
│ ├── README.md
│ ├── exemplo.txt
│ └── src/
│ └── main.rs
├── gutogalego/
│ ├── Cargo.toml
│ ├── README.md
│ └── src/
│ └── main.rs
├── gutogalego__2/
│ ├── Cargo.toml
│ ├── README.md
│ └── src/
│ └── main.rs
├── gutogalego__3/
│ ├── Cargo.toml
│ ├── README.md
│ └── src/
│ └── main.rs
├── jaiaani/
│ └── problema_01/
│ ├── .gitignore
│ ├── Dockerfile
│ ├── LICENSE
│ ├── README.md
│ ├── project.clj
│ ├── resources/
│ │ └── input/
│ │ ├── example1.txt
│ │ ├── example2.txt
│ │ ├── example3.txt
│ │ └── results.txt
│ ├── src/
│ │ └── plantation_profit/
│ │ ├── core.clj
│ │ └── english_core.clj
│ └── test/
│ └── plantation_profit/
│ └── core_test.clj
├── jojodev/
│ ├── README.md
│ └── problema-1.py
├── juanplopes/
│ ├── .gitignore
│ ├── README.md
│ └── problema-1.cpp
├── marcosvile/
│ ├── Dockerfile
│ ├── Readme.md
│ └── problema-1.sh
├── olegon/
│ ├── .gitignore
│ ├── README.md
│ ├── compile-and-run.sh
│ └── main.cpp
├── ryrden/
│ ├── README.md
│ ├── go.mod
│ └── ryrden.go
├── wmsbill/
│ ├── .nvmrc
│ ├── README.md
│ └── problema_01.js
└── zeroskullx/
├── .nvmrc
├── .temp
├── README.md
├── problema-01.js
└── test.txt
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Código de Conduta
A UBL é um ambiente onde todos os que aprendem e contribuem podem se sentir seguros e acolhidos. Este documento define as políticas e valores da nossa comunidade.
# Regras
* Aprenda e ajude os outros a aprenderem.
* Seja gentil e educado com os seus colegas.
* Critique ideias, não pessoas.
* Discuta de forma pública. Evite mandar mensagens diretas para as pessoas, a menos que elas peçam.
* Faça perguntas; não pergunte se pode perguntar. Não precisa escrever "Tem alguém que pode me ajudar com X?" Simplesmente pergunte sobre X.
# Proibições
* Nenhuma violência ou ameaça de violência de qualquer tipo.
* Nenhuma linguagem ou ação sexista, racista, homofóbica, transfóbica, ou qualquer outra que seja preconceituosa ou discriminatória; isso inclui piadas.
* Nenhum assédio sexual, incluindo avanços sexuais indesejados ou comentários ofensivos sobre o sexo de alguém.
* Nenhum palavrão ou xingamento contra outras pessoas (mas pode usar palavrões e xingamentos sobre o código, IDE, linguagem, hardware ou física).
* Nenhum material impróprio para menores. Isso inclui nudez, gore, ou qualquer outra imagem que possa ser perturbadora.
* Nenhuma divulgação de informações privadas de outra pessoa sem a sua permissão (doxxing).
* Nenhum assédio ou intimidação, online ou fora da internet.
* Nenhum spam, trollagem, provocação, ou qualquer outra coisa que atrapalhe a paz.
* Nenhum nome de usuário inadequado. Os moderadores irão mudar o seu nome se ele for considerado impróprio para menores ou ofensivo.
* Nenhuma defesa ou ameaça de qualquer um dos comportamentos proibidos.
# Denúncia e Moderação
No servidor da UBL no Discord, os usuários podem usar @Moderação e @Admin para alertar a equipe de moderação sobre algum problema em um canal.
No GitHub você pode nos marcar diretamente em qualquer issue ou PR sobre uma violação.
Se você vir algum comportamento que viole o Código de Conduta, denuncie-o à equipe de moderação o mais rápido possível, seja de forma privada ou pública.
A violação dos termos deste Código de Conduta terá consequências que dependerão de a) a gravidade da violação, e b) o histórico de violações. As possíveis consequências são: silenciamento temporário, expulsão da participação, banimento temporário ou permanente de toda a participação futura na comunidade.
Se você se sentir injustiçado, você pode contatar um moderador ou organizador da comunidade e explicar o seu problema. O seu problema será resolvido por consenso dos moderadores.
# Atribuição
Partes deste Código de Conduta foram inspiradas pelos seguintes:
* [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct/)
* [Rust Lang Code of Conduct](https://www.contributor-covenant.org/version/2/0/code_of_conduct/)
* O Código de Conduta do OSSU, derivado do [Código de Conduta do Fórum FrontEnd BR](https://www.contributor-covenant.org/version/2/0/code_of_conduct/)
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2023 Universidade Brasileira Livre
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================

<p align="center">
<a href="https://discord.gg/eXUBTY6HAu">
<img src="https://img.shields.io/discord/866378348368625704.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2" alt="Discord">
</a>
<a href="https://github.com/Universidade-Livre/rinha-de-algoritmos/stargazers">
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/Universidade-Livre/rinha-de-algoritmos?logo=apache%20spark&logoColor=gray&labelColor=E6E600&color=D8D800">
</a>
</p>
<hr>
> Você está prestes a entrar na Rinha de Algoritmos, uma competição incrível que desafia você a mostrar o seu talento no mundo dos algoritmos e estruturas de dados. Nesta aventura, você vai enfrentar problemas reais que exigem soluções criativas e eficientes. Você vai se surpreender com casos curiosos, onde a sua habilidade em resolver desafios computacionais fará toda a diferença. Prepare-se para se divertir em um ambiente estimulante, onde o seu domínio algorítmico será testado. Venha para a Rinha de Algoritmos e embarque nessa jornada desafiadora!
## O que é?
A rinha de algoritmos é uma competição amistosa baseada em competições similares, como a [Rinha de Compiladores](https://github.com/aripiprazole/rinha-de-compiler), [Rinha de Frontend](https://github.com/codante-io/rinha-frontend), e [Rinha de Backend](https://github.com/zanfranceschi/rinha-de-backend-2023-q3). O projeto possui como objetivo avaliar a capacidade dos participantes no design de algoritmos e estruturas de dados para resolver problemas práticos.
Para avaliar os participantes, a descrição de algum caso prático será proposta. Caberá aos participantes identificar o problema e propor a melhor solução para resolvê-lo. Seguindo o mesmo modelo de maratonas de programação, serão fornecidas uma lista de entradas e de resultados esperados, em formato de texto, que poderão ser utilizados para guiar a criação do algoritmo. A pontuação e o ranking correspondente serão baseados em instâncias privadas que serão liberadas **apenas ao final** da competição.
Cada participante deverá entregar um algoritmo, sinalizando para qual problema aquele algoritmo foi criado, podendo utilizar apenas 2 unidades de CPU e 2GB de memória. Para mais detalhes sobre as submissões, veja [como submeter um algoritmo](how_to_participate.md).
Caso hajam dúvidas, por favor abram uma *issue* ou utilizem o nosso servidor do Discord!
## Regras
- Embora estaremos sempre incentivando a conversa e colaboração entre os participantes em prol do estabelecimento de um ambiente de aprendizado, não será permitido compartilhar as soluções nos canais de comunicação da UBL¹;
- Para essa competição é importante ressaltar que **não** é permitido o uso de *solvers*².
- Caso sejam utilizados algoritmos de Monte Carlo³, o valor de solução a ser considerado será o melhor dentre $40$ iterações do algoritmo, ou o valor mais próximo possível dessa quantidade de iterações, a depender do tempo necessário para uma solução ser computada.
---
> ¹: *Note que isso não proibe tirar dúvidas de outros participantes ou fornecer direções. Não esperamos que cada candidato submeta uma solução única, até mesmo porque uma implementação inteligente pode fazer a diferença entre ambas as submissões.*
>
> ²: *Um solver é um programa de computador que, quando aplicado a um problema, é capaz de encontrar a solução automaticamente, sem intervenção direta ou ajuste significativo por parte do usuário. Geralmente, o objetivo de um solver é encontrar a melhor solução ou uma solução aproximada para o problema, tornando-o um mecanismo automatizado de resolução. Na Rinha de Algoritmos, seu uso é proibido. A justificativa é incentivar a resolução manual e criativa dos problemas.*
>
> ³: *Aos participantes interessados em aprender mais sobre algoritmos probabilisticos, vejam os livros recomendados para a Rinha e a página na [Wikipedia](https://en.wikipedia.org/wiki/Randomized_algorithm).*
---
## Pontuação
Uma função $f: \mathbb{R}^2 \rightarrow \mathbb{R}$ determinará a pontuação dos participantes. Antes de descrevê-la, denotaremos por $\mathbf{x} = [x_1 \; x_2]^T$ o vetor de saída do algoritmo, onde $x_1$ é o tempo, em segundos, para obtenção da solução, e $x_2$ é o valor da **solução viável**¹ encontrada.
A pontuação é dada por $f(\mathbf{x}) = \min(100, \; C_{1} / x_{1}) + \min(100, \; C_{2} / |x^{\star} - x_{2}|)$, onde $x^{\star}$ é o valor da solução ótima. As constantes $C_1$ e $C_2$ serão definidas para cada problema, e servem para penalizar o tempo de execução e o quão distante a solução viável está do ótimo, respectivamente.
Vale ressaltar que quanto maior for o valor de $f(\mathbf{x})$, melhor será a pontuação.
---
> ¹: *Uma solução viável é toda solução que satisfazem as restrições do problema, embora talvez não seja a solução ótima.*
---
## Problemas
### Problema 01: Lucro de Plantação no Stardew Valley
**Descrição:** Na busca por otimizar seus ganhos enquanto joga Stardew Valley, você analisa as opções de sementes disponíveis em determinado momento e registra a quantidade de espaços disponíveis para o plantio.
Por ser um fazendeiro organizado, você já tem conhecimento sobre a quantia de moedas que pode obter ao plantar cada tipo de semente durante um período específico, bem como a quantidade de espaços necessários para cada uma delas. Seu objetivo é, portanto, maximizar seu lucro ao plantar o maior número possível de sementes, levando em consideração a capacidade de plantio disponível, ao final do período escolhido. Para fins de simplicidade, assumiremos que todas as sementes possuem o mesmo tempo de plantio e maturação.
Para este problema, definiremos $C_{1} = 1$, $C_{2} = 0.2$, e uma pontuação bônus por cada instância resolvida de $C_{3} = 50$.
Confira os detalhes em [como participar](how_to_participate.md#problema-01).
---
### Problema 02: Age of Empires - A Grande Fronteira
**Descrição:** Na vastidão estratégica do Age of Empires, o participante ousa enfrentar o desafio supremo denominado "A Grande Fronteira". Neste épico, os líderes imperiais, incluindo você, são convocados a traçar uma trama intrincada de postos avançados não apenas para expandir os domínios do império, mas para construir uma defesa intransponível contra os astutos adversários.
Esses postos avançados, transcendendo meras construções, tornam-se os pilares cruciais na busca pela supremacia. A singularidade deste desafio coloca você na posição de escolher sabiamente os locais estratégicos, onde os postos avançados devem dominar as extremidades da fronteira, enquanto mantêm uma rede complexa que conecta todas as propriedades do império. O objetivo é criar uma teia que, ao expandir territorialmente, posiciona os postos avançados como sentinelas estratégicas, maximizando a muralha defensiva.
A vitória não está apenas na quantidade de território conquistado, mas na maestria de suas escolhas, destacando-se em "A Grande Fronteira". Como líder imperial, ao assegurar a máxima presença defensiva e conectar todas as propriedades do vasto império, você gravará seu nome na história estratégica do Age of Empires. Que a sua sagacidade e estratégia iluminem o caminho para a supremacia!
Para este problema problema, definiremos $C_{1} = 100$, $C_{2} = 25$, e uma pontuação bônus para cada instância resolvida de $C_{3} = 70$.
---
### Problema 03: ???
**Descrição:** ???
## Resultados
Nesta seção disponibilizaremos os resultados das submissões. Para cada instância resolvida, uma pontuação bônus será aplicada.
Incluiremos uma submissão secreta de um membro da moderação da UBL para fins de benchmarking inicial. Esta submissão **não** será considerada para fins de premiação.
A pontuação será calculada a partir da média de $40$ iterações do algoritmo.
---
### Resultados do Problema 01:
| Posição | Participante | Segundos | Resolvidas | Linguagem
| ---------- | ---------- | ------- | ------- | ---------- |
| - | Secreto | ? | ?/20 | ? |
---
### Resultados do Problema 02:
| Posição | Participante | Pontuação | Resolvidas | Linguagem
| ---------- | ---------- | ------- | ------- | ---------- |
| - | Secreto | ? | ?/20 | ? |
---
### Resultados do Problema 03:
| Posição | Participante | Pontuação | Resolvidas | Linguagem
| ---------- | ---------- | ------- | ------- | ---------- |
| - | Secreto | ? | ?/20 | ? |
---
## Premiação
Forneceremos uma premiação simbólica para os três primeiros colocados. Esta premiação consiste em cargos comemorativos no [servidor da UBL](url).
## Leitura recomendada
Nesta seção incluiremos alguns livros recomendados que podem ajudar na elaboração de algoritmos para os problemas que serão trabalhados nesta Rinha. Quando gratuitos, incluiremos um link para acesso.
Não faremos a distinção entre um livro de nível básico ou avançado. Cabe ao participante conferir as primeiras páginas do livro e fazer esse juízo por si só.
### Referências
- Carvalho, Cerioli, Dahab, Feofiloff, Fernandes, Ferreira, Guimarães, Miyazawa, Pina Jr, Soares, Wakabayashi, Uma Introdução Sucinta a Algoritmos de Aproximação, IMPA, 2001. [Disponivel aqui](https://www.ime.usp.br/~cris/aprox/).
- Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to Algorithms (3rd ed.). London, England: MIT Press.
- J.L. Szwarcfiter e L. Markenzon, Estruturas de Dados e seus Algoritmos, 2a.ed., Livros Técnicos e Científicos, 1994.
- Kleinberg, J., & Tardos, E. (2006). Algorithm design. Pearson Education India.
- Mitzenmacher, M., & Upfal, E. (2017). Probability and computing (2nd ed.). Cambridge, England: Cambridge University Press.
- Motwani, R., & Raghavan, P. (1995). Randomized algorithms. Cambridge University Press.
- P. Feofiloff, Y. Kohayakawa, & Y. Wakabayashi. (2011). Uma Introdução Sucinta à Teoria dos Grafos. [Disponível aqui](https://www.ime.usp.br/~pf/teoriadosgrafos/).
- P. Feofiloff. Análise de Algoritmos. [Disponível aqui](https://www.ime.usp.br/~pf/analise_de_algoritmos/).
- P. Feofiloff. (2019). Minicurso de Análise de Algoritmos. [Disponível aqui](https://www.ime.usp.br/~pf/livrinho-AA/).
- Vazirani, V. V. (2002). Approximation algorithms. Springer Science & Business Media.
================================================
FILE: how_to_participate.md
================================================
# Como participar
Nesta seção descreveremos os procedimentos para participação e submissão na Rinha de Algoritmos.
## Como submeter
Começar a Rinha de Algoritmos é mamão com açúcar, é só:
1. No seu Terminal, clone esse repositório com o comando `git clone git@github.com:Universidade-Livre/rinha-de-algoritmos`.
2. Crie uma ramificação (branch) no repositório clonado para a resolução do seu exercício com o comando `git checkout -b problema-1`.
3. Na pasta [submissions](./submissions/) crie uma pasta com o seu nome de usuário. Ex: `mateusrovedaa/`
4. Resolva o problema com base nas instruções informadas na seção [Instâncias](#instâncias) e salve o código em um arquivo com o nome `problema-1.ext`, onde `ext` é a extensão da linguagem de programação. Além disso, crie um arquivo `README.md` colocando instruções e detalhes da implementação que achar necessário. Preferencialmente, faça com que o seu código receba o arquivo das instâncias como argumentos no CLI.
5. Ainda, para facilitar a avaliação por parte da organização, crie um ambiente Docker limitando os recursos para duas unidades de CPU e 2GB de RAM, conforme as restrições mencionadas no [README](README.md).
6. Adicione as alterações feitas para serem enviadas com o comando `git add .`
7. Faça o commit enviando essas alterações `git commit -m "Submissão do problema 01"`.
8. Abra um PR para a ramificação main.
## Instâncias
Para cada problema fornecemos 3 instâncias relativamente pequenas para realizar os experimentos iniciais. As instâncias referentes ao problema $1 \leq i \leq 3$ encontram-se em `resources/instancias/exemplo_0i`. Ainda, todas as pastas contêm um arquivo `resultados.txt` com as soluções ótimas das instâncias dadas, separadas por espaço.
Nas seções abaixo, descreveremos a estrutura dos arquivos de texto que compõem as instâncias e formalizaremos os objetivos e restrições.
## Estrutura dos Problemas
### Problema 01
**Entrada:**
Seja $n$ a quantidade de sementes, $v_{i}$ e $w_{i}$ o valor e a quantidade de espaços necesários para a semente $i$, e $W$ a quantidade de espaços disponíveis. O problema possui os seguintes limitantes. As instâncias estão organizadas da seguinte maneira.
- A primeira linha consiste de dois valores, a quantidade de sementes distintas e a quantidade de espaços disponíveis, respectivamente.
- As $n$ linhas seguintes, onde $n$ é a quantidade de tipos sementes, consistem de dois valores por linha, divididas por espaço. O primeiro é o espaço necessário $w_{i}$ para plantar a semente $i$, já o segundo corresponde ao ganho em moedas $v_{i}$ no final do periodo ao plantar esta semente.
Para todos os tipos de semente, você possui apenas **UMA** unidade!
**Limites:**
- $1 \leq n \leq 1000$
- $30 \leq v_{i} \leq 200$
- $1 \leq w_{i} \leq 7$
- $1 \leq W \leq 2666$
**Objetivo:**
- Obtenha o lucro máximo possível.
**Exemplo**
Suponhamos que você receba as informações abaixo, e que possui apenas 2 blocos disponíveis pra plantio.
| **Semente** | **Valor** | **Espaço** |
|-------------|-----------|------------|
| Café | 150 | 1 |
| Arroz | 260 | 2 |
| Cenoura | 100 | 1 |
Podemos ver facilmente que a solução ótima é dada pelo plantio de arroz apenas. Perceba que o plantio de duas unidades de café, totalizando um lucro de 300, não é possível pela nossa suposição de haver apenas uma única unidade de cada tipo de semente.
---
### Problema 02
**Entrada:**
- A primeira linha contém dois inteiros: o número de postos avançados $N$ ($2 \leq N \leq 120$) e o número de estradas $M$ ($1 \leq M \leq \frac{N \times (N-1)}{2}$).
- As próximas $M$ linhas contêm dois inteiros cada: $u$ e $v$ ($1 \leq u, v \leq N$), indicando uma estrada conectando os postos avançados $u$ e $v$.
**Saída:**
- A saída deve conter um único inteiro $K$: o número total de postos avançados que definem a muralha
**Objetivo:**
- Maximizar o tamanho da muralha, definida como quantidade de pontos avançados nas extremidades do território, enquanto conecta todas as propriedades do império.
**Exemplo de Entrada 01:**
```plaintext
8 7
1 2
2 3
3 4
4 5
5 6
6 7
7 8
```
A entrada acima pode ser exibida como um grafo, conforme a figura abaixo.

**Exemplo de Saída 01:**
```plaintext
2
```
Neste exemplo, temos que basta utilizarmos todas as estradas disponíveis para traçar todos os postos avançados. Como as sentinelas sempre estarão nas fronteiras, a muralha de tamanho máximo possui tamanho $2$.
Consideremos outro exemplo deste mesmo problema. Desta vez, suponha que há uma estrada entre os postos $5$ e $1$.
**Exemplo de Entrada 02:**
```plaintext
8 8
1 2
2 3
3 4
4 5
5 6
5 1
6 7
7 8
```
A entrada acima pode ser exibida como um grafo, conforme a figura abaixo.

**Exemplo de Saída 02:**
```plaintext
3
```
Neste caso, podemos compor nossa muralha de modo que esta possua tamanho no máximo $3$, conforme podemos observar na figura abaixo.

---
### Problema 03
================================================
FILE: resources/instances/problem_01/exemplo_01.txt
================================================
22 36
3 86
1 80
3 71
2 39
2 53
3 47
2 46
1 32
1 69
2 89
4 58
3 86
3 54
3 53
1 64
4 82
1 46
2 48
4 53
1 68
3 94
1 87
================================================
FILE: resources/instances/problem_01/exemplo_02.txt
================================================
9 10
3 44
1 78
2 64
1 49
4 69
1 87
3 78
2 45
3 84
================================================
FILE: resources/instances/problem_01/exemplo_03.txt
================================================
25 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
================================================
FILE: resources/instances/problem_01/resultados.txt
================================================
exemplo_01.txt 1194
exemplo_02.txt 407
exemplo_03.txt 1566
================================================
FILE: resources/instances/problem_02/exemplo_01.txt
================================================
40 47
1 2
1 24
2 12
3 18
3 22
4 11
4 29
4 32
5 6
5 27
6 12
6 22
7 15
7 17
8 13
8 15
8 36
9 17
9 21
10 18
10 30
10 32
11 40
12 31
13 22
13 31
14 25
14 32
16 19
16 23
16 24
17 20
18 33
19 38
20 23
21 38
23 35
25 39
26 27
28 33
28 35
29 34
29 37
30 34
33 36
36 40
37 39
================================================
FILE: resources/instances/problem_02/exemplo_02.txt
================================================
30 35
1 3
1 16
2 9
2 23
3 8
3 23
4 18
4 22
4 30
5 6
5 11
6 9
6 19
7 16
7 18
7 20
8 26
8 27
9 18
9 21
10 13
10 30
12 15
12 22
13 17
14 24
14 28
15 17
19 27
20 21
21 29
22 24
24 26
25 28
25 29
================================================
FILE: resources/instances/problem_02/exemplo_03.txt
================================================
30 218
1 3
1 8
1 9
1 11
1 12
1 13
1 14
1 16
1 18
1 20
1 22
1 24
1 26
1 27
1 28
2 8
2 9
2 11
2 12
2 14
2 15
2 19
2 22
2 26
2 29
3 7
3 9
3 10
3 11
3 12
3 14
3 20
3 22
3 23
3 27
3 29
3 30
4 9
4 10
4 11
4 12
4 14
4 16
4 18
4 19
4 21
4 23
4 25
4 29
4 30
5 6
5 9
5 11
5 13
5 14
5 15
5 16
5 17
5 22
5 23
5 24
5 28
5 29
6 8
6 9
6 13
6 14
6 17
6 18
6 19
6 21
6 26
6 29
7 9
7 10
7 11
7 12
7 13
7 17
7 18
7 20
7 22
7 25
8 9
8 12
8 16
8 17
8 21
8 22
8 24
8 26
8 28
8 30
9 11
9 12
9 14
9 18
9 21
9 22
9 23
9 24
9 27
9 28
9 30
10 11
10 12
10 15
10 18
10 20
10 21
10 22
10 27
10 28
10 30
11 12
11 14
11 15
11 16
11 17
11 18
11 19
11 21
11 22
11 23
11 27
11 28
12 13
12 15
12 16
12 20
12 21
12 22
12 23
12 25
12 27
12 29
13 15
13 17
13 19
13 20
13 22
13 23
13 24
13 27
13 28
13 29
13 30
14 15
14 16
14 21
14 22
14 24
14 25
14 27
15 16
15 17
15 18
15 19
15 20
15 23
15 24
15 28
15 29
16 17
16 18
16 19
16 20
16 23
16 24
16 25
16 27
16 28
16 29
17 21
17 22
17 23
17 24
17 28
18 19
18 24
18 25
18 30
19 20
19 22
19 24
19 25
19 29
19 30
20 21
20 22
20 26
20 29
20 30
21 22
21 23
21 24
21 26
21 28
21 30
22 24
22 26
22 27
22 28
23 24
23 28
24 25
24 27
24 28
25 26
25 27
25 30
26 28
26 29
26 30
27 29
27 30
28 29
29 30
================================================
FILE: resources/instances/problem_02/resultados.txt
================================================
exemplo_01.txt 15
exemplo_02.txt 12
exemplo_03.txt 27
================================================
FILE: resources/instances/problem_03/results.txt
================================================
================================================
FILE: submissions/.gitkeep
================================================
================================================
FILE: submissions/danielsalles/README.md
================================================
### Compile with:
```
g++ -o problema-1-binary problema-1.cpp -O3
```
### Run with:
```
./problema-1-binary < ../../resources/instances/problem_01/exemplo_01.txt
```
================================================
FILE: submissions/danielsalles/problema-1.cpp
================================================
#include <iostream>
#include <vector>
#include <algorithm>
struct Seed {
int cost;
int profit;
int space;
Seed(int c, int p, int s) : cost(c), profit(p), space(s) {}
};
int calculateMaxProfit(const std::vector<Seed>& seeds, int availableSpace) {
int n = seeds.size();
std::vector<int> dp(availableSpace + 1, 0);
for (int i = 0; i < n; i++) {
for (int j = availableSpace; j >= seeds[i].space; j--) {
dp[j] = std::max(dp[j], dp[j - seeds[i].space] + seeds[i].profit);
}
}
return dp[availableSpace];
}
int main() {
int N, W;
std::cin >> N >> W;
std::vector<Seed> seeds;
seeds.reserve(N);
for(int i = 0; i < N; i++) {
int cost, profit, space;
std::cin >> space >> profit;
cost = 0;
seeds.push_back(Seed(cost, profit, space));
}
int maxProfit = calculateMaxProfit(seeds, W);
std::cout << maxProfit << std::endl;
return 0;
}
================================================
FILE: submissions/devmessias_01_numba_AOT/Makefile
================================================
compile:
cd aot && python setup.py build_ext --inplace
install:
pip install -r requirements.txt
install-aot-lib:
cd aot && python setup.py install
compile-pyc:
python -m compileall problem_01.py
setup: install compile install-aot-lib compile-pyc
================================================
FILE: submissions/devmessias_01_numba_AOT/README.md
================================================
Este exemplo usa compilação AOT usando numba para python. Portanto,
é necessário executar a instalação e compilação primeiro
```
make setup
```
O comando acima ira:
- AOT de uma implementação básica usando NUMBA estrategia de memoization (instâncias são pequenas de mais)
- Instalar o módulo no ambiente
- compilar o pyc para cache
Para executar para cada instância (troquei espaços por tab na primeira linha que tava mal formatada)
```
python problem_01.py exemplo_01.txt
```
================================================
FILE: submissions/devmessias_01_numba_AOT/aot/knapsack.py
================================================
from numba import jit, int64
import numpy as np
from numba.pycc import CC
cc = CC('knapsack')
cc.verbose = True
@cc.export('knapsack', 'int64(int64[:, :], int64)')
def knapsack(items, capacity):
dp = np.zeros(capacity + 1, dtype=np.int64)
for weight, value in items:
for w in range(capacity, weight - 1, -1):
dp[w] = max(dp[w], dp[w - weight] + value)
return dp[capacity]
if __name__ == "__main__":
cc.compile()
================================================
FILE: submissions/devmessias_01_numba_AOT/aot/setup.py
================================================
from setuptools import setup
from setuptools.extension import Extension
from Cython.Build import cythonize
extensions = [
Extension(
name="knapsack",
sources=["knapsack.py"]
),
]
setup(
name="knapsack",
ext_modules=cythonize(extensions),
)
================================================
FILE: submissions/devmessias_01_numba_AOT/exemplo_01.txt
================================================
22 36
3 86
1 80
3 71
2 39
2 53
3 47
2 46
1 32
1 69
2 89
4 58
3 86
3 54
3 53
1 64
4 82
1 46
2 48
4 53
1 68
3 94
1 87
================================================
FILE: submissions/devmessias_01_numba_AOT/exemplo_02.txt
================================================
9 10
3 44
1 78
2 64
1 49
4 69
1 87
3 78
2 45
3 84
================================================
FILE: submissions/devmessias_01_numba_AOT/exemplo_03.txt
================================================
25 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
================================================
FILE: submissions/devmessias_01_numba_AOT/problem_01.py
================================================
from sys import argv
from numpy import genfromtxt, int32
import knapsack
if __name__ == "__main__":
data = genfromtxt(argv[1], delimiter='\t', dtype=int32)
capacity = data[0][1]
items = data[1:]
solution = knapsack.knapsack(items, capacity)
print(solution)
================================================
FILE: submissions/devmessias_01_numba_AOT/requirements.txt
================================================
Cython==3.0.8
llvmlite==0.39.1
numba==0.56
numpy==1.22
================================================
FILE: submissions/diogosm/Dockerfile
================================================
FROM python:3.8
WORKDIR /app
COPY . /app
RUN pip install numba
#RUN apt-get update && apt-get install -y bc
CMD ["bash", "-c", "time python3 problema-1.py < /app/exemplo_03.txt"]
================================================
FILE: submissions/diogosm/README.md
================================================
# Para rodar
Se tiver docker: `./run.sh`. Irá retornar a saída e o tempo de execucao. Caso contrário: `python3 problema-1.py < exemplo_XX.txt`. Mude XX para a instância de entrada.
# Tentativa 1 (pd c/ memoization
Resultado:
```bash
real 0m0.013s
user 0m0.013s
sys 0m0.000s
```
# Tentativa 2 (com numba) *NOT WORKING*
```bash
real 0m0.000s
user 0m0.000s
sys 0m0.000s
```
================================================
FILE: submissions/diogosm/exemplo_01.txt
================================================
22 36
3 86
1 80
3 71
2 39
2 53
3 47
2 46
1 32
1 69
2 89
4 58
3 86
3 54
3 53
1 64
4 82
1 46
2 48
4 53
1 68
3 94
1 87
================================================
FILE: submissions/diogosm/exemplo_02.txt
================================================
9 10
3 44
1 78
2 64
1 49
4 69
1 87
3 78
2 45
3 84
================================================
FILE: submissions/diogosm/exemplo_03.txt
================================================
25 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
================================================
FILE: submissions/diogosm/problema-1.py
================================================
import sys
#from numba import jit, njit
#import numpy as np
n, s = map(int, next(sys.stdin).strip().split())
tuples = [tuple(map(int, next(sys.stdin).strip().split())) for _ in range(n)]
## remove solucoes impossiveis
tuples.sort(key=lambda x: x[1]/x[0], reverse=True)
tuples = [tup for tup in tuples if tup[0] <= s]
memoization = {}
## calc pd
#@njit
def calc_lucro(n_aux, s_aux):
if (n_aux, s_aux) in memoization:
return memoization[(n_aux, s_aux)]
if n_aux == 0 or s_aux == 0:
return 0
if tuples[n_aux-1][0] > s_aux:
memoization[(n_aux, s_aux)] = calc_lucro(n_aux - 1, s_aux)
else:
## verifico adicionando e nao adicionando
memoization[(n_aux, s_aux)] = max( tuples[n_aux-1][1] + calc_lucro(n_aux-1, s_aux - tuples[n_aux-1][0]),
calc_lucro(n_aux - 1, s_aux))
return memoization[(n_aux, s_aux)]
print(calc_lucro(n,s))
#print(memoization)
================================================
FILE: submissions/diogosm/resultados.txt
================================================
instances/exemplo_01.txt 1194
instances/exemplo_02.txt 407
instances/exemplo_03.txt 1566
================================================
FILE: submissions/diogosm/run.sh
================================================
#!/bin/bash
docker build -t python-rinha . && docker run python-rinha
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/Dockerfile
================================================
FROM python:3.11.7-alpine3.18
# Install the hyperfine package
RUN apk --no-cache add hyperfine jq
WORKDIR /app
COPY . /app
# Make the script executable
RUN chmod +x /app/runtime.sh
# Run the script as the default command
CMD ["/app/runtime.sh"]
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/ReadMe.md
================================================
# Requisitos
- ***Docker***
# Como Rodar
### PowerShell(MS) *ou* Shell(Linux)
> Execute uma linha de cada vez no console, sempre esperando a anterior terminar de executar
`e não esqueça de escrever o "."`
1. Ir ao **diretório** do *Dockerfile*
- **PowerShell**/***Bash***
```PowerShell
cd Path/to/submissions/gabrielng-rj99/Problema_1/Python/
```
2. *Gerar* a **Imagem** do *Dockerfile*
- **PowerShell**/***Bash***
```PowerShell
docker build -t problem_1:gabrielng-rj99 .
```
3. *Gerar* um **conteiner** da *imagem* e rodá-lo
- **PowerShell**/***Bash***
```PowerShell
docker run --cpus=2 --memory=2g --name gng-rj99_p1 problem_1:gabrielng-rj99
```
- **Resultado Esperado(Print):**

4. Caso queira rodar o conteiner novamente (sem gerar num novo conteiner)
- **PowerShell**/***Bash***
```PowerShell
docker start -a gng-rj99_p1
```
### Para apagar os conteiners da imagem e a imagem:
#### 1. Parar todas os conteiners da imagem "*problem_1:gabrielng-rj99*"
---
- **PowerShell** `docker ps -aq --filter ancestor=problem_1:gabrielng-rj99 | ForEach-Object { docker stop $_ }`
- ***Bash*** `docker ps -a | grep problem_1:gabrielng-rj99 | awk '{print $1}' | xargs docker stop`
---
#### 2. Remover todas os conteiners da imagem "*problem_1:gabrielng-rj99*"
---
- **PowerShell** `docker ps -aq --filter ancestor=problem_1:gabrielng-rj99 | ForEach-Object { docker rm $_ }`
- ***Bash*** `docker ps -a | grep problem_1:gabrielng-rj99 | awk '{print $1}' | xargs docker rm`
---
#### 3. Remover a imagem criada
- **PowerShell**/***Bash***
```bash
docker rmi problem_1:gabrielng-rj99
```
# Notas:
1. Para timar facilmente os runtimes do dockerfile basta editar o Dockerfile "run_commands.sh" (nas linhas "RUN" e "CMD") para "runtime.sh" dependendo do método pra avaliar.
2. Sinta-se a vontade para alterar os parâmetros do benchmark como
WARMUP e RUNS no runtime.sh
### Rodar mais exemplos/arquivos
- basta colocar todos os arquivos na pasta "examples" abaixo **ANTES** de criar a **imagem** como na foto do **"*Resultado Esperado*"**
> Path / to /submissions/gabrielng-rj99/Problema_1/Python/examples
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_01.txt
================================================
22 36
3 86
1 80
3 71
2 39
2 53
3 47
2 46
1 32
1 69
2 89
4 58
3 86
3 54
3 53
1 64
4 82
1 46
2 48
4 53
1 68
3 94
1 87
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_02.txt
================================================
9 10
3 44
1 78
2 64
1 49
4 69
1 87
3 78
2 45
3 84
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_03.txt
================================================
25 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/handmade_tests.txt
================================================
# Run handmade tests
def run_handmade_tests():
file_paths = [
"submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_01.txt", # 1194
"submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_02.txt", # 407
"submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_03.txt", # 1566
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest.txt", # 80762
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest2.txt", # 96601
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest3.txt", # 84067
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest4.txt", # 74789
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest5.txt", #102945
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test01_03.txt", # 1581
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test02_03.txt", # 1583
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test03_03.txt", # 1596
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test03.1_03.txt", # 1612
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test04_03.txt", # 1597
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test05_03.txt", # 1585
]
for file in file_paths:
print(execute_algorithm(file))
run_handmade_tests()
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest.txt
================================================
1509 2000
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest2.txt
================================================
1000 2500
4 190
7 164
5 172
6 78
2 188
5 139
1 56
2 75
6 183
1 92
5 183
1 132
3 30
5 30
5 175
5 62
3 122
1 61
7 116
5 171
2 50
1 187
3 115
5 76
4 73
2 191
6 141
7 165
3 140
3 168
6 71
4 100
4 112
3 82
1 138
5 165
6 137
3 31
6 153
6 58
5 118
1 130
1 58
5 197
7 125
1 121
5 30
7 133
4 76
2 106
5 73
3 118
2 48
4 191
7 126
7 91
6 126
6 158
3 87
2 78
1 39
1 38
6 179
3 182
4 139
1 167
4 102
4 120
5 183
6 189
5 41
7 163
5 100
7 181
2 196
2 47
1 167
4 31
1 156
3 39
6 70
5 147
2 57
5 42
1 85
1 163
3 41
1 194
1 74
2 98
6 93
4 162
5 121
1 41
2 134
5 37
4 72
6 191
3 103
4 171
3 147
2 177
7 42
6 133
3 194
7 191
4 168
6 60
3 75
7 185
2 80
7 82
3 131
3 63
4 84
3 43
3 59
7 140
3 121
5 106
1 175
6 110
5 60
7 72
5 101
5 168
2 135
2 85
4 148
7 158
5 141
3 193
6 75
7 30
3 184
4 98
3 56
2 68
5 30
7 140
5 74
7 180
7 136
5 99
6 57
7 82
3 135
6 152
7 155
4 125
6 200
2 180
4 163
5 161
5 58
4 150
4 77
1 45
4 146
6 169
7 183
4 159
2 86
2 195
1 85
6 144
7 117
4 183
4 68
5 75
3 108
2 65
1 68
2 84
5 127
7 123
5 101
3 153
6 194
1 180
6 72
6 173
6 130
6 39
5 188
4 55
5 164
1 34
4 78
6 71
2 44
4 82
7 89
7 49
5 89
5 46
4 127
2 72
1 159
2 181
3 152
4 164
3 179
7 56
4 59
7 98
4 56
5 133
4 197
5 78
1 128
4 47
3 180
2 74
5 101
7 38
1 89
7 90
4 190
3 115
2 34
7 50
2 163
6 51
7 109
3 185
1 140
5 97
2 151
3 190
4 166
6 69
6 112
4 131
6 161
3 175
6 190
5 183
6 181
1 124
3 182
6 31
1 189
6 57
3 39
3 130
4 81
6 133
2 73
1 131
2 78
5 73
7 126
6 56
3 170
5 186
4 60
6 56
1 80
1 166
6 144
7 40
7 80
5 174
3 109
3 191
3 72
6 188
7 46
4 152
7 63
2 195
4 31
6 123
5 59
5 168
5 135
6 167
1 74
4 154
4 176
6 79
3 146
6 39
5 50
5 90
6 123
5 143
2 189
7 190
6 69
6 81
7 170
2 130
4 151
5 128
6 93
1 67
5 46
5 121
1 161
7 84
5 95
7 82
7 97
2 91
2 116
1 38
5 103
2 80
2 173
3 51
6 163
4 62
3 93
1 99
1 112
4 93
2 40
7 194
6 125
7 174
6 102
4 131
2 174
3 152
2 30
1 45
6 136
5 54
3 76
5 97
6 69
4 148
2 170
2 95
6 138
1 143
6 67
6 55
5 107
1 33
5 116
3 154
3 177
3 136
7 143
7 170
6 94
4 85
7 121
7 80
4 160
2 77
4 178
7 139
4 41
2 119
6 57
1 102
1 115
1 64
5 161
5 166
2 36
7 155
6 134
5 43
7 100
5 179
5 152
1 116
4 33
7 145
2 33
1 115
1 96
5 125
2 131
2 103
1 169
5 148
5 170
6 181
5 96
4 141
3 140
7 149
3 48
2 190
3 55
4 132
3 55
3 179
7 82
5 124
7 160
3 35
6 171
4 72
7 137
7 77
5 131
2 157
5 181
7 105
1 94
6 83
6 114
6 100
6 179
3 129
7 190
7 48
2 148
7 141
6 178
3 97
7 90
4 44
4 105
5 118
1 182
1 79
2 162
6 99
1 97
4 36
3 189
6 139
7 92
3 67
6 90
7 82
3 151
5 46
4 116
1 60
7 52
4 43
4 198
3 34
2 160
6 181
2 40
5 162
6 63
5 101
2 136
7 119
6 87
3 60
1 154
1 49
3 154
4 160
1 116
2 156
5 90
7 186
7 43
4 88
1 174
7 198
2 163
6 70
5 164
2 178
4 65
6 196
6 31
2 135
1 155
5 42
1 118
3 131
1 44
5 163
4 121
5 107
4 62
3 143
3 164
3 112
1 192
3 172
2 173
4 78
3 91
4 55
4 50
5 117
7 169
6 193
4 83
2 38
6 165
1 136
1 185
7 189
7 104
3 192
4 117
2 186
2 150
6 108
5 104
5 44
7 181
7 46
5 193
5 198
6 49
1 154
3 78
1 128
4 173
3 41
7 89
6 98
7 80
5 193
2 197
6 43
6 189
6 184
4 151
2 64
4 140
3 114
6 112
6 146
5 136
5 69
5 195
1 200
2 58
5 187
4 120
7 165
2 80
6 93
2 31
1 144
6 35
3 156
2 143
1 198
3 154
4 103
3 120
2 154
1 59
3 65
3 137
5 164
5 121
3 174
7 136
4 133
3 164
3 117
2 120
3 112
5 164
1 79
6 74
7 76
6 125
1 43
4 161
1 125
4 147
3 104
5 181
2 58
1 153
5 83
5 32
2 185
5 139
4 87
2 96
4 151
1 200
7 31
4 132
7 147
3 161
3 140
4 147
1 159
5 45
7 137
5 198
5 65
4 79
7 91
5 57
7 184
4 153
3 140
2 197
1 107
3 126
4 157
4 136
5 200
3 174
3 82
7 150
4 52
6 163
1 189
2 147
2 70
2 98
1 62
1 110
7 105
4 173
6 86
2 76
7 108
3 47
1 195
5 125
4 114
7 110
7 81
2 123
6 160
3 49
4 144
2 117
2 138
1 116
3 150
4 184
1 59
5 88
2 95
7 173
1 175
2 110
5 36
5 89
3 194
4 43
2 105
6 192
4 191
4 160
7 126
1 98
5 82
1 91
1 125
2 195
4 37
2 124
4 196
3 37
7 170
1 35
6 119
7 98
5 182
4 135
5 179
6 130
7 59
2 159
4 137
7 97
7 114
2 36
2 60
5 159
5 143
4 160
6 145
1 180
6 138
5 178
2 56
3 111
7 178
7 90
2 160
7 51
5 107
3 38
1 157
1 48
1 181
3 178
6 184
6 179
5 41
1 187
1 64
3 132
7 139
4 142
2 136
4 34
1 178
7 136
2 32
4 68
3 67
5 87
2 37
1 60
7 103
2 123
1 30
4 99
4 169
2 98
7 97
1 168
4 61
6 114
6 96
3 102
1 119
1 198
4 74
1 74
1 144
5 59
6 99
3 81
1 84
4 35
1 144
2 59
6 42
1 98
6 83
5 133
6 175
7 191
7 63
1 180
1 79
1 80
5 140
5 86
4 80
5 109
7 125
4 179
2 125
7 182
2 38
7 32
7 168
4 81
6 117
5 185
3 38
1 98
5 190
2 126
2 149
6 117
6 191
7 189
3 32
5 107
4 148
5 52
5 144
2 74
3 69
5 69
2 32
7 96
5 156
3 100
3 54
6 141
6 163
4 57
1 184
7 34
1 163
2 84
6 73
7 82
2 162
2 147
4 83
6 176
6 32
3 148
7 54
7 143
2 52
5 122
1 70
7 159
2 84
5 86
1 193
1 149
7 142
5 181
1 48
5 185
1 100
3 151
1 64
5 194
4 200
3 34
5 120
7 92
1 145
5 103
5 95
1 59
1 47
7 128
6 111
4 191
2 89
4 147
1 61
2 64
6 164
5 68
7 131
6 94
7 196
2 167
3 175
7 79
4 181
6 190
1 63
3 168
4 150
1 78
2 47
5 158
1 37
7 153
2 120
6 30
2 78
2 106
4 90
4 64
3 144
4 194
7 72
2 160
1 146
6 141
6 78
3 32
1 159
3 148
5 184
3 85
2 50
5 140
1 155
6 154
3 155
5 64
1 31
2 93
1 181
3 142
4 107
6 79
4 112
2 145
7 154
5 104
7 48
2 186
2 44
5 185
5 124
7 62
1 69
6 99
2 48
4 66
4 161
1 125
4 35
4 195
2 189
2 150
2 38
4 145
5 47
5 113
5 150
2 99
6 198
7 47
5 126
3 147
6 61
7 125
3 99
4 70
3 181
6 192
1 164
1 117
1 143
4 162
7 82
3 37
6 92
7 156
4 75
7 119
6 141
6 74
6 31
4 65
1 134
5 33
2 62
1 170
4 123
4 34
7 51
2 91
5 152
6 194
7 137
5 167
2 72
6 102
2 47
3 178
6 67
6 133
3 39
4 120
2 162
1 144
2 108
7 126
4 108
7 38
1 143
7 181
3 143
7 176
6 158
4 37
1 156
5 42
5 37
3 128
2 197
1 37
5 88
3 40
2 40
5 88
4 168
3 82
6 104
1 55
1 49
4 132
1 148
4 131
6 65
1 127
4 87
3 168
6 50
7 115
5 54
6 38
2 150
3 44
1 114
2 44
4 182
4 76
3 64
6 158
3 43
3 107
4 175
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest3.txt
================================================
1000 2000
6 113
2 32
6 149
1 176
7 166
6 64
2 98
6 81
3 175
4 60
4 158
3 164
3 47
2 192
6 114
1 36
5 142
4 181
3 106
4 66
4 151
6 187
6 113
5 117
2 137
6 163
4 145
4 68
4 165
5 174
5 68
2 151
5 78
1 89
5 158
3 79
2 59
3 146
7 160
2 42
6 141
7 188
3 70
7 87
1 174
4 81
2 170
5 161
2 129
6 171
4 156
5 36
5 132
7 51
1 82
7 104
7 41
3 110
7 181
6 67
3 44
6 107
7 140
4 135
2 47
1 63
3 117
6 194
5 156
7 111
7 182
2 46
1 115
2 42
4 154
4 154
7 153
3 197
4 172
7 179
2 59
1 162
6 162
1 150
6 179
1 43
6 188
5 46
6 188
1 166
3 171
6 162
7 94
4 68
2 140
4 74
6 63
5 182
2 151
1 118
3 120
1 83
6 158
5 137
2 179
5 141
3 170
3 100
1 106
3 86
7 130
1 114
7 126
4 111
1 179
3 58
6 35
6 159
2 198
7 66
4 133
7 57
3 53
6 41
2 90
1 184
1 119
6 117
4 134
5 192
2 113
2 73
4 160
7 176
2 182
3 189
4 120
4 58
6 31
2 65
3 117
4 67
2 116
2 52
5 178
3 83
1 116
7 31
7 109
1 119
6 37
5 37
4 110
7 105
4 107
4 180
7 158
1 64
1 80
3 198
6 110
2 79
5 38
2 114
7 180
5 124
7 165
4 120
3 30
6 104
1 71
5 153
5 52
6 89
2 73
5 200
7 56
4 105
1 172
2 75
4 104
4 71
1 78
4 145
7 57
7 136
7 37
5 122
4 80
3 188
3 115
7 146
2 128
6 176
2 98
6 99
3 150
7 44
1 127
1 87
6 129
4 39
4 63
5 157
6 163
4 115
1 150
3 64
4 162
3 100
4 189
5 138
2 115
5 119
2 160
5 126
4 82
4 151
5 99
5 179
2 147
6 109
2 42
4 31
3 187
3 110
1 152
4 139
3 142
5 135
6 35
3 152
7 60
4 161
5 175
5 54
7 153
5 35
1 58
5 38
7 121
3 182
2 42
3 57
3 95
1 71
1 114
1 78
7 46
6 119
3 140
3 156
7 120
5 74
1 92
1 192
7 132
1 156
2 117
6 127
4 36
5 62
7 109
1 54
1 143
4 41
5 167
6 79
1 52
4 80
7 151
3 192
5 134
7 186
6 31
6 197
5 186
7 52
3 183
5 149
7 130
4 78
7 145
6 76
7 158
5 181
3 137
7 95
2 170
1 104
3 66
6 192
4 115
6 120
5 99
4 128
6 88
1 60
3 49
7 156
6 199
2 110
6 86
2 160
6 161
2 82
1 186
3 40
1 124
6 124
6 107
3 64
4 83
4 32
5 156
5 179
5 159
6 130
6 142
7 102
3 191
4 145
5 35
7 131
6 109
2 134
6 115
3 163
6 173
6 98
1 104
3 86
5 148
1 34
7 194
6 115
2 98
2 45
3 118
6 92
6 75
2 156
3 157
7 181
2 151
6 93
6 187
2 113
6 67
4 180
2 193
3 57
7 33
2 156
6 196
3 181
5 111
3 83
3 94
2 91
3 134
6 171
1 33
5 81
3 39
3 50
2 183
6 181
7 121
7 31
1 101
2 148
4 127
6 138
4 179
3 172
2 132
5 30
6 136
2 163
5 174
1 161
2 86
4 160
4 109
2 112
7 96
2 60
1 129
4 129
2 151
7 46
7 186
6 90
4 32
6 191
1 102
7 113
5 112
1 199
4 162
4 169
3 91
6 68
7 156
1 163
1 128
4 178
6 84
5 102
7 157
7 83
4 183
5 76
4 95
7 99
7 34
3 92
6 198
3 160
7 196
6 138
2 148
1 91
7 76
5 192
2 30
6 96
6 83
3 30
4 142
3 96
3 187
1 92
6 158
4 142
5 175
3 176
1 72
7 165
7 131
5 195
6 77
7 84
3 193
6 71
3 67
2 114
4 39
2 164
6 188
5 169
2 139
7 170
7 88
6 79
7 151
7 153
3 127
5 125
6 189
7 131
6 69
2 56
5 70
4 44
3 45
4 151
7 32
5 122
6 82
6 144
1 62
5 158
1 42
2 96
7 187
3 57
6 148
1 181
2 149
3 40
3 46
4 171
3 45
7 77
6 49
5 36
4 65
6 76
4 91
2 59
3 88
3 145
2 38
7 165
5 69
7 151
4 57
3 81
2 34
6 176
7 105
4 116
6 70
5 143
6 186
3 41
4 97
5 117
5 160
5 152
6 119
4 61
6 161
2 96
3 199
2 173
5 68
4 99
6 37
7 81
4 175
5 102
3 93
4 192
6 198
5 100
6 168
7 140
2 72
6 75
7 171
4 159
3 33
5 176
6 40
7 177
5 82
7 86
2 198
6 168
5 160
2 37
5 37
2 80
2 125
7 139
4 77
1 78
4 91
5 125
3 159
6 178
4 141
3 95
6 63
3 110
6 98
3 115
3 180
7 85
3 153
3 165
5 53
7 156
3 143
2 31
3 37
2 175
7 64
7 163
7 159
1 109
5 176
5 77
4 40
6 120
5 101
3 56
6 60
6 127
6 137
7 174
2 145
5 169
5 46
4 104
1 132
4 140
4 54
4 179
2 32
2 56
4 59
1 199
7 40
6 87
2 39
2 96
1 167
6 135
7 97
7 153
4 99
6 179
4 81
4 86
2 33
7 135
2 104
7 193
6 33
4 45
7 125
7 76
3 175
3 94
1 112
3 108
5 169
1 93
4 157
4 104
6 139
4 196
1 92
1 105
4 174
4 189
1 88
1 93
4 98
1 71
4 54
7 72
3 70
2 141
5 151
7 162
4 188
3 106
3 156
5 121
6 91
7 63
4 70
2 116
4 115
4 31
7 78
6 181
7 160
6 88
4 70
3 90
5 105
5 176
2 66
6 178
6 177
5 166
4 126
3 40
6 35
2 161
7 34
5 142
5 151
3 197
2 74
5 104
2 90
2 193
1 148
4 63
6 60
3 192
5 139
5 126
4 98
1 199
5 195
7 180
5 194
6 136
7 167
7 101
7 72
3 84
1 79
6 88
3 132
1 103
3 107
4 93
4 41
1 152
1 67
5 73
5 57
6 151
7 50
7 125
5 117
7 135
5 56
6 56
2 69
2 115
1 53
1 52
3 92
2 115
4 102
4 113
5 46
2 43
3 167
6 35
7 114
4 54
7 105
5 97
5 74
4 159
2 157
4 127
2 121
7 72
6 117
5 76
5 183
4 87
6 43
5 55
5 38
7 54
5 106
5 193
5 52
6 177
5 151
4 194
1 102
3 200
4 37
7 172
2 46
6 105
1 117
2 133
3 184
6 134
2 106
1 119
4 69
5 73
3 177
1 52
4 146
2 155
5 39
1 72
7 108
7 178
4 57
4 112
4 129
6 178
1 174
7 132
4 148
4 194
2 155
3 40
6 65
6 36
4 73
2 196
7 100
1 113
7 139
3 100
5 90
2 106
1 104
1 42
3 127
2 45
7 142
2 187
1 179
7 163
1 58
6 92
7 120
4 110
6 185
5 103
7 44
7 183
5 44
5 77
5 40
7 92
7 177
6 59
2 172
7 70
5 149
4 110
4 132
1 119
2 133
3 58
3 195
7 153
7 152
3 61
1 75
3 110
1 194
1 177
5 181
1 131
3 112
5 184
6 177
1 171
4 152
1 165
1 194
5 141
7 121
5 77
6 130
2 73
7 195
2 89
6 183
4 181
2 82
7 84
6 100
3 135
6 34
2 192
3 187
2 112
7 129
3 183
1 178
1 180
7 180
3 152
3 62
2 89
7 146
6 165
6 35
5 142
2 92
7 84
5 176
5 76
1 117
3 38
1 75
4 152
6 137
5 56
4 171
4 65
3 93
5 83
6 38
2 35
5 111
1 150
5 188
1 49
1 145
2 65
5 96
2 147
3 165
2 182
4 84
5 167
1 121
1 53
3 89
2 31
4 153
6 161
6 139
3 167
3 53
4 117
7 180
3 38
5 120
5 119
7 165
2 130
3 113
3 199
2 34
5 102
3 183
1 121
7 62
2 143
6 148
2 137
2 127
1 184
6 182
5 159
6 169
7 73
1 197
5 51
4 190
7 70
4 48
1 182
4 123
1 67
7 188
5 106
7 184
4 109
5 170
2 174
4 88
6 99
5 36
3 82
7 109
2 153
4 128
3 152
7 49
7 129
5 38
1 139
6 190
1 151
6 97
3 75
6 95
2 56
7 103
2 116
2 138
4 91
5 179
6 158
6 56
4 113
4 46
7 117
6 162
4 71
4 150
4 170
3 104
3 127
7 146
4 178
6 121
5 51
1 188
4 192
1 153
5 197
2 151
6 95
5 53
3 94
1 190
5 31
1 144
6 109
5 109
2 200
3 131
2 35
7 117
6 156
1 151
6 175
7 68
6 33
2 86
3 59
3 49
6 108
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest4.txt
================================================
1000 1500
6 152
3 34
1 151
6 198
5 126
7 133
2 167
6 114
7 165
2 144
7 55
1 50
7 174
6 98
1 151
7 87
4 37
2 195
5 45
1 127
1 92
1 169
1 36
3 171
1 131
2 128
7 137
6 58
3 162
3 170
3 174
6 113
2 179
5 151
7 30
3 152
3 162
1 148
6 157
7 70
4 58
6 181
4 100
4 134
5 193
2 39
3 152
6 139
3 182
4 40
2 157
7 117
6 70
5 36
5 94
2 81
3 103
4 140
1 110
6 31
6 35
5 171
4 136
2 46
1 41
3 31
7 40
4 130
4 57
2 164
2 144
6 155
5 79
4 188
6 167
1 193
7 64
2 92
4 68
4 149
3 62
1 111
1 181
2 196
3 67
7 94
7 49
5 185
7 84
5 150
4 126
2 86
2 107
5 177
2 153
5 127
4 179
7 74
7 142
5 167
2 132
3 99
2 188
2 58
3 69
1 133
3 51
4 167
1 77
7 182
2 55
2 60
3 57
7 66
3 104
2 161
1 81
6 108
7 44
6 150
1 195
7 44
7 85
4 67
2 171
7 136
3 50
2 129
6 119
3 157
7 79
3 143
4 80
6 61
2 52
1 172
4 62
3 101
3 83
6 164
4 168
6 74
1 106
3 75
3 115
6 122
3 134
2 54
5 145
6 73
6 40
7 112
3 97
6 129
1 107
1 180
2 35
6 40
2 200
4 77
5 127
2 119
7 90
1 71
3 149
2 120
4 132
5 119
5 136
7 115
5 123
5 161
5 155
2 69
7 169
4 80
2 167
5 68
2 79
6 154
7 146
4 151
2 174
1 165
4 63
3 169
7 136
3 120
4 182
4 96
1 118
7 63
3 163
3 190
6 90
6 117
5 157
6 87
7 149
6 125
6 135
2 145
7 110
2 148
4 35
2 50
7 200
5 77
2 44
6 97
7 187
2 100
1 127
6 34
2 57
1 44
5 146
2 67
3 72
3 172
3 160
6 139
3 64
3 76
7 179
5 143
6 56
3 55
4 114
6 139
6 97
2 142
2 187
1 53
6 30
5 131
3 197
2 113
2 191
2 42
4 112
6 175
4 44
2 89
5 77
5 64
7 65
6 80
1 164
7 46
1 36
1 59
5 116
6 111
4 68
7 151
5 147
2 49
7 91
4 69
3 68
5 155
5 122
6 89
7 200
6 92
7 31
3 99
6 45
1 152
6 102
3 132
5 163
3 166
7 64
1 135
1 154
4 158
1 71
4 121
4 60
5 119
7 135
5 100
6 160
6 44
6 66
3 45
1 73
4 64
1 37
5 89
2 74
1 164
5 189
3 185
3 127
3 177
7 127
7 196
4 99
5 195
7 62
3 74
5 110
1 137
1 114
2 75
2 67
4 189
5 41
3 114
3 193
5 62
3 33
1 100
7 110
3 150
3 121
6 36
5 174
3 120
6 139
2 192
5 74
1 161
2 168
2 135
1 173
5 147
5 59
5 35
3 108
1 45
2 64
2 99
3 63
3 176
4 119
2 171
5 135
4 132
3 128
4 38
3 146
7 182
7 177
3 36
1 128
2 143
1 159
1 46
6 40
5 30
5 71
5 140
5 100
3 165
5 86
1 144
4 184
2 30
7 54
6 148
5 172
4 133
6 147
1 200
2 58
7 85
5 32
2 198
2 163
6 53
7 44
7 33
6 110
1 187
4 127
2 196
1 131
3 119
6 179
6 148
1 44
4 194
4 84
2 80
6 155
5 113
6 175
2 89
3 113
2 34
6 60
3 133
2 136
3 103
4 63
1 94
5 37
1 134
3 92
6 194
3 163
2 148
4 199
3 138
7 49
2 57
7 166
5 176
7 154
2 68
4 186
6 95
4 175
3 90
3 124
1 45
4 197
6 131
5 55
5 68
3 33
2 111
7 40
7 41
7 61
3 54
3 180
5 138
7 134
3 39
4 124
4 160
6 40
7 154
5 96
2 31
3 88
7 190
7 197
3 133
5 184
6 36
3 43
4 45
3 49
6 192
1 59
4 59
4 105
1 192
2 145
4 55
5 191
4 30
3 139
7 97
3 112
4 39
6 182
4 70
7 187
7 133
6 92
2 157
6 79
2 33
7 118
5 176
5 102
3 138
6 115
7 195
3 74
5 118
2 200
1 135
7 73
2 126
4 161
3 144
4 99
5 87
6 33
6 56
1 104
7 119
5 195
2 190
4 184
2 130
5 129
5 153
1 104
1 140
3 64
2 187
3 91
2 149
7 44
3 39
1 156
7 178
2 55
3 74
4 166
7 149
3 45
2 86
5 35
4 76
1 58
7 140
1 132
3 114
6 145
4 161
2 79
1 75
4 74
1 180
1 178
7 194
4 119
2 157
5 118
2 62
5 136
4 43
4 62
1 44
5 115
3 88
5 48
6 52
1 111
3 34
3 83
1 67
1 119
7 55
1 156
4 177
7 192
5 126
4 143
4 82
5 65
7 191
4 93
5 93
2 88
7 121
6 112
2 58
2 197
3 65
6 104
1 196
7 191
3 122
6 59
4 186
6 198
5 94
4 60
4 41
7 175
1 179
7 150
1 200
3 111
7 90
2 144
6 73
4 57
1 136
6 173
7 132
6 152
4 132
3 59
6 46
2 129
7 40
6 92
1 139
6 120
6 156
5 134
3 181
1 114
2 192
2 175
7 149
4 145
1 71
3 128
7 154
7 91
4 179
4 196
3 191
6 94
4 168
7 197
4 142
5 117
4 171
2 141
7 86
3 173
2 188
5 170
4 60
3 173
2 156
1 105
1 43
4 156
3 66
3 103
6 56
1 106
5 38
5 59
3 76
5 121
6 199
2 141
4 198
2 32
3 108
1 128
1 175
4 42
2 126
4 136
3 63
4 80
2 80
2 83
2 75
2 153
3 63
3 193
5 164
3 44
1 171
7 106
4 196
2 199
3 108
5 89
1 105
2 117
3 78
2 45
5 100
2 51
6 30
2 82
1 133
1 157
7 107
6 178
4 173
4 161
4 194
5 197
1 178
3 133
4 165
4 125
6 179
2 158
3 163
2 75
3 60
7 68
5 100
4 68
3 112
6 192
5 36
4 166
6 200
1 120
7 200
4 111
3 99
2 125
7 31
1 56
6 72
7 60
7 30
2 41
2 164
7 77
1 146
5 129
7 67
7 156
2 167
6 184
3 174
2 179
1 161
1 64
1 168
7 200
5 104
1 73
4 197
5 154
6 82
2 122
2 190
4 115
1 94
3 140
4 174
4 61
2 140
1 145
6 89
1 155
6 124
2 91
7 106
2 78
3 100
5 154
6 60
4 155
5 162
6 166
5 108
5 90
5 187
6 173
7 65
3 149
7 188
7 100
2 73
4 94
1 91
5 194
6 123
5 198
7 154
3 100
5 176
7 186
2 159
6 50
2 174
4 80
1 83
7 178
6 191
2 194
1 142
7 80
5 147
7 171
2 94
3 160
3 35
6 193
5 165
6 97
5 90
2 139
5 142
6 108
1 143
3 70
2 47
2 179
6 151
4 96
6 31
4 130
4 192
3 115
5 44
5 33
5 110
3 57
4 105
7 45
2 107
5 174
4 57
1 108
6 90
1 46
6 116
6 56
1 151
7 43
3 138
1 57
1 124
2 94
6 98
3 168
6 97
2 94
6 64
3 158
6 124
4 121
1 183
2 96
2 155
4 155
5 116
3 123
4 79
2 132
4 98
5 65
6 131
1 160
6 172
7 145
3 44
2 181
3 33
7 178
4 190
7 34
7 161
5 69
1 37
1 138
4 42
5 112
4 101
2 187
7 167
3 177
1 192
6 90
2 177
2 56
4 34
6 136
7 108
1 54
3 185
1 173
1 77
5 116
5 89
5 36
2 161
7 63
7 42
6 180
3 193
6 109
7 79
7 192
5 51
1 181
6 165
5 115
5 59
4 195
3 113
1 52
7 94
6 59
6 41
1 56
3 151
5 146
7 92
6 30
7 59
2 102
4 33
5 114
7 110
3 78
3 144
5 175
2 87
1 162
3 185
7 173
5 40
6 66
3 148
4 184
6 139
5 172
5 103
5 162
3 171
6 61
1 131
6 185
2 50
7 104
1 80
4 52
7 36
2 106
3 172
4 172
2 76
7 50
4 121
6 63
3 94
2 97
4 119
2 161
7 78
5 86
6 86
7 167
4 58
2 145
2 190
2 113
5 125
1 198
4 81
1 155
4 113
4 75
1 143
2 143
5 187
6 184
6 134
2 141
5 130
5 58
5 180
2 174
7 176
3 188
5 57
7 53
3 56
4 53
7 183
7 160
2 170
6 185
5 42
4 124
6 182
7 197
4 96
4 125
7 159
6 79
6 172
7 58
6 145
7 107
3 115
2 139
5 134
3 135
6 65
5 119
2 88
2 71
3 104
7 172
5 84
7 105
1 89
7 107
6 44
7 33
1 97
2 35
3 132
4 36
6 63
1 178
4 160
3 35
5 152
7 117
3 47
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest5.txt
================================================
1000 3000
2 172
1 74
2 95
3 160
1 41
1 41
4 98
2 131
2 52
7 195
5 129
5 122
7 171
3 71
3 89
2 73
4 52
2 128
7 179
3 113
6 199
6 187
3 164
6 77
7 200
6 127
5 184
1 98
2 104
7 129
4 128
6 111
6 110
6 186
7 145
2 110
1 190
4 57
4 169
2 169
2 33
1 99
1 154
3 176
4 69
1 117
7 33
1 53
6 152
3 72
7 104
2 38
2 101
2 128
2 101
5 151
3 115
7 117
6 94
3 128
2 65
5 30
6 30
4 151
6 175
5 45
6 75
6 55
1 69
5 41
1 88
6 89
6 115
2 114
2 153
6 77
5 182
2 91
6 49
4 140
6 107
6 106
6 154
4 50
6 139
6 93
1 34
1 168
1 107
5 76
4 72
1 126
4 180
4 126
5 77
3 124
5 131
5 58
7 91
3 164
3 183
4 133
1 165
3 75
5 104
1 74
5 162
6 86
7 190
5 93
3 137
1 97
5 86
4 195
1 159
1 200
2 64
3 142
3 109
6 166
7 98
6 155
4 186
4 75
3 199
2 100
7 97
6 130
7 165
6 141
5 72
3 130
4 67
5 146
6 101
5 90
2 60
2 181
5 41
1 43
5 118
3 85
2 94
2 57
3 59
2 114
5 113
5 152
1 83
7 139
5 169
2 45
2 158
5 62
7 75
7 107
1 65
7 189
3 109
1 165
5 116
6 161
2 137
6 193
4 143
7 80
5 132
1 98
6 92
3 173
5 131
1 174
2 41
6 76
7 65
3 135
2 56
5 134
5 70
2 194
3 38
3 57
4 57
6 162
7 90
1 116
6 190
5 119
4 114
4 185
4 52
3 162
6 60
3 118
7 155
7 51
6 114
2 95
6 111
6 139
4 149
7 98
3 40
2 79
2 109
3 125
3 63
4 87
4 76
2 62
4 131
1 32
6 174
7 91
3 60
1 171
3 107
2 167
4 171
4 41
6 118
4 101
2 103
7 153
4 127
6 128
2 54
7 180
7 118
1 147
5 79
2 72
3 140
5 128
4 36
4 157
2 125
4 196
2 71
3 197
3 179
1 52
2 195
5 196
4 85
3 89
5 140
5 70
2 41
3 124
7 76
1 59
1 98
4 34
3 46
2 126
7 90
6 67
6 63
6 81
2 103
3 34
7 55
1 180
7 112
3 80
6 40
1 127
3 86
4 40
2 176
1 119
4 149
3 122
2 189
6 186
2 189
6 137
3 75
5 112
3 83
1 35
1 199
3 66
7 117
5 190
4 40
5 106
3 37
3 136
6 156
3 150
3 57
3 59
7 122
1 184
7 35
1 77
4 83
1 139
5 135
6 170
4 200
5 197
1 30
7 168
3 97
2 105
7 162
3 182
3 69
7 156
5 106
4 146
7 34
3 172
4 31
7 145
5 31
2 86
4 136
2 106
7 37
7 71
2 104
4 55
5 63
7 79
5 72
6 35
5 83
3 40
5 40
5 193
2 154
3 183
5 62
6 80
7 34
4 73
4 165
2 116
3 174
6 77
7 157
7 127
3 114
6 78
2 184
4 50
5 73
4 76
5 138
7 51
2 75
1 182
3 164
4 77
4 73
2 189
7 108
3 128
4 92
7 40
2 82
1 132
5 186
6 108
7 104
7 137
2 36
6 111
7 131
3 145
7 112
4 146
2 119
1 49
7 194
3 47
5 38
2 92
6 162
5 100
5 56
6 182
1 186
6 139
4 137
3 47
7 105
6 175
1 39
5 57
6 90
4 105
1 153
7 55
3 50
1 181
2 39
3 138
5 163
6 36
7 130
6 42
3 147
1 48
3 93
2 71
2 158
3 58
4 48
5 31
5 148
6 68
6 151
4 180
1 105
2 185
3 140
4 138
7 57
3 79
3 190
4 135
6 135
5 62
1 127
7 49
3 46
5 144
2 53
4 62
4 44
7 88
6 91
2 190
1 194
4 195
5 102
5 101
1 75
5 57
2 108
6 134
6 195
1 94
1 185
7 110
6 107
1 51
5 151
7 94
3 101
5 179
6 58
6 126
2 128
3 49
6 109
2 121
2 64
2 145
3 153
5 61
5 75
7 60
7 33
1 72
7 86
6 122
7 172
3 153
2 160
4 140
1 173
3 121
6 49
4 101
6 117
2 38
3 107
5 115
5 147
1 173
5 66
4 198
5 124
6 80
6 79
2 91
3 126
2 38
1 111
6 196
1 187
1 114
6 105
4 126
4 150
4 61
6 86
3 33
6 136
6 39
2 118
2 91
7 101
6 93
1 39
6 121
1 168
5 71
5 61
2 115
5 64
3 151
6 197
5 174
1 100
6 185
5 137
6 41
7 105
6 146
3 45
4 52
7 79
2 141
7 145
1 65
4 107
6 66
7 81
4 157
3 198
6 80
2 72
7 116
7 102
3 148
1 109
5 141
2 148
3 125
3 145
5 44
2 167
4 196
1 166
1 133
7 173
5 166
1 65
4 31
1 72
4 174
5 36
2 70
5 42
3 148
7 193
3 38
6 143
7 175
4 90
5 91
3 172
3 183
5 146
5 165
3 64
3 186
4 87
2 199
5 127
1 53
3 184
3 137
2 38
1 191
5 39
1 110
1 156
3 139
4 35
7 190
6 41
1 159
7 31
7 152
5 129
6 135
6 118
2 168
5 160
5 187
5 171
6 140
3 172
5 190
5 149
3 83
5 176
2 165
1 43
2 169
4 138
5 194
7 197
2 111
4 101
2 157
5 94
4 169
3 189
5 174
5 168
3 193
2 148
4 128
7 135
7 198
3 76
6 106
3 128
2 74
6 62
2 192
2 70
4 30
7 180
1 94
4 80
4 149
4 170
1 164
4 101
7 190
4 118
3 137
4 40
2 84
4 172
3 75
4 90
2 102
1 152
5 192
5 57
6 77
4 147
5 131
1 96
6 41
5 31
3 112
6 176
6 187
6 55
4 103
3 101
1 114
3 79
7 34
7 191
1 153
5 185
5 170
6 69
2 89
5 174
6 88
4 121
1 115
6 34
1 46
5 123
7 143
5 95
4 166
7 159
3 118
1 61
7 46
7 127
2 56
7 52
2 31
6 167
1 78
4 102
4 94
2 72
5 95
1 107
6 147
1 34
6 84
5 129
5 151
6 126
1 130
5 112
7 154
1 109
4 37
7 62
6 136
6 94
3 173
7 128
2 68
2 83
2 125
7 102
4 138
2 46
7 72
4 52
6 43
5 172
4 134
6 98
1 49
1 172
1 199
4 113
1 168
4 180
7 142
7 101
3 86
6 153
7 70
2 103
2 102
3 40
1 194
7 67
4 131
4 108
3 103
1 41
7 152
7 80
2 85
3 147
4 176
4 143
1 81
1 67
7 54
7 153
5 107
3 197
6 33
4 78
3 88
3 94
4 72
1 192
6 68
1 67
4 129
7 78
3 114
6 141
4 93
2 58
2 91
4 134
2 32
3 35
4 100
4 64
3 131
1 50
5 76
5 46
5 70
4 75
1 103
7 36
3 193
6 135
3 103
1 165
3 143
7 177
3 141
3 76
5 100
2 54
5 84
3 48
2 183
4 136
7 161
6 106
2 91
3 165
6 134
6 67
6 183
3 144
6 47
4 185
2 123
3 131
2 76
7 37
7 33
6 165
6 152
1 165
3 112
7 156
6 87
1 157
6 171
2 124
6 79
2 144
2 126
6 140
6 163
5 76
6 96
4 197
6 51
7 30
4 92
2 165
7 126
7 169
6 160
7 118
2 98
3 42
3 55
1 191
6 74
1 108
4 52
2 124
6 159
5 99
3 129
1 83
4 82
5 32
6 122
4 123
1 167
1 82
4 81
3 146
2 107
6 169
3 98
4 102
5 185
2 118
4 120
7 113
2 55
6 138
4 191
1 142
5 77
6 171
1 189
3 130
1 106
2 117
1 141
3 199
7 52
2 129
4 32
4 186
1 166
1 114
4 193
7 50
3 30
6 103
5 122
3 189
5 128
5 171
1 145
3 83
2 129
4 64
6 62
5 103
1 193
4 183
2 175
6 104
1 48
3 163
5 180
7 170
2 50
1 31
4 137
2 172
1 144
1 174
7 35
7 165
3 151
1 193
2 176
1 72
4 146
1 188
7 37
4 147
2 79
2 135
6 111
2 73
5 174
5 119
6 87
4 41
1 45
7 34
5 150
6 53
3 116
2 59
1 109
1 192
5 71
1 36
5 103
5 113
1 87
1 31
2 155
2 31
1 137
7 130
1 125
7 134
6 129
7 148
3 31
3 36
6 91
2 152
6 39
7 98
7 33
6 146
6 122
3 82
2 95
1 114
1 152
4 169
3 178
1 165
4 140
3 39
4 169
5 74
7 49
4 117
3 144
3 144
5 60
5 161
5 177
3 160
4 49
3 122
7 118
6 78
7 194
5 74
1 92
6 59
2 79
5 146
5 30
2 59
7 126
7 143
4 46
3 194
1 129
5 126
7 145
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test01_03.txt
================================================
26 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test02_03.txt
================================================
26 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
2 30
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test03.1_03.txt
================================================
26 47
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
2 30
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test03_03.txt
================================================
26 46
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
2 30
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test04_03.txt
================================================
26 46
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 44
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
2 30
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test05_03.txt
================================================
25 46
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 61
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/problema-1.py
================================================
import sys
def knapsack(SPACE, ARRAY):
n = len(ARRAY)
dp = [0] * (SPACE + 1)
for i in range(n):
wi = ARRAY[i][0] # Weight
vi = ARRAY[i][1] # Value
for j in range(SPACE, wi - 1, -1):
dp[j] = max(dp[j], vi + dp[j - wi])
return dp[SPACE]
def execute_algorithm(file_path):
with open(file_path, 'r') as file:
_n, W = map(int, file.readline().split())
file_array = []
for line in file:
row = list(map(int, line.split()))
row += [row[1]/row[0]]
file_array.append(row)
return knapsack(W, file_array)
if __name__ == '__main__':
file_path = sys.argv[1]
print(f"{execute_algorithm(file_path):>10}")
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/run_commands.sh
================================================
#!/bin/sh
MFNL=0 # Max FileName Length Start
for file in examples/*
do
filename=$(basename $file)
len=$(echo -n "$filename" | wc -c)
if [ $len -gt $MFNL ]; then
MFNL=$len
fi
done
clear
printf "%-${MFNL}s %s \t \n" "FileName" "Respostas"
for file in examples/*
do
output=$(python problema-1.py $file)
filename=$(basename $file)
printf "%-${MFNL}s $output\n" "$filename"
done
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/runtime.sh
================================================
#!/bin/sh
WARMUP=20
RUNS=20
SUM_MEANS=0
FILE_COUNT=0
MFNL=0 # Max FileName Length Start
for file in examples/*
do
filename=$(basename $file)
len=$(echo -n "$filename" | wc -c)
if [ $len -gt $MFNL ]; then
MFNL=$len
fi
done
clear
echo -e "\n\nRodará um (Hyperfine) Benchmark de $RUNS runs para cada arquivo"
echo -e "Depois pego as médias numa jq, e calculo ao final a soma das médias"
echo -e "Isso foi feito para facilitar a execução e visualização dos resultados\n\n"
printf "%-${MFNL}s %s \t %s \n" "FileName" "Respostas" "Runtime"
for file in examples/*
do
result=$(hyperfine --warmup $WARMUP --runs $RUNS "python problema-1.py $file" --export-json /tmp/hyperfine_results.json 2>/dev/null)
output=$(python problema-1.py $file)
filename=$(basename $file)
mean=$(jq -r '.results | .[0].mean' /tmp/hyperfine_results.json)
formatted_mean=$(printf "%.9f" $mean)
SUM_MEANS=$(echo "$SUM_MEANS + $mean" | bc)
FILE_COUNT=$((FILE_COUNT + 1))
printf "%-${MFNL}s $output \t $formatted_mean s\n" "$filename"
done
AVERAGE_MEAN=$(echo "scale=9; $SUM_MEANS / $FILE_COUNT" | bc)
TOTAL_RUNTIME=$(printf "%.9f" $SUM_MEANS)
AVERAGE_MEAN=$(printf "%.9f" $AVERAGE_MEAN)
echo -e "\nTotal Runtime: \t\t $TOTAL_RUNTIME s\n"
echo -e "\nAvarage Runtime: \t\t $AVERAGE_MEAN s\n\n"
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Python/test_hyperfine.sh
================================================
#!/bin/sh
#Hyperfine all examples one by one
clear
WARMUP=10
RUNS=200
for file in examples/*
do
namefile=$(basename $file)
output=$(python problema-1.py $file)
echo -e "\nResposta do $namefile -> $output"
echo -e "Benchmark"
hyperfine --warmup $WARMUP --runs $RUNS "python problema-1.py $file" 2>/dev/null | grep -v "^Benchmark 1: python problema-1.py"
done
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/Cargo.toml
================================================
[package]
name = "problema_1"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/Dockerfile
================================================
FROM rust:1.75-alpine3.18
# Install the hyperfine package
RUN apk --no-cache add hyperfine jq
WORKDIR /app
COPY . /app
# Convert line endings of the script to Unix format and executable
RUN dos2unix /app/run_commands.sh
RUN chmod +x /app/run_commands.sh
# Run the script as the default command
CMD ["/app/run_commands.sh"]
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/ReadMe.md
================================================
# Requisitos
- ***Docker***
# Como Rodar
### PowerShell(MS) *ou* Shell(Linux)
> Execute uma linha de cada vez no console, sempre esperando a anterior terminar de executar
`e não esqueça de escrever o "."`
1. Ir ao **diretório** do *Dockerfile*
- **PowerShell**/***Bash***
```PowerShell
cd Path/to/submissions/gabrielng-rj99/Problema_1/Rust/
```
2. *Gerar* a **Imagem** do *Dockerfile*
- **PowerShell**/***Bash***
```PowerShell
docker build -t problem_1:gabrielng-rj99 .
```
3. *Gerar* um **conteiner** da *imagem* e rodá-lo
- **PowerShell**/***Bash***
```PowerShell
docker run --cpus=2 --memory=2g --name gng-rj99_p1 problem_1:gabrielng-rj99
```
- **Resultado Esperado(Print):**

4. Caso queira rodar o conteiner novamente (sem gerar num novo conteiner)
- **PowerShell**/***Bash***
```PowerShell
docker start -a gng-rj99_p1
```
### Para apagar os conteiners da imagem e a imagem:
#### 1. Parar todas os conteiners da imagem "*problem_1:gabrielng-rj99*"
---
- **PowerShell** `docker ps -aq --filter ancestor=problem_1:gabrielng-rj99 | ForEach-Object { docker stop $_ }`
- ***Bash*** `docker ps -a | grep problem_1:gabrielng-rj99 | awk '{print $1}' | xargs docker stop`
---
#### 2. Remover todas os conteiners da imagem "*problem_1:gabrielng-rj99*"
---
- **PowerShell** `docker ps -aq --filter ancestor=problem_1:gabrielng-rj99 | ForEach-Object { docker rm $_ }`
- ***Bash*** `docker ps -a | grep problem_1:gabrielng-rj99 | awk '{print $1}' | xargs docker rm`
---
#### 3. Remover a imagem criada
- **PowerShell**/***Bash***
```bash
docker rmi problem_1:gabrielng-rj99
```
# Notas:
1. Sinta-se a vontade para alterar os parâmetros do benchmark como
WARMUP e RUNS no run_commands.sh
### Rodar mais exemplos/arquivos
- basta colocar todos os arquivos na pasta "examples" abaixo **ANTES** de criar a **imagem** como na foto do **"*Resultado Esperado*"**
> Path / to /submissions/gabrielng-rj99/Problema_1/Rust/examples
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/examples/exemplo_01.txt
================================================
22 36
3 86
1 80
3 71
2 39
2 53
3 47
2 46
1 32
1 69
2 89
4 58
3 86
3 54
3 53
1 64
4 82
1 46
2 48
4 53
1 68
3 94
1 87
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/examples/exemplo_02.txt
================================================
9 10
3 44
1 78
2 64
1 49
4 69
1 87
3 78
2 45
3 84
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/examples/exemplo_03.txt
================================================
25 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/handmade_tests.txt
================================================
# Run handmade tests
def run_handmade_tests():
file_paths = [
"submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_01.txt", # 1194
"submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_02.txt", # 407
"submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_03.txt", # 1566
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest.txt", # 80762
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest2.txt", # 96601
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest3.txt", # 84067
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest4.txt", # 74789
"submissions/gabrielng-rj99/Problema_1/Python/examples/longruntest5.txt", #102945
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test01_03.txt", # 1581
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test02_03.txt", # 1583
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test03_03.txt", # 1596
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test03.1_03.txt", # 1612
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test04_03.txt", # 1597
"submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test05_03.txt", # 1585
]
for file in file_paths:
print(execute_algorithm(file))
run_handmade_tests()
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest.txt
================================================
1509 2000
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest2.txt
================================================
1000 2500
4 190
7 164
5 172
6 78
2 188
5 139
1 56
2 75
6 183
1 92
5 183
1 132
3 30
5 30
5 175
5 62
3 122
1 61
7 116
5 171
2 50
1 187
3 115
5 76
4 73
2 191
6 141
7 165
3 140
3 168
6 71
4 100
4 112
3 82
1 138
5 165
6 137
3 31
6 153
6 58
5 118
1 130
1 58
5 197
7 125
1 121
5 30
7 133
4 76
2 106
5 73
3 118
2 48
4 191
7 126
7 91
6 126
6 158
3 87
2 78
1 39
1 38
6 179
3 182
4 139
1 167
4 102
4 120
5 183
6 189
5 41
7 163
5 100
7 181
2 196
2 47
1 167
4 31
1 156
3 39
6 70
5 147
2 57
5 42
1 85
1 163
3 41
1 194
1 74
2 98
6 93
4 162
5 121
1 41
2 134
5 37
4 72
6 191
3 103
4 171
3 147
2 177
7 42
6 133
3 194
7 191
4 168
6 60
3 75
7 185
2 80
7 82
3 131
3 63
4 84
3 43
3 59
7 140
3 121
5 106
1 175
6 110
5 60
7 72
5 101
5 168
2 135
2 85
4 148
7 158
5 141
3 193
6 75
7 30
3 184
4 98
3 56
2 68
5 30
7 140
5 74
7 180
7 136
5 99
6 57
7 82
3 135
6 152
7 155
4 125
6 200
2 180
4 163
5 161
5 58
4 150
4 77
1 45
4 146
6 169
7 183
4 159
2 86
2 195
1 85
6 144
7 117
4 183
4 68
5 75
3 108
2 65
1 68
2 84
5 127
7 123
5 101
3 153
6 194
1 180
6 72
6 173
6 130
6 39
5 188
4 55
5 164
1 34
4 78
6 71
2 44
4 82
7 89
7 49
5 89
5 46
4 127
2 72
1 159
2 181
3 152
4 164
3 179
7 56
4 59
7 98
4 56
5 133
4 197
5 78
1 128
4 47
3 180
2 74
5 101
7 38
1 89
7 90
4 190
3 115
2 34
7 50
2 163
6 51
7 109
3 185
1 140
5 97
2 151
3 190
4 166
6 69
6 112
4 131
6 161
3 175
6 190
5 183
6 181
1 124
3 182
6 31
1 189
6 57
3 39
3 130
4 81
6 133
2 73
1 131
2 78
5 73
7 126
6 56
3 170
5 186
4 60
6 56
1 80
1 166
6 144
7 40
7 80
5 174
3 109
3 191
3 72
6 188
7 46
4 152
7 63
2 195
4 31
6 123
5 59
5 168
5 135
6 167
1 74
4 154
4 176
6 79
3 146
6 39
5 50
5 90
6 123
5 143
2 189
7 190
6 69
6 81
7 170
2 130
4 151
5 128
6 93
1 67
5 46
5 121
1 161
7 84
5 95
7 82
7 97
2 91
2 116
1 38
5 103
2 80
2 173
3 51
6 163
4 62
3 93
1 99
1 112
4 93
2 40
7 194
6 125
7 174
6 102
4 131
2 174
3 152
2 30
1 45
6 136
5 54
3 76
5 97
6 69
4 148
2 170
2 95
6 138
1 143
6 67
6 55
5 107
1 33
5 116
3 154
3 177
3 136
7 143
7 170
6 94
4 85
7 121
7 80
4 160
2 77
4 178
7 139
4 41
2 119
6 57
1 102
1 115
1 64
5 161
5 166
2 36
7 155
6 134
5 43
7 100
5 179
5 152
1 116
4 33
7 145
2 33
1 115
1 96
5 125
2 131
2 103
1 169
5 148
5 170
6 181
5 96
4 141
3 140
7 149
3 48
2 190
3 55
4 132
3 55
3 179
7 82
5 124
7 160
3 35
6 171
4 72
7 137
7 77
5 131
2 157
5 181
7 105
1 94
6 83
6 114
6 100
6 179
3 129
7 190
7 48
2 148
7 141
6 178
3 97
7 90
4 44
4 105
5 118
1 182
1 79
2 162
6 99
1 97
4 36
3 189
6 139
7 92
3 67
6 90
7 82
3 151
5 46
4 116
1 60
7 52
4 43
4 198
3 34
2 160
6 181
2 40
5 162
6 63
5 101
2 136
7 119
6 87
3 60
1 154
1 49
3 154
4 160
1 116
2 156
5 90
7 186
7 43
4 88
1 174
7 198
2 163
6 70
5 164
2 178
4 65
6 196
6 31
2 135
1 155
5 42
1 118
3 131
1 44
5 163
4 121
5 107
4 62
3 143
3 164
3 112
1 192
3 172
2 173
4 78
3 91
4 55
4 50
5 117
7 169
6 193
4 83
2 38
6 165
1 136
1 185
7 189
7 104
3 192
4 117
2 186
2 150
6 108
5 104
5 44
7 181
7 46
5 193
5 198
6 49
1 154
3 78
1 128
4 173
3 41
7 89
6 98
7 80
5 193
2 197
6 43
6 189
6 184
4 151
2 64
4 140
3 114
6 112
6 146
5 136
5 69
5 195
1 200
2 58
5 187
4 120
7 165
2 80
6 93
2 31
1 144
6 35
3 156
2 143
1 198
3 154
4 103
3 120
2 154
1 59
3 65
3 137
5 164
5 121
3 174
7 136
4 133
3 164
3 117
2 120
3 112
5 164
1 79
6 74
7 76
6 125
1 43
4 161
1 125
4 147
3 104
5 181
2 58
1 153
5 83
5 32
2 185
5 139
4 87
2 96
4 151
1 200
7 31
4 132
7 147
3 161
3 140
4 147
1 159
5 45
7 137
5 198
5 65
4 79
7 91
5 57
7 184
4 153
3 140
2 197
1 107
3 126
4 157
4 136
5 200
3 174
3 82
7 150
4 52
6 163
1 189
2 147
2 70
2 98
1 62
1 110
7 105
4 173
6 86
2 76
7 108
3 47
1 195
5 125
4 114
7 110
7 81
2 123
6 160
3 49
4 144
2 117
2 138
1 116
3 150
4 184
1 59
5 88
2 95
7 173
1 175
2 110
5 36
5 89
3 194
4 43
2 105
6 192
4 191
4 160
7 126
1 98
5 82
1 91
1 125
2 195
4 37
2 124
4 196
3 37
7 170
1 35
6 119
7 98
5 182
4 135
5 179
6 130
7 59
2 159
4 137
7 97
7 114
2 36
2 60
5 159
5 143
4 160
6 145
1 180
6 138
5 178
2 56
3 111
7 178
7 90
2 160
7 51
5 107
3 38
1 157
1 48
1 181
3 178
6 184
6 179
5 41
1 187
1 64
3 132
7 139
4 142
2 136
4 34
1 178
7 136
2 32
4 68
3 67
5 87
2 37
1 60
7 103
2 123
1 30
4 99
4 169
2 98
7 97
1 168
4 61
6 114
6 96
3 102
1 119
1 198
4 74
1 74
1 144
5 59
6 99
3 81
1 84
4 35
1 144
2 59
6 42
1 98
6 83
5 133
6 175
7 191
7 63
1 180
1 79
1 80
5 140
5 86
4 80
5 109
7 125
4 179
2 125
7 182
2 38
7 32
7 168
4 81
6 117
5 185
3 38
1 98
5 190
2 126
2 149
6 117
6 191
7 189
3 32
5 107
4 148
5 52
5 144
2 74
3 69
5 69
2 32
7 96
5 156
3 100
3 54
6 141
6 163
4 57
1 184
7 34
1 163
2 84
6 73
7 82
2 162
2 147
4 83
6 176
6 32
3 148
7 54
7 143
2 52
5 122
1 70
7 159
2 84
5 86
1 193
1 149
7 142
5 181
1 48
5 185
1 100
3 151
1 64
5 194
4 200
3 34
5 120
7 92
1 145
5 103
5 95
1 59
1 47
7 128
6 111
4 191
2 89
4 147
1 61
2 64
6 164
5 68
7 131
6 94
7 196
2 167
3 175
7 79
4 181
6 190
1 63
3 168
4 150
1 78
2 47
5 158
1 37
7 153
2 120
6 30
2 78
2 106
4 90
4 64
3 144
4 194
7 72
2 160
1 146
6 141
6 78
3 32
1 159
3 148
5 184
3 85
2 50
5 140
1 155
6 154
3 155
5 64
1 31
2 93
1 181
3 142
4 107
6 79
4 112
2 145
7 154
5 104
7 48
2 186
2 44
5 185
5 124
7 62
1 69
6 99
2 48
4 66
4 161
1 125
4 35
4 195
2 189
2 150
2 38
4 145
5 47
5 113
5 150
2 99
6 198
7 47
5 126
3 147
6 61
7 125
3 99
4 70
3 181
6 192
1 164
1 117
1 143
4 162
7 82
3 37
6 92
7 156
4 75
7 119
6 141
6 74
6 31
4 65
1 134
5 33
2 62
1 170
4 123
4 34
7 51
2 91
5 152
6 194
7 137
5 167
2 72
6 102
2 47
3 178
6 67
6 133
3 39
4 120
2 162
1 144
2 108
7 126
4 108
7 38
1 143
7 181
3 143
7 176
6 158
4 37
1 156
5 42
5 37
3 128
2 197
1 37
5 88
3 40
2 40
5 88
4 168
3 82
6 104
1 55
1 49
4 132
1 148
4 131
6 65
1 127
4 87
3 168
6 50
7 115
5 54
6 38
2 150
3 44
1 114
2 44
4 182
4 76
3 64
6 158
3 43
3 107
4 175
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest3.txt
================================================
1000 2000
6 113
2 32
6 149
1 176
7 166
6 64
2 98
6 81
3 175
4 60
4 158
3 164
3 47
2 192
6 114
1 36
5 142
4 181
3 106
4 66
4 151
6 187
6 113
5 117
2 137
6 163
4 145
4 68
4 165
5 174
5 68
2 151
5 78
1 89
5 158
3 79
2 59
3 146
7 160
2 42
6 141
7 188
3 70
7 87
1 174
4 81
2 170
5 161
2 129
6 171
4 156
5 36
5 132
7 51
1 82
7 104
7 41
3 110
7 181
6 67
3 44
6 107
7 140
4 135
2 47
1 63
3 117
6 194
5 156
7 111
7 182
2 46
1 115
2 42
4 154
4 154
7 153
3 197
4 172
7 179
2 59
1 162
6 162
1 150
6 179
1 43
6 188
5 46
6 188
1 166
3 171
6 162
7 94
4 68
2 140
4 74
6 63
5 182
2 151
1 118
3 120
1 83
6 158
5 137
2 179
5 141
3 170
3 100
1 106
3 86
7 130
1 114
7 126
4 111
1 179
3 58
6 35
6 159
2 198
7 66
4 133
7 57
3 53
6 41
2 90
1 184
1 119
6 117
4 134
5 192
2 113
2 73
4 160
7 176
2 182
3 189
4 120
4 58
6 31
2 65
3 117
4 67
2 116
2 52
5 178
3 83
1 116
7 31
7 109
1 119
6 37
5 37
4 110
7 105
4 107
4 180
7 158
1 64
1 80
3 198
6 110
2 79
5 38
2 114
7 180
5 124
7 165
4 120
3 30
6 104
1 71
5 153
5 52
6 89
2 73
5 200
7 56
4 105
1 172
2 75
4 104
4 71
1 78
4 145
7 57
7 136
7 37
5 122
4 80
3 188
3 115
7 146
2 128
6 176
2 98
6 99
3 150
7 44
1 127
1 87
6 129
4 39
4 63
5 157
6 163
4 115
1 150
3 64
4 162
3 100
4 189
5 138
2 115
5 119
2 160
5 126
4 82
4 151
5 99
5 179
2 147
6 109
2 42
4 31
3 187
3 110
1 152
4 139
3 142
5 135
6 35
3 152
7 60
4 161
5 175
5 54
7 153
5 35
1 58
5 38
7 121
3 182
2 42
3 57
3 95
1 71
1 114
1 78
7 46
6 119
3 140
3 156
7 120
5 74
1 92
1 192
7 132
1 156
2 117
6 127
4 36
5 62
7 109
1 54
1 143
4 41
5 167
6 79
1 52
4 80
7 151
3 192
5 134
7 186
6 31
6 197
5 186
7 52
3 183
5 149
7 130
4 78
7 145
6 76
7 158
5 181
3 137
7 95
2 170
1 104
3 66
6 192
4 115
6 120
5 99
4 128
6 88
1 60
3 49
7 156
6 199
2 110
6 86
2 160
6 161
2 82
1 186
3 40
1 124
6 124
6 107
3 64
4 83
4 32
5 156
5 179
5 159
6 130
6 142
7 102
3 191
4 145
5 35
7 131
6 109
2 134
6 115
3 163
6 173
6 98
1 104
3 86
5 148
1 34
7 194
6 115
2 98
2 45
3 118
6 92
6 75
2 156
3 157
7 181
2 151
6 93
6 187
2 113
6 67
4 180
2 193
3 57
7 33
2 156
6 196
3 181
5 111
3 83
3 94
2 91
3 134
6 171
1 33
5 81
3 39
3 50
2 183
6 181
7 121
7 31
1 101
2 148
4 127
6 138
4 179
3 172
2 132
5 30
6 136
2 163
5 174
1 161
2 86
4 160
4 109
2 112
7 96
2 60
1 129
4 129
2 151
7 46
7 186
6 90
4 32
6 191
1 102
7 113
5 112
1 199
4 162
4 169
3 91
6 68
7 156
1 163
1 128
4 178
6 84
5 102
7 157
7 83
4 183
5 76
4 95
7 99
7 34
3 92
6 198
3 160
7 196
6 138
2 148
1 91
7 76
5 192
2 30
6 96
6 83
3 30
4 142
3 96
3 187
1 92
6 158
4 142
5 175
3 176
1 72
7 165
7 131
5 195
6 77
7 84
3 193
6 71
3 67
2 114
4 39
2 164
6 188
5 169
2 139
7 170
7 88
6 79
7 151
7 153
3 127
5 125
6 189
7 131
6 69
2 56
5 70
4 44
3 45
4 151
7 32
5 122
6 82
6 144
1 62
5 158
1 42
2 96
7 187
3 57
6 148
1 181
2 149
3 40
3 46
4 171
3 45
7 77
6 49
5 36
4 65
6 76
4 91
2 59
3 88
3 145
2 38
7 165
5 69
7 151
4 57
3 81
2 34
6 176
7 105
4 116
6 70
5 143
6 186
3 41
4 97
5 117
5 160
5 152
6 119
4 61
6 161
2 96
3 199
2 173
5 68
4 99
6 37
7 81
4 175
5 102
3 93
4 192
6 198
5 100
6 168
7 140
2 72
6 75
7 171
4 159
3 33
5 176
6 40
7 177
5 82
7 86
2 198
6 168
5 160
2 37
5 37
2 80
2 125
7 139
4 77
1 78
4 91
5 125
3 159
6 178
4 141
3 95
6 63
3 110
6 98
3 115
3 180
7 85
3 153
3 165
5 53
7 156
3 143
2 31
3 37
2 175
7 64
7 163
7 159
1 109
5 176
5 77
4 40
6 120
5 101
3 56
6 60
6 127
6 137
7 174
2 145
5 169
5 46
4 104
1 132
4 140
4 54
4 179
2 32
2 56
4 59
1 199
7 40
6 87
2 39
2 96
1 167
6 135
7 97
7 153
4 99
6 179
4 81
4 86
2 33
7 135
2 104
7 193
6 33
4 45
7 125
7 76
3 175
3 94
1 112
3 108
5 169
1 93
4 157
4 104
6 139
4 196
1 92
1 105
4 174
4 189
1 88
1 93
4 98
1 71
4 54
7 72
3 70
2 141
5 151
7 162
4 188
3 106
3 156
5 121
6 91
7 63
4 70
2 116
4 115
4 31
7 78
6 181
7 160
6 88
4 70
3 90
5 105
5 176
2 66
6 178
6 177
5 166
4 126
3 40
6 35
2 161
7 34
5 142
5 151
3 197
2 74
5 104
2 90
2 193
1 148
4 63
6 60
3 192
5 139
5 126
4 98
1 199
5 195
7 180
5 194
6 136
7 167
7 101
7 72
3 84
1 79
6 88
3 132
1 103
3 107
4 93
4 41
1 152
1 67
5 73
5 57
6 151
7 50
7 125
5 117
7 135
5 56
6 56
2 69
2 115
1 53
1 52
3 92
2 115
4 102
4 113
5 46
2 43
3 167
6 35
7 114
4 54
7 105
5 97
5 74
4 159
2 157
4 127
2 121
7 72
6 117
5 76
5 183
4 87
6 43
5 55
5 38
7 54
5 106
5 193
5 52
6 177
5 151
4 194
1 102
3 200
4 37
7 172
2 46
6 105
1 117
2 133
3 184
6 134
2 106
1 119
4 69
5 73
3 177
1 52
4 146
2 155
5 39
1 72
7 108
7 178
4 57
4 112
4 129
6 178
1 174
7 132
4 148
4 194
2 155
3 40
6 65
6 36
4 73
2 196
7 100
1 113
7 139
3 100
5 90
2 106
1 104
1 42
3 127
2 45
7 142
2 187
1 179
7 163
1 58
6 92
7 120
4 110
6 185
5 103
7 44
7 183
5 44
5 77
5 40
7 92
7 177
6 59
2 172
7 70
5 149
4 110
4 132
1 119
2 133
3 58
3 195
7 153
7 152
3 61
1 75
3 110
1 194
1 177
5 181
1 131
3 112
5 184
6 177
1 171
4 152
1 165
1 194
5 141
7 121
5 77
6 130
2 73
7 195
2 89
6 183
4 181
2 82
7 84
6 100
3 135
6 34
2 192
3 187
2 112
7 129
3 183
1 178
1 180
7 180
3 152
3 62
2 89
7 146
6 165
6 35
5 142
2 92
7 84
5 176
5 76
1 117
3 38
1 75
4 152
6 137
5 56
4 171
4 65
3 93
5 83
6 38
2 35
5 111
1 150
5 188
1 49
1 145
2 65
5 96
2 147
3 165
2 182
4 84
5 167
1 121
1 53
3 89
2 31
4 153
6 161
6 139
3 167
3 53
4 117
7 180
3 38
5 120
5 119
7 165
2 130
3 113
3 199
2 34
5 102
3 183
1 121
7 62
2 143
6 148
2 137
2 127
1 184
6 182
5 159
6 169
7 73
1 197
5 51
4 190
7 70
4 48
1 182
4 123
1 67
7 188
5 106
7 184
4 109
5 170
2 174
4 88
6 99
5 36
3 82
7 109
2 153
4 128
3 152
7 49
7 129
5 38
1 139
6 190
1 151
6 97
3 75
6 95
2 56
7 103
2 116
2 138
4 91
5 179
6 158
6 56
4 113
4 46
7 117
6 162
4 71
4 150
4 170
3 104
3 127
7 146
4 178
6 121
5 51
1 188
4 192
1 153
5 197
2 151
6 95
5 53
3 94
1 190
5 31
1 144
6 109
5 109
2 200
3 131
2 35
7 117
6 156
1 151
6 175
7 68
6 33
2 86
3 59
3 49
6 108
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest4.txt
================================================
1000 1500
6 152
3 34
1 151
6 198
5 126
7 133
2 167
6 114
7 165
2 144
7 55
1 50
7 174
6 98
1 151
7 87
4 37
2 195
5 45
1 127
1 92
1 169
1 36
3 171
1 131
2 128
7 137
6 58
3 162
3 170
3 174
6 113
2 179
5 151
7 30
3 152
3 162
1 148
6 157
7 70
4 58
6 181
4 100
4 134
5 193
2 39
3 152
6 139
3 182
4 40
2 157
7 117
6 70
5 36
5 94
2 81
3 103
4 140
1 110
6 31
6 35
5 171
4 136
2 46
1 41
3 31
7 40
4 130
4 57
2 164
2 144
6 155
5 79
4 188
6 167
1 193
7 64
2 92
4 68
4 149
3 62
1 111
1 181
2 196
3 67
7 94
7 49
5 185
7 84
5 150
4 126
2 86
2 107
5 177
2 153
5 127
4 179
7 74
7 142
5 167
2 132
3 99
2 188
2 58
3 69
1 133
3 51
4 167
1 77
7 182
2 55
2 60
3 57
7 66
3 104
2 161
1 81
6 108
7 44
6 150
1 195
7 44
7 85
4 67
2 171
7 136
3 50
2 129
6 119
3 157
7 79
3 143
4 80
6 61
2 52
1 172
4 62
3 101
3 83
6 164
4 168
6 74
1 106
3 75
3 115
6 122
3 134
2 54
5 145
6 73
6 40
7 112
3 97
6 129
1 107
1 180
2 35
6 40
2 200
4 77
5 127
2 119
7 90
1 71
3 149
2 120
4 132
5 119
5 136
7 115
5 123
5 161
5 155
2 69
7 169
4 80
2 167
5 68
2 79
6 154
7 146
4 151
2 174
1 165
4 63
3 169
7 136
3 120
4 182
4 96
1 118
7 63
3 163
3 190
6 90
6 117
5 157
6 87
7 149
6 125
6 135
2 145
7 110
2 148
4 35
2 50
7 200
5 77
2 44
6 97
7 187
2 100
1 127
6 34
2 57
1 44
5 146
2 67
3 72
3 172
3 160
6 139
3 64
3 76
7 179
5 143
6 56
3 55
4 114
6 139
6 97
2 142
2 187
1 53
6 30
5 131
3 197
2 113
2 191
2 42
4 112
6 175
4 44
2 89
5 77
5 64
7 65
6 80
1 164
7 46
1 36
1 59
5 116
6 111
4 68
7 151
5 147
2 49
7 91
4 69
3 68
5 155
5 122
6 89
7 200
6 92
7 31
3 99
6 45
1 152
6 102
3 132
5 163
3 166
7 64
1 135
1 154
4 158
1 71
4 121
4 60
5 119
7 135
5 100
6 160
6 44
6 66
3 45
1 73
4 64
1 37
5 89
2 74
1 164
5 189
3 185
3 127
3 177
7 127
7 196
4 99
5 195
7 62
3 74
5 110
1 137
1 114
2 75
2 67
4 189
5 41
3 114
3 193
5 62
3 33
1 100
7 110
3 150
3 121
6 36
5 174
3 120
6 139
2 192
5 74
1 161
2 168
2 135
1 173
5 147
5 59
5 35
3 108
1 45
2 64
2 99
3 63
3 176
4 119
2 171
5 135
4 132
3 128
4 38
3 146
7 182
7 177
3 36
1 128
2 143
1 159
1 46
6 40
5 30
5 71
5 140
5 100
3 165
5 86
1 144
4 184
2 30
7 54
6 148
5 172
4 133
6 147
1 200
2 58
7 85
5 32
2 198
2 163
6 53
7 44
7 33
6 110
1 187
4 127
2 196
1 131
3 119
6 179
6 148
1 44
4 194
4 84
2 80
6 155
5 113
6 175
2 89
3 113
2 34
6 60
3 133
2 136
3 103
4 63
1 94
5 37
1 134
3 92
6 194
3 163
2 148
4 199
3 138
7 49
2 57
7 166
5 176
7 154
2 68
4 186
6 95
4 175
3 90
3 124
1 45
4 197
6 131
5 55
5 68
3 33
2 111
7 40
7 41
7 61
3 54
3 180
5 138
7 134
3 39
4 124
4 160
6 40
7 154
5 96
2 31
3 88
7 190
7 197
3 133
5 184
6 36
3 43
4 45
3 49
6 192
1 59
4 59
4 105
1 192
2 145
4 55
5 191
4 30
3 139
7 97
3 112
4 39
6 182
4 70
7 187
7 133
6 92
2 157
6 79
2 33
7 118
5 176
5 102
3 138
6 115
7 195
3 74
5 118
2 200
1 135
7 73
2 126
4 161
3 144
4 99
5 87
6 33
6 56
1 104
7 119
5 195
2 190
4 184
2 130
5 129
5 153
1 104
1 140
3 64
2 187
3 91
2 149
7 44
3 39
1 156
7 178
2 55
3 74
4 166
7 149
3 45
2 86
5 35
4 76
1 58
7 140
1 132
3 114
6 145
4 161
2 79
1 75
4 74
1 180
1 178
7 194
4 119
2 157
5 118
2 62
5 136
4 43
4 62
1 44
5 115
3 88
5 48
6 52
1 111
3 34
3 83
1 67
1 119
7 55
1 156
4 177
7 192
5 126
4 143
4 82
5 65
7 191
4 93
5 93
2 88
7 121
6 112
2 58
2 197
3 65
6 104
1 196
7 191
3 122
6 59
4 186
6 198
5 94
4 60
4 41
7 175
1 179
7 150
1 200
3 111
7 90
2 144
6 73
4 57
1 136
6 173
7 132
6 152
4 132
3 59
6 46
2 129
7 40
6 92
1 139
6 120
6 156
5 134
3 181
1 114
2 192
2 175
7 149
4 145
1 71
3 128
7 154
7 91
4 179
4 196
3 191
6 94
4 168
7 197
4 142
5 117
4 171
2 141
7 86
3 173
2 188
5 170
4 60
3 173
2 156
1 105
1 43
4 156
3 66
3 103
6 56
1 106
5 38
5 59
3 76
5 121
6 199
2 141
4 198
2 32
3 108
1 128
1 175
4 42
2 126
4 136
3 63
4 80
2 80
2 83
2 75
2 153
3 63
3 193
5 164
3 44
1 171
7 106
4 196
2 199
3 108
5 89
1 105
2 117
3 78
2 45
5 100
2 51
6 30
2 82
1 133
1 157
7 107
6 178
4 173
4 161
4 194
5 197
1 178
3 133
4 165
4 125
6 179
2 158
3 163
2 75
3 60
7 68
5 100
4 68
3 112
6 192
5 36
4 166
6 200
1 120
7 200
4 111
3 99
2 125
7 31
1 56
6 72
7 60
7 30
2 41
2 164
7 77
1 146
5 129
7 67
7 156
2 167
6 184
3 174
2 179
1 161
1 64
1 168
7 200
5 104
1 73
4 197
5 154
6 82
2 122
2 190
4 115
1 94
3 140
4 174
4 61
2 140
1 145
6 89
1 155
6 124
2 91
7 106
2 78
3 100
5 154
6 60
4 155
5 162
6 166
5 108
5 90
5 187
6 173
7 65
3 149
7 188
7 100
2 73
4 94
1 91
5 194
6 123
5 198
7 154
3 100
5 176
7 186
2 159
6 50
2 174
4 80
1 83
7 178
6 191
2 194
1 142
7 80
5 147
7 171
2 94
3 160
3 35
6 193
5 165
6 97
5 90
2 139
5 142
6 108
1 143
3 70
2 47
2 179
6 151
4 96
6 31
4 130
4 192
3 115
5 44
5 33
5 110
3 57
4 105
7 45
2 107
5 174
4 57
1 108
6 90
1 46
6 116
6 56
1 151
7 43
3 138
1 57
1 124
2 94
6 98
3 168
6 97
2 94
6 64
3 158
6 124
4 121
1 183
2 96
2 155
4 155
5 116
3 123
4 79
2 132
4 98
5 65
6 131
1 160
6 172
7 145
3 44
2 181
3 33
7 178
4 190
7 34
7 161
5 69
1 37
1 138
4 42
5 112
4 101
2 187
7 167
3 177
1 192
6 90
2 177
2 56
4 34
6 136
7 108
1 54
3 185
1 173
1 77
5 116
5 89
5 36
2 161
7 63
7 42
6 180
3 193
6 109
7 79
7 192
5 51
1 181
6 165
5 115
5 59
4 195
3 113
1 52
7 94
6 59
6 41
1 56
3 151
5 146
7 92
6 30
7 59
2 102
4 33
5 114
7 110
3 78
3 144
5 175
2 87
1 162
3 185
7 173
5 40
6 66
3 148
4 184
6 139
5 172
5 103
5 162
3 171
6 61
1 131
6 185
2 50
7 104
1 80
4 52
7 36
2 106
3 172
4 172
2 76
7 50
4 121
6 63
3 94
2 97
4 119
2 161
7 78
5 86
6 86
7 167
4 58
2 145
2 190
2 113
5 125
1 198
4 81
1 155
4 113
4 75
1 143
2 143
5 187
6 184
6 134
2 141
5 130
5 58
5 180
2 174
7 176
3 188
5 57
7 53
3 56
4 53
7 183
7 160
2 170
6 185
5 42
4 124
6 182
7 197
4 96
4 125
7 159
6 79
6 172
7 58
6 145
7 107
3 115
2 139
5 134
3 135
6 65
5 119
2 88
2 71
3 104
7 172
5 84
7 105
1 89
7 107
6 44
7 33
1 97
2 35
3 132
4 36
6 63
1 178
4 160
3 35
5 152
7 117
3 47
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest5.txt
================================================
1000 3000
2 172
1 74
2 95
3 160
1 41
1 41
4 98
2 131
2 52
7 195
5 129
5 122
7 171
3 71
3 89
2 73
4 52
2 128
7 179
3 113
6 199
6 187
3 164
6 77
7 200
6 127
5 184
1 98
2 104
7 129
4 128
6 111
6 110
6 186
7 145
2 110
1 190
4 57
4 169
2 169
2 33
1 99
1 154
3 176
4 69
1 117
7 33
1 53
6 152
3 72
7 104
2 38
2 101
2 128
2 101
5 151
3 115
7 117
6 94
3 128
2 65
5 30
6 30
4 151
6 175
5 45
6 75
6 55
1 69
5 41
1 88
6 89
6 115
2 114
2 153
6 77
5 182
2 91
6 49
4 140
6 107
6 106
6 154
4 50
6 139
6 93
1 34
1 168
1 107
5 76
4 72
1 126
4 180
4 126
5 77
3 124
5 131
5 58
7 91
3 164
3 183
4 133
1 165
3 75
5 104
1 74
5 162
6 86
7 190
5 93
3 137
1 97
5 86
4 195
1 159
1 200
2 64
3 142
3 109
6 166
7 98
6 155
4 186
4 75
3 199
2 100
7 97
6 130
7 165
6 141
5 72
3 130
4 67
5 146
6 101
5 90
2 60
2 181
5 41
1 43
5 118
3 85
2 94
2 57
3 59
2 114
5 113
5 152
1 83
7 139
5 169
2 45
2 158
5 62
7 75
7 107
1 65
7 189
3 109
1 165
5 116
6 161
2 137
6 193
4 143
7 80
5 132
1 98
6 92
3 173
5 131
1 174
2 41
6 76
7 65
3 135
2 56
5 134
5 70
2 194
3 38
3 57
4 57
6 162
7 90
1 116
6 190
5 119
4 114
4 185
4 52
3 162
6 60
3 118
7 155
7 51
6 114
2 95
6 111
6 139
4 149
7 98
3 40
2 79
2 109
3 125
3 63
4 87
4 76
2 62
4 131
1 32
6 174
7 91
3 60
1 171
3 107
2 167
4 171
4 41
6 118
4 101
2 103
7 153
4 127
6 128
2 54
7 180
7 118
1 147
5 79
2 72
3 140
5 128
4 36
4 157
2 125
4 196
2 71
3 197
3 179
1 52
2 195
5 196
4 85
3 89
5 140
5 70
2 41
3 124
7 76
1 59
1 98
4 34
3 46
2 126
7 90
6 67
6 63
6 81
2 103
3 34
7 55
1 180
7 112
3 80
6 40
1 127
3 86
4 40
2 176
1 119
4 149
3 122
2 189
6 186
2 189
6 137
3 75
5 112
3 83
1 35
1 199
3 66
7 117
5 190
4 40
5 106
3 37
3 136
6 156
3 150
3 57
3 59
7 122
1 184
7 35
1 77
4 83
1 139
5 135
6 170
4 200
5 197
1 30
7 168
3 97
2 105
7 162
3 182
3 69
7 156
5 106
4 146
7 34
3 172
4 31
7 145
5 31
2 86
4 136
2 106
7 37
7 71
2 104
4 55
5 63
7 79
5 72
6 35
5 83
3 40
5 40
5 193
2 154
3 183
5 62
6 80
7 34
4 73
4 165
2 116
3 174
6 77
7 157
7 127
3 114
6 78
2 184
4 50
5 73
4 76
5 138
7 51
2 75
1 182
3 164
4 77
4 73
2 189
7 108
3 128
4 92
7 40
2 82
1 132
5 186
6 108
7 104
7 137
2 36
6 111
7 131
3 145
7 112
4 146
2 119
1 49
7 194
3 47
5 38
2 92
6 162
5 100
5 56
6 182
1 186
6 139
4 137
3 47
7 105
6 175
1 39
5 57
6 90
4 105
1 153
7 55
3 50
1 181
2 39
3 138
5 163
6 36
7 130
6 42
3 147
1 48
3 93
2 71
2 158
3 58
4 48
5 31
5 148
6 68
6 151
4 180
1 105
2 185
3 140
4 138
7 57
3 79
3 190
4 135
6 135
5 62
1 127
7 49
3 46
5 144
2 53
4 62
4 44
7 88
6 91
2 190
1 194
4 195
5 102
5 101
1 75
5 57
2 108
6 134
6 195
1 94
1 185
7 110
6 107
1 51
5 151
7 94
3 101
5 179
6 58
6 126
2 128
3 49
6 109
2 121
2 64
2 145
3 153
5 61
5 75
7 60
7 33
1 72
7 86
6 122
7 172
3 153
2 160
4 140
1 173
3 121
6 49
4 101
6 117
2 38
3 107
5 115
5 147
1 173
5 66
4 198
5 124
6 80
6 79
2 91
3 126
2 38
1 111
6 196
1 187
1 114
6 105
4 126
4 150
4 61
6 86
3 33
6 136
6 39
2 118
2 91
7 101
6 93
1 39
6 121
1 168
5 71
5 61
2 115
5 64
3 151
6 197
5 174
1 100
6 185
5 137
6 41
7 105
6 146
3 45
4 52
7 79
2 141
7 145
1 65
4 107
6 66
7 81
4 157
3 198
6 80
2 72
7 116
7 102
3 148
1 109
5 141
2 148
3 125
3 145
5 44
2 167
4 196
1 166
1 133
7 173
5 166
1 65
4 31
1 72
4 174
5 36
2 70
5 42
3 148
7 193
3 38
6 143
7 175
4 90
5 91
3 172
3 183
5 146
5 165
3 64
3 186
4 87
2 199
5 127
1 53
3 184
3 137
2 38
1 191
5 39
1 110
1 156
3 139
4 35
7 190
6 41
1 159
7 31
7 152
5 129
6 135
6 118
2 168
5 160
5 187
5 171
6 140
3 172
5 190
5 149
3 83
5 176
2 165
1 43
2 169
4 138
5 194
7 197
2 111
4 101
2 157
5 94
4 169
3 189
5 174
5 168
3 193
2 148
4 128
7 135
7 198
3 76
6 106
3 128
2 74
6 62
2 192
2 70
4 30
7 180
1 94
4 80
4 149
4 170
1 164
4 101
7 190
4 118
3 137
4 40
2 84
4 172
3 75
4 90
2 102
1 152
5 192
5 57
6 77
4 147
5 131
1 96
6 41
5 31
3 112
6 176
6 187
6 55
4 103
3 101
1 114
3 79
7 34
7 191
1 153
5 185
5 170
6 69
2 89
5 174
6 88
4 121
1 115
6 34
1 46
5 123
7 143
5 95
4 166
7 159
3 118
1 61
7 46
7 127
2 56
7 52
2 31
6 167
1 78
4 102
4 94
2 72
5 95
1 107
6 147
1 34
6 84
5 129
5 151
6 126
1 130
5 112
7 154
1 109
4 37
7 62
6 136
6 94
3 173
7 128
2 68
2 83
2 125
7 102
4 138
2 46
7 72
4 52
6 43
5 172
4 134
6 98
1 49
1 172
1 199
4 113
1 168
4 180
7 142
7 101
3 86
6 153
7 70
2 103
2 102
3 40
1 194
7 67
4 131
4 108
3 103
1 41
7 152
7 80
2 85
3 147
4 176
4 143
1 81
1 67
7 54
7 153
5 107
3 197
6 33
4 78
3 88
3 94
4 72
1 192
6 68
1 67
4 129
7 78
3 114
6 141
4 93
2 58
2 91
4 134
2 32
3 35
4 100
4 64
3 131
1 50
5 76
5 46
5 70
4 75
1 103
7 36
3 193
6 135
3 103
1 165
3 143
7 177
3 141
3 76
5 100
2 54
5 84
3 48
2 183
4 136
7 161
6 106
2 91
3 165
6 134
6 67
6 183
3 144
6 47
4 185
2 123
3 131
2 76
7 37
7 33
6 165
6 152
1 165
3 112
7 156
6 87
1 157
6 171
2 124
6 79
2 144
2 126
6 140
6 163
5 76
6 96
4 197
6 51
7 30
4 92
2 165
7 126
7 169
6 160
7 118
2 98
3 42
3 55
1 191
6 74
1 108
4 52
2 124
6 159
5 99
3 129
1 83
4 82
5 32
6 122
4 123
1 167
1 82
4 81
3 146
2 107
6 169
3 98
4 102
5 185
2 118
4 120
7 113
2 55
6 138
4 191
1 142
5 77
6 171
1 189
3 130
1 106
2 117
1 141
3 199
7 52
2 129
4 32
4 186
1 166
1 114
4 193
7 50
3 30
6 103
5 122
3 189
5 128
5 171
1 145
3 83
2 129
4 64
6 62
5 103
1 193
4 183
2 175
6 104
1 48
3 163
5 180
7 170
2 50
1 31
4 137
2 172
1 144
1 174
7 35
7 165
3 151
1 193
2 176
1 72
4 146
1 188
7 37
4 147
2 79
2 135
6 111
2 73
5 174
5 119
6 87
4 41
1 45
7 34
5 150
6 53
3 116
2 59
1 109
1 192
5 71
1 36
5 103
5 113
1 87
1 31
2 155
2 31
1 137
7 130
1 125
7 134
6 129
7 148
3 31
3 36
6 91
2 152
6 39
7 98
7 33
6 146
6 122
3 82
2 95
1 114
1 152
4 169
3 178
1 165
4 140
3 39
4 169
5 74
7 49
4 117
3 144
3 144
5 60
5 161
5 177
3 160
4 49
3 122
7 118
6 78
7 194
5 74
1 92
6 59
2 79
5 146
5 30
2 59
7 126
7 143
4 46
3 194
1 129
5 126
7 145
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test01_03.txt
================================================
26 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
1 15
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test02_03.txt
================================================
26 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
2 30
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test03.1_03.txt
================================================
26 47
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
2 30
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test03_03.txt
================================================
26 46
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
2 30
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test04_03.txt
================================================
26 46
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 44
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
2 30
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test05_03.txt
================================================
25 46
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 61
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/run_commands.sh
================================================
#!/bin/sh
WARMUP=50
RUNS=100
SUM_MEANS=0
FILE_COUNT=0
MFNL=0 # Max FileName Length Start
for file in examples/*
do
filename=$(basename "$file")
len=$(echo -n "$filename" | wc -c)
if [ "$len" -gt "$MFNL" ]; then
MFNL=$len
fi
done
# Build the project
cargo build --release --quiet
export BC_LINE_LENGTH=0
clear
echo -e "\n\nRodará um (Hyperfine) Benchmark de $RUNS runs para cada arquivo"
echo -e "Depois pego as médias numa jq, e calculo ao final a soma das médias"
echo -e "Isso foi feito para facilitar a execução e visualização dos resultados\n\n"
printf "%-${MFNL}s %s \t %s \n" "FileName" "Respostas" "Runtime"
for file in examples/*
do
result=$(hyperfine --warmup "$WARMUP" --runs "$RUNS" "./target/release/problema_1 $file" --export-json /tmp/hyperfine_results.json 2>/dev/null)
output=$(./target/release/problema_1 "$file")
filename=$(basename "$file")
mean=$(jq -r '.results | .[0].mean' /tmp/hyperfine_results.json)
formatted_mean=$(echo "$mean" | awk '{printf "%.9f", $1}')
SUM_MEANS=$(awk "BEGIN {print $SUM_MEANS + $formatted_mean}")
FILE_COUNT=$((FILE_COUNT + 1))
printf "%-${MFNL}s $output \t $formatted_mean s\n" "$filename"
done
AVERAGE_MEAN=$(echo "scale=9; $SUM_MEANS / $FILE_COUNT" | bc)
TOTAL_RUNTIME=$(printf "%.9f" "$SUM_MEANS")
AVERAGE_MEAN=$(printf "%.9f" "$AVERAGE_MEAN")
echo -e "\nTotal Runtime: \t\t $TOTAL_RUNTIME s\n"
echo -e "\nAvarage Runtime: \t\t $AVERAGE_MEAN s\n\n"
================================================
FILE: submissions/gabrielng-rj99/Problema_1/Rust/src/main.rs
================================================
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn knapsack(space: i64, array: &[(i64, i64, f64)]) -> i64 {
let n = array.len();
let mut dp = vec![0; (space + 1) as usize];
for i in 0..n {
let (wi, vi, _) = array[i];
for j in (wi..=space).rev() {
dp[j as usize] = dp[j as usize].max(vi + dp[(j - wi) as usize]);
}
}
dp[space as usize]
}
fn execute_algorithm(file_path: &str) -> i64 {
let file = File::open(file_path).unwrap();
let reader = BufReader::new(file);
let mut lines = reader.lines();
let first_line = lines.next().unwrap().unwrap();
let mut values = first_line.split_whitespace().map(|x| x.parse::<i64>().unwrap());
let _n = values.next().unwrap();
let w = values.next().unwrap();
let mut file_array = Vec::new();
for line in lines {
let mut row: Vec<f64> = line.unwrap()
.split_whitespace()
.map(|x| x.parse::<f64>().unwrap())
.collect();
let ratio = row[1] / row[0];
row.push(ratio);
file_array.push((row[0] as i64, row[1] as i64, ratio));
}
knapsack(w, &file_array)
}
fn main() {
let args: Vec<String> = env::args().collect();
let file_path = &args[1];
println!("{:>10}", execute_algorithm(file_path));
}
================================================
FILE: submissions/gabrielng-rj99/Problema_2/Python/Dockerfile
================================================
FROM python:3.11.7-alpine3.18
# Install the hyperfine package and networkx
RUN apk --no-cache add hyperfine jq \
&& pip install networkx==3.2
WORKDIR /app
COPY . /app
# Make the script executable
RUN chmod +x /app/runtime.sh
# Run the script as the default command
CMD ["/app/runtime.sh"]
================================================
FILE: submissions/gabrielng-rj99/Problema_2/Python/ReadMe.md
================================================
# Requisitos
- ***Docker***
# Como Rodar
### PowerShell(MS) *ou* Shell(Linux)
> Execute uma linha de cada vez no console, sempre esperando a anterior terminar de executar
`e não esqueça de escrever o "."`
1. Ir ao **diretório** do *Dockerfile*
- **PowerShell**/***Bash***
```PowerShell
cd Path/to/submissions/gabrielng-rj99/Problema_2/Python/
```
2. *Gerar* a **Imagem** do *Dockerfile*
- **PowerShell**/***Bash***
```PowerShell
docker build -t problem_2:gabrielng-rj99 .
```
3. *Gerar* um **conteiner** da *imagem* e rodá-lo
- **PowerShell**/***Bash***
```PowerShell
docker run --cpus=2 --memory=2g --name gng-rj99_p2 problem_2:gabrielng-rj99
```
- **Resultado Esperado(Print):**

4. Caso queira rodar o conteiner novamente (sem gerar num novo conteiner)
- **PowerShell**/***Bash***
```PowerShell
docker start -a gng-rj99_p2
```
### Para apagar os conteiners da imagem e a imagem:
#### 1. Parar todas os conteiners da imagem "*problem_2:gabrielng-rj99*"
---
- **PowerShell** `docker ps -aq --filter ancestor=problem_2:gabrielng-rj99 | ForEach-Object { docker stop $_ }`
- ***Bash*** `docker ps -a | grep problem_2:gabrielng-rj99 | awk '{print $1}' | xargs docker stop`
---
#### 2. Remover todas os conteiners da imagem "*problem_2:gabrielng-rj99*"
---
- **PowerShell** `docker ps -aq --filter ancestor=problem_2:gabrielng-rj99 | ForEach-Object { docker rm $_ }`
- ***Bash*** `docker ps -a | grep problem_2:gabrielng-rj99 | awk '{print $1}' | xargs docker rm`
---
#### 3. Remover a imagem criada
- **PowerShell**/***Bash***
```bash
docker rmi problem_2:gabrielng-rj99
```
# Notas:
1. Para timar facilmente os runtimes do dockerfile basta editar o Dockerfile "run_commands.sh" (nas linhas "RUN" e "CMD") para "runtime.sh" dependendo do método pra avaliar.
2. Sinta-se a vontade para alterar os parâmetros do benchmark como
WARMUP e RUNS no runtime.sh
### Rodar mais exemplos/arquivos
- basta colocar todos os arquivos na pasta "examples" abaixo **ANTES** de criar a **imagem** como na foto do **"*Resultado Esperado*"**
> Path / to /submissions/gabrielng-rj99/Problema_2/Python/examples
================================================
FILE: submissions/gabrielng-rj99/Problema_2/Python/examples/exemplo_01.txt
================================================
40 47
1 2
1 24
2 12
3 18
3 22
4 11
4 29
4 32
5 6
5 27
6 12
6 22
7 15
7 17
8 13
8 15
8 36
9 17
9 21
10 18
10 30
10 32
11 40
12 31
13 22
13 31
14 25
14 32
16 19
16 23
16 24
17 20
18 33
19 38
20 23
21 38
23 35
25 39
26 27
28 33
28 35
29 34
29 37
30 34
33 36
36 40
37 39
================================================
FILE: submissions/gabrielng-rj99/Problema_2/Python/examples/exemplo_02.txt
================================================
30 35
1 3
1 16
2 9
2 23
3 8
3 23
4 18
4 22
4 30
5 6
5 11
6 9
6 19
7 16
7 18
7 20
8 26
8 27
9 18
9 21
10 13
10 30
12 15
12 22
13 17
14 24
14 28
15 17
19 27
20 21
21 29
22 24
24 26
25 28
25 29
================================================
FILE: submissions/gabrielng-rj99/Problema_2/Python/examples/exemplo_03.txt
================================================
30 218
1 3
1 8
1 9
1 11
1 12
1 13
1 14
1 16
1 18
1 20
1 22
1 24
1 26
1 27
1 28
2 8
2 9
2 11
2 12
2 14
2 15
2 19
2 22
2 26
2 29
3 7
3 9
3 10
3 11
3 12
3 14
3 20
3 22
3 23
3 27
3 29
3 30
4 9
4 10
4 11
4 12
4 14
4 16
4 18
4 19
4 21
4 23
4 25
4 29
4 30
5 6
5 9
5 11
5 13
5 14
5 15
5 16
5 17
5 22
5 23
5 24
5 28
5 29
6 8
6 9
6 13
6 14
6 17
6 18
6 19
6 21
6 26
6 29
7 9
7 10
7 11
7 12
7 13
7 17
7 18
7 20
7 22
7 25
8 9
8 12
8 16
8 17
8 21
8 22
8 24
8 26
8 28
8 30
9 11
9 12
9 14
9 18
9 21
9 22
9 23
9 24
9 27
9 28
9 30
10 11
10 12
10 15
10 18
10 20
10 21
10 22
10 27
10 28
10 30
11 12
11 14
11 15
11 16
11 17
11 18
11 19
11 21
11 22
11 23
11 27
11 28
12 13
12 15
12 16
12 20
12 21
12 22
12 23
12 25
12 27
12 29
13 15
13 17
13 19
13 20
13 22
13 23
13 24
13 27
13 28
13 29
13 30
14 15
14 16
14 21
14 22
14 24
14 25
14 27
15 16
15 17
15 18
15 19
15 20
15 23
15 24
15 28
15 29
16 17
16 18
16 19
16 20
16 23
16 24
16 25
16 27
16 28
16 29
17 21
17 22
17 23
17 24
17 28
18 19
18 24
18 25
18 30
19 20
19 22
19 24
19 25
19 29
19 30
20 21
20 22
20 26
20 29
20 30
21 22
21 23
21 24
21 26
21 28
21 30
22 24
22 26
22 27
22 28
23 24
23 28
24 25
24 27
24 28
25 26
25 27
25 30
26 28
26 29
26 30
27 29
27 30
28 29
29 30
================================================
FILE: submissions/gabrielng-rj99/Problema_2/Python/problema-2.py
================================================
import networkx as nx
import sys
G = nx.Graph()
edges_count = {}
ans = 0
def count_edges(N, edges):
global edges_count
edges_count = {node: 0 for node in range(1, N + 1)}
for edge in edges:
for node in edge:
edges_count[node] += 1
def add_ans():
global ans, edges_count
for node in edges_count:
if edges_count[node] == 1:
ans += 1
def open_edges_file(file_path):
with open(file_path, 'r') as file:
_N, W = map(int, file.readline().split())
file_array = []
for line in file:
row = tuple(map(int, line.split()))
file_array.append(row)
return _N, W, file_array
def roots_leaves_from(cycle: list):
global edges_count
roots = []
leaves = []
for node in cycle:
if not roots:
roots = [node]
elif edges_count[node] > edges_count[roots[0]]:
roots = [node]
elif edges_count[node] == edges_count[roots[0]]:
roots.append(node)
if not leaves:
leaves = [node]
elif edges_count[node] < edges_count[leaves[0]]:
leaves = [node]
elif edges_count[node] == edges_count[leaves[0]]:
leaves.append(node)
return roots, leaves
def is_connected(nodes: list):
global G
for node in nodes:
connections = list(G.neighbors(node))
for node_2 in connections:
if node_2 in nodes:
return True
return False
def leaves_connected_to_not_roots(leaves, roots, cycle):
global G
for leaf in leaves:
connections = list(G.neighbors(leaf))
for node in connections:
if node not in roots and node in cycle:
return True
return False
def erase_edge_from(cycle):
global G
roots, leaves = roots_leaves_from(cycle)[0], roots_leaves_from(cycle)[1]
if len(leaves) >= 2:
if is_connected(leaves):
for i in range(-1, len(leaves) - 1):
if G.has_edge(leaves[i], leaves[i + 1]):
G.remove_edge(leaves[i], leaves[i + 1])
edges_count[leaves[i]] -= 1
edges_count[leaves[i + 1]] -= 1
break
elif leaves_connected_to_not_roots(leaves, roots, cycle):
for i in range(-1, len(cycle) - 1):
c1 = cycle[i] in leaves
c2 = cycle[i + 1] in leaves
c3 = cycle[i] not in roots
c4 = cycle[i + 1] not in roots
check1 = all([c1, c4])
check2 = all([c2, c3])
if check1 or check2:
G.remove_edge(cycle[i], cycle[i + 1])
edges_count[cycle[i]] -= 1
edges_count[cycle[i + 1]] -= 1
break
else:
for i in range(-1, len(cycle) - 1):
check1 = cycle[i] in leaves
check2 = cycle[i + 1] in leaves
if check1 or check2:
# print("checkpoint 1.3.1")
G.remove_edge(cycle[i], cycle[i + 1])
edges_count[cycle[i]] -= 1
edges_count[cycle[i + 1]] -= 1
break
else:
if leaves_connected_to_not_roots(leaves, roots, cycle):
for i in range(-1, len(cycle) - 1):
c1 = cycle[i] in leaves
c2 = cycle[i + 1] in leaves
c3 = cycle[i] not in roots
c4 = cycle[i + 1] not in roots
check1 = c1 or c2
check2 = c3 or c4
if check1 and check2:
G.remove_edge(cycle[i], cycle[i + 1])
edges_count[cycle[i]] -= 1
edges_count[cycle[i + 1]] -= 1
break
else:
for i in range(-1, len(cycle) - 1):
check1 = cycle[i] in leaves
check2 = cycle[i + 1] in leaves
if check1 or check2:
G.remove_edge(cycle[i], cycle[i + 1])
edges_count[cycle[i]] -= 1
edges_count[cycle[i + 1]] -= 1
break
def find_cycle_starting_from(start_node):
global G
try:
cycle_edges = nx.find_cycle(G, source=start_node)
cycle_nodes = [u for u, _ in cycle_edges]
return cycle_nodes
except nx.NetworkXNoCycle:
return None
def break_all_cycles():
global G
start_node = max(edges_count, key=edges_count.get)
while nx.cycle_basis(G):
cycle = find_cycle_starting_from(start_node)
erase_edge_from(cycle)
def main(file_path):
global G, ans
N, _W, file_array = open_edges_file(file_path)
G.add_edges_from(file_array)
count_edges(N, file_array)
break_all_cycles()
add_ans()
return ans
if __name__ == '__main__':
file_path = sys.argv[1]
print(f"{main(file_path):>10}")
================================================
FILE: submissions/gabrielng-rj99/Problema_2/Python/run_commands.sh
================================================
#!/bin/sh
MFNL=0 # Max FileName Length Start
for file in examples/*
do
filename=$(basename $file)
len=$(echo -n "$filename" | wc -c)
if [ $len -gt $MFNL ]; then
MFNL=$len
fi
done
clear
printf "%-${MFNL}s %s \t \n" "FileName" "Respostas"
for file in examples/*
do
output=$(python problema-2.py $file)
filename=$(basename $file)
printf "%-${MFNL}s $output\n" "$filename"
done
================================================
FILE: submissions/gabrielng-rj99/Problema_2/Python/runtime.sh
================================================
#!/bin/sh
WARMUP=10
RUNS=10
SUM_MEANS=0
FILE_COUNT=0
MFNL=0 # Max FileName Length Start
for file in examples/*
do
filename=$(basename $file)
len=$(echo -n "$filename" | wc -c)
if [ $len -gt $MFNL ]; then
MFNL=$len
fi
done
clear
echo -e "\n\nRodará um (Hyperfine) Benchmark de $RUNS runs para cada arquivo"
echo -e "Depois pego as médias numa jq, e calculo ao final a soma das médias"
echo -e "Isso foi feito para facilitar a execução e visualização dos resultados\n\n"
printf "%-${MFNL}s %s \t %s \n" "FileName" "Respostas" "Runtime"
for file in examples/*
do
result=$(hyperfine --warmup $WARMUP --runs $RUNS "python problema-2.py $file" --export-json /tmp/hyperfine_results.json 2>/dev/null)
output=$(python problema-2.py $file)
filename=$(basename $file)
mean=$(jq -r '.results | .[0].mean' /tmp/hyperfine_results.json)
formatted_mean=$(printf "%.9f" $mean)
SUM_MEANS=$(echo "$SUM_MEANS + $mean" | bc)
FILE_COUNT=$((FILE_COUNT + 1))
printf "%-${MFNL}s $output \t $formatted_mean s\n" "$filename"
done
AVERAGE_MEAN=$(echo "scale=9; $SUM_MEANS / $FILE_COUNT" | bc)
TOTAL_RUNTIME=$(printf "%.9f" $SUM_MEANS)
AVERAGE_MEAN=$(printf "%.9f" $AVERAGE_MEAN)
echo -e "\nTotal Runtime: \t\t $TOTAL_RUNTIME s\n"
echo -e "\nAvarage Runtime: \t\t $AVERAGE_MEAN s\n\n"
================================================
FILE: submissions/gbpagano/Cargo.toml
================================================
[package]
name = "gbpagano"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
================================================
FILE: submissions/gbpagano/README.md
================================================
# Usage
run with cargo
```sh
cargo run --release -- {filepath}
```
example:
```sh
cargo run --release -- ../../resources/instances/problem_01/exemplo_01.txt
```
================================================
FILE: submissions/gbpagano/exemplo.txt
================================================
25 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
================================================
FILE: submissions/gbpagano/src/main.rs
================================================
use std::env;
use std::fs::File;
use std::io::{self, BufRead};
fn main() {
let args: Vec<_> = env::args().collect();
let file = File::open(&args[1]).unwrap();
let lines: Vec<_> = io::BufReader::new(file)
.lines()
.map(|line| line.unwrap())
.collect();
let capacity = lines[0]
.split_whitespace()
.nth(1)
.unwrap()
.parse::<usize>()
.unwrap();
let items: Vec<(usize, usize)> = lines[1..]
.iter()
.map(|line| {
let parts = line.split_whitespace().collect::<Vec<_>>();
(parts[0].parse().unwrap(), parts[1].parse().unwrap())
})
.collect();
let mut max_values = vec![0; capacity + 1];
for (weight, value) in items {
for w in (weight..=capacity).rev() {
max_values[w] = max_values[w].max(max_values[w - weight] + value);
}
}
println!("result: {}", max_values[capacity]);
}
================================================
FILE: submissions/gutogalego/Cargo.toml
================================================
[package]
name = "gutogalego"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
================================================
FILE: submissions/gutogalego/README.md
================================================
To run this, have rust installed, and run:
```
cargo run --release -- your_filename.txt
```
for example
```
cargo run --release -- ../../resources/instances/problem_01/exemplo_03.txt
```
================================================
FILE: submissions/gutogalego/src/main.rs
================================================
use std::env;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn knapsack(items: &[(usize, usize)], capacity: usize) -> usize {
let mut dp = vec![0; capacity + 1];
for &(weight, value) in items {
for w in (weight..=capacity).rev() {
dp[w] = std::cmp::max(dp[w], dp[w - weight] + value);
}
}
dp[capacity]
}
fn main() -> io::Result<()> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Usage: {} <filename>", args[0]);
std::process::exit(1);
}
let filename = &args[1];
let path = Path::new(filename);
let file = File::open(&path)?;
let lines: Vec<String> = io::BufReader::new(file).lines().filter_map(|line| line.ok()).collect();
let capacity: usize = lines[0].split_whitespace().nth(1).unwrap().parse().unwrap();
let items: Vec<(usize, usize)> = lines[1..]
.iter()
.map(|line| {
let parts: Vec<&str> = line.split_whitespace().collect();
let weight: usize = parts[0].parse().unwrap();
let value: usize = parts[1].parse().unwrap();
(weight, value)
})
.collect();
let max_value = knapsack(&items, capacity);
println!("Solution: {}", max_value);
Ok(())
}
================================================
FILE: submissions/gutogalego__2/Cargo.toml
================================================
[package]
name = "gutogalego__2"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
================================================
FILE: submissions/gutogalego__2/README.md
================================================
To run this, have rust installed, and run:
```
cargo run --release -- your_filename.txt
```
for example
```
cargo run --release -- ../../resources/instances/problem_01/exemplo_03.txt
```
================================================
FILE: submissions/gutogalego__2/src/main.rs
================================================
use std::env;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn main() -> io::Result<()> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Usage: {} <filename>", args[0]);
std::process::exit(1);
}
let filename = &args[1];
let path = Path::new(filename);
let file = File::open(&path)?;
let lines: Vec<String> = io::BufReader::new(file).lines().filter_map(|line| line.ok()).collect();
let capacity: usize = lines[0].split_whitespace().nth(1).unwrap().parse().unwrap();
let mut items: Vec<(usize, usize, f64)> = lines[1..]
.iter()
.map(|line| {
let parts: Vec<&str> = line.split_whitespace().collect();
let weight: usize = parts[0].parse().unwrap();
let value: usize = parts[1].parse().unwrap();
let ratio: f64 = value as f64 / weight as f64;
(weight, value, ratio)
})
.collect();
items.sort_by(|a, b| b.2.partial_cmp(&a.2).unwrap());
let mut max_value: f64 = 0.0;
let mut remaining_capacity = capacity;
for &(weight, value, _) in &items {
if weight <= remaining_capacity {
max_value += value as f64;
remaining_capacity -= weight;
} else {
max_value += value as f64 * (remaining_capacity as f64 / weight as f64);
break;
}
}
println!("Solution: {}", max_value);
Ok(())
}
================================================
FILE: submissions/gutogalego__3/Cargo.toml
================================================
[package]
name = "gutogalego__3"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
================================================
FILE: submissions/gutogalego__3/README.md
================================================
To run this, have rust installed, and run:
```
cargo run --release -- your_filename.txt
```
for example
```
cargo run --release -- ../../resources/instances/problem_01/exemplo_03.txt
```
================================================
FILE: submissions/gutogalego__3/src/main.rs
================================================
use std::env;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn main() -> io::Result<()> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("Usage: {} <filename>", args[0]);
std::process::exit(1);
}
let filename = &args[1];
let path = Path::new(filename);
let file = File::open(&path)?;
let lines: Vec<String> = io::BufReader::new(file).lines().filter_map(|line| line.ok()).collect();
let capacity: usize = lines[0].split_whitespace().nth(1).unwrap().parse().unwrap();
let items: Vec<(usize, usize)> = lines[1..]
.iter()
.map(|line| {
let parts: Vec<&str> = line.split_whitespace().collect();
let weight: usize = parts[0].parse().unwrap();
let value: usize = parts[1].parse().unwrap();
(weight, value)
})
.collect();
let mut max_value: f64 = 0.0;
let mut remaining_capacity = capacity;
for &(weight, value) in &items {
if weight <= remaining_capacity {
max_value += value as f64;
remaining_capacity -= weight;
} else {
max_value += value as f64 * (remaining_capacity as f64 / weight as f64);
break;
}
}
let adjusted_max_value = max_value * 1.33;
println!("Solution: {}", adjusted_max_value);
Ok(())
}
================================================
FILE: submissions/jaiaani/problema_01/.gitignore
================================================
/target
/classes
/checkouts
profiles.clj
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
/.prepl-port
.hgignore
.hg/
.DS*
================================================
FILE: submissions/jaiaani/problema_01/Dockerfile
================================================
FROM clojure:latest
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
COPY . /app
# Install additional dependencies using lein
RUN lein deps
# Build the Clojure application
RUN lein uberjar
CMD ["java", "-jar", "target/plantation-profit-0.1.0-SNAPSHOT-standalone.jar"]
================================================
FILE: submissions/jaiaani/problema_01/LICENSE
================================================
Eclipse Public License - v 2.0
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
1. DEFINITIONS
"Contribution" means:
a) in the case of the initial Contributor, the initial content
Distributed under this Agreement, and
b) in the case of each subsequent Contributor:
i) changes to the Program, and
ii) additions to the Program;
where such changes and/or additions to the Program originate from
and are Distributed by that particular Contributor. A Contribution
"originates" from a Contributor if it was added to the Program by
such Contributor itself or anyone acting on such Contributor's behalf.
Contributions do not include changes or additions to the Program that
are not Modified Works.
"Contributor" means any person or entity that Distributes the Program.
"Licensed Patents" mean patent claims licensable by a Contributor which
are necessarily infringed by the use or sale of its Contribution alone
or when combined with the Program.
"Program" means the Contributions Distributed in accordance with this
Agreement.
"Recipient" means anyone who receives the Program under this Agreement
or any Secondary License (as applicable), including Contributors.
"Derivative Works" shall mean any work, whether in Source Code or other
form, that is based on (or derived from) the Program and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship.
"Modified Works" shall mean any work in Source Code or other form that
results from an addition to, deletion from, or modification of the
contents of the Program, including, for purposes of clarity any new file
in Source Code form that contains any contents of the Program. Modified
Works shall not include works that contain only declarations,
interfaces, types, classes, structures, or files of the Program solely
in each case in order to link to, bind by name, or subclass the Program
or Modified Works thereof.
"Distribute" means the acts of a) distributing or b) making available
in any manner that enables the transfer of a copy.
"Source Code" means the form of a Program preferred for making
modifications, including but not limited to software source code,
documentation source, and configuration files.
"Secondary License" means either the GNU General Public License,
Version 2.0, or any later versions of that license, including any
exceptions or additional permissions as identified by the initial
Contributor.
2. GRANT OF RIGHTS
a) Subject to the terms of this Agreement, each Contributor hereby
grants Recipient a non-exclusive, worldwide, royalty-free copyright
license to reproduce, prepare Derivative Works of, publicly display,
publicly perform, Distribute and sublicense the Contribution of such
Contributor, if any, and such Derivative Works.
b) Subject to the terms of this Agreement, each Contributor hereby
grants Recipient a non-exclusive, worldwide, royalty-free patent
license under Licensed Patents to make, use, sell, offer to sell,
import and otherwise transfer the Contribution of such Contributor,
if any, in Source Code or other form. This patent license shall
apply to the combination of the Contribution and the Program if, at
the time the Contribution is added by the Contributor, such addition
of the Contribution causes such combination to be covered by the
Licensed Patents. The patent license shall not apply to any other
combinations which include the Contribution. No hardware per se is
licensed hereunder.
c) Recipient understands that although each Contributor grants the
licenses to its Contributions set forth herein, no assurances are
provided by any Contributor that the Program does not infringe the
patent or other intellectual property rights of any other entity.
Each Contributor disclaims any liability to Recipient for claims
brought by any other entity based on infringement of intellectual
property rights or otherwise. As a condition to exercising the
rights and licenses granted hereunder, each Recipient hereby
assumes sole responsibility to secure any other intellectual
property rights needed, if any. For example, if a third party
patent license is required to allow Recipient to Distribute the
Program, it is Recipient's responsibility to acquire that license
before distributing the Program.
d) Each Contributor represents that to its knowledge it has
sufficient copyright rights in its Contribution, if any, to grant
the copyright license set forth in this Agreement.
e) Notwithstanding the terms of any Secondary License, no
Contributor makes additional grants to any Recipient (other than
those set forth in this Agreement) as a result of such Recipient's
receipt of the Program under the terms of a Secondary License
(if permitted under the terms of Section 3).
3. REQUIREMENTS
3.1 If a Contributor Distributes the Program in any form, then:
a) the Program must also be made available as Source Code, in
accordance with section 3.2, and the Contributor must accompany
the Program with a statement that the Source Code for the Program
is available under this Agreement, and informs Recipients how to
obtain it in a reasonable manner on or through a medium customarily
used for software exchange; and
b) the Contributor may Distribute the Program under a license
different than this Agreement, provided that such license:
i) effectively disclaims on behalf of all other Contributors all
warranties and conditions, express and implied, including
warranties or conditions of title and non-infringement, and
implied warranties or conditions of merchantability and fitness
for a particular purpose;
ii) effectively excludes on behalf of all other Contributors all
liability for damages, including direct, indirect, special,
incidental and consequential damages, such as lost profits;
iii) does not attempt to limit or alter the recipients' rights
in the Source Code under section 3.2; and
iv) requires any subsequent distribution of the Program by any
party to be under a license that satisfies the requirements
of this section 3.
3.2 When the Program is Distributed as Source Code:
a) it must be made available under this Agreement, or if the
Program (i) is combined with other material in a separate file or
files made available under a Secondary License, and (ii) the initial
Contributor attached to the Source Code the notice described in
Exhibit A of this Agreement, then the Program may be made available
under the terms of such Secondary Licenses, and
b) a copy of this Agreement must be included with each copy of
the Program.
3.3 Contributors may not remove or alter any copyright, patent,
trademark, attribution notices, disclaimers of warranty, or limitations
of liability ("notices") contained within the Program from any copy of
the Program which they Distribute, provided that Contributors may add
their own appropriate notices.
4. COMMERCIAL DISTRIBUTION
Commercial distributors of software may accept certain responsibilities
with respect to end users, business partners and the like. While this
license is intended to facilitate the commercial use of the Program,
the Contributor who includes the Program in a commercial product
offering should do so in a manner which does not create potential
liability for other Contributors. Therefore, if a Contributor includes
the Program in a commercial product offering, such Contributor
("Commercial Contributor") hereby agrees to defend and indemnify every
other Contributor ("Indemnified Contributor") against any losses,
damages and costs (collectively "Losses") arising from claims, lawsuits
and other legal actions brought by a third party against the Indemnified
Contributor to the extent caused by the acts or omissions of such
Commercial Contributor in connection with its distribution of the Program
in a commercial product offering. The obligations in this section do not
apply to any claims or Losses relating to any actual or alleged
intellectual property infringement. In order to qualify, an Indemnified
Contributor must: a) promptly notify the Commercial Contributor in
writing of such claim, and b) allow the Commercial Contributor to control,
and cooperate with the Commercial Contributor in, the defense and any
related settlement negotiations. The Indemnified Contributor may
participate in any such claim at its own expense.
For example, a Contributor might include the Program in a commercial
product offering, Product X. That Contributor is then a Commercial
Contributor. If that Commercial Contributor then makes performance
claims, or offers warranties related to Product X, those performance
claims and warranties are such Commercial Contributor's responsibility
alone. Under this section, the Commercial Contributor would have to
defend claims against the other Contributors related to those performance
claims and warranties, and if a court requires any other Contributor to
pay any damages as a result, the Commercial Contributor must pay
those damages.
5. NO WARRANTY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE. Each Recipient is solely responsible for determining the
appropriateness of using and distributing the Program and assumes all
risks associated with its exercise of rights under this Agreement,
including but not limited to the risks and costs of program errors,
compliance with applicable laws, damage to or loss of data, programs
or equipment, and unavailability or interruption of operations.
6. DISCLAIMER OF LIABILITY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
7. GENERAL
If any provision of this Agreement is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this Agreement, and without further
action by the parties hereto, such provision shall be reformed to the
minimum extent necessary to make such provision valid and enforceable.
If Recipient institutes patent litigation against any entity
(including a cross-claim or counterclaim in a lawsuit) alleging that the
Program itself (excluding combinations of the Program with other software
or hardware) infringes such Recipient's patent(s), then such Recipient's
rights granted under Section 2(b) shall terminate as of the date such
litigation is filed.
All Recipient's rights under this Agreement shall terminate if it
fails to comply with any of the material terms or conditions of this
Agreement and does not cure such failure in a reasonable period of
time after becoming aware of such noncompliance. If all Recipient's
rights under this Agreement terminate, Recipient agrees to cease use
and distribution of the Program as soon as reasonably practicable.
However, Recipient's obligations under this Agreement and any licenses
granted by Recipient relating to the Program shall continue and survive.
Everyone is permitted to copy and distribute copies of this Agreement,
but in order to avoid inconsistency the Agreement is copyrighted and
may only be modified in the following manner. The Agreement Steward
reserves the right to publish new versions (including revisions) of
this Agreement from time to time. No one other than the Agreement
Steward has the right to modify this Agreement. The Eclipse Foundation
is the initial Agreement Steward. The Eclipse Foundation may assign the
responsibility to serve as the Agreement Steward to a suitable separate
entity. Each new version of the Agreement will be given a distinguishing
version number. The Program (including Contributions) may always be
Distributed subject to the version of the Agreement under which it was
received. In addition, after a new version of the Agreement is published,
Contributor may elect to Distribute the Program (including its
Contributions) under the new version.
Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
receives no rights or licenses to the intellectual property of any
Contributor under this Agreement, whether expressly, by implication,
estoppel or otherwise. All rights in the Program not expressly granted
under this Agreement are reserved. Nothing in this Agreement is intended
to be enforceable by any entity that is not a Contributor or Recipient.
No third-party beneficiary rights are created under this Agreement.
Exhibit A - Form of Secondary Licenses Notice
"This Source Code may also be made available under the following
Secondary Licenses when the conditions for such availability set forth
in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public
License as published by the Free Software Foundation, either version 2
of the License, or (at your option) any later version, with the GNU
Classpath Exception which is available at
https://www.gnu.org/software/classpath/license.html."
Simply including a copy of this Agreement, including this Exhibit A
is not sufficient to license the Source Code under Secondary Licenses.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to
look for such a notice.
You may add additional accurate notices of copyright ownership.
================================================
FILE: submissions/jaiaani/problema_01/README.md
================================================
# plantation-profit
A Clojure library designed to ... well, that part is up to you.
## Usage
🇧🇷
Para executar o programa siga os seguintes passos:
Usando o docker...
* Nesse mesmo diretório, rode o comando: `docker build -t problema1 .`
* Depois rode o comando `docker run --rm -it problema1`
* Como input há 3 opções:
- example1
- example2
- example3
são referentes aos exemplos dados, é somente uma concatenação para se referir
aos arquivos localizados na pasta ./resources/input,
```clojure
(defn input
[example]
(with-open [rdr (reader (str "./resources/input/" example ".txt"))]
(doall (mapv vector (line-seq rdr)))))```
se for necessário testar outras entradas, é só adicionar o arquivo nessa pasta.
English -
To run the program, follow these steps:
Using docker...
* In that same directory, run the command: `docker build problema1 .`
* Then run the command `docker run --rm -it problema1`
* As input there are 3 options:
- example1
- example2
- example3
refer to the examples given, it is just a concatenation to refer
to files located in the ./resources/input folder,
```clojure
(defn input
[example]
(with-open [rdr (reader (str "./resources/input/" example ".txt"))]
(doall (mapv vector (line-seq rdr)))))```
If you need to test other entries, just add the file to this folder.
## License
Copyright © 2024 FIXME
This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the Eclipse
Public License, v. 2.0 are satisfied: GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or (at your
option) any later version, with the GNU Classpath Exception which is available
at https://www.gnu.org/software/classpath/license.html.
================================================
FILE: submissions/jaiaani/problema_01/project.clj
================================================
(defproject plantation-profit "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.11.1"]
[prismatic/schema "1.4.1"]]
:repl-options {:init-ns plantation-profit.core}
:main plantation-profit.core)
================================================
FILE: submissions/jaiaani/problema_01/resources/input/example1.txt
================================================
22 36
3 86
1 80
3 71
2 39
2 53
3 47
2 46
1 32
1 69
2 89
4 58
3 86
3 54
3 53
1 64
4 82
1 46
2 48
4 53
1 68
3 94
1 87
================================================
FILE: submissions/jaiaani/problema_01/resources/input/example2.txt
================================================
9 10
3 44
1 78
2 64
1 49
4 69
1 87
3 78
2 45
3 84
================================================
FILE: submissions/jaiaani/problema_01/resources/input/example3.txt
================================================
25 45
1 38
1 99
3 78
3 60
2 69
1 32
2 100
4 59
1 67
3 80
4 44
2 96
2 48
3 46
1 74
3 65
3 32
1 30
4 87
4 90
1 40
2 71
1 86
1 98
1 99
================================================
FILE: submissions/jaiaani/problema_01/resources/input/results.txt
================================================
inputExample1.txt 1194
inputExample2.txt 407
inputExample3.txt 1566
================================================
FILE: submissions/jaiaani/problema_01/src/plantation_profit/core.clj
================================================
(ns plantation-profit.core
(:require [schema.core :as s])
(:use clojure.string)
(:use clojure.java.io)
(:gen-class))
(def InfosSemente
{:v s/Int
:w s/Int})
(defn input
[example]
(with-open [rdr (reader (str "./resources/input/" example ".txt"))]
(doall (mapv vector (line-seq rdr)))))
(s/defn linha-semente->vetor-semente :- [s/Int s/Int]
[linha-input]
(mapv #(Integer/parseInt %) (clojure.string/split (first linha-input) #"\t")))
(defn elementos-do-input
[input]
{:primeira-linha (map #(Integer/parseInt %) (clojure.string/split (first (first input)) #" "))
:vetor-info-sementes (map #(linha-semente->vetor-semente %) (remove #{(first input)} input))})
(s/defn wire->model-semente :- InfosSemente
[vetor-semente :- [s/Int s/Int]]
(let [espaco-necessario (first vetor-semente)
valor (second vetor-semente)]
{:v valor
:w espaco-necessario}))
(s/defn lista-info-sementes :- [InfosSemente]
[vetor-semente :- [s/Int s/Int]]
(mapv #(wire->model-semente %) vetor-semente))
(s/defn maximo-lucro-possivel
[quantidade-sementes :- s/Int
lista-de-sementes :- [InfosSemente]
espacos-disponiveis :- s/Int]
(if (or (zero? quantidade-sementes) (zero? espacos-disponiveis))
0
(let [semente (nth lista-de-sementes (dec quantidade-sementes))
espacos-restantes (- espacos-disponiveis (:w semente))]
(if (> (:w semente) espacos-disponiveis)
(maximo-lucro-possivel (dec quantidade-sementes) lista-de-sementes espacos-disponiveis)
(max (+ (:v semente) (maximo-lucro-possivel (dec quantidade-sementes) lista-de-sementes espacos-restantes))
(maximo-lucro-possivel (dec quantidade-sementes) lista-de-sementes espacos-disponiveis))))))
(defn output
[arquivoExemplo]
(let [input (input (str arquivoExemplo))
elementos-do-input (elementos-do-input input)
lista-de-sementes (lista-info-sementes (:vetor-info-sementes elementos-do-input))
quantidade-de-sementes (first (:primeira-linha elementos-do-input))
espacos-disponiveis (second (:primeira-linha elementos-do-input))]
(println (str "O maximo lucro possivel é de R$"
(maximo-lucro-possivel quantidade-de-sementes lista-de-sementes espacos-disponiveis)
",00"))))
(defn- exit [status msg]
(println msg)
(System/exit status))
(defn -main
[& args]
(println "As opcoes sao example1, example2, example3, referentes aos exemplos do projeto")
(println "Insira aqui o exemplo que voce deseja testar:")
(-> (read-line)
output)
(exit 1 "End"))
================================================
FILE: submissions/jaiaani/problema_01/src/plantation_profit/english_core.clj
================================================
(ns plantation-profit.english-core
(:require [schema.core :as s])
(:use clojure.string)
(:use clojure.java.io)
(:gen-class))
;The same code, but in an english version :)
(def SeedInfo
{:v s/Int
:w s/Int})
(defn input
[txt-path]
(with-open [rdr (reader (str txt-path))]
(doall (mapv vector (line-seq rdr)))))
(s/defn seed-line->seed-vector :- [s/Int s/Int]
[input-line]
(mapv #(Integer/parseInt %) (clojure.string/split (first input-line) #"\t")))
(defn input-elements
[input]
{:first-line (map #(Integer/parseInt %) (clojure.string/split (first (first input)) #" "))
:seeds-informations (map #(seed-line->seed-vector %) (remove #{(first input)} input))})
(s/defn wire->model-seed :- SeedInfo
[seed-vector :- [s/Int s/Int]]
(let [space-required (first seed-vector)
value (second seed-vector)]
{:v value
:w space-required}))
(s/defn list-of-seeds :- [SeedInfo]
[seed-vector :- [s/Int s/Int]]
(mapv #(wire->model-seed %) seed-vector))
(s/defn maximum-possible-profit :- s/Int
[seeds-qty :- s/Int
list-of-seeds :- [SeedInfo]
spaces-available :- s/Int]
(if (or (zero? seeds-qty) (zero? spaces-available))
0
(let [seed (nth list-of-seeds (dec seeds-qty))
remaining-spaces (- spaces-available (:w seed))]
(if (> (:w seed) spaces-available)
(maximum-possible-profit (dec seeds-qty) list-of-seeds spaces-available)
(max (+ (:v seed) (maximum-possible-profit (dec seeds-qty) list-of-seeds remaining-spaces))
(maximum-possible-profit (dec seeds-qty) list-of-seeds spaces-available))))))
(defn output [filePath]
(let [input (input filePath)
input-elements (input-elements input)
list-of-seeds (list-of-seeds (:seeds-informations input-elements))
seeds-qty (first (:first-line input-elements))
spaces-available (second (:first-line input-elements))]
(println (str "The maximum possible profit is R$"
(maximum-possible-profit seeds-qty list-of-seeds spaces-available) ",00"))))
(defn- exit [status msg]
(println msg)
(System/exit status))
(defn -main
[& args]
(println "The options are example1, example2, example3, referring to the project examples")
(println "Enter the example you want to test here:")
(-> (read-line)
output)
(exit 1 "End"))
================================================
FILE: submissions/jaiaani/problema_01/test/plantation_profit/core_test.clj
================================================
(ns plantation-profit.core-test
(:require [clojure.test :refer :all]
[plantation-profit.core :as core]))
(def lista-de-sementes
[{:v 86 :w 3}
{:v 80 :w 1}
{:v 71 :w 3}
{:v 39 :w 2}
{:v 53 :w 2}
{:v 47 :w 3}
{:v 46 :w 2}
{:v 32 :w 1}
{:v 69 :w 1}
{:v 89 :w 2}
{:v 58 :w 4}
{:v 86 :w 3}
{:v 54 :w 3}
{:v 53 :w 3}
{:v 64 :w 1}
{:v 82 :w 4}
{:v 46 :w 1}
{:v 48 :w 2}
{:v 53 :w 4}
{:v 68 :w 1}
{:v 94 :w 3}
{:v 87 :w 1}])
(deftest maximo-lucro-possivel-test
(testing
"Dada a quantidade de sementes, as informacoes da semente e os espacos disponiveis
deve retornar o maior lucro possivel"
(is (= (core/maximo-lucro-possivel 22 lista-de-sementes 36)
1194))))
================================================
FILE: submissions/jojodev/README.md
================================================
## Como Executar
**Pré-requisitos:**
- Tenha Python instalado.
**Execução:**
- Abra um terminal no diretório do script.
- Execute o script com o comando:
```
python problema-1.py input.txt
```
- Exemplo:
```
python problema-1.py ../../resources/instances/problem_01/exemplo_02.txt
```
================================================
FILE: submissions/jojodev/problema-1.py
================================================
import sys
def ler_entrada(nome_arquivo):
matriz = []
with open(nome_arquivo, 'r') as arquivo:
primeira_linha = arquivo.readline().split()
n, W = int(primeira_linha[0]), int(primeira_linha[1])
for _ in range(n):
linha = arquivo.readline().split()
semente = [int(linha[0]), int(linha[1])]
matriz.append(semente)
pesos = [item[0] for item in matriz]
valores = [item[1] for item in matriz]
return n, W, pesos, valores
def knapsack_iterativo(capacidade, pesos, valores, n):
tabela = [[0] * (capacidade + 1) for _ in range(n + 1)]
for i in range(1, n + 1):
for w in range(capacidade + 1):
if pesos[i - 1] <= w:
tabela[i][w] = max(valores[i - 1] + tabela[i - 1][w - pesos[i - 1]], tabela[i - 1][w])
else:
tabela[i][w] = tabela[i - 1][w]
return tabela[n][capacidade]
if __name__ == "__main__":
nome_arquivo = sys.argv[1]
n, capacidade, pesos, valores = ler_entrada(nome_arquivo)
resultado = knapsack_iterativo(capacidade, pesos, valores, n)
print(resultado)
================================================
FILE: submissions/juanplopes/.gitignore
================================================
*.in
*.out
================================================
FILE: submissions/juanplopes/README.md
================================================
# Juan Lopes
Para compilar e executar qualquer problema:
```
g++ -O2 problema-1.cpp && ./a.out < ../../resources/instances/problem_01/exemplo_01.txt
```
================================================
FILE: submissions/juanplopes/problema-1.cpp
================================================
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int T[3030];
int main() {
int N, W;
scanf("%d %d", &N, &W);
T[0] = 1;
for(int i=0; i<N; i++) {
int wi, vi;
scanf("%d %d", &wi, &vi);
for(int j=W - wi; j>=0; j--) {
if (T[j] <= 0) continue;
if (T[j] + vi > T[j + wi])
T[j + wi] = T[j] + vi;
}
}
printf("%d\n", *max_element(T, T+W+1)-1);
}
================================================
FILE: submissions/marcosvile/Dockerfile
================================================
FROM bash:latest
RUN apk add --no-cache bash
COPY problema-1.sh /app/problema-1.sh
RUN chmod +x /app/problema-1.sh
WORKDIR /app
CMD ["./problema-1.sh"]
================================================
FILE: submissions/marcosvile/Readme.md
================================================
## Execução do Projeto
Este projeto utiliza Docker para criar um ambiente isolado para a execução de scripts Bash. A seguir, são fornecidas instruções para construir a imagem Docker, executar o contêiner e passar um arquivo externo como entrada.
1. Construa a imagem Docker e execute o contêiner:
```
$ docker build submissions/marcosvile/. -t problem_01 && time sudo docker run --rm --cpus=2 --memory=2g -v $(pwd)/[diretório do arquivo de entrada]:/app/resources problem_01 ./problema-1.sh resources/[nome do arquivo de entrada].txt
```
Este comando constrói a imagem a ser utilizada no contêiner contento o script bash, e executa um contêiner a partir dessa imagem parametrizado conforme os requisitos do problema com dois núcleos de CPU, 2 GB de RAM e mapeia o diretório local passado pela flag -v, para dentro do contêiner. Certifique-se de substituir o nome do diretório onde contém o arquivo de entrada e o nome utilizado pelo arquivo de entrada externo.
Certifique-se de ajustar os caminhos e nomes de arquivo conforme necessário com base na sua estrutura de diretórios e requisitos específicos.
================================================
FILE: submissions/marcosvile/problema-1.sh
================================================
#!/bin/bash
set -exo pipefail
main() {
chmod +r "$1"
local arquivo=$1
if [ "$#" -ne 1 ]; then
echo "Arquivo de entrada não especificado."
exit 1
fi
if [ ! -e "$arquivo" ]; then
echo "O arquivo '$arquivo' não existe."
exit 1
fi
calcular_lucro_maximo "$arquivo"
}
calcular_lucro_maximo() {
local arquivo=$1
declare -a linhas_array=()
while IFS= read -r linha; do
linhas_array+=("$linha")
done < "$arquivo"
read -r quantidade_sementes quantidade_espacos <<< "${linhas_array[0]}"
if [ "$quantidade_sementes" -lt 1 ] || [ "$quantidade_sementes" -gt 1000 ] || \
[ "$quantidade_espacos" -lt 1 ] || [ "$quantidade_espacos" -gt 2666 ]; then
echo "Quantidades de sementes ou espaços fora dos limites permitidos."
exit 1
fi
declare -a valores=()
declare -a espacos_necessarios=()
for ((i = 1; i <= quantidade_sementes; i++)); do
read -r espaco_necessario valor <<< "${linhas_array[i]}"
if [ "$espaco_necessario" -lt 1 ] || [ "$espaco_necessario" -gt 7 ] || \
[ "$valor" -lt 30 ] || [ "$valor" -gt 200 ]; then
echo "Valores de espaço necessário ou valor fora dos limites permitidos."
exit 1
fi
espacos_necessarios+=("$espaco_necessario")
valores+=("$valor")
done
declare -a lucro_maximo=()
for ((i = 0; i <= quantidade_espacos; i++)); do
lucro_maximo+=("0")
done
for ((i = 1; i <= quantidade_sementes; i++)); do
for ((j = quantidade_espacos; j >= espacos_necessarios[i-1]; j--)); do
lucro_potencial=$((valores[i-1] + lucro_maximo[j - espacos_necessarios[i-1]]))
if [ "$lucro_potencial" -gt "${lucro_maximo[j]}" ]; then
lucro_maximo[j]=$lucro_potencial
fi
done
done
echo "Lucro máximo usando todas as sementes e espaço possível: ${lucro_maximo[quantidade_espacos]}"
}
main "$@"
================================================
FILE: submissions/olegon/.gitignore
================================================
/a.out
================================================
FILE: submissions/olegon/README.md
================================================
# Como rodar?
Eu deixei um script chamado `compile-and-run.sh`, então basta executá-lo:
```bash
./compile-and-run.sh
```
A saída esperada é:
```plain
Preparing...
Expected results are:
instances/exemplo_01.txt 1194
instances/exemplo_02.txt 407
instances/exemplo_03.txt 1566
Running for input file: ../../resources/instances/problem_01/exemplo_01.txt
1194
Running for input file: ../../resources/instances/problem_01/exemplo_02.txt
407
Running for input file: ../../resources/instances/problem_01/exemplo_03.txt
1566
```
# Qual linguagem foi utilizada?
Eu utilizei C++ por preferência pessoal e por ser uma linguagem muito rápida.
# Como resolvi?
Para cada semente, eu testo o valor obtido caso eu plante a semente e caso eu descarte a semente. É necessário testar o caso de descartar a semente, por mais que ela parece ótima, porque combinações de outras sementes podem gerar um valor melhor. A desvantagem de fazer isso é que eu posso calcular as mesmas combinações várias vezes:
- Caso 1: descartar - descartar - descartar - descartar - descartar
- Caso 2: descartar - descartar - descartar - descartar - **plantar**
- Caso 3: descartar - descartar - descartar - **plantar** - descartar
- Caso 4: descartar - descartar - descartar - **plantar** - **plantar**
Como exemplo, os casos 3 e 4 repetem os casos 1 e 2, e isto vai acontecer várias vezes. Para resolver esse problema, eu usei um *cache* para guardar as computações já feitas e reutilizá-las. Problemas com característica de subproblemas que se repetem e que podem ser usados para resolver problemas maiores podem ser resolvidos com *programação dinâmica*, que foi o que utilizei.
================================================
FILE: submissions/olegon/compile-and-run.sh
================================================
#!/bin/bash
set -e
echo "Preparing..."
g++ main.cpp -W -Wall -std=c++14 -O3
echo "Expected results are:"
cat "../../resources/instances/problem_01/resultados.txt"
for f in ../../resources/instances/problem_01/exemplo_*.txt; do
echo "Running for input file: $f";
cat "$f" | ./a.out;
done;
================================================
FILE: submissions/olegon/main.cpp
================================================
/*
Rinha de algoritmos - Problema 01
https://github.com/olegon/rinha-de-algoritmos/blob/main/how_to_participate.md#problema-01
*/
#include <bits/stdc++.h>
using namespace std;
int optimize(int i, int n, vector<int> &w, vector<int> &v, int W, vector<vector<int>> &dp);
int main(void) {
ios::sync_with_stdio(false);
int n, W;
cin >> n >> W;
vector<int> w(n), v(n);
for (int i = 0; i < n; i++) {
cin >> w[i];
cin >> v[i];
}
vector<vector<int>> dp(n, vector<int>(W + 1, -1));
cout << optimize(0, n, w, v, W, dp) << endl;
return EXIT_SUCCESS;
}
int optimize(int i, int n, vector<int> &w, vector<int> &v, int W, vector<vector<int>> &dp) {
if (i >= n) return 0;
if (dp[i][W] != -1) return dp[i][W];
if (w[i] > W) return optimize(i + 1, n, w, v, W, dp);
int value_taking_current_seed = v[i] + optimize(i + 1, n, w, v, W - w[i], dp);
int value_skipping_current_seed = optimize(i + 1, n, w, v, W, dp);
dp[i][W] = max(value_taking_current_seed, value_skipping_current_seed);
return dp[i][W];
}
================================================
FILE: submissions/ryrden/README.md
================================================
# Pré-requisitos
- [Golang](https://golang.org/dl/)
# Execução
**Linux:**
```bash
go run ryrden.go < ../../resourcers/instances/problem_01/exemplo_01.txt
```
**Windows:**
```bash
Get-Content ../../resourcers/instances/problem_01/exemplo_01.txt | go run ryrden.go
```
================================================
FILE: submissions/ryrden/go.mod
================================================
module github.com/ryrden/rinha-de-algoritmos
go 1.18
================================================
FILE: submissions/ryrden/ryrden.go
================================================
package main
import (
"bufio"
"fmt"
"os"
)
func knapsack(totalItems int, maxCapacity int, values []int, weights []int) int {
if totalItems <= 0 || maxCapacity <= 0 {
return 0
}
dp := make([]int, maxCapacity+1)
for item := 1; item <= totalItems; item++ {
currentWeight := weights[item-1]
currentValue := values[item-1]
for capacity := maxCapacity; capacity >= currentWeight; capacity-- {
dp[capacity] = max(dp[capacity], dp[capacity-currentWeight] + currentValue)
}
}
return dp[maxCapacity]
}
func main() {
reader := bufio.NewReader(os.Stdin)
n, W, v, w := readInput(reader)
maxProfit := knapsack(n, W, v, w)
fmt.Printf("Maximum Profit: %d\n", maxProfit)
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
func readInput(reader *bufio.Reader) (int, int, []int, []int) {
var n, W int
fmt.Fscan(reader, &n, &W)
v, w := make([]int, n), make([]int, n)
for i := 0; i < n; i++ {
fmt.Fscan(reader, &w[i], &v[i])
}
return n, W, v, w
}
================================================
FILE: submissions/wmsbill/.nvmrc
================================================
v20.10.0
================================================
FILE: submissions/wmsbill/README.md
================================================
# wmsbill Submission
## How to run
- Enter this folder and run `nvm use` (or use node 20)
- Than run `node problema_01.js {filepath}/{filename}.txt`
- If no filepath provided, examplo_03.txt will be used.
================================================
FILE: submissions/wmsbill/problema_01.js
================================================
const fs = require("node:fs");
const args = process.argv.slice(2);
function parse(fileContent) {
const [inputConfig, ...entries] = fileContent
.split("\n")
.filter((line) => line.length > 0)
.map((line) => line.split(/\W/).map(Number));
return [inputConfig[1], entries];
}
function main(file) {
const fileContent = fs.readFileSync(file, "utf8");
const [spaces, entries] = parse(fileContent);
const table = new Map();
entries
.sort((a, b) => b[1] / b[0] - a[1] / a[0])
.forEach(([size, value]) => {
if (table.has(size)) {
table.get(size).push(value);
return;
}
table.set(size, [value]);
});
const pointers = Array.from({ length: table.size + 1 }, () => 0);
const profitTable = [{ value: 0, pointers }];
for (let i = 1; i <= spaces; i++) {
let maxProfit = { value: 0, pointers: [] };
for (const [size, items] of table) {
const lastProfit = profitTable[i - size];
if (!lastProfit) {
break;
}
const value = items[lastProfit.pointers[size]] ?? 0;
const profit = lastProfit.value + value;
if (profit > maxProfit.value) {
const newPointers = lastProfit.pointers.slice();
newPointers[size]++;
maxProfit = {
value: profit,
pointers: newPointers,
};
}
}
profitTable[i] = maxProfit;
}
return profitTable.at(-1).value;
}
const result = main(
args[0] ?? "./resources/instances/problem_01/exemplo_03.txt"
);
console.log(result);
================================================
FILE: submissions/zeroskullx/.nvmrc
================================================
v20.10.0
================================================
FILE: submissions/zeroskullx/.temp
================================================
//RAW
function maxCoinsX(seeds, W) {
const n = seeds.length;
// Inicializando a matriz para armazenar as soluções parciais
const mtz = new Array(n + 1).fill(0).map(() => new Array(W + 1).fill(0));
//console.log("mtz:", mtz);
// Preenchendo a matriz usando prog dinâmica
for (let i = 1; i <= n; i++) {
const wi = seeds[i - 1].spaceRequired;
const vi = seeds[i - 1].coins;
for (let j = 1; j <= W; j++) {
// Verificando se podemos incluir a semente i na plantação
if (wi <= j) {
// Se for possível incluir a semente i na plantação, então o valor máximo obtido é o máximo entre:
// 1) o valor máximo obtido sem incluir a semente i na plantação e
// 2) o valor máximo obtido incluindo a semente i na plantação
mtz[i][j] = Math.max(mtz[i - 1][j], mtz[i - 1][j - wi] + vi);
} else {
// Se não for possível incluir a semente i na plantação, então o valor máximo obtido é o mesmo da semente anterior
mtz[i][j] = mtz[i - 1][j];
}
}
}
// Reconstruindo a solução para determinar as sementes escolhidas
const selectedSeeds = [];
let ni = n;
let Wj = W;
while (ni > 0 && Wj > 0) {
if (mtz[ni][Wj] !== mtz[ni - 1][Wj]) {
selectedSeeds.push(seeds[ni - 1].seed);
Wj -= seeds[ni - 1].spaceRequired;
}
ni--;
}
// Retornando o valor máximo obtido e a ou as sementes escolhidas
return { maxValue: mtz[n][W], selectedSeeds };
}
// // EXEMPLO DE USO
// // # Sementes disponíveis
// const seeds = [
// { seed: "cafe", coins: 150, spaceRequired: 1 },
// { seed: "arroz", coins: 260, spaceRequired: 2 },
// { seed: "cenoura", coins: 100, spaceRequired: 1 },
// // { seed: 'batata', coins: 100, spaceRequired: 2 },
// // { seed: 'feijão', coins: 160, spaceRequired: 1 },
// ];
// // # Espaço disponível na plantação
// const W = 2;
// const result = maxCoins(seeds, W);
// const seedLabel =
// result.selectedSeeds.length > 1 ? "Sementes escolhidas" : "Semente escolhida";
// console.log(
// `${seedLabel}: ${result.selectedSeeds.join(", ")}. Valor máximo obtido: ${result.maxValue
// }`
// );
//SORT SOMENTE PARA FINS DE TESTE
// Função para ordenar as sementes,
// Exemplo: ['11', '9', 'batata', '1', 'arroz'] = ['1', '9', '11', 'arroz', 'batata']
================================================
FILE: submissions/zeroskullx/README.md
================================================
# Zeroskullx
## Problema 01: Lucro de Plantação no Stardew Valley
**🛠 Getting Started**
- JavaScript
- Node v20.10.0
**🚀 Run problem**
```bash
node problema-01 ../../resources/instances/problem_01/exemplo_01.txt
```
or
```bash
node problema-01 ../../resources/instances/problem_01/exemplo_01.txt -s
```
_Utilize -S para visualizar as sementes plantadas._
## Algoritmo de Programação Dinâmica
"Programação Dinâmica é uma técnica de otimização que resolve problemas dividindo-os em subproblemas menores e resolvendo cada subproblema apenas uma vez."
Iniciei o processo criando uma matriz para armazenar as sementes válidas. Além disso, levei a análise um passo adiante ao incluir as sementes plantadas, junto com o valor gerado por elas. No entanto, antes de chegar a esses resultados, elaborei um array de sementes com base nos exemplos do arquivo de texto. Isso foi feito para proporcionar uma compreensão mais aprofundada do algoritmo que seria aplicado às sementes.
```typescript
[
{
seed: string, //nome da semente baseado no index da linha
spaceRequired: number,
coins: number,
},
];
```
_Não usei typescript, somente para fins ilustrativos_
## Desempenho do Algoritmo
O desempenho do algoritmo pode depender de diversos fatores, incluindo o tamanho dos dados de entrada. O algoritmo `maxCoins` é uma implementação de um problema clássico chamado "Problema da Mochila" usando programação dinâmica. A complexidade de tempo típica do algoritmo é da ordem de O(n \* W), onde "n" é o número de sementes e "W" é a capacidade total dos espaços disponíveis.
## Resultado Template
```bash
◽ Solução: 407
or
🌱 Sementes plantadas: [2, 3, 4, 6, 8, 9]
◽ Solução: 407
```
================================================
FILE: submissions/zeroskullx/problema-01.js
================================================
const args = process.argv.slice(2);
const arg0 = args[0];
const arg1 = args[1];
// ALGORITMO DE PROGRAMAÇÃO DINÂMICA PARA
// RESOLVER O PROBLEMA DA PLANTAÇÃO DE SEMENTES
function maxCoins(seeds, W) {
const n = seeds.length;
const mtz = Array.from({ length: n + 1 }, () => Array(W + 1).fill(0));
for (let i = 1; i <= n; i++) {
const { spaceRequired: wi, coins: vi } = seeds[i - 1];
for (let j = 1; j <= W; j++) {
mtz[i][j] = Math.max(
mtz[i - 1][j],
wi <= j ? mtz[i - 1][j - wi] + vi : 0
);
}
}
const selectedSeeds = [];
for (let ni = n, Wj = W; ni > 0 && Wj > 0; ni--) {
if (mtz[ni][Wj] !== mtz[ni - 1][Wj]) {
selectedSeeds.push(seeds[ni - 1].seed);
Wj -= seeds[ni - 1].spaceRequired;
}
}
return { maxValue: mtz[n][W], selectedSeeds };
}
//CONSTRUÇÃO DOS ARQUIVOS PARA TESTES
const fs = require("fs");
function buildInventory(filename) {
if (!fs.existsSync(filename)) {
console.error(`Arquivo ${filename} não encontrado.`);
return;
}
const content = fs.readFileSync(filename, "utf-8");
const lines = content.trim().split("\n");
const [totalSeeds, availableSpace] = lines[0].split(/\s+/).map(Number);
//Escolhas, pqn?! Mesmo diminuindo o desempenho,
//coloquei uma validação aqui.
const seeds = lines.slice(1).map((line, index) => {
const [spaceRequired, coins] = line.split(/\s+/).map(Number);
if (isNaN(spaceRequired) || isNaN(coins)) {
return null
}
return { seed: `${index + 1}`, coins, spaceRequired };
}).filter(seed => seed !== null);
const results = maxCoins(seeds, availableSpace);
echoResult(results);
//return { totalSeeds, availableSpace, seeds };
}
//IMPRIMIR O RESULTADO
// # Organizar as sementes em ordem crescente
const sortSeeds = (seeds) => {
seeds.sort((a, b) => {
if (!isNaN(a) && !isNaN(b)) {
return parseInt(a, 10) - parseInt(b, 10);
}
if (!isNaN(a)) {
return -1;
}
if (!isNaN(b)) {
return 1;
}
return a.localeCompare(b);
});
return seeds;
};
const echoResult = (result) => {
const seedLabel =
result.selectedSeeds.length > 1 ? "Sementes plantadas" : "Semente plantada";
if (arg1?.toLowerCase() === "-s")
console.log(
`🌱 ${seedLabel}: [${sortSeeds(result.selectedSeeds).join(", ")}].`
);
console.log(`◽ Solução: ${result.maxValue}`);
};
//EXEC
buildInventory(arg0);
================================================
FILE: submissions/zeroskullx/test.txt
================================================
3 2
1 150
2 260
1 100
gitextract_f3v2cmdo/
├── .gitignore
├── CODE_OF_CONDUCT.md
├── LICENSE
├── README.md
├── how_to_participate.md
├── resources/
│ └── instances/
│ ├── problem_01/
│ │ ├── exemplo_01.txt
│ │ ├── exemplo_02.txt
│ │ ├── exemplo_03.txt
│ │ └── resultados.txt
│ ├── problem_02/
│ │ ├── exemplo_01.txt
│ │ ├── exemplo_02.txt
│ │ ├── exemplo_03.txt
│ │ └── resultados.txt
│ └── problem_03/
│ └── results.txt
└── submissions/
├── .gitkeep
├── danielsalles/
│ ├── README.md
│ └── problema-1.cpp
├── devmessias_01_numba_AOT/
│ ├── Makefile
│ ├── README.md
│ ├── aot/
│ │ ├── knapsack.py
│ │ └── setup.py
│ ├── exemplo_01.txt
│ ├── exemplo_02.txt
│ ├── exemplo_03.txt
│ ├── problem_01.py
│ └── requirements.txt
├── diogosm/
│ ├── Dockerfile
│ ├── README.md
│ ├── exemplo_01.txt
│ ├── exemplo_02.txt
│ ├── exemplo_03.txt
│ ├── problema-1.py
│ ├── resultados.txt
│ └── run.sh
├── gabrielng-rj99/
│ ├── Problema_1/
│ │ ├── Python/
│ │ │ ├── Dockerfile
│ │ │ ├── ReadMe.md
│ │ │ ├── examples/
│ │ │ │ ├── exemplo_01.txt
│ │ │ │ ├── exemplo_02.txt
│ │ │ │ └── exemplo_03.txt
│ │ │ ├── handmade_tests/
│ │ │ │ ├── handmade_tests.txt
│ │ │ │ ├── longruntest.txt
│ │ │ │ ├── longruntest2.txt
│ │ │ │ ├── longruntest3.txt
│ │ │ │ ├── longruntest4.txt
│ │ │ │ ├── longruntest5.txt
│ │ │ │ ├── test01_03.txt
│ │ │ │ ├── test02_03.txt
│ │ │ │ ├── test03.1_03.txt
│ │ │ │ ├── test03_03.txt
│ │ │ │ ├── test04_03.txt
│ │ │ │ └── test05_03.txt
│ │ │ ├── problema-1.py
│ │ │ ├── run_commands.sh
│ │ │ ├── runtime.sh
│ │ │ └── test_hyperfine.sh
│ │ └── Rust/
│ │ ├── Cargo.toml
│ │ ├── Dockerfile
│ │ ├── ReadMe.md
│ │ ├── examples/
│ │ │ ├── exemplo_01.txt
│ │ │ ├── exemplo_02.txt
│ │ │ └── exemplo_03.txt
│ │ ├── handmade_tests/
│ │ │ ├── handmade_tests.txt
│ │ │ ├── longruntest.txt
│ │ │ ├── longruntest2.txt
│ │ │ ├── longruntest3.txt
│ │ │ ├── longruntest4.txt
│ │ │ ├── longruntest5.txt
│ │ │ ├── test01_03.txt
│ │ │ ├── test02_03.txt
│ │ │ ├── test03.1_03.txt
│ │ │ ├── test03_03.txt
│ │ │ ├── test04_03.txt
│ │ │ └── test05_03.txt
│ │ ├── run_commands.sh
│ │ └── src/
│ │ └── main.rs
│ └── Problema_2/
│ └── Python/
│ ├── Dockerfile
│ ├── ReadMe.md
│ ├── examples/
│ │ ├── exemplo_01.txt
│ │ ├── exemplo_02.txt
│ │ └── exemplo_03.txt
│ ├── problema-2.py
│ ├── run_commands.sh
│ └── runtime.sh
├── gbpagano/
│ ├── Cargo.toml
│ ├── README.md
│ ├── exemplo.txt
│ └── src/
│ └── main.rs
├── gutogalego/
│ ├── Cargo.toml
│ ├── README.md
│ └── src/
│ └── main.rs
├── gutogalego__2/
│ ├── Cargo.toml
│ ├── README.md
│ └── src/
│ └── main.rs
├── gutogalego__3/
│ ├── Cargo.toml
│ ├── README.md
│ └── src/
│ └── main.rs
├── jaiaani/
│ └── problema_01/
│ ├── .gitignore
│ ├── Dockerfile
│ ├── LICENSE
│ ├── README.md
│ ├── project.clj
│ ├── resources/
│ │ └── input/
│ │ ├── example1.txt
│ │ ├── example2.txt
│ │ ├── example3.txt
│ │ └── results.txt
│ ├── src/
│ │ └── plantation_profit/
│ │ ├── core.clj
│ │ └── english_core.clj
│ └── test/
│ └── plantation_profit/
│ └── core_test.clj
├── jojodev/
│ ├── README.md
│ └── problema-1.py
├── juanplopes/
│ ├── .gitignore
│ ├── README.md
│ └── problema-1.cpp
├── marcosvile/
│ ├── Dockerfile
│ ├── Readme.md
│ └── problema-1.sh
├── olegon/
│ ├── .gitignore
│ ├── README.md
│ ├── compile-and-run.sh
│ └── main.cpp
├── ryrden/
│ ├── README.md
│ ├── go.mod
│ └── ryrden.go
├── wmsbill/
│ ├── .nvmrc
│ ├── README.md
│ └── problema_01.js
└── zeroskullx/
├── .nvmrc
├── .temp
├── README.md
├── problema-01.js
└── test.txt
SYMBOL INDEX (39 symbols across 16 files)
FILE: submissions/danielsalles/problema-1.cpp
type Seed (line 5) | struct Seed {
method Seed (line 9) | Seed(int c, int p, int s) : cost(c), profit(p), space(s) {}
function calculateMaxProfit (line 12) | int calculateMaxProfit(const std::vector<Seed>& seeds, int availableSpac...
function main (line 25) | int main() {
FILE: submissions/devmessias_01_numba_AOT/aot/knapsack.py
function knapsack (line 9) | def knapsack(items, capacity):
FILE: submissions/diogosm/problema-1.py
function calc_lucro (line 16) | def calc_lucro(n_aux, s_aux):
FILE: submissions/gabrielng-rj99/Problema_1/Python/problema-1.py
function knapsack (line 2) | def knapsack(SPACE, ARRAY):
function execute_algorithm (line 14) | def execute_algorithm(file_path):
FILE: submissions/gabrielng-rj99/Problema_1/Rust/src/main.rs
function knapsack (line 5) | fn knapsack(space: i64, array: &[(i64, i64, f64)]) -> i64 {
function execute_algorithm (line 19) | fn execute_algorithm(file_path: &str) -> i64 {
function main (line 44) | fn main() {
FILE: submissions/gabrielng-rj99/Problema_2/Python/problema-2.py
function count_edges (line 8) | def count_edges(N, edges):
function add_ans (line 15) | def add_ans():
function open_edges_file (line 21) | def open_edges_file(file_path):
function roots_leaves_from (line 33) | def roots_leaves_from(cycle: list):
function is_connected (line 55) | def is_connected(nodes: list):
function leaves_connected_to_not_roots (line 65) | def leaves_connected_to_not_roots(leaves, roots, cycle):
function erase_edge_from (line 75) | def erase_edge_from(cycle):
function find_cycle_starting_from (line 143) | def find_cycle_starting_from(start_node):
function break_all_cycles (line 152) | def break_all_cycles():
function main (line 159) | def main(file_path):
FILE: submissions/gbpagano/src/main.rs
function main (line 5) | fn main() {
FILE: submissions/gutogalego/src/main.rs
function knapsack (line 6) | fn knapsack(items: &[(usize, usize)], capacity: usize) -> usize {
function main (line 18) | fn main() -> io::Result<()> {
FILE: submissions/gutogalego__2/src/main.rs
function main (line 6) | fn main() -> io::Result<()> {
FILE: submissions/gutogalego__3/src/main.rs
function main (line 6) | fn main() -> io::Result<()> {
FILE: submissions/jojodev/problema-1.py
function ler_entrada (line 3) | def ler_entrada(nome_arquivo):
function knapsack_iterativo (line 21) | def knapsack_iterativo(capacidade, pesos, valores, n):
FILE: submissions/juanplopes/problema-1.cpp
function main (line 9) | int main() {
FILE: submissions/olegon/main.cpp
function main (line 12) | int main(void) {
function optimize (line 33) | int optimize(int i, int n, vector<int> &w, vector<int> &v, int W, vector...
FILE: submissions/ryrden/ryrden.go
function knapsack (line 9) | func knapsack(totalItems int, maxCapacity int, values []int, weights []i...
function main (line 28) | func main() {
function max (line 36) | func max(a, b int) int {
function readInput (line 43) | func readInput(reader *bufio.Reader) (int, int, []int, []int) {
FILE: submissions/wmsbill/problema_01.js
function parse (line 4) | function parse(fileContent) {
function main (line 13) | function main(file) {
FILE: submissions/zeroskullx/problema-01.js
function maxCoins (line 7) | function maxCoins(seeds, W) {
function buildInventory (line 37) | function buildInventory(filename) {
Condensed preview — 131 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (200K chars).
[
{
"path": ".gitignore",
"chars": 0,
"preview": ""
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 2914,
"preview": "# Código de Conduta\n\nA UBL é um ambiente onde todos os que aprendem e contribuem podem se sentir seguros e acolhidos. Es"
},
{
"path": "LICENSE",
"chars": 1086,
"preview": "MIT License\n\nCopyright (c) 2023 Universidade Brasileira Livre\n\nPermission is hereby granted, free of charge, to any pers"
},
{
"path": "README.md",
"chars": 10243,
"preview": "\n\n<p align=\"center\">\n <a href=\"https://discord.gg/eXUBTY6HAu\">\n "
},
{
"path": "how_to_participate.md",
"chars": 5118,
"preview": "# Como participar\n\nNesta seção descreveremos os procedimentos para participação e submissão na Rinha de Algoritmos.\n\n## "
},
{
"path": "resources/instances/problem_01/exemplo_01.txt",
"chars": 116,
"preview": "22 36\n3\t86\n1\t80\n3\t71\n2\t39\n2\t53\n3\t47\n2\t46\n1\t32\n1\t69\n2\t89\n4\t58\n3\t86\n3\t54\n3\t53\n1\t64\n4\t82\n1\t46\n2\t48\n4\t53\n1\t68\n3\t94\n1\t87\n"
},
{
"path": "resources/instances/problem_01/exemplo_02.txt",
"chars": 50,
"preview": "9 10\n3\t44\n1\t78\n2\t64\n1\t49\n4\t69\n1\t87\n3\t78\n2\t45\n3\t84\n"
},
{
"path": "resources/instances/problem_01/exemplo_03.txt",
"chars": 132,
"preview": "25 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "resources/instances/problem_01/resultados.txt",
"chars": 59,
"preview": "exemplo_01.txt\t1194\nexemplo_02.txt\t407\nexemplo_03.txt\t1566\n"
},
{
"path": "resources/instances/problem_02/exemplo_01.txt",
"chars": 267,
"preview": "40 47\n1 2\n1 24\n2 12\n3 18\n3 22\n4 11\n4 29\n4 32\n5 6\n5 27\n6 12\n6 22\n7 15\n7 17\n8 13\n8 15\n8 36\n9 17\n9 21\n10 18\n10 30\n10 32\n11 "
},
{
"path": "resources/instances/problem_02/exemplo_02.txt",
"chars": 191,
"preview": "30 35\n1 3\n1 16\n2 9\n2 23\n3 8\n3 23\n4 18\n4 22\n4 30\n5 6\n5 11\n6 9\n6 19\n7 16\n7 18\n7 20\n8 26\n8 27\n9 18\n9 21\n10 13\n10 30\n12 15\n1"
},
{
"path": "resources/instances/problem_02/exemplo_03.txt",
"chars": 1197,
"preview": "30 218\n1 3\n1 8\n1 9\n1 11\n1 12\n1 13\n1 14\n1 16\n1 18\n1 20\n1 22\n1 24\n1 26\n1 27\n1 28\n2 8\n2 9\n2 11\n2 12\n2 14\n2 15\n2 19\n2 22\n2 2"
},
{
"path": "resources/instances/problem_02/resultados.txt",
"chars": 54,
"preview": "exemplo_01.txt 15\nexemplo_02.txt 12\nexemplo_03.txt 27\n"
},
{
"path": "resources/instances/problem_03/results.txt",
"chars": 0,
"preview": ""
},
{
"path": "submissions/.gitkeep",
"chars": 0,
"preview": ""
},
{
"path": "submissions/danielsalles/README.md",
"chars": 166,
"preview": "### Compile with:\n```\ng++ -o problema-1-binary problema-1.cpp -O3\n```\n\n### Run with:\n```\n./problema-1-binary < ../../res"
},
{
"path": "submissions/danielsalles/problema-1.cpp",
"chars": 960,
"preview": "#include <iostream>\n#include <vector>\n#include <algorithm>\n\nstruct Seed {\n int cost;\n int profit;\n int space;\n "
},
{
"path": "submissions/devmessias_01_numba_AOT/Makefile",
"chars": 256,
"preview": "compile:\n\tcd aot && python setup.py build_ext --inplace\n\n\ninstall:\n\tpip install -r requirements.txt\n\ninstall-aot-lib:\n\tc"
},
{
"path": "submissions/devmessias_01_numba_AOT/README.md",
"chars": 483,
"preview": "\nEste exemplo usa compilação AOT usando numba para python. Portanto,\né necessário executar a instalação e compilação pri"
},
{
"path": "submissions/devmessias_01_numba_AOT/aot/knapsack.py",
"chars": 451,
"preview": "from numba import jit, int64\nimport numpy as np\nfrom numba.pycc import CC\n\ncc = CC('knapsack')\ncc.verbose = True\n\n@cc.ex"
},
{
"path": "submissions/devmessias_01_numba_AOT/aot/setup.py",
"chars": 274,
"preview": "from setuptools import setup\nfrom setuptools.extension import Extension\nfrom Cython.Build import cythonize\n\nextensions ="
},
{
"path": "submissions/devmessias_01_numba_AOT/exemplo_01.txt",
"chars": 116,
"preview": "22\t36\n3\t86\n1\t80\n3\t71\n2\t39\n2\t53\n3\t47\n2\t46\n1\t32\n1\t69\n2\t89\n4\t58\n3\t86\n3\t54\n3\t53\n1\t64\n4\t82\n1\t46\n2\t48\n4\t53\n1\t68\n3\t94\n1\t87\n"
},
{
"path": "submissions/devmessias_01_numba_AOT/exemplo_02.txt",
"chars": 50,
"preview": "9\t10\n3\t44\n1\t78\n2\t64\n1\t49\n4\t69\n1\t87\n3\t78\n2\t45\n3\t84\n"
},
{
"path": "submissions/devmessias_01_numba_AOT/exemplo_03.txt",
"chars": 132,
"preview": "25\t45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/devmessias_01_numba_AOT/problem_01.py",
"chars": 269,
"preview": "from sys import argv\nfrom numpy import genfromtxt, int32\nimport knapsack\n\n\nif __name__ == \"__main__\":\n data = genfromtx"
},
{
"path": "submissions/devmessias_01_numba_AOT/requirements.txt",
"chars": 55,
"preview": "Cython==3.0.8\nllvmlite==0.39.1\nnumba==0.56\nnumpy==1.22\n"
},
{
"path": "submissions/diogosm/Dockerfile",
"chars": 182,
"preview": "FROM python:3.8\n\nWORKDIR /app\nCOPY . /app\n\nRUN pip install numba\n#RUN apt-get update && apt-get install -y bc\n\nCMD [\"bas"
},
{
"path": "submissions/diogosm/README.md",
"chars": 397,
"preview": "# Para rodar\n\nSe tiver docker: `./run.sh`. Irá retornar a saída e o tempo de execucao. Caso contrário: `python3 problema"
},
{
"path": "submissions/diogosm/exemplo_01.txt",
"chars": 116,
"preview": "22 36\n3\t86\n1\t80\n3\t71\n2\t39\n2\t53\n3\t47\n2\t46\n1\t32\n1\t69\n2\t89\n4\t58\n3\t86\n3\t54\n3\t53\n1\t64\n4\t82\n1\t46\n2\t48\n4\t53\n1\t68\n3\t94\n1\t87\n"
},
{
"path": "submissions/diogosm/exemplo_02.txt",
"chars": 50,
"preview": "9 10\n3\t44\n1\t78\n2\t64\n1\t49\n4\t69\n1\t87\n3\t78\n2\t45\n3\t84\n"
},
{
"path": "submissions/diogosm/exemplo_03.txt",
"chars": 132,
"preview": "25 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/diogosm/problema-1.py",
"chars": 872,
"preview": "import sys\n#from numba import jit, njit\n#import numpy as np\n\nn, s = map(int, next(sys.stdin).strip().split())\ntuples = ["
},
{
"path": "submissions/diogosm/resultados.txt",
"chars": 89,
"preview": "instances/exemplo_01.txt\t1194\ninstances/exemplo_02.txt\t407\ninstances/exemplo_03.txt\t1566\n"
},
{
"path": "submissions/diogosm/run.sh",
"chars": 71,
"preview": "#!/bin/bash\n\ndocker build -t python-rinha . && docker run python-rinha\n"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/Dockerfile",
"chars": 248,
"preview": "FROM python:3.11.7-alpine3.18\n\n# Install the hyperfine package\nRUN apk --no-cache add hyperfine jq\n\nWORKDIR /app\nCOPY . "
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/ReadMe.md",
"chars": 2150,
"preview": "# Requisitos\n- ***Docker***\n\n# Como Rodar\n### PowerShell(MS) *ou* Shell(Linux)\n> Execute uma linha de cada vez no cons"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_01.txt",
"chars": 116,
"preview": "22 36\n3\t86\n1\t80\n3\t71\n2\t39\n2\t53\n3\t47\n2\t46\n1\t32\n1\t69\n2\t89\n4\t58\n3\t86\n3\t54\n3\t53\n1\t64\n4\t82\n1\t46\n2\t48\n4\t53\n1\t68\n3\t94\n1\t87\n"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_02.txt",
"chars": 50,
"preview": "9 10\n3\t44\n1\t78\n2\t64\n1\t49\n4\t69\n1\t87\n3\t78\n2\t45\n3\t84\n"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/examples/exemplo_03.txt",
"chars": 132,
"preview": "25 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/handmade_tests.txt",
"chars": 1563,
"preview": "# Run handmade tests\n\ndef run_handmade_tests():\n file_paths = [\n \"submissions/gabrielng-rj99/Problema_1/Python"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest.txt",
"chars": 7608,
"preview": "1509 2000\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest2.txt",
"chars": 5596,
"preview": "1000 2500\n4\t190\n7\t164\n5\t172\n6\t78\n2\t188\n5\t139\n1\t56\n2\t75\n6\t183\n1\t92\n5\t183\n1\t132\n3\t30\n5\t30\n5\t175\n5\t62\n3\t122\n1\t61\n7\t116\n5\t17"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest3.txt",
"chars": 5617,
"preview": "1000 2000\n6\t113\n2\t32\n6\t149\n1\t176\n7\t166\n6\t64\n2\t98\n6\t81\n3\t175\n4\t60\n4\t158\n3\t164\n3\t47\n2\t192\n6\t114\n1\t36\n5\t142\n4\t181\n3\t106\n4\t6"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest4.txt",
"chars": 5608,
"preview": "1000 1500\n6\t152\n3\t34\n1\t151\n6\t198\n5\t126\n7\t133\n2\t167\n6\t114\n7\t165\n2\t144\n7\t55\n1\t50\n7\t174\n6\t98\n1\t151\n7\t87\n4\t37\n2\t195\n5\t45\n1\t1"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/longruntest5.txt",
"chars": 5599,
"preview": "1000 3000\n2\t172\n1\t74\n2\t95\n3\t160\n1\t41\n1\t41\n4\t98\n2\t131\n2\t52\n7\t195\n5\t129\n5\t122\n7\t171\n3\t71\n3\t89\n2\t73\n4\t52\n2\t128\n7\t179\n3\t113\n"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test01_03.txt",
"chars": 137,
"preview": "26 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test02_03.txt",
"chars": 137,
"preview": "26 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test03.1_03.txt",
"chars": 137,
"preview": "26 47\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test03_03.txt",
"chars": 137,
"preview": "26 46\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test04_03.txt",
"chars": 137,
"preview": "26 46\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t44\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/handmade_tests/test05_03.txt",
"chars": 132,
"preview": "25 46\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t61\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/problema-1.py",
"chars": 758,
"preview": "import sys\ndef knapsack(SPACE, ARRAY):\n n = len(ARRAY)\n dp = [0] * (SPACE + 1)\n\n for i in range(n):\n wi"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/run_commands.sh",
"chars": 405,
"preview": "#!/bin/sh\n\nMFNL=0 # Max FileName Length Start\n\nfor file in examples/*\ndo\n filename=$(basename $file)\n len=$(e"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/runtime.sh",
"chars": 1313,
"preview": "#!/bin/sh\n\nWARMUP=20\nRUNS=20\nSUM_MEANS=0\nFILE_COUNT=0\nMFNL=0 # Max FileName Length Start\n\nfor file in examples/"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Python/test_hyperfine.sh",
"chars": 373,
"preview": "#!/bin/sh\n\n#Hyperfine all examples one by one\nclear\n\nWARMUP=10\nRUNS=200\n\nfor file in examples/*\ndo\n namefile=$(basename"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/Cargo.toml",
"chars": 178,
"preview": "[package]\nname = \"problema_1\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.r"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/Dockerfile",
"chars": 326,
"preview": "FROM rust:1.75-alpine3.18\n\n# Install the hyperfine package\nRUN apk --no-cache add hyperfine jq\n\nWORKDIR /app\nCOPY . /app"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/ReadMe.md",
"chars": 1976,
"preview": "# Requisitos\n- ***Docker***\n\n# Como Rodar\n### PowerShell(MS) *ou* Shell(Linux)\n> Execute uma linha de cada vez no cons"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/examples/exemplo_01.txt",
"chars": 116,
"preview": "22 36\n3\t86\n1\t80\n3\t71\n2\t39\n2\t53\n3\t47\n2\t46\n1\t32\n1\t69\n2\t89\n4\t58\n3\t86\n3\t54\n3\t53\n1\t64\n4\t82\n1\t46\n2\t48\n4\t53\n1\t68\n3\t94\n1\t87\n"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/examples/exemplo_02.txt",
"chars": 50,
"preview": "9 10\n3\t44\n1\t78\n2\t64\n1\t49\n4\t69\n1\t87\n3\t78\n2\t45\n3\t84\n"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/examples/exemplo_03.txt",
"chars": 132,
"preview": "25 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/handmade_tests.txt",
"chars": 1563,
"preview": "# Run handmade tests\n\ndef run_handmade_tests():\n file_paths = [\n \"submissions/gabrielng-rj99/Problema_1/Python"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest.txt",
"chars": 7608,
"preview": "1509 2000\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest2.txt",
"chars": 5596,
"preview": "1000 2500\n4\t190\n7\t164\n5\t172\n6\t78\n2\t188\n5\t139\n1\t56\n2\t75\n6\t183\n1\t92\n5\t183\n1\t132\n3\t30\n5\t30\n5\t175\n5\t62\n3\t122\n1\t61\n7\t116\n5\t17"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest3.txt",
"chars": 5617,
"preview": "1000 2000\n6\t113\n2\t32\n6\t149\n1\t176\n7\t166\n6\t64\n2\t98\n6\t81\n3\t175\n4\t60\n4\t158\n3\t164\n3\t47\n2\t192\n6\t114\n1\t36\n5\t142\n4\t181\n3\t106\n4\t6"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest4.txt",
"chars": 5608,
"preview": "1000 1500\n6\t152\n3\t34\n1\t151\n6\t198\n5\t126\n7\t133\n2\t167\n6\t114\n7\t165\n2\t144\n7\t55\n1\t50\n7\t174\n6\t98\n1\t151\n7\t87\n4\t37\n2\t195\n5\t45\n1\t1"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/longruntest5.txt",
"chars": 5599,
"preview": "1000 3000\n2\t172\n1\t74\n2\t95\n3\t160\n1\t41\n1\t41\n4\t98\n2\t131\n2\t52\n7\t195\n5\t129\n5\t122\n7\t171\n3\t71\n3\t89\n2\t73\n4\t52\n2\t128\n7\t179\n3\t113\n"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test01_03.txt",
"chars": 137,
"preview": "26 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test02_03.txt",
"chars": 137,
"preview": "26 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test03.1_03.txt",
"chars": 137,
"preview": "26 47\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test03_03.txt",
"chars": 137,
"preview": "26 46\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test04_03.txt",
"chars": 137,
"preview": "26 46\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t44\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/handmade_tests/test05_03.txt",
"chars": 132,
"preview": "25 46\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t61\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/run_commands.sh",
"chars": 1460,
"preview": "#!/bin/sh\n\nWARMUP=50\nRUNS=100\nSUM_MEANS=0\nFILE_COUNT=0\nMFNL=0 # Max FileName Length Start\n\nfor file in example"
},
{
"path": "submissions/gabrielng-rj99/Problema_1/Rust/src/main.rs",
"chars": 1326,
"preview": "use std::env;\nuse std::fs::File;\nuse std::io::{BufRead, BufReader};\n\nfn knapsack(space: i64, array: &[(i64, i64, f64)]) "
},
{
"path": "submissions/gabrielng-rj99/Problema_2/Python/Dockerfile",
"chars": 297,
"preview": "FROM python:3.11.7-alpine3.18\n\n# Install the hyperfine package and networkx\nRUN apk --no-cache add hyperfine jq \\\n &&"
},
{
"path": "submissions/gabrielng-rj99/Problema_2/Python/ReadMe.md",
"chars": 2150,
"preview": "# Requisitos\n- ***Docker***\n\n# Como Rodar\n### PowerShell(MS) *ou* Shell(Linux)\n> Execute uma linha de cada vez no cons"
},
{
"path": "submissions/gabrielng-rj99/Problema_2/Python/examples/exemplo_01.txt",
"chars": 267,
"preview": "40 47\n1 2\n1 24\n2 12\n3 18\n3 22\n4 11\n4 29\n4 32\n5 6\n5 27\n6 12\n6 22\n7 15\n7 17\n8 13\n8 15\n8 36\n9 17\n9 21\n10 18\n10 30\n10 32\n11 "
},
{
"path": "submissions/gabrielng-rj99/Problema_2/Python/examples/exemplo_02.txt",
"chars": 191,
"preview": "30 35\n1 3\n1 16\n2 9\n2 23\n3 8\n3 23\n4 18\n4 22\n4 30\n5 6\n5 11\n6 9\n6 19\n7 16\n7 18\n7 20\n8 26\n8 27\n9 18\n9 21\n10 13\n10 30\n12 15\n1"
},
{
"path": "submissions/gabrielng-rj99/Problema_2/Python/examples/exemplo_03.txt",
"chars": 1197,
"preview": "30 218\n1 3\n1 8\n1 9\n1 11\n1 12\n1 13\n1 14\n1 16\n1 18\n1 20\n1 22\n1 24\n1 26\n1 27\n1 28\n2 8\n2 9\n2 11\n2 12\n2 14\n2 15\n2 19\n2 22\n2 2"
},
{
"path": "submissions/gabrielng-rj99/Problema_2/Python/problema-2.py",
"chars": 5018,
"preview": "import networkx as nx\nimport sys\n\nG = nx.Graph()\nedges_count = {}\nans = 0\n\ndef count_edges(N, edges):\n global edges_c"
},
{
"path": "submissions/gabrielng-rj99/Problema_2/Python/run_commands.sh",
"chars": 405,
"preview": "#!/bin/sh\n\nMFNL=0 # Max FileName Length Start\n\nfor file in examples/*\ndo\n filename=$(basename $file)\n len=$(e"
},
{
"path": "submissions/gabrielng-rj99/Problema_2/Python/runtime.sh",
"chars": 1313,
"preview": "#!/bin/sh\n\nWARMUP=10\nRUNS=10\nSUM_MEANS=0\nFILE_COUNT=0\nMFNL=0 # Max FileName Length Start\n\nfor file in examples/"
},
{
"path": "submissions/gbpagano/Cargo.toml",
"chars": 177,
"preview": "[package]\nname = \"gbpagano\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.rus"
},
{
"path": "submissions/gbpagano/README.md",
"chars": 166,
"preview": "# Usage\n\nrun with cargo\n\n```sh\ncargo run --release -- {filepath}\n```\n\nexample: \n\n```sh\ncargo run --release -- ../../reso"
},
{
"path": "submissions/gbpagano/exemplo.txt",
"chars": 132,
"preview": "25 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/gbpagano/src/main.rs",
"chars": 958,
"preview": "use std::env;\nuse std::fs::File;\nuse std::io::{self, BufRead};\n\nfn main() {\n let args: Vec<_> = env::args().collect()"
},
{
"path": "submissions/gutogalego/Cargo.toml",
"chars": 162,
"preview": "[package]\nname = \"gutogalego\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://doc.r"
},
{
"path": "submissions/gutogalego/README.md",
"chars": 190,
"preview": "To run this, have rust installed, and run:\n\n```\ncargo run --release -- your_filename.txt\n```\n\nfor example \n\n```\ncargo ru"
},
{
"path": "submissions/gutogalego/src/main.rs",
"chars": 1300,
"preview": "use std::env;\nuse std::fs::File;\nuse std::io::{self, BufRead};\nuse std::path::Path;\n\nfn knapsack(items: &[(usize, usize)"
},
{
"path": "submissions/gutogalego__2/Cargo.toml",
"chars": 165,
"preview": "[package]\nname = \"gutogalego__2\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://do"
},
{
"path": "submissions/gutogalego__2/README.md",
"chars": 190,
"preview": "To run this, have rust installed, and run:\n\n```\ncargo run --release -- your_filename.txt\n```\n\nfor example \n\n```\ncargo ru"
},
{
"path": "submissions/gutogalego__2/src/main.rs",
"chars": 1472,
"preview": "use std::env;\nuse std::fs::File;\nuse std::io::{self, BufRead};\nuse std::path::Path;\n\nfn main() -> io::Result<()> {\n l"
},
{
"path": "submissions/gutogalego__3/Cargo.toml",
"chars": 165,
"preview": "[package]\nname = \"gutogalego__3\"\nversion = \"0.1.0\"\nedition = \"2021\"\n\n# See more keys and their definitions at https://do"
},
{
"path": "submissions/gutogalego__3/README.md",
"chars": 190,
"preview": "To run this, have rust installed, and run:\n\n```\ncargo run --release -- your_filename.txt\n```\n\nfor example \n\n```\ncargo ru"
},
{
"path": "submissions/gutogalego__3/src/main.rs",
"chars": 1393,
"preview": "use std::env;\nuse std::fs::File;\nuse std::io::{self, BufRead};\nuse std::path::Path;\n\nfn main() -> io::Result<()> {\n l"
},
{
"path": "submissions/jaiaani/problema_01/.gitignore",
"chars": 130,
"preview": "/target\n/classes\n/checkouts\nprofiles.clj\npom.xml\npom.xml.asc\n*.jar\n*.class\n/.lein-*\n/.nrepl-port\n/.prepl-port\n.hgignore\n"
},
{
"path": "submissions/jaiaani/problema_01/Dockerfile",
"chars": 337,
"preview": "FROM clojure:latest\n\n# Set the working directory to /app\nWORKDIR /app\n\n# Copy the current directory contents into the co"
},
{
"path": "submissions/jaiaani/problema_01/LICENSE",
"chars": 14372,
"preview": "Eclipse Public License - v 2.0\n\n THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE\n PUBLIC LICE"
},
{
"path": "submissions/jaiaani/problema_01/README.md",
"chars": 2088,
"preview": "# plantation-profit\n\nA Clojure library designed to ... well, that part is up to you.\n\n## Usage\n🇧🇷\nPara executar o progra"
},
{
"path": "submissions/jaiaani/problema_01/project.clj",
"chars": 434,
"preview": "(defproject plantation-profit \"0.1.0-SNAPSHOT\"\n :description \"FIXME: write description\"\n :url \"http://example.com/FIXM"
},
{
"path": "submissions/jaiaani/problema_01/resources/input/example1.txt",
"chars": 115,
"preview": "22 36\n3\t86\n1\t80\n3\t71\n2\t39\n2\t53\n3\t47\n2\t46\n1\t32\n1\t69\n2\t89\n4\t58\n3\t86\n3\t54\n3\t53\n1\t64\n4\t82\n1\t46\n2\t48\n4\t53\n1\t68\n3\t94\n1\t87"
},
{
"path": "submissions/jaiaani/problema_01/resources/input/example2.txt",
"chars": 50,
"preview": "9 10\n3\t44\n1\t78\n2\t64\n1\t49\n4\t69\n1\t87\n3\t78\n2\t45\n3\t84\n"
},
{
"path": "submissions/jaiaani/problema_01/resources/input/example3.txt",
"chars": 132,
"preview": "25 45\n1\t38\n1\t99\n3\t78\n3\t60\n2\t69\n1\t32\n2\t100\n4\t59\n1\t67\n3\t80\n4\t44\n2\t96\n2\t48\n3\t46\n1\t74\n3\t65\n3\t32\n1\t30\n4\t87\n4\t90\n1\t40\n2\t71\n1\t8"
},
{
"path": "submissions/jaiaani/problema_01/resources/input/results.txt",
"chars": 68,
"preview": "inputExample1.txt\t1194\ninputExample2.txt\t407\ninputExample3.txt\t1566\n"
},
{
"path": "submissions/jaiaani/problema_01/src/plantation_profit/core.clj",
"chars": 2585,
"preview": "(ns plantation-profit.core\n (:require [schema.core :as s])\n (:use clojure.string)\n (:use clojure.java.io)\n (:gen-cla"
},
{
"path": "submissions/jaiaani/problema_01/src/plantation_profit/english_core.clj",
"chars": 2338,
"preview": "(ns plantation-profit.english-core\n (:require [schema.core :as s])\n (:use clojure.string)\n (:use clojure.java.io)\n ("
},
{
"path": "submissions/jaiaani/problema_01/test/plantation_profit/core_test.clj",
"chars": 758,
"preview": "(ns plantation-profit.core-test\n (:require [clojure.test :refer :all]\n [plantation-profit.core :as core]))\n\n"
},
{
"path": "submissions/jojodev/README.md",
"chars": 334,
"preview": "## Como Executar\n\n**Pré-requisitos:**\n - Tenha Python instalado.\n\n**Execução:**\n - Abra um terminal no diretório do "
},
{
"path": "submissions/jojodev/problema-1.py",
"chars": 1109,
"preview": "import sys\n\ndef ler_entrada(nome_arquivo):\n matriz = []\n\n with open(nome_arquivo, 'r') as arquivo:\n primeir"
},
{
"path": "submissions/juanplopes/.gitignore",
"chars": 11,
"preview": "*.in\n*.out\n"
},
{
"path": "submissions/juanplopes/README.md",
"chars": 154,
"preview": "# Juan Lopes\n\nPara compilar e executar qualquer problema:\n\n```\ng++ -O2 problema-1.cpp && ./a.out < ../../resources/insta"
},
{
"path": "submissions/juanplopes/problema-1.cpp",
"chars": 484,
"preview": "#include <iostream>\n#include <cstring>\n#include <cstdio>\n#include <algorithm>\nusing namespace std;\n\nint T[3030];\n\nint ma"
},
{
"path": "submissions/marcosvile/Dockerfile",
"chars": 156,
"preview": "FROM bash:latest\n\nRUN apk add --no-cache bash\n\nCOPY problema-1.sh /app/problema-1.sh\n\nRUN chmod +x /app/problema-1.sh\n\nW"
},
{
"path": "submissions/marcosvile/Readme.md",
"chars": 1108,
"preview": "## Execução do Projeto\n\nEste projeto utiliza Docker para criar um ambiente isolado para a execução de scripts Bash. A se"
},
{
"path": "submissions/marcosvile/problema-1.sh",
"chars": 1995,
"preview": "#!/bin/bash\n\nset -exo pipefail\n\nmain() {\n\n chmod +r \"$1\"\n \n local arquivo=$1\n\n if [ \"$#\" -ne 1 ]; then\n "
},
{
"path": "submissions/olegon/.gitignore",
"chars": 7,
"preview": "/a.out\n"
},
{
"path": "submissions/olegon/README.md",
"chars": 1671,
"preview": "# Como rodar?\n\nEu deixei um script chamado `compile-and-run.sh`, então basta executá-lo:\n\n```bash\n./compile-and-run.sh\n`"
},
{
"path": "submissions/olegon/compile-and-run.sh",
"chars": 300,
"preview": "#!/bin/bash\n\nset -e\n\necho \"Preparing...\"\ng++ main.cpp -W -Wall -std=c++14 -O3\n\necho \"Expected results are:\"\ncat \"../../r"
},
{
"path": "submissions/olegon/main.cpp",
"chars": 1088,
"preview": "/*\nRinha de algoritmos - Problema 01\nhttps://github.com/olegon/rinha-de-algoritmos/blob/main/how_to_participate.md#probl"
},
{
"path": "submissions/ryrden/README.md",
"chars": 274,
"preview": "\n# Pré-requisitos\n\n- [Golang](https://golang.org/dl/)\n\n# Execução\n\n**Linux:**\n\n```bash\ngo run ryrden.go < ../../resource"
},
{
"path": "submissions/ryrden/go.mod",
"chars": 54,
"preview": "module github.com/ryrden/rinha-de-algoritmos\n\ngo 1.18\n"
},
{
"path": "submissions/ryrden/ryrden.go",
"chars": 986,
"preview": "package main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc knapsack(totalItems int, maxCapacity int, values []int, weights []i"
},
{
"path": "submissions/wmsbill/.nvmrc",
"chars": 8,
"preview": "v20.10.0"
},
{
"path": "submissions/wmsbill/README.md",
"chars": 207,
"preview": "# wmsbill Submission\n\n## How to run\n\n- Enter this folder and run `nvm use` (or use node 20)\n- Than run `node problema_01"
},
{
"path": "submissions/wmsbill/problema_01.js",
"chars": 1529,
"preview": "const fs = require(\"node:fs\");\nconst args = process.argv.slice(2);\n\nfunction parse(fileContent) {\n const [inputConfig, "
},
{
"path": "submissions/zeroskullx/.nvmrc",
"chars": 10,
"preview": "v20.10.0\r\n"
},
{
"path": "submissions/zeroskullx/.temp",
"chars": 2368,
"preview": "//RAW\r\n\r\nfunction maxCoinsX(seeds, W) {\r\n const n = seeds.length;\r\n\r\n // Inicializando a matriz para armazenar as solu"
},
{
"path": "submissions/zeroskullx/README.md",
"chars": 1753,
"preview": "# Zeroskullx\r\n\r\n## Problema 01: Lucro de Plantação no Stardew Valley\r\n\r\n**🛠 Getting Started**\r\n\r\n- JavaScript\r\n- Node v2"
},
{
"path": "submissions/zeroskullx/problema-01.js",
"chars": 2513,
"preview": "const args = process.argv.slice(2);\r\nconst arg0 = args[0];\r\nconst arg1 = args[1];\r\n\r\n// ALGORITMO DE PROGRAMAÇÃO DINÂMIC"
},
{
"path": "submissions/zeroskullx/test.txt",
"chars": 29,
"preview": "3 2\r\n1 150\r\n2 260\r\n1 100\r\n"
}
]
About this extraction
This page contains the full source code of the Universidade-Livre/rinha-de-algoritmos GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 131 files (157.7 KB), approximately 80.0k tokens, and a symbol index with 39 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.