#include<cstdio> using ll = longlong; inline ll read(){ ll S = 0, C = 0; char Y = getchar(); while (Y > 57 || Y < 48) C |= Y == 45, Y = getchar(); while (Y <= 57 && Y >= 48) S = (S << 3) + (S << 1) + Y - 48, Y = getchar(); return C ? -S : S; }
voideachT(){ int n = read(); printf("%d\n", n % 10 + n / 10); }
intmain(){ for (int T = read(); T--; eachT()); return0; }
#include<cstdio> using ll = longlong; inline ll read(){ ll S = 0, C = 0; char Y = getchar(); while (Y > 57 || Y < 48) C |= Y == 45, Y = getchar(); while (Y <= 57 && Y >= 48) S = (S << 3) + (S << 1) + Y - 48, Y = getchar(); return C ? -S : S; }
voideachT(){ int a1 = read(), a2 = read(), b1 = read(), b2 = read(); int res = 0; res += a1 > b1 and a2 > b2; res += a1 > b2 and a2 > b1;
res += a1 > b1 and a2 == b2; res += a2 > b1 and a1 == b2; res += a1 > b2 and a2 == b1; res += a2 > b2 and a1 == b1;
printf("%d\n", res * 2); }
intmain(){ for (int T = read(); T--; eachT()); return0; }
#include<cstdio> #include<vector> using ll = longlong; using pii = std::pair<int, int>; inline ll read(){ ll S = 0, C = 0; char Y = getchar(); while (Y > 57 || Y < 48) C |= Y == 45, Y = getchar(); while (Y <= 57 && Y >= 48) S = (S << 3) + (S << 1) + Y - 48, Y = getchar(); return C ? -S : S; }
voideachT(){ int n = read(), s = read(), m = read();
std::vector<pii> a(n + 1); for (int i = 1; i <= n; ++i) { a[i - 1].second = read(); a[i].first = read(); } a[n].second = m;
for (int i = 0; i <= n; ++i) { if (a[i].second - a[i].first >= s) { printf("YES\n"); return; } } printf("NO\n"); return; }
intmain(){ for (int T = read(); T--; eachT()); return0; }
#include<cstdio> #include<algorithm> #include<vector> using ll = longlong; using pii = std::pair<int, int>; inline ll read(){ ll S = 0, C = 0; char Y = getchar(); while (Y > 57 || Y < 48) C |= Y == 45, Y = getchar(); while (Y <= 57 && Y >= 48) S = (S << 3) + (S << 1) + Y - 48, Y = getchar(); return C ? -S : S; }
voideachT(){ int l = read(), r = read();
ll res = 0; for (int i = 0, pow = 1; pow <= r; ++i) { if (pow <= l and l < 3 * pow) { res += i + 1; }
int L = std::max(l, pow); int R = std::min(r, pow * 3 - 1); if (L <= R) res += (R - L + 1) * (i + 1);
pow *= 3; }
printf("%lld\n", res); }
intmain(){ for (int T = read(); T--; eachT()); return0; }