#include <stdio.h>
#include <unistd.h>  // For sleep function

void philosopher_activity(int id) {
    printf("Philosopher %d has entered the room\n", id);
    printf("Philosopher %d is eating\n", id);
    sleep(1);  // Simulates eating
    printf("Philosopher %d has left the room\n", id);
}

int main() {
    int i;

    // Philosopher 0 enters, eats, and leaves first
    philosopher_activity(0);

    // Other philosophers enter but do not eat immediately
    for (i = 1; i <= 3; i++) {
        printf("Philosopher %d has entered the room\n", i);
    }

    // Philosopher 1 eats and leaves
    philosopher_activity(1);

    // Philosopher 2 eats and leaves
    philosopher_activity(2);

    // Philosopher 3 eats and leaves
    philosopher_activity(3);

    // Philosopher 4 enters, eats, and leaves
    philosopher_activity(4);

    return 0;
}
