文件输入输出

#define DEBUG
int main(){
    #ifdef DEBUG
	    freopen("input.in", "r", stdin);
	    //freopen("output.out", "w", stdout);
    #endif
    int n;
    scanf("%d",&n);
    //cout << "Hello world!" << endl;
    return 0;
 
}

程序计时

#include<iostream>
#include<ctime>
using namespace std;
#define DEBUG
int main(){
    int n;
    scanf("%d",&n);
    //cout << "Hello world!" << endl;
    #ifdef DEBUG
	    printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
    #endif
    return 0;
 
}

【丰衣足食】C++写一个对拍器(美其名曰评测机) - 知乎 (zhihu.com)