static void OpenConsole()
{
int outHandle, errHandle, inHandle;
FILE *outFile, *errFile, *inFile;
AllocConsole();
CONSOLE_SCREEN_BUFFER_INFO coninfo;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
coninfo.dwSize.Y = 9999;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
outHandle = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
errHandle = _open_osfhandle((long)GetStdHandle(STD_ERROR_HANDLE),_O_TEXT);
inHandle = _open_osfhandle((long)GetStdHandle(STD_INPUT_HANDLE),_O_TEXT );
outFile = _fdopen(outHandle, "w" );
errFile = _fdopen(errHandle, "w");
inFile = _fdopen(inHandle, "r");
*stdout = *outFile;
*stderr = *errFile;
*stdin = *inFile;
setvbuf( stdout, NULL, _IONBF, 0 );
setvbuf( stderr, NULL, _IONBF, 0 );
setvbuf( stdin, NULL, _IONBF, 0 );
std::ios::sync_with_stdio();
}