(edit because of formatting issues. How do you use newline in cf posts anyway?) ``↵
↵
I have some beginner friends and people asking me how to do multi-testcase format and how to use fast I/O for different languages so I suppose I will just put it here for newbies-and-unrated-people-who-aren't-familiar-to-this-yet's reference. Apparently it's more of not understanding how multi-testcase / fast IO works rather than not knowing how to code it. It's a lot easier to explain using code.↵
↵
#### C++ 17 (also known as the Andersons' format):↵
~~~~~↵
(#inlcude <bits/stdc++.h>↵
using namespace std;)↵
↵
void solve(){↵
//insert code here↵
}↵
↵
signed main (void){↵
int N; cin >> N;↵
for (int l=0; l < N; l++){↵
solve();↵
}↵
}↵
~~~~~↵
↵
Fast I/O↵
↵
~~~~~↵
#inlcude <bits/stdc++.h>↵
using namespace std;↵
void fastscan([your type] &number){↵
bool negative = false;↵
register [your type] c;↵
number = 0;↵
c = _getchar_nolock();↵
if (c=='-'){↵
negative = true;↵
c = _getchar_nolock();↵
}↵
for (; (c>47 && c<58); c=_getchar_nolock())↵
number = number *10 + c — 48;↵
if (negative)↵
number *= -1;↵
}↵
↵
signed main (void){↵
ios_base::sync_with_stdio(false);↵
cin.tie(NULL);↵
int N; cin >> N;↵
for (int l=0; l < N; l++){↵
solve();↵
}↵
}↵
~~~~~↵
↵
Note that this may vary, I used geany `_getchar_nolock`. The more recognized version should be `getchar_unlocked`.↵
↵
↵
#### Kotlin:↵
~~~~~↵
fun main() {↵
val br = System.`in`.bufferedReader()↵
val pw = System.out.bufferedWriter() //these two lines are the fast output/inputs↵
↵
val n = br.readLine().toInt() //the umber of testcases are usually in one line↵
repeat(times = n){↵
//insert code here↵
}↵
pw.flush()↵
}↵
~~~~~↵
#### Python: (one of my less used languages and thus I don't know much about it's fast I/O)↵
~~~~~↵
def solve():↵
#insert code↵
↵
t = int(input().strip())↵
for _ in range(t):↵
solve() ↵
~~~~~↵
I am probably one of the less qualified people to teach you guys but I'll be glad if this helps :D↵
I'm quite interested in how this will work for js since when I prompted deepseek it gave a very long and weird response. I will appreciate it if someone can explain in the comments. ↵
↵
I have some beginner friends and people asking me how to do multi-testcase format and how to use fast I/O for different languages so I suppose I will just put it here for newbies-and-unrated-people-who-aren't-familiar-to-this-yet's reference. Apparently it's more of not understanding how multi-testcase / fast IO works rather than not knowing how to code it. It's a lot easier to explain using code.↵
↵
#### C++ 17 (also known as the Andersons' format):↵
~~~~~↵
using namespace std;
↵
void solve(){↵
//insert code here↵
}↵
↵
signed main (void){↵
int N; cin >> N;↵
for (int l=0; l < N; l++){↵
solve();↵
}↵
}↵
~~~~~↵
↵
Fast I/O↵
↵
~~~~~↵
#inlcude <bits/stdc++.h>↵
using namespace std;↵
void fastscan([your type] &number){↵
bool negative = false;↵
register [your type] c;↵
number = 0;↵
c = _getchar_nolock();↵
if (c=='-'){↵
negative = true;↵
c = _getchar_nolock();↵
}↵
for (; (c>47 && c<58); c=_getchar_nolock())↵
number = number *10 + c — 48;↵
if (negative)↵
number *= -1;↵
}↵
↵
signed main (void){↵
ios_base::sync_with_stdio(false);↵
cin.tie(NULL);↵
int N; cin >> N;↵
for (int l=0; l < N; l++){↵
solve();↵
}↵
}↵
~~~~~↵
↵
Note that this may vary, I used geany `_getchar_nolock`. The more recognized version should be `getchar_unlocked`.↵
↵
↵
#### Kotlin:↵
~~~~~↵
fun main() {↵
val br = System.`in`.bufferedReader()↵
val pw = System.out.bufferedWriter() //these two lines are the fast output/inputs↵
↵
val n = br.readLine().toInt() //the umber of testcases are usually in one line↵
repeat(times = n){↵
//insert code here↵
}↵
pw.flush()↵
}↵
~~~~~↵
#### Python: (one of my less used languages and thus I don't know much about it's fast I/O)↵
~~~~~↵
def solve():↵
#insert code↵
↵
t = int(input().strip())↵
for _ in range(t):↵
solve() ↵
~~~~~↵
I am probably one of the less qualified people to teach you guys but I'll be glad if this helps :D↵
I'm quite interested in how this will work for js since when I prompted deepseek it gave a very long and weird response. I will appreciate it if someone can explain in the comments. ↵




