size_t base20(unsigned int n, uint8_t *out) {
    
    uint8_t *start = out;
    do {*out++ = n % 20;} while (n /= 20);
    size_t length = out - start;

    
    while (out > start) {
        uint8_t x = *--out;
        *out = *start;
        *start++ = x;
    }
    return length;
}


void make_digit(int n, char *place, size_t line_length) {
    static const char *parts[] = {,,,,,};
    int i;

    
    for (i=4; i>0; i--, n -= 5)
        memcpy(place + i*line_length, parts[MAX(0, MIN(5, n))], 4);

    
    if (n == -20) place[4 * line_length + 1] = '@';
}


char *mayan(unsigned int n) {
    if (n == 0) return NULL; 

    uint8_t digits[15]; 
    size_t n_digits = base20(n, digits);

    
    size_t line_length = n_digits*5 + 2;

    
    char *str = malloc(line_length * 6 + 1);
    if (str == NULL) return NULL;
    str[line_length * 6] = 0;

    
    char *ptr;
    unsigned int i;
    
    for (ptr=str, i=0; i<line_length; i+=5, ptr+=5) 
        memcpy(ptr, , 5);
    memcpy(ptr-5, , 2);
    memcpy(str+5*line_length, str, line_length);
    
    for (ptr=str+line_length, i=0; i<line_length; i+=5, ptr+=5)
        memcpy(ptr, , 5);
    memcpy(ptr-5, , 2);
    memcpy(str+2*line_length, str+line_length, line_length);
    memcpy(str+3*line_length, str+line_length, 2*line_length);

    
    for (i=0; i<n_digits; i++)
        make_digit(digits[i], str+1+5*i, line_length);

    return str;
}

int main(int argc, char **argv) {
    if (argc != 2) {
        fprintf(stderr, );
        return 1;
    }
    int i = atoi(argv[1]);
    if (i <= 0) {
        fprintf(stderr, );
        return 1;
    }
    char *m = mayan(i);
    printf(,m);
    free(m);
    return 0;
}