iidai/codenet huggingface dataset:
Language: C

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

typedef long long int int64;

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) > (0) ? (a) : -(a))

int digit(int64 n) {
    int res = 0;
    while (n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

void run(void) {
    int64 n;
    scanf("%lld", &n);
    int min = digit(n);
    int i;
    for (i = 1; (int64)i * i <= n; i++) {
        if (n % i != 0) continue;
        int64 a = i;
        int64 b = n / i;
        min = MIN(min, MAX(digit(a), digit(b)));
    }
    printf("%d\n", min);
}

int main(void) {
    run();
    return 0;
}

Example test case(s):
input: 10000

output: 3
Language: C

#include <stdio.h>
int main() {
    int n;
    scanf("%d", &n);
    if (n % 1000 == 0)
        printf("%d\n", 0);
    else
        printf("%d\n", (n / 1000 + 1) * 1000 - n);
}

Example test case(s):
input: 1900

output: 100
Language: C

#include <stdio.h>

int main() {
    int a[1000], n, i, j, d = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    for (i = 0; i < n; i++) {
        for (j = n - 1; j >= i + 1; j--) {
            if (a[j] < a[j - 1]) {
                int temp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = temp;
                d++;
            }
        }
    }
    printf("%d", a[0]);
    for (i = 1; i < n; i++) {
        printf(" %d", a[i]);
    }
    printf("\n%d\n", d);
    return 0;
}

Example test case(s):
input: 5
5 3 2 4 1

output: 1 2 3 4 5
8
Language: C

#include <stdio.h>
#include <string.h>

int data[111111];
int seq[222222];

int max(int a, int b);

int main(void) {
    int n, k, t, i, p, ret = 0;

    while (1) {
        scanf("%d %d", &n, &k);
        if (!n && !k) break;

        memset(data, 0, sizeof(data));
        memset(seq, 0, sizeof(seq));

        for (i = 0; i < k; i++) {
            scanf("%d", &t);
            data[t]++;
        }

        p = 0;
        for (i = 1; i <= n; i++) {
            if (data[i]) {
                seq[p]++;
            } else {
                p += 2;
            }
        }
        p++;

        if (data[0]) {
            for (i = 0; i < p; i++) {
                ret = max(ret, seq[i] + seq[i + 2] + 1);
            }
        } else {
            for (i = 0; i < p; i++) {
                ret = max(ret, seq[i]);
            }
        }

        printf("%d\n", ret);
    }

    return 0;
}

int max(int a, int b) {
    if (a > b) {
        return a;
    }
    return b;
}

Example test case(s):
input: 7 5
6
2
4
7
1
7 5
6
2
0
4
7
0 0

output: 2
4
Language: C

#include <stdio.h>

#define N 200
#define SHIRO 0
#define HAI 1
#define KURO 2

void aaaaa();
void bbbbb(int);

int n, A[N][N];
int color[N], d[N], f[N];
int TT;

int main() {
    int u, k, v;
    int i, j;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            A[i][j] = 0;
        }
    }
    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        u--;
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            v--;
            A[u][v] = 1;
        }
    }

    aaaaa();

    return 0;
}

void aaaaa() {
    int u, i;

    for (i = 0; i < n; i++) {
        color[i] = SHIRO;
    }

    TT = 0;

    for (u = 0; u < n; u++) {
        if (color[u] == SHIRO) {
            bbbbb(u);
        }
    }

    for (i = 0; i < n; i++) {
        printf("%d %d %d\n", i + 1, d[i], f[i]);
    }
}

void bbbbb(int k) {
    int v;
    color[k] = HAI;
    TT++;
    d[k] = TT;
    for (v = 0; v < n; v++) {
        if (A[k][v] == 0) continue;
        if (color[v] == SHIRO) {
            bbbbb(v);
        }
    }
    color[k] = KURO;
    f[k] = ++TT;
}

Example test case(s):
input: 4
1 1 2
2 1 4
3 0
4 1 3

output: 1 1 8
2 2 7
3 4 5
4 3 6
Language: C

#include <stdio.h>

int main(void) {
    int n;
    unsigned long long int m;
    scanf("%d", &n);
    m = n;
    n--;
    for (; n > 1; n--) {
        m *= n;
    }
    printf("%lld\n", m);
    return 0;
}

Example test case(s):
input: 5

output: 120
Language: C

#include <stdio.h>

int main(void) {
    int S;
    scanf("%d", &S);

    if (S < 60) {
        printf("0:0:%d\n", S);
    }

    else if (S < 3600) {
        printf("0:%d:%d\n", (int)S / 60, S % 60);
    }

    else {
        printf("%d:%d:%d\n", (int)S / 3600, (int)(S % 3600) / 60,
               (S % 60) % 60);
    }
    return 0;
}

Example test case(s):
input: 46979

output: 13:2:59
Language: C

#include <stdio.h>

int main() {
    int N = 0;
    int R = 0;

    scanf("%d %d", &N, &R);

    if (N >= 10) {
        printf("%d\n", R);
    } else {
        printf("%d\n", R + 100 * (10 - N));
    }

    return 0;
}

Example test case(s):
input: 2 2919

output: 3719
Language: C

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

int top, S[10000];

void push(int x) { S[++top] = x; }

int pop() { return S[top--]; }

int main() {
    int a, b;
    char s[200];
    top = 0;

    while (scanf("%s", s) != EOF) {
        if (s[0] == '+') {
            b = pop();
            a = pop();
            push(a + b);
        } else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        } else if (s[0] == '*') {
            b = pop();
            a = pop();
            push(a * b);
        } else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());
    return 0;
}

Example test case(s):
input: 1 2 +

output: 3
Language: C

#include <stdio.h>

int main(void) {
    int i, a, b, s;
    int count[4];
    for (i = 0; i < 4; i++) count[i] = 0;
    for (i = 0; i < 3; i++) {
        scanf("%d %d", &a, &b);
        count[a - 1]++;
        count[b - 1]++;
    }
    s = 1;
    for (i = 0; i < 4; i++) s *= count[i];
    if (s == 4)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

Example test case(s):
input: 4 2
1 3
2 3

output: YES
Language: C

#include <stdio.h>

int main(void) {
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if (b > a * c) {
        printf("%d\n", c);
    } else {
        printf("%d\n", b / a);
    }

    return 0;
}

Example test case(s):
input: 2 11 4

output: 4
Language: C

#include <stdio.h>

int main(void) {
    int n, k;
    scanf("%d%d", &n, &k);
    if (n % k == 0)
        printf("0\n");
    else
        printf("1\n");
    return 0;
}

Example test case(s):
input: 7 3

output: 1
Language: C

#include <stdio.h>
int main() {
    int m, n;
    int i, j;
    int A[100][100];
    int B[100];
    int S[100] = {0};

    scanf("%d %d", &m, &n);

    for (i = 0; i < m; i++) {
        for (j = 0; j < n - 1; j++) {
            scanf("%d ", &A[i][j]);
        }
        scanf("%d\n", &A[i][n - 1]);
    }

    for (i = 0; i < n; i++) {
        scanf("%d\n", &B[i]);
    }

    for (i = 0; i < m; i++) {
        for (j = 0; j < n; j++) {
            S[i] = S[i] + A[i][j] * B[j];
        }
    }

    for (i = 0; i < m; i++) {
        printf("%d\n", S[i]);
    }

    return 0;
}

Example test case(s):
input: 3 4
1 2 0 1
0 3 0 1
4 1 1 0
1
2
3
0

output: 5
6
9
Language: C

#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (key == A[mid]) return 1;
        if (key > A[mid])
            left = mid + 1;
        else if (key < A[mid])
            right = mid;
    }
    return 0;
}

int main(void) {
    int i, q, k, sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &k);
        if (binarySearch(k)) sum++;
    }
    printf("%d\n", sum);
    return 0;
}

Example test case(s):
input: 5
1 2 3 4 5
3
3 4 1

output: 3
Language: C

#include <stdio.h>
int main() {
    int in;
    int h, m, s;
    scanf("%d", &in);

    h = in / 3600;
    in %= 3600;

    m = in / 60;
    in %= 60;

    s = in;

    printf("%d:%d:%d\n", h, m, s);
}

Example test case(s):
input: 46979

output: 13:2:59
Language: C

#include <stdio.h>

int main(void) {
    char s[4], t[4];
    scanf("%s", s);
    scanf("%s", t);
    int hit = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) hit++;
    }
    printf("%d\n", hit);
    return 0;
}

Example test case(s):
input: CSS
CSR

output: 2
Language: C

#include <stdio.h>

int main() {
    int r, c, n, flag, cnt;
    int arr[16][16] = {0};

    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        flag = 1;
        r = (n + 1) / 2 + 1;
        c = (n + 1) / 2;
        arr[r][c] = cnt = 1;

        while (cnt != n * n + 1) {
            ++cnt;
            if (flag) {
                ++r;
                ++c;
                if (c > n) {
                    c = 1;
                }

                if (r > n) {
                    r = 1;
                }

                if (arr[r][c]) {
                    flag = 0;
                    --cnt;
                } else {
                    arr[r][c] = cnt;
                }
            } else {
                ++r;
                --c;
                if (c < 1) {
                    c = n;
                }

                if (r > n) {
                    r = 1;
                }

                if (arr[r][c]) {
                    flag = 0;
                } else {
                    arr[r][c] = cnt;
                    flag = 1;
                }
            }
        }

        for (r = 1; r < n + 1; r++) {
            for (c = 1; c < n + 1; c++) {
                printf("%4d", arr[r][c]);
                arr[r][c] = 0;
                if (c == n) {
                    printf("\n");
                }
            }
        }
    }

    return 0;
}

Example test case(s):
input: 3
5
0

output:    4   9   2
   3   5   7
   8   1   6
  11  24   7  20   3
   4  12  25   8  16
  17   5  13  21   9
  10  18   1  14  22
  23   6  19   2  15
Language: C

#include <stdio.h>

int main(void) {
    int n, sum;
    scanf("%d", &n);
    sum = (n * (n + 1)) / 2;
    printf("%d\n", sum);
    return 0;
}

Example test case(s):
input: 3

output: 6
Language: C

#include <stdio.h>

int c[26];

int main(void) {
    char str[1200];
    for (; scanf("%s", str) > 0;) {
        for (char *p = str; *p; p++) {
            if ('a' <= *p && *p <= 'z') {
                c[*p - 'a']++;
            } else if ('A' <= *p && *p <= 'Z') {
                c[*p - 'A']++;
            }
        }
    }
    for (int i = 0; i < 26; i++) {
        printf("%c : %d\n", 'a' + i, c[i]);
    }
    return 0;
}

Example test case(s):
input: This is a pen.

output: a : 1
b : 0
c : 0
d : 0
e : 1
f : 0
g : 0
h : 1
i : 2
j : 0
k : 0
l : 0
m : 0
n : 1
o : 0
p : 1
q : 0
r : 0
s : 2
t : 1
u : 0
v : 0
w : 0
x : 0
y : 0
z : 0
Language: C

#include <stdio.h>

#define PutChar(c)  \
    ;               \
    *p = (char)(c); \
    ++p;

#define MAX_N (2000001)
#define MAX_Ai (10001)
#define STR_SIZE (10000010)

int getNum(void);
void putNum(int n);
void CountingSort(int A[], int B[], int k, int len);

int A[MAX_N];
int B[MAX_N];
char str[STR_SIZE];
char *p = str;

int main(void) {
    register int i;
    int n;

    fread(str, 1, STR_SIZE, stdin);

    n = getNum();
    for (i = 1; i <= n; ++i) {
        A[i] = getNum();
    }

    CountingSort(A, B, MAX_Ai, n);

    p = str;
    --n;
    for (i = 1; i <= n; ++i) {
        putNum(B[i]);
        PutChar(' ');
    }
    putNum(B[i]);
    PutChar('\0');

    puts(str);

    return 0;
}

int getNum(void) {
    int n = 0;
    while ((*p >= '0') && (*p <= '9')) {
        n = n * 10 + (int)(*p - '0');
        ++p;
    }
    ++p;
    return n;
}

void putNum(int n) {
    int d;
    if (n < 10) {
        PutChar('0' + n);
        return;
    }
    d = n / 10;
    if (d) putNum(d);
    PutChar('0' + (n - (d * 10)));
}

void CountingSort(int A[], int B[], int k, int len) {
    int C[MAX_Ai] = {0};
    int i, j;
    for (j = 1; j <= len; ++j) {
        ++C[A[j]];
    }
    for (i = 1; i <= k; ++i) {
        C[i] += C[i - 1];
    }
    for (j = len; j > 0; --j) {
        B[C[A[j]]] = A[j];
        --C[A[j]];
    }
}

Example test case(s):
input: 7
2 5 1 3 2 3 0

output: 0 1 2 2 3 3 5
Language: C

#include <stdio.h>

#define M 100
#define whi 0
#define gra 1
#define bla 2

int n;
int T[M][M];
int color[M], d[M];
int Q[M], head = 0, tail = 0;

void enqueue(int x) {
    Q[tail] = x;
    tail = (tail + 1) % M;
}

int dequeue(void) {
    int x;
    x = Q[head];
    head = (head + 1) % M;
    return x;
}

void bfs(int s) {
    int i, u, v;

    for (i = 0; i < n; i++) {
        color[i] = whi;
        d[i] = 1000000;
    }

    color[s] = gra;
    d[s] = 0;
    enqueue(s);

    while (head != tail) {
        u = dequeue();
        for (v = 0; v < n; v++) {
            if (T[u][v] == 1 && color[v] == whi) {
                color[v] = gra;
                d[v] = d[u] + 1;
                enqueue(v);
            }
        }
        color[u] = bla;
    }
}

int main() {
    int i, j;
    int u, k, v;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            T[i][j] = 0;
        }
    }

    for (i = 0; i < n; i++) {
        scanf("%d %d", &u, &k);
        u--;
        for (j = 0; j < k; j++) {
            scanf("%d", &v);
            v--;
            T[u][v] = 1;
        }
    }

    bfs(0);

    for (i = 0; i < n; i++) {
        if (d[i] == 1000000) d[i] = -1;
        printf("%d %d\n", i + 1, d[i]);
    }

    return 0;
}

Example test case(s):
input: 4
1 2 2 4
2 1 4
3 0
4 1 3

output: 1 0
2 1
3 2
4 1
Language: C

#pragma warning(disable : 4996)
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_STRING 30
#define MAX_LINE 2000000
#define MAX_HUMAN 200000

char sLongInputLine[MAX_LINE + 1] = "";
int anComingSec[MAX_HUMAN];

int main() {
    char sInput[MAX_STRING + 1] = "";
    char* psWord = NULL;
    char* psInput = NULL;

    int nHumanNumber = 0;
    int nNextHumanIndex = 0;
    int nWaterLength = 0;
    int nWaterLife = 0;
    int nStart = 0;
    int nStop = 0;

    int nIndex = 0;
    int i = 0;
    int j = 0;

    fgets(sInput, MAX_STRING, stdin);
    if (strchr(sInput, '\n') != NULL) {
        sInput[strlen(sInput) - 1] = '\0';
    }
    psInput = strtok(sInput, " ");
    nHumanNumber = atoi(psInput);
    psInput = strtok(NULL, " ");
    nWaterLength = atoi(psInput);

    fgets(sLongInputLine, MAX_LINE, stdin);
    if (strchr(sLongInputLine, '\n') != NULL) {
        sLongInputLine[strlen(sLongInputLine) - 1] = '\0';
    }
    psInput = strtok(sLongInputLine, " ");
    for (i = 0; i < nHumanNumber; i++) {
        anComingSec[i] = atoi(psInput);
        psInput = strtok(NULL, " ");
    }

    nStart = anComingSec[0];

    while (nNextHumanIndex < nHumanNumber) {
        if (nNextHumanIndex == nHumanNumber) {
            break;
        } else {
            nStop = nStart + nWaterLength;
            if (anComingSec[nNextHumanIndex] < nStop) {
                while (nNextHumanIndex < nHumanNumber &&
                       anComingSec[nNextHumanIndex] < nStop) {
                    if (nStop <= anComingSec[nNextHumanIndex] + nWaterLength) {
                        nStop = anComingSec[nNextHumanIndex] + nWaterLength;
                        nNextHumanIndex++;
                    }
                }
                if (nNextHumanIndex == nHumanNumber) {
                    nWaterLife = nWaterLife + (nStop - nStart);
                    break;
                }
            }
            nWaterLife = nWaterLife + (nStop - nStart);
            nStart = nStop;
            if (nStart < anComingSec[nNextHumanIndex]) {
                nStart = anComingSec[nNextHumanIndex];
            }
        }
    }
    printf("%d\n", nWaterLife);

    return 0;
}

Example test case(s):
input: 2 4
0 3

output: 7
Language: C

#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int32_t nextint(void) {
    char c = getchar_unlocked();
    while (c != '-' && (c < '0' || '9' < c)) c = getchar_unlocked();
    bool s = false;
    if (c == '-') {
        s = true;
        c = getchar_unlocked();
    }
    uint32_t x = 0;
    while ('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar_unlocked();
    }
    return s ? -x : x;
}

int n;

int p(int a, int b) {
    if (a < b) {
        return a + b * n;
    } else {
        return b + a * n;
    }
}

int a[1000][999];

int e1[1000000];
int e2[1000000];
int d[1000000];
bool b[1000000];

int f(int from) {
    if (b[from]) return -1;
    if (d[from]) return d[from];
    b[from] = true;
    int to;
    to = e1[from];
    int max = 0;
    if (to != 0) {
        int now = f(to);
        if (now < 0) return now;
        if (now > max) max = now;
    }
    to = e2[from];
    if (to != 0) {
        int now = f(to);
        if (now < 0) return now;
        if (now > max) max = now;
    }
    b[from] = false;
    return d[from] = max + 1;
}

int main(void) {
    n = nextint();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            a[i][j] = nextint() - 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 2; j++) {
            int from = p(i, a[i][j]);
            int to = p(i, a[i][j + 1]);
            if (e1[from] == 0) {
                e1[from] = to;
            } else if (e2[from] == 0) {
                e2[from] = to;
            } else {
                puts("-1");
                return 0;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int from = p(i, a[i][0]);
        int now = f(from);
        if (now < 0) {
            ans = -1;
            break;
        }
        if (now > ans) ans = now;
    }
    printf("%d\n", ans);
}

Example test case(s):
input: 3
2 3
1 3
1 2

output: 3
Language: C

#include <stdio.h>
#define NIL -1
struct Node {
    int parent, left, right;
};
struct Node R[10000];
int n;
void preorder(int);
void inorder(int);
void postorder(int);

void preorder(int x) {
    if (x == NIL) return;
    printf(" %d", x);
    preorder(R[x].left);
    preorder(R[x].right);
}
void inorder(int x) {
    if (x == NIL) return;
    inorder(R[x].left);
    printf(" %d", x);
    inorder(R[x].right);
}
void postorder(int x) {
    if (x == NIL) return;
    postorder(R[x].left);
    postorder(R[x].right);
    printf(" %d", x);
}

int main() {
    int i, a, b, c, root;
    scanf("%d", &n);
    for (i = 0; i < n; i++) R[i].parent = NIL;
    for (i = 0; i < n; i++) {
        scanf("%d %d %d", &a, &b, &c);
        R[a].left = b;
        R[a].right = c;
        if (b != NIL) R[b].parent = a;
        if (c != NIL) R[c].parent = a;
    }
    for (i = 0; i < n; i++) {
        if (R[i].parent == NIL) root = i;
    }
    printf("Preorder\n");
    preorder(root);
    printf("\n");
    printf("Inorder\n");
    inorder(root);
    printf("\n");
    printf("Postorder\n");
    postorder(root);
    printf("\n");
    return 0;
}

Example test case(s):
input: 9
0 1 4
1 2 3
2 -1 -1
3 -1 -1
4 5 8
5 6 7
6 -1 -1
7 -1 -1
8 -1 -1

output: Preorder
 0 1 2 3 4 5 6 7 8
Inorder
 2 1 3 0 6 5 7 4 8
Postorder
 2 3 1 6 7 5 8 4 0
Language: C

#include <stdio.h>

main() {
    int a, b, mawari, menseki;

    scanf("%d %d", &a, &b);
    mawari = a + a + b + b;
    menseki = a * b;
    printf("%d %d\n", menseki, mawari);
    return 0;
}

Example test case(s):
input: 3 5

output: 15 16
Language: C

#include <stdio.h>

int main() {
    long int n, k, q;

    scanf("%ld%ld%ld", &n, &k, &q);

    int arr[n];
    for (long int i = 0; i <= n; i++) {
        arr[i] = 0;
    }

    for (long int i = 0; i < q; i++) {
        long int temp;
        scanf("%ld", &temp);
        arr[temp] += 1;
    }

    for (long int i = 1; i <= n; i++) {
        if (arr[i] > (q - k)) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }

    return 0;
}

Example test case(s):
input: 6 3 4
3
1
3
2

output: No
No
Yes
No
No
No
Language: C

#include <stdio.h>
int main() {
    int a, b, c, x, y;
    scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
    c *= 2;
    if (a + b <= c)
        printf("%d\n", a * x + b * y);
    else {
        if (x <= y) {
            if (b <= c)
                printf("%d\n", c * x + (y - x) * b);
            else
                printf("%d\n", c * y);
        } else {
            if (a <= c)
                printf("%d\n", c * y + (x - y) * a);
            else
                printf("%d\n", c * x);
        }
    }
    return 0;
}

Example test case(s):
input: 1500 2000 1600 3 2

output: 7900
Language: C

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

struct node {
    int key;
    struct node *p;
    struct node *l;
    struct node *r;
};

typedef struct node *NodePointer;

NodePointer r, NIL;

NodePointer find(NodePointer x, int k) {
    while (x != NIL && k != x->key) {
        if (k < x->key) {
            x = x->l;
        } else {
            x = x->r;
        }
    }
    return x;
}

void insert(int k) {
    NodePointer y = NIL;
    NodePointer x = r;

    NodePointer z = (NodePointer)malloc(sizeof(struct node));
    z->key = k;
    z->l = NIL;
    z->r = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->l;
        } else {
            x = x->r;
        }
    }
    z->p = y;

    if (y == NIL) {
        r = z;
    } else if (z->key < y->key) {
        y->l = z;
    } else {
        y->r = z;
    }
}

void inorder(NodePointer u) {
    if (u == NIL) {
        return;
    }
    inorder(u->l);
    printf(" %d", u->key);
    inorder(u->r);
}

void preorder(NodePointer u) {
    if (u == NIL) {
        return;
    }
    printf(" %d", u->key);
    preorder(u->l);
    preorder(u->r);
}

void print() {
    inorder(r);
    puts("");
    preorder(r);
    puts("");
}

int main() {
    int n, i, j, z, x;
    char s[10];

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s", s);
        if (s[0] == 'f') {
            scanf("%d", &x);
            NodePointer t = find(r, x);
            if (t == NIL)
                printf("no\n");
            else
                printf("yes\n");

        } else if (s[0] == 'i') {
            scanf("%d", &z);
            insert(z);
        } else {
            print();
        }
    }

    return 0;
}

Example test case(s):
input: 10
insert 30
insert 88
insert 12
insert 1
insert 20
find 12
insert 17
insert 25
find 16
print

output: yes
no
 1 12 17 20 25 30 88
 30 12 1 20 17 25 88
Language: C

#include <ctype.h>
#include <stdio.h>

int main() {
    int i, alpha[26];
    char ch;

    for (i = 0; i < 26; i++) alpha[i] = 0;

    while (1) {
        ch = getchar();
        if (ch == EOF) break;

        if (isalpha(ch)) {
            if (isupper(ch))
                alpha[ch - 65]++;
            else
                alpha[ch - 97]++;
        }
    }

    ch = 'a';
    for (i = 0; i < 26; i++, ch++) {
        printf("%c : %d\n", ch, alpha[i]);
    }
}

Example test case(s):
input: This is a pen.

output: a : 1
b : 0
c : 0
d : 0
e : 1
f : 0
g : 0
h : 1
i : 2
j : 0
k : 0
l : 0
m : 0
n : 1
o : 0
p : 1
q : 0
r : 0
s : 2
t : 1
u : 0
v : 0
w : 0
x : 0
y : 0
z : 0
Language: C

#include <stdio.h>
int linersearch(int[], int, int);

int main() {
    int i, n, s[100000], q, t, count = 0;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d", &s[i]);
    }

    scanf("%d", &q);

    for (i = 0; i < q; i++) {
        scanf("%d", &t);
        if (linersearch(s, n, t)) count++;
    }
    printf("%d\n", count);

    return 0;
}

int linersearch(int a[], int n, int key) {
    int i = 0;

    a[n] = key;

    while (a[i] != key) {
        i++;
    }
    return i != n;
}

Example test case(s):
input: 5
1 2 3 4 5
3
3 4 1

output: 3