Here is my code:
#include
void scan(int* i)
{
int t=0;
char c;
bool negative=false;
c=getchar_unlocked();
while(c<\'0
getchar_unlocked()
is mainly used for competitive programming, however, if you want to use this elsewhere, just make sure, only 1 thread is using it at a time.
Same applies to putchar_unlocked() function too.
It is a POSIX equivalent so Windows compiler doesn't support it.
However, you can use either of two-
1) Normal speed
int getchar_unlocked() { return getchar(); }
void putchar_unlocked(char _c) {return putchar(_c); }
2) Fast speed
int getchar_unlocked() { return _getchar_nolock(); }
void putchar_unlocked(char _c) { return _putchar_nolock(_c); }