What is this Fast I/O code than printf() & scanf() in c++???

In many solution of problems i have noticed that many users use some kind of code for Fast I/O technique which made their execution a lot faster than usual despite of having same logic??
For e.g.
above code execution time was 0.09!!
and this my code:
with execution time of 0.79!!
This is a lot of difference which occurred only due to printf() & scanf() vs. some Fast I/0 Code??

Not 100% sure , but basically the difference is that Printf is a generic function made to recognize various format, data types and to extract that from the input, here it directly reads the stream in the raw form, and you are responsible for extracting the information required. Hence you save a lot of overheads, which add time.


How are we able to save the overheads could u explain it please?I understand that we’re extracting the data in raw form and then extracting the required information but this also is taking time isn’t it?

1 Like

The same thing is discussed over here. Please read it.

why negative input gives positive output if printed as it is suing the fast input methods???

fast IO in C++

      inline void read(int &x){

        register char c=gc();
        for(;c<'0' || c>'9';c=gc());
         for(;c>='0' && c<='9';c=gc())
      inline void write(int x){

         register char buffor[35];
         register int i=0;
            } while(x);
            while(i>=0) putchar_unlocked(buffor[i--]);