---
# System prepended metadata

title: rit/wit
tags: [codebook]

---

---
tags: codebook
---

# rit/wit

## C++14(up)
```cpp=
#include<iostream>
#include<vector>
#include<cctype>
#include<limits>
#include<algorithm>
using namespace std;
template<typename T>
bool rit(T& x) {
	cout << "no speed up" << endl;
	return bool(cin >> x);
}
template<>
bool rit<int>(int& ret) {
	ret = 0; bool b = false; char c = cin.rdbuf()->sbumpc();
	while (!isdigit(c)) {
		if (c == EOF)
			return false;
		b = (c == '-' ? true : b);
		c = cin.rdbuf()->sbumpc();
	}
	while (isdigit(c))
		ret = ret * 10 + c - '0', c = cin.rdbuf()->sbumpc();
	ret = b ? -ret : ret;
	return true;
}
template<>
bool rit<long long>(long long& ret) {
	ret = 0; bool b = false; char c = cin.rdbuf()->sbumpc();
	while (!isdigit(c)) {
		if (c == EOF)
			return false;
		b = (c == '-' ? true : b);
		c = cin.rdbuf()->sbumpc();
	}
	while (isdigit(c))
		ret = ret * 10 + c - '0', c = cin.rdbuf()->sbumpc();
	ret = b ? -ret : ret;
	return true;
}
template<>
bool rit<unsigned>(unsigned& re) {
	re = 0; char c = cin.rdbuf()->sbumpc();
	while (!isdigit(c)) {
		if (c == EOF)
			return false;
		c = cin.rdbuf()->sbumpc();
	}
	while (isdigit(c))
		re = re * 10 + c - '0', c = cin.rdbuf()->sbumpc();
	return true;
}
template<>
bool rit<unsigned long long>(unsigned long long& re) {
	re = 0; char c = cin.rdbuf()->sbumpc();
	while (!isdigit(c)) {
		if (c == EOF)
			return false;
		c = cin.rdbuf()->sbumpc();
	}
	while (isdigit(c))
		re = re * 10 + c - '0', c = cin.rdbuf()->sbumpc();
	return true;
}
/*
template<typename...Args>
void scan(Args&...args) {
	(rit(args), ...);
}
*/
template<typename... Args>
void scan(Args&... args) {
	initializer_list<bool> {(rit(args), false)...};
}

template<typename T>
void wit(T&& x) {
	cout << x;
}
template<>
void wit<char>(char&& x) {
	cout.rdbuf()->sputc(x);
}
template<>
void wit<int>(int&& x) {
	if (!x) cout.rdbuf()->sputc('0');
	char tmp[10]; int cnt = 0; bool b = false;
	if (x & numeric_limits<int>::min()) tmp[cnt++] = -(x % 10) + '0', x /= -10, b = true;
	while (x) tmp[cnt++] = x % 10 + '0', x /= 10;
	if (b) cout.rdbuf()->sputc('-');
	while (cnt--) cout.rdbuf()->sputc(tmp[cnt]);
}
template<>
void wit<long long>(long long&& x) {
	if (!x) cout.rdbuf()->sputc('0');
	char tmp[19]; int cnt = 0; bool b = false;
	if (x & numeric_limits<long long>::min()) tmp[cnt++] = -(x % 10) + '0', x /= -10, b = true;
	while (x) tmp[cnt++] = x % 10 + '0', x /= 10;
	if (b) cout.rdbuf()->sputc('-');
	while (cnt--) cout.rdbuf()->sputc(tmp[cnt]);
}
template<>
void wit<unsigned>(unsigned&& x) {
	if (!x) cout.rdbuf()->sputc('0');
	char tmp[10]; int cnt = 0;
	while (x) tmp[cnt++] = x % 10 + '0', x /= 10;
	while (cnt--) cout.rdbuf()->sputc(tmp[cnt]);
}
template<>
void wit<unsigned long long>(unsigned long long&& x) {
	if (!x) cout.rdbuf()->sputc('0');
	char tmp[19]; int cnt = 0;
	while (x) tmp[cnt++] = x % 10 + '0', x /= 10;
	while (cnt--) cout.rdbuf()->sputc(tmp[cnt]);
}
/*
template<typename ...Args>
void print(Args&&... args) {
	(wit(args), ...), wit('\n');
}
*/
template<typename... Args>
void print(Args... args) {
	initializer_list<bool> {(wit(args), false)...};
	wit('\n');
}
ostream& operator<<(ostream& os, const vector<auto>& v) {
	for (const auto& i : v)
		wit(i), wit(' ');
	return os;
}
ostream& operator<<(ostream& os, const pair<auto, auto>& p) {
	wit(p.first), wit(' '), wit(p.second), wit('\n');
	return os;
}
/*
ostream& operator<<(ostream& os, const vector<pair<auto, auto>>& v) {
	for (const auto& [i, j] : v)
		wit(i), wit(' '), wit(j), wit(' ');
	return os;
}
*/
ostream& operator<<(ostream& os, const vector<pair<auto, auto>>& v) {
	for (const auto& i : v)
		wit(i.first), wit(' '), wit(i.second), wit(' ');
	return os;
}
istream& operator>>(istream& is, vector<auto>& v) {
	for (auto& i : v)
		rit(i);
	return is;
}
istream& operator>>(istream& is, pair<auto, auto>& p) {
	rit(p.first), rit(p.second);
	return is;
}
/*
istream& operator>>(istream& is, vector<pair<auto, auto>>& v) {
	for (auto& [i, j] : v)
		rit(i), rit(j);
	return is;
}
*/
istream& operator>>(istream& is, vector<pair<auto, auto>>& v) {
	for (auto& i : v)
		rit(i.first), rit(i.second);
	return is;
}
int main() {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; rit(n);
	vector<int> v(n);
	for (auto& i : v)
		rit(i);
	sort(v.begin(), v.end());
	for (auto && i : v)
		wit(i), wit(' ');
	return 0;
}
```


