#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

int main() {
    char s[100001];
    scanf("%s", s);

    //
    bool answer = true;
    int cnt = 0;
    for (int i=0; s[i] != '\0'; i++) {
        if (s[i] == '(')
            cnt++;
        else
            cnt--;

        if (cnt < 0) {
            answer = false;
            break;
        }
    }

    if (cnt != 0)
        answer = false;

    printf("%d", answer);

    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: