C++読み込み最適化(入出力ストリームを閉じる)、ファイルからデータを読み、ファイルにデータを出力する


std::ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0); 


freopen("in.txt", "r", stdin);    //     ,    in.txt      
freopen("out.txt", "w", stdout);     //     ,        out.txt    
inline int read() {
    int f = 0, fu = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') fu = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}