Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://github.com/github/linguist/blob/master/docs/overrides.md#using-gitattributes
website/** linguist-vendored
*.py linguist-vendored
*.sh linguist-vendored
41 changes: 41 additions & 0 deletions .github/workflows/gh_pages_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy Docusaurus to GitHub Pages

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "lts/krypton"

- name: Navigate to website folder
working-directory: ./website
run: echo "Now in the website directory."

- name: Install dependencies
working-directory: ./website
run: npm install

- name: Build Docusaurus
working-directory: ./website
run: npm run build

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./website/build
publish_branch: gh-pages

- name: Notify success
run: echo "Deployment successful on GitHub Pages."
289 changes: 199 additions & 90 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion misc/misc_cond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ template<typename T>
inline bool between(T a, T b, T c) { return (a <= b && b <= c); }
// #define between(a, b, c) ((a) <= (b) && (b) <= (c))
#define has_key(it, key) (it.find(key) != it.end())
#define check_coord(x, y, n, m) (0 <=x && x < n && 0 <= y && y < m)
#define check_coord(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
3 changes: 3 additions & 0 deletions website/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/github/linguist/blob/master/docs/overrides.md#using-gitattributes
*.css linguist-vendored
*.js linguist-vendored
20 changes: 20 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
1 change: 1 addition & 0 deletions website/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/krypton
21 changes: 21 additions & 0 deletions website/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Luis Miguel Báez

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Website

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

## Quick Start

First, ensure you're using the correct Node.js version:

```bash
nvm install
nvm use
```

### Installation

```
npm install
```

### Local Development

```
npm start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
npm run build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

Using SSH:

```
USE_SSH=true npm run deploy
```

Not using SSH:

```
GIT_USER=<Your GitHub username> npm run deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
3 changes: 3 additions & 0 deletions website/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
7 changes: 7 additions & 0 deletions website/docs/c-cpp/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "C/C++",
"position": 2,
"link": {
"type": "generated-index"
}
}
37 changes: 37 additions & 0 deletions website/docs/c-cpp/compilation-io-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
sidebar_position: 1
title: Compilation IO Guide
sidebar_label: Compilation IO Guide
---

## Compile and Execute C++ Program with Input and Output Redirection

**Standard**
```bash
g++-14 -std=c++17 -Wall -O2 -fno-sanitize-recover -o A A.cpp
```

**Debug**
```bash
g++-14 -std=c++17 -DDEBUG -Wall -O2 -fno-sanitize-recover -o A A.cpp
```

**Running**
```bash
./A < A.in > A.out
```

### Explanation
This command compiles and executes a C++ program, redirecting the input and output to specific files. Below is a breakdown of the command: _(Useful for competitive programming)_

- `g++-14`: Specifies the version of the GNU C++ Compiler, in this case, version 14.
- `-std=c++17`: Instructs the compiler to use the C++17 standard for compilation.
- `-Wall`: Enables all compiler warnings, which helps in identifying potential issues.
- `-O2`: Activates a moderate level of optimization to improve the performance of the compiled program.
- `-fno-sanitize-recover`: Ensures the program stops execution immediately when encountering a sanitization error, instead of attempting to recover.
- `-DDEBUG`: Defines the macro `DEBUG`, enabling any conditional compilation sections related to debugging within the source code.
- `-o A`: Specifies that the output executable file will be named `A`.
- `A.cpp`: The source file to be compiled.
- `./A < A.in > A.out`: Executes the compiled program, reading input from the file `A.in` and writing the output to the file `A.out`.

This method is efficient for running programs with predefined input and capturing the output into a file for further analysis or documentation purposes.
43 changes: 43 additions & 0 deletions website/docs/c-cpp/measuring-execution-time.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
sidebar_position: 3
title: Measuring Execution Time in C++
sidebar_label: Measuring Execution Time
---

## Measuring Execution Time in C++

This simple example shows how to measure the execution time of a block of code using the `<chrono>` library.

### Code Example

```cpp
// #include <chrono>

auto start = chrono::high_resolution_clock::now();

// CODE TO BE MEASURED
// Example: for (int i = 0; i < 1000000; ++i) {}

auto end = chrono::high_resolution_clock::now();

chrono::duration<double, milli> duration = end - start;
cout << "Execution time: " << duration.count() << " ms" << endl;
```

### Explanation

* `chrono::high_resolution_clock::now()`
Captures the current high-precision timestamp (start and end).

* `end - start`
Calculates the elapsed time between the two timestamps.

* `chrono::duration<double, milli>`
Converts the time difference into **milliseconds**.

* `duration.count()`
Returns the numerical value of the elapsed time, which is printed to the console.

### Tip

You can replace the comment `// CODE TO BE MEASURED` with any operation you want to benchmark — for example, loops, function calls, or algorithm executions.
53 changes: 53 additions & 0 deletions website/docs/c-cpp/memory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
sidebar_position: 1
title: Memory Guide
sidebar_label: Memory Guide
---

## Limit Memory Usage with `ulimit` Command

The following commands allow you to limit the memory usage for your processes. These limits are specified in kilobytes (KB) and are useful for setting constraints during development, particularly for ensuring your programs do not exceed certain memory thresholds. Here’s how you can set and verify these limits:

```bash
ulimit -v 65536 # Limit memory to 64 MB
ulimit -v 131072 # Limit memory to 128 MB
ulimit -v 262144 # Limit memory to 256 MB
ulimit -v 524288 # Limit memory to 512 MB
ulimit -v 1048576 # Limit memory to 1 GB
ulimit -v 2097152 # Limit memory to 2 GB
ulimit -v 4194304 # Limit memory to 4 GB
ulimit -v 8388608 # Limit memory to 8 GB
ulimit -v 16777216 # Limit memory to 16 GB
ulimit -v 33554432 # Limit memory to 32 GB
```

You may find more details in the `ulimit` manual page using the command:

```bash
man ulimit
```

### Verify Current Limits

To check the current resource limits, you can execute the following command:

```bash
ulimit -a
```

### Memory Limits Table

The following table provides a reference for memory limits in both megabytes (MB) and kilobytes (KB):

| Memory (MB) | Memory (KB) |
|--------------|--------------|
| 64 MB | 65,536 KB |
| 128 MB | 131,072 KB |
| 256 MB | 262,144 KB |
| 512 MB | 524,288 KB |
| 1 GB | 1,048,576 KB |
| 2 GB | 2,097,152 KB |
| 4 GB | 4,194,304 KB |
| 8 GB | 8,388,608 KB |
| 16 GB | 16,777,216 KB|
| 32 GB | 33,554,432 KB|
Loading