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

int main() {
    wchar_t 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 = GetOpenFileNameW(&ofn);
    if (!res) {
        puts("GetOpenFileNameW(...) failed!");
        exit(1);
    }

    char ansiFile[MAX_PATH];
    wcstombs(ansiFile, ofn.lpstrFile, MAX_PATH);

    FILE *f = fopen(ansiFile, "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;
}
