<commit_before>// A broken quicksort program (there is a bug).
//
// This program parses a list of numbers and then sorts them, printing the
// result to standard out.
//
// Usage: ./brokenQuicksort 1 4 3 9 1
//        1 1 3 4 9

#include <stdio.h>
#include <cstdlib>

void swap(int* numbers, int a, int b) {
    int temp = numbers[a];
    numbers[a] = numbers[b];
    numbers[b] = temp;
}

int partition(int* numbers, int a, int b) {
    int pivot = numbers[b];
    while (a < b) {
        while (numbers[a] < pivot)
            a++;
        while (numbers[b] > pivot)
            b--;

        if (numbers[a] == numbers[b])
            a++;
        else if (a < b)
            swap(numbers, a, b);

    }
    return b;
}

void quicksort(int* numbers, int a, int b) {
    if (a < b) {
        int m = partition(numbers, a, b);
        quicksort(numbers, a, m - 1);
        quicksort(numbers, m + 1, b);
        if (numbers[a] == 5) // BUG!
            swap(numbers, a, b);
    }
}

void sort(int* numbers, int count) {
    quicksort(numbers, 0, count);
}

int main(int argc, char *argv[]) {
    int numArgs = argc - 1;
    if (numArgs <= 1) {
        fprintf(stderr, "Run with a list of numbers to sort them.\n");<commit_msg>Ha, fix a bug with single inputs in the brokenQuicksort example<commit_after>// A broken quicksort program (there is a bug).
//
// This program parses a list of numbers and then sorts them, printing the
// result to standard out.
//
// Usage: ./brokenQuicksort 1 4 3 9 1
//        1 1 3 4 9

#include <stdio.h>
#include <cstdlib>

void swap(int* numbers, int a, int b) {
    int temp = numbers[a];
    numbers[a] = numbers[b];
    numbers[b] = temp;
}

int partition(int* numbers, int a, int b) {
    int pivot = numbers[b];
    while (a < b) {
        while (numbers[a] < pivot)
            a++;
        while (numbers[b] > pivot)
            b--;
        if (numbers[a] == numbers[b])
            a++;
        else if (a < b)
            swap(numbers, a, b);
    }
    return b;
}

void quicksort(int* numbers, int a, int b) {
    if (a < b) {
        int m = partition(numbers, a, b);
        quicksort(numbers, a, m - 1);
        quicksort(numbers, m + 1, b);
        if (numbers[a] == 5) // WARNING: THIS IS A BUG!
            swap(numbers, a, b);
    }
}

void sort(int* numbers, int count) {
    quicksort(numbers, 0, count);
}

int main(int argc, char *argv[]) {
    int numArgs = argc - 1;
    if (numArgs < 1) {
        fprintf(stderr, "Run with a list of numbers to sort them.\n");
{'fraction_non_alphanumeric': 0.14575059571088164, 'fraction_numerical': 0.012708498808578236, 'mean_word_length': 2.0312876052948257, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7649659', 'n_tokens_mistral': 919, 'n_tokens_neox': 864, 'n_words': 313}