<commit_before>#include <stdio.h>
#include <stdlib.h>
#include "stack.h"

void push(struct stack **list, int number) {
    struct stack *new_node = NULL;

    new_node = malloc(sizeof(*new_node));
    new_node->number = number;
    new_node->next = NULL;

    if (*list == NULL) {
        *list = new_node;
    } else {
        struct stack *it = *list;

        while (it->next != NULL) {
            it = it->next;
        }
        it->next = new_node;
    }
}

struct stack *pop(struct stack **list) {
    struct stack *it = *list;
    struct stack *node = NULL;

    while (it->next != NULL && it->next->next != NULL) {
        it = it->next;
    }
    node = it->next;
    it->next = NULL;
    return node;
}

void printStack(struct stack *list) {
    if (list == NULL) {
        printf("The stack is empty\n");
        exit(0);
    }
    while (list != NULL) {
        printf("%d\n", list->number);
        list = list->next;
    }
}
<commit_msg>Change stack time complexity from O(n) to O(1)<commit_after>#include <stdio.h>
#include <stdlib.h>
#include "stack.h"

void push(struct stack **list, int number) {
    struct stack *new_node = NULL;

    new_node = malloc(sizeof(*new_node));
    new_node->number = number;
    new_node->next = NULL;

    if (*list == NULL) {
        *list = new_node;
    } else {
        new_node->next = *list;
        *list = new_node;
    }
}

struct stack *pop(struct stack **list) {
    if (list == NULL) {
        return NULL;
    }
    struct stack *node = *list;
    struct stack *head = (*list)->next;
    (*list)->next = NULL;
    *list = head;
    return node;
}

void printStack(struct stack *list) {
    if (list == NULL) {
        printf("The stack is empty\n");
        exit(0);
    }
    while (list != NULL) {
        printf("%d\n", list->number);
        list = list->next;
    }
}

{'fraction_non_alphanumeric': 0.16104461371055495, 'fraction_numerical': 0.001632208922742111, 'mean_word_length': 2.170689655172414, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, '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': '7097037', 'n_tokens_mistral': 636, 'n_tokens_neox': 622, 'n_words': 166}