From 2d7ef2e2d57fb13f89ee8dd51956a23958c3bce1 Mon Sep 17 00:00:00 2001 From: tryh4rd-26 Date: Fri, 6 Feb 2026 20:19:07 +0530 Subject: [PATCH 1/2] Add Python data loading library for IMO Bench datasets with testing suites --- README.md | 2 + imobench-pylib/.gitignore | 137 ++++++++++ imobench-pylib/CONTRIBUTING.md | 178 ++++++++++++ imobench-pylib/LICENSE | 170 ++++++++++++ imobench-pylib/MANIFEST.in | 17 ++ imobench-pylib/README.md | 306 +++++++++++++++++++++ imobench-pylib/examples/README.md | 98 +++++++ imobench-pylib/examples/advanced.py | 269 ++++++++++++++++++ imobench-pylib/examples/quickstart.py | 200 ++++++++++++++ imobench-pylib/pyproject.toml | 104 +++++++ imobench-pylib/setup.py | 69 +++++ imobench-pylib/src/imobench/__init__.py | 40 +++ imobench-pylib/src/imobench/exceptions.py | 21 ++ imobench-pylib/src/imobench/loader.py | 318 ++++++++++++++++++++++ imobench-pylib/src/imobench/types.py | 89 ++++++ imobench-pylib/src/imobench/validators.py | 183 +++++++++++++ imobench-pylib/tests/conftest.py | 8 + imobench-pylib/tests/test_integration.py | 142 ++++++++++ imobench-pylib/tests/test_loader.py | 137 ++++++++++ imobench-pylib/tests/test_types.py | 111 ++++++++ imobench-pylib/tests/test_validators.py | 230 ++++++++++++++++ 21 files changed, 2829 insertions(+) create mode 100644 imobench-pylib/.gitignore create mode 100644 imobench-pylib/CONTRIBUTING.md create mode 100644 imobench-pylib/LICENSE create mode 100644 imobench-pylib/MANIFEST.in create mode 100644 imobench-pylib/README.md create mode 100644 imobench-pylib/examples/README.md create mode 100644 imobench-pylib/examples/advanced.py create mode 100644 imobench-pylib/examples/quickstart.py create mode 100644 imobench-pylib/pyproject.toml create mode 100644 imobench-pylib/setup.py create mode 100644 imobench-pylib/src/imobench/__init__.py create mode 100644 imobench-pylib/src/imobench/exceptions.py create mode 100644 imobench-pylib/src/imobench/loader.py create mode 100644 imobench-pylib/src/imobench/types.py create mode 100644 imobench-pylib/src/imobench/validators.py create mode 100644 imobench-pylib/tests/conftest.py create mode 100644 imobench-pylib/tests/test_integration.py create mode 100644 imobench-pylib/tests/test_loader.py create mode 100644 imobench-pylib/tests/test_types.py create mode 100644 imobench-pylib/tests/test_validators.py diff --git a/README.md b/README.md index a4d7312..1fd1b14 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ reasoning in AI. Following our * *IMO-GradingBench*: A dataset of 1000 human gradings to advance automatic evaluation. + + ## [Aletheia](aletheia/README.md) A reasoning agent powered by Gemini Deep Think that can iteratively generate, verify, and revise solutions. diff --git a/imobench-pylib/.gitignore b/imobench-pylib/.gitignore new file mode 100644 index 0000000..26c85b8 --- /dev/null +++ b/imobench-pylib/.gitignore @@ -0,0 +1,137 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +Pipfile.lock + +# PEP 582 +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# IDEs +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# macOS +.DS_Store + +# Project specific +*.csv.gz +*.csv.bz2 diff --git a/imobench-pylib/CONTRIBUTING.md b/imobench-pylib/CONTRIBUTING.md new file mode 100644 index 0000000..eaa3916 --- /dev/null +++ b/imobench-pylib/CONTRIBUTING.md @@ -0,0 +1,178 @@ +# Contributing to IMO Bench Python Library + +Thank you for your interest in contributing to the IMO Bench Python library! + +## Repository Structure + +This library (`imobench-pylib`) is part of the larger [Superhuman Reasoning](https://github.com/google-deepmind/superhuman) repository by Google DeepMind. + +## Types of Contributions + +### Bug Reports + +If you find a bug, please open an issue with: +- Clear description of the problem +- Minimal reproducible example +- Expected vs actual behavior +- Python version and environment details +- Relevant error messages and stack traces + +### Feature Requests + +For new features: +- Describe the use case +- Explain why it would benefit users +- Provide example API usage if possible + +### Code Contributions + +1. **Fork and Clone** + ```bash + git clone https://github.com/YOUR-USERNAME/superhuman.git + cd superhuman/imobench-pylib + ``` + +2. **Set Up Development Environment** + ```bash + python -m venv venv + source venv/bin/activate # On Windows: venv\Scripts\activate + pip install -e ".[dev]" + ``` + +3. **Create a Branch** + ```bash + git checkout -b feature/your-feature-name + ``` + +4. **Make Changes** +- Follow existing code style + - Use type hints + - Add docstrings + - Keep functions focused and testable + +5. **Write Tests** + ```bash + # Add tests in tests/ + pytest tests/ + ``` + +6. **Check Code Quality** + ```bash + # Format code + black src/ tests/ + + # Type checking + mypy src/ + + # Linting + ruff check src/ tests/ + ``` + +7. **Run All Tests** + ```bash + pytest tests/ -v --cov=imobench + ``` + +8. **Commit and Push** + ```bash + git add . + git commit -m "Add: brief description of changes" + git push origin feature/your-feature-name + ``` + +9. **Open a Pull Request** + - Describe your changes clearly + - Link any related issues + - Ensure CI passes + +## Development Guidelines + +### Code Style + +- Follow PEP 8 +- Use type hints for all functions +- Maximum line length: 100 characters +- Use descriptive variable names + +### Testing + +- Write tests for new functionality +- Maintain or improve test coverage +- Test edge cases and error conditions +- Use pytest fixtures for common setup + +### Documentation + +- Add docstrings to all public functions/classes +- Update README if adding new features +- Add examples for new functionality +- Keep docstrings clear and concise + +### Type Hints + +```python +from typing import Optional, List + +def load_data( + category: Optional[str] = None, + validate: bool = True +) -> List[Problem]: + """Load problems with optional filtering. + + Args: + category: Filter by category + validate: Enable validation + + Returns: + List of Problem objects + """ + pass +``` + +## Project Structure + +``` +imobench-pylib/ +├── src/imobench/ # Source code +│ ├── __init__.py # Public API +│ ├── types.py # Type definitions +│ ├── loader.py # Data loading +│ ├── validators.py # Validation logic +│ └── exceptions.py # Custom exceptions +├── tests/ # Test suite +├── examples/ # Usage examples +├── docs/ # Documentation +└── setup.py # Package configuration +``` + +## Commit Message Guidelines + +Use clear, descriptive commit messages: + +- `Add: new feature or functionality` +- `Fix: bug fix` +- `Update: modify existing functionality` +- `Refactor: code restructuring` +- `Docs: documentation changes` +- `Test: add or modify tests` +- `Chore: maintenance tasks` + +Example: +``` +Add: lazy loading support for gradingbench + +- Implement iterator-based loading +- Add lazy parameter to load_gradingbench() +- Update tests and documentation +``` + +## Questions? + +For questions about: +- **Library usage**: Open a GitHub issue +- **Dataset content**: See main repository +- **Research paper**: Check IMO Bench website + +## License + +By contributing, you agree that your contributions will be licensed under the Apache License 2.0. diff --git a/imobench-pylib/LICENSE b/imobench-pylib/LICENSE new file mode 100644 index 0000000..f11af38 --- /dev/null +++ b/imobench-pylib/LICENSE @@ -0,0 +1,170 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) 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. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), strict liability, or + otherwise, contract, or otherwise) arising in any way out of the use of + this software, even if advised of the possibility of such damage. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/imobench-pylib/MANIFEST.in b/imobench-pylib/MANIFEST.in new file mode 100644 index 0000000..689ecb2 --- /dev/null +++ b/imobench-pylib/MANIFEST.in @@ -0,0 +1,17 @@ +include README.md +include LICENSE +include pyproject.toml +include setup.py + +recursive-include src *.py +recursive-include tests *.py +recursive-include examples *.py +recursive-include examples *.md + +exclude .gitignore +exclude .github + +global-exclude __pycache__ +global-exclude *.py[cod] +global-exclude *.so +global-exclude .DS_Store diff --git a/imobench-pylib/README.md b/imobench-pylib/README.md new file mode 100644 index 0000000..23d8916 --- /dev/null +++ b/imobench-pylib/README.md @@ -0,0 +1,306 @@ +# IMO Bench Python Library + +A Python library for loading and working with the **IMO Bench** mathematical reasoning benchmarks from Google DeepMind. + +## Overview + +IMO Bench is a suite of advanced benchmarks designed to evaluate robust mathematical reasoning in AI systems. This library provides a simple, type-safe interface for loading and working with the benchmark datasets. + +### Datasets + +- **IMO-AnswerBench**: 400 challenging short-answer problems +- **IMO-ProofBench**: 60 expert-vetted proof-based problems +- **IMO-GradingBench**: 1000 human gradings for automatic evaluation development + +## Installation + +### From Source + +```bash +cd imobench-pylib +pip install -e . +``` + +### Development Installation + +```bash +pip install -e ".[dev]" +``` + +## Quick Start + +```python +from imobench import load_answerbench, load_proofbench, load_gradingbench + +# Load all short-answer problems +problems = load_answerbench() +print(f"Loaded {len(problems)} problems") + +# Filter by category +algebra_problems = load_answerbench(category="Algebra") +for problem in algebra_problems[:3]: + print(f"{problem.problem_id}: {problem.subcategory}") + +# Load proof-based problems +proof_problems = load_proofbench(level="IMO-easy") + +# Load grading data (use lazy loading for efficiency) +for grading in load_gradingbench(min_points=8, lazy=True): + print(f"Problem {grading.problem_id}: {grading.points}/10 points") + break # Process one at a time +``` + +## Usage Examples + +### Basic Loading + +```python +from imobench import load_answerbench + +# Load all problems +problems = load_answerbench() + +# Access problem fields +problem = problems[0] +print(problem.problem_id) # "imo-bench-algebra-001" +print(problem.category) # "Algebra" +print(problem.subcategory) # "Operation" +print(problem.problem) # LaTeX problem statement +print(problem.short_answer) # Expected answer +print(problem.source) # "IMO Shortlist 2021" +``` + +### Filtering + +```python +# Filter by category +geometry_problems = load_answerbench(category="Geometry") + +# Filter by source +imo_2021 = load_answerbench(source="IMO Shortlist 2021") + +# Multiple filters +algebra_inequalities = load_answerbench( + category="Algebra", + subcategory="Inequality" +) +``` + +### Working with ProofBench + +```python +from imobench import load_proofbench + +# Load by difficulty level +easy_problems = load_proofbench(level="IMO-easy") + +# Access detailed fields +problem = easy_problems[0] +print(problem.solution) # Reference solution +print(problem.grading_guidelines) # Grading criteria +``` + +### Efficient GradingBench Processing + +```python +from imobench import load_gradingbench + +# Load specific problem's gradings +gradings = load_gradingbench(problem_id="PB-Basic-001") + +# Filter by score range +high_quality = load_gradingbench(min_points=8) + +# Lazy loading for memory efficiency (recommended for large datasets) +for grading in load_gradingbench(lazy=True): + # Process one at a time + analyze_response(grading.response, grading.points) +``` + +### Custom Data Directory + +```python +from imobench import IMOBenchLoader +from pathlib import Path + +# Specify custom data location +loader = IMOBenchLoader(data_dir=Path("/path/to/imobench/data")) +problems = loader.load_answerbench() +``` + +### Type-Safe Access + +All data types are immutable dataclasses with full type hints: + +```python +from imobench.types import AnswerBenchProblem + +problem: AnswerBenchProblem = problems[0] +# IDE will provide autocomplete and type checking +``` + +## Data Schema + +### AnswerBenchProblem + +| Field | Type | Description | +|-------|------|-------------| +| `problem_id` | `str` | Unique identifier (e.g., "imo-bench-algebra-001") | +| `problem` | `str` | Problem statement in LaTeX format | +| `short_answer` | `str` | Expected answer | +| `category` | `str` | Main category (Algebra, Combinatorics, Geometry, Number theory) | +| `subcategory` | `str` | Specific subcategory | +| `source` | `str` | Original source of the problem | + +### ProofBenchProblem + +| Field | Type | Description | +|-------|------|-------------| +| `problem_id` | `str` | Unique identifier (e.g., "PB-Basic-001") | +| `problem` | `str` | Problem statement | +| `solution` | `str` | Reference solution | +| `grading_guidelines` | `str` | Guidelines for partial credit | +| `category` | `str` | Main category | +| `level` | `str` | Difficulty level (IMO-easy, pre-IMO, etc.) | +| `short_answer` | `str` | Brief expected answer | +| `source` | `str` | Original source | + +### GradingBenchEntry + +| Field | Type | Description | +|-------|------|-------------| +| `grading_id` | `str` | Unique identifier (e.g., "GB-0001") | +| `problem_id` | `str` | Reference to problem | +| `problem` | `str` | Problem statement | +| `solution` | `str` | Reference solution | +| `grading_guidelines` | `str` | Grading criteria | +| `response` | `str` | The response being graded | +| `points` | `int` | Points awarded (0-10) | +| `reward` | `float` | Reward value | +| `problem_source` | `str` | Original source | + +## API Reference + +### Loading Functions + +#### `load_answerbench(**kwargs) -> list[AnswerBenchProblem]` + +Load IMO-AnswerBench dataset. + +**Parameters:** +- `category` (Optional[str]): Filter by category +- `subcategory` (Optional[str]): Filter by subcategory +- `source` (Optional[str]): Filter by source +- `validate` (bool): Enable validation (default: True) + +#### `load_proofbench(**kwargs) -> list[ProofBenchProblem]` + +Load IMO-ProofBench dataset. + +**Parameters:** +- `category` (Optional[str]): Filter by category +- `level` (Optional[str]): Filter by difficulty level +- `validate` (bool): Enable validation (default: True) + +#### `load_gradingbench(**kwargs) -> list[GradingBenchEntry] | Iterator[GradingBenchEntry]` + +Load IMO-GradingBench dataset. + +**Parameters:** +- `problem_id` (Optional[str]): Filter by problem ID +- `min_points` (Optional[int]): Minimum points threshold +- `max_points` (Optional[int]): Maximum points threshold +- `validate` (bool): Enable validation (default: True) +- `lazy` (bool): Return iterator for memory efficiency (default: False) + +### Class: IMOBenchLoader + +Advanced loader with custom data directory support. + +```python +loader = IMOBenchLoader(data_dir=Path("/path/to/data")) +``` + +## Development + +### Running Tests + +```bash +# Install dev dependencies +pip install -e ".[dev]" + +# Run tests +pytest + +# Run with coverage +pytest --cov=imobench --cov-report=html +``` + +### Code Quality + +```bash +# Format code +black src/ tests/ + +# Type checking +mypy src/ + +# Linting +ruff check src/ tests/ +``` + +## Project Structure + +``` +imobench-pylib/ +├── src/ +│ └── imobench/ +│ ├── __init__.py # Public API +│ ├── types.py # Data type definitions +│ ├── loader.py # Loading functionality +│ ├── validators.py # Data validation +│ └── exceptions.py # Custom exceptions +├── tests/ +│ ├── conftest.py # Test configuration +│ ├── test_types.py # Type tests +│ ├── test_validators.py # Validation tests +│ ├── test_loader.py # Loader tests +│ └── test_integration.py # Integration tests +├── examples/ # Usage examples +├── docs/ # Documentation +├── setup.py # Package setup +├── pyproject.toml # Project configuration +└── README.md # This file +``` + +## License + +This library is licensed under the Apache License 2.0. See the main repository for full license details. + +## Citation + +```bibtex +@inproceedings{luong-etal-2025-towards, + title = "Towards Robust Mathematical Reasoning", + author = {Thang Luong and Dawsen Hwang and Hoang H. Nguyen and Golnaz Ghiasi and Yuri Chervonyi and Insuk Seo and Junsu Kim and Garrett Bingham and Jonathan Lee and Swaroop Mishra and Alex Zhai and Clara Huiyi Hu and Henryk Michalewski and Jimin Kim and Jeonghyun Ahn and Junhwi Bae and Xingyou Song and Trieu H. Trinh and Quoc V. Le and Junehyuk Jung}, + booktitle = "Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing", + year = "2025", + url = "https://aclanthology.org/2025.emnlp-main.1794/", +} +``` + +## Contributing + +This library is maintained as part of the Google DeepMind Superhuman Reasoning project. For issues or contributions related to the datasets themselves, please see the main repository. + +For library-specific issues or improvements, please open an issue describing: +- The problem or feature request +- Expected vs actual behavior +- Minimal reproducible example +- Python version and environment details + +## Support + +- **Documentation**: [https://imobench.github.io](https://imobench.github.io) +- **Issues**: [GitHub Issues](https://github.com/google-deepmind/superhuman/issues) +- **Repository**: [google-deepmind/superhuman](https://github.com/google-deepmind/superhuman) diff --git a/imobench-pylib/examples/README.md b/imobench-pylib/examples/README.md new file mode 100644 index 0000000..19a72b0 --- /dev/null +++ b/imobench-pylib/examples/README.md @@ -0,0 +1,98 @@ +# IMO Bench Python Library - Examples + +This directory contains example scripts demonstrating how to use the IMO Bench Python library. + +## Running Examples + +Make sure you have installed the library first: + +```bash +cd imobench-pylib +pip install -e . +``` + +## Available Examples + +### Quick Start (`quickstart.py`) + +Basic usage patterns for loading and working with IMO Bench datasets. + +```bash +python examples/quickstart.py +``` + +**Topics covered:** +- Basic loading of datasets +- Filtering by category, subcategory, and level +- Category and subcategory analysis +- Working with ProofBench +- Efficient GradingBench processing with lazy loading +- Analyzing problem sources + +### Advanced Usage (`advanced.py`) + +More sophisticated patterns for working with the datasets. + +```bash +python examples/advanced.py +``` + +**Topics covered:** +- Custom data directories +- Data validation and error handling +- Cross-dataset analysis +- Performance optimization techniques +- Statistical analysis +- Difficulty pattern analysis + +## Common Patterns + +### Loading Data + +```python +from imobench import load_answerbench, load_proofbench, load_gradingbench + +# Load all problems +problems = load_answerbench() + +# Filter by category +algebra = load_answerbench(category="Algebra") + +# Lazy loading for efficiency +for grading in load_gradingbench(lazy=True): + process(grading) +``` + +### Custom Data Directory + +```python +from imobench import IMOBenchLoader +from pathlib import Path + +loader = IMOBenchLoader(data_dir=Path("/path/to/data")) +problems = loader.load_answerbench() +``` + +### Error Handling + +```python +from imobench.exceptions import ValidationError, DataLoadError + +try: + problems = load_answerbench(validate=True) +except ValidationError as e: + print(f"Invalid data: {e}") +except DataLoadError as e: + print(f"Loading failed: {e}") +``` + +## Tips + +1. **Use lazy loading** for GradingBench (186K entries) to avoid memory issues +2. **Disable validation** (`validate=False`) for faster loading if data is trusted +3. **Filter early** using built-in parameters rather than loading everything +4. **Use type hints** to get IDE autocomplete and type checking + +## More Information + +See the main [README.md](../README.md) for complete API documentation. diff --git a/imobench-pylib/examples/advanced.py b/imobench-pylib/examples/advanced.py new file mode 100644 index 0000000..0a7884b --- /dev/null +++ b/imobench-pylib/examples/advanced.py @@ -0,0 +1,269 @@ +"""Advanced usage examples for IMO Bench library. + +This script demonstrates more advanced patterns including: +- Custom data directories +- Cross-dataset analysis +- Performance optimization +- Error handling +""" + +from pathlib import Path +from typing import Dict, List +from imobench import IMOBenchLoader +from imobench.types import AnswerBenchProblem, ProofBenchProblem, GradingBenchEntry +from imobench.exceptions import ValidationError, DataLoadError + + +def example_custom_loader(): + """Example 1: Using custom data directory.""" + print("=" * 60) + print("Example 1: Custom Data Directory") + print("=" * 60) + + # Specify custom location for IMO Bench data + # Adjust this path to match your setup + repo_root = Path(__file__).parent.parent.parent + data_dir = repo_root / "imobench" + + try: + loader = IMOBenchLoader(data_dir=data_dir) + problems = loader.load_answerbench() + print(f"\nSuccessfully loaded {len(problems)} problems from: {data_dir}") + except Exception as e: + print(f"\nError loading data: {e}") + print("Adjust the data_dir path to match your setup") + + +def example_validation(): + """Example 2: Data validation and error handling.""" + print("\n" + "=" * 60) + print("Example 2: Validation and Error Handling") + print("=" * 60) + + loader = IMOBenchLoader() + + # Load with validation enabled (default) + try: + problems = loader.load_answerbench(validate=True) + print(f"\nValidation passed! Loaded {len(problems)} valid problems") + except ValidationError as e: + print(f"\nValidation error: {e}") + except DataLoadError as e: + print(f"\nData loading error: {e}") + + # Disable validation for faster loading (if data is trusted) + problems_fast = loader.load_answerbench(validate=False) + print(f"Fast loading (no validation): {len(problems_fast)} problems") + + +def example_cross_dataset_analysis(): + """Example 3: Analyzing relationships across datasets.""" + print("\n" + "=" * 60) + print("Example 3: Cross-Dataset Analysis") + print("=" * 60) + + loader = IMOBenchLoader() + + # Load datasets + proof_problems = loader.load_proofbench() + grading_entries = loader.load_gradingbench() + + # Build index of proof problems + proof_index: Dict[str, ProofBenchProblem] = { + p.problem_id: p for p in proof_problems + } + + # Analyze gradings per problem + gradings_per_problem: Dict[str, List[GradingBenchEntry]] = {} + for entry in grading_entries[:1000]: # Sample first 1000 + if entry.problem_id not in gradings_per_problem: + gradings_per_problem[entry.problem_id] = [] + gradings_per_problem[entry.problem_id].append(entry) + + print(f"\nAnalyzed {len(gradings_per_problem)} problems with gradings") + + # Find problems with most gradings + top_graded = sorted( + gradings_per_problem.items(), + key=lambda x: len(x[1]), + reverse=True + )[:5] + + print("\nMost graded problems:") + for problem_id, entries in top_graded: + if problem_id in proof_index: + problem = proof_index[problem_id] + avg_points = sum(e.points for e in entries) / len(entries) + print(f" {problem_id} ({problem.level}): " + f"{len(entries)} gradings, avg {avg_points:.1f} points") + + +def example_performance_optimization(): + """Example 4: Performance optimization techniques.""" + print("\n" + "=" * 60) + print("Example 4: Performance Optimization") + print("=" * 60) + + loader = IMOBenchLoader() + + # Strategy 1: Lazy loading for large datasets + print("\nStrategy 1: Lazy loading") + print(" Processing gradingbench entries one at a time...") + + count = 0 + for entry in loader.load_gradingbench(lazy=True): + count += 1 + if count >= 1000: + break + + print(f" Processed {count} entries without loading entire dataset") + + # Strategy 2: Filtering at load time + print("\nStrategy 2: Early filtering") + print(" Loading only high-scoring entries...") + + high_scores = loader.load_gradingbench(min_points=9) + print(f" Loaded {len(high_scores)} high-scoring entries") + + # Strategy 3: Disable validation for trusted data + print("\nStrategy 3: Fast loading (validation disabled)") + + import time + start = time.time() + problems_validated = loader.load_answerbench(validate=True) + time_validated = time.time() - start + + start = time.time() + problems_fast = loader.load_answerbench(validate=False) + time_fast = time.time() - start + + print(f" With validation: {time_validated:.3f}s") + print(f" Without validation: {time_fast:.3f}s") + print(f" Speedup: {time_validated/time_fast:.1f}x") + + +def example_statistical_analysis(): + """Example 5: Statistical analysis of datasets.""" + print("\n" + "=" * 60) + print("Example 5: Statistical Analysis") + print("=" * 60) + + loader = IMOBenchLoader() + problems = loader.load_answerbench() + + # Analyze answer formats + answer_types = { + 'numeric': 0, + 'algebraic': 0, + 'interval': 0, + 'set': 0, + 'other': 0, + } + + for problem in problems: + answer = problem.short_answer.strip() + if answer.isdigit() or (answer.startswith('-') and answer[1:].isdigit()): + answer_types['numeric'] += 1 + elif '$' in answer: + answer_types['algebraic'] += 1 + elif 'infty' in answer or '[' in answer or '(' in answer: + answer_types['interval'] += 1 + elif '{' in answer or '}' in answer: + answer_types['set'] += 1 + else: + answer_types['other'] += 1 + + print("\nAnswer format distribution:") + for format_type, count in sorted(answer_types.items(), key=lambda x: -x[1]): + pct = 100 * count / len(problems) + print(f" {format_type}: {count} ({pct:.1f}%)") + + # Analyze problem statement lengths + lengths = [len(p.problem) for p in problems] + avg_length = sum(lengths) / len(lengths) + min_length = min(lengths) + max_length = max(lengths) + + print(f"\nProblem statement statistics:") + print(f" Average length: {avg_length:.0f} characters") + print(f" Shortest: {min_length} characters") + print(f" Longest: {max_length} characters") + + +def example_difficulty_analysis(): + """Example 6: Analyzing difficulty patterns in GradingBench.""" + print("\n" + "=" * 60) + print("Example 6: Difficulty Analysis") + print("=" * 60) + + loader = IMOBenchLoader() + + # Sample grading entries + entries = loader.load_gradingbench()[:5000] + + # Score distribution + score_dist = {i: 0 for i in range(11)} + for entry in entries: + score_dist[entry.points] += 1 + + print("\nScore distribution (0-10 points):") + print(" Score | Count | Percentage | Bar") + print(" " + "-" * 50) + + max_count = max(score_dist.values()) + for score, count in sorted(score_dist.items()): + pct = 100 * count / len(entries) + bar_length = int(30 * count / max_count) + bar = "█" * bar_length + print(f" {score:5d} | {count:5d} | {pct:6.1f}% | {bar}") + + # Average scores by problem + problem_scores: Dict[str, List[int]] = {} + for entry in entries: + if entry.problem_id not in problem_scores: + problem_scores[entry.problem_id] = [] + problem_scores[entry.problem_id].append(entry.points) + + problem_avgs = { + pid: sum(scores) / len(scores) + for pid, scores in problem_scores.items() + } + + # Find hardest and easiest problems + sorted_problems = sorted(problem_avgs.items(), key=lambda x: x[1]) + + print(f"\nEasiest problems (avg score):") + for pid, avg in sorted_problems[-3:]: + print(f" {pid}: {avg:.2f}/10") + + print(f"\nHardest problems (avg score):") + for pid, avg in sorted_problems[:3]: + print(f" {pid}: {avg:.2f}/10") + + +def main(): + """Run all advanced examples.""" + print("\n" + "=" * 60) + print("IMO BENCH LIBRARY - ADVANCED EXAMPLES") + print("=" * 60) + + try: + example_custom_loader() + example_validation() + example_cross_dataset_analysis() + example_performance_optimization() + example_statistical_analysis() + example_difficulty_analysis() + + print("\n" + "=" * 60) + print("All advanced examples completed!") + print("=" * 60 + "\n") + + except Exception as e: + print(f"\nError: {e}") + import traceback + traceback.print_exc() + + +if __name__ == "__main__": + main() diff --git a/imobench-pylib/examples/quickstart.py b/imobench-pylib/examples/quickstart.py new file mode 100644 index 0000000..483d1a8 --- /dev/null +++ b/imobench-pylib/examples/quickstart.py @@ -0,0 +1,200 @@ +"""Basic usage examples for IMO Bench library. + +This script demonstrates the most common use cases for loading and +working with IMO Bench datasets. +""" + +from imobench import load_answerbench, load_proofbench, load_gradingbench + + +def example_basic_loading(): + """Example 1: Basic loading of datasets.""" + print("=" * 60) + print("Example 1: Basic Loading") + print("=" * 60) + + # Load all short-answer problems + problems = load_answerbench() + print(f"\nLoaded {len(problems)} problems from AnswerBench") + + # Display first problem + first = problems[0] + print(f"\nFirst problem:") + print(f" ID: {first.problem_id}") + print(f" Category: {first.category}") + print(f" Subcategory: {first.subcategory}") + print(f" Source: {first.source}") + print(f" Problem: {first.problem[:100]}...") + print(f" Answer: {first.short_answer}") + + +def example_filtering(): + """Example 2: Filtering datasets.""" + print("\n" + "=" * 60) + print("Example 2: Filtering") + print("=" * 60) + + # Filter by category + algebra_problems = load_answerbench(category="Algebra") + print(f"\nAlgebra problems: {len(algebra_problems)}") + + # Filter by subcategory + inequalities = load_answerbench( + category="Algebra", + subcategory="Inequality" + ) + print(f"Algebra inequalities: {len(inequalities)}") + + # Filter proof problems by difficulty + easy_proofs = load_proofbench(level="IMO-easy") + print(f"Easy proof problems: {len(easy_proofs)}") + + +def example_category_analysis(): + """Example 3: Analyzing category distribution.""" + print("\n" + "=" * 60) + print("Example 3: Category Analysis") + print("=" * 60) + + problems = load_answerbench() + + # Count problems by category + categories = {} + for problem in problems: + categories[problem.category] = categories.get(problem.category, 0) + 1 + + print("\nProblems by category:") + for category, count in sorted(categories.items()): + print(f" {category}: {count}") + + +def example_subcategory_analysis(): + """Example 4: Analyzing subcategories within a category.""" + print("\n" + "=" * 60) + print("Example 4: Subcategory Analysis") + print("=" * 60) + + # Focus on Algebra problems + algebra = load_answerbench(category="Algebra") + + # Count subcategories + subcategories = {} + for problem in algebra: + subcategories[problem.subcategory] = \ + subcategories.get(problem.subcategory, 0) + 1 + + print(f"\nAlgebra subcategories ({len(subcategories)} total):") + for subcat, count in sorted(subcategories.items(), key=lambda x: -x[1]): + print(f" {subcat}: {count}") + + +def example_proofbench(): + """Example 5: Working with ProofBench.""" + print("\n" + "=" * 60) + print("Example 5: ProofBench Exploration") + print("=" * 60) + + # Load all proof problems + proofs = load_proofbench() + print(f"\nTotal proof problems: {len(proofs)}") + + # Analyze difficulty levels + levels = {} + for proof in proofs: + levels[proof.level] = levels.get(proof.level, 0) + 1 + + print("\nDifficulty distribution:") + for level, count in sorted(levels.items()): + print(f" {level}: {count}") + + # Show example problem + if proofs: + example = proofs[0] + print(f"\nExample problem ({example.problem_id}):") + print(f" Level: {example.level}") + print(f" Category: {example.category}") + print(f" Problem: {example.problem[:150]}...") + + +def example_gradingbench_lazy(): + """Example 6: Efficient GradingBench processing with lazy loading.""" + print("\n" + "=" * 60) + print("Example 6: GradingBench with Lazy Loading") + print("=" * 60) + + # Use lazy loading to process entries one at a time + print("\nProcessing high-scoring entries (≥8 points)...") + + count = 0 + points_sum = 0 + + for entry in load_gradingbench(min_points=8, lazy=True): + count += 1 + points_sum += entry.points + + # Process first few as examples + if count <= 3: + print(f"\n Entry {count}:") + print(f" Grading ID: {entry.grading_id}") + print(f" Problem ID: {entry.problem_id}") + print(f" Points: {entry.points}/10") + print(f" Response: {entry.response[:100]}...") + + # Stop after processing 100 for this example + if count >= 100: + break + + if count > 0: + avg_points = points_sum / count + print(f"\nProcessed {count} entries") + print(f"Average points: {avg_points:.2f}/10") + + +def example_source_analysis(): + """Example 7: Analyzing problem sources.""" + print("\n" + "=" * 60) + print("Example 7: Source Analysis") + print("=" * 60) + + problems = load_answerbench() + + # Count problems by source + sources = {} + for problem in problems: + sources[problem.source] = sources.get(problem.source, 0) + 1 + + print(f"\nMost common sources:") + for source, count in sorted(sources.items(), key=lambda x: -x[1])[:10]: + print(f" {source}: {count} problems") + + +def main(): + """Run all examples.""" + print("\n" + "=" * 60) + print("IMO BENCH LIBRARY - USAGE EXAMPLES") + print("=" * 60) + + try: + example_basic_loading() + example_filtering() + example_category_analysis() + example_subcategory_analysis() + example_proofbench() + example_gradingbench_lazy() + example_source_analysis() + + print("\n" + "=" * 60) + print("All examples completed successfully!") + print("=" * 60 + "\n") + + except Exception as e: + print(f"\nError: {e}") + print("\nMake sure the imobench data directory is accessible.") + print("You may need to specify a custom data directory:") + print("\n from imobench import IMOBenchLoader") + print(" from pathlib import Path") + print(" loader = IMOBenchLoader(data_dir=Path('/path/to/imobench'))") + + +if __name__ == "__main__": + main() diff --git a/imobench-pylib/pyproject.toml b/imobench-pylib/pyproject.toml new file mode 100644 index 0000000..ff86356 --- /dev/null +++ b/imobench-pylib/pyproject.toml @@ -0,0 +1,104 @@ +[build-system] +requires = ["setuptools>=61.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "imobench" +version = "0.1.0" +description = "Python library for loading and working with IMO Bench datasets" +readme = "README.md" +requires-python = ">=3.9" +license = {text = "Apache-2.0"} +authors = [ + {name = "IMO Bench Contributors"} +] +keywords = ["mathematics", "reasoning", "benchmark", "imo", "olympiad", "ai"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] + +[project.optional-dependencies] +dev = [ + "pytest>=7.0.0", + "pytest-cov>=4.0.0", + "black>=23.0.0", + "mypy>=1.0.0", + "ruff>=0.1.0", +] +pandas = [ + "pandas>=1.5.0", +] + +[project. urls] +Homepage = "https://imobench.github.io" +Repository = "https://github.com/google-deepmind/superhuman" +Issues = "https://github.com/google-deepmind/superhuman/issues" + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.pytest.ini_options] +testpaths = ["tests"] +python_files = ["test_*.py"] +python_classes = ["Test*"] +python_functions = ["test_*"] +addopts = [ + "-v", + "--strict-markers", + "--tb=short", +] + +[tool.black] +line-length = 100 +target-version = ["py39", "py310", "py311", "py312"] +include = '\.pyi?$' + +[tool.mypy] +python_version = "3.9" +warn_return_any = true +warn_unused_configs = true +disallow_untyped_defs = true +disallow_incomplete_defs = true +check_untyped_defs = true +no_implicit_optional = true +warn_redundant_casts = true +warn_unused_ignores = true +warn_no_return = true +strict_equality = true + +[tool.ruff] +line-length = 100 +target-version = "py39" +select = [ + "E", # pycodestyle errors + "W", # pycodestyle warnings + "F", # pyflakes + "I", # isort + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "UP", # pyupgrade +] +ignore = [ + "E501", # line too long (handled by black) +] + +[tool.coverage.run] +source = ["src"] +omit = ["*/tests/*", "*/test_*.py"] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise AssertionError", + "raise NotImplementedError", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] diff --git a/imobench-pylib/setup.py b/imobench-pylib/setup.py new file mode 100644 index 0000000..45bc148 --- /dev/null +++ b/imobench-pylib/setup.py @@ -0,0 +1,69 @@ +"""Setup configuration for imobench package.""" + +from setuptools import setup, find_packages +from pathlib import Path + +# Read the README file +readme_file = Path(__file__).parent / "README.md" +if readme_file.exists(): + long_description = readme_file.read_text(encoding="utf-8") +else: + long_description = "Python library for loading and working with IMO Bench datasets" + +setup( + name="imobench", + version="0.1.0", + author="IMO Bench Contributors", + author_email="", + description="Python library for loading and working with IMO Bench mathematical reasoning benchmarks", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/google-deepmind/superhuman", + project_urls={ + "Bug Tracker": "https://github.com/google-deepmind/superhuman/issues", + "Documentation": "https://imobench.github.io", + "Source Code": "https://github.com/google-deepmind/superhuman", + }, + package_dir={"": "src"}, + packages=find_packages(where="src"), + classifiers=[ + "Development Status :: 3 - Alpha", + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Topic :: Software Development :: Libraries :: Python Modules", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Operating System :: OS Independent", + ], + python_requires=">=3.9", + install_requires=[ + # No external dependencies required - uses only stdlib + ], + extras_require={ + "dev": [ + "pytest>=7.0.0", + "pytest-cov>=4.0.0", + "black>=23.0.0", + "mypy>=1.0.0", + "ruff>=0.1.0", + ], + "pandas": [ + "pandas>=1.5.0", + ], + }, + keywords=[ + "mathematics", + "reasoning", + "benchmark", + "imo", + "olympiad", + "ai", + "machine-learning", + "evaluation", + ], +) diff --git a/imobench-pylib/src/imobench/__init__.py b/imobench-pylib/src/imobench/__init__.py new file mode 100644 index 0000000..9e39817 --- /dev/null +++ b/imobench-pylib/src/imobench/__init__.py @@ -0,0 +1,40 @@ +"""IMO Bench - Python library for loading and working with IMO Bench datasets. + +This package provides utilities for loading, validating, and working with +the IMO Bench mathematical reasoning benchmarks, including: +- IMO-AnswerBench: 400 challenging short-answer problems +- IMO-ProofBench: 60 proof-based problems +- IMO-GradingBench: 1000 human gradings for evaluation + +Example: + >>> from imobench import load_answerbench, load_proofbench + >>> problems = load_answerbench() + >>> for problem in problems[:5]: + ... print(f"{problem.problem_id}: {problem.category}") +""" + +__version__ = "0.1.0" +__author__ = "IMO Bench Contributors" +__all__ = [ + "load_answerbench", + "load_proofbench", + "load_gradingbench", + "AnswerBenchProblem", + "ProofBenchProblem", + "GradingBenchEntry", + "IMOBenchLoader", + "ValidationError", +] + +from .loader import ( + load_answerbench, + load_proofbench, + load_gradingbench, + IMOBenchLoader, +) +from .types import ( + AnswerBenchProblem, + ProofBenchProblem, + GradingBenchEntry, +) +from .exceptions import ValidationError diff --git a/imobench-pylib/src/imobench/exceptions.py b/imobench-pylib/src/imobench/exceptions.py new file mode 100644 index 0000000..fe71d6f --- /dev/null +++ b/imobench-pylib/src/imobench/exceptions.py @@ -0,0 +1,21 @@ +"""Custom exceptions for IMO Bench library.""" + + +class IMOBenchError(Exception): + """Base exception for all IMO Bench errors.""" + pass + + +class ValidationError(IMOBenchError): + """Raised when data validation fails.""" + pass + + +class DataLoadError(IMOBenchError): + """Raised when data cannot be loaded.""" + pass + + +class FileNotFoundError(DataLoadError): + """Raised when a dataset file cannot be found.""" + pass diff --git a/imobench-pylib/src/imobench/loader.py b/imobench-pylib/src/imobench/loader.py new file mode 100644 index 0000000..34d360b --- /dev/null +++ b/imobench-pylib/src/imobench/loader.py @@ -0,0 +1,318 @@ +"""Data loading functionality for IMO Bench datasets.""" + +import csv +from pathlib import Path +from typing import Iterator, Optional, Callable + +from .types import ( + AnswerBenchProblem, + ProofBenchProblem, + GradingBenchEntry, + AnswerBenchDataset, + ProofBenchDataset, + GradingBenchDataset, +) +from .exceptions import DataLoadError, FileNotFoundError as IMOFileNotFoundError +from .validators import ( + validate_answerbench_row, + validate_proofbench_row, + validate_gradingbench_row, +) + + +class IMOBenchLoader: + """Main loader class for IMO Bench datasets. + + This class provides methods to load datasets from CSV files with + support for filtering, lazy loading, and validation. + + Args: + data_dir: Path to the directory containing CSV files. + Defaults to looking for '../imobench' relative to package. + + Example: + >>> loader = IMOBenchLoader() + >>> problems = loader.load_answerbench(category="Algebra") + >>> print(f"Loaded {len(problems)} algebra problems") + """ + + def __init__(self, data_dir: Optional[Path] = None): + if data_dir is None: + # Default: look for imobench directory at repo root + package_dir = Path(__file__).parent + data_dir = package_dir.parent.parent.parent / "imobench" + + self.data_dir = Path(data_dir) + if not self.data_dir.exists(): + raise IMOFileNotFoundError( + f"Data directory not found: {self.data_dir}\n" + f"Please provide the correct path to the imobench directory." + ) + + def _load_csv(self, filename: str) -> list[dict[str, str]]: + """Load a CSV file and return rows as dictionaries.""" + filepath = self.data_dir / filename + + if not filepath.exists(): + raise IMOFileNotFoundError( + f"Dataset file not found: {filepath}\n" + f"Expected location: {filepath}" + ) + + try: + with open(filepath, 'r', encoding='utf-8') as f: + reader = csv.DictReader(f) + return list(reader) + except Exception as e: + raise DataLoadError(f"Error reading {filename}: {e}") from e + + def load_answerbench( + self, + category: Optional[str] = None, + subcategory: Optional[str] = None, + source: Optional[str] = None, + validate: bool = True, + ) -> AnswerBenchDataset: + """Load IMO-AnswerBench dataset. + + Args: + category: Filter by category (e.g., "Algebra", "Geometry") + subcategory: Filter by subcategory + source: Filter by source (e.g., "IMO Shortlist 2021") + validate: Whether to validate each row + + Returns: + List of AnswerBenchProblem objects + + Raises: + DataLoadError: If the file cannot be loaded + ValidationError: If validation is enabled and data is invalid + """ + rows = self._load_csv("answerbench.csv") + problems = [] + + for row in rows: + if validate: + validate_answerbench_row(row) + + # Apply filters + if category and row['Category'] != category: + continue + if subcategory and row['Subcategory'] != subcategory: + continue + if source and row['Source'] != source: + continue + + problem = AnswerBenchProblem( + problem_id=row['Problem ID'], + problem=row['Problem'], + short_answer=row['Short Answer'], + category=row['Category'], + subcategory=row['Subcategory'], + source=row['Source'], + ) + problems.append(problem) + + return problems + + def load_proofbench( + self, + category: Optional[str] = None, + level: Optional[str] = None, + validate: bool = True, + ) -> ProofBenchDataset: + """Load IMO-ProofBench dataset. + + Args: + category: Filter by category (e.g., "Algebra", "Geometry") + level: Filter by difficulty level (e.g., "IMO-easy", "pre-IMO") + validate: Whether to validate each row + + Returns: + List of ProofBenchProblem objects + + Raises: + DataLoadError: If the file cannot be loaded + ValidationError: If validation is enabled and data is invalid + """ + rows = self._load_csv("proofbench.csv") + problems = [] + + for row in rows: + if validate: + validate_proofbench_row(row) + + # Apply filters + if category and row['Category'] != category: + continue + if level and row['Level'] != level: + continue + + problem = ProofBenchProblem( + problem_id=row['Problem ID'], + problem=row['Problem'], + solution=row['Solution'], + grading_guidelines=row['Grading guidelines'], + category=row['Category'], + level=row['Level'], + short_answer=row['Short Answer'], + source=row['Source'], + ) + problems.append(problem) + + return problems + + def load_gradingbench( + self, + problem_id: Optional[str] = None, + min_points: Optional[int] = None, + max_points: Optional[int] = None, + validate: bool = True, + lazy: bool = False, + ) -> GradingBenchDataset | Iterator[GradingBenchEntry]: + """Load IMO-GradingBench dataset. + + Note: This dataset is large (186K lines). Consider using lazy=True + for memory-efficient iteration. + + Args: + problem_id: Filter by problem ID + min_points: Filter by minimum points awarded + max_points: Filter by maximum points awarded + validate: Whether to validate each row + lazy: If True, return an iterator instead of loading all data + + Returns: + List of GradingBenchEntry objects, or Iterator if lazy=True + + Raises: + DataLoadError: If the file cannot be loaded + ValidationError: If validation is enabled and data is invalid + """ + if lazy: + return self._iter_gradingbench( + problem_id=problem_id, + min_points=min_points, + max_points=max_points, + validate=validate, + ) + + rows = self._load_csv("gradingbench.csv") + entries = [] + + for row in rows: + if validate: + validate_gradingbench_row(row) + + # Parse numeric fields + try: + points = int(row['Points']) + reward = row['Reward'].strip() + except (ValueError, KeyError) as e: + if validate: + raise DataLoadError(f"Invalid field: {e}") from e + continue + + # Apply filters + if problem_id and row['Problem ID'] != problem_id: + continue + if min_points is not None and points < min_points: + continue + if max_points is not None and points > max_points: + continue + + entry = GradingBenchEntry( + grading_id=row['Grading ID'], + problem_id=row['Problem ID'], + problem=row['Problem'], + solution=row['Solution'], + grading_guidelines=row['Grading guidelines'], + response=row['Response'], + points=points, + reward=reward, + problem_source=row['Problem Source'], + ) + entries.append(entry) + + return entries + + def _iter_gradingbench( + self, + problem_id: Optional[str] = None, + min_points: Optional[int] = None, + max_points: Optional[int] = None, + validate: bool = True, + ) -> Iterator[GradingBenchEntry]: + """Lazy iterator for gradingbench dataset.""" + filepath = self.data_dir / "gradingbench.csv" + + with open(filepath, 'r', encoding='utf-8') as f: + reader = csv.DictReader(f) + + for row in reader: + if validate: + validate_gradingbench_row(row) + + try: + points = int(row['Points']) + reward = row['Reward'].strip() + except (ValueError, KeyError): + if validate: + raise + continue + + # Apply filters + if problem_id and row['Problem ID'] != problem_id: + continue + if min_points is not None and points < min_points: + continue + if max_points is not None and points > max_points: + continue + + yield GradingBenchEntry( + grading_id=row['Grading ID'], + problem_id=row['Problem ID'], + problem=row['Problem'], + solution=row['Solution'], + grading_guidelines=row['Grading guidelines'], + response=row['Response'], + points=points, + reward=reward, + problem_source=row['Problem Source'], + ) + + +# Convenience functions using default loader +_default_loader: Optional[IMOBenchLoader] = None + + +def _get_default_loader() -> IMOBenchLoader: + """Get or create the default loader instance.""" + global _default_loader + if _default_loader is None: + _default_loader = IMOBenchLoader() + return _default_loader + + +def load_answerbench(**kwargs) -> AnswerBenchDataset: + """Load IMO-AnswerBench using default loader. + + See IMOBenchLoader.load_answerbench() for arguments. + """ + return _get_default_loader().load_answerbench(**kwargs) + + +def load_proofbench(**kwargs) -> ProofBenchDataset: + """Load IMO-ProofBench using default loader. + + See IMOBenchLoader.load_proofbench() for arguments. + """ + return _get_default_loader().load_proofbench(**kwargs) + + +def load_gradingbench(**kwargs) -> GradingBenchDataset | Iterator[GradingBenchEntry]: + """Load IMO-GradingBench using default loader. + + See IMOBenchLoader.load_gradingbench() for arguments. + """ + return _get_default_loader().load_gradingbench(**kwargs) diff --git a/imobench-pylib/src/imobench/types.py b/imobench-pylib/src/imobench/types.py new file mode 100644 index 0000000..5274510 --- /dev/null +++ b/imobench-pylib/src/imobench/types.py @@ -0,0 +1,89 @@ +"""Type definitions for IMO Bench datasets.""" + +from dataclasses import dataclass +from typing import Optional + + +@dataclass(frozen=True) +class AnswerBenchProblem: + """A problem from IMO-AnswerBench. + + Attributes: + problem_id: Unique identifier (e.g., "imo-bench-algebra-001") + problem: The problem statement in LaTeX format + short_answer: The expected answer + category: Main category (Algebra, Combinatorics, Geometry, Number theory) + subcategory: Specific subcategory within the main category + source: Original source of the problem + """ + problem_id: str + problem: str + short_answer: str + category: str + subcategory: str + source: str + + def __repr__(self) -> str: + return f"AnswerBenchProblem(id='{self.problem_id}', category='{self.category}')" + + +@dataclass(frozen=True) +class ProofBenchProblem: + """A problem from IMO-ProofBench. + + Attributes: + problem_id: Unique identifier (e.g., "PB-Basic-001") + problem: The problem statement in LaTeX format + solution: Reference solution + grading_guidelines: Guidelines for grading partial solutions + category: Main category (Algebra, Combinatorics, Geometry, Number theory) + level: Difficulty level (e.g., "IMO-easy", "pre-IMO", "IMO-hard") + short_answer: Brief expected answer + source: Original source of the problem + """ + problem_id: str + problem: str + solution: str + grading_guidelines: str + category: str + level: str + short_answer: str + source: str + + def __repr__(self) -> str: + return f"ProofBenchProblem(id='{self.problem_id}', level='{self.level}')" + + +@dataclass(frozen=True) +class GradingBenchEntry: + """An entry from IMO-GradingBench. + + Attributes: + grading_id: Unique identifier (e.g., "GB-0001") + problem_id: Reference to the problem being graded + problem: The problem statement + solution: Reference solution + grading_guidelines: Grading criteria + response: The response being graded + points: Points awarded (0-10 scale) + reward: Reward category (e.g., "Correct", "Partial", "Incorrect", "Almost") + problem_source: Original source of the problem + """ + grading_id: str + problem_id: str + problem: str + solution: str + grading_guidelines: str + response: str + points: int + reward: str + problem_source: str + + def __repr__(self) -> str: + return f"GradingBenchEntry(id='{self.grading_id}', points={self.points})" + + +# Type aliases for collections +AnswerBenchDataset = list[AnswerBenchProblem] +ProofBenchDataset = list[ProofBenchProblem] +GradingBenchDataset = list[GradingBenchEntry] diff --git a/imobench-pylib/src/imobench/validators.py b/imobench-pylib/src/imobench/validators.py new file mode 100644 index 0000000..09f33fc --- /dev/null +++ b/imobench-pylib/src/imobench/validators.py @@ -0,0 +1,183 @@ +"""Validation utilities for IMO Bench datasets.""" + +from typing import Any +from .exceptions import ValidationError + + +# Required fields for each dataset +ANSWERBENCH_REQUIRED_FIELDS = { + 'Problem ID', 'Problem', 'Short Answer', 'Category', 'Subcategory', 'Source' +} + +PROOFBENCH_REQUIRED_FIELDS = { + 'Problem ID', 'Problem', 'Solution', 'Grading guidelines', + 'Category', 'Level', 'Short Answer', 'Source' +} + +GRADINGBENCH_REQUIRED_FIELDS = { + 'Grading ID', 'Problem ID', 'Problem', 'Solution', + 'Grading guidelines', 'Response', 'Points', 'Reward', 'Problem Source' +} + +# Valid categories +VALID_CATEGORIES = {'Algebra', 'Combinatorics', 'Geometry', 'Number theory'} + + +def validate_answerbench_row(row: dict[str, Any]) -> None: + """Validate a row from answerbench.csv. + + Args: + row: Dictionary representing a CSV row + + Raises: + ValidationError: If validation fails + """ + # Check required fields + missing_fields = ANSWERBENCH_REQUIRED_FIELDS - set(row.keys()) + if missing_fields: + raise ValidationError( + f"Missing required fields: {', '.join(missing_fields)}" + ) + + # Check for empty values + for field in ANSWERBENCH_REQUIRED_FIELDS: + if not row[field] or not row[field].strip(): + raise ValidationError(f"Empty value for required field: {field}") + + # Validate category + if row['Category'] not in VALID_CATEGORIES: + raise ValidationError( + f"Invalid category: {row['Category']}. " + f"Must be one of: {', '.join(VALID_CATEGORIES)}" + ) + + # Validate problem ID format + if not row['Problem ID'].startswith('imo-bench-'): + raise ValidationError( + f"Invalid Problem ID format: {row['Problem ID']}. " + f"Should start with 'imo-bench-'" + ) + + +def validate_proofbench_row(row: dict[str, Any]) -> None: + """Validate a row from proofbench.csv. + + Args: + row: Dictionary representing a CSV row + + Raises: + ValidationError: If validation fails + """ + # Check required fields + missing_fields = PROOFBENCH_REQUIRED_FIELDS - set(row.keys()) + if missing_fields: + raise ValidationError( + f"Missing required fields: {', '.join(missing_fields)}" + ) + + # Check for empty values (allow empty short_answer as it can be descriptive) + for field in PROOFBENCH_REQUIRED_FIELDS - {'Short Answer'}: + if not row[field] or not row[field].strip(): + raise ValidationError(f"Empty value for required field: {field}") + + # Validate category + if row['Category'] not in VALID_CATEGORIES: + raise ValidationError( + f"Invalid category: {row['Category']}. " + f"Must be one of: {', '.join(VALID_CATEGORIES)}" + ) + + # Validate problem ID format + if not row['Problem ID'].startswith('PB-'): + raise ValidationError( + f"Invalid Problem ID format: {row['Problem ID']}. " + f"Should start with 'PB-'" + ) + + +def validate_gradingbench_row(row: dict[str, Any]) -> None: + """Validate a row from gradingbench.csv. + + Args: + row: Dictionary representing a CSV row + + Raises: + ValidationError: If validation fails + """ + # Check required fields + missing_fields = GRADINGBENCH_REQUIRED_FIELDS - set(row.keys()) + if missing_fields: + raise ValidationError( + f"Missing required fields: {', '.join(missing_fields)}" + ) + + # Check for empty values + for field in GRADINGBENCH_REQUIRED_FIELDS: + if field not in row or row[field] is None: + raise ValidationError(f"Missing field: {field}") + if isinstance(row[field], str) and not row[field].strip(): + raise ValidationError(f"Empty value for required field: {field}") + + # Validate grading ID format + if not row['Grading ID'].startswith('GB-'): + raise ValidationError( + f"Invalid Grading ID format: {row['Grading ID']}. " + f"Should start with 'GB-'" + ) + + # Validate numeric fields + try: + points = int(row['Points']) + if not 0 <= points <= 10: + raise ValidationError( + f"Points must be between 0 and 10, got: {points}" + ) + except ValueError: + raise ValidationError(f"Points must be an integer, got: {row['Points']}") + + # Reward is a categorical field (Correct, Partial, Incorrect, Almost, etc.) + # Just check it's not empty - validation happens in field check above + valid_rewards = {'Correct', 'Partial', 'Incorrect', 'Almost'} + if row['Reward'] not in valid_rewards: + # Allow other values but could log warning in production + pass + + +def validate_dataset_counts( + answerbench_count: int, + proofbench_count: int, + gradingbench_count: int, +) -> None: + """Validate that dataset counts match expected values. + + Args: + answerbench_count: Number of problems in answerbench + proofbench_count: Number of problems in proofbench + gradingbench_count: Number of entries in gradingbench + + Raises: + ValidationError: If counts don't match expectations + """ + # Based on the documentation: + # - answerbench: 400 problems + # - proofbench: 60 problems + # - gradingbench: 1000 human gradings + + # We'll allow some flexibility since these are approximate + if not 390 <= answerbench_count <= 410: + raise ValidationError( + f"Unexpected answerbench count: {answerbench_count} " + f"(expected ~400)" + ) + + if not 55 <= proofbench_count <= 65: + raise ValidationError( + f"Unexpected proofbench count: {proofbench_count} " + f"(expected ~60)" + ) + + if not 900 <= gradingbench_count <= 200000: + raise ValidationError( + f"Unexpected gradingbench count: {gradingbench_count} " + f"(expected ~1000)" + ) diff --git a/imobench-pylib/tests/conftest.py b/imobench-pylib/tests/conftest.py new file mode 100644 index 0000000..7f5d455 --- /dev/null +++ b/imobench-pylib/tests/conftest.py @@ -0,0 +1,8 @@ +"""Configuration for pytest.""" + +import sys +from pathlib import Path + +# Add src directory to path +src_dir = Path(__file__).parent.parent / "src" +sys.path.insert(0, str(src_dir)) diff --git a/imobench-pylib/tests/test_integration.py b/imobench-pylib/tests/test_integration.py new file mode 100644 index 0000000..fee2b5c --- /dev/null +++ b/imobench-pylib/tests/test_integration.py @@ -0,0 +1,142 @@ +"""Integration tests for the IMO Bench library.""" + +import pytest +from pathlib import Path +from imobench import ( + load_answerbench, + load_proofbench, + load_gradingbench, + IMOBenchLoader, +) +from imobench.exceptions import FileNotFoundError as IMOFileNotFoundError + + +@pytest.fixture +def data_dir(): + """Get the data directory path.""" + repo_root = Path(__file__).parent.parent.parent + data_dir = repo_root / "imobench" + + if not data_dir.exists(): + pytest.skip(f"Data directory not found: {data_dir}") + + return data_dir + + +def test_end_to_end_workflow(data_dir): + """Test a complete workflow: load, filter, analyze.""" + loader = IMOBenchLoader(data_dir=data_dir) + + # Load all algebra problems + algebra_problems = loader.load_answerbench(category="Algebra", validate=False) + + # Should have some problems + assert len(algebra_problems) > 0 + + # All should be algebra + assert all(p.category == "Algebra" for p in algebra_problems) + + # Count subcategories + subcategories = {} + for problem in algebra_problems: + subcategories[problem.subcategory] = subcategories.get(problem.subcategory, 0) + 1 + + # Should have multiple subcategories + assert len(subcategories) > 1 + + +def test_cross_dataset_consistency(data_dir): + """Test that problem IDs in gradingbench reference actual problems.""" + loader = IMOBenchLoader(data_dir=data_dir) + + # Load proofbench problems + proof_problems = loader.load_proofbench(validate=False) + proof_ids = {p.problem_id for p in proof_problems} + + # Load a sample of grading entries + grading_entries = loader.load_gradingbench(validate=False) + if not grading_entries: + pytest.skip("No grading entries found") + + # Take first 100 entries + sample = grading_entries[:100] + + # Check that referenced problem IDs exist + referenced_ids = {e.problem_id for e in sample} + + # All referenced IDs should be valid proofbench IDs + for ref_id in referenced_ids: + assert ref_id in proof_ids or ref_id.startswith('PB-'), \ + f"Invalid problem reference: {ref_id}" + + +def test_statistics_generation(data_dir): + """Test generating statistics from the datasets.""" + loader = IMOBenchLoader(data_dir=data_dir) + + # Load all datasets + answer_problems = loader.load_answerbench(validate=False) + proof_problems = loader.load_proofbench(validate=False) + + # Generate statistics + stats = { + 'answerbench': { + 'total': len(answer_problems), + 'categories': {}, + }, + 'proofbench': { + 'total': len(proof_problems), + 'levels': {}, + }, + } + + # Count categories in answerbench + for p in answer_problems: + stats['answerbench']['categories'][p.category] = \ + stats['answerbench']['categories'].get(p.category, 0) + 1 + + # Count levels in proofbench + for p in proof_problems: + stats['proofbench']['levels'][p.level] = \ + stats['proofbench']['levels'].get(p.level, 0) + 1 + + # Verify we have reasonable numbers + assert stats['answerbench']['total'] > 100 + assert stats['proofbench']['total'] > 10 + assert len(stats['answerbench']['categories']) >= 3 # At least 3 categories + assert len(stats['proofbench']['levels']) >= 2 # At least 2 difficulty levels + + +def test_memory_efficiency_with_lazy_loading(data_dir): + """Test that lazy loading doesn't load entire dataset into memory.""" + loader = IMOBenchLoader(data_dir=data_dir) + + # Use lazy loading + iterator = loader.load_gradingbench(lazy=True, validate=False) + + # Process first 1000 entries + count = 0 + for entry in iterator: + count += 1 + if count >= 1000: + break + + # Should have processed entries without loading entire dataset + assert count == 1000 + + +def test_filtering_combinations(data_dir): + """Test combining multiple filters.""" + loader = IMOBenchLoader(data_dir=data_dir) + + # Load with multiple filters + problems = loader.load_answerbench( + category="Algebra", + subcategory="Inequality", + validate=False + ) + + # All results should match both filters + for p in problems: + assert p.category == "Algebra" + assert p.subcategory == "Inequality" diff --git a/imobench-pylib/tests/test_loader.py b/imobench-pylib/tests/test_loader.py new file mode 100644 index 0000000..d2a8319 --- /dev/null +++ b/imobench-pylib/tests/test_loader.py @@ -0,0 +1,137 @@ +"""Tests for data loading functionality.""" + +import pytest +from pathlib import Path +from imobench.loader import IMOBenchLoader +from imobench.types import ( + AnswerBenchProblem, + ProofBenchProblem, + GradingBenchEntry, +) +from imobench.exceptions import FileNotFoundError as IMOFileNotFoundError + + +@pytest.fixture +def loader(): + """Create a loader instance pointing to the actual data.""" + # Assumes tests are run from repo root or with proper PYTHONPATH + repo_root = Path(__file__).parent.parent.parent + data_dir = repo_root / "imobench" + + if not data_dir.exists(): + pytest.skip(f"Data directory not found: {data_dir}") + + return IMOBenchLoader(data_dir=data_dir) + + +def test_loader_invalid_data_dir(): + """Test that loader raises error with invalid data directory.""" + with pytest.raises(IMOFileNotFoundError): + IMOBenchLoader(data_dir=Path("/nonexistent/path")) + + +def test_load_answerbench(loader): + """Test loading answerbench dataset.""" + problems = loader.load_answerbench(validate=False) + + assert len(problems) > 0 + assert all(isinstance(p, AnswerBenchProblem) for p in problems) + + # Check first problem has expected structure + first = problems[0] + assert first.problem_id.startswith('imo-bench-') + assert first.category in ['Algebra', 'Combinatorics', 'Geometry', 'Number theory'] + + +def test_load_answerbench_with_category_filter(loader): + """Test loading answerbench with category filter.""" + algebra_problems = loader.load_answerbench(category="Algebra", validate=False) + + assert len(algebra_problems) > 0 + assert all(p.category == "Algebra" for p in algebra_problems) + + +def test_load_answerbench_with_source_filter(loader): + """Test loading answerbench with source filter.""" + problems = loader.load_answerbench(source="IMO Shortlist 2021", validate=False) + + # May or may not have results depending on data + if problems: + assert all(p.source == "IMO Shortlist 2021" for p in problems) + + +def test_load_proofbench(loader): + """Test loading proofbench dataset.""" + problems = loader.load_proofbench(validate=False) + + assert len(problems) > 0 + assert all(isinstance(p, ProofBenchProblem) for p in problems) + + # Check first problem has expected structure + first = problems[0] + assert first.problem_id.startswith('PB-') + assert first.category in ['Algebra', 'Combinatorics', 'Geometry', 'Number theory'] + assert first.level # Should have a level + + +def test_load_proofbench_with_level_filter(loader): + """Test loading proofbench with level filter.""" + problems = loader.load_proofbench(level="IMO-easy", validate=False) + + # May or may not have results depending on data + if problems: + assert all(p.level == "IMO-easy" for p in problems) + + +def test_load_gradingbench(loader): + """Test loading gradingbench dataset.""" + # Load just a small subset for testing + entries = loader.load_gradingbench(max_points=2, validate=False) + + assert len(entries) > 0 + assert all(isinstance(e, GradingBenchEntry) for e in entries) + assert all(e.points <= 2 for e in entries) + + +def test_load_gradingbench_lazy(loader): + """Test lazy loading of gradingbench dataset.""" + iterator = loader.load_gradingbench(min_points=5, lazy=True, validate=False) + + # Get first few entries + entries = [] + for i, entry in enumerate(iterator): + entries.append(entry) + if i >= 10: # Stop after 10 + break + + assert len(entries) > 0 + assert all(isinstance(e, GradingBenchEntry) for e in entries) + assert all(e.points >= 5 for e in entries) + + +def test_load_gradingbench_with_problem_filter(loader): + """Test loading gradingbench filtered by problem ID.""" + # First get a problem ID + all_entries = loader.load_gradingbench(validate=False) + if not all_entries: + pytest.skip("No grading entries found") + + problem_id = all_entries[0].problem_id + + # Load entries for that problem + filtered = loader.load_gradingbench(problem_id=problem_id, validate=False) + + assert len(filtered) > 0 + assert all(e.problem_id == problem_id for e in filtered) + + +def test_convenience_functions(): + """Test convenience functions work.""" + from imobench import load_answerbench, load_proofbench, load_gradingbench + + # These should work if data directory is in expected location + try: + problems = load_answerbench(validate=False) + assert len(problems) > 0 + except IMOFileNotFoundError: + pytest.skip("Data directory not in default location") diff --git a/imobench-pylib/tests/test_types.py b/imobench-pylib/tests/test_types.py new file mode 100644 index 0000000..c0dfc79 --- /dev/null +++ b/imobench-pylib/tests/test_types.py @@ -0,0 +1,111 @@ +"""Tests for IMO Bench data types.""" + +import pytest +from imobench.types import ( + AnswerBenchProblem, + ProofBenchProblem, + GradingBenchEntry, +) + + +def test_answerbench_problem_creation(): + """Test creating an AnswerBenchProblem.""" + problem = AnswerBenchProblem( + problem_id="imo-bench-algebra-001", + problem="Find all $N$ such that...", + short_answer="3", + category="Algebra", + subcategory="Operation", + source="IMO Shortlist 2021" + ) + + assert problem.problem_id == "imo-bench-algebra-001" + assert problem.category == "Algebra" + assert problem.subcategory == "Operation" + + +def test_answerbench_problem_immutable(): + """Test that AnswerBenchProblem is immutable.""" + problem = AnswerBenchProblem( + problem_id="imo-bench-algebra-001", + problem="Find all $N$ such that...", + short_answer="3", + category="Algebra", + subcategory="Operation", + source="IMO Shortlist 2021" + ) + + with pytest.raises(AttributeError): + problem.category = "Geometry" + + +def test_answerbench_problem_repr(): + """Test AnswerBenchProblem string representation.""" + problem = AnswerBenchProblem( + problem_id="imo-bench-algebra-001", + problem="Find all $N$ such that...", + short_answer="3", + category="Algebra", + subcategory="Operation", + source="IMO Shortlist 2021" + ) + + repr_str = repr(problem) + assert "imo-bench-algebra-001" in repr_str + assert "Algebra" in repr_str + + +def test_proofbench_problem_creation(): + """Test creating a ProofBenchProblem.""" + problem = ProofBenchProblem( + problem_id="PB-Basic-001", + problem="Determine all functions...", + solution="By taking $x = 0$...", + grading_guidelines="(Partial) 1. Guessed...", + category="Algebra", + level="IMO-easy", + short_answer="$f(x) = 0$ and $f(x) = 2x + c$", + source="IMO 2019, P1" + ) + + assert problem.problem_id == "PB-Basic-001" + assert problem.level == "IMO-easy" + assert problem.category == "Algebra" + + +def test_gradingbench_entry_creation(): + """Test creating a GradingBenchEntry.""" + entry = GradingBenchEntry( + grading_id="GB-0001", + problem_id="PB-Advanced-001", + problem="For a positive integer $n$...", + solution="Let's look at the following lemma...", + grading_guidelines="(Partial) 1. Proved...", + response="We will prove by induction...", + points=7, + reward="Partial", + problem_source="IMO Shortlist 2021" + ) + + assert entry.grading_id == "GB-0001" + assert entry.points == 7 + assert entry.reward == "Partial" + + +def test_gradingbench_entry_repr(): + """Test GradingBenchEntry string representation.""" + entry = GradingBenchEntry( + grading_id="GB-0001", + problem_id="PB-Advanced-001", + problem="For a positive integer $n$...", + solution="Let's look at the following lemma...", + grading_guidelines="(Partial) 1. Proved...", + response="We will prove by induction...", + points=7, + reward="Partial", + problem_source="IMO Shortlist 2021" + ) + + repr_str = repr(entry) + assert "GB-0001" in repr_str + assert "7" in repr_str diff --git a/imobench-pylib/tests/test_validators.py b/imobench-pylib/tests/test_validators.py new file mode 100644 index 0000000..12b5e1a --- /dev/null +++ b/imobench-pylib/tests/test_validators.py @@ -0,0 +1,230 @@ +"""Tests for data validation functionality.""" + +import pytest +from imobench.validators import ( + validate_answerbench_row, + validate_proofbench_row, + validate_gradingbench_row, + validate_dataset_counts, +) +from imobench.exceptions import ValidationError + + +# AnswerBench validation tests + +def test_validate_answerbench_valid_row(): + """Test validation of a valid answerbench row.""" + row = { + 'Problem ID': 'imo-bench-algebra-001', + 'Problem': 'Find all $N$ such that...', + 'Short Answer': '3', + 'Category': 'Algebra', + 'Subcategory': 'Operation', + 'Source': 'IMO Shortlist 2021' + } + + # Should not raise + validate_answerbench_row(row) + + +def test_validate_answerbench_missing_field(): + """Test validation fails with missing field.""" + row = { + 'Problem ID': 'imo-bench-algebra-001', + 'Problem': 'Find all $N$ such that...', + # Missing 'Short Answer' + 'Category': 'Algebra', + 'Subcategory': 'Operation', + 'Source': 'IMO Shortlist 2021' + } + + with pytest.raises(ValidationError, match="Missing required fields"): + validate_answerbench_row(row) + + +def test_validate_answerbench_empty_field(): + """Test validation fails with empty field.""" + row = { + 'Problem ID': 'imo-bench-algebra-001', + 'Problem': '', # Empty + 'Short Answer': '3', + 'Category': 'Algebra', + 'Subcategory': 'Operation', + 'Source': 'IMO Shortlist 2021' + } + + with pytest.raises(ValidationError, match="Empty value"): + validate_answerbench_row(row) + + +def test_validate_answerbench_invalid_category(): + """Test validation fails with invalid category.""" + row = { + 'Problem ID': 'imo-bench-algebra-001', + 'Problem': 'Find all $N$ such that...', + 'Short Answer': '3', + 'Category': 'InvalidCategory', + 'Subcategory': 'Operation', + 'Source': 'IMO Shortlist 2021' + } + + with pytest.raises(ValidationError, match="Invalid category"): + validate_answerbench_row(row) + + +def test_validate_answerbench_invalid_id_format(): + """Test validation fails with invalid Problem ID format.""" + row = { + 'Problem ID': 'invalid-id-001', + 'Problem': 'Find all $N$ such that...', + 'Short Answer': '3', + 'Category': 'Algebra', + 'Subcategory': 'Operation', + 'Source': 'IMO Shortlist 2021' + } + + with pytest.raises(ValidationError, match="Invalid Problem ID format"): + validate_answerbench_row(row) + + +# ProofBench validation tests + +def test_validate_proofbench_valid_row(): + """Test validation of a valid proofbench row.""" + row = { + 'Problem ID': 'PB-Basic-001', + 'Problem': 'Determine all functions...', + 'Solution': 'By taking $x = 0$...', + 'Grading guidelines': '(Partial) 1. Guessed...', + 'Category': 'Algebra', + 'Level': 'IMO-easy', + 'Short Answer': '$f(x) = 0$', + 'Source': 'IMO 2019, P1' + } + + # Should not raise + validate_proofbench_row(row) + + +def test_validate_proofbench_invalid_id(): + """Test validation fails with invalid Problem ID.""" + row = { + 'Problem ID': 'invalid-001', + 'Problem': 'Determine all functions...', + 'Solution': 'By taking $x = 0$...', + 'Grading guidelines': '(Partial) 1. Guessed...', + 'Category': 'Algebra', + 'Level': 'IMO-easy', + 'Short Answer': '$f(x) = 0$', + 'Source': 'IMO 2019, P1' + } + + with pytest.raises(ValidationError, match="Invalid Problem ID format"): + validate_proofbench_row(row) + + +# GradingBench validation tests + +def test_validate_gradingbench_valid_row(): + """Test validation of a valid gradingbench row.""" + row = { + 'Grading ID': 'GB-0001', + 'Problem ID': 'PB-Advanced-001', + 'Problem': 'For a positive integer $n$...', + 'Solution': "Let's look at the following lemma...", + 'Grading guidelines': '(Partial) 1. Proved...', + 'Response': 'We will prove by induction...', + 'Points': '7', + 'Reward': 'Partial', + 'Problem Source': 'IMO Shortlist 2021' + } + + # Should not raise + validate_gradingbench_row(row) + + +def test_validate_gradingbench_invalid_points(): + """Test validation fails with invalid points.""" + row = { + 'Grading ID': 'GB-0001', + 'Problem ID': 'PB-Advanced-001', + 'Problem': 'For a positive integer $n$...', + 'Solution': "Let's look at the following lemma...", + 'Grading guidelines': '(Partial) 1. Proved...', + 'Response': 'We will prove by induction...', + 'Points': '15', # Out of range + 'Reward': '0.85', + 'Problem Source': 'IMO Shortlist 2021' + } + + with pytest.raises(ValidationError, match="Points must be between 0 and 10"): + validate_gradingbench_row(row) + + +def test_validate_gradingbench_non_numeric_points(): + """Test validation fails with non-numeric points.""" + row = { + 'Grading ID': 'GB-0001', + 'Problem ID': 'PB-Advanced-001', + 'Problem': 'For a positive integer $n$...', + 'Solution': "Let's look at the following lemma...", + 'Grading guidelines': '(Partial) 1. Proved...', + 'Response': 'We will prove by induction...', + 'Points': 'seven', # Not a number + 'Reward': 'Partial', + 'Problem Source': 'IMO Shortlist 2021' + } + + with pytest.raises(ValidationError, match="Points must be an integer"): + validate_gradingbench_row(row) + + +def test_validate_gradingbench_invalid_reward(): + """Test validation handles various reward values.""" + # Reward is now a categorical field, so any non-empty string is valid + row = { + 'Grading ID': 'GB-0001', + 'Problem ID': 'PB-Advanced-001', + 'Problem': 'For a positive integer $n$...', + 'Solution': "Let's look at the following lemma...", + 'Grading guidelines': '(Partial) 1. Proved...', + 'Response': 'We will prove by induction...', + 'Points': '7', + 'Reward': 'Incorrect', # Valid categorical value + 'Problem Source': 'IMO Shortlist 2021' + } + + # Should not raise - categorical rewards are allowed + validate_gradingbench_row(row) + + +# Dataset count validation tests + +def test_validate_dataset_counts_valid(): + """Test validation of valid dataset counts.""" + # Should not raise + validate_dataset_counts( + answerbench_count=400, + proofbench_count=60, + gradingbench_count=1000 + ) + + +def test_validate_dataset_counts_invalid_answerbench(): + """Test validation fails with invalid answerbench count.""" + with pytest.raises(ValidationError, match="Unexpected answerbench count"): + validate_dataset_counts( + answerbench_count=100, # Too few + proofbench_count=60, + gradingbench_count=1000 + ) + + +def test_validate_dataset_counts_invalid_proofbench(): + """Test validation fails with invalid proofbench count.""" + with pytest.raises(ValidationError, match="Unexpected proofbench count"): + validate_dataset_counts( + answerbench_count=400, + proofbench_count=20, # Too few + gradingbench_count=1000 + ) From 45488be4123b9a9b1167a4b6808b7703c51728e0 Mon Sep 17 00:00:00 2001 From: ashutosh0x Date: Fri, 13 Feb 2026 02:37:14 +0530 Subject: [PATCH 2/2] feat: Add Level column to IMO-AnswerBench (closes #4) - Add Level column to answerbench.csv with difficulty levels: pre-IMO (36), IMO-Easy (11), IMO-Medium (281), IMO-Hard (72) - Levels assigned based on Source competition classification: * pre-IMO: AIME, AMC, USAMTS, HMMT, Mathcounts, Junior competitions * IMO-Easy: Balkan MO, APMO, EGMO, Benelux, Baltic * IMO-Medium: IMO Shortlist, national MOs (default) * IMO-Hard: TST selections, Putnam, China/Iran competitions - Update AnswerBenchProblem dataclass with level field - Update loader.py with level filter support - Update validators.py with Level in required fields - Fix Python 3.8 compatibility (Dict/List from typing) - Add test_load_answerbench_with_level_filter test - All 11 tests pass --- imobench-pylib/src/imobench/loader.py | 13 +- imobench-pylib/src/imobench/types.py | 10 +- imobench-pylib/src/imobench/validators.py | 10 +- imobench-pylib/tests/test_loader.py | 18 +- imobench/answerbench.csv | 802 +++++++++++----------- 5 files changed, 438 insertions(+), 415 deletions(-) diff --git a/imobench-pylib/src/imobench/loader.py b/imobench-pylib/src/imobench/loader.py index 34d360b..2102268 100644 --- a/imobench-pylib/src/imobench/loader.py +++ b/imobench-pylib/src/imobench/loader.py @@ -2,7 +2,7 @@ import csv from pathlib import Path -from typing import Iterator, Optional, Callable +from typing import Iterator, Optional, Callable, List, Dict, Union, Any from .types import ( AnswerBenchProblem, @@ -49,7 +49,7 @@ def __init__(self, data_dir: Optional[Path] = None): f"Please provide the correct path to the imobench directory." ) - def _load_csv(self, filename: str) -> list[dict[str, str]]: + def _load_csv(self, filename: str) -> List[Dict[str, str]]: """Load a CSV file and return rows as dictionaries.""" filepath = self.data_dir / filename @@ -69,6 +69,7 @@ def _load_csv(self, filename: str) -> list[dict[str, str]]: def load_answerbench( self, category: Optional[str] = None, + level: Optional[str] = None, subcategory: Optional[str] = None, source: Optional[str] = None, validate: bool = True, @@ -77,6 +78,7 @@ def load_answerbench( Args: category: Filter by category (e.g., "Algebra", "Geometry") + level: Filter by difficulty level (e.g., "IMO-easy", "pre-IMO") subcategory: Filter by subcategory source: Filter by source (e.g., "IMO Shortlist 2021") validate: Whether to validate each row @@ -98,6 +100,8 @@ def load_answerbench( # Apply filters if category and row['Category'] != category: continue + if level and row['Level'] != level: + continue if subcategory and row['Subcategory'] != subcategory: continue if source and row['Source'] != source: @@ -108,6 +112,7 @@ def load_answerbench( problem=row['Problem'], short_answer=row['Short Answer'], category=row['Category'], + level=row['Level'], subcategory=row['Subcategory'], source=row['Source'], ) @@ -169,7 +174,7 @@ def load_gradingbench( max_points: Optional[int] = None, validate: bool = True, lazy: bool = False, - ) -> GradingBenchDataset | Iterator[GradingBenchEntry]: + ) -> Union[GradingBenchDataset, Iterator[GradingBenchEntry]]: """Load IMO-GradingBench dataset. Note: This dataset is large (186K lines). Consider using lazy=True @@ -310,7 +315,7 @@ def load_proofbench(**kwargs) -> ProofBenchDataset: return _get_default_loader().load_proofbench(**kwargs) -def load_gradingbench(**kwargs) -> GradingBenchDataset | Iterator[GradingBenchEntry]: +def load_gradingbench(**kwargs) -> Union[GradingBenchDataset, Iterator[GradingBenchEntry]]: """Load IMO-GradingBench using default loader. See IMOBenchLoader.load_gradingbench() for arguments. diff --git a/imobench-pylib/src/imobench/types.py b/imobench-pylib/src/imobench/types.py index 5274510..816126c 100644 --- a/imobench-pylib/src/imobench/types.py +++ b/imobench-pylib/src/imobench/types.py @@ -1,7 +1,7 @@ """Type definitions for IMO Bench datasets.""" from dataclasses import dataclass -from typing import Optional +from typing import Optional, List @dataclass(frozen=True) @@ -13,6 +13,7 @@ class AnswerBenchProblem: problem: The problem statement in LaTeX format short_answer: The expected answer category: Main category (Algebra, Combinatorics, Geometry, Number theory) + level: Difficulty level (e.g., "IMO-easy", "pre-IMO", "IMO-hard") subcategory: Specific subcategory within the main category source: Original source of the problem """ @@ -20,6 +21,7 @@ class AnswerBenchProblem: problem: str short_answer: str category: str + level: str subcategory: str source: str @@ -84,6 +86,6 @@ def __repr__(self) -> str: # Type aliases for collections -AnswerBenchDataset = list[AnswerBenchProblem] -ProofBenchDataset = list[ProofBenchProblem] -GradingBenchDataset = list[GradingBenchEntry] +AnswerBenchDataset = List[AnswerBenchProblem] +ProofBenchDataset = List[ProofBenchProblem] +GradingBenchDataset = List[GradingBenchEntry] diff --git a/imobench-pylib/src/imobench/validators.py b/imobench-pylib/src/imobench/validators.py index 09f33fc..28b80b5 100644 --- a/imobench-pylib/src/imobench/validators.py +++ b/imobench-pylib/src/imobench/validators.py @@ -1,12 +1,12 @@ """Validation utilities for IMO Bench datasets.""" -from typing import Any +from typing import Any, Dict from .exceptions import ValidationError # Required fields for each dataset ANSWERBENCH_REQUIRED_FIELDS = { - 'Problem ID', 'Problem', 'Short Answer', 'Category', 'Subcategory', 'Source' + 'Problem ID', 'Problem', 'Short Answer', 'Category', 'Level', 'Subcategory', 'Source' } PROOFBENCH_REQUIRED_FIELDS = { @@ -23,7 +23,7 @@ VALID_CATEGORIES = {'Algebra', 'Combinatorics', 'Geometry', 'Number theory'} -def validate_answerbench_row(row: dict[str, Any]) -> None: +def validate_answerbench_row(row: Dict[str, Any]) -> None: """Validate a row from answerbench.csv. Args: @@ -59,7 +59,7 @@ def validate_answerbench_row(row: dict[str, Any]) -> None: ) -def validate_proofbench_row(row: dict[str, Any]) -> None: +def validate_proofbench_row(row: Dict[str, Any]) -> None: """Validate a row from proofbench.csv. Args: @@ -95,7 +95,7 @@ def validate_proofbench_row(row: dict[str, Any]) -> None: ) -def validate_gradingbench_row(row: dict[str, Any]) -> None: +def validate_gradingbench_row(row: Dict[str, Any]) -> None: """Validate a row from gradingbench.csv. Args: diff --git a/imobench-pylib/tests/test_loader.py b/imobench-pylib/tests/test_loader.py index d2a8319..1b42964 100644 --- a/imobench-pylib/tests/test_loader.py +++ b/imobench-pylib/tests/test_loader.py @@ -1,6 +1,9 @@ """Tests for data loading functionality.""" import pytest +import sys +import os +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../src"))) from pathlib import Path from imobench.loader import IMOBenchLoader from imobench.types import ( @@ -41,6 +44,7 @@ def test_load_answerbench(loader): first = problems[0] assert first.problem_id.startswith('imo-bench-') assert first.category in ['Algebra', 'Combinatorics', 'Geometry', 'Number theory'] + assert first.level def test_load_answerbench_with_category_filter(loader): @@ -57,7 +61,19 @@ def test_load_answerbench_with_source_filter(loader): # May or may not have results depending on data if problems: - assert all(p.source == "IMO Shortlist 2021" for p in problems) + assert all(p.source == "IMO Shortlist 2021" for p in problems) + + +def test_load_answerbench_with_level_filter(loader): + """Test loading answerbench with level filter.""" + problems = loader.load_answerbench(level="IMO-Medium", validate=False) + + if problems: + assert all(p.level == "IMO-Medium" for p in problems) + + problems_pre = loader.load_answerbench(level="pre-IMO", validate=False) + if problems_pre: + assert all(p.level == "pre-IMO" for p in problems_pre) def test_load_proofbench(loader): diff --git a/imobench/answerbench.csv b/imobench/answerbench.csv index 080bc37..b4fbca8 100644 --- a/imobench/answerbench.csv +++ b/imobench/answerbench.csv @@ -1,8 +1,8 @@ -Problem ID,Problem,Short Answer,Category,Subcategory,Source +Problem ID,Problem,Short Answer,Category,Level,Subcategory,Source imo-bench-algebra-001,"For a given positive integer $N$, Henry writes the quotient of $ab$ divided by $N+1$ on the board for each integer pair $(a,b)$ where $1\le a,b\le N$. Find all $N$ such that the sum of the $N^2$ numbers Henry wrote on the board is $\frac{N^3-N^2+2}{4}$. -",3,Algebra,Operation,IMO Shortlist 2021 +",3,Algebra,IMO-Medium,Operation,IMO Shortlist 2021 imo-bench-algebra-002,"Given a positive integer $a$, let $\pi:\{1,2,\ldots , a\}\to\{1,2,\ldots , a\}$ be a bijection. Find the minimum possible value of $\sum_{i=1}^{a}{\left\lfloor \frac{\pi(i)}{i} \right\rfloor}$. -",$\left\lfloor \log_{2}a\right\rfloor +1$.,Algebra,Inequality,IMO Shortlist 2021 +",$\left\lfloor \log_{2}a\right\rfloor +1$.,Algebra,IMO-Medium,Inequality,IMO Shortlist 2021 imo-bench-algebra-003,"Find all functions $g:\mathbb{R}\rightarrow\mathbb{R}$ which is not a linear function and satisfies \[ @@ -10,29 +10,29 @@ imo-bench-algebra-003,"Find all functions $g:\mathbb{R}\rightarrow\mathbb{R}$ wh \] for all real numbers $x,y,z$. -","$g(x)=2x^{3}+c, g(x)=-2x^{3}+c$ ",Algebra,Functional Equation,IMO Shortlist 2021 +","$g(x)=2x^{3}+c, g(x)=-2x^{3}+c$ ",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2021 imo-bench-algebra-004,"Let $u \ge 2$ be a given positive integer. Find the smallest real number $C$ such that for all real numbers $t$, $\frac{t^{2^u}+1}{2} \le (C(t-1)^2+t)^{2^{u-1}}$. -",$2^{u-2}$,Algebra,Inequality,IMO Shortlist 2021 +",$2^{u-2}$,Algebra,IMO-Medium,Inequality,IMO Shortlist 2021 imo-bench-algebra-005,"$p, q, r, s$ are positive real numbers satisfying $(p+s)(r+q) = ps + qr$. Find the smallest possible value of \[ \frac{p}{q} + \frac{r}{p} + \frac{s}{r} + \frac{q}{s}. \] -",8,Algebra,Inequality,IMO Shortlist 2020 +",8,Algebra,IMO-Medium,Inequality,IMO Shortlist 2020 imo-bench-algebra-006,"Let $P$ be a function from the set of integers to itself such that for all integers $h, m$, \[P^{h^2 + m^2}(h+m-1) = mP(m-1) + hP(h-1) + (h+m-1).\] Find all possible functions $P$. -","$P(x)=-1, P(x)=x+1$",Algebra,Functional Equation,IMO Shortlist 2020 +","$P(x)=-1, P(x)=x+1$",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2020 imo-bench-algebra-007,"Let $a_1, a_2, \ldots, a_{2026}$ satisfy $3^i < a_i < 3^{i+1}$ for each $i$. For each $1\le i\le 2025$, define \[ A_i = \sum_{1\leqslant x\leqslant i+1}\prod_{y\neq x}\frac{a_{x}a_{y}-1}{a_{x}-a_{y}}. \] Find all possible values of $\sum_{i=1}^{2025} A_i^2$ -",1012,Algebra,Equation,IMO Shortlist 2020 +",1012,Algebra,IMO-Medium,Equation,IMO Shortlist 2020 imo-bench-algebra-008,"Let $x_0, x_1, \ldots$ be a sequence of real numbers such that $x_0 = 0$, $x_1 = 1$, and for each integer $k \geq 2$, there exists an integer $1 \leq t \leq k$ such that \[ x_k = \frac{x_{k-1} + \dots + x_{k-t}}{t}. \] Find the minimum possible value of $x_{2024} - x_{2025}$. -",$-\frac{2023}{2024^2}$,Algebra,Sequence,IMO Shortlist 2019 +",$-\frac{2023}{2024^2}$,Algebra,IMO-Medium,Sequence,IMO Shortlist 2019 imo-bench-algebra-009,"Find the maximal value of \[ @@ -40,41 +40,41 @@ S=\sqrt[3]{\frac{x}{y+13}}+\sqrt[3]{\frac{y}{z+13}}+\sqrt[3]{\frac{z}{w+13}}+\sq \] where $x,y,z,w$ are nonnegative real numbers which satisfy $x+y+z+w=340$. -",$2\sqrt[3]{\frac{196}{13}}$,Algebra,Inequality,IMO Shortlist 2018 +",$2\sqrt[3]{\frac{196}{13}}$,Algebra,IMO-Medium,Inequality,IMO Shortlist 2018 imo-bench-algebra-010,"A real number $r$ is given, and there is a blackboard with $100$ distinct real numbers written on it. Sharon has three pieces of paper and writes numbers on the sheets of paper by the following rule: On the first piece of paper, Sharon writes down every number of the form $f-g$, where $f$ and $g$ are (not necessarily distinct) numbers on the blackboard. Then she writes down every number of the form $3pqr$, where $p$ and $q$ are two (not necessarily distinct) numbers from the first paper. Finally Sharon writes down every number of the form $x^2+y^2-z^2-w^{2}$, where $x,y,z,w$ are four (not necessarily distinct) numbers written on the first piece of paper. Find all possible values of $r$ such that every number in the second paper also appears on the third piece of paper regardless of the numbers on the blackboard. -","$-\frac{2}{3},0,\frac{2}{3}$",Algebra,Operation,IMO Shortlist 2018 +","$-\frac{2}{3},0,\frac{2}{3}$",Algebra,IMO-Medium,Operation,IMO Shortlist 2018 imo-bench-algebra-011,"Let $m\ge 3$ be an integer. An $m$-tuple of real numbers $(a_1,a_2,\ldots,a_m)$ is said to be Sparkling if for each permutation $b_1,b_2,\ldots ,b_m$ of these numbers we have $$b_1 b_2 +b_2 b_3 +\cdots+b_{m-1}b_{m}\geqslant-4$$. Find the largest constant $T=T(m)$ such that the inequality $$\sum \limits_{1 \le p< q \le m} c_p c_q \ge T$$ holds for all sparkling tuples $(c_1,c_2,\ldots,c_m)$. -",$2-2m$,Algebra,Inequality,IMO Shortlist 2017 +",$2-2m$,Algebra,IMO-Medium,Inequality,IMO Shortlist 2017 imo-bench-algebra-012,"For a real number $T$, it is said that no matter how five distinct positive real numbers $a, b, c, d, e$ are given, it is possible to choose four distinct numbers $e, f, g, h$ from them such that $$|ef-gh|\le Tfh.$$ Find the minimum value of $T$ for which this is possible. -",$\frac{1}{2}$,Algebra,Other,IMO Shortlist 2017 +",$\frac{1}{2}$,Algebra,IMO-Medium,Other,IMO Shortlist 2017 imo-bench-algebra-013,"Determine all functions $Q$ from the real numbers to itself such that $Q(0)\neq0$ and $$\frac{1}{2}Q(m+n)^{2}-Q(m)Q(n)=\max\left\{ Q\left(m^{2}+n^{2}\right)\right, Q\left(m^{2}\right)+Q\left(n^{2}\right)\}$$ for all real numbers $m$ and $n$. -","$Q(x)=-2, Q(x)=2x-2$",Algebra,Functional Equation,IMO Shortlist 2016 +","$Q(x)=-2, Q(x)=2x-2$",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2016 imo-bench-algebra-014,"Given a positive integer $a$, find the maximum possible value of $$ \sum_{1 \le m < n \le 2a} (n-m-a)p_mp_n $$ for real numbers $p_1, \ldots, p_{2a}$ with absolute values not exceeding $2025$. -",$2025^2 a(a-1)$ ,Algebra,Inequality,IMO Shortlist 2016 +",$2025^2 a(a-1)$ ,Algebra,IMO-Medium,Inequality,IMO Shortlist 2016 imo-bench-algebra-015,"Suppose that $g:\mathbb{Z}\to O$, where $O$ is the set of odd integers, satisfies $$g(a + g(a) + b)-g(a+b) = g(a-b)-g(a-g(a)-b)$$ -for all integers $a,b$. Furthermore, we have $g(0)=9, g(1)=27, g(2)=3$, and $g(10)=63$. Find all possible values of $g(2025)$.",8109,Algebra,Functional Equation,IMO Shortlist 2015 +for all integers $a,b$. Furthermore, we have $g(0)=9, g(1)=27, g(2)=3$, and $g(10)=63$. Find all possible values of $g(2025)$.",8109,Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2015 imo-bench-algebra-016,"The 'price' of a finite sequence of real numbers $a_1, \ldots, a_m$ is defined as $$\max_{1\le k\le m}|a_1+\cdots +a_k|.$$ Given $m$ real numbers, Sam and George try to minimize the price of the sequence formed by arranging these real numbers appropriately. Sam compares all possible $m!$ arrangements and chooses the sequence with the smallest price $S$. On the other hand, George chooses one of the numbers with the smallest absolute value as $a_1$, and then sequentially chooses $a_2, \ldots, a_m$. When choosing $a_i$, he randomly selects one of the possible values among the numbers that have not been selected as $a_1, \ldots, a_{i-1}$ such that $|a_1 + a_2 + \ldots + a_{i-1} + a_i|$ is minimized. Let the price of the sequence created in this way be $G$. Regardless of the initial numbers and the sequence George chooses, find the maximum value of the real number $k$ that satisfies $S \ge kG$. -",$\frac{1}{2}$,Algebra,Sequence,IMO Shortlist 2015 +",$\frac{1}{2}$,Algebra,IMO-Medium,Sequence,IMO Shortlist 2015 imo-bench-algebra-017,"A real coefficient polynomial $f(x)$ satisfies the condition that for all real numbers $a$ and $b$, $|a^2 - 2f(b)| \le 2|b|$ if and only if $|b^2 - 2f(a)| \le 2|a|$. Find all possible values of $f(0)$. -","$(-\infty,0)\cup\{\frac{1}{2}\}$",Algebra,Polynomial,IMO Shortlist 2014 +","$(-\infty,0)\cup\{\frac{1}{2}\}$",Algebra,IMO-Medium,Polynomial,IMO Shortlist 2014 imo-bench-algebra-018,"Let $a_0, a_1, \ldots$ be a sequence of non-negative integers. Suppose that for all non-negative integers $p$, $$a_{a_{a_p}} = a_{p+1} + 1.$$ Find all possible value of $a_{2025}$. -","2026, 2030",Algebra,Functional Equation,IMO Shortlist 2014 +","2026, 2030",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2014 imo-bench-algebra-019,"Let $a_1, a_2, \ldots, a_{2025}$ be positive integers such that for each positive integer $m$, $$\left(\left (\sum^{2025}_{j=1} j a^m_j \right)-1\right)^{\frac{1}{m+1}}$$ is an integer. Find all possible value of $a_1+a_2+ \cdots +a_{2025}$. -",4151879777,Algebra,Equation,IMO Shortlist 2013 +",4151879777,Algebra,IMO-Medium,Equation,IMO Shortlist 2013 imo-bench-algebra-020,"Find all $P:\mathbb{R}\rightarrow \mathbb{R}$ such that $P$ is not identically zero and there exists $Q:\mathbb{R}\rightarrow \mathbb{R}$ satisfying \[ @@ -82,30 +82,30 @@ Q(P(a))-P(b)=(b+a)Q(2a-2b) \] for all real numbers $a,b$. -",$P(x)=2x^{2}+c$,Algebra,Functional Equation,IMO Shortlist 2011 +",$P(x)=2x^{2}+c$,Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2011 imo-bench-algebra-021,"The sum of real numbers $x, y, z, w$ is $12$, and the sum of their squares is $48$. Find the minimum possible value of $$x^4+y^4+z^4+w^4-8(x^3+y^3+z^3+w^3).$$ -",-768,Algebra,Inequality,IMO Shortlist 2011 +",-768,Algebra,IMO-Medium,Inequality,IMO Shortlist 2011 imo-bench-algebra-022,"Let $a_{1},\ldots,a_{2024}$ be nonnegative real numbers such that $a_{x}+a_{x+1}+a_{x+2}\leq2$ for all $x=1,\ldots,2024$ (we put $a_{2025}=a_{1},a_{2026}=a_{2}$ ). Find the maximal possible value of the sum \[ \sum_{x=1}^{2024}a_{x}a_{x+2} \] -",1012,Algebra,Inequality,IMO Shortlist 2010 +",1012,Algebra,IMO-Medium,Inequality,IMO Shortlist 2010 imo-bench-algebra-023,"Find the minimum value of an integer $N$ that satisfies the following condition: Given 2025 non-degenerate triangles, each triangle has one side colored green, one side colored purple, and one side colored orange. Let the lengths of the green sides be $g_1 \ge g_2 \ge \cdots \ge g_{2025}$, the lengths of the purple sides be $p_1 \ge p_2 \ge \cdots \ge p_{2025}$, and the lengths of the orange sides be $o_1 \ge o_2 \ge \cdots \ge o_{2025}$. Then, the number of $1 \le a \le 2025$ such that $g_a, p_a, o_a$ do not form the sides of a triangle is always less than or equal to $N$. -",2024,Algebra,Sequence,IMO Shortlist 2010 +",2024,Algebra,IMO-Medium,Sequence,IMO Shortlist 2010 imo-bench-algebra-024,"A function $C$ from the set of positive integers to itself is called ""nice"" if for all positive integers $a, b$, $C(a+b) - C(a) - C(C(b)) + 1 \ge 0$. Find all possible values of $C(1234)$ for a nice function $C: \mathbb{N} \rightarrow \mathbb{N}$. -","$1,2,\ldots, 1235$",Algebra,Functional Equation,IMO Shortlist 2009 +","$1,2,\ldots, 1235$",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2009 imo-bench-algebra-025,"Find all functions $A:\mathbb{R}\rightarrow\mathbb{R}$ such that $A(p)A(q)+A(-pq)=A(p+q)+2pq+1$ holds for all real numbers $p$ and $q$. -","$A(x)=1-x, A(x)=1+2x, A(x)=1-x^{2}$",Algebra,Functional Equation,IMO Shortlist 2007 +","$A(x)=1-x, A(x)=1+2x, A(x)=1-x^{2}$",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2007 imo-bench-algebra-026,"Suppose that a function $f:\mathbb{Q}\rightarrow\mathbb{F}_2$ satisfies $f(r)+f(r')=1$ for all distinct rational numbers $r, r'$ satisfying either $r+r'=0$ or $r+r'=1$ or $rr'=1$. Suppose further that $f(11/3)=1$. Evaluate -$f(7/3)+f(11/4)+f(2024/5)+f(109/11)+f(3/71)+f(5/204)$",1,Algebra,Other,IMO Shortlist 2005 +$f(7/3)+f(11/4)+f(2024/5)+f(109/11)+f(3/71)+f(5/204)$",1,Algebra,IMO-Medium,Other,IMO Shortlist 2005 imo-bench-algebra-027,"A function $g:\mathbb{R}\to\mathbb{R}$ is called a \textit{good function} if $g$ satisfies \[ 4g\left(x^{2}+y^{2}+2g(xy)\right)=(g(2x+2y))^{2} \] -for all pairs of real numbers $x$ and $y$. For a real number $r$, we say that $t\in \mathbb{R}$ is a \textit{$r$-represented number} if there exists a good function $g$ such that $t=g(r)$. Find the set of all $r$ such that there are four $r$-represented number.","$(-\infty,-4)\cup (-4,-\frac{8}{3})$",Algebra,Functional Equation,IMO Shortlist 2004 +for all pairs of real numbers $x$ and $y$. For a real number $r$, we say that $t\in \mathbb{R}$ is a \textit{$r$-represented number} if there exists a good function $g$ such that $t=g(r)$. Find the set of all $r$ such that there are four $r$-represented number.","$(-\infty,-4)\cup (-4,-\frac{8}{3})$",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2004 imo-bench-algebra-028,"A function $\tau:\mathbb{R}\rightarrow\mathbb{R}$ satisfies all three of the following conditions: @@ -116,11 +116,11 @@ satisfies all three of the following conditions: (3) If $c>1>d$, then $ \tau (c + d - cd)=\tau (c) + \tau (d) -\tau (c) \tau (d)$. Find all the possible values of $\tau(-1)$. -","$(-\infty , 0]$",Algebra,Functional Equation,IMO Shortlist 2004 +","$(-\infty , 0]$",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2004 imo-bench-algebra-029,"Find all functions $g:\mathbb{R}^+\rightarrow\mathbb{R}^+$ such that for all positive real numbers $q, w, e$, $g(4qwe)+g(q)+g(w)+g(e)=9g(\sqrt{qw})g(\sqrt{eq})g(\sqrt{we})$, and if $r>t\ge \frac{1}{2}$, then $g(r)>g(t)$. -",$g(x)=\frac{1}{3} ((2x)^a +(2x)^{-a})$ for some $a>0$,Algebra,Functional Equation,IMO Shortlist 2003 +",$g(x)=\frac{1}{3} ((2x)^a +(2x)^{-a})$ for some $a>0$,Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2003 imo-bench-algebra-030,"Find the maximum value of $D$ satisfying the following condition: There exists an infinite sequence $x_1, x_2, \ldots$ where each term belongs to $[0, 777]$ such that for all positive integers $m < n$, we have $$(m+n)|x_n^2 - x_m^2| \ge D.$$ -",603729,Algebra,Inequality,IMO Shortlist 2003 +",603729,Algebra,IMO-Medium,Inequality,IMO Shortlist 2003 imo-bench-algebra-031,"Let $E$ be the set of nonnegative even integers. Find all functions $T:E^3\rightarrow \mathbb{R}$ such that for all even integers $k, m, n$, $$ T(k,m,n) = \begin{cases} k+m+n & \text{if} \; kmn = 0, \\ @@ -128,83 +128,83 @@ $$ T(k,m,n) = \begin{cases} k+m+n & \text{if} \; kmn = 0, \\ + T(k,m + 2,n - 2) + T(k,m - 2,n + 2) & \\ + T(k - 2,m + 2,n) + T(k - 2,m,n + 2) ) & \text{otherwise} \end{cases} $$ -","$T(p,q,r)=0 if (p,q,r)=(0,0,0), p+q+r+\frac{9pqr}{4(p+q+r)} otherwise$",Algebra,Functional Equation,IMO Shortlist 2002 +","$T(p,q,r)=0 if (p,q,r)=(0,0,0), p+q+r+\frac{9pqr}{4(p+q+r)} otherwise$",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2002 imo-bench-algebra-032,"We call $g: \mathbb{R} \rightarrow \mathbb{R}$ a good function if $g$ satisfies all the following conditions: (1) For any two distinct real numbers $a, b$, if $g(ab) = 0$, then $g(a) = 0$ or $g(b) = 0$. (2) For any two distinct real numbers $a, b$, if $g(ab) \neq 0$, then $$\frac{g(a)-g(b)}{a-b}=\frac{g(a)g(b)}{g(ab)}.$$ (3) $g(1)=1$ \\ -Let $S=\{2^a 3^b 5^c 7^d : a,b,c,d\in \mathbb{Z}\}$ and we call $h:S\rightarrow \mathbb{R}$ an essential function if there exists a good function $g$ such that $h(x)=g(x)$ for all $x\in S$. Find the number of essential functions. ",16,Algebra,Functional Equation,IMO Shortlist 2001 +Let $S=\{2^a 3^b 5^c 7^d : a,b,c,d\in \mathbb{Z}\}$ and we call $h:S\rightarrow \mathbb{R}$ an essential function if there exists a good function $g$ such that $h(x)=g(x)$ for all $x\in S$. Find the number of essential functions. ",16,Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2001 imo-bench-algebra-033,"Find all pairs $(M, x_0, x_1, \lodts , x_M)$ of positive integers $x_0, x_1, \ldots, x_M$ that satisfy the following three conditions: (1) $x_0 = 1$. (2) For each $1 \le i < M$, $x_{i+1} \ge 1 + \frac{x_i^3 - x_i^2}{x_{i-1}}$. (3) $\sum_{i=1}^{M} \frac{x_{i-1}}{x_i} = 0.9375$. -","$(4, 1, 2, 5, 134, 718240)$",Algebra,Sequence,IMO Shortlist 2001 +","$(4, 1, 2, 5, 134, 718240)$",Algebra,IMO-Medium,Sequence,IMO Shortlist 2001 imo-bench-algebra-034,"Find all functions $P, Q: \mathbb{R} \rightarrow \mathbb{R}$ such that for all real numbers $m, n$, $$P(m+Q(n))=nP(m) - m P(n) + Q(m).$$ -","$P(x)=(cx+c^{2})/(1+c), Q(x)=cx+c^{2}$, where $c\ne -1$",Algebra,Functional Equation,IMO Shortlist 2001 +","$P(x)=(cx+c^{2})/(1+c), Q(x)=cx+c^{2}$, where $c\ne -1$",Algebra,IMO-Medium,Functional Equation,IMO Shortlist 2001 imo-bench-algebra-035,"Find all real-coefficient polynomials $f$ such that $2f(0.5f(n))=f(f(n))-f(n)^2$ holds for all real numbers $n$. -","$f(x)=-1, f(x)=2x^{2}+b x, f(x)=0$",Algebra,Polynomial,Iran 2002 +","$f(x)=-1, f(x)=2x^{2}+b x, f(x)=0$",Algebra,IMO-Hard,Polynomial,Iran 2002 imo-bench-algebra-036,"Find all functions $Y: \mathbb{R} \backslash\{0\} \rightarrow \mathbb{R}$ such that for any non-zero real numbers $a, b$ with $ab \neq -1$, the following equation holds: \[ a Y\left(a+\frac{1}{b}\right)+b Y(b)+\frac{a}{b}=b Y\left(b+\frac{1}{a}\right)+a Y(a)+\frac{b}{a} \] ","$Y(x)=A+\frac{B}{x}-x$ -",Algebra,Functional Equation,Iran 2002 +",Algebra,IMO-Hard,Functional Equation,Iran 2002 imo-bench-algebra-037,"Find all functions $X: \mathbb{C} \rightarrow \mathbb{C}$ such that the equation $$X(X(a)+b X(b)-b-1)=1+a+|b|^{2}$$ holds for all complex numbers $a,b\in \mathbb{C}$ and that $X(1)=u$ for some $u\in \mathbb{C}$ such that $|u-1|=1$. -",$X(y)=1+(u-1) \bar{y}$,Algebra,Functional Equation,Iran 2024 +",$X(y)=1+(u-1) \bar{y}$,Algebra,IMO-Hard,Functional Equation,Iran 2024 imo-bench-algebra-038,"For real numbers $c, v > 1$, suppose there exist real-coefficient polynomials $A(x)$ and $B(x)$, neither of which is a constant polynomial and both of which have a leading coefficient of 1, such that for each positive integer $t$, the real solutions of $A(x) = c^t$ and $B(x) = v^t$ agree. Find all possible pairs $(c, v)$.","all $(c,v)$ for which $c,v>1$ and $\frac{\log c}{\log v}\in\mathbb{Q}$ -",Algebra,Polynomial,Iran 2024 +",Algebra,IMO-Hard,Polynomial,Iran 2024 imo-bench-algebra-039,"Let $p, q, r, s$ be constants such that the equation $py^3 + qy^2 + ry + s = 0$ has three distinct real roots. Find all possible values for the number of distinct real roots of the equation $$\left(pz^{3}+qz^{2}+rz+s\right)(6pz+2q)=\left(3pz^{2}+2qz+r\right)^{2}.$$ -",2,Algebra,Equation,Ukraine 1997 +",2,Algebra,IMO-Medium,Equation,Ukraine 1997 imo-bench-algebra-040,"Find all functions $G:\mathbb{R}\rightarrow\mathbb{R}$ that satisfy both of the following conditions: (1) For all real numbers $m,n$, $G(m)+G(n)-G(m+n)\in\{1,2\}$. (2) For all real numbers $l$, $\lfloor G(l) \rfloor - \lfloor l \rfloor =1$. -",f(x)=x+1,Algebra,Functional Equation,Korea 2018 +",f(x)=x+1,Algebra,IMO-Medium,Functional Equation,Korea 2018 imo-bench-algebra-041,"Find all $f \in \mathbb{C}[x,y]$ such that for all complex numbers $a, b$, $$f(a^2,b^2)=f\left(\frac{(a-b)^{2}}{2}, \frac{(a+b)^{2}}{2}\right).$$ -","$f(x,y)= g(x+y, xy(x-y)^{2})$ for some polynomial $g$",Algebra,Polynomial,Iran 2009 +","$f(x,y)= g(x+y, xy(x-y)^{2})$ for some polynomial $g$",Algebra,IMO-Hard,Polynomial,Iran 2009 imo-bench-algebra-042,"A sequence $f_1, f_2, \ldots, f_{1028}$ of non-negative real numbers is said to be concave if for each $1 < i < 1028$, $f_{i+1} \le 2f_i - f_{i-1}$. Find the minimum value of the constant $L$ such that the inequality $$L \sum_{j=1}^{1028} i f_{i}^{2} \geq \sum_{i=1}^{1028} f_{i}^{2}$$ holds for all concave sequences $f_1, f_2, \ldots, f_{1028}$. -",$\frac{685}{176302}$,Algebra,Sequence,Iran 2010 +",$\frac{685}{176302}$,Algebra,IMO-Hard,Sequence,Iran 2010 imo-bench-algebra-043,"A sequence $b_1, b_2, \ldots, b_k$ is said to 'increase steeply' if each term is positive, and for each $2 \le i \le k$, $b_i \ge b_{i-1} + \cdots + b_2 + b_1$. Find the maximum value of the constant $S$ such that for all $k$ and steeply increasing sequences $b_1, b_2, \ldots, b_k$, $$S\sum_{i=1}^k{\sqrt{x_i}}\le \sqrt{\sum_{i=1}^k{x_i}}$$ holds. -",$\sqrt{2}-1$,Algebra,Inequality,IMO Shortlist 1986 +",$\sqrt{2}-1$,Algebra,IMO-Medium,Inequality,IMO Shortlist 1986 imo-bench-algebra-044,"Find the maximum value of the constant $U$ such that $(2x^2+1)(2y^2+1)(2z^2+1)\ge U(xy+yz+zx)$ is always true for positive real numbers $x, y, z$. -",$\frac{9}{2}$,Algebra,Inequality,APMO 2004 +",$\frac{9}{2}$,Algebra,IMO-Easy,Inequality,APMO 2004 imo-bench-algebra-045,"We say that a tuple $(u,v,w)$ of positive real numbers is 'entangled' if $(u+v+w)^3 = 32uvw$. For entangled $(u,v,w)$, find the sum of the minimum and maximum possible value of $$\frac{uvw(u+v+w)}{u^4+v^4+w^4}.$$ -",$\frac{17458+2970\sqrt{5}}{23769}$,Algebra,Inequality,Vietnam 2004 +",$\frac{17458+2970\sqrt{5}}{23769}$,Algebra,IMO-Medium,Inequality,Vietnam 2004 imo-bench-algebra-046,"$(x,y,z) \in \mathbb{R}^3$ is a unit vector with respect to the Euclidean distance. Find the minimum possible value of $9xyz - 2(x+y+z)$. -",$-\frac{10}{3}$,Algebra,Inequality,Vietnam 2002 +",$-\frac{10}{3}$,Algebra,IMO-Medium,Inequality,Vietnam 2002 imo-bench-algebra-047,"We call a real number $x$ 'mysterious' if it is a solution to $A(x) = \frac{1}{\sqrt[3]{3}}x$ for some polynomial $A(x)$ with rational coefficients. Find all polynomials $A(x)$ with rational coefficients of lowest possible degree such that $\sqrt[3]{3} + \sqrt[3]{9}$ is mysterious. -",$A(x)=\frac{1}{2}(x^2-x-4)$,Algebra,Polynomial,Vietnam 1997 +",$A(x)=\frac{1}{2}(x^2-x-4)$,Algebra,IMO-Medium,Polynomial,Vietnam 1997 imo-bench-algebra-048,"Let $P$ be a real-coefficient polynomial with positive leading coefficient such that $tP(t)P(1-t) \ge -225 - t^3$ holds for all real numbers $t$. Find all possible values of $P(0)$. -","$[-6,5]$",Algebra,Polynomial,Czech-Slovakia 1995 +","$[-6,5]$",Algebra,IMO-Medium,Polynomial,Czech-Slovakia 1995 imo-bench-algebra-049,"Real numbers $d$ and $f$, and negative real numbers $\alpha$ and $\beta$ satisfy the following two conditions. (1) $\alpha^{4}+4\alpha^{3}+4\alpha^{2}+d\alpha+f=\beta^{4}+4\beta^{3}+4\beta^{2}+d\beta+f=0$ (2) $\frac{1}{\alpha}+\frac{1}{\beta}=-2$ Find the minimum possible value of $d-f$. -",$\frac{16}{27}$,Algebra,Inequality,Moldova 2008 +",$\frac{16}{27}$,Algebra,IMO-Medium,Inequality,Moldova 2008 imo-bench-algebra-050,"Let $r$ be the unique positive root of $x^3+x^2+x-10=0$. Suppose that for non-negative integers $k_0, k_1, k_2, \ldots , k_{100}$, we have $$\sum_{i=0}^{101}k_i r^i=2025.$$ Find the minimum possible value of $\sum_{i=0}^{101}k_i$. -",44,Algebra,Polynomial,Vietnam 2015 +",44,Algebra,IMO-Medium,Polynomial,Vietnam 2015 imo-bench-algebra-051,"Find all possible positive integer $n$ such that there exists polynomial $P(x), Q(x)$ with integer coefficients such that \[ P(x)^2 + 3P(x)Q(x) + 2Q(x)^2 = x^{n+2} - 3x^{n+1} + 2x^{n} + 6 \] -and $1 \le \deg P \le n + 1$.",odd $n$,Algebra,Polynomial,Czech-Polish-Slovak Match 2005 +and $1 \le \deg P \le n + 1$.",odd $n$,Algebra,IMO-Medium,Polynomial,Czech-Polish-Slovak Match 2005 imo-bench-algebra-052,"Find the minimal $d$ satisfying the following property: For any sequence of integers $x_1, x_2, \ldots, x_n$ satisfying @@ -214,82 +214,82 @@ For any sequence of integers $x_1, x_2, \ldots, x_n$ satisfying for all $i = 1, 2, \ldots, n$, there exists a subset $I$ of $\{1,2, \ldots, n\}$ such that \[ \left| \sum_{i \in I} x_i - 1810 \right| \le d. -\]",48,Algebra,Sequence,Argentina 2017 +\]",48,Algebra,IMO-Medium,Sequence,Argentina 2017 imo-bench-algebra-053,"Let $x, y, z$ be real numbers such that \[ |x^2 + 2yz + 2(x + y + z) + 3|, |y^2 + 2zx + 2(x + y + z) + 3|, |z^2 + 2xy + 2(x + y + z) + 3| \] -are three heights of a (non-degenerate) triangle. Find all possible values of $xy + yz + zx + 2(x + y + z)$.","$(-\infty, -3) \cup (-3, \infty)$",Algebra,Inequality,Czech and Slovak 2018 +are three heights of a (non-degenerate) triangle. Find all possible values of $xy + yz + zx + 2(x + y + z)$.","$(-\infty, -3) \cup (-3, \infty)$",Algebra,IMO-Medium,Inequality,Czech and Slovak 2018 imo-bench-algebra-054,"Let $a_0, a_1, a_2, \ldots$ be an infinite sequence of integers that is not eventually periodic, which means there does not exist integers $N, d > 0$ such that $a_{n + d} = a_n$ for all integers $n \ge N$. -Let $S$ be the set of $2025$-tuples containing $(a_{n + 1}, \ldots, a_{n + 2025})$ for $n = 0, 1, \ldots$. Find the minimum number of elements of $S$.",2026,Algebra,Sequence,Italia 2018 +Let $S$ be the set of $2025$-tuples containing $(a_{n + 1}, \ldots, a_{n + 2025})$ for $n = 0, 1, \ldots$. Find the minimum number of elements of $S$.",2026,Algebra,IMO-Medium,Sequence,Italia 2018 imo-bench-algebra-055,"Consider a sequence of positive integers $x_1, x_2, \ldots$ satisfying the following condition: \[ (x_{2n + d} - x_{n + d} - n)(x_{2n + d} - x_n - n - d) = 0 \] -for all integers $n \ge 32$ and $d \ge 1024$. Find the value of the largest possible positive integer $n$ for which $x_{n + 1} - x_n \neq 1$.",2079,Algebra,Sequence,Japan 2018 +for all integers $n \ge 32$ and $d \ge 1024$. Find the value of the largest possible positive integer $n$ for which $x_{n + 1} - x_n \neq 1$.",2079,Algebra,IMO-Medium,Sequence,Japan 2018 imo-bench-algebra-056,"Find the smallest positive integer $k$ such that there exist two polynomials $f(x),g(x)$ with integer coefficients, both of degree at least 2025 and leading coefficients at least 1000, such that \[ f(g(x)) - 3g(f(x)) = k \] -for infinitely many real numbers $x$. ",1,Algebra,Polynomial,Korea 2018 +for infinitely many real numbers $x$. ",1,Algebra,IMO-Medium,Polynomial,Korea 2018 imo-bench-algebra-057,"Let $p$ be a positive rational number. Alice and Bob each have a blackboard, initially displaying 0. In the $n$-th minute ($n = 1, 2, 3, \ldots$) they independently add $p^n,0$, or $-p^n$ to the number on their respective boards. -After a certain number of minutes, their blackboards display the same number, despite having made at least one different choice during the process. Determine all possible values of $p$.","1/2,1,2",Algebra,Operation,Balkan 2018 -imo-bench-algebra-058,"For all positive integers $n$ and all real numbers $a_1, \ldots, a_n$ less than or equal to $2 / \sqrt{n}$ such that $\sum_{i=1}^n a_i^3 = 0$, find the maximum value of $\sum_{k=1}^n a_i^2$.",$\frac{16}{3}$,Algebra,Inequality,Romania 2018 +After a certain number of minutes, their blackboards display the same number, despite having made at least one different choice during the process. Determine all possible values of $p$.","1/2,1,2",Algebra,IMO-Easy,Operation,Balkan 2018 +imo-bench-algebra-058,"For all positive integers $n$ and all real numbers $a_1, \ldots, a_n$ less than or equal to $2 / \sqrt{n}$ such that $\sum_{i=1}^n a_i^3 = 0$, find the maximum value of $\sum_{k=1}^n a_i^2$.",$\frac{16}{3}$,Algebra,IMO-Medium,Inequality,Romania 2018 imo-bench-algebra-059,"Compute the integral part of the number \[ \sum_{n=1}^{2024}\frac{2025^n}{\left(1+2025\right)\cdots\left(n+2025\right)}-\sum_{n=1}^{2024}\left(1-\frac{1}{2025}\right)\cdots\left(1-\frac{n}{2025}\right). -\]",0,Algebra,Inequality,Romania 2018 +\]",0,Algebra,IMO-Medium,Inequality,Romania 2018 imo-bench-algebra-060,"Let $n, p, q$ be positive integers such that \[ S = \frac{12 + n}{p} + \frac{13 - n}{q} < 1, \quad 1 \le n \le 12. \] -Find the maximum possible value of $S$.", $\frac{2617}{2618}$,Algebra,Inequality,Singapore 2018 +Find the maximum possible value of $S$.", $\frac{2617}{2618}$,Algebra,IMO-Medium,Inequality,Singapore 2018 imo-bench-algebra-061,"Call a polynomial $P(x, y, z)$ with integer coefficients \emph{good} if for any real numbers $x, y, z$, $P(x, y, z) = 0$ if and only if $x = y = z$. -Find the maximal integer $n$ such that for all \emph{good} polynomials $P$ and integers $a, b, c$ satisfying $b - a = c -b\ne 0$, $P(a, b, c)$ is divisible by $(b - a)^n$.",2,Algebra,Polynomial,Singapore 2018 +Find the maximal integer $n$ such that for all \emph{good} polynomials $P$ and integers $a, b, c$ satisfying $b - a = c -b\ne 0$, $P(a, b, c)$ is divisible by $(b - a)^n$.",2,Algebra,IMO-Medium,Polynomial,Singapore 2018 imo-bench-algebra-062,"Let $x_0, x_1, \ldots, x_{2024}$ and $y_1, y_2, \ldots, y_{2024}$ be two real sequences such that for all $n = 0, 1, \ldots, 2023$, \[ x_{n+1} = 4x_n^2, \quad y_{n+1} = x_n \quad \text{ or } \quad x_{n+1} = \frac{x_n}{2}, \quad y_{n+1} = \frac{1}{4} - x_n \] holds, and $x_{2024} \le x_0$. Find the maximal value of $y_1 + \cdots + y_{2024}$. -",506,Algebra,Sequence,Turkey 2018 +",506,Algebra,IMO-Medium,Sequence,Turkey 2018 imo-bench-algebra-063,"Let $a, b, c$ be lengths of the sides of some triangle of positive area, satisfying \[ a^2b^2 = 2(a + b - c)(b + c - a)(c + a - b). \] Find the maximum value for $a + b + c$. -",8,Algebra,Inequality,Austria 2017 +",8,Algebra,IMO-Medium,Inequality,Austria 2017 imo-bench-algebra-064,"Let $a, b, c, k$ be nonzero real numbers such that \[ a - b = kbc, \quad b - c = kca, \quad c- a = kab. \] Find all possible values of $\frac{a}{c} + \frac{b}{a} + \frac{c}{b}$. -",-3,Algebra,Inequality,Belarus 2017 +",-3,Algebra,IMO-Medium,Inequality,Belarus 2017 imo-bench-algebra-065,"Find all positive real $c$ such that there exists an infinite sequence of positive real numbers $a_1, a_2, \dots$ satisfying \[ a_{n+2}^2 - a_{n+1} + c a_n = 0 \] for all $n \ge 1$. -",$0 0$ with the following property: for every sequence of positive real numbers $c_1, c_2, c_3, \dots$ with $c_i < C$ for all $i$, Ronaldo can (after studying the sequence) ensure that there is some point on the circle that it will never visit or run across.",0.5,Combinatorics,Operations,EGMO 2023 -imo-bench-combinatorics-012,"A domino is a $2 \times 1$ or $1 \times 2$ tile. A mysterious puzzle involves placing exactly $k^2$ dominoes on a $2k \times 2k$ chessboard without overlapping. The placement must satisfy a peculiar condition: every $2 \times 2$ square on the board contains at least two uncovered unit squares that lie in the same row or column. Additionally, there are some strange symbols engraved on the board that seem to have no connection to the puzzle. Determine in how many ways the dominoes can be placed according to these rules.",$\binom{2k}{k}^2$,Combinatorics,Enumerative Combinatorics,EGMO 2015 +Determine the largest constant $C > 0$ with the following property: for every sequence of positive real numbers $c_1, c_2, c_3, \dots$ with $c_i < C$ for all $i$, Ronaldo can (after studying the sequence) ensure that there is some point on the circle that it will never visit or run across.",0.5,Combinatorics,IMO-Easy,Operations,EGMO 2023 +imo-bench-combinatorics-012,"A domino is a $2 \times 1$ or $1 \times 2$ tile. A mysterious puzzle involves placing exactly $k^2$ dominoes on a $2k \times 2k$ chessboard without overlapping. The placement must satisfy a peculiar condition: every $2 \times 2$ square on the board contains at least two uncovered unit squares that lie in the same row or column. Additionally, there are some strange symbols engraved on the board that seem to have no connection to the puzzle. Determine in how many ways the dominoes can be placed according to these rules.",$\binom{2k}{k}^2$,Combinatorics,IMO-Easy,Enumerative Combinatorics,EGMO 2015 imo-bench-combinatorics-013,"There are 42 students participating in the Team Selection Test, each of them is assigned a positive integer from $1$ to $42$ such that no two students have the same number and every number from $1$ to $42$ is assigned to a student. The team leader want to select a subset of these students such that there are no two students that have numbers whose difference is $1$ or $21$. For example, the team leader can pick the set $\{1, 3, 6, 25, 28, 34, 42\}$ but not $\{1, 2, 4, 6, 24\}$ or $\{1, 3, 24, 26, 28\}$. -How many ways can the team leader pick such a subset?",120526555,Combinatorics,Enumerative Combinatorics,Vietnam Mathematical Olympiad 2009 -imo-bench-combinatorics-014,"In a board of $125 \times 125$ grids, we pick $k$ unit squares such that every picked square shares vertices with at most $1$ other picked square. Some squares are colored red and some squares are colored blue, where red squares and blue squares satisfy the following condition: any two squares of the same color do not share a side or a vertex. Determine the maximum of $k$.",5292,Combinatorics,Extremal Combinatorics,Vietnam TST 2021 -imo-bench-combinatorics-015,"The $30$ edges of a regular icosahedron are distinguished by labeling them $1,2,\dots,30.$ Hoang, a Vietnamese student, is tasked with painting each edge red, white, or blue. However, there's a special condition: each of the 20 triangular faces of the icosahedron must have two edges of the same color and a third edge of a different color. Additionally, there are 20 small balls inside the icosahedron, each with a different distinct number written on them. How many different ways are there to paint the edges to satisfy the given condition?",$12^{10}$,Combinatorics,Enumerative Combinatorics,Putnam 2017 -imo-bench-combinatorics-016,"Suppose $X$ is a set with $|X| = 56$. In a Chinese mathematics competition, students are given 15 subsets of $X$. Find the minimum value of $n$, so that if the cardinality of the union of any 7 of these subsets is greater or equal to $n$, then there exists 3 of them whose intersection is nonempty.",41,Combinatorics,Extremal Combinatorics,China 2006 -imo-bench-combinatorics-017,"Let $A_1 A_2 \cdots A_{101}$ be a regular $101$ polygon. Denote by $P$ the set of its vertices. Additionally, let $Q$ be a set of $200$ random points in the plane, none of which are collinear. Find the number of convex pentagons whose vertices belong to $P$ and have exactly two acute angles.",48500200,Combinatorics,Enumerative Combinatorics,China 2009 -imo-bench-combinatorics-018,"Find the smallest positive integer $k$ such that, for any subset $A$ of $S=\{1,2,\ldots,2024\}$ with $|A|=k$, there exist three elements $x,y,z$ in $A$ such that $x=a+b$, $y=b+c$, $z=c+a$, where $a,b,c$ are in $S$ and are distinct integers. Additionally, there exists a set $B$ such that $B$ is a subset of $S$ and $|B|=10$.",1014,Combinatorics,Additive Combinatorics,China 2012 +How many ways can the team leader pick such a subset?",120526555,Combinatorics,IMO-Medium,Enumerative Combinatorics,Vietnam Mathematical Olympiad 2009 +imo-bench-combinatorics-014,"In a board of $125 \times 125$ grids, we pick $k$ unit squares such that every picked square shares vertices with at most $1$ other picked square. Some squares are colored red and some squares are colored blue, where red squares and blue squares satisfy the following condition: any two squares of the same color do not share a side or a vertex. Determine the maximum of $k$.",5292,Combinatorics,IMO-Hard,Extremal Combinatorics,Vietnam TST 2021 +imo-bench-combinatorics-015,"The $30$ edges of a regular icosahedron are distinguished by labeling them $1,2,\dots,30.$ Hoang, a Vietnamese student, is tasked with painting each edge red, white, or blue. However, there's a special condition: each of the 20 triangular faces of the icosahedron must have two edges of the same color and a third edge of a different color. Additionally, there are 20 small balls inside the icosahedron, each with a different distinct number written on them. How many different ways are there to paint the edges to satisfy the given condition?",$12^{10}$,Combinatorics,IMO-Hard,Enumerative Combinatorics,Putnam 2017 +imo-bench-combinatorics-016,"Suppose $X$ is a set with $|X| = 56$. In a Chinese mathematics competition, students are given 15 subsets of $X$. Find the minimum value of $n$, so that if the cardinality of the union of any 7 of these subsets is greater or equal to $n$, then there exists 3 of them whose intersection is nonempty.",41,Combinatorics,IMO-Hard,Extremal Combinatorics,China 2006 +imo-bench-combinatorics-017,"Let $A_1 A_2 \cdots A_{101}$ be a regular $101$ polygon. Denote by $P$ the set of its vertices. Additionally, let $Q$ be a set of $200$ random points in the plane, none of which are collinear. Find the number of convex pentagons whose vertices belong to $P$ and have exactly two acute angles.",48500200,Combinatorics,IMO-Hard,Enumerative Combinatorics,China 2009 +imo-bench-combinatorics-018,"Find the smallest positive integer $k$ such that, for any subset $A$ of $S=\{1,2,\ldots,2024\}$ with $|A|=k$, there exist three elements $x,y,z$ in $A$ such that $x=a+b$, $y=b+c$, $z=c+a$, where $a,b,c$ are in $S$ and are distinct integers. Additionally, there exists a set $B$ such that $B$ is a subset of $S$ and $|B|=10$.",1014,Combinatorics,IMO-Hard,Additive Combinatorics,China 2012 imo-bench-combinatorics-019," We arrange the numbers in ${\{1,2,\ldots ,49} \}$ as a $7 \times 7$ matrix $A = ( a_{ij} )$. Next we can select any row or column and add $1$ to every number in it, or subtract $1$ from every number in it. We call the arrangement good if we can change every number of the matrix to $0$ in a finite number of such moves. How many good arrangements are there? -",50803200,Combinatorics,Enumerative Combinatorics,China 2012 -imo-bench-combinatorics-020,"Suppose there are $40$ professional baseball teams participating in a tournament. In each round of the game, we will divide the $40$ teams into $20$ pairs, and each pair plays the game at the same time. After the tournament, it is known that every two teams have played at most one game. Find the smallest positive integer $a$, so that we can arrange a schedule satisfying the above conditions, and if we take one more round, there is always a pair of teams who have played in the game.",21,Combinatorics,Graph Theory,Vietnam TST 2020 -imo-bench-combinatorics-021,"Let $A$ be a set containing $2000$ distinct integers and $B$ be a set containing $2016$ distinct integers. Let $C$ be a set containing $2020$ distinct integers. $K$ is the number of pairs $(m,n)$ satisfying\[ \begin{cases} m\in A, n\in B\\ |m-n|\leq 1000 \end{cases} \] Find the maximum value of $K$.",3016944,Combinatorics,Extremal Combinatorics,Vietnam TST 2016 -imo-bench-combinatorics-022,"Consider a regular hexagon with side length $100$ that is divided into equilateral triangles with side length $1$ by lines parallel to its sides. Additionally, there are two circles with radii $99$ and $101$, respectively. Find the number of regular hexagons all of whose vertices are among the vertices of the equilateral triangles of the regular hexagon with side length $100$.",25502500,Combinatorics,Enumerative Combinatorics,Balkan MO 2014 -imo-bench-combinatorics-023,"At a university dinner, there are 2017 mathematicians who each order two distinct entrées, with no two mathematicians ordering the same pair of entrées. The price of each dish varies depending on the popularity of the dish. The cost of each entrée is equal to the number of mathematicians who ordered it, and the university pays for each mathematician's less expensive entrée (ties broken arbitrarily). Over all possible sets of orders, what is the maximum total amount the university could have paid?",127009,Combinatorics,Graph Theory,USA TST 2017 +",50803200,Combinatorics,IMO-Hard,Enumerative Combinatorics,China 2012 +imo-bench-combinatorics-020,"Suppose there are $40$ professional baseball teams participating in a tournament. In each round of the game, we will divide the $40$ teams into $20$ pairs, and each pair plays the game at the same time. After the tournament, it is known that every two teams have played at most one game. Find the smallest positive integer $a$, so that we can arrange a schedule satisfying the above conditions, and if we take one more round, there is always a pair of teams who have played in the game.",21,Combinatorics,IMO-Hard,Graph Theory,Vietnam TST 2020 +imo-bench-combinatorics-021,"Let $A$ be a set containing $2000$ distinct integers and $B$ be a set containing $2016$ distinct integers. Let $C$ be a set containing $2020$ distinct integers. $K$ is the number of pairs $(m,n)$ satisfying\[ \begin{cases} m\in A, n\in B\\ |m-n|\leq 1000 \end{cases} \] Find the maximum value of $K$.",3016944,Combinatorics,IMO-Hard,Extremal Combinatorics,Vietnam TST 2016 +imo-bench-combinatorics-022,"Consider a regular hexagon with side length $100$ that is divided into equilateral triangles with side length $1$ by lines parallel to its sides. Additionally, there are two circles with radii $99$ and $101$, respectively. Find the number of regular hexagons all of whose vertices are among the vertices of the equilateral triangles of the regular hexagon with side length $100$.",25502500,Combinatorics,IMO-Easy,Enumerative Combinatorics,Balkan MO 2014 +imo-bench-combinatorics-023,"At a university dinner, there are 2017 mathematicians who each order two distinct entrées, with no two mathematicians ordering the same pair of entrées. The price of each dish varies depending on the popularity of the dish. The cost of each entrée is equal to the number of mathematicians who ordered it, and the university pays for each mathematician's less expensive entrée (ties broken arbitrarily). Over all possible sets of orders, what is the maximum total amount the university could have paid?",127009,Combinatorics,IMO-Hard,Graph Theory,USA TST 2017 imo-bench-combinatorics-024,"Let $S$ denote the set of all permutations of the numbers $1,2,\dots,2024.$ For $\pi\in S,$ let $\sigma(\pi)=1$ if $\pi$ is an even permutation and $\sigma(\pi)=-1$ if $\pi$ is an odd permutation. Also, let $v(\pi)$ denote the number of fixed points of $\pi.$ Let $f(x)$ be an arbitrary polynomial such that $f(0)=1$. Compute the sum -\[ \sum_{\pi\in S}\frac{\sigma(\pi)}{v(\pi)+1}. \]",$-\frac{2024}{2025}$,Combinatorics,Enumerative Combinatorics,Putnam 2005 -imo-bench-combinatorics-025,"Alice and Bob play a game on a board consisting of one row of 2020 consecutive squares. They take turns placing tiles that cover two adjacent squares, with Alice going first. By rule, a tile must not cover a square that is already covered by another tile. The game ends when no tile can be placed according to this rule. Alice's goal is to maximize the number of uncovered squares when the game ends; Bob's goal is to minimize it. What is the greatest number of uncovered squares that Alice can ensure at the end of the game, no matter how Bob plays?",290,Combinatorics,Game Theory,Putnam 2022 +\[ \sum_{\pi\in S}\frac{\sigma(\pi)}{v(\pi)+1}. \]",$-\frac{2024}{2025}$,Combinatorics,IMO-Hard,Enumerative Combinatorics,Putnam 2005 +imo-bench-combinatorics-025,"Alice and Bob play a game on a board consisting of one row of 2020 consecutive squares. They take turns placing tiles that cover two adjacent squares, with Alice going first. By rule, a tile must not cover a square that is already covered by another tile. The game ends when no tile can be placed according to this rule. Alice's goal is to maximize the number of uncovered squares when the game ends; Bob's goal is to minimize it. What is the greatest number of uncovered squares that Alice can ensure at the end of the game, no matter how Bob plays?",290,Combinatorics,IMO-Hard,Game Theory,Putnam 2022 imo-bench-combinatorics-026,"Let $S = \left\{ 1,2,\dots,25 \right\}$. Each of the $2^{25}$ subsets of $S$ is to be colored blue or green. (The subset itself is assigned a color and not its individual elements.) For any set $T \subseteq S$, we then write $f(T)$ for the number of subsets of $T$ that are blue. -Determine the number of colorings that satisfy the following condition: for any subsets $T_1$ and $T_2$ of $S$,\[ f(T_1)f(T_2) = f(T_1 \cup T_2)f(T_1 \cap T_2). \]",847288609444,Combinatorics,Enumerative Combinatorics,USA 2015 -imo-bench-combinatorics-027,"Two rational numbers \(\tfrac{m}{n}\) and \(\tfrac{n}{m}\) are written on a blackboard, where \(m\) and \(n\) are relatively prime positive integers. At any point, Lin may pick two of the numbers \(x\) and \(y\) written on the board and write either their arithmetic mean \(\tfrac{x+y}{2}\) or their harmonic mean \(\tfrac{2xy}{x+y}\) on the board as well. For a pair \((m,n)\) such that Lin can write 1 on the board in finitely many steps, find the largest value of $m+n$ knowing that $m+n < 3000$.",2048,Combinatorics,Operations,USA 2019 -imo-bench-combinatorics-028,"Several positive integers are written on a chalkboard in a row from left to right. A transformation is performed as follows: For every pair of consecutive integers on the chalkboard, the sum of those two numbers is written between them. After 2013 such transformations, how many times does the number 2013 appear on the chalkboard if the initial numbers written on the chalkboard are 1, 2, 3, ..., 1000?",1198,Combinatorics,Operations,Vietnam Mathematical Olympiad 2013 +Determine the number of colorings that satisfy the following condition: for any subsets $T_1$ and $T_2$ of $S$,\[ f(T_1)f(T_2) = f(T_1 \cup T_2)f(T_1 \cap T_2). \]",847288609444,Combinatorics,IMO-Medium,Enumerative Combinatorics,USA 2015 +imo-bench-combinatorics-027,"Two rational numbers \(\tfrac{m}{n}\) and \(\tfrac{n}{m}\) are written on a blackboard, where \(m\) and \(n\) are relatively prime positive integers. At any point, Lin may pick two of the numbers \(x\) and \(y\) written on the board and write either their arithmetic mean \(\tfrac{x+y}{2}\) or their harmonic mean \(\tfrac{2xy}{x+y}\) on the board as well. For a pair \((m,n)\) such that Lin can write 1 on the board in finitely many steps, find the largest value of $m+n$ knowing that $m+n < 3000$.",2048,Combinatorics,IMO-Medium,Operations,USA 2019 +imo-bench-combinatorics-028,"Several positive integers are written on a chalkboard in a row from left to right. A transformation is performed as follows: For every pair of consecutive integers on the chalkboard, the sum of those two numbers is written between them. After 2013 such transformations, how many times does the number 2013 appear on the chalkboard if the initial numbers written on the chalkboard are 1, 2, 3, ..., 1000?",1198,Combinatorics,IMO-Medium,Operations,Vietnam Mathematical Olympiad 2013 imo-bench-combinatorics-029,"We call a rectangle of the size $1 \times 2$ a domino. Rectangle of the $2 \times 3$ removing two opposite (under center of rectangle) corners we call S-tetramino. These figures can be rotated. A rectangle of the size $2 \times 4$ removing two opposite (under center of rectangle) corners we call L-hexamino. These figures can be rotated. -It requires to tile rectangle of size $1008 \times 1010$ by using dominoes and S-tetraminoes. What is the minimal number of dominoes should be used?",506,Combinatorics,Tiling,Vietnam TST 2010 -imo-bench-combinatorics-030,"A cube with size $18 \times 18 \times 18$ consists of $5832$ unit cubes, all colored white. Anton and Berta play a game on this cube. Anton chooses some pillars with size $1\times 1\times 18$ such that no two pillars share a vertex or side, and turns all chosen unit cubes to black. Berta is allowed to choose some unit cubes and ask Anton their colors. In addition, Anton also tells Berta that he painted at least two pillars. How many unit cubes, at least, that Berta need to choose so that for any answer from Anton, Berta can always determine the black unit cubes?",486,Combinatorics,Extremal Combinatorics,Vietnam TST 2013 +It requires to tile rectangle of size $1008 \times 1010$ by using dominoes and S-tetraminoes. What is the minimal number of dominoes should be used?",506,Combinatorics,IMO-Hard,Tiling,Vietnam TST 2010 +imo-bench-combinatorics-030,"A cube with size $18 \times 18 \times 18$ consists of $5832$ unit cubes, all colored white. Anton and Berta play a game on this cube. Anton chooses some pillars with size $1\times 1\times 18$ such that no two pillars share a vertex or side, and turns all chosen unit cubes to black. Berta is allowed to choose some unit cubes and ask Anton their colors. In addition, Anton also tells Berta that he painted at least two pillars. How many unit cubes, at least, that Berta need to choose so that for any answer from Anton, Berta can always determine the black unit cubes?",486,Combinatorics,IMO-Hard,Extremal Combinatorics,Vietnam TST 2013 imo-bench-combinatorics-031,"Let $\gamma \geq 1$ be a real number. Sun Wukong and the Sea God play a turn-based game on an infinite grid of unit squares. Before the game starts, the Sea God chooses a finite number of cells to be flooded with seawater. Sun Wukong is building a magical barrier, which is a subset of unit edges of the grid (called walls) forming a connected, non-self-intersecting path or loop. Additionally, there is a magical artifact that randomly generates a finite number of extra walls on the grid, with no specific pattern or distribution. -The game then begins with Sun Wukong moving first. On each of Sun Wukong's turns, he adds one or more walls to the magical barrier, as long as the total length of the barrier is at most $\gamma n$ after his $n$th turn. On each of the Sea God's turns, every cell which is adjacent to an already flooded cell and with no wall between them becomes flooded as well. Sun Wukong wins if the magical barrier forms a closed loop such that all flooded cells are contained in the interior of the loop — hence stopping the flood and saving the world. What is the largest constant $C$ such that for all $\gamma > C$ can Sun Wukong guarantee victory in a finite number of turns no matter how the Sea God chooses the initial cells to flood?",2,Combinatorics,Game Theory,USA TST 2020 -imo-bench-combinatorics-032,"A classroom contains 68 pairs of nonzero integers. Suppose that for each positive integer $k$ at most one of the pairs $(k, k)$ and $(-k, -k)$ is written on the classroom board. A student erases some of the 136 integers, subject to the condition that no two erased integers may add to 0. The student then scores one point for each of the 68 pairs in which at least one integer is erased. Additionally, the classroom has another broken whiteboard, and some integers might be invisible. Determine, with proof, the largest number $N$ of points that the student can guarantee to score regardless of which 68 pairs have been written on the board.",43,Combinatorics,Extremal Combinatorics,USAMO 2010 +The game then begins with Sun Wukong moving first. On each of Sun Wukong's turns, he adds one or more walls to the magical barrier, as long as the total length of the barrier is at most $\gamma n$ after his $n$th turn. On each of the Sea God's turns, every cell which is adjacent to an already flooded cell and with no wall between them becomes flooded as well. Sun Wukong wins if the magical barrier forms a closed loop such that all flooded cells are contained in the interior of the loop — hence stopping the flood and saving the world. What is the largest constant $C$ such that for all $\gamma > C$ can Sun Wukong guarantee victory in a finite number of turns no matter how the Sea God chooses the initial cells to flood?",2,Combinatorics,IMO-Hard,Game Theory,USA TST 2020 +imo-bench-combinatorics-032,"A classroom contains 68 pairs of nonzero integers. Suppose that for each positive integer $k$ at most one of the pairs $(k, k)$ and $(-k, -k)$ is written on the classroom board. A student erases some of the 136 integers, subject to the condition that no two erased integers may add to 0. The student then scores one point for each of the 68 pairs in which at least one integer is erased. Additionally, the classroom has another broken whiteboard, and some integers might be invisible. Determine, with proof, the largest number $N$ of points that the student can guarantee to score regardless of which 68 pairs have been written on the board.",43,Combinatorics,IMO-Medium,Extremal Combinatorics,USAMO 2010 imo-bench-combinatorics-033,"Let $n \geq 2$ be an integer. An $n \times n$ board is initially empty. Each minute, you may perform one of four moves: If there is an L-shaped tromino region of three cells without stones on the board (see figure; rotations not allowed), you may place a stone in each of those cells. If all cells in a column have a stone, you may remove all stones from that column. If all cells in a row have a stone, you may remove all stones from that row. -Find the largest positive integer $n \leq 500$ such that it is possible that, after some non-zero number of moves, the board has no stones.",498,Combinatorics,Operations,USAMO 2021 +Find the largest positive integer $n \leq 500$ such that it is possible that, after some non-zero number of moves, the board has no stones.",498,Combinatorics,IMO-Medium,Operations,USAMO 2021 imo-bench-combinatorics-034,"Let $a, b, c$ be positive integers. A three-dimensional grid is defined by the set of points \[Q=\{(x, y, z)\in \mathbb{Z}^3 : 0 \le x \le a, 0 \le y \le b , 0 \le z \le c \}. \] @@ -560,42 +560,42 @@ Initially, there are a total of $M$ identical pieces distributed among the point (2) Remove $3$ pieces from a point $(x, y, z)$ and place one piece on the point $(x, y-1, z)$, provided $y>0$. (3) Remove $5$ pieces from a point $(x, y, z)$ and place one piece on the point $(x, y, z-1)$, provided $z>0$. -Find the smallest positive integer $M$ such that, regardless of the initial distribution of the pieces, one can always perform a sequence of operations to place at least one piece on the point $(0,0,0)$.",$2^a 3^b 5^c$,Combinatorics,Operations,China TST 2022 +Find the smallest positive integer $M$ such that, regardless of the initial distribution of the pieces, one can always perform a sequence of operations to place at least one piece on the point $(0,0,0)$.",$2^a 3^b 5^c$,Combinatorics,IMO-Hard,Operations,China TST 2022 imo-bench-combinatorics-035,"Let $S$ be a subset of $2012$ points on the plane with these conditions: $i)$ There does not exist $2012$ lines in the plane such that every element of $S$ lies on at least one of them. Additionally, there does not exist any circle passing through every element of $S$. $ii)$ for all $X \in S$ there exists $2012$ lines in the plane such that every element of $S - \{X\}$ lies on at least one of them. -Find the maximum possible value of $\mid S\mid$.",2027091,Combinatorics,Combinatorial Geometry,Iran TST 2012 -imo-bench-combinatorics-036,"Let $P$ be a regular $199$-gon. Assign integers between $1$ and $199$ to the vertices of $P$ such that each integer appears exactly once (If two assignments coincide under rotation, treat them as the same). An operation is a swap of the integers assigned to a pair of adjacent vertices of $P$. Find the smallest integer $n$ such that one can achieve every other assignment from a given one with no more than $n$ operations.",9801,Combinatorics,Operations,China MO 2024 +Find the maximum possible value of $\mid S\mid$.",2027091,Combinatorics,IMO-Hard,Combinatorial Geometry,Iran TST 2012 +imo-bench-combinatorics-036,"Let $P$ be a regular $199$-gon. Assign integers between $1$ and $199$ to the vertices of $P$ such that each integer appears exactly once (If two assignments coincide under rotation, treat them as the same). An operation is a swap of the integers assigned to a pair of adjacent vertices of $P$. Find the smallest integer $n$ such that one can achieve every other assignment from a given one with no more than $n$ operations.",9801,Combinatorics,IMO-Hard,Operations,China MO 2024 imo-bench-combinatorics-037,"Lê Bá Khánh Trình is a famous Vietnamese IMO contestant who won Vietnam's only Special Prize. He enjoys solving mathematics problems and dancing. As the IMO is coming soon, he is studying the following mathematical problem: A subset $S$ of $\{0, 1, 2, \ldots \}$ is called Bachata if $0 \in S$ and for each element $n \in S,$ the integers $n + 11$ and $n + 20$ belong to $S.$ Please determine the number of Bachata subsets of $\{0, 1, 2, \ldots \}.$ -",2731365,Combinatorics,Extremal Combinatorics,IMO Shortlist 2000 -imo-bench-combinatorics-038,"Let $A = (a_1, a_2, \ldots, a_{2025})$ be a sequence of positive integers. Let $m$ be the number of 3-element subsequences $(a_i,a_j,a_k)$ with $1 \leq i < j < k \leq 2025$, such that $a_j = a_i + 1$ and $a_k = a_j + 1$. Let $n$ be the number of 4-element subsequences $(a_i,a_j,a_k, a_l)$ with $1 \leq i < j < k < l \leq 2025$, such that $a_j = a_i + 1$, $a_k = a_j + 1$ and $a_l = a_k+1$. Considering all such sequences $A$, find the greatest value of $m$.",307546875,Combinatorics,Extremal Combinatorics,IMO Shortlist 2001 -imo-bench-combinatorics-039,"The unit squares of an $2025 \times 2025$ chessboard are coloured alternately black and white, with the four corners coloured black. An L-tromino is a shape consisting of three unit squares connected in the shape of the letter L. A mysterious alien spaceship has landed on Earth and the aliens have brought with them a variety of L-trominos of various sizes and orientations. Is it possible to cover all the black squares with non-overlapping L-trominos? If it is possible, what is the minimum number of L-trominos needed?",1026169,Combinatorics,Tiling,IMO Shortlist 2002 -imo-bench-combinatorics-040,"A sequence of $15$ positive integers (not necessarily distinct) is called kawaii if it satisfies the following condition: for each positive integer $k\geq2$, if the number $k$ appears in the sequence then so does the number $k-1$, and moreover the first occurrence of $k-1$ comes before the last occurrence of $k$. Suppose there is a set $S$ of distinct integers, with $|S| = 16$. How many kawaii sequences are there?",1307674368000,Combinatorics,Enumerative Combinatorics,IMO Shortlist 2002 -imo-bench-combinatorics-041,"Two players, Ivan and Maria, are playing a guessing game. Ivan chooses three integers $x, y, z$ such that $0 \le x, y, z \le 9$. Maria tries to guess these integers by asking Ivan questions. In each question, Maria gives Ivan three integers $a, b, c$ such that $0 \le a, b, c \le 9$. Ivan then calculates and tells Maria the value of $|x+y-a-b| + |y+z-b-c| + |z+x-c-a|$. What is the minimum number of questions Maria needs to ask to be sure of determining Ivan's three integers?",3,Combinatorics,Extremal Combinatorics,IMO Shortlist 2002 -imo-bench-combinatorics-042,"In a social network with 120 users, some pairs of users are connected as friends. A weak quartet is a group of four users where exactly one pair is friends. What is the maximum possible number of weak quartets in this network?",4769280,Combinatorics,Graph Theory,IMO Shortlist 2002 -imo-bench-combinatorics-043,"There are 579 students at a prestigious Korean university known as KAIST. Some students come together to form numerous study groups (a student may belong to different study groups). Some study groups join together to form several research labs (a study group may belong to different research labs). There are a total of $k$ research labs. Suppose that the following conditions hold: (i) Each pair of students are in exactly one study group. (ii) For each student and each research lab, the student is in exactly one study group of the research lab. (iii) Each study group has an odd number of students. In addition, a study group with $2m + 1$ students ($m$ is a positive integer) is in exactly $m$ research labs. Find all possible values of $k$.",289,Combinatorics,Existence Combinatorics,IMO Shortlist 2004 -imo-bench-combinatorics-044,"Consider a matrix of size $230 \times 230$ whose entries are real numbers of absolute value not exceeding 1, and the sum of all entries is 0. Let $m$ be an odd positive integer. Determine the least number $C$ such that every such matrix necessarily has a row or a column with the sum of its entries not exceeding $C$ in absolute value.",115,Combinatorics,Extremal Combinatorics,IMO Shortlist 2004 +",2731365,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2000 +imo-bench-combinatorics-038,"Let $A = (a_1, a_2, \ldots, a_{2025})$ be a sequence of positive integers. Let $m$ be the number of 3-element subsequences $(a_i,a_j,a_k)$ with $1 \leq i < j < k \leq 2025$, such that $a_j = a_i + 1$ and $a_k = a_j + 1$. Let $n$ be the number of 4-element subsequences $(a_i,a_j,a_k, a_l)$ with $1 \leq i < j < k < l \leq 2025$, such that $a_j = a_i + 1$, $a_k = a_j + 1$ and $a_l = a_k+1$. Considering all such sequences $A$, find the greatest value of $m$.",307546875,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2001 +imo-bench-combinatorics-039,"The unit squares of an $2025 \times 2025$ chessboard are coloured alternately black and white, with the four corners coloured black. An L-tromino is a shape consisting of three unit squares connected in the shape of the letter L. A mysterious alien spaceship has landed on Earth and the aliens have brought with them a variety of L-trominos of various sizes and orientations. Is it possible to cover all the black squares with non-overlapping L-trominos? If it is possible, what is the minimum number of L-trominos needed?",1026169,Combinatorics,IMO-Medium,Tiling,IMO Shortlist 2002 +imo-bench-combinatorics-040,"A sequence of $15$ positive integers (not necessarily distinct) is called kawaii if it satisfies the following condition: for each positive integer $k\geq2$, if the number $k$ appears in the sequence then so does the number $k-1$, and moreover the first occurrence of $k-1$ comes before the last occurrence of $k$. Suppose there is a set $S$ of distinct integers, with $|S| = 16$. How many kawaii sequences are there?",1307674368000,Combinatorics,IMO-Medium,Enumerative Combinatorics,IMO Shortlist 2002 +imo-bench-combinatorics-041,"Two players, Ivan and Maria, are playing a guessing game. Ivan chooses three integers $x, y, z$ such that $0 \le x, y, z \le 9$. Maria tries to guess these integers by asking Ivan questions. In each question, Maria gives Ivan three integers $a, b, c$ such that $0 \le a, b, c \le 9$. Ivan then calculates and tells Maria the value of $|x+y-a-b| + |y+z-b-c| + |z+x-c-a|$. What is the minimum number of questions Maria needs to ask to be sure of determining Ivan's three integers?",3,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2002 +imo-bench-combinatorics-042,"In a social network with 120 users, some pairs of users are connected as friends. A weak quartet is a group of four users where exactly one pair is friends. What is the maximum possible number of weak quartets in this network?",4769280,Combinatorics,IMO-Medium,Graph Theory,IMO Shortlist 2002 +imo-bench-combinatorics-043,"There are 579 students at a prestigious Korean university known as KAIST. Some students come together to form numerous study groups (a student may belong to different study groups). Some study groups join together to form several research labs (a study group may belong to different research labs). There are a total of $k$ research labs. Suppose that the following conditions hold: (i) Each pair of students are in exactly one study group. (ii) For each student and each research lab, the student is in exactly one study group of the research lab. (iii) Each study group has an odd number of students. In addition, a study group with $2m + 1$ students ($m$ is a positive integer) is in exactly $m$ research labs. Find all possible values of $k$.",289,Combinatorics,IMO-Medium,Existence Combinatorics,IMO Shortlist 2004 +imo-bench-combinatorics-044,"Consider a matrix of size $230 \times 230$ whose entries are real numbers of absolute value not exceeding 1, and the sum of all entries is 0. Let $m$ be an odd positive integer. Determine the least number $C$ such that every such matrix necessarily has a row or a column with the sum of its entries not exceeding $C$ in absolute value.",115,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2004 imo-bench-combinatorics-045,"Two players $A$ and $B$ are playing a game by taking turns writing numbers from the set $\{1, \dots, N\}$ on a blackboard, where $N$ is a positive integer. Player $A$ starts the game by writing the number $1$. If a player writes the number $n$, then the other player can write either $n+1$ or $2n$, provided the number does not exceed $N$. The player who writes the number $N$ wins. We say that $N$ is of type $A$ if player $A$ has a winning strategy, and of type $B$ if player $B$ has a winning strategy. The game board is made of a special type of wood imported from Brazil. -Find the least $N > 400$ such that it is a type B number.",512,Combinatorics,Game Theory,IMO Shortlist 2004 -imo-bench-combinatorics-046,"The Bank of Hanoi issues $n$ different types of coins, numbered from $1$ to $n$. A cashier arranges these coins in a $2004 \times 2004$ matrix. Let $X_i$ be the set of distinct coin types in row $i$, and $Y_j$ the set of distinct coin types in column $j$, for $1 \le i, j \le 2004$. The cashier's arrangement is considered ""harmonious"" if all $X_i$ and $Y_j$ are distinct sets. Find the least integer $n$ such that a harmonious arrangement is possible.",13,Combinatorics,Extremal Combinatorics,IMO Shortlist 2004 -imo-bench-combinatorics-047,"For a finite graph $G$, let $f(G)$ be the number of triangles and $g(G)$ the number of tetrahedra formed by edges of $G$. In addition, let $h(G)$ be the number of pentagons formed by edges of $G$. Find the least constant $c$ such that \[\frac{g(G)^3}{f(G)^4}\le c\] for every graph $G$.",$\frac{3}{32}$,Combinatorics,Graph Theory,IMO Shortlist 2004 -imo-bench-combinatorics-048,"Find the smallest positive integers $n$, for which the numbers in the set $S=\{1,2, \ldots, n\}$ can be colored red and blue, with the following condition being satisfied: the set $S \times S \times S$ contains exactly 2007 ordered triples $(x, y, z)$ such that (i) $x, y, z$ are of the same color and (ii) $x+y+z$ is divisible by $n$. Additionally, find all positive integers $m$ such that $m$ is a multiple of 3.",69,Combinatorics,Existence Combinatorics,IMO Shortlist 2007 +Find the least $N > 400$ such that it is a type B number.",512,Combinatorics,IMO-Medium,Game Theory,IMO Shortlist 2004 +imo-bench-combinatorics-046,"The Bank of Hanoi issues $n$ different types of coins, numbered from $1$ to $n$. A cashier arranges these coins in a $2004 \times 2004$ matrix. Let $X_i$ be the set of distinct coin types in row $i$, and $Y_j$ the set of distinct coin types in column $j$, for $1 \le i, j \le 2004$. The cashier's arrangement is considered ""harmonious"" if all $X_i$ and $Y_j$ are distinct sets. Find the least integer $n$ such that a harmonious arrangement is possible.",13,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2004 +imo-bench-combinatorics-047,"For a finite graph $G$, let $f(G)$ be the number of triangles and $g(G)$ the number of tetrahedra formed by edges of $G$. In addition, let $h(G)$ be the number of pentagons formed by edges of $G$. Find the least constant $c$ such that \[\frac{g(G)^3}{f(G)^4}\le c\] for every graph $G$.",$\frac{3}{32}$,Combinatorics,IMO-Medium,Graph Theory,IMO Shortlist 2004 +imo-bench-combinatorics-048,"Find the smallest positive integers $n$, for which the numbers in the set $S=\{1,2, \ldots, n\}$ can be colored red and blue, with the following condition being satisfied: the set $S \times S \times S$ contains exactly 2007 ordered triples $(x, y, z)$ such that (i) $x, y, z$ are of the same color and (ii) $x+y+z$ is divisible by $n$. Additionally, find all positive integers $m$ such that $m$ is a multiple of 3.",69,Combinatorics,IMO-Medium,Existence Combinatorics,IMO Shortlist 2007 imo-bench-combinatorics-049,"In a research lab, scientists are studying the spread of a newly discovered bacteria on a $64 \times 64$ square petri dish. The dish is divided into small square sections, each of which is a $1 \times 1$ square and is either infected (black) or sterile (white). Initially, there are exactly $k$ infected sections, and the rest are sterile. Scientists observe that the bacteria spread according to two specific growth rules: 1) If a $2 \times 2$ square section has exactly three infected sections, the last sterile section gets infected. 2) If a $2 \times 2$ square has exactly two infected sections, the infection mutates—infected sections become sterile, and sterile sections become infected. The researchers want to determine the smallest number of initially infected sections, $k$, such that no matter how the infection starts, it will always be possible to spread the bacteria to the entire dish after a sequence of growth and mutation cycles. -What is the smallest such $k$ that guarantees a full infection?",1057,Combinatorics,Operations,China TST 2023 -imo-bench-combinatorics-050,"At World Cup 2050, there are $256$ teams participating. The organizer gives each team a flag 8 units wide and one unit high composed of 8 fields of size $1 \times 1$, each field being either yellow or blue. No two countries have the same flag. We say that a set of 8 flags is diverse if these flags can be arranged into an $8 \times 8$ square so that all 8 fields on its main diagonal will have the same color. Determine the smallest positive integer $M$ such that among any $M$ distinct flags, there exist 8 flags forming a diverse set.",65,Combinatorics,Existence Combinatorics,IMO Shortlist 2010 +What is the smallest such $k$ that guarantees a full infection?",1057,Combinatorics,IMO-Hard,Operations,China TST 2023 +imo-bench-combinatorics-050,"At World Cup 2050, there are $256$ teams participating. The organizer gives each team a flag 8 units wide and one unit high composed of 8 fields of size $1 \times 1$, each field being either yellow or blue. No two countries have the same flag. We say that a set of 8 flags is diverse if these flags can be arranged into an $8 \times 8$ square so that all 8 fields on its main diagonal will have the same color. Determine the smallest positive integer $M$ such that among any $M$ distinct flags, there exist 8 flags forming a diverse set.",65,Combinatorics,IMO-Medium,Existence Combinatorics,IMO Shortlist 2010 imo-bench-combinatorics-051,"A conference hall is used for hosting events, and each event is assigned a specific time slot (represented as an interval that is a subset of $[0,1]$) within the full schedule from $0$ to $1$ (representing a day on a normalized scale). The hall manager designs a schedule (which is a set of intervals representing time slots) that follows these strict rules when booking events: \begin{itemize} @@ -606,8 +606,8 @@ imo-bench-combinatorics-051,"A conference hall is used for hosting events, and e Now, suppose two different event schedules (sets of booked events) are considered, called $\mathcal{A}$ and $\mathcal{B}$. For any event $I \in \mathcal{A}$ and event $J \in \mathcal{B}$, define $n(\mathcal{A}, \mathcal{B})$ as the number of overlapping event pairs $(I, J)$ such that $I \cap J \neq \emptyset$. -Determine the maximum possible value of $n(\mathcal{A}, \mathcal{B})$ over all valid schedules.",27648,Combinatorics,Extremal Combinatorics,Korean Final 2022 -imo-bench-combinatorics-052,"Let $k>0$ be an integer. We are given a balance and $k$ weights of weight $2^{0}, 2^{1}, \ldots, 2^{k-1}$. Additionally, we are given a set of $k$ stones with weights $3^0, 3^1, \ldots, 3^{k-1}$. In a sequence of $k$ moves we place all weights on the balance. In the first move we choose a weight and put it on the left pan. In each of the following moves we choose one of the remaining weights and we add it either to the left or to the right pan. Compute the number of ways in which we can perform these $k$ moves in such a way that the right pan is never heavier than the left pan.",$(2k-1)!!$,Combinatorics,Enumerative Combinatorics,IMO Shortlist 2011 +Determine the maximum possible value of $n(\mathcal{A}, \mathcal{B})$ over all valid schedules.",27648,Combinatorics,IMO-Medium,Extremal Combinatorics,Korean Final 2022 +imo-bench-combinatorics-052,"Let $k>0$ be an integer. We are given a balance and $k$ weights of weight $2^{0}, 2^{1}, \ldots, 2^{k-1}$. Additionally, we are given a set of $k$ stones with weights $3^0, 3^1, \ldots, 3^{k-1}$. In a sequence of $k$ moves we place all weights on the balance. In the first move we choose a weight and put it on the left pan. In each of the following moves we choose one of the remaining weights and we add it either to the left or to the right pan. Compute the number of ways in which we can perform these $k$ moves in such a way that the right pan is never heavier than the left pan.",$(2k-1)!!$,Combinatorics,IMO-Medium,Enumerative Combinatorics,IMO Shortlist 2011 imo-bench-combinatorics-053,"In the mystical land of Azeroth, an ancient ritual requires the Sky Guardians to form sacred constellations using $n$ magical stars scattered randomly in the sky. These stars are carefully positioned such that no three of them lie in a straight line. Each star is imbued with either red or blue energy, assigned randomly by the celestial forces. The Guardians must form triangular constellations using these stars as vertices, following a strict rule: @@ -616,26 +616,26 @@ Each star is imbued with either red or blue energy, assigned randomly by the cel The prophecy foretells that once a sufficient number of stars are used, it will inevitably result in at least two constellations where all three stars share the same color. -What is the smallest number of stars, n, required to guarantee that at least two monochromatic triangular constellations (all-red or all-blue triangular constellations) must exist in the final celestial pattern?",8,Combinatorics,Combinatorial Geometry,China TST 2007 +What is the smallest number of stars, n, required to guarantee that at least two monochromatic triangular constellations (all-red or all-blue triangular constellations) must exist in the final celestial pattern?",8,Combinatorics,IMO-Hard,Combinatorial Geometry,China TST 2007 imo-bench-combinatorics-054,"Consider a checkerboard consisting of $38$ by $38$ unit squares. At the midpoints of some of these unit squares, there is an ant. At time 0, each ant starts moving with speed 1 parallel to some edge of the checkerboard. When two ants moving in opposite directions meet, they both turn $90^{\circ}$ clockwise and continue moving with speed 1. When more than two ants meet, or when two ants moving in perpendicular directions meet, the ants continue moving in the same direction as before they met. When an ant reaches one of the edges of the checkerboard, it falls off and will not re-appear. Also, there are some spiders on the checkerboard that do not move at all. -Considering all possible starting positions, determine the latest possible moment at which the last ant falls off the checkerboard or prove that such a moment does not necessarily exist.",56,Combinatorics,Operations,IMO Shortlist 2011 -imo-bench-combinatorics-055,"On a large chessboard of 2011 by 2011 squares, a finite number of square tiles are placed. Each tile covers a square area of 52 by 52 cells. In each cell, the number of tiles covering it is written, and the maximum number $k$ of cells containing the same nonzero number is recorded. Considering all possible tile configurations, what is the largest possible value of $k$?",3986729,Combinatorics,Extremal Combinatorics,IMO Shortlist 2011 -imo-bench-combinatorics-056,"A teacher wants to divide a class of $d$ students into $k$ groups (some of which may be empty). Each student $i$ has a score $a_i$ between 0 and 1, inclusive, and the sum of the scores of all students is $59$. The teacher wants to partition the students into groups such that the sum of the scores in each group is at most 1. Find the smallest integer $k$ such that this is always possible, regardless of the number of students $d$ and their scores $a_1, \ldots, a_d$.",117,Combinatorics,Set Combinatorics,IMO Shortlist 2013 +Considering all possible starting positions, determine the latest possible moment at which the last ant falls off the checkerboard or prove that such a moment does not necessarily exist.",56,Combinatorics,IMO-Medium,Operations,IMO Shortlist 2011 +imo-bench-combinatorics-055,"On a large chessboard of 2011 by 2011 squares, a finite number of square tiles are placed. Each tile covers a square area of 52 by 52 cells. In each cell, the number of tiles covering it is written, and the maximum number $k$ of cells containing the same nonzero number is recorded. Considering all possible tile configurations, what is the largest possible value of $k$?",3986729,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2011 +imo-bench-combinatorics-056,"A teacher wants to divide a class of $d$ students into $k$ groups (some of which may be empty). Each student $i$ has a score $a_i$ between 0 and 1, inclusive, and the sum of the scores of all students is $59$. The teacher wants to partition the students into groups such that the sum of the scores in each group is at most 1. Find the smallest integer $k$ such that this is always possible, regardless of the number of students $d$ and their scores $a_1, \ldots, a_d$.",117,Combinatorics,IMO-Medium,Set Combinatorics,IMO Shortlist 2013 imo-bench-combinatorics-057,"In the plane, 2025 red points and 2026 blue points are marked so that no three of the marked points are collinear. One needs to draw $k$ lines not passing through the marked points and dividing the plane into several regions. The goal is to do it in such a way that no region contains points of both colors. -Find the minimal value of $k$ such that the goal is attainable for every possible configuration of 4051 points.",2025,Combinatorics,Combinatorial Geometry,IMO Shortlist 2013 -imo-bench-combinatorics-058,"Consider an $n \times n$ chessboard consisting of $n^2$ unit squares, where $n \geqslant 2$ is an integer. A configuration of $n$ rooks on this board is called balanced if each row and each column contains exactly one rook. Find the largest positive integer $k$ such that for any balanced configuration of rooks, there exists a $k \times k$ square with no rook in any of its $k^2$ unit squares. Additionally, consider a $2n \times 2n$ go board, where we put go pieces on that board.",$\lfloor\sqrt{n-1}\rfloor$,Combinatorics,Tiling,IMO Shortlist 2014 +Find the minimal value of $k$ such that the goal is attainable for every possible configuration of 4051 points.",2025,Combinatorics,IMO-Medium,Combinatorial Geometry,IMO Shortlist 2013 +imo-bench-combinatorics-058,"Consider an $n \times n$ chessboard consisting of $n^2$ unit squares, where $n \geqslant 2$ is an integer. A configuration of $n$ rooks on this board is called balanced if each row and each column contains exactly one rook. Find the largest positive integer $k$ such that for any balanced configuration of rooks, there exists a $k \times k$ square with no rook in any of its $k^2$ unit squares. Additionally, consider a $2n \times 2n$ go board, where we put go pieces on that board.",$\lfloor\sqrt{n-1}\rfloor$,Combinatorics,IMO-Medium,Tiling,IMO Shortlist 2014 imo-bench-combinatorics-059,"A card deck consists of 1024 cards. On each card, a set of distinct decimal digits is written in such a way that no two of these sets coincide, including an empty card. Two players alternately take cards from the deck, one card per turn. After the deck is empty, each player checks if he can throw out one of his cards so that each of the ten digits occurs on an even number of his remaining cards. If one player can do this but the other one cannot, the one who can is the winner; otherwise, a draw is declared. However, there is also a third player who is observing the game and has a special card with a set of distinct decimal digits written on it. This third player does not participate in the game. -Determine all possible first moves of the first player after which the opponent has a winning strategy.",taking the empty card,Combinatorics,Game Theory,IMO Shortlist 2014 -imo-bench-combinatorics-060,"Let $t_0,t_1,\ldots ,t_{86}$ be integers satisfying $0=t_02k$, and shares them with the deputy leader and a contestant. The leader then secretly reveals an $n$-digit binary string to the deputy leader, who writes down all $n$-digit binary strings that differ from the leader's string in exactly $k$ positions. The contestant is allowed to examine the strings written by the deputy leader and attempt to guess the leader's string. What is the minimum number of guesses (in terms of $n$ and $k$) required to guarantee a correct answer?",1,Combinatorics,Game Theory,IMO Shortlist 2016 +Alice takes the first turn. Find the largest value of $n$ such that the game ends in a draw.",6,Combinatorics,IMO-Medium,Game Theory,IMO Shortlist 2015 +imo-bench-combinatorics-063,"The leader of a Vietnamese Olympiad team selects positive integers $n$ and $k$ with $n>2k$, and shares them with the deputy leader and a contestant. The leader then secretly reveals an $n$-digit binary string to the deputy leader, who writes down all $n$-digit binary strings that differ from the leader's string in exactly $k$ positions. The contestant is allowed to examine the strings written by the deputy leader and attempt to guess the leader's string. What is the minimum number of guesses (in terms of $n$ and $k$) required to guarantee a correct answer?",1,Combinatorics,IMO-Medium,Game Theory,IMO Shortlist 2016 imo-bench-combinatorics-064,"Find all positive integers $n$ for which all positive divisors of $n$ can be put into the cells of a rectangular table under the following constraints: \begin{itemize} @@ -653,7 +653,7 @@ imo-bench-combinatorics-064,"Find all positive integers $n$ for which all positi \item the sums of all rows are equal; \item the sums of all columns are equal; and \item the number of rows is a prime number. -\end{itemize}",No positive integers,Combinatorics,Existence Combinatorics,IMO Shortlist 2016 +\end{itemize}",No positive integers,Combinatorics,IMO-Medium,Existence Combinatorics,IMO Shortlist 2016 imo-bench-combinatorics-065,"Find the largest positive integers $n$ that is no more than $2000$ for which we can fill in the entries of an $n \times n$ table with the following properties: \begin{itemize} @@ -662,24 +662,24 @@ imo-bench-combinatorics-065,"Find the largest positive integers $n$ that is no m \item in any diagonal whose number of entries is a multiple of three, the letters $I, M$ and $O$ occur the same number of times. \item the letter P does not appear on any entry at all \item $n$ is divisible by $13$. -\end{itemize}",1989,Combinatorics,Existence Combinatorics,IMO Shortlist 2016 -imo-bench-combinatorics-066,A set of diagonals of a regular $109$-gon is called good if any two diagonals in the set either do not intersect in the interior or are perpendicular. Find the maximum possible size of a good set.,106,Combinatorics,Combinatorial Geometry,IMO Shortlist 2016 -imo-bench-combinatorics-067,"Suppose we have a $194 \times 194$ board and we want to mark some cells on this board. Determine the smallest positive integer $k$ such that it is possible to mark $k$ cells on the board in a way that there exists a unique partition of the board into $1 \times 2$ and $2 \times 1$ dominoes, where none of the dominoes contains two marked cells.",194,Combinatorics,Extremal Combinatorics,IMO Shortlist 2016 +\end{itemize}",1989,Combinatorics,IMO-Medium,Existence Combinatorics,IMO Shortlist 2016 +imo-bench-combinatorics-066,A set of diagonals of a regular $109$-gon is called good if any two diagonals in the set either do not intersect in the interior or are perpendicular. Find the maximum possible size of a good set.,106,Combinatorics,IMO-Medium,Combinatorial Geometry,IMO Shortlist 2016 +imo-bench-combinatorics-067,"Suppose we have a $194 \times 194$ board and we want to mark some cells on this board. Determine the smallest positive integer $k$ such that it is possible to mark $k$ cells on the board in a way that there exists a unique partition of the board into $1 \times 2$ and $2 \times 1$ dominoes, where none of the dominoes contains two marked cells.",194,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2016 imo-bench-combinatorics-068,"Sir Alex plays the following game on a row of 9 cells. Initially, all cells are empty. In each move, Sir Alex is allowed to perform exactly one of the following two operations: (1) Choose any number of the form $2^{j}$, where $j$ is a non-negative integer, and put it into an empty cell. (2) Choose two (not necessarily adjacent) cells with the same number in them; denote that number by $2^{j}$. Replace the number in one of the cells with $2^{j+1}$ and erase the number in the other cell. -During the game, Sir Alex encounters a mysterious genie that grants him a wish. However, the genie warns Sir Alex that he can only make a limited number of moves. At the end of the game, one cell contains the number $2^40$, while the other cells are empty. Determine the maximum number of moves that Sir Alex could have made.",200293447,Combinatorics,Operations,IMO Shortlist 2017 -imo-bench-combinatorics-069,"A large $45 \times 45 \times 45$ cube is composed of $45^3$ smaller unit cubes. Each unit cube is painted with one color. For each $45 \times 45 \times 1$ rectangular prism consisting of $n^{2}$ unit cubes (of any of the three possible orientations), we consider the set of distinct colors present in that prism. A mischievous gnome, known for rearranging things, has decided to play a prank. He rearranges the colors of the unit cubes such that the set of colors in any $45 \times 45 \times 1$ prism in one orientation appears in an $45 \times 45 \times 1$ prism in each of the other two orientations. Determine the maximal possible number of colors that are present in the large cube after the gnome's antics.",31395,Combinatorics,Extremal Combinatorics,IMO Shortlist 2017 +During the game, Sir Alex encounters a mysterious genie that grants him a wish. However, the genie warns Sir Alex that he can only make a limited number of moves. At the end of the game, one cell contains the number $2^40$, while the other cells are empty. Determine the maximum number of moves that Sir Alex could have made.",200293447,Combinatorics,IMO-Medium,Operations,IMO Shortlist 2017 +imo-bench-combinatorics-069,"A large $45 \times 45 \times 45$ cube is composed of $45^3$ smaller unit cubes. Each unit cube is painted with one color. For each $45 \times 45 \times 1$ rectangular prism consisting of $n^{2}$ unit cubes (of any of the three possible orientations), we consider the set of distinct colors present in that prism. A mischievous gnome, known for rearranging things, has decided to play a prank. He rearranges the colors of the unit cubes such that the set of colors in any $45 \times 45 \times 1$ prism in one orientation appears in an $45 \times 45 \times 1$ prism in each of the other two orientations. Determine the maximal possible number of colors that are present in the large cube after the gnome's antics.",31395,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2017 imo-bench-combinatorics-070,"Queenie and Horst play a game on a $40 \times 60$ chessboard with some strange rules. In the beginning the board is empty. In every turn, Horst places a black knight on an empty square in such a way that his new knight does not attack any previous knights. The knight can jump in an L-shape, i.e., two squares in one direction and one square in a perpendicular direction. Then Queenie places a white queen on an empty square. The queen can move any number of squares in a straight line horizontally, vertically, or diagonally. The game gets finished when somebody cannot move. The players are also allowed to play randomly as long as the rules are followed. -Find the maximal positive $K$ such that, regardless of the strategy of Queenie, Horst can put at least $K$ knights on the board.",600,Combinatorics,Extremal Combinatorics,IMO Shortlist 2018 -imo-bench-combinatorics-071,"A sports tournament is being organized for $256$ players. Every pair of players must play exactly one match against each other. The tournament is scheduled such that each day only one match is played. Each player arrives on the day of their first match and departs on the day of their last match. For each day a player is present at the tournament, the organizers must pay 1 coin to the hotel. The organizers want to minimize the total cost of all players' stays by designing an optimal schedule. Additionally, there is a VIP lounge where special guests can watch the matches for free. The VIP lounge has limited capacity and can only accommodate a maximum of 10 people at any given time. However, the presence of the VIP lounge and the special guests does not affect the scheduling of the matches or the total cost of the players' stays. Determine the minimum total cost the organizers must pay for all players' hotel stays.",4202432,Combinatorics,Extremal Combinatorics,IMO Shortlist 2018 +Find the maximal positive $K$ such that, regardless of the strategy of Queenie, Horst can put at least $K$ knights on the board.",600,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2018 +imo-bench-combinatorics-071,"A sports tournament is being organized for $256$ players. Every pair of players must play exactly one match against each other. The tournament is scheduled such that each day only one match is played. Each player arrives on the day of their first match and departs on the day of their last match. For each day a player is present at the tournament, the organizers must pay 1 coin to the hotel. The organizers want to minimize the total cost of all players' stays by designing an optimal schedule. Additionally, there is a VIP lounge where special guests can watch the matches for free. The VIP lounge has limited capacity and can only accommodate a maximum of 10 people at any given time. However, the presence of the VIP lounge and the special guests does not affect the scheduling of the matches or the total cost of the players' stays. Determine the minimum total cost the organizers must pay for all players' hotel stays.",4202432,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2018 imo-bench-combinatorics-072,"A group of students are playing a coin-flipping game. They have 64 coins lined up on a table, each showing either heads or tails. They take turns performing the following operation: if there are $k$ coins showing heads and $k>0$, then they flip the $k^{\text {th }}$ coin over; otherwise, they stop the game. For example, if they start with the configuration $T H T$, the game would proceed as follows: $T H T \rightarrow H H T \rightarrow H T T \rightarrow T T T$, which takes three turns. They define a strange mathematical function $f(x)= 2x+10$ to add irrelevance to the problem. -Letting $C$ denote the initial configuration (a sequence of 64 H's and T's), write $\ell(C)$ for the number of turns needed before all coins show T. Show that this number $\ell(C)$ is finite, and determine its average value over all $2^{64}$ possible initial configurations $C$.",1040,Combinatorics,Operations,IMO Shortlist 2019 +Letting $C$ denote the initial configuration (a sequence of 64 H's and T's), write $\ell(C)$ for the number of turns needed before all coins show T. Show that this number $\ell(C)$ is finite, and determine its average value over all $2^{64}$ possible initial configurations $C$.",1040,Combinatorics,IMO-Medium,Operations,IMO Shortlist 2019 imo-bench-combinatorics-073,"In a grand theater, there are $40000$ seats arranged into $200$ rows, each row has $200$ seats to form a $200 \times 200$ seating arrangement. Out of these seats, some seats are reserved and others remain available. The theater organizers want to assign reserved seats following these two strict conditions: 1) No two reserved seats can be in rows that have the same number of reserved seats while also being in columns that have the same number of reserved seats. @@ -687,7 +687,7 @@ imo-bench-combinatorics-073,"In a grand theater, there are $40000$ seats arrange What is the largest possible value of $m$ for which such a seating assignment can be created? -",96,Combinatorics,Extremal Combinatorics,China TST 2023 +",96,Combinatorics,IMO-Hard,Extremal Combinatorics,China TST 2023 imo-bench-combinatorics-074,"There are 100 empty boxes $B_{1}, \ldots, B_{100}$ in a row on a table and an unlimited supply of pebbles. Given a positive integer $n$, Alice and Bob play the following game. In the first round, Alice takes $n$ pebbles and distributes them into the 100 boxes as she wishes. Each subsequent round consists of two steps: @@ -696,33 +696,33 @@ In the first round, Alice takes $n$ pebbles and distributes them into the 100 bo (b) Alice picks one of these two groups, adds one pebble to each box in that group, and removes one pebble from each box in the other group. -Bob wins if, at the end of any round, some box contains no pebbles. Find the smallest $n$ such that Alice can prevent Bob from winning.",2600,Combinatorics,Game Theory,IMO Shortlist 2019 +Bob wins if, at the end of any round, some box contains no pebbles. Find the smallest $n$ such that Alice can prevent Bob from winning.",2600,Combinatorics,IMO-Medium,Game Theory,IMO Shortlist 2019 imo-bench-combinatorics-075,"In a crowded marketplace, $7396$ stalls are arranged in a straight line, numbered from 1 to $7396$. Each of two merchants, Ali and Baba, sells $k$ distinct items numbered from 1 to $k$; each item is sold at a lower-numbered stall and bought at a higher-numbered stall. For each merchant, and for any $i$ and $j$ with $1 \leqslant i m$. -Prove that there are only finitely many positive integers which are not colorful. Find the largest among them.",9701,Combinatorics,Extremal Combinatorics,IMO Shortlist 2021 +Prove that there are only finitely many positive integers which are not colorful. Find the largest among them.",9701,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2021 imo-bench-combinatorics-079,"Determine the largest $N$ for which there exists a table $T$ of integers with $N$ rows and 16 columns that has the following properties: (i) Every row contains the numbers $1,2, \ldots, 16$ in some order. (ii) For any two distinct rows $r$ and $s$, there is a column $c$ such that $|T(r, c)-T(s, c)| \geqslant 2$. In addition to the given constraints, every column in the table must contain distinct integers. -Here $T(r, c)$ means the number at the intersection of the row $r$ and the column $c$.",81729648000,Combinatorics,Extremal Combinatorics,IMO Shortlist 2021 +Here $T(r, c)$ means the number at the intersection of the row $r$ and the column $c$.",81729648000,Combinatorics,IMO-Medium,Extremal Combinatorics,IMO Shortlist 2021 imo-bench-combinatorics-080,"A $\pm 1$-sequence is a sequence of 2022 numbers $a_{1}, \ldots, a_{2022}$, each equal to either +1 or -1. Additionally, there is a sequence of 3000 numbers $b_{1}, \ldots, b_{3000}$, each equal to either 0 or 2. Determine the largest $C$ so that, for any $\pm 1$-sequence, there exists an integer $k$ and indices $1 \leqslant t_{1}<\ldotsf\left(x_{2}, y_{2}\right)$, we have $f\left(x_{1}+1, y_{1}\right)>f\left(x_{2}+1, y_{2}\right)$ and $f\left(x_{1}, y_{1}+1\right)>f\left(x_{2}, y_{2}+1\right)$. Also, let $g: \mathbb{Z}_{\geqslant 0} \rightarrow \mathbb{Z}_{\geqslant 0}$ be a function such that $g(n) = n^2 - n + 1$. -Let $N$ be the number of pairs of integers $(x, y)$, with $0 \leqslant x, y<100$, such that $f(x, y)$ is odd. Let the smallest and largest possible value of $N$ be $a,b$, find the product $ab$.",18750000,Combinatorics,Other,IMO Shortlist 2022 +Let $N$ be the number of pairs of integers $(x, y)$, with $0 \leqslant x, y<100$, such that $f(x, y)$ is odd. Let the smallest and largest possible value of $N$ be $a,b$, find the product $ab$.",18750000,Combinatorics,IMO-Medium,Other,IMO Shortlist 2022 imo-bench-combinatorics-087,"An and Bình are two Vietnamese high school students studied in the Math specialized class at Phổ Thông Năng Khiếu. As part of their Math Olympiad training, they play the following games to study combinatorics. A 0-1 sequence of length $4096$ is given. An can pick a member from the sequence, and reveal it (its place and its value) to Bình. Find the largest number $s$ for which Bình can always pick $s$ members of the sequence, and guess all their values correctly. -An and Bình can discuss a strategy before the game with the aim of maximizing the number of correct guesses of Bình. The only information Bình has is the length of the sequence and the member of the sequence picked by An.",13,Combinatorics,Game Theory,Komal +An and Bình can discuss a strategy before the game with the aim of maximizing the number of correct guesses of Bình. The only information Bình has is the length of the sequence and the member of the sequence picked by An.",13,Combinatorics,IMO-Medium,Game Theory,Komal imo-bench-combinatorics-088,"A simple graph G has 11 vertices. We label every edge of G the difference of the degrees of its endpoints. What can be the largest value of the sum of the labels on the edges? -",168,Combinatorics,Graph Theory,Komal +",168,Combinatorics,IMO-Medium,Graph Theory,Komal imo-bench-combinatorics-089,"We colored the $10000$ unit squares of an $100 \times 100$ square lattice such that in each $2\times 2$ square, at least two of the four unit squares have the same color. What is the largest number of colors we could have used? -",5099,Combinatorics,Extremal Combinatorics,Komal +",5099,Combinatorics,IMO-Medium,Extremal Combinatorics,Komal imo-bench-combinatorics-090,"A polyomino is a figure which consists of unit squares joined together by their sides. (A polyomino may contain holes.) Consider a grid of unit square cells which extends to infinity in all directions. Find the greatest positive integer $C$ which satisfies the following condition: For every colouring of the cells of the grid in $36$ colours, there is some polyomino within the grid which contains at most $35$ colours and whose area is at least $C$. -",2450,Combinatorics,Tiling,Komal +",2450,Combinatorics,IMO-Medium,Tiling,Komal imo-bench-combinatorics-091,"Let $n,s,$ and $t$ be positive integers and $0<\lambda<1.$ A simple graph on $n$ vertices with at least $\lambda n^2$ edges is given. We say that $(x_1,\ldots,x_s,y_1,\ldots,y_t)$ is a good intersection if letters $x_i$ and $y_j$ denote not necessarily distinct vertices and every $x_iy_j$ is an edge of the graph $(1\leq i\leq s,$ $1\leq j\leq t).$ Find the minimum number of good insertions. -",$\lambda^{st}n^{s+t}$,Combinatorics,Graph Theory,Komal +",$\lambda^{st}n^{s+t}$,Combinatorics,IMO-Medium,Graph Theory,Komal imo-bench-combinatorics-092,"For an arbitrary positive integer $m$, not divisible by $3$, consider the permutation $x \mapsto 3x \pmod{m}$ on the set $\{ 1,2,\dotsc ,m-1\}$. This permutation can be decomposed into disjointed cycles; for instance, for $m=10$ the cycles are $(1\mapsto 3\to 9,\mapsto 7,\mapsto 1)$, $(2\mapsto 6\mapsto 8\mapsto 4\mapsto 2)$ and $(5\mapsto 5)$. Find the second largest integer $m < 200$ such that the number of cycles odd? -",197,Combinatorics,Graph Theory,Komal +",197,Combinatorics,IMO-Medium,Graph Theory,Komal imo-bench-combinatorics-093,"Let $s$ be positive integers such that $s<5625$. Initially, one cell out of an $n \times n$ grid is coloured green. On each turn, we pick some green cell $c$ and colour green some $s$ out of the $5625$ cells in the $75 \times 75$ square centred at $c$. No cell may be coloured green twice. We say that $s$ is sparse if there exists some positive number $C$ such that, for every positive integer $n$, the total number of green cells after any number of turns is always going to be at most $Cn$. Find the least sparse integer $s$. -",4181,Combinatorics,Extremal Combinatorics,Komal +",4181,Combinatorics,IMO-Medium,Extremal Combinatorics,Komal imo-bench-combinatorics-094,"Bart, Lisa and Maggie play the following game: Bart colors finitely many points red or blue on a circle such that no four colored points can be chosen on the circle such that their colors are blue-red-blue-red (the four points do not have to be consecutive). Lisa chooses finitely many of the colored points. Now Bart gives the circle (possibly rotated) to Maggie with Lisa's chosen points, however, without their colors. Finally, Maggie colors all the points of the circle to red or blue. Lisa and Maggie wins the game, if Maggie correctly guessed the colors of Bart's points. A strategy of Lisa and Maggie is called a winning strategy, if they can win the game for all possible colorings by Bart. Prove that Lisa and Maggie have a winning strategy, where Lisa chooses at most $c$ points in all possible cases, and find the smallest possible value of $c$. -",3,Combinatorics,Game Theory,Komal -imo-bench-combinatorics-095,"In a dance party initially there are $24$ girls and $26$ boys in the pool and infinitely many more girls and boys waiting outside. In each round, a participant is picked uniformly at random; if a girl is picked, then she invites a boy from the pool to dance and then both of them elave the party after the dance; while if a boy is picked, then he invites a girl and a boy from the waiting line and dance together. The three of them all stay after the dance. The party is over when there are only (two) boys left in the pool. What is the probability that the party never ends?",$\frac{24}{25}$,Combinatorics,Enumerative Combinatorics,Alibaba Math Competition 2021 +",3,Combinatorics,IMO-Medium,Game Theory,Komal +imo-bench-combinatorics-095,"In a dance party initially there are $24$ girls and $26$ boys in the pool and infinitely many more girls and boys waiting outside. In each round, a participant is picked uniformly at random; if a girl is picked, then she invites a boy from the pool to dance and then both of them elave the party after the dance; while if a boy is picked, then he invites a girl and a boy from the waiting line and dance together. The three of them all stay after the dance. The party is over when there are only (two) boys left in the pool. What is the probability that the party never ends?",$\frac{24}{25}$,Combinatorics,IMO-Medium,Enumerative Combinatorics,Alibaba Math Competition 2021 imo-bench-combinatorics-096,"In the kingdom of Graphlandia, there are $1875$ towns spread across the land. These towns are connected by roads, but the road network follows strict rules: (i) No two towns are directly connected by more than one road, and no town has a road leading back to itself. @@ -794,230 +794,230 @@ imo-bench-combinatorics-096,"In the kingdom of Graphlandia, there are $1875$ tow (iii) At least one town is very isolated, having only one road leading to it. Despite this, the kingdom is well connected—any two towns can be reached from each other by traveling on at most three roads. -The royal engineers want to design the road network as efficiently as possible while satisfying all these conditions. What is the minimum number of roads that must be built to ensure the network remains functional under these constraints?",2150,Combinatorics,Graph Theory,China TST 2011 +The royal engineers want to design the road network as efficiently as possible while satisfying all these conditions. What is the minimum number of roads that must be built to ensure the network remains functional under these constraints?",2150,Combinatorics,IMO-Hard,Graph Theory,China TST 2011 imo-bench-combinatorics-097,"In a circular seating arrangement at a party, there are $16$ guests sitting at the table play a game. Each guest has a unique name tag crated by the game master, and then these name tags are randomly distributed among the guests. In each of the next $n$ rounds, the guests plays the game according to the following rule: i) Any guest who has their own name tag exits the table. ii) The remaining guests pass their name tags to the guest sitting immediately to their right. -We are interested in finding the number of ways the name tags can be distributed such that there exists at least one guest who does not leave the table after 4 rounds.",85383238549,Combinatorics,Enumerative Combinatorics,Korean Final 2014 -imo-bench-combinatorics-098,Let $P_n$ be a path on $n$ vertices and let $\lambda$ be a positive real number. Define $Z_{P_n}(\lambda) = \sum_{I \in S} \lambda^{|I|}$ where $\cI(P_n)$ is the set of independent set of $P_n$. Compute $z_{15}$ in terms of $\lambda$.,$\lambda^8 + 36\lambda^7 + 210\lambda^6 + 462\lambda^5 + 495\lambda^4 + 286\lambda^3 + 91\lambda^2 + 15\lambda + 1$,Combinatorics,Enumerative Combinatorics,Statistical Mechanics method for Combinatorics +We are interested in finding the number of ways the name tags can be distributed such that there exists at least one guest who does not leave the table after 4 rounds.",85383238549,Combinatorics,IMO-Medium,Enumerative Combinatorics,Korean Final 2014 +imo-bench-combinatorics-098,Let $P_n$ be a path on $n$ vertices and let $\lambda$ be a positive real number. Define $Z_{P_n}(\lambda) = \sum_{I \in S} \lambda^{|I|}$ where $\cI(P_n)$ is the set of independent set of $P_n$. Compute $z_{15}$ in terms of $\lambda$.,$\lambda^8 + 36\lambda^7 + 210\lambda^6 + 462\lambda^5 + 495\lambda^4 + 286\lambda^3 + 91\lambda^2 + 15\lambda + 1$,Combinatorics,IMO-Medium,Enumerative Combinatorics,Statistical Mechanics method for Combinatorics imo-bench-combinatorics-099,"A $\textit{lattice point}$ of a Tango dance floor is a point $(x,y)$ in which both $x$ and $y$ are integers. Find the smallest positive integer $c$ such that every lattice point of the dance floor can be colored with one of $c$ colors, such that the following two conditions hold: If $(x,y)$ and $(a,b)$ are two distinct neighboring points; that is, $|x-a|\leq1$ and $|y-b|\leq1$, then $(x,y)$ and $(a,b)$ must be different colors. -If $(x,y)$ and $(a,b)$ are two lattice points such that $x\equiv a\pmod{2025}$ and $y\equiv b\pmod{2025}$, then $(x,y)$ and $(a,b)$ must be the same color.",5,Combinatorics,Graph Theory,USAMTS 2022 +If $(x,y)$ and $(a,b)$ are two lattice points such that $x\equiv a\pmod{2025}$ and $y\equiv b\pmod{2025}$, then $(x,y)$ and $(a,b)$ must be the same color.",5,Combinatorics,pre-IMO,Graph Theory,USAMTS 2022 imo-bench-combinatorics-100,"Grogg and Winnie are playing a game using a deck of $50$ cards numbered $1$ through $50$. They take turns with Grogg going first. On each turn a player chooses a card from the deck—this choice is made deliberately, not at random—and then adds it to one of two piles (both piles are empty at the start of the game). After all $50$ cards are in the two piles, the values of the cards in each pile are summed, and Winnie wins the positive difference of the sums of the two piles, in dollars. (For instance, if the first pile has cards summing to $510$ and the second pile has cards summing to $765$, then Winnie wins $ \$255$.) Winnie wants to win as much as possible, and Grogg wants Winnie to win as little as possible. If they both play with perfect strategy, find (with proof) the amount that Winnie wins. -",75,Combinatorics,Game Theory,USAMTS 2022 +",75,Combinatorics,pre-IMO,Game Theory,USAMTS 2022 imo-bench-geometry-001,"Let $h$ be the smallest height of a triangular pyramid, and let $d$ be the shortest distance between its opposite edges. Let $S$ be the set of values of $t$ such that the inequality $d > th$ is possible. Find the supremum of $S$. -",$\frac{3}{2}$,Geometry,3d_geometry,Sharygin 2008 +",$\frac{3}{2}$,Geometry,IMO-Medium,3d_geometry,Sharygin 2008 imo-bench-geometry-002,"Given right triangle $ XYZ$ with hypothenuse $ XZ$ and $ \angle X = 50^{\circ}$. Points $ P$ and $ Q$ on the side $ YZ$ are such that $ \angle PXZ = \angle QXY = 10^{\circ}$. Compute the ratio $2 \times YQ/ZP$. -",4,Geometry,computation,Sharygin 2008 +",4,Geometry,IMO-Medium,computation,Sharygin 2008 imo-bench-geometry-003,"Given a convex $n$-sided polygon $B_1\ldots B_n$. Let $Q_i$ ($i = 1,\ldots, n$) be points on the boundary of the polygon such that $B_iQ_i$ divides the area of the polygon in half. Assume that none of the points $Q_i$ coincide with any vertex of the polygon and that these points lie on $k$ sides of the $n$-sided polygon. For a given value of $n$, determine the minimum possible value of $k$. -",3,Geometry,combinatorial_geometry,Sharygin 2009 +",3,Geometry,IMO-Medium,combinatorial_geometry,Sharygin 2009 imo-bench-geometry-004,"Let $n$ cities lie on the circumference of a circular lake. Exactly half of the triangles formed by connecting any three of these cities are acute-angled triangles. Find the value of $n$ for which this is possible. -","4, 5",Geometry,combinatorial_geometry,Sharygin 2009 +","4, 5",Geometry,IMO-Medium,combinatorial_geometry,Sharygin 2009 imo-bench-geometry-005,"Given cyclic quadrilateral $PQRS$. Four circles each touching its diagonals and the circumcircle internally are equal. Compute the ratio $\frac{PR}{PQ}+\frac{PS}{PQ}$. -",$\sqrt{2}+1$,Geometry,proof_based_geometry,Sharygin 2009 +",$\sqrt{2}+1$,Geometry,IMO-Medium,proof_based_geometry,Sharygin 2009 imo-bench-geometry-006,"Let $x, y, z$ be the lengths of some triangle's sides, $s, \rho$ be the semiperimeter and the inradius of the triangle. Find the minimum value of $\sqrt{\frac{xy(s- z)}{s}} +\sqrt{\frac{zx(s- y)}{s}} +\sqrt{\frac{yz(s-x)}{s}}$ in terms of $\rho$. -",$6\rho$,Geometry,extremal_geometry,Sharygin 2009 +",$6\rho$,Geometry,IMO-Medium,extremal_geometry,Sharygin 2009 imo-bench-geometry-007,"The cirumradius and the inradius of triangle $XYZ$ are equal to $R$ and $r$, respectively. $O$ and $I$ are the circumcenter and incenter of triangle $XYZ$, respectively. The external bisector of angle $Z$ intersects side $XY$ at point $P$. Point $Q$ is the foot of the perpendicular from $P$ to line $OI$. Determine the length of segment $OQ$. -",$\frac{R^2+Rr}{\sqrt{R^2-2Rr}}$,Geometry,computation,Sharygin 2009 +",$\frac{R^2+Rr}{\sqrt{R^2-2Rr}}$,Geometry,IMO-Medium,computation,Sharygin 2009 imo-bench-geometry-008,"Let $C, I$ be the circumcenter and the incenter of a right-angled triangle; $R, r$ be the radii of respective circles; $K$ be the reflection of the vertex of the right angle in $I$. Find $CK$ in terms of $R$ and $r$. -",$R-2r$,Geometry,computation,Sharygin 2010 +",$R-2r$,Geometry,IMO-Medium,computation,Sharygin 2010 imo-bench-geometry-009,"A convex $m$-gon $Q$, where $m > 3$, is divided into identical triangles by diagonals that do not intersect within it. For which values of $m$ is it possible for $Q$ to be circumscribed? -",4,Geometry,combinatorial_geometry,Sharygin 2011 +",4,Geometry,IMO-Medium,combinatorial_geometry,Sharygin 2011 imo-bench-geometry-010,"Let $XYZ$ be an isosceles triangle with $YZ = p$ and $XY = XZ = q$. Segment $XZ$ is the base of an isosceles triangle $XDZ$ with $XD = DZ = p$ such that points $D$ and $Y$ share the opposite sides of $XZ$. Let $ZM$ and $ZN$ be the bisectors in triangles $XYZ$ and $XDZ$ respectively. Determine the circumradius of triangle $ZMN$ in terms of $p,q$. -",$\frac{pq}{p+q}$,Geometry,computation,Sharygin 2012 +",$\frac{pq}{p+q}$,Geometry,IMO-Medium,computation,Sharygin 2012 imo-bench-geometry-011,"Given five distinct points $A_1, A_2, A_3, A_4, A_5$ in space. These points are the centers of five spheres, such that four of the spheres are pairwise externally tangent, and these four spheres are internally tangent to the fifth sphere. It is impossible to determine which of these points is the center of the largest sphere. Find the ratio of the largest radius to the smallest radius among the five spheres. -",$\frac{5+\sqrt{21}}{2}$,Geometry,3d_geometry,Sharygin 2013 +",$\frac{5+\sqrt{21}}{2}$,Geometry,IMO-Medium,3d_geometry,Sharygin 2013 imo-bench-geometry-012,"Let XYZ be a fixed triangle in the plane. Let P be an arbitrary point in the plane. The circle with center P, passing through X, meets XY and XZ again at points X_y and X_z respectively. Points Y_x, Y_z, Z_x and Z_y are defined similarly. A point P is called special if the points X_y, X_z, Y_x, Y_z, Z_x, and Z_y are concyclic. For a given triangle XYZ, how many special points can there be? -",4,Geometry,proof_based_geometry,Sharygin 2014 +",4,Geometry,IMO-Medium,proof_based_geometry,Sharygin 2014 imo-bench-geometry-013,"In triangle $XYZ$, we have $XY = YZ$, $\angle Y = 20^\circ$. Point $P$ on $XZ$ is such that $XP : PZ = 1 : 2$, point $Q$ is the projection of $Z$ to $YP$. Find angle $\angle XQY$ in terms of degree. -",100,Geometry,computation,Sharygin 2015 +",100,Geometry,IMO-Medium,computation,Sharygin 2015 imo-bench-geometry-014,"Let $XYZ$ be an acute-angled, nonisosceles triangle. Altitudes $XX'$ and $YY'$ meet at point $O$, and the medians of triangle $XOY$ meet at point $N$. Line $ZN$ bisects segment $X'Y'$. Find angle $Z$ in terms of degree. -",45,Geometry,computation,Sharygin 2015 +",45,Geometry,IMO-Medium,computation,Sharygin 2015 imo-bench-geometry-015,"A triangle XYZ with $\angle X = 60^\circ$ is given. Points P and Q on XY and XZ respectively are such that the circumcenter of XYZ bisects segment PQ. Find the ratio XQ:PY. -",2,Geometry,computation,Sharygin 2016 +",2,Geometry,IMO-Medium,computation,Sharygin 2016 imo-bench-geometry-016,"Diagonals of a quadrilateral $WXYZ$ are equal and intersect at point $M$. The perpendicular bisectors to segments $WX$ and $YZ$ intersect at point $N$, and the perpendicular bisectors to $XY$ and $WZ$ intersect at point $O$. Find angle $\frac{\angle NMO}{5}$ in terms of degree. -",18,Geometry,computation,Sharygin 2016 +",18,Geometry,IMO-Medium,computation,Sharygin 2016 imo-bench-geometry-017,"Let $P$ and $Q$ be the circumcenter and incenter of triangle $DEF$. The perpendicular from $Q$ to $PQ$ meets $DE$ and the external bisector of angle $F$ at points $M$ and $N$ respectively. What is the value of $QM/QN$? -",0.5,Geometry,computation,Sharygin 2016 +",0.5,Geometry,IMO-Medium,computation,Sharygin 2016 imo-bench-geometry-018,"Let $I$ be the incenter of triangle $XYZ$, $N$ be the midpoint of $XZ$, and $V$ be the midpoint of arc $XY$ of the circumcircle not containing $Z$. It is known that $\angle XIN = 90^\circ$. Compute $\frac{2 \times ZI}{IV}$. -",4,Geometry,computation,Sharygin 2017 +",4,Geometry,IMO-Medium,computation,Sharygin 2017 imo-bench-geometry-019,"Let $XYZ$ be a right-angled triangle ($\angle Z = 90^\circ$) and $W$ be the midpoint of an altitude from Z. The reflections of the line $XY$ about $XW$ and $YW$, respectively, meet at point $P$. Find the ratio $S_{XYP}:S_{XYZ}$. Note: $S_{\alpha}$ means the area of $\alpha$. -",$\frac{4}{3}$,Geometry,computation,Sharygin 2017 +",$\frac{4}{3}$,Geometry,IMO-Medium,computation,Sharygin 2017 imo-bench-geometry-020,"Let $l$ and $m$ be parallel lines with $100$ distinct points marked on $l$ and $100$ distinct points marked on $m$. Find the greatest possible number of acute-angled triangles all of whose vertices are marked. -",333300,Geometry,combinatorial_geometry,Sharygin 2017 +",333300,Geometry,IMO-Medium,combinatorial_geometry,Sharygin 2017 imo-bench-geometry-021,"What is the least positive integer n such that, in every convex 1001-sided polygon, the sum of any n diagonals is greater than or equal to the sum of the remaining diagonals? -",499000,Geometry,combinatorial_geometry,Sharygin 2019 +",499000,Geometry,IMO-Medium,combinatorial_geometry,Sharygin 2019 imo-bench-geometry-022,"A triangle $OPQ$ with $\angle P=90^{\circ}$ lies inside another triangle with vertex $O$. The altitude of $OPQ$ from $P$ until it meets the side of angle $O$ at $N$. The distances from $N$ and $Q$ to the second side of angle $O$ are $2$ and $1$ respectively. Find the length of $OP$. -",$\sqrt{2}$,Geometry,computation,Sharygin 2019 +",$\sqrt{2}$,Geometry,IMO-Medium,computation,Sharygin 2019 imo-bench-geometry-023,"A truncated triangular pyramid is circumscribed around a sphere that touches its bases at points $P_1, P_2$. Let $h$ be the altitude of the pyramid, $r_1, r_2$ be the circumradii of its bases, and $C_1, C_2$ be the circumcenters of the bases. Compute $(r_1^2-C_1P_1^2)(r_2^2-C_2P_2^2)$ in terms of $r_1, r_2$ and $h$. -",$r_1r_2 h^2$,Geometry,3d_geometry,Sharygin 2021 (correspondence) +",$r_1r_2 h^2$,Geometry,IMO-Medium,3d_geometry,Sharygin 2021 (correspondence) imo-bench-geometry-024,"Let $PQRS$ be a convex quadrilateral. The circumcenter and the incenter of triangle $PQR$ coincide with the incenter and the circumcenter of triangle $PRS$ respectively. It is known that $PQ = 1$. What is the value of angle P in degrees? -",72,Geometry,computation,Sharygin 2021 +",72,Geometry,IMO-Medium,computation,Sharygin 2021 imo-bench-geometry-025,"Let $XYZ$ be an acute-angled scalene triangle and $P$ be a point inside it such that $\angle XPY = \angle YPZ = 120^o$. A circle centered at point $Q$ passes through the midpoints of the sides of $XYZ$. For $Y, P, Q$ collinear, find angle $XYZ$ in terms of degree. -",30,Geometry,computation,Sharygin 2021 +",30,Geometry,IMO-Medium,computation,Sharygin 2021 imo-bench-geometry-026,"A line intersects a segment $PQ$ at point $R$. What is the maximum number of points $Y$ on this line such that one of the angles $\angle PYR$ and $\angle QYR$ is equal to half of the other? -",4,Geometry,computation,Sharygin 2022 -imo-bench-geometry-027,"The median $WY$ and the altitude $UZ$ of an acute-angled triangle $UVW$ intersect at point $P$. A point $Q$ lies outside the triangle such that $UPWQ$ is a parallelogram. Find the length of $VQ$, if $MP = x$, $PW = y$.",$2x+y$,Geometry,computation,Sharygin 2023 +",4,Geometry,IMO-Medium,computation,Sharygin 2022 +imo-bench-geometry-027,"The median $WY$ and the altitude $UZ$ of an acute-angled triangle $UVW$ intersect at point $P$. A point $Q$ lies outside the triangle such that $UPWQ$ is a parallelogram. Find the length of $VQ$, if $MP = x$, $PW = y$.",$2x+y$,Geometry,IMO-Medium,computation,Sharygin 2023 imo-bench-geometry-028,"Let $\Omega$ be the circumcircle of triangle $XYZ$, $C$ be its center, $X'$ be the point of $\Omega$ opposite to $X$, and $P$ be a point on a minor arc $YZ$ of $\Omega$. A point $P'$ is the reflection of $P$ about $YZ$. The line $X'P'$ meets $\Omega$ for the second time at point $Q$. The perpendicular bisector to $P'Q$ meets $XY$ and $XZ$ at points $R$ and $S$ respectively. Denote $\alpha = \angle YXZ$, compute $\angle RCS$ in terms of $\alpha$. -",$180 - 2\alpha$,Geometry,computation,Sharygin 2023 +",$180 - 2\alpha$,Geometry,IMO-Medium,computation,Sharygin 2023 imo-bench-geometry-029,"Let $XYZ$ be a triangle with $\angle X = 120^\circ$, $J$ be the incenter, and $N$ be the midpoint of $YZ$. The line passing through $N$ and parallel to $XJ$ intersects the circle with diameter $YZ$ at points $U$ and $V$ ($X$ and $U$ lie on the same semiplane with respect to $YZ$). The line passing through $U$ and perpendicular to $VJ$ intersects $XY$ and $XZ$ at points $R$ and $S$ respectively. Find the value of $\angle RJS$ in terms of degree. -",90,Geometry,computation,Sharygin 2023 +",90,Geometry,IMO-Medium,computation,Sharygin 2023 imo-bench-geometry-030,"The vertices $X$, $Y$, $Z$ of rectangle $ZWXY$ lie on the sides $DE$, $EF$, $FD$ respectively of a regular triangle $DEF$ in such a way that $DX = 2$, $FZ = 1$. The vertex $W$ lies outside the triangle. Find the value of $\frac{\angle ZXY}{3}$ in terms of degree. -",10,Geometry,computation,Sharygin 2024 +",10,Geometry,IMO-Medium,computation,Sharygin 2024 imo-bench-geometry-031,"For which largest value of $n$ does there exist a convex polyhedron with $n$ faces such that for each face there is a point outside the polyhedron from which the remaining $n - 1$ faces are visible? -",4,Geometry,combinatorial_geometry,Sharygin 2024 +",4,Geometry,IMO-Medium,combinatorial_geometry,Sharygin 2024 imo-bench-geometry-032,"Given a triangle $XYZ$ and $2$ point $P \in XY, \; M \in YZ$ such that $YP=2XP, \; ZM=2YM$ and $D$ is the common point of $XM$ and $ZP$. Compute $\dfrac{ S_{ \triangle XYZ}}{S_{\triangle YZD}}.$ -",1.75,Geometry,computation,Hanoi Open Mathematical Olympiad 2012 +",1.75,Geometry,IMO-Medium,computation,Hanoi Open Mathematical Olympiad 2012 imo-bench-geometry-033,"Let $XYZ$ be a triangle with $\angle X = 90^o, \angle Y = 60^o$ and $YZ = 1$. Draw outside of $\vartriangle XYZ$ three equilateral triangles $XYU, XZV$ and $YZW$. Determine the area of $\vartriangle UVW$. -",$\frac{9\sqrt{3}}{16}$,Geometry,computation,Hanoi Open Mathematical Olympiad 2013 +",$\frac{9\sqrt{3}}{16}$,Geometry,IMO-Medium,computation,Hanoi Open Mathematical Olympiad 2013 imo-bench-geometry-034,"Let $A$ be the area of parallelogram $PQRS$ and points $X,Y$ belong to $QR$ and $PS$, respectively, such that $QR = 3QX, 3PS = 4PY$. Let $I$ be the intersection of $PX$ and $QY$. Each straight line of $PX$ and $QY$ meets that of $RS$ at points $U$ and $V$, respectively. Determine the area of triangle $UIV$ in terms of $A$. -",$\frac{50}{39}A$,Geometry,computation,Hanoi Open Mathematical Olympiad 2014 +",$\frac{50}{39}A$,Geometry,IMO-Medium,computation,Hanoi Open Mathematical Olympiad 2014 imo-bench-geometry-035,"Let $XYZ$ be an acute triangle with $XY = 3$ and $XZ = 4$. Let $XH,XO$ and $XM$ be the altitude, the bisector and the median derived from $X$, respectively. If $HO = 3 MO$, then what is the length of $YZ$? -",$\frac{7}{2}$,Geometry,computation,Hanoi Open Mathematical Olympiad 2018 +",$\frac{7}{2}$,Geometry,IMO-Medium,computation,Hanoi Open Mathematical Olympiad 2018 imo-bench-geometry-036,"In triangle $XYZ$, $\angle YXZ = 60^o$, $XY = 3a$ and $XZ = 4a, (a > 0)$. Let $P$ be a point on the segment $XY$ such that $XP = \frac{1}{3} XY$. Let $Q$ be a point on the side $XZ$ such that $XQ = \frac{1}{2} XZ$. Let $R$ be the midpoint of $PQ$. Determine the length of $YR$. -",$\frac{a\sqrt{19}}{2}$,Geometry,computation,Hanoi Open Mathematical Olympiad 2018 +",$\frac{a\sqrt{19}}{2}$,Geometry,IMO-Medium,computation,Hanoi Open Mathematical Olympiad 2018 imo-bench-geometry-037,"Suppose that $PQRST$ is a convex pentagon with $\angle P = 90^o, \angle Q = 105^o, \angle R = 90^o$ and $PQ = 2, QR = RS = ST = \sqrt{2}$. If the length of $PT$ is $\sqrt{a} - b$ where $a, b$ are integers, what is the value of $a + b$? -",4,Geometry,computation,Hanoi Open Mathematical Olympiad 2018 +",4,Geometry,IMO-Medium,computation,Hanoi Open Mathematical Olympiad 2018 imo-bench-geometry-038,"Let $Q, R$ be fixed points with coordinates $(-1,0)$ and $(1,0)$ respectively and $P$ be a moving point with coordinate $(a,b)$. Let $O, M$ be orthocentre and centroid of triangle $PQR$. It is known that the midpoint of $OM$ lies on $QR$, find the locus of $P$. -",$3a^2 - b^2 = 3$,Geometry,locus_geometry,Vietnam Mathematical Olympiad 2007 +",$3a^2 - b^2 = 3$,Geometry,IMO-Medium,locus_geometry,Vietnam Mathematical Olympiad 2007 imo-bench-geometry-039,"Given a circumcircle $(K)$ and two fixed points $Y,Z$ on $(K)$. $YZ$ is not the diameter of $(K)$. A point $X$ varies on $(K)$ such that $XYZ$ is an acute triangle. $M,N$ is the foot of the altitude from $Y,Z$ respectively of $XYZ$. $(J)$ is a variable circumcircle going through $M$ and $N$ with center $J$. Assume that $(J)$ touches $YZ$ at $P$. Denote $\cot Y = y$ and $\cot Z = z$, calculate $\frac{PY}{PZ}$ in terms of $y, z$. -",$\sqrt{\frac{y}{z}}$,Geometry,computation,Vietnam Mathematical Olympiad 2015 +",$\sqrt{\frac{y}{z}}$,Geometry,IMO-Medium,computation,Vietnam Mathematical Olympiad 2015 imo-bench-geometry-040,"Let $k$ be a positive real number. Triangle XYZ is acute and scalene, O is its circumcenter and XD, YE, ZF are the internal bisectors. On the rays XD, YE, ZF, respectively, let points P, Q, R such that $\frac{XP}{XD} = \frac{YQ}{YE} = \frac{ZR}{ZF} = k$. Denote $(C_1), (C_2), (C_3)$ be respectively the circle through P and touches OX at X, the circle through Q and touches OY at Y, the circle through R and touches OZ at Z. Find all values of k such that three circles $(C_1), (C_2), (C_3)$ have exactly two common points. -","1/2, 1",Geometry,proof_based_geometry,Vietnam TST 2008 +","1/2, 1",Geometry,IMO-Hard,proof_based_geometry,Vietnam TST 2008 imo-bench-geometry-041,"Let $XYZ$ be a triangle with $\angle X = 60^\circ$. The points $P,Q,R$ lie on $YZ,XZ,XY$ respectively such that $YR = RP = PQ = QZ$. If $XQ = 2XR$, find the values of $\angle Y$ in terms of degree. -",75,Geometry,computation,Iran Geometry Olympiad 2015 +",75,Geometry,IMO-Hard,computation,Iran Geometry Olympiad 2015 imo-bench-geometry-042,"Let $\Gamma$ be the circumcircle of right-angled triangle $XYZ$ ($\angle X = 90^{\circ}$). The tangent to $\Gamma$ at point $X$ intersects the line $YZ$ at point $T$. Suppose that $N$ is the midpoint of the minor arc $XY$, and $TN$ intersects $\Gamma$ for the second time in $R$. The tangent to $\Gamma$ at point $R$ intersects $XZ$ at $L$. Compute $\angle TLC$ in terms of degree. -",90,Geometry,computation,Iran Geometry Olympiad 2016 +",90,Geometry,IMO-Hard,computation,Iran Geometry Olympiad 2016 imo-bench-geometry-043,"Let $XYZ$ be an acute triangle with $X=60^{\circ}$. Let $Q, R$ be the feet of altitudes through $Y, Z$ respectively. Compute $ZQ-YR$ in terms of $XY, XZ$. -",$\frac{3}{2}(XZ-XY)$,Geometry,computation,Iran Geometry Olympiad 2017 +",$\frac{3}{2}(XZ-XY)$,Geometry,IMO-Hard,computation,Iran Geometry Olympiad 2017 imo-bench-geometry-044,"Given $PQRS$ is a parallelogram. We know that $\angle S = 60^\circ$, $PS = 2$ and $PQ = \sqrt{3} + 1$. Point $N$ is the midpoint of $PS$. Segment $RE$ is the angle bisector of $R$. Find the angle $REQ$ in terms of degree. -",75,Geometry,computation,Iran Geometry Olympiad 2018 +",75,Geometry,IMO-Hard,computation,Iran Geometry Olympiad 2018 imo-bench-geometry-045,"Find all possible values of integer $k > 3$ such that there is a convex $k$-gon in which each diagonal is the perpendicular bisector of at least one other diagonal. -",4,Geometry,combinatorial_geometry,Iran Geometry Olympiad 2018 +",4,Geometry,IMO-Hard,combinatorial_geometry,Iran Geometry Olympiad 2018 imo-bench-geometry-046,"Let $XYZ$ be an isosceles triangle ($XY = XZ$) with its circumcenter $P$. Point $Q$ is the midpoint of the segment $YZ$ and point $R$ is the reflection of the point $Q$ with respect to the side $XZ$. Suppose that $S$ is a point so that $XQYS$ is a rectangle. Denote $\angle YXZ = a$, compute $\angle PRS$ in terms of $a$. -",$\frac{a}{2}$,Geometry,computation,Iran Geometry Olympiad 2020 +",$\frac{a}{2}$,Geometry,IMO-Hard,computation,Iran Geometry Olympiad 2020 imo-bench-geometry-047,"Let $FGHIJ$ be a convex pentagon such that $FG = GH = HI$ and $\angle GIJ = \angle JFH = 30$ degree. Find the possible values of $\frac{\angle GJH}{5}$ in terms of degree. -",12,Geometry,computation,Iran Geometry Olympiad 2022 +",12,Geometry,IMO-Hard,computation,Iran Geometry Olympiad 2022 imo-bench-geometry-048,"Let $ XYZ $ be a triangle with incenter $ J $. Let segment $ XJ $ meets the incircle of triangle $ XYZ $ at point $ K $. Suppose that the angle created by line $ YK $ and line $ XZ $ is $90^\circ$. Let $ R $ be a point such that $ \angle YRX = \angle RXJ = 90^\circ $. Point $ S $ lies on segment $ YK $ such that the circumcircle of triangle $ XYS $ is tangent to line $ YJ $. Point $ T $ lies on line $ RS $ such that $ \angle JXT = \angle TXZ $. Let $\gamma$ be the value of $\angle XTR$ in terms of degree, compute $\frac{\gamma}{3}$. -",15,Geometry,computation,USA TST 2024 +",15,Geometry,IMO-Hard,computation,USA TST 2024 imo-bench-geometry-049,"There are several circles whose radii are no more than 1, and whose centers all lie on a segment with length $l$. Find the maximum value of the perimeter of the union of all the circles. -",$\pi(l+2)$,Geometry,combinatorial_geometry,Iran Geometry Olympiad 2023 +",$\pi(l+2)$,Geometry,IMO-Hard,combinatorial_geometry,Iran Geometry Olympiad 2023 imo-bench-geometry-050,"In $\triangle XYZ$, $XZ=15$, $YZ=20$, and $XY=25$. Points $U$ and $V$ lie on $\overline{XY}$, points $W$ and $S$ lie on $\overline{YZ}$, and points $T$ and $R$ lie on $\overline{XZ}$, with $XU=VY=YW=SZ=ZT=XR=5$. Find the area of hexagon $UVWSTR$. -",120,Geometry,computation,AIME 2019 +",120,Geometry,pre-IMO,computation,AIME 2019 imo-bench-geometry-051,"Let $\overline{CD}$ be a chord of a circle $\Omega$, and let $R$ be a point on the chord $\overline{CD}$. Circle $\Omega_1$ passes through $C$ and $R$ and is internally tangent to $\Omega$. Circle $\Omega_2$ passes through $D$ and $R$ and is internally tangent to $\Omega$. Circles $\Omega_1$ and $\Omega_2$ intersect at points $R$ and $S$. Line $RS$ intersects $\Omega$ at $U$ and $V$. Assume that $CR=4$, $RD=6$, $UV=11$, and $RS^2 = \frac{m}{n}$, where $m$ and $n$ are relatively prime positive integers. Find $m+n$. -",29,Geometry,computation,AIME 2019 +",29,Geometry,pre-IMO,computation,AIME 2019 imo-bench-geometry-052,"Triangle $XYZ$ has side lengths $XY=4$, $YZ=5$, and $ZX=6$. Points $P$ and $Q$ are on ray $XY$ with $XY 1$ such that there exists a permutation $(a_1, a_2, \dots, a_n)$ of the all divisors of $m$ for which $a_1 + \dots + a_i$ is a perfect square for all $1 \leq i \leq n$. -",3,Number theory,Perfect power,IMO Shortlist 2021 +",3,Number theory,IMO-Medium,Perfect power,IMO Shortlist 2021 imo-bench-number_theory-002,"Find the number of all positive integers $2\leq m \leq 2000$ that satisfy the following condition: For any $m$ distinct positive integers $(n_1, \ldots, n_m)$, at least one of the following two conditions holds: $n_1 + \ldots + n_m$ is a multiple of $m$, or there exists a permutation $(k_1, \ldots, k_m)$ such that $k_1 + 2k_2 + \ldots + mk_m$ is a multiple of $m$. -",1009,Number theory,Divisibility,IMO Shortlist 2021 +",1009,Number theory,IMO-Medium,Divisibility,IMO Shortlist 2021 imo-bench-number_theory-003,"Suppose that the function $g:\mathbb{N}\rightarrow \mathbb{N}$ satisfies following four conditions. (1) There exists a natural number $n$ such that $g(n) \neq 1$. @@ -1028,148 +1028,148 @@ imo-bench-number_theory-003,"Suppose that the function $g:\mathbb{N}\rightarrow (4) $g(39455)=11$ and $g(94175)=21$. -Find $g(41000)$.",31,Number theory,Functional Equation,IMO Shortlist 2020 +Find $g(41000)$.",31,Number theory,IMO-Medium,Functional Equation,IMO Shortlist 2020 imo-bench-number_theory-004,"Find all positive integer triples $(x, y, z)$ that satisfy $x^3 + y^3 + z^3 - x^2y^2z^2 = 0$ and $x \le y \le z$. -","$(1, 2, 3)$",Number theory,Diophantine Equation,IMO Shortlist 2019 +","$(1, 2, 3)$",Number theory,IMO-Medium,Diophantine Equation,IMO Shortlist 2019 imo-bench-number_theory-005,"A subset $X$ of $\mathbb{Z}$ is called rich if for any positive integer $n$ and $n$ numbers $x_0, x_1, \dots, x_n$ belonging to $X$, all integer roots of $x_0 + x_1 \cdot x + \dots + x_n \cdot x^n = 0$ belong to $X$. Find all rich sets that contain $2^k - 2^l$ for any positive integers $k$ and $l$. -",$\mathbb{Z}$,Number theory,Polynomial,IMO Shortlist 2019 +",$\mathbb{Z}$,Number theory,IMO-Medium,Polynomial,IMO Shortlist 2019 imo-bench-number_theory-006,"For a given positive integer $a$, find the number of positive integers $b$ less than or equal to $a^2+1$ that satisfy the following condition: There exists a positive integer $s$ such that the number of divisors of $s \cdot a$ is equal to the number of divisors of $s \cdot a + s \cdot b$. ","$a^2 - a + 1$ ( $a \ge 2$) -0 ($a=1$)",Number theory,Divisor,IMO Shortlist 2018 +0 ($a=1$)",Number theory,IMO-Medium,Divisor,IMO Shortlist 2018 imo-bench-number_theory-007,"Find all positive integers $n \geq 2$ that satisfy the following condition: (Condition) For any $n$ numbers $b_1, \dots, b_n$ whose sum is not a multiple of $n$, there exists some $1 \leq j \leq n$ such that $b_j, b_j + b_{j-1}, \dots, b_j + b_{j-1} + \dots + b_{j-n+1}$ are all not multiples of $n$. (Here, for any integer $i$ with $1 \leq i \leq n$, $b_{i-n} = b_i$.) ","n is prime -",Number theory,Divisibility,IMO Shortlist 2017 +",Number theory,IMO-Medium,Divisibility,IMO Shortlist 2017 imo-bench-number_theory-008,"Does there exist a positive integer $n$ satisfying the following condition? If so, find the smallest such $n$. (Condition) There exist infinitely many ordered $n$-tuples of positive rational numbers $(x_1, \dots, x_n)$ such that both $\sum_{i=1}^n i \cdot x_i$ and $\frac{1}{x_1 + \dots + x_n} + \frac{1}{x_2 + \dots + x_n} + \dots + \frac{1}{x_n}$ are positive integers. -",3,Number theory,Divisibility,IMO Shortlist 2017 +",3,Number theory,IMO-Medium,Divisibility,IMO Shortlist 2017 imo-bench-number_theory-009,"For a positive integer $n$, let $\tau(n)$ be the number of divisors of $n$, and let $\tau_1(n)$ be the number of divisors of $n$ that leave a remainder of 1 when divided by 3. Find all positive integers that cannot be represented as $\frac{\tau(22m)}{\tau_1(22m)}$ for some positive integer $m$. -",1 and odd prime numbers,Number theory,Number Theoretic Functions,IMO Shortlist 2016 +",1 and odd prime numbers,Number theory,IMO-Medium,Number Theoretic Functions,IMO Shortlist 2016 imo-bench-number_theory-010,"Suppose $f$ is a polynomial with integer coefficients of odd degree $d \ge 3$. Assume that the following condition holds: (Condition) For any positive integer $n$, there exist distinct positive integers $a_1, \dots, a_n$ such that for any $1 \leq i, j \leq n$, $\frac{f(a_i)}{f(a_j)}$ is between $\frac{1}{2}$ and $2$ and is the $d$-th power of some rational number. Furthermore, for some prime $p$, we know that $f(1)=3^d p$ and $\frac{f(2)}{f'(2)}=\frac{5}{2d}$. Evaluate $f(3)$. -",$7^d p$,Number theory,Polynomial,IMO Shortlist 2016 +",$7^d p$,Number theory,IMO-Medium,Polynomial,IMO Shortlist 2016 imo-bench-number_theory-011,"Find all positive integers $n$ such that the sequence $\{x_i\}$ defined by $x_1 = \frac{2n-1}{2}$ and $x_{k+1} = x_k \cdot \lfloor x_k \rfloor$ for $k\ge 1$ contains at least one integer. -","$n=1, n \ge 3$",Number theory,Sequence,IMO Shortlist 2015 +","$n=1, n \ge 3$",Number theory,IMO-Medium,Sequence,IMO Shortlist 2015 imo-bench-number_theory-012,"Find all positive integers $n$ such that there exists a function $f:\mathbb{N}\rightarrow \mathbb{N}$ from positive integers to positive integers satisfying $\operatorname{gcd}(f(a)+a+b, f(a+b)+a)\leq n$ for all positive integers $a,b$. -",$n \ge 2$,Number theory,Functional Equation,IMO Shortlist 2015 +",$n \ge 2$,Number theory,IMO-Medium,Functional Equation,IMO Shortlist 2015 imo-bench-number_theory-013,"For a positive integer $n \geq 2$, let the set $C_n$ be the set of integers $2^n - 2^i$ for integers $i$ such that $0 \leq i < n$. Find the smallest positive integer that cannot be expressed as a sum of numbers in $C_n$ (where the same number can be used multiple times). ","$(n-2)2^n +1$ -",Number theory,Representation,IMO Shortlist 2014 +",Number theory,IMO-Medium,Representation,IMO Shortlist 2014 imo-bench-number_theory-014,"Find all pairs of positive integers $(a,b)$ that satisfy the following condition: $\sqrt[3]{7a^2 +ab+b^2}=a+1$ ","$(n^2 +3n+2, n^3 + 4n^2 + 3n -1)$ -for $n \ge 1$",Number theory,Diophantine Equation,IMO Shortlist 2014 +for $n \ge 1$",Number theory,IMO-Medium,Diophantine Equation,IMO Shortlist 2014 imo-bench-number_theory-015,"Find all ordered triples $(p, a, b)$ of a prime $p > 2$ and positive integers $a, b$ such that $a\le b$ and both $a^{p-1} + b$ and $b^{p-1} + a$ are powers of $p$. -","(3,2,5)",Number theory,Perfect power,IMO Shortlist 2014 +","(3,2,5)",Number theory,IMO-Medium,Perfect power,IMO Shortlist 2014 imo-bench-number_theory-016,"Find all functions $g:\mathbb{Q}\rightarrow \mathbb{Z}$ that satisfy the following condition for any rational number $x$, integer $a$, and positive integer $b$: $g(x)=g(\frac{g(bx-a)+a}{b})$ ","$g(x)=c, g(x)=\lceil x \rceil, g(x)=\lfloor x \rfloor$ -",Number theory,Functional Equation,IMO Shortlist 2013 +",Number theory,IMO-Medium,Functional Equation,IMO Shortlist 2013 imo-bench-number_theory-017,"$\alpha$ is a real number that is not rational, and $k$ is a positive integer. A pair of positive integers $(m, n)$ is called ""pretty"" if $m\lceil n\alpha \rceil - n \lfloor m\alpha \rfloor =k$. A pretty pair $(m, n)$ is called ""cool"" if neither $(m-n, n)$ nor $(m, n-m)$ are pretty pairs. Find the number of cool pairs when $k=2310$. -",6912,Number theory,Other,IMO Shortlist 2013 +",6912,Number theory,IMO-Medium,Other,IMO Shortlist 2013 imo-bench-number_theory-018,"Let a set of integers $X$ be called a \textit{good set} if it satisfies the following condition: (Condition) For any $a, b \in X$ (where $a$ and $b$ can be equal) and any $i \in \mathbb{Z}$, $a^2 + i \cdot a \cdot b + b^2 \in X$. An ordered pair $(x, y)$ of two different positive integers is called a \textit{complex pair} if there are at least two good sets containing both $x$ and $y$. A non-negative integer $m$ is called a \textit{good number} if there exists a complex pair $(x,y)$ such that $m=x^2 + y^2$. Find $20$th smallest good number. -",208,Number theory,Set,IMO Shortlist 2012 +",208,Number theory,IMO-Medium,Set,IMO Shortlist 2012 imo-bench-number_theory-019,"Find all positive integer triples $(a,b,c)$ that satisfy $a \le b \le c$ and $a^3 (b^3 +c^3 )= 2012 (abc+2)$ ","(2,251,252) -",Number theory,Diophantine Equation,IMO Shortlist 2012 +",Number theory,IMO-Medium,Diophantine Equation,IMO Shortlist 2012 imo-bench-number_theory-020,"Find the number of positive integers $n\ge 2$ less than 200 that are relatively prime to 6 such that for any positive integer $a$ satisfying the condition that the quotient when $n$ is divided by $a$ is 2, the binomial coefficient $\binom{a-1}{n-2a-1}$ is a multiple of $n-2a$. -",44,Number theory,Divisibility,IMO Shortlist 2012 +",44,Number theory,IMO-Medium,Divisibility,IMO Shortlist 2012 imo-bench-number_theory-021,"For a positive integer $n$, we call $g:\mathbb{Z}\rightarrow \mathbb{Z}$ a \textif{$n$-good function} if $g(1)=1$ and for any two distinct integers $a$ and $b$, $g(a)-g(b)$ divides $a^n -b^n$. We call a positive integer $n$ an \textit{exotic integer} if the number of $n$-good functions is twice of an odd integer. Find $132$th exotic integer. -",69169,Number theory,Functional Equation,IMO Shortlist 2011 +",69169,Number theory,IMO-Medium,Functional Equation,IMO Shortlist 2011 imo-bench-number_theory-022,"For a given positive integer $n$, let $m$ be the exponent of 2 in the prime factorization of $n$. Define $f(n) = \frac{n}{2^m}$. Find all positive integers $u$ for which there exists a positive integer $v$ such that (Condition) $f(u+v) - f(u), f(u+v+1) - f(u+1), \cdots, f(u+2v-1) - f(u+v-1)$ are all multiples of 4. -","1,3,5",Number theory,Divisibility,IMO Shortlist 2011 +","1,3,5",Number theory,IMO-Medium,Divisibility,IMO Shortlist 2011 imo-bench-number_theory-023,"Find the smallest positive integer $m$ that satisfies the following condition: (Condition) There exist $m$ distinct positive integers $a_1, \dots, a_m$ such that $(1-\frac{1}{a_1})\cdots (1-\frac{1}{a_m}) = \frac{42}{2010}$. -",48,Number theory,Diophantine Equation,IMO Shortlist 2010 +",48,Number theory,IMO-Medium,Diophantine Equation,IMO Shortlist 2010 imo-bench-number_theory-024,"Denote by $(a_1, b_1), \ldots, (a_k, b_k)$ all the ordered pairs of positive integers $(a,b)$ that satisfy $a^2 + 2\cdot 3^b = a(2^{b+1}-1)$. Evaluate $\sum_{i=1}^k (a_i + b_i)$. -",94,Number theory,Diophantine Equation,IMO Shortlist 2010 +",94,Number theory,IMO-Medium,Diophantine Equation,IMO Shortlist 2010 imo-bench-number_theory-025,"Find the smallest positive integer $n$ for which there exist integer-coefficient polynomials $P_1, \dots, P_n$ such that $\frac{{P_1(x)}^2 + \cdots + {P_n(x)}^2}{x^2 + 7}$ is a perfect square of an positive integer. -",5,Number theory,Polynomial,IMO Shortlist 2010 +",5,Number theory,IMO-Medium,Polynomial,IMO Shortlist 2010 imo-bench-number_theory-026,"Find the maximum number of possible colors in a $2^n \times 2^n$ board colored such that for any $0 \leq a, b \leq 2^n - 1$, the color of the cell in the $a$-th row and $b$-th column is the same as the color of the cell in the $(b-a)$-th row and $a$-th column (where rows and columns are numbered from 0 to $2^n - 1$, and the row index is taken modulo $2^n$). ","$2^n$ -",Number theory,Other,IMO Shortlist 2010 +",Number theory,IMO-Medium,Other,IMO Shortlist 2010 imo-bench-number_theory-027,"Find the largest $n$ for which there exist positive integers $x_1, \dots, x_n$ satisfying the following condition: (Condition) For any $2 \leq i \leq n-1$, $x_{i+1}x_{i-1} + x_{i+1} + x_{i-1} = x_i^2$. -",4,Number theory,Diophantine Equation,IMO Shortlist 2009 +",4,Number theory,IMO-Medium,Diophantine Equation,IMO Shortlist 2009 imo-bench-number_theory-028,"Given a positive integer $n$, there exists an integer $a$ such that the sequence $\{a_k\}$ defined by $a_0 = a$ and $a_k = \frac{a_{k-1}}{k} + k^{n-1}$ consists only of integers. Find the possible values of the remainder when $n$ is divided by 3. -",2,Number theory,Sequence,IMO Shortlist 2009 +",2,Number theory,IMO-Medium,Sequence,IMO Shortlist 2009 imo-bench-number_theory-029,"Let $\tau(n)$ be the number of positive divisors of a positive integer $n$. Suppose that the function $g:\mathbb{N}\rightarrow \mathbb{N}$ satisfying the following two conditions: (1) For any positive integer $n$, $\tau(g(n))=n$. (2) $\frac{(m-1)n^{mn-1}g(m)}{g(mn)}$ is an integer. If $N>1$ is a positive integer whose prime factorization can be written as $N=p_1^{e_1}\cdots p_k^{e_k}$ where $p_1, \ldots, p_k$ are distinct prime, and $e_1, \ldots, e_k$ are positive integers. Find all the possible values of $g(N)$. ","$p_1^{p_1^{e_1}-1} \cdots p_k^{p_k^{e_k}-1}$ -",Number theory,Functional Equation,IMO Shortlist 2008 +",Number theory,IMO-Medium,Functional Equation,IMO Shortlist 2008 imo-bench-number_theory-030,"For a positive integer $n$, let $a_n = \binom{2^n}{2^{n-1}}$. For this, let $b_n = a_{n+1}-a_n$. For $n\geq 2$, find the exponent of $2$ in the prime factorization of $b_n$. -",$3n$,Number theory,Binomial,IMO Shortlist 2007 +",$3n$,Number theory,IMO-Medium,Binomial,IMO Shortlist 2007 imo-bench-number_theory-031,"Let $k>l$ be given coprime positive integers greater than 1. Define a function $f: \mathbb{Z}\rightarrow \mathbb{Z}$ as follows: for $x$, $f(x)$ is the smallest value of $|a|+|b|$ among all integers $a,b$ satisfying $ka+lb = x$. - An integer $x$ is called 'nice' if $f(x)\geq \max (f(x-a),f(x+a),f(x-b),f(x+b))$. Denote by $F(k,l)$ the the number of nice integers when both $k$ and $l$ are odd, and denote by $G(k,l)$ the number of nice integers when either $k$ or $l$ is even. Suppose that there exists polynomials $p(k,l)$ and $q(k,l)$ such that $F(k,l)=p(k,l)$ for all odd integers $k,l$ and $G(k,l)=q(k,l)$ whenever at least one of $k$ or $l$ is even. Evaluate $p(k,l)^2 + q(k,l)^2$.",$5(l-1)^2$,Number theory,Diophantine Equation,IMO Shortlist 2006 + An integer $x$ is called 'nice' if $f(x)\geq \max (f(x-a),f(x+a),f(x-b),f(x+b))$. Denote by $F(k,l)$ the the number of nice integers when both $k$ and $l$ are odd, and denote by $G(k,l)$ the number of nice integers when either $k$ or $l$ is even. Suppose that there exists polynomials $p(k,l)$ and $q(k,l)$ such that $F(k,l)=p(k,l)$ for all odd integers $k,l$ and $G(k,l)=q(k,l)$ whenever at least one of $k$ or $l$ is even. Evaluate $p(k,l)^2 + q(k,l)^2$.",$5(l-1)^2$,Number theory,IMO-Medium,Diophantine Equation,IMO Shortlist 2006 imo-bench-number_theory-032,"For the integer sequence $(a_n)$ defined by $a_1=10$ and $a_{n+1}=6a_n - 2^{n+2} - 3^{n+1} +5$, find all positive numbers that are relatively prime to every number in $(a_n)$. -",1,Number theory,Divisibility,IMO Shortlist 2005 +",1,Number theory,IMO-Medium,Divisibility,IMO Shortlist 2005 imo-bench-number_theory-033,"Find all positive integers $m$ for which there exists a unique positive integer $n$ satisfying the following two conditions: (1) $0 \leq n < m!$ (2) $m! \mid n^m + 1$ ","m is prime or 1 -",Number theory,Divisibility,IMO Shortlist 2005 +",Number theory,IMO-Medium,Divisibility,IMO Shortlist 2005 imo-bench-number_theory-034,"Find all integer values that appear exactly once as the value of $\frac{g(n)}{n}$, where $g:\mathbb{N}\rightarrow\mathbb{N}$ is a function defined by $g(m)=\sum_{i=1}^m \gcd(i,m)$.","All powers of 2 -",Number theory,Divisor,IMO Shortlist 2004 +",Number theory,IMO-Medium,Divisor,IMO Shortlist 2004 imo-bench-number_theory-035,"Let $n$ be a given positive integer bigger than 1. For $1 \leq k \leq n$, $a_k = 2^{k-1}$. For $k > n$, the sequence $(a_i)$ satisfies the recurrence relation $a_k = a_{k-1} + \cdots + a_{k-n}$. Suppose that $m$ consecutive terms in the sequence are multiples of $n$. Find the maximum possible value of $m$. -",$n-1$,Number theory,Sequence,IMO Shortlist 2003 +",$n-1$,Number theory,IMO-Medium,Sequence,IMO Shortlist 2003 imo-bench-number_theory-036,"We are given the function $f:\mathbb{N}\rightarrow \mathbb{N}$. $f(n)$ is the number obtained by moving the units digit of $n$ to the front. Find all positive integers $n$ such that $f^{-1}(f(n)^2)=n^2$. ","$2,3, \underbrace{2\cdots2}_{n}1$ -",Number theory,Base and Digit,IMO Shortlist 2003 +",Number theory,IMO-Medium,Base and Digit,IMO Shortlist 2003 imo-bench-number_theory-037,"Let $A$ be the set of odd integers $a$ such that $|a|$ is not a perfect square. Find all numbers that can be expressed as $x+y+z$ for $x, y, z \in A$ such that $xyz$ is a perfect square. ","All numbers of the form $4k+3$ -",Number theory,Representation,IMO Shortlist 2003 +",Number theory,IMO-Medium,Representation,IMO Shortlist 2003 imo-bench-number_theory-038,"Let a set $S$ be called $p$-good for a given prime number $p$ if it satisfies the following three conditions: (1) $S$ consists of positive integers. (2) The number of primes dividing at least one number in $S$ is $p-1$. (3) For any subset of $S$, the product of all elements in that subset is not a $p$-th power. Find the maximum number of elements that a $p$-good set can have. -",$(p-1)^2$,Number theory,Set,IMO Shortlist 2003 -imo-bench-number_theory-039,"Find the smallest positive integer $n$ such that there exists infinitely many triple $(a,b,c)$ of distinct positive integers such that $\frac{(a+b+c)(ab+bc+ca)+a+b+c}{4abc} = n$.",3,Number theory,Diophantine Equation,IMO Shortlist 2002 +",$(p-1)^2$,Number theory,IMO-Medium,Set,IMO Shortlist 2003 +imo-bench-number_theory-039,"Find the smallest positive integer $n$ such that there exists infinitely many triple $(a,b,c)$ of distinct positive integers such that $\frac{(a+b+c)(ab+bc+ca)+a+b+c}{4abc} = n$.",3,Number theory,IMO-Medium,Diophantine Equation,IMO Shortlist 2002 imo-bench-number_theory-040,"Consider ordered quadruples of positive integers $(a,b,c,d)$ satisfying the following two conditions: (1) $a+b=c+d$ (2) $ab=2cd$ Find the maximum value of $k$ such that $\frac{c^2 +d^2}{cd} \geq k$ holds for all such quadruples. -",6,Number theory,Diophantine Equation,IMO Shortlist 2001 +",6,Number theory,IMO-Medium,Diophantine Equation,IMO Shortlist 2001 imo-bench-number_theory-041,"Find all positive integers $n\ge 2$ such that for any positive integer $k$ relatively prime to $n$, $k^2 - 1$ is a multiple of $n$. ","2, 3, 4, 6, 8, 12, 24 -",Number theory,Divisibility,IMO Shortlist 2000 -imo-bench-number_theory-042,Find all positive integers $k$ such that the number of positive divisors of $2k^3$ is $2k$. ,"1, 4, 10",Number theory,Divisor,IMO Shortlist 2000 +",Number theory,IMO-Medium,Divisibility,IMO Shortlist 2000 +imo-bench-number_theory-042,Find all positive integers $k$ such that the number of positive divisors of $2k^3$ is $2k$. ,"1, 4, 10",Number theory,IMO-Medium,Divisor,IMO Shortlist 2000 imo-bench-number_theory-043,"We call an ordered triple $(x,y,z)$ of positive integers a \textit{good triple} if $\frac{(x+1)^y}{x^z +1}$ is a positive integer. Find the number of good triples (x,y,z) such that $0 a_k$ for $k > N$. Find all possible values of the positive integer $n$ for which the sequence defined by $x_k = \operatorname{lcm}(k, k+1, \ldots, k+(n-1))$ is a weakly increasing sequence. -","1, 2",Number theory,Sequence,Belarus 2018 +","1, 2",Number theory,IMO-Medium,Sequence,Belarus 2018 imo-bench-number_theory-051,"Find the maximum value of $k$ such that for any finite set of positive real numbers less than or equal to 1 whose sum is $k$, it is possible to partition the set into two sets such that the sum of the numbers in one set is less than or equal to 1 and the sum of the numbers in the other set is less than or equal to 6. -",6.5,Number theory,Set,Belarus 2018 +",6.5,Number theory,IMO-Medium,Set,Belarus 2018 imo-bench-number_theory-052,"Find all prime numbers $p < 260^2$ that satisfy $\{\sqrt{p}\} < \frac{1}{510}$. -",$2^{16} + 1$,Number theory,Number Theoretic Functions,Belarus 2018 +",$2^{16} + 1$,Number theory,IMO-Medium,Number Theoretic Functions,Belarus 2018 imo-bench-number_theory-053,"Given a positive integer $n$, a sequence $(x_1, \cdots, x_n)$ exists such that for any $(c_1, \cdots, c_n) \in \{-1, 1\}^n$, $(c_1 x_1, c_1 x_1 + c_2 x_2, \cdots, c_1 x_1 + \cdots + c_n x_n)$ is a permutation of $(1, \cdots, n)$ modulo $n$. Find all possible values of $n$. ","All powers of 2 -",Number theory,Sequence,Britain 2018 +",Number theory,IMO-Medium,Sequence,Britain 2018 imo-bench-number_theory-054,"Find all positive integers $a$ that satisfy the following condition: (Condition) There exists a positive integer $b$ such that, if $A$ is the set of positive divisors of $a$, then every number in $A-b$ is also a divisor of $a$. ","All prime numbers, 1, 4, and 6. -",Number theory,Divisor,Dutch 2017 +",Number theory,IMO-Medium,Divisor,Dutch 2017 imo-bench-number_theory-055,"A positive integer $m$ consisting of distinct digits is considered ""good"" if it is a single-digit number, or if removing one of its digits results in a divisor of $m$ that is also a good number. Find the largest good number. -",146250,Number theory,Base and Digit,Estonia TST 2018 -imo-bench-number_theory-056,Let $P$ be a polynomial of degree $n>1$ such that all its non-zero coefficients are 1 or -1. Suppose that $P(k)$ is a multiple of $n$ for any positive integer $k$. Find the minimum possible number of non-zero coefficients in $P$.,2,Number theory,Polynomial,Estonia TST 2018 +",146250,Number theory,IMO-Hard,Base and Digit,Estonia TST 2018 +imo-bench-number_theory-056,Let $P$ be a polynomial of degree $n>1$ such that all its non-zero coefficients are 1 or -1. Suppose that $P(k)$ is a multiple of $n$ for any positive integer $k$. Find the minimum possible number of non-zero coefficients in $P$.,2,Number theory,IMO-Hard,Polynomial,Estonia TST 2018 imo-bench-number_theory-057,"Let $b_m b_{m-1}\cdots b_0$ be the base-7 representation of a positive integer $n$ for some positive integer $m$. Let $a_i$ be the number obtained by removing the digit $b_i$ from the base-7 representation of $m$ (read in base 7). Find the number of $n$ that satisfy $n=\sum_{i=0}^{m-1}a_i$. -",42,Number theory,Base and Digit,Japan 2018 +",42,Number theory,IMO-Medium,Base and Digit,Japan 2018 imo-bench-number_theory-058,"Let $N$ be a positive integer. Consider an infinite two-dimensional grid where each cell $(i, j) \in \mathbb{Z}_{>0}^2$ is filled with a positive integer $a_{ij}$. Determine all possible ways to fill the grid so that the following two conditions are satisfied: (i) Each positive integer $n$ appears exactly $n$ times in the grid. (ii) For each $n = 0, 1, \ldots, N$, the difference $a_{k + n, \ell + N - n} - a_{k, \ell}$ is a constant depending on $n$ for any positive integers $k, \ell$. -",$a_{ij} = i + j - 1$,Number theory,Sequence,Japan TST 2018 +",$a_{ij} = i + j - 1$,Number theory,IMO-Hard,Sequence,Japan TST 2018 imo-bench-number_theory-059,"Let $n$ be a positive integer with at least 5 positive divisors. Let $a, b, c$ be its second, third, and fifth smallest divisors, respectively. Suppose the following equation holds: \[ (a + b + c)^2 = a^2 + b^2 + c^2 + 2n \] Find all possible values the number of divisors of $n$. -","8, 9",Number theory,Diophantine Equation,Belarus 2017 +","8, 9",Number theory,IMO-Medium,Diophantine Equation,Belarus 2017 imo-bench-number_theory-060,"Define a set \[ S = \{2025k + 1: 0 \le k \le 2025^{100}, k \in \mathbb{Z}\}. \] Consider the following operation: take the largest element of $S$, and remove all of its divisors from $S$. Repeating this operation, what will be the last element removed from $S$? ","$\frac{2025^{101} + 2025^2 + 2025 + 1}{2026}$ -",Number theory,Operation,Bulgaria 2017 +",Number theory,IMO-Medium,Operation,Bulgaria 2017 imo-bench-number_theory-061,"Find all even integers $d$ such that the number of ordered integer pairs $(x, y)$ satisfying \[ (x + 2y - d)^2 = xy \] -is even.","all multiples of 14, excluding 0",Number theory,Diophantine Equation,Czech and Slovak 2017 (modified) +is even.","all multiples of 14, excluding 0",Number theory,IMO-Medium,Diophantine Equation,Czech and Slovak 2017 (modified) imo-bench-number_theory-062,"Let $g: \mathbb{Z}_{>0} \to \mathbb{Z}$ be a function satisfying the following conditions: (i) $g(p) = p + 1$ for all prime numbers $p$, @@ -1235,23 +1235,23 @@ imo-bench-number_theory-062,"Let $g: \mathbb{Z}_{>0} \to \mathbb{Z}$ be a functi (ii) $g(nm) + nm = ng(m) + mg(n)$ for all positive integers $n, m$. Find all integers $1 \le n \le 4000$ satisfying $g(n) = 2n$. -","4, 27, 3125",Number theory,Functional Equation,Dutch 2017 +","4, 27, 3125",Number theory,IMO-Medium,Functional Equation,Dutch 2017 imo-bench-number_theory-063,"Find all nonnegative integers $n$ such that \[ \frac{3((n+2)! + 1)}{2n - 1} \] is an integer. -","0, 1, 2, 4, 12",Number theory,Divisibility,Dutch 2017 +","0, 1, 2, 4, 12",Number theory,IMO-Medium,Divisibility,Dutch 2017 imo-bench-number_theory-064,"Let $d(n)$ be the number of positive divisors of $n$ other than 1 and itself. Find the least nonnegative integer $a$ for which there exists a positive integer $n$ such that \[ d(n) = d(n + 735) = a. \] -",2,Number theory,Divisor,Estonian Math Competition 16/17 +",2,Number theory,IMO-Medium,Divisor,Estonian Math Competition 16/17 imo-bench-number_theory-065,"Let $k$ be a positive integer and $p$ be a prime. Define a sequence $(x_n)$ of positive integers such that $x_1 = 8p^k$ and \[ x_n = (n+1)^{x_{n-1}/n}, \quad n = 2, 3, \ldots. \] -Suppose that the product $x_1 x_2 \cdots x_n$ divides $(x_1 - 1)(x_2 - 1)\cdots(x_{n+1} -1)$ for all $n = 1, 2, \ldots$. Find all possible primes $p$.","2, 5",Number theory,Sequence,Romania 2017 +Suppose that the product $x_1 x_2 \cdots x_n$ divides $(x_1 - 1)(x_2 - 1)\cdots(x_{n+1} -1)$ for all $n = 1, 2, \ldots$. Find all possible primes $p$.","2, 5",Number theory,IMO-Medium,Sequence,Romania 2017 imo-bench-number_theory-066,"Let $\mathbb{N}$ be the set of positive integers. Find all functions $f:\mathbb{N}\rightarrow\mathbb{N} \cup \{0\}$ such that \[ @@ -1259,49 +1259,49 @@ Find all functions $f:\mathbb{N}\rightarrow\mathbb{N} \cup \{0\}$ such that \] for all $x, y \in \mathbb{N}$. ","$f(x) = x^2 - x$ -",Number theory,Functional Equation,Balkan MO 2017 +",Number theory,IMO-Easy,Functional Equation,Balkan MO 2017 imo-bench-number_theory-067,"Find all primes $q$ such that \[ \sqrt[3]{\frac{q^3 + 1}{q + 1}} \] is a prime number different from $q$. -",19,Number theory,Diophantine Equation,Belarus 2016 +",19,Number theory,IMO-Medium,Diophantine Equation,Belarus 2016 imo-bench-number_theory-068,"Find all integers $n\ge 3$ for which $2^n - 3$ is a power of 5. -","3,7",Number theory,Diophantine Equation,Belarus 2016 +","3,7",Number theory,IMO-Medium,Diophantine Equation,Belarus 2016 imo-bench-number_theory-069,"Let $n$ be a positive integer, and let $1 = d_0 < d_1 < \dots < d_k$ be its odd divisors in increasing order. Find all $n$ such that $k \ge 1$ and $5d_1 = n - 3d_k$. -","60, 100, 8p (for all odd primes p)",Number theory,Divisor,Dutch 2015 -imo-bench-number_theory-070,"We call a triple $(x, y, z)$ of (not necessarily positive) integers a \textit{good triple} if $y^x z^y x^z$ is a positive prime number. We enumerate good triples as $(x_1, y_1, z_1), (x_2, y_2, z_2), \dots$ in a way that $x_k^2 + y_k^2 + z_k^2 \le x_{k+1}^2 + y_{k+1}^2 + z_{k+1}^2$ holds for all positive integer $k$. Evaluate $x_{200}^2 + y_{200}^2 + z_{200}^2$",18771,Number theory,Other,Estonia 2015/2016 +","60, 100, 8p (for all odd primes p)",Number theory,IMO-Medium,Divisor,Dutch 2015 +imo-bench-number_theory-070,"We call a triple $(x, y, z)$ of (not necessarily positive) integers a \textit{good triple} if $y^x z^y x^z$ is a positive prime number. We enumerate good triples as $(x_1, y_1, z_1), (x_2, y_2, z_2), \dots$ in a way that $x_k^2 + y_k^2 + z_k^2 \le x_{k+1}^2 + y_{k+1}^2 + z_{k+1}^2$ holds for all positive integer $k$. Evaluate $x_{200}^2 + y_{200}^2 + z_{200}^2$",18771,Number theory,IMO-Medium,Other,Estonia 2015/2016 imo-bench-number_theory-071,"Find the number of triples $(a, b, c)$ of positive integers such that \[ \sqrt{\frac{1001}{abc}}(\sqrt{ab} + \sqrt{bc} + \sqrt{ca}) \] is a positive integer. -",14,Number theory,Divisibility,Hong Kong 2015 +",14,Number theory,IMO-Medium,Divisibility,Hong Kong 2015 imo-bench-number_theory-072,"Find all tuples of positive integers $(x, n, k)$ with $x > n \ge 2$ such that \[ x^n + x = 2^k + 2. \] ","$(5, 3, 7)$ -",Number theory,Diophantine Equation,Olimpiadi Italiane della Matematica 2016 +",Number theory,IMO-Medium,Diophantine Equation,Olimpiadi Italiane della Matematica 2016 imo-bench-number_theory-073,"Let $q$ be an odd prime number. For an integer $i$ from 1 to $q-1$, let $n_i$ denote the number of divisors of $qi+1$ that are greater than or equal to $i$ and less than or equal to $q-1$. Find the sum of $n_1, n_2, \ldots, n_{q-1}$. ","$q-1$ -",Number theory,Divisor,Japan 2016 +",Number theory,IMO-Medium,Divisor,Japan 2016 imo-bench-number_theory-074,"Find all pairs $(a, b)$ of rational numbers such that \[ a^2 - b^2 = \frac{a}{a - 2}. \] -","(0, 0)",Number theory,Diophantine Equation,Korea 2026 (modified) +","(0, 0)",Number theory,IMO-Medium,Diophantine Equation,Korea 2026 (modified) imo-bench-number_theory-075,"Find all monic polynomials $P(x)$ with integer coefficients for which \[ \frac{6(|P(q)|!) - 1}{q} \] is an integer for every prime $q$ greater than 3. ","$P(x) = x - 4$ -",Number theory,Polynomial,Balkan MO 2016 +",Number theory,IMO-Easy,Polynomial,Balkan MO 2016 imo-bench-number_theory-076,"(a) Show that there exists a degree 3 monic polynomial $P(x)$ with integer coefficients such that for an integer $n$, $P(n)$ is a square of an integer if and only if $n = 2024$ or $2025$. (b) For such a polynomial $P(x)$ in (a), find all possible values for $P(2024)P(2025)$. -",0,Number theory,Polynomial,RMM 2016 +",0,Number theory,IMO-Medium,Polynomial,RMM 2016 imo-bench-number_theory-077,"Given a positive integer n, perform the following operation: (i) Remove the last digit of n. @@ -1311,12 +1311,12 @@ imo-bench-number_theory-077,"Given a positive integer n, perform the following o For example, if $n = 1013$, the operation yields $101 + 9 = 110$. If $n = 2$, the operation yields $0 + 6 = 6$. Starting with $260^{135}$, repeatedly apply this operation $2025$ times. What is the final resulting number? -",8,Number theory,Operation,Japan 2015 +",8,Number theory,IMO-Medium,Operation,Japan 2015 imo-bench-number_theory-078,"Find all nonnegative integers $n$ for which the following holds: \begin{center} $20^{n+1}$ is divisible by $n^3 + 4n^2 + 6n + 4$. \end{center} -","0,2,6",Number theory,Divisibility,Japan 2015 +","0,2,6",Number theory,IMO-Medium,Divisibility,Japan 2015 imo-bench-number_theory-079,"Define two sequences $\{a_n\}$ and $\{b_n\}$ as follows: \[ \begin{array}{lll} @@ -1325,58 +1325,58 @@ imo-bench-number_theory-079,"Define two sequences $\{a_n\}$ and $\{b_n\}$ as fol \end{array} \] Find all positive integers $n$ such that $a_{n+2} \cdot 42^{b_{2n}}$ is an integer. -",All positive integers,Number theory,Sequence,Korea 2015 (modified) +",All positive integers,Number theory,IMO-Medium,Sequence,Korea 2015 (modified) imo-bench-number_theory-080,"Let $p$ be a prime greater than $100$. Find the $9$th largest positive integer $n$ less than $p$ such that \[ nk + k \ge p \left\lfloor \frac{nk + n}{p} \right\rfloor \] -for all $k = 0, 1, \ldots, p - 2$.",$\lfloor \frac{p}{9} \rfloor$ ,Number theory,Number Theoretic Functions,RMM 2015 +for all $k = 0, 1, \ldots, p - 2$.",$\lfloor \frac{p}{9} \rfloor$ ,Number theory,IMO-Medium,Number Theoretic Functions,RMM 2015 imo-bench-number_theory-081,"Find all pairs of positive integers $(M, N)$ that satisfy $M \ge 2014$, $N \ge 4028$, and $\binom{M}{2014} = \binom{N}{4028} \times \frac{4028!}{2014!}$. -",no solutions,Number theory,Binomial,China TST 2014 ( modified) +",no solutions,Number theory,IMO-Hard,Binomial,China TST 2014 ( modified) imo-bench-number_theory-082,"Find the number of integer-coefficient polynomials $P$ that satisfy all of the following conditions: (1) $\deg P \le 3$, and all coefficients of $P$ are between $0$ and $2012$, inclusive. (2) $P(x) + P(-x)$ is a multiple of $2013$ for all positive integers $x$ less than or equal to $100$. (3) The remainders when $P(0), P(1), \dots, P(2012)$ are divided by $2013$ are all distinct. -",7200,Number theory,Polynomial,China Girl's MO 2014 +",7200,Number theory,IMO-Hard,Polynomial,China Girl's MO 2014 imo-bench-number_theory-083,"Let $K$ be a subset of $\{0, 1, \dots, 2020\}$ with $|K| \ge 3$. For any $p, q \in K$, there exists $r \in K$ such that $p+q-2r$ is a multiple of $2021$. Find all possible values of $|K|$. -","43,47,2021",Number theory,Set,China Girl's MO 2014 +","43,47,2021",Number theory,IMO-Hard,Set,China Girl's MO 2014 imo-bench-number_theory-084,"Find all integers $x$ such that $(8x-41)(x+3)^2$ is a perfect cube. -","5,-3",Number theory,Diophantine Equation,Greece 2014 +","5,-3",Number theory,IMO-Medium,Diophantine Equation,Greece 2014 imo-bench-number_theory-085,"For which integer $x$ from $1$ to $1717$ maximizes the number of positive integers $y$ for which $\frac{1}{x} + \frac{1}{y}$ is a unit fraction? -",1680,Number theory,Diophantine Equation,Hong Kong 2014 +",1680,Number theory,IMO-Medium,Diophantine Equation,Hong Kong 2014 imo-bench-number_theory-086,"Positive integers $M$ and $N$ satisfy the following conditions: (1) $M$ is a 1000-digit number, and none of its digits are 0. (2) The decimal expansion of $\left \lfloor \frac{M}{N} \right\rfloor$ contains the digit 0 exactly $A$ times. (The leading digit of the decimal expansion is not 0.) Find the maximum possible value of $A$. -",939,Number theory,Base and Digit,Japan 2014 +",939,Number theory,IMO-Medium,Base and Digit,Japan 2014 imo-bench-number_theory-087,"Let a number that can be expressed as $n^a + 1$ (where $a$ is a positive integer) for a positive integer $n$ be called an $n$-near number. Denote by $(B_1, T_1, S_1), \ldots, (B_k, T_k, S_k)$ all ordered triples $(B, T, S)$ such that $B + T = S$, where $B$ is a 2-near number, $T$ is a 3-near number, and $S$ is a 6-near number. Evaluate $\sum_{i=1}^k (B_i + T_i + S_i)$ -",162,Number theory,Representation,Japan TST 2014 +",162,Number theory,IMO-Hard,Representation,Japan TST 2014 imo-bench-number_theory-088,"For a positive integer $n$, find the sum of all $n$ such that the number of ordered pairs of positive integers $(a,b)$ where the greatest common divisor of $a$ and $b$ is $2023$ and the least common multiple of $a$ and $b$ is $n!$ does not exceed 4000. -",820,Number theory,Divisor,Hungary 1998 +",820,Number theory,IMO-Medium,Divisor,Hungary 1998 imo-bench-number_theory-089,"The incircle of a triangle with side lengths that are three consecutive integers is a unit circle. Find all possible values for the perimeter of the triangle. -",12,Number theory,Diophantine Equation,Russia 1998 +",12,Number theory,IMO-Medium,Diophantine Equation,Russia 1998 imo-bench-number_theory-090,"Let $n > 12345$ be a prime number. Let $P$ be the set of all bijections from $\{1, 2, \dots, n\}$ to itself. Let $Q$ be a subset of $P$ such that for any two elements $\tau, \sigma \in Q$, the number of $1 \le x \le n$ such that $\tau(x) = \sigma(x)$ is at least 2. Find the maximum possible value of $|Q|$. -",$(n-2)!$,Number theory,Other,Iran 2004 -imo-bench-number_theory-091,"A finite set $U$ of positive integers such that $|U|\ge 3$ is called a \textit{good set} if the greatest common divisor of any three distinct elements of $U$ is $1$, and for any two distinct elements of $U$, there exists another element that is a divisor of their product. A positive integer $m$ is called a \textit{good number} if there exists a good set $U$ such that $m$ is the product of elements of $U$. Find the $20$th smallest good number.",1600,Number theory,Set,Iran 2011 +",$(n-2)!$,Number theory,IMO-Hard,Other,Iran 2004 +imo-bench-number_theory-091,"A finite set $U$ of positive integers such that $|U|\ge 3$ is called a \textit{good set} if the greatest common divisor of any three distinct elements of $U$ is $1$, and for any two distinct elements of $U$, there exists another element that is a divisor of their product. A positive integer $m$ is called a \textit{good number} if there exists a good set $U$ such that $m$ is the product of elements of $U$. Find the $20$th smallest good number.",1600,Number theory,IMO-Hard,Set,Iran 2011 imo-bench-number_theory-092,"Given distinct primes $p