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

int main() {
    char file[MAX_PATH] = {0};
    
    OPENFILENAME ofn = {
        .lStructSize = sizeof(ofn),
        .lpstrFilter = "All Files\0*.*\0",
        .lpstrFile = file,
        .nMaxFile = MAX_PATH,
        .lpstrTitle = "Select File",
        .Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST
    };

    int res = GetOpenFileNameA(&ofn);

    if (!res) {
        puts("GetOpenFileNameA(...) failed!");
        exit(1);
    }

    FILE *f = fopen(ofn.lpstrFile, "r");
    if (!f) {
        perror("fopen(...)");
        exit(1);
    }

    long input;
    if (fscanf(f, "%ld", &input) != 1) {
        puts("fscanf(...) failed to scan input number");
        exit(1);
    }

    printf("%ld\n", 2 * input);
    return 0;
}