## C++17(up)

```cpp=
#include<iostream>
#include<vector>
#include<cctype>
#include<limits>
#include<algorithm>
using namespace std;
template<typename T>
bool rit(T& x) {
	cout << "no speed up" << endl;
	return bool(cin >> x);
}
template<>
bool rit<int>(int& ret) {
	ret = 0; bool b = false; char c = cin.rdbuf()->sbumpc();
	while (!isdigit(c)) {
		if (c == EOF)
			return false;
		b = (c == '-' ? true : b);
		c = cin.rdbuf()->sbumpc();
	}
	while (isdigit(c))
		ret = ret * 10 + c - '0', c = cin.rdbuf()->sbumpc();
	ret = b ? -ret : ret;
	return true;
}
template<>
bool rit<long long>(long long& ret) {
	ret = 0; bool b = false; char c = cin.rdbuf()->sbumpc();
	while (!isdigit(c)) {
		if (c == EOF)
			return false;
		b = (c == '-' ? true : b);
		c = cin.rdbuf()->sbumpc();
	}
	while (isdigit(c))
		ret = ret * 10 + c - '0', c = cin.rdbuf()->sbumpc();
	ret = b ? -ret : ret;
	return true;
}
template<>
bool rit<unsigned>(unsigned& re) {
	re = 0; char c = cin.rdbuf()->sbumpc();
	while (!isdigit(c)) {
		if (c == EOF)
			return false;
		c = cin.rdbuf()->sbumpc();
	}
	while (isdigit(c))
		re = re * 10 + c - '0', c = cin.rdbuf()->sbumpc();
	return true;
}
template<>
bool rit<unsigned long long>(unsigned long long& re) {
	re = 0; char c = cin.rdbuf()->sbumpc();
	while (!isdigit(c)) {
		if (c == EOF)
			return false;
		c = cin.rdbuf()->sbumpc();
	}
	while (isdigit(c))
		re = re * 10 + c - '0', c = cin.rdbuf()->sbumpc();
	return true;
}
template<typename...Args>
void scan(Args&...args) {
	(rit(args), ...);
}
template<typename T>
void wit(T&& x) {
	cout << x;
}
template<>
void wit<char>(char&& x) {
	cout.rdbuf()->sputc(x);
}
template<>
void wit<int>(int&& x) {
	if (!x) cout.rdbuf()->sputc('0');
	char tmp[10]; int cnt = 0; bool b = false;
	if (x & numeric_limits<int>::min()) tmp[cnt++] = -(x % 10) + '0', x /= -10, b = true;
	while (x) tmp[cnt++] = x % 10 + '0', x /= 10;
	if (b) cout.rdbuf()->sputc('-');
	while (cnt--) cout.rdbuf()->sputc(tmp[cnt]);
}
template<>
void wit<long long>(long long&& x) {
	if (!x) cout.rdbuf()->sputc('0');
	char tmp[19]; int cnt = 0; bool b = false;
	if (x & numeric_limits<long long>::min()) tmp[cnt++] = -(x % 10) + '0', x /= -10, b = true;
	while (x) tmp[cnt++] = x % 10 + '0', x /= 10;
	if (b) cout.rdbuf()->sputc('-');
	while (cnt--) cout.rdbuf()->sputc(tmp[cnt]);
}
template<>
void wit<unsigned>(unsigned&& x) {
	if (!x) cout.rdbuf()->sputc('0');
	char tmp[10]; int cnt = 0;
	while (x) tmp[cnt++] = x % 10 + '0', x /= 10;
	while (cnt--) cout.rdbuf()->sputc(tmp[cnt]);
}
template<>
void wit<unsigned long long>(unsigned long long&& x) {
	if (!x) cout.rdbuf()->sputc('0');
	char tmp[19]; int cnt = 0;
	while (x) tmp[cnt++] = x % 10 + '0', x /= 10;
	while (cnt--) cout.rdbuf()->sputc(tmp[cnt]);
}
template<typename ...Args>
void print(Args&&... args) {
	(wit(args), ...), wit('\n');
}
ostream& operator<<(ostream& os, const vector<auto>& v) {
	for (const auto& i : v)
		wit(i), wit(' ');
	return os;
}
ostream& operator<<(ostream& os, const pair<auto, auto>& p) {
	wit(p.first), wit(' '), wit(p.second), wit('\n');
	return os;
}

ostream& operator<<(ostream& os, const vector<pair<auto, auto>>& v) {
	for (const auto& [i, j] : v)
		wit(i), wit(' '), wit(j), wit(' ');
	return os;
}
istream& operator>>(istream& is, vector<auto>& v) {
	for (auto& i : v)
		rit(i);
	return is;
}
istream& operator>>(istream& is, pair<auto, auto>& p) {
	rit(p.first), rit(p.second);
	return is;
}
istream& operator>>(istream& is, vector<pair<auto, auto>>& v) {
	for (auto& [i, j] : v)
		rit(i), rit(j);
	return is;
}
int main() {
	cin.tie(nullptr);
	cout.tie(nullptr);
	ios::sync_with_stdio(false);
	int n; rit(n);
	vector<int> v(n);
	for (auto& i : v)
		rit(i);
	sort(v.begin(), v.end());
	for (auto && i : v)
		wit(i), wit(' ');
	return 0;
}
```