#include "_.h"

int main(int argc, char **argv) {
	
    if (argc != 2)
        return 1;

    char *input = argv[1];
    char **inputs = str_split(strdup(input), '\n');

    int *list_one = calloc(strlen(input) + 1, sizeof(int *));
    int *list_two = calloc(strlen(input) + 1, sizeof(int *));


    int i = 0;
    for (i = 0; inputs[i] != NULL; i++) {
        char **inputs_int = str_split(strdup(inputs[i]), ' ');
        list_one[i] = atoi(inputs_int[0]);
        list_two[i] = atoi(inputs_int[1]);
    }

    list_one[i] = -2;
    list_two[i] = -2;

    int number = 0;

    for (i = 0; list_one[i] != -2; i++) {
        int time = 0;
        for (int j = 0; list_two[j] != -2; j++) {
            if (list_two[j] == list_one[i])
                time++;
        }

        number += list_one[i] * time;
    }

    printf("number: %d\n", number);

    return 0;
}
