solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
#include <bits/stdc++.h>
using namespace std;
template <class T>
void pp(T v) {
for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it)
cout << *it << ' ';
cout << endl;
}
template <class T>
void pp(T v, int n) {
for (int i = 0; i < (int)n; i++) cout << v[i] << ' ';
cout << endl;
}
const int INF = 1 << 28;
const double EPS = 1.0e-9;
static const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int g(const char c) {
if (isdigit(c)) return c - '0';
if (isupper(c)) return c - 'A' + 10;
if (islower(c)) return c - 'a' + 10;
return -1;
}
int f(const string s, const int b) {
int base = 1, num = 0;
for (int i = s.size() - 1; i >= 0; i--) {
int v = g(s[i]);
if (v >= b) return -1;
num += base * v;
base *= b;
if (num > 100) return -2;
}
return num;
}
int main(void) {
string line;
cin >> line;
replace((line).begin(), (line).end(), ':', ' ');
stringstream ss(line);
string a, b;
ss >> a >> b;
vector<int> ans;
for (int n = 2; n <= 102; n++) {
int av = f(a, n);
int bv = f(b, n);
if (av >= 0 && av <= 23) {
if (bv >= 0 && bv <= 59) {
if (n >= 100) {
cout << -1 << endl;
return 0;
}
ans.push_back(n);
}
}
}
if (ans.empty()) {
cout << 0 << endl;
} else {
pp(ans);
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000, inf = 1000000000, mod = 1000003;
vector<int> v;
bool ch(string s, int a, bool k) {
long long p = 1, n = 0;
reverse(s.begin(), s.end());
for (int i = 0; i < s.length(); i++) {
if (s[i] >= 'A' && s[i] <= 'Z') {
if (int(s[i] - 'A') + 10 >= a) return false;
n += p * (int(s[i] - 'A') + 10);
} else if (int(s[i] - '0') >= a)
return false;
else
n += p * int(s[i] - '0');
p *= a;
}
if (k)
if (n <= 59 && n >= 0) {
return true;
} else
return false;
else if (n <= 23 && n >= 0) {
return true;
} else
return false;
}
int main() {
string s, a, b;
cin >> s;
int w = 0;
while (s[w] != ':') a += s[w++];
w++;
while (w < s.length()) b += s[w++];
for (int i = 2; i < 300; i++)
if (ch(a, i, false) && ch(b, i, true)) {
v.push_back(i);
}
if (v.size() > 150)
cout << -1 << endl;
else if (v.size() == 0)
cout << 0 << endl;
else
for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
return 0;
}
| 8 | CPP |
a,b=input().split(':')
z='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
c=[z.find(i) for i in a]
d=[z.find(i) for i in b]
for i in range(len(c)):
if c[i]>0:
break
c=c[i:]
for i in range(len(d)):
if d[i]>0:
break
d=d[i:]
if int(a,base=max(*c+[1])+1)>23 or int(b,base=max(*d+[1])+1)>59:
print(0)
elif len(c)==len(d)==1:
print(-1)
else:
for i in range(max(*d+c)+1,61):
e=0
for j in range(len(c)):
e+=i**j*c[-1-j]
f=0
for j in range(len(d)):
f+=i**j*d[-1-j]
if 0<=e<=23 and 0<=f<=59:
print(i,end=' ') | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
string s;
int n;
int colon;
inline int get_digit(char ch) {
if ('0' <= ch && ch <= '9') return ch - '0';
return ch - 'A' + 10;
}
int transform(string s, int base) {
int ans = 0;
for (int i = 0; i < (int)s.size(); ++i) {
int digit = get_digit(s[i]);
if (digit >= base) return INF;
ans = ans * base + digit;
}
return ans;
}
int main() {
cin >> s;
n = s.size();
for (int i = 0; i < n; ++i)
if (s[i] == ':') colon = i;
vector<int> sol;
for (int base = 2; base <= 60; ++base)
if (transform(s.substr(0, colon), base) < 24 &&
transform(s.substr(colon + 1, n - colon), base) < 60)
sol.push_back(base);
if (sol.size() == 0) {
cout << "0\n";
return 0;
}
if (sol.back() == 60) {
cout << "-1\n";
return 0;
}
for (size_t i = 0; i < sol.size(); ++i) cout << sol[i] << " ";
}
| 8 | CPP |
#include <bits/stdc++.h>
int main() {
int i, j, t, b[20] = {0}, c[20] = {0}, max, lenb, lenc, sumb, sumc, flog = 0;
char a[20];
scanf("%s", a);
i = 0;
j = 0;
while (a[i] == '0') {
i++;
}
while (1) {
if (a[i] == ':' || a[i] == 0) break;
if (a[i] >= '0' && a[i] <= '9')
b[j] = a[i] - '0';
else
b[j] = a[i] - 'A' + 10;
j++;
i++;
}
lenb = j;
j = 0;
i++;
while (a[i] == '0') {
i++;
}
while (a[i] != 0) {
if (a[i] >= '0' && a[i] <= '9')
c[j++] = a[i] - '0';
else
c[j++] = a[i] - 'A' + 10;
i++;
}
lenc = j;
max = b[0];
for (i = 1; i < lenb; i++)
if (b[i] > max) max = b[i];
for (i = 0; i < lenc; i++)
if (c[i] > max) max = c[i];
if (lenb <= 1 && lenc <= 1 && b[0] < 24 && c[0] < 60)
printf("-1\n");
else {
while (1) {
sumb = sumc = 0;
t = 1;
max++;
for (i = lenb - 1; i >= 0; i--) {
sumb += t * b[i];
t *= max;
}
t = 1;
for (i = lenc - 1; i >= 0; i--) {
sumc += t * c[i];
t *= max;
}
if (sumb < 24 && sumc < 60) {
flog = 1;
printf("%d ", max);
} else {
if (flog == 1) printf("\n");
break;
}
}
if (flog == 0) printf("0\n");
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int imax = 0;
char str[N];
void fun(char *temp) {
memset(str, 0, sizeof(str));
int len = strlen(temp), cnt = 0;
bool flag = 0;
for (int i = 0; i < len; i++) {
if (flag)
str[cnt++] = temp[i];
else if (temp[i] != '0') {
flag = 1;
str[cnt++] = temp[i];
}
}
if (!flag) str[0] = '0';
}
bool judge(int base, char *str1, char *str2) {
int len1 = strlen(str1), len2 = strlen(str2), hour = 0;
for (int i = 0; i < len1; i++) {
if (isdigit(str1[i]))
hour = hour * base + str1[i] - '0';
else
hour = hour * base + str1[i] - 'A' + 10;
}
if (hour >= 24) return 0;
int min = 0;
for (int i = 0; i < len2; i++) {
if (isdigit(str2[i]))
min = min * base + str2[i] - '0';
else
min = min * base + str2[i] - 'A' + 10;
}
if (min >= 60) return 0;
return 1;
}
int prejudge(char *str1, char *str2) {
int len1 = strlen(str1), len2 = strlen(str2);
if (len1 == 1 && len2 == 1) {
if (str1[0] >= 'O')
return 0;
else
return -1;
} else {
bool flag = judge(imax, str1, str2);
if (flag == 0)
return 0;
else
return 1;
}
}
int main() {
char sstr[N];
while (scanf("%s", sstr) != EOF) {
imax = 0;
int len = strlen(sstr);
for (int i = 0; i < len; i++) {
if (isdigit(sstr[i]))
imax = max(imax, sstr[i] - '0');
else if (isalpha(sstr[i]))
imax = max(imax, sstr[i] - 'A' + 10);
}
imax++;
char temp1[N], temp2[N], str1[N] = {0}, str2[N] = {0};
sscanf(sstr, "%[^:]:%s", temp1, temp2);
fun(temp1);
strcpy(str1, str);
fun(temp2);
strcpy(str2, str);
int flag = prejudge(str1, str2);
if (flag <= 0) {
printf("%d\n", flag);
continue;
}
for (int i = imax; i <= 60; i++) {
if (judge(i, str1, str2)) {
flag = 1;
printf("%d ", i);
}
}
puts("");
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
bool ckeck(int s, string h, string m) {
int hn = 0, mn = 0;
int step = 1;
for (int i = h.length() - 1; i >= 0; i--) {
if (isalpha(h[i]))
hn += (h[i] - 'A' + 10) * step;
else
hn += (h[i] - '0') * step;
step *= s;
}
step = 1;
for (int i = m.length() - 1; i >= 0; i--) {
if (isalpha(m[i]))
mn += (m[i] - 'A' + 10) * step;
else
mn += (m[i] - '0') * step;
step *= s;
}
if (hn <= 23 && mn <= 59) return true;
return false;
}
int main() {
string s, s1, s2;
string h, m;
cin >> s;
int p = s.find(':');
s1 = s.substr(0, p);
s2 = s.substr(p + 1);
int i = 0;
while (s1[i] == '0') i++;
h = s1.substr(i);
i = 0;
while (s2[i] == '0') i++;
m = s2.substr(i);
if (h.length() == 0) h.push_back(0);
if (m.length() == 0) m.push_back(0);
if (h.length() == 1 && m.length() == 1) {
if ((isalpha(h[0]) && h[0] > 'N')) {
cout << 0;
return 0;
} else {
cout << -1;
return 0;
}
}
int minsystem = 2;
for (int i = 0; i < h.length(); i++)
if (isalpha(h[i]))
minsystem = max(minsystem, h[i] - 'A' + 11);
else
minsystem = max(minsystem, h[i] - '0' + 1);
for (int i = 0; i < m.length(); i++)
if (isalpha(m[i]))
minsystem = max(minsystem, m[i] - 'A' + 11);
else
minsystem = max(minsystem, m[i] - '0' + 1);
vector<int> answ;
int k = minsystem;
while (ckeck(k, h, m)) {
answ.push_back(k);
k++;
}
if (answ.size() == 0)
cout << 0;
else
for (int i = 0; i < answ.size(); i++) cout << answ[i] << " ";
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f;
int main() {
string in, b, a;
vector<int> res;
cin >> in;
int Max = -1;
for (long long i = 0; i < in.size(); ++i) {
if (in[i] >= '0' && in[i] <= '9') {
Max = max(Max, in[i] - '0');
} else if (in[i] >= 'A' && in[i] <= 'Z') {
Max = max(Max, in[i] - 'A' + 10);
}
}
bool inf = true;
int ares1 = -1, ares2 = -1, bres1 = 0, bres2 = 0;
while (ares1 != bres1 || ares2 != bres2) {
ares1 = bres1;
ares2 = bres2;
bres1 = 0;
bres2 = 0;
Max++;
bool f = true;
int c = 0;
for (long long i = in.size() - 1; i > -1; --i) {
if (in[i] == ':') {
f = false;
c = 0;
continue;
}
if (f) {
bres2 += in[i] >= '0' && in[i] <= '9'
? (in[i] - '0') * pow(Max, c++)
: (in[i] - 'A' + 10) * pow(Max, c++);
} else {
bres1 += in[i] >= '0' && in[i] <= '9'
? (in[i] - '0') * pow(Max, c++)
: (in[i] - 'A' + 10) * pow(Max, c++);
}
}
if (bres1 > 23 || bres2 > 59) {
inf = false;
break;
} else {
res.push_back(Max);
}
}
if (inf) {
cout << -1;
return 0;
}
if (res.empty()) {
cout << 0;
return 0;
}
for (long long i = 0; i < res.size(); ++i) cout << res[i] << " ";
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
char s[100];
int i, j, S, l, k, Min, b[10], f[100], c[200];
int main() {
gets(s);
l = strlen(s);
for (i = '0'; i <= '9'; i++) c[i] = i - '0';
for (i = 'A'; i <= 'Z'; i++) c[i] = i - 'A' + 10;
Min = 2;
for (i = 0; i < l; i++)
if (s[j] != ':' && c[s[i]] + 1 > Min) Min = c[s[i]] + 1;
for (i = Min; i <= 60; i++) {
b[0] = b[1] = 0, k = 0;
for (j = 0; j < l; j++) {
if (s[j] == ':')
k++;
else
b[k] = b[k] * i + c[s[j]];
}
if (b[0] < 24 && b[1] < 60) S++, f[i] = 1;
}
if (S == 0)
printf("0\n");
else if (S == 61 - Min)
printf("-1\n");
else {
for (i = 2; i <= 60; i++)
if (f[i]) {
S--;
if (S)
printf("%d ", i);
else
printf("%d\n", i);
}
}
return 0;
}
| 8 | CPP |
a, b = input().split(':')
a = list(a)
b = list(b)
c = 10
for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
for j in range(len(a)):
if a[j] == i:
a[j] = c
for j in range(len(b)):
if b[j] == i:
b[j] = c
c += 1
a = list(map(int, a))
b = list(map(int, b))
ans = []
for c in range(2, 200):
x1 = 0
x2 = 0
for p in range(len(a)):
x1 += a[p] * c ** (len(a) - p - 1)
for p in range(len(b)):
x2 += b[p] * c ** (len(b) - p - 1)
if 0 <= x1 <= 23 and 0 <= x2 <= 59 and max(a) < c and max(b) < c:
ans.append(c)
if len(ans) > 100:
print(-1)
elif ans:
print(*ans)
else:
print(0)
| 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 1e3 + 10;
int a[N];
void init() {
for (int i = 0; i < 10; i++) a[i + '0'] = i;
for (int i = 0; i < 26; i++) a[i + 'A'] = i + 10;
}
long long check(string &s, int b) {
long long ret = 0;
for (auto &c : s) {
ret *= b;
ret += a[c];
if (a[c] >= b) return -1;
}
return ret;
}
int main() {
init();
string str;
cin >> str;
int o = str.find(':');
string s1 = str.substr(0, o);
string s2 = str.substr(o + 1);
vector<int> ans;
for (int i = 1; i <= 1000; i++) {
long long h = check(s1, i);
long long m = check(s2, i);
if (h >= 24) break;
if (m >= 60) break;
if (h >= 0 && m >= 0) ans.push_back(i);
}
if (ans.empty())
cout << 0 << endl;
else if (ans.back() == 1000)
cout << -1 << endl;
else
for (auto &x : ans) cout << x << ' ';
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
string s, a, b;
int maxv;
bool check(int x) {
int h = 0, m = 0, t;
for (int i = 0; i < a.size(); i++) {
if (isdigit(a[i]))
t = a[i] - '0';
else
t = a[i] - 'A' + 10;
h = h * x + t;
maxv = max(maxv, t);
}
for (int i = 0; i < b.size(); i++) {
if (isdigit(b[i]))
t = b[i] - '0';
else
t = b[i] - 'A' + 10;
m = m * x + t;
maxv = max(maxv, t);
}
return h <= 23 && m <= 59;
}
int main() {
cin >> s;
int i;
for (i = 0; s[i] != ':'; i++) a.push_back(s[i]);
for (i++; i < s.size(); i++) b.push_back(s[i]);
int L = 0, R = 70, mid;
while (L + 1 < R) {
mid = (L + R) / 2;
if (check(mid))
L = mid;
else
R = mid;
}
if (L >= 60)
puts("-1");
else if (L <= maxv)
puts("0");
else
for (int i = maxv + 1; i <= L; i++) printf("%d%c", i, i == L ? '\n' : ' ');
return 0;
}
| 8 | CPP |
time = input()
hour = time.split(':')[0]
minute = time.split(':')[1]
minBase = 0
def charToVal(x):
if ord(x) < 58:
return ord(x) - 48
else:
return ord(x) - 55
for x in hour:
if ord(x) < 58:
minBase = max(minBase, ord(x) - 47)
else:
minBase = max(minBase, ord(x) - 54)
for x in minute:
if ord(x) < 58:
minBase = max(minBase, ord(x) - 47)
else:
minBase = max(minBase, ord(x) - 54)
solutions = []
for base in range(minBase, 62):
multiple = 1
converted_hour = 0
for x in range(len(hour) - 1, -1, -1):
converted_hour += multiple*(charToVal(hour[x]))
multiple *= base
if converted_hour >= 24:
break
multiple = 1
converted_minute = 0
for x in range(len(minute) - 1, -1, -1):
converted_minute += multiple*(charToVal(minute[x]))
multiple *= base
if converted_minute >= 60:
break
solutions.append(base)
if 61 in solutions:
print(-1)
elif len(solutions) == 0:
print(0)
else:
for x in solutions:
print(x, end=' ') | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void sprint(string s) {
for (int i = 0; i < s.size(); ++i) printf("%c", s[i]);
printf("\n");
}
int f(vector<int> x, vector<int> y, int t) {
int a = 0, b = 0;
reverse(x.begin(), x.end());
reverse(y.begin(), y.end());
int temp = 1;
for (int i = 0; i < x.size(); ++i) {
if (x[i] >= t) return 0;
a += x[i] * temp;
temp *= t;
}
temp = 1;
for (int i = 0; i < y.size(); ++i) {
if (y[i] >= t) return 0;
b += y[i] * temp;
temp *= t;
}
if (a <= 23 and b <= 59)
return 1;
else
return -1;
}
int main() {
string s;
cin >> s;
int x = s.find(":");
string a = s.substr(0, x);
string b = s.substr(x + 1, s.size() - x - 1);
bool t = 0;
for (int i = 0; i < a.size() - 1; ++i) {
if (a[i] != '0') t = 1;
}
if (!t) {
for (int i = 0; i < b.size() - 1; ++i) {
if (b[i] != '0') t = 1;
}
char c = a[a.size() - 1];
if (!t) {
if ((c - '0' >= 0 and c - '9' <= 0) or (c - 'A' >= 0 and c - 'N' <= 0)) {
printf("-1\n");
return 0;
}
}
}
vector<int> xx, y;
for (int i = 0; i < a.size(); ++i) {
if (a[i] - '0' >= 0 and a[i] - '9' <= 0)
xx.push_back(a[i] - '0');
else
xx.push_back(a[i] - 'A' + 10);
}
for (int i = 0; i < b.size(); ++i) {
if (b[i] - '0' >= 0 and b[i] - '9' <= 0)
y.push_back(b[i] - '0');
else
y.push_back(b[i] - 'A' + 10);
}
int tt = 2;
int tot = 0;
while (1) {
int temp = f(xx, y, tt);
if (temp == -1) break;
if (temp == 1) tot++, printf("%d ", tt);
tt++;
}
if (tot == 0) printf("0\n");
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int num[255];
int nbase(string s, int b) {
int i = 0, m = 1, ret = 0;
while (i < s.size()) {
if (num[s[s.size() - i - 1]] >= b) return 1000000;
ret += num[s[s.size() - i - 1]] * m;
i++;
m *= b;
}
return ret;
}
int main() {
for (int i = '0'; i <= '9'; i++) num[i] = i - '0';
for (int i = 'A'; i <= 'Z'; i++) num[i] = i - 'A' + 10;
string s, h, m;
cin >> s;
int p = 0;
while (s[p] != ':') p++;
h = s.substr(0, p);
m = s.substr(p + 1, s.size() - p - 1);
vector<int> cor;
for (int i = 2; i < 60; i++) {
if (nbase(h, i) < 24 && nbase(m, i) < 60) cor.push_back(i);
}
if (nbase(h, 70) < 24 && nbase(m, 70) < 60)
cout << -1 << endl;
else if (cor.size() == 0)
cout << 0 << endl;
else {
cout << cor[0];
for (int i = 1; i < cor.size(); i++) cout << ' ' << cor[i];
cout << endl;
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
char s[100100];
int a[100], b[100], al, bl, ax, bx;
int main() {
int i, j, k, max = 1;
gets(s);
for (i = 0; s[i] != ':'; i++)
;
j = 0;
for (i--; i >= 0; i--, j++) {
if ('0' <= s[i] && s[i] <= '9') a[j] = s[i] - 48;
if ('A' <= s[i] && s[i] <= 'Z') a[j] = s[i] - 65 + 10;
if (a[j] > max) max = a[j];
}
al = j;
for (; al > 1 && !a[al - 1]; al--)
;
for (i = 0; s[i]; i++)
;
j = 0;
for (i--; s[i] != ':'; i--, j++) {
if ('0' <= s[i] && s[i] <= '9') b[j] = s[i] - 48;
if ('A' <= s[i] && s[i] <= 'Z') b[j] = s[i] - 65 + 10;
if (b[j] > max) max = b[j];
}
bl = j;
for (; bl > 1 && !b[bl - 1]; bl--)
;
max++;
ax = 0;
for (i = al - 1; i >= 0; i--) ax = ax * max + a[i];
bx = 0;
for (i = bl - 1; i >= 0; i--) bx = bx * max + b[i];
if (ax > 23 || bx > 59) {
printf("0\n");
} else if (al == 1 && bl == 1) {
printf("-1\n");
} else {
printf("%d", max);
for (k = max + 1;; k++) {
ax = 0;
for (i = al - 1; i >= 0; i--) ax = ax * k + a[i];
bx = 0;
for (i = bl - 1; i >= 0; i--) bx = bx * k + b[i];
if (ax <= 23 && bx <= 59) {
printf(" %d", k);
} else
break;
}
putchar(10);
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
long long to_dec(string s, long long base) {
long long re = 0;
for (int a = 0; a < s.size(); ++a)
if ('0' <= s[a] && s[a] <= '9')
re = re * base + (long long)(s[a] - '0');
else if ('A' <= s[a] && s[a] <= 'Z')
re = re * base + (long long)(s[a] - 'A' + 10);
return re;
}
string to_to(long long num, long long base) {
string re;
while (num > 0) {
long long rem = num % base;
if (rem <= 9)
re = string(1, '0' + rem) + re;
else
re = string(1, 'A' + rem - 10) + re;
num /= base;
}
if (re == "") re = "0";
return re;
}
int main() {
string s, t;
while (cin >> s) {
int maxv = 0;
for (int i = 0; i < s.size(); ++i) {
if (s[i] == ':') continue;
if (isupper(s[i]))
maxv = max(maxv, s[i] - 'A' + 10);
else
maxv = max(maxv, s[i] - '0');
}
maxv = max(2, maxv + 1);
int p = s.find(':');
t = s.substr(p + 1);
s = s.erase(p);
int h = to_dec(s, maxv);
int m = to_dec(t, maxv);
if (h)
while (s[0] == '0') s.erase(0, 1);
else
s = "0";
if (m)
while (t[0] == '0') t.erase(0, 1);
else
t = "0";
if (s.size() == 1 && h < 24 && t.size() == 1 && m < 60) {
cout << "-1\n";
continue;
}
if (h > 23 || m > 59) {
cout << "0\n";
continue;
}
cout << maxv;
for (int i = maxv + 1;; ++i) {
h = to_dec(s, i);
m = to_dec(t, i);
if (h > 23 || m > 59) break;
cout << ' ' << i;
}
cout << '\n';
}
return 0;
}
| 8 | CPP |
from sys import setrecursionlimit, exit, stdin
from math import ceil, floor, acos, pi
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from functools import reduce
import itertools
setrecursionlimit(10**7)
RI=lambda x=' ': list(map(int,input().split(x)))
RS=lambda x=' ': input().rstrip().split(x)
dX= [-1, 1, 0, 0,-1, 1,-1, 1]
dY= [ 0, 0,-1, 1, 1,-1,-1, 1]
mod=int(1e9+7)
eps=1e-6
MAX=1000
#################################################
def to_base(s, b):
if not s:
return 0
v=int(s[-1], 36)
if v>=b:
return MAX
return v+to_base(s[:-1], b) *b
h, m = RS(':')
ans=[]
for b in range(100):
if to_base(h, b) < 24 and to_base(m, b) <60:
ans.append(b)
if not ans:
print(0)
elif ans[-1]==99:
print(-1)
else:
print(*ans)
| 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int hour[10];
int mini[10];
int main() {
memset(hour, 0, sizeof(hour));
memset(mini, 0, sizeof(mini));
string s;
cin >> s;
string s1 = "";
string s2 = "";
int i = 0;
for (i = 0; i < s.size(); i++) {
if (s[i] != ':') {
s1 += s[i];
} else {
i++;
break;
}
}
for (i = i; i < s.size(); i++) {
s2 += s[i];
}
while (s1.size() < 5) {
string tmps = '0' + s1;
s1 = tmps;
}
while (s2.size() < 5) {
string tmps = '0' + s2;
s2 = tmps;
}
int count = 4;
for (int i = 0; i < s1.size(); i++) {
if (int(s1[i]) >= 48 && int(s1[i]) <= 57) {
hour[count] = int(s1[i]) - 48;
} else
hour[count] = int(s1[i]) - 55;
count--;
}
count = 4;
for (int i = 0; i < s2.size(); i++) {
if (int(s2[i]) >= 48 && int(s2[i]) <= 57) {
mini[count] = int(s2[i]) - 48;
} else
mini[count] = int(s2[i]) - 55;
count--;
}
if (hour[0] < 24 && hour[1] == 0 && hour[2] == 0 && hour[3] == 0 &&
hour[4] == 0 && mini[0] < 60 && mini[1] == 0 && mini[2] == 0 &&
mini[3] == 0 && mini[4] == 0) {
cout << "-1";
return 0;
}
int max = 0;
for (int i = 0; i < 5; i++) {
if (hour[i] > max) max = hour[i];
if (mini[i] > max) max = mini[i];
}
int start = max + 1;
while (1) {
int sum1 = 0;
int sum2 = 0;
for (int i = 0; i < 5; i++) {
sum1 += hour[i] * pow(start, i);
sum2 += mini[i] * pow(start, i);
}
if (sum1 > 23 || sum2 > 59) {
if (start == max + 1) cout << "0";
break;
} else {
cout << start << " ";
start++;
}
}
return 0;
}
| 8 | CPP |
#Algorithm :
# 1) Split into strings , remove zeros
# 2) Start checking for every integer in a range of(2 to 61)
# 3) check the numbers and respetively add them !
################################
#Function to calculate the value
#This function is approximately called 60 times by 2 strings ! And it still works
def base(t,b):
num = 0
p = 1
i = len(t) - 1
v = 0
while i >=0 :
if(t[i].isdigit()):
v = int(t[i])
else:
#Important to convert alphabets to numbers
v = ord(t[i]) - 55
#If a value in string is greater than the numeral , then there can't exist such a numeral system
if v >= b:
return -1
num = num + (v*p)
p=p*b
i=i-1
return num
###################################
#Function to remove leading zeros
def remove_zeros(s):
i=0
res=""
while i < len(s) and s[i] == "0":
i=i+1
while i < len(s):
res = res + s[i]
i=i+1
if res == "":
res = "0"
return res
#####################################
s = input().split(":")
num = []
for i in range(2):
s[i]=remove_zeros(s[i])
#Important range used for checking
for i in range(2,61):
a = base(s[0],i)
b = base(s[1],i)
if a >= 0 and a <= 23 and b >=0 and b <= 59:
num.append(i)
if len(num) == 0:
print(0)
elif 60 in num :
# As 60 cannot come it is possible only when there are only numbers at the 0th place
print(-1)
else:
for x in num:
print(x) | 8 | PYTHON3 |
s=input()
s=s.split(":")
h=s[0]
m=s[1]
h=h[::-1]
m=m[::-1]
mi=0
def eval(s,x):
su=0
j=0
for i in s:
if ord(i)>=ord('0') and ord(i)<=ord('9'):
su=su+(x**j)*(ord(i)-48)
else:
su=su+(x**j)*(ord(i)-55)
j+=1
return su
for i in (h+m):
if ord(i)>=ord('0') and ord(i)<=ord('9'):
mi=max(mi,ord(i)-48)
else:
mi=max(mi,ord(i)-55)
mi+=1
mi=max(2,mi)
x=mi
if(eval(h,x)>23 or eval(m,x)>59): print(0)
elif(eval(h,x)==eval(h,x+1) and eval(m,x)==eval(m,x+1)): print(-1)
else:
while 1:
if eval(h,x)<=23 and eval(m,x)<=59:
x+=1
else: break
if(mi==x):print(0)
for i in range(mi,x):
print(i,end=" ")
print("") | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void fun(int b, int d) {
int u = 1;
int v = 0;
if ((b < 0 && d > 0) || (b > 0 && d < 0)) v = 1;
b = abs(b);
d = abs(d);
if (b < d) {
swap(b, d);
u = 0;
}
int b1 = b, d1 = d;
int x = b % d;
while (x) {
b = d;
d = x;
x = b % d;
}
if (u == 0) {
if (v) d1 *= -1;
cout << d1 / d << "/" << b1 / d;
} else {
if (v) b1 *= -1;
cout << b1 / d << "/" << d1 / d;
}
}
int po(int m, int i) {
int r = 1;
while (i--) {
r *= m;
}
return r;
}
long long num7(long long x) {
long long v = 0;
while (x) {
if (x % 10 == 7) v++;
x /= 10;
}
return v;
}
long long num4(long long x) {
long long v = 0;
while (x) {
if (x % 10 == 4) v++;
x /= 10;
}
return v;
}
int arr[101];
int main() {
string s;
cin >> s;
vector<int> v1, v2;
int u = 1;
for (int i = s.size() - 1; i >= 0; i--) {
int a;
if (s[i] == ':') {
u = 0;
continue;
}
if (isalpha(s[i])) {
a = s[i] - 'A' + 10;
} else
a = s[i] - '0';
if (u)
v2.push_back(a);
else
v1.push_back(a);
}
while (!v1.empty()) {
if (v1.back() != 0)
break;
else
v1.pop_back();
}
while (!v2.empty()) {
if (v2.back())
break;
else
v2.pop_back();
}
int m = 0;
for (unsigned int i = 0; i < v1.size(); i++) {
if (v1[i] > m) m = v1[i];
}
for (unsigned int i = 0; i < v2.size(); i++) {
if (v2[i] > m) m = v2[i];
}
int l = 0;
while (1) {
m++;
int sumh = 0, summ = 0;
for (unsigned int i = 0; i < v1.size(); i++) {
sumh += po(m, i) * v1[i];
}
for (unsigned int i = 0; i < v2.size(); i++) {
summ += po(m, i) * v2[i];
}
if (sumh < 24 && summ < 60) {
l = 1;
if (v1.size() < 2 && v2.size() < 2) {
cout << "-1";
break;
} else
cout << m << " ";
} else {
if (l)
break;
else {
cout << "0";
break;
}
}
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
vector<long long> a[3], ans;
long long i, k = 1, t = 0, x, y, j, p, xx, yy;
cin >> s;
for (i = (0); i < (s.length()); i++) {
if (s[i] == ':') {
k++;
continue;
}
a[k].push_back(int(s[i]));
if (s[i] <= '9' && s[i] >= '0')
a[k][a[k].size() - 1] -= 48;
else
a[k][a[k].size() - 1] -= 55;
t = max(t, a[k].back());
}
x = y = 0;
xx = yy = -1;
for (i = t + 1; x < 24 && y < 60; i++) {
if (i != t + 1) ans.push_back(i - 1);
x = y = 0;
p = 1;
for (j = a[1].size() - 1; j > -1; j--) x += p * a[1][j], p *= i;
p = 1;
for (j = a[2].size() - 1; j > -1; j--) y += p * a[2][j], p *= i;
if (xx == x && yy == y) {
cout << -1;
return 0;
}
xx = x;
yy = y;
}
if (!ans.size())
cout << 0;
else
for (i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tpl = tuple<int, int, int>;
using pcc = pair<char, char>;
const ll inf = 1e18 + 100;
const ll mod = 998244353;
int dr[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};
int kr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int kc[] = {-2, -2, -1, 1, 2, 2, -1, 1};
int dgr[] = {-1, -1, 1, 1};
int dgc[] = {1, -1, -1, 1};
const int N = 2e6;
int value(char ch) {
if (isdigit(ch)) return ch - '0';
return ch - 'A' + 10;
}
ll convert(string str, int b) {
ll ans = 0, cur = 1;
for (int i = str.size() - 1; i >= 0; i--) {
ans += (value(str[i]) * cur);
cur *= b;
}
return ans;
}
void solve() {
string str, hour, minit;
cin >> str;
int len = str.size();
int mx = 0, ok = 0;
for (char ch : str) {
if (ch == ':') {
ok = 1;
continue;
}
mx = max(mx, value(ch));
if (ok) {
minit += ch;
} else {
hour += ch;
}
}
vector<ll> ans;
ll H = 0, M = 0;
for (int base = mx + 1; base <= N; base++) {
H = convert(hour, base);
M = convert(minit, base);
if (H >= 24 or M >= 60) break;
ans.push_back(base);
}
if (ans.size() > 1000000)
printf("-1\n");
else if (ans.size() == 0)
printf("0\n");
else {
for (ll x : ans) printf("%lld ", x);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int char2int(char c) {
int d = 0;
if ('0' <= c && c <= '9')
d = c - '0';
else if ('A' <= c && c <= 'Z')
d = c - 'A' + 10;
else if ('a' <= c && c <= 'z')
d = c - 'a' + 10;
return d;
}
int str2int(string s, int base) {
int ret = 0;
for (int i = 0; i < s.size(); i++) {
ret = ret * base + char2int(s[i]);
}
return ret;
}
int main(void) {
string sin, sh, sm;
cin >> sin;
for (int i = 0; i < sin.size(); i++) {
if (sin[i] == ':') {
int j;
for (j = 0; j < i; j++) {
if (sin[j] == '0') continue;
break;
}
sh = sin.substr(j, i - j);
for (j = i + 1; j < sin.size(); j++) {
if (sin[j] == '0') continue;
break;
}
sm = sin.substr(j);
}
}
int minbase = 0;
for (int i = 0; i < sin.size(); i++) {
if (sin[i] == ':') continue;
int d = char2int(sin[i]);
if (minbase < d) minbase = d;
}
minbase++;
if (sh.size() <= 1 && sm.size() <= 1) {
int h = 0;
if (sh.size() == 1) h = char2int(sh[0]);
if (h > 23)
cout << 0 << endl;
else
cout << -1 << endl;
return 0;
}
int minh = str2int(sh, minbase);
int minm = str2int(sm, minbase);
if (minh > 23 || minm > 59) {
cout << 0 << endl;
return 0;
}
cout << minbase;
int base = minbase + 1;
while (1) {
int h = str2int(sh, base);
int m = str2int(sm, base);
if (h > 23 || m > 59) break;
cout << ' ' << base;
base++;
}
cout << endl;
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int toNum(char a) {
if (isdigit(a)) return a - '0';
return a - 'A' + 10;
}
int toDec(string s, int rad) {
int i = s.size();
int mult = 1;
int res = 0;
for (--i; i >= 0 && res < 60; --i) {
res += toNum(s[i]) * mult;
mult *= rad;
}
return res;
}
bool isValid(string a, string b, int rad) {
if (toDec(a, rad) < 24 && toDec(b, rad) < 60) return true;
return false;
}
int main() {
int i, j;
string s;
cin >> s;
int pos = s.find(':');
string a, b;
a = s.substr(0, pos);
b = s.substr(pos + 1);
j = 2;
if (isValid(a, b, 73)) {
cout << -1 << endl;
return 0;
}
for (i = 0; i < a.size(); ++i) {
j = max(j, toNum(a[i] + 1));
}
for (i = 0; i < b.size(); ++i) {
j = max(j, toNum(b[i] + 1));
}
if (!isValid(a, b, j)) {
cout << 0 << endl;
return 0;
}
for (i = j; isValid(a, b, i); ++i) {
cout << i << endl;
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int f(char c) {
if (c >= '0' && c <= '9') return c - '0';
return c - 'A' + 10;
}
int main() {
string s, s1, s2;
cin >> s;
for (int i = 0; i < s.size(); ++i)
if (s[i] == ':') s[i] = ' ';
istringstream is(s);
is >> s1 >> s2;
int p1 = 0, p2 = 0;
while (p1 + 1 < s1.size() && s1[p1] == '0') ++p1;
while (p2 + 1 < s2.size() && s2[p2] == '0') ++p2;
if (p1 == s1.size() - 1 && f(s1[s1.size() - 1]) < 24 && p2 == s2.size() - 1)
cout << -1 << '\n';
else {
vector<int> ans;
for (int b = 2; b < 100; ++b) {
bool ok = true;
int h = 0, mm = 0;
for (int i = p1; i < s1.size(); ++i) {
if (f(s1[i]) < b)
h = min(24, h * b + f(s1[i]));
else
ok = false;
}
for (int i = p2; i < s2.size(); ++i) {
if (f(s2[i]) < b)
mm = min(60, mm * b + f(s2[i]));
else
ok = false;
}
if (ok && h < 24 && mm < 60) ans.push_back(b);
}
if (ans.empty())
cout << 0 << '\n';
else {
for (int i = 0; i < ans.size(); ++i) cout << ans[i] << ' ';
cout << '\n';
}
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
if (y == 0)
return x;
else
return gcd(y, x % y);
}
char str[30];
int arr[100];
int main() {
cin >> str;
int l = strlen(str);
int p = strchr(str, ':') - str;
int K = 0;
int flag = 0;
for (int i = 1; i <= 60; i++) {
long long a = 0, b = 0;
bool ok = 1;
for (int j = 0; j < p; j++) {
int k = str[j] - '0';
if (str[j] >= 'A' && str[j] <= 'Z') k = str[j] - 'A' + 10;
if (k >= i) {
ok = 0;
break;
}
a *= i;
a += k;
}
if (!ok) continue;
for (int j = p + 1; j < l; j++) {
int k = str[j] - '0';
if (str[j] >= 'A' && str[j] <= 'Z') k = str[j] - 'A' + 10;
if (k >= i) {
ok = 0;
break;
}
b *= i;
b += k;
}
if (!ok) continue;
if (a > 23LL || b > 59LL) continue;
arr[K++] = i;
if (i == 60) flag = 1;
}
if (!K)
puts("0");
else {
if (flag)
puts("-1");
else {
for (int i = 0; i < K; i++) cout << arr[i] << ' ';
}
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int getzn(string s, int o) {
string z("0");
int a = 0;
for (int i = 0; i < s.size(); i++)
if (a < 60) {
a *= o;
a += s[i] - z[0];
}
return a;
}
int main() {
string z("0A:"), s, s1, s2;
cin >> s;
int dif = (int)z[1] - (int)z[0] - 10, i = 0, maxx = 0, ans = 0;
while (s[i] != z[2]) {
if ((int)s[i] >= (int)z[1]) s[i] = (char)(s[i] - dif);
s1 += s[i];
maxx = max(maxx, (int)(s[i] - z[0]));
i++;
}
i++;
while (i < s.size()) {
if ((int)s[i] >= (int)z[1]) s[i] = (char)(s[i] - dif);
s2 += s[i];
maxx = max(maxx, (int)(s[i] - z[0]));
i++;
}
bool a[62];
for (i = maxx + 1; i < 62; i++) {
a[i] = (getzn(s1, i) < 24 && getzn(s2, i) < 60);
ans += a[i];
}
if (a[61]) ans = -1;
if (ans <= 0) {
cout << ans << endl;
} else {
for (i = maxx + 1; i < 62; i++) {
if (a[i]) cout << i << " ";
}
cout << endl;
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void remax(T& A, T B) {
if (A < B) A = B;
}
template <class T>
inline void remin(T& A, T B) {
if (A > B) A = B;
}
string ToString(long long num) {
string ret;
do {
ret += ((num % 10) + '0');
num /= 10;
} while (num);
reverse(ret.begin(), ret.end());
return ret;
}
long long ToNumber(string s) {
long long r = 0, p = 1;
for (int i = s.size() - 1; i >= 0; --i) r += (s[i] - '0') * p, p *= 10;
return r;
}
long long Gcd(long long a, long long b) {
while (a %= b ^= a ^= b ^= a)
;
return b;
}
long long Power(long long base, long long power) {
long long ret = 1;
while (power) {
if (power & 1) ret *= base;
power >>= 1;
base *= base;
}
return ret;
}
long long PowerMod(long long base, long long power, long long mod) {
if (!power) return 1;
if (power & 1) return (base * PowerMod(base, power - 1, mod)) % mod;
return PowerMod((base * base) % mod, power >> 1, mod);
}
int Log(long long num, long long base) {
int ret = 0;
while (num) {
++ret;
num /= base;
}
return ret;
}
int Count(long long mask) {
int ret = 0;
while (mask) {
if (mask & 1) ++ret;
mask >>= 1;
}
return ret;
}
int f(string& s, int x) {
int ret = 0;
for (char& ch : s) {
int tmp;
if (isdigit(ch))
tmp = (ch - '0');
else
tmp = (ch - 'A') + 10;
if (tmp >= x) return -1;
ret *= x;
ret += tmp;
}
return ret;
}
inline void run() {
vector<int> ans;
string s, t, h, m;
int sz;
cin >> s;
sz = (int)s.size();
for (int i = 0; i < sz; ++i)
if (s[i] == ':')
h = t, t = "";
else
t += s[i];
m = t;
for (int i = 2; i <= 60; ++i) {
int a = f(h, i);
int b = f(m, i);
if (a >= 0 && a < 24 && b >= 0 && b < 60)
if (i < 60)
ans.emplace_back(i);
else {
puts("-1");
return;
}
}
if (ans.empty())
puts("0");
else {
for (int x : ans) printf("%d ", x);
puts("");
}
}
int main() {
run();
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long *tol(string s) {
long long *ans = (long long *)(malloc(5 * sizeof(long long)));
long long len_s = s.size();
long long i = 0;
while (i < 5 - len_s) {
ans[i++] = 0;
}
long long j = 0;
while (j < len_s) {
if (s[j] <= 58)
ans[i++] = (long long)(s[j++]) - 48;
else {
ans[i++] = (long long)(s[j++]) - 55;
}
}
return ans;
}
long long con(long long *a, long long b) {
long long ans = 0;
long long x = 1;
for (long long i = 4; i >= 0; i--, x = x * b) ans += (a[i] * x);
return ans;
}
int main() {
string s;
cin >> s;
long long i = 0;
long long len_s = s.size();
string a, b;
a = "";
b = "";
while (s[i] != ':') {
a.push_back(s[i]);
i++;
}
i++;
while (i < len_s) {
b.push_back(s[i]);
i++;
}
long long *a1, *b1;
a1 = tol(a);
b1 = tol(b);
long long m = 0;
for (long long i = 0; i < 5; i++) {
if (m < a1[i]) m = a1[i];
if (m < b1[i]) m = b1[i];
}
long long ans = 60;
for (long long i = 59; i > m; i--) {
long long x = con(a1, i);
long long y = con(b1, i);
if ((x < 24) && (y < 60)) {
ans = i;
break;
}
}
if (ans == 60)
cout << 0 << endl;
else {
long long flag1 = 0, flag2 = 0;
for (long long i = 0; i < 4; i++) {
if (a1[i] != 0) flag1 = 1;
if (b1[i] != 0) flag2 = 1;
}
if ((flag1 == 0) && (flag2 == 0)) {
if ((a1[4] < 24) && (b1[4] < 60))
cout << -1 << endl;
else {
cout << 0 << endl;
}
} else {
for (long long i = m + 1; i <= ans; i++) cout << i << " ";
cout << endl;
}
}
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
char S[15];
int Sep, N, MaxD;
vector<int> Ans;
int Digit(int Pos) {
return ('0' <= S[Pos] && S[Pos] <= '9' ? S[Pos] - '0' : S[Pos] - 'A' + 10);
}
int Nr(int Left, int Right, int Base) {
int Ans = 0;
for (int i = Left; i <= Right; ++i) Ans = Ans * Base + Digit(i);
return Ans;
}
int main() {
gets(S + 1);
N = strlen(S + 1);
for (int i = 1; i <= N; ++i)
if (S[i] == ':') Sep = i;
for (int i = 1; i <= N; ++i)
if (i != Sep) MaxD = max(MaxD, Digit(i));
for (int i = MaxD + 1;
i <= 1000 && Nr(1, Sep - 1, i) < 24 && Nr(Sep + 1, N, i) < 60; ++i)
Ans.push_back(i);
if (Ans.size() > 100)
printf("-1");
else if (Ans.size() == 0)
printf("0");
else {
for (int i = 0; i < Ans.size(); ++i) printf("%i ", Ans[i]);
}
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
bool Isvalid(char s[], int least) {
int i = 0, sum = 0;
while (s[i] != '\0' && s[i] != ':') {
if (s[i] > '9')
sum = sum * least + s[i] - 'A' + 10;
else
sum = sum * least + s[i] - '0';
i++;
}
if (sum > 23) return false;
i++;
sum = 0;
while (s[i] != '\0') {
if (s[i] > '9')
sum = sum * least + s[i] - 'A' + 10;
else
sum = sum * least + s[i] - '0';
i++;
}
if (sum > 59) return false;
return true;
}
int getmaxdig(char s[]) {
int i = 0, pos = 0;
while (s[i] != '\0') {
if (s[i] != ':' && s[i] > s[pos]) {
pos = i;
}
i++;
}
if (s[pos] > '9')
return s[pos] - 'A' + 10;
else
return s[pos] - '0';
}
bool Isinfinted(char s[]) {
int i = 0;
while (s[i] == '0') i++;
if (s[i] <= ('A' + 13) && s[i + 1] == ':' || s[i] == ':') {
if (s[i] == ':')
i++;
else
i += 2;
while (s[i] == '0') i++;
if (s[i + 1] == '\0' || s[i] == '\0') return true;
return false;
}
return false;
}
int main() {
char s[20];
cin >> s;
int maxdig = getmaxdig(s) + 1;
if (Isinfinted(s))
cout << "-1" << endl;
else if (Isvalid(s, maxdig)) {
for (; Isvalid(s, maxdig); maxdig++) cout << maxdig << " ";
cout << endl;
} else
cout << "0" << endl;
return 0;
}
| 8 | CPP |
import os
import sys
from io import BytesIO, IOBase
from collections import Counter
import math as mt
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def lcm(a, b):
return (a * b) / gcd(a, b)
mod = int(1e9) + 7
def power(k, n):
if n == 0:
return 1
if n % 2:
return (power(k, n - 1) * k) % mod
t = power(k, n // 2)
return (t * t) % mod
def totalPrimeFactors(n):
count = 0
if (n % 2) == 0:
count += 1
while (n % 2) == 0:
n //= 2
i = 3
while i * i <= n:
if (n % i) == 0:
count += 1
while (n % i) == 0:
n //= i
i += 2
if n > 2:
count += 1
return count
# #MAXN = int(1e7 + 1)
# # spf = [0 for i in range(MAXN)]
#
#
# def sieve():
# spf[1] = 1
# for i in range(2, MAXN):
# spf[i] = i
# for i in range(4, MAXN, 2):
# spf[i] = 2
#
# for i in range(3, mt.ceil(mt.sqrt(MAXN))):
# if (spf[i] == i):
# for j in range(i * i, MAXN, i):
# if (spf[j] == j):
# spf[j] = i
#
#
# def getFactorization(x):
# ret = 0
# while (x != 1):
# k = spf[x]
# ret += 1
# # ret.add(spf[x])
# while x % k == 0:
# x //= k
#
# return ret
# Driver code
# precalculating Smallest Prime Factor
# sieve()
def main():
for _ in range(int(input())):
n=int(input())
a=list(map(int, input().split()))
ans=[]
for i in range(0, n, 2):
ans.append([1, i, i+1])
ans.append([2, i, i+1])
ans.append([2, i, i+1])
ans.append([1, i, i + 1])
ans.append([2, i, i + 1])
ans.append([2, i, i + 1])
print(len(ans))
for i in ans:
print(i[0], i[1]+1, i[2]+1)
return
if __name__ == "__main__":
main()
| 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define fi first
//#define se second
typedef long long ll;
const ll INF=1e18*9;
const int N=1e6+15;
const int M=203;
const int mod1=1e9+7;
const int mod=998244353;
const int base=131;
int n,m,k,ans,x,y,mid,sx=-1,sy=-1,mx,mi=INF,aa,cnt=1;
int a[N];
//char b[M][M];
//stack<int>st;
//pair<int,int>P[N];
//int c[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//int c1[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
//bool vis[N];
//pair<int,int>p[N];
struct node
{
int x,y,z;
};
map<int,int>mp,mp1;
string s,ss;
vector<node>ve;
//bool ok(int sx){return ((sx%4==0 && sx%100) || (sx%400==0));}
int dx[]={1,1,1,0,0,-1,-1,-1};
int dy[]={-1,0,1,-1,1,-1,0,1};
//bool cmp(int a,int b){return a>b; }
/*inline int read()
{
int x=0,f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}*/
void solve()
{
//cout<<"SF"<<endl;
int pos=0,f1=0,s1=0,s2=0;ans=0;mx=INF;
cin>>n;ve.clear();
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
int l=1,r=n;
while(l<=r)
{
ve.push_back(node{1,l,r});
a[l]+=a[r];
ve.push_back(node{2,l,r});
a[r]-=a[l];
ve.push_back(node{1,l,r});
a[l]+=a[r];
ve.push_back(node{2,l,r});
a[r]-=a[l];
ve.push_back(node{1,l,r});
a[l]+=a[r];
ve.push_back(node{2,l,r});
a[r]-=a[l];
l++;r--;
}
/*for(int i=1;i<=n;i++)cout<<a[i]<<" ";
cout<<endl;*/
cout<<ve.size()<<endl;
for(auto i:ve)cout<<i.x<<" "<<i.y<<" "<<i.z<<endl;
}
/*
*/
signed main()
{
//cout<<__gcd(3333300,20000)<<endl;
//cout<<(5&1)<<endl;
//cout<<C(1e8,354)<<endl;
//init(1e8+1,100019);
ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
//int T;for(T=read();T--;)
int T;for(cin>>T;T--;)
//while(cin>>n>>k)
solve();
}
| 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
ll maxn = 10000;
#define fi first
#define sec second
// ll powy(ll a, ll b)
// {
// if (b == 0) return 1;
// ll c = powy(a, b / 2);
// if (b % 2 == 1) return (((c * c) % mod) * a) % mod;
// else return ((c * c) % mod);
// }
// vector<ll> fib(maxn);
// void calc()
// {
// fib[0] = 0; fib[1] = 1;
// for (ll i = 2; i < maxn; i++)
// fib[i] = (fib[i - 1] + fib[i - 2]) % mod;
// }
// vector<ll> fact(maxn);
// void pc()
// {
// fact[0] = 1;
// for (ll i = 1; i < maxn; i++)
// fact[i] = (fact[i - 1] * i) % mod;
// }
// ll ncr(ll n, ll r)
// {
// if (n < r) return 0;
// if (n == r) return 1;
// if (r == 0) return 1;
// ll inv = powy((fact[n - r] * fact[r]) % mod, mod - 2) % mod;
// ll ans = (inv * fact[n]) % mod;
// return ans;
// }
// const int N = 10000;
// int lp[N + 1];
// vector<int> pr;
// void sieve() {
// for (int i = 2; i <= N; ++i) {
// if (lp[i] == 0) {
// lp[i] = i;
// pr.push_back (i);
// }
// for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= N; ++j)
// lp[i * pr[j]] = pr[j];
// }
// }
bool cmp(pair<ll, pair<ll, string> > p1, pair<ll, pair<ll, string> > p2)
{
if (p1.fi > p2.fi) return true;
else if (p2.fi > p1.fi) return false;
else
{
if (p1.sec.fi > p2.sec.fi) return true;
else return false;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t; cin >> t;
while (t--) {
ll n; cin >> n;
vector<ll> vec(n);
for (ll i = 0; i < n; i++)
{
cin >> vec[i];
}
ll k = (3 * n);
cout << k << "\n";
for (ll i = 0; i < n - 1; i += 2)
{
cout << "1 " << i + 1 << " " << i + 2 << "\n";
cout << "2 " << i + 1 << " " << i + 2 << "\n";
cout << "1 " << i + 1 << " " << i + 2 << "\n";
cout << "2 " << i + 1 << " " << i + 2 << "\n";
cout << "1 " << i + 1 << " " << i + 2 << "\n";
cout << "2 " << i + 1 << " " << i + 2 << "\n";
}
}
return 0;
}
| 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>PBDS;
#define mod 1000000007
#define INF 10000000000007
#define DEBUG false
#define N 200005
ll gcd(ll a , ll b) {return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b)
{
return (a / gcd(a, b)) * b;
}
void solve()
{
ll n;
cin >> n;
ll a[n];
for (ll i = 0; i < n; i++)cin >> a[i];
cout << 3 * n << "\n";
for (ll i = 0; i < n; i += 2)
{
cout << "1 " << i + 1 << " " << i + 2 << "\n";
cout << "2 " << i + 1 << " " << i + 2 << "\n";
cout << "1 " << i + 1 << " " << i + 2 << "\n";
cout << "2 " << i + 1 << " " << i + 2 << "\n";
cout << "1 " << i + 1 << " " << i + 2 << "\n";
cout << "2 " << i + 1 << " " << i + 2 << "\n";
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output3.txt", "w", stdout);
#endif
ll t = 1;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
| 8 | CPP |
from math import *
from collections import defaultdict as dt
from sys import stdin
inp = lambda : stdin.readline().strip()
I = lambda : int(inp())
M = lambda : map(int,inp().split())
L = lambda : list(M())
mod = 1000000007
inf = 100000000000000000000
ss = "abcdefghijklmnopqrstuvwxyz"
############## All the best start coding #############
def solve():
n=I()
a=L()
print(n*3)
for i in range(1,n,2):
print(1,i,i+1)
print(2,i,i+1)
print(2,i,i+1)
print(1,i,i+1)
print(2,i,i+1)
print(2,i,i+1)
##################### Submit now #####################
tt=1
tt=I()
for _ in range(tt):
solve() | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
#define float long double
#define int long long
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define endl '\n'
#define cnl cout<<endl;
#define ms(x,v) ((x), v, sizeof((x)))
#define loop(i,a,b) for(int i = a; i < b ; i++)
#define printvec(v) for(int tt = 0; tt < sz(v);tt++) cout << v[tt] << " ";
#define inputvec(v) for(int tt = 0;tt < sz(v); tt++) cin >> v[tt];
#define CASET int ___T; scanf("%lld", &___T); for(int cs = 1; cs <= ___T; cs++)
const int N = 300 * 1000 + 9;
const ll maxi = 3e9 + 10;
// const int inf = 1e18;
const int mod = 998244353;
#define pi 3.141592653589793238
void HakunaMatata(/*int tt*/){
int n; cin >> n ;
vector<int> v(n);
for(int i= 0;i < n;i++){
cin >> v[i];
}
cout << (n/2)*6 << endl;
for(int i = 0;i < n;i=i+ 2){
cout << 1 << " " << i+1<< " " << i+2 << endl;
cout << 2 << " " << i+1 << " " << i+2 << endl;
cout << 1 << " " << i+1 << " " << i+2 << endl;
cout << 1 << " " << i+1 << " " << i+2 << endl;
cout << 2 << " " << i+1 << " " << i+2 << endl;
cout << 1 << " " << i+1<< " " << i+2 << endl;
}
return ;
}
signed main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
// cout << "HELLO" << endl;
//init();
CASET
// int t = 1; cin >> t;
// int tt = 1;
// while(t--){
// HakunaMatata(tt);
HakunaMatata();
// tt++;
// }
return 0;
} | 8 | CPP |
import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
# sys.setrecursionlimit(100000000)
flush = lambda: stdout.flush()
stdstr = lambda: stdin.readline()
stdint = lambda: int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda: map(int, stdstr().split())
stdarr = lambda: list(map(int, stdstr().split()))
mod = 1000000007
def f(arr, i, j):
arr[i] = arr[i] + arr[j]
def s(arr, i, j):
arr[j] = arr[j]-arr[i]
for _ in range(stdint()):
n = stdint()
arr = stdarr()
res = []
for i in range(0, n, 2):
x,y = i+1, i+2
res.append([1, x,y])
# f(arr, x, y)
res.append([2, x,y])
# s(arr, x, y)
res.append([2, x, y])
# s(arr, x, y)
res.append([1,x,y])
# f(arr, x, y)
res.append([2,x,y])
# s(arr, x, y)
res.append([2,x,y])
# s(arr, x, y)
print(len(res))
for i in res:
print(*i)
| 8 | PYTHON3 |
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
import math
from collections import Counter
def func(array):
print(3 * len(array))
for i in range(0, len(array), 2):
for j in range(3):
print(f"2 {i+1} {i+2}")
print(f"1 {i+1} {i+2}")
def main():
num_test = int(parse_input())
result = []
for _ in range(num_test):
n = int(parse_input())
array = [int(i) for i in parse_input().split()]
func(array)
# print("\n".join(map(str, result)))
# region fastio
# BUFSIZE = 8192
# class FastIO(IOBase):
# newlines = 0
# def __init__(self, file):
# self._fd = file.fileno()
# self.buffer = BytesIO()
# self.writable = "x" in file.mode or "r" not in file.mode
# self.write = self.buffer.write if self.writable else None
# def read(self):
# while True:
# b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
# if not b:
# break
# ptr = self.buffer.tell()
# self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
# self.newlines = 0
# return self.buffer.read()
# def readline(self):
# while self.newlines == 0:
# b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
# self.newlines = b.count(b"\n") + (not b)
# ptr = self.buffer.tell()
# self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
# self.newlines -= 1
# return self.buffer.readline()
# def flush(self):
# if self.writable:
# os.write(self._fd, self.buffer.getvalue())
# self.buffer.truncate(0), self.buffer.seek(0)
# class IOWrapper(IOBase):
# def __init__(self, file):
# self.buffer = FastIO(file)
# self.flush = self.buffer.flush
# self.writable = self.buffer.writable
# self.write = lambda s: self.buffer.write(s.encode("ascii"))
# self.read = lambda: self.buffer.read().decode("ascii")
# self.readline = lambda: self.buffer.readline().decode("ascii")
# sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
parse_input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
if __name__ == "__main__":
main()
| 8 | PYTHON3 |
import sys
input=sys.stdin.readline
t=int(input())
for you in range(t):
n=int(input())
l=input().split()
print(3*n)
for i in range(n//2):
a=2*i+1
b=2*i+2
print(1,a,b)
print(2,a,b)
print(1,a,b)
print(2,a,b)
print(1,a,b)
print(2,a,b)
| 8 | PYTHON3 |
import sys
readline = sys.stdin.readline
DEBUG = True
T = int(input())
Ans = []
for qu in range(T):
N = int(readline())
A = list(map(int, readline().split()))
cnt = 0
res = []
for i in range(1, N+1, 2):
j = i+1
res.append((1, i, j))
res.append((2, i, j))
res.append((1, i, j))
res.append((1, i, j))
res.append((2, i, j))
res.append((1, i, j))
Ans.append(str(len(res)))
oA = A[:]
for a, b, c in res:
Ans.append('{} {} {}'.format(a, b, c))
b -= 1
c -= 1
if a == 1:
A[b] += A[c]
else:
A[c] -= A[b]
#print(oA == [-a for a in A])
print('\n'.join(Ans)) | 8 | PYTHON3 |
#include<iostream>
#include<bits/stdc++.h>
#define m_p make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define crap ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
using namespace std;
#define INF 1000000
#define vll vector<ll>
const int M = 1e9+7;
ll fastpower(ll x,ll n,ll M)
{
if(n==0)
return 1;
else if(n%2 == 0) //n is even
return fastpower((x*x)%M,n/2,M);
else //n is odd
return (x*fastpower((x*x)%M,(n-1)/2,M))%M;
}
ll GCD(ll A, ll B) {
if(B==0)
return A;
else
return GCD(B, A % B);
}
bool vowl(char c)
{
return c=='a'||c=='e'||c=='i'||c=='o'||c=='u';
}
ll modInverse(ll A,ll M)// when M is prime
{
return fastpower(A,M-2,M);
}
void sieve(ll N) {
bool isPrime[N+1];
for(ll i = 0; i <= N;++i) {
isPrime[i] = true;
}
isPrime[0] = false;
isPrime[1] = false;
for(ll i = 2; i * i <= N; ++i) {
if(isPrime[i] == true) { //Mark all the multiples of i as composite numbers
for(ll j = i * i; j <= N ;j += i)
isPrime[j] = false;
}
}
}
vector<ll> factorize(ll n) {
vector<ll> res;
for (ll i = 2; i * i <= n; ++i) {
while (n % i == 0) {
res.push_back(i);
n /= i;
}
}
if (n != 1) {
res.push_back(n);
}
return res;
}
int main()
{
crap;
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
ll arr[n+5];
f1(i,n)cin>>arr[i];
cout<<3*n<<endl;
for(int i=1;i<n;i+=2)
{
cout<<"1"<<" "<<i<<" "<<i+1<<endl;
cout<<"2"<<" "<<i<<" "<<i+1<<endl;
cout<<"2"<<" "<<i<<" "<<i+1<<endl;
cout<<"1"<<" "<<i<<" "<<i+1<<endl;
cout<<"2"<<" "<<i<<" "<<i+1<<endl;
cout<<"2"<<" "<<i<<" "<<i+1<<endl;
}
}
return 0;
} | 8 | CPP |
#!/usr/bin/env python
from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from decimal import *
from io import BytesIO, IOBase
from itertools import accumulate,combinations,permutations,combinations_with_replacement,product
from collections import *
import timeit,time
# sys.setrecursionlimit(10**5)
M = 10 ** 9 + 7
import heapq
# print(math.factorial(5))
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
# sys.setrecursionlimit(10**6)
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
"""Prints the values to a stream, or to sys.stdout by default."""
sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
at_start = True
for x in args:
if not at_start:
file.write(sep)
file.write(str(x))
at_start = False
file.write(kwargs.pop("end", "\n"))
if kwargs.pop("flush", False):
file.flush()
if sys.version_info[0] < 3:
sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
def inp(): return sys.stdin.readline().rstrip("\r\n") # for fast input
def out(var): sys.stdout.write(str(var)) # for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def fsep(): return map(float, inp().split())
def inpu(): return int(inp())
# -----------------------------------------------------------------
def regularbracket(t):
p = 0
for i in t:
if i == "(":
p += 1
else:
p -= 1
if p < 0:
return False
else:
if p > 0:
return False
else:
return True
# -------------------------------------------------
def binarySearchcount(arr, n, key):
left = 0
right = n - 1
count = 0
while (left <= right):
mid = int((right + left) / 2)
# Check if middle element is
# less than or equal to key
if (arr[mid] <= key):
count = mid + 1
left = mid + 1
# If key is smaller, ignore right half
else:
right = mid - 1
return count
#--------------------------------------------------binery search
def binarySearch(arr, n, key):
left = 0
right = n - 1
while (left <= right):
mid = ((right + left) // 2)
if arr[mid]==key:
return mid
if (arr[mid] <= key):
left = mid + 1
# If key is smaller, ignore right half
else:
right = mid - 1
return -1
#-------------------------------------------------ternary search
def ternarysearch(arr,n,key):
l,r=0,n-1
while(l<=r):
mid = (-l+r)//3 + l
mid2 = mid + (-l+r)//3
if arr[mid]==key:
return mid
if arr[mid2]==key:
return mid2
if arr[mid]>key:
r=mid-1
elif arr[mid2]<key:
l=mid2+1
else:
l=mid+1
r=mid2-1
return -1
# ------------------------------reverse string(pallindrome)
def reverse1(string):
pp = ""
for i in string[::-1]:
pp += i
if pp == string:
return True
return False
# --------------------------------reverse list(paindrome)
def reverse2(list1):
l = []
for i in list1[::-1]:
l.append(i)
if l == list1:
return True
return False
def mex(list1):
# list1 = sorted(list1)
p = max(list1) + 1
for i in range(len(list1)):
if list1[i] != i:
p = i
break
return p
def sumofdigits(n):
n = str(n)
s1 = 0
for i in n:
s1 += int(i)
return s1
def perfect_square(n):
s = math.sqrt(n)
if s == int(s):
return True
return False
# -----------------------------roman
def roman_number(x):
if x > 15999:
return
value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
symbol = ["F", "MF", "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
roman = ""
i = 0
while x > 0:
div = x // value[i]
x = x % value[i]
while div:
roman += symbol[i]
div -= 1
i += 1
return roman
def soretd(s):
for i in range(1, len(s)):
if s[i - 1] > s[i]:
return False
return True
# print(soretd("1"))
# ---------------------------
def countRhombi(h, w):
ct = 0
for i in range(2, h + 1, 2):
for j in range(2, w + 1, 2):
ct += (h - i + 1) * (w - j + 1)
return ct
def countrhombi2(h, w):
return ((h * h) // 4) * ((w * w) // 4)
# ---------------------------------
def binpow(a, b):
if b == 0:
return 1
else:
res = binpow(a, b // 2)
if b % 2 != 0:
return res * res * a
else:
return res * res
# -------------------------------------------------------
def binpowmodulus(a, b, m):
a %= m
res = 1
while (b > 0):
if (b & 1):
res = res * a % m
a = a * a % m
b >>= 1
return res
# -------------------------------------------------------------
def coprime_to_n(n):
result = n
i = 2
while (i * i <= n):
if (n % i == 0):
while (n % i == 0):
n //= i
result -= result // i
i += 1
if (n > 1):
result -= result // n
return result
def luckynumwithequalnumberoffourandseven(x,n,a):
if x >= n and str(x).count("4") == str(x).count("7"):
a.append(x)
else:
if x < 1e12:
luckynumwithequalnumberoffourandseven(x * 10 + 4,n,a)
luckynumwithequalnumberoffourandseven(x * 10 + 7,n,a)
return a
#----------------------
def luckynum(x,l,r,a):
if x>=l and x<=r:
a.append(x)
if x>r:
a.append(x)
return a
if x < 1e10:
luckynum(x * 10 + 4, l,r,a)
luckynum(x * 10 + 7, l,r,a)
return a
def luckynuber(x, n, a):
p = set(str(x))
if len(p) <= 2:
a.append(x)
if x < n:
luckynuber(x + 1, n, a)
return a
# ------------------------------------------------------interactive problems
def interact(type, x):
if type == "r":
inp = input()
return inp.strip()
else:
print(x, flush=True)
# ------------------------------------------------------------------zero at end of factorial of a number
def findTrailingZeros(n):
# Initialize result
count = 0
# Keep dividing n by
# 5 & update Count
while (n >= 5):
n //= 5
count += n
return count
# -----------------------------------------------merge sort
# Python program for implementation of MergeSort
def mergeSort(arr):
if len(arr) > 1:
# Finding the mid of the array
mid = len(arr) // 2
# Dividing the array elements
L = arr[:mid]
# into 2 halves
R = arr[mid:]
# Sorting the first half
mergeSort(L)
# Sorting the second half
mergeSort(R)
i = j = k = 0
# Copy data to temp arrays L[] and R[]
while i < len(L) and j < len(R):
if L[i] < R[j]:
arr[k] = L[i]
i += 1
else:
arr[k] = R[j]
j += 1
k += 1
# Checking if any element was left
while i < len(L):
arr[k] = L[i]
i += 1
k += 1
while j < len(R):
arr[k] = R[j]
j += 1
k += 1
# -----------------------------------------------lucky number with two lucky any digits
res = set()
def solven(p, l, a, b, n): # given number
if p > n or l > 10:
return
if p > 0:
res.add(p)
solven(p * 10 + a, l + 1, a, b, n)
solven(p * 10 + b, l + 1, a, b, n)
# problem
"""
n = int(input())
for a in range(0, 10):
for b in range(0, a):
solve(0, 0)
print(len(res))
"""
# In the array A at every step we have two
# choices for each element either we can
# ignore the element or we can include the
# element in our subset
def subsetsUtil(A, subset, index, d):
print(*subset)
s = sum(subset)
d.append(s)
for i in range(index, len(A)):
# include the A[i] in subset.
subset.append(A[i])
# move onto the next element.
subsetsUtil(A, subset, i + 1, d)
# exclude the A[i] from subset and
# triggers backtracking.
subset.pop(-1)
return d
def subsetSums(arr, l, r, d, sum=0):
if l > r:
d.append(sum)
return
subsetSums(arr, l + 1, r, d, sum + arr[l])
# Subset excluding arr[l]
subsetSums(arr, l + 1, r, d, sum)
return d
def print_factors(x):
factors = []
for i in range(1, x + 1):
if x % i == 0:
factors.append(i)
return (factors)
# -----------------------------------------------
def calc(X, d, ans, D):
# print(X,d)
if len(X) == 0:
return
i = X.index(max(X))
ans[D[max(X)]] = d
Y = X[:i]
Z = X[i + 1:]
calc(Y, d + 1, ans, D)
calc(Z, d + 1, ans, D)
# ---------------------------------------
def factorization(n, l):
c = n
if prime(n) == True:
l.append(n)
return l
for i in range(2, c):
if n == 1:
break
while n % i == 0:
l.append(i)
n = n // i
return l
# endregion------------------------------
def good(b):
l = []
i = 0
while (len(b) != 0):
if b[i] < b[len(b) - 1 - i]:
l.append(b[i])
b.remove(b[i])
else:
l.append(b[len(b) - 1 - i])
b.remove(b[len(b) - 1 - i])
if l == sorted(l):
# print(l)
return True
return False
# arr=[]
# print(good(arr))
def generate(st, s):
if len(s) == 0:
return
# If current string is not already present.
if s not in st:
st.add(s)
# Traverse current string, one by one
# remove every character and recur.
for i in range(len(s)):
t = list(s).copy()
t.remove(s[i])
t = ''.join(t)
generate(st, t)
return
#=--------------------------------------------longest increasing subsequence
def largestincreasingsubsequence(A):
l = [1]*len(A)
sub=[]
for i in range(1,len(l)):
for k in range(i):
if A[k]<A[i]:
sub.append(l[k])
l[i]=1+max(sub,default=0)
return max(l,default=0)
#----------------------------------
# Function to calculate
# Bitwise OR of sums of
# all subsequences
def findOR(nums, N):
# Stores the prefix
# sum of nums[]
prefix_sum = 0
# Stores the bitwise OR of
# sum of each subsequence
result = 0
# Iterate through array nums[]
for i in range(N):
# Bits set in nums[i] are
# also set in result
result |= nums[i]
# Calculate prefix_sum
prefix_sum += nums[i]
# Bits set in prefix_sum
# are also set in result
result |= prefix_sum
# Return the result
return result
def OR(a, n):
ans = a[0]
for i in range(1, n):
ans |= a[i]
#l.append(ans)
return ans
def toString(List):
return ''.join(List)
# Function to print permutations of string
# This function takes three parameters:
# 1. String
# 2. Starting index of the string
# 3. Ending index of the string.
def permute(a, l, r,p):
if l == r:
p.append(toString(a))
else:
for i in range(l, r + 1):
a[l], a[i] = a[i], a[l]
permute(a, l + 1, r,p)
a[l], a[i] = a[i], a[l] # backtrack
# Function to find square root of
# given number upto given precision
def squareRoot(number, precision):
start = 0
end, ans = number, 1
# For computing integral part
# of square root of number
while (start <= end):
mid = int((start + end) / 2)
if (mid * mid == number):
ans = mid
break
# incrementing start if integral
# part lies on right side of the mid
if (mid * mid < number):
start = mid + 1
# decrementing end if integral part
# lies on the left side of the mid
else:
end = mid - 1
# For computing the fractional part
# of square root upto given precision
increment = 0.1
for i in range(0, precision):
while (ans * ans <= number):
ans += increment
# loop terminates when ans * ans > number
ans = ans - increment
increment = increment / 10
return ans
def countRectangles(l, w):
# if we take gcd(l, w), this
# will be largest possible
# side for suare, hence minimum
# number of square.
squareSide = math.gcd(l, w)
return int((l * w) / (squareSide * squareSide))
# Function that count the
# total numbersProgram between L
# and R which have all the
# digit same
def count_same_digit(L, R):
tmp = 0
ans = 0
n = int(math.log10(R) + 1)
for i in range(0, n):
# tmp has all digits as 1
tmp = tmp * 10 + 1
for j in range(1, 10):
if (L <= (tmp * j) and (tmp * j) <= R):
#print(tmp*j)
# Increment the required count
ans += 1
return ans
#----------------------------------print k closest number of a number in an array
def findCrossOver(arr, low, high, x):
# Base cases
if (arr[high] <= x): # x is greater than all
return high
if (arr[low] > x): # x is smaller than all
return low
# Find the middle point
mid = (low + high) // 2
if (arr[mid] <= x and arr[mid + 1] > x):
return mid
if (arr[mid] < x):
return findCrossOver(arr, mid + 1, high, x)
return findCrossOver(arr, low, mid - 1, x)
def Kclosest(arr, x, k, n,ans):
# Find the crossover point
l = findCrossOver(arr, 0, n - 1, x)
r = l + 1
count = 0
if (arr[l] == x):
l -= 1
#print(l)
while (l >= 0 and r < n and count < k):
if (x - arr[l] < arr[r] - x):
ans.append(arr[l])
l -= 1
else:
ans.append(arr[r])
r += 1
count += 1
while (count < k and l >= 0):
ans.append(arr[l])
l -= 1
count += 1
while (count < k and r < n):
ans.append(arr[r])
r += 1
count += 1
return ans
#---------------------------------------------------------------
def prime(n):
if n <= 1: # negative numbers, 0 or 1
return False
if n <= 3: # 2 and 3
return True
if n % 2 == 0 or n % 3 == 0:
return False
for i in range(5, int(math.sqrt(n)) + 1, 2):
if n % i == 0:
return False
return True
def calcSum(arr, n, k):
# Initialize sum = 0
l=[]
sum=0
# Consider first subarray of size k
# Store the sum of elements
for i in range(k):
sum += arr[i]
# Print the current sum
l.append(sum)
# Consider every subarray of size k
# Remove first element and add current
# element to the window
for i in range(k, n):
# Add the element which enters
# into the window and substract
# the element which pops out from
# the window of the size K
sum = (sum - arr[i - k]) + arr[i]
# Print the sum of subarray
l.append(sum)
return l
def dfs(root,nodeVal,nodeConnection,visited):
leftVal = nodeVal[root][0]
rightVal = nodeVal[root][1]
solution = []
if nodeConnection[root]:
visited.add(root)
for i in nodeConnection[root]:
if i not in visited:
solution.append(dfs(i,nodeVal,nodeConnection,visited))
# print("solution",solution)
leftMax = 0
rightMax = 0
for i in solution:
l, r = i
leftMax += max(abs(leftVal - l[0]) + l[1], abs(leftVal - r[0]) + r[1])
rightMax += max(abs(rightVal - l[0]) + l[1], abs(rightVal - r[0]) + r[1])
# print(root,"return->",(leftVal,leftMax),(rightVal,rightMax))
return ((leftVal, leftMax), (rightVal, rightMax))
else:
# ((left,maxVal),(right,maxVal))
return ((leftVal, 0), (rightVal, 0))
def luckynumber(x,n,a):
if x >0:
a.append(x)
if x>10**9:
return a
else:
if x < 1e12:
luckynumber(x * 10 + 4,n,a)
luckynumber(x * 10 + 7,n,a)
def lcm(a,b):
return (a*b)//math.gcd(a,b)
def query(l, r):
if l >= r:
return -1
print('?', l + 1, r + 1)
sys.stdout.flush()
return int(input()) - 1
def answer(p):
print('!', p + 1)
sys.stdout.flush()
exit()
def main():
for _ in range(int(input())):
n=int(input())
arr=list(map(int,input().split()))
ans=[]
i=0
while(i<n):
ans.append([2,i+1,i+2])
ans.append([1,i+1,i+2])
ans.append([1,i+1,i+2])
ans.append([2,i+1,i+2])
ans.append([1,i+1,i+2])
ans.append([1,i+1,i+2])
i+=2
print(len(ans))
for i in ans:
print(*i)
if __name__ == '__main__':
main()
| 8 | PYTHON3 |
def ans(a):
sol = []
k = 0
for i in range(0,len(a),2):
k+=6
x = [[1,i+1,i+1+1],[2,i+1,i+1+1],[1,i+1,i+1+1],[2,i+1,i+1+1],[1,i+1,i+1+1],[2,i+1,i+1+1]]
sol.append(x)
return sol,k
#Fast I/O
import sys,os
import math
# To enable the file I/O i the below 2 lines are uncommented.
# read from in.txt if uncommented
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
# will print on Console if file I/O is not activated
#if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
# inputs template
from io import BytesIO, IOBase
def main():
for _ in range(int(input())):
n = input()
a = list(MI())
sol,k = ans(a)
print(k)
for i in sol:
for j in i:
print(*j)
# Sample Inputs/Output
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
#for array of integers
def MI():return (map(int,input().split()))
# endregion
#for fast output, always take string
def outP(var): sys.stdout.write(str(var)+'\n')
# end of any user-defined functions
MOD=10**9+7
mod=998244353
# main functions for execution of the program.
if __name__ == '__main__':
#This doesn't works here but works wonders when submitted on CodeChef or CodeForces
main()
| 8 | PYTHON3 |
for _ in range(int(input())):
n=int(input())
arr=list(map(int,input().split()))
print((n//2)*6)
x=1
y=2
for i in range(n//2):
print(2,x,y)
print(1,x,y)
print(1,x,y)
print(2,x,y)
print(1,x,y)
print(1,x,y)
x+=2
y+=2
| 8 | PYTHON3 |
t = int(input())
for _ in range(t):
n = int(input())
arr = [int(x) for x in input().split()]
operations = []
for i in range(0, n, 2):
a, b = arr[i], arr[i + 1]
while arr[i] != -a or arr[i + 1] != -b:
arr[i] += arr[i + 1]
arr[i + 1] -= arr[i]
operations.append('1 %d %d'%(i + 1, i + 2))
operations.append('2 %d %d'%(i + 1, i + 2))
k = len(operations)
print(k)
for i in range(k):
print(operations[i]) | 8 | PYTHON3 |
for _ in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
print(n * 3)
for i in range(0, n, 2):
for j in range(3):
print(1, i + 1, i + 2)
print(2, i + 1, i + 2)
| 8 | PYTHON3 |
import sys
from sys import stdin
def q(ty,i,j):
ans.append((ty,i+1,j+1))
if ty == 1:
a[i] = a[i] + a[j]
else:
a[j] = a[j] - a[i]
tt = int(stdin.readline())
for loop in range(tt):
n = int(stdin.readline())
a = list(map(int,stdin.readline().split()))
ans = []
for i in range(0,n,2):
for j in range(2):
q(1,i,i+1)
q(2,i,i+1)
q(1,i,i+1)
#print (*a,file=sys.stderr)
print (len(ans))
for i in ans:
print (*i) | 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve(void);
int main(){
int t;
cin>>t;
while(t--){
solve();
}
return 0;}
void solve(){
ll n,i;
cin>>n;
ll a[n+1];
for(i=1;i<=n;i++)
{cin>>a[i];
}
cout<<3*n<<endl;
for(i=1;i<n;i++)
{
cout<<"1"<<" "<<i<<" "<<i+1<<endl;
cout<<"2"<<" "<<i<<" "<<i+1<<endl;
cout<<"1"<<" "<<i<<" "<<i+1<<endl;
cout<<"2"<<" "<<i<<" "<<i+1<<endl;
cout<<"1"<<" "<<i<<" "<<i+1<<endl;
cout<<"2"<<" "<<i<<" "<<i+1<<endl;
i++;
}
}
| 8 | CPP |
#===========Template===============
from io import BytesIO, IOBase
from math import sqrt
import sys,os
from os import path
inpl=lambda:list(map(int,input().split()))
inpm=lambda:map(int,input().split())
inpi=lambda:int(input())
inp=lambda:input()
rev,ra,l=reversed,range,len
P=print
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
def B(n):
return bin(n).replace("0b","")
def factors(n):
arr=[]
for i in ra(2,int(sqrt(n))+1):
if n%i==0:
arr.append(i)
if i*i!=n:
arr.append(int(n/i))
return arr
def prime_factors(n):
omap={2:0}
while n!=1 and n%2==0:
omap[2]+=1
n/=2
for i in ra(3,int(math.sqrt(n))+1,2):
while n!=1 and n%i==0:
if i not in omap:omap[i]=1
else:omap[i]+=1
n/=i
if n!=1:
omap[int(n)]=1
return omap
def dfs(arr,n):
pairs=[[i+1] for i in ra(n)]
vis=[0]*(n+1)
for i in ra(l(arr)):
pairs[arr[i][0]-1].append(arr[i][1])
pairs[arr[i][1]-1].append(arr[i][0])
comp=[]
for i in ra(n):
stack=[pairs[i]]
temp=[]
if vis[stack[-1][0]]==0:
while len(stack)>0:
if vis[stack[-1][0]]==0:
temp.append(stack[-1][0])
vis[stack[-1][0]]=1
s=stack.pop()
for j in s[1:]:
if vis[j]==0:
stack.append(pairs[j-1])
else:
stack.pop()
comp.append(temp)
return comp
#=========I/p O/p ========================================#
from bisect import bisect_left as bl
from bisect import bisect_right as br
import sys,operator,math,operator
from collections import Counter
if(path.exists('input.txt')):
sys.stdin = open("input.txt","r")
sys.stdout = open("output.txt","w")
import random
#==============To chaliye shuru krte he ====================#
tc=inpi()
while tc:
tc -= 1
n=inpi()
li=inpl()
P(int(6*(n//2)))
for i in ra(0,n,2):
P(1,i+1,i+2)
P(2,i+1,i+2)
P(1,i+1,i+2)
P(1,i+1,i+2)
P(2,i+1,i+2)
P(1,i+1,i+2) | 8 | PYTHON3 |
#include <bits/stdc++.h>
#define ll long long int
#define fs first
#define sd second
#define pb push_back
#define pii pair<int, int>
using namespace std;
int main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int t; cin >> t;
while(t--){
int n; cin >> n;
ll a[n];
for(ll x : a) cin >> x;
//int k[5000];
/*
* i < j
* a[i] = k, k + l, k + l, l, l, -k, -k
* a[j] = l, l, -k, -k, -k - l, -k - l, -l
* n*3
* 1 i j
* 2 i j
* 1 i j
* 2 i j
* 1 i j
* 2 i j
*/
cout << 3*n << endl;
for(int i = 0; i < n; i += 2){
cout << "1 " << i+1 << " " << i+2 << endl;
cout << "2 " << i+1 << " " << i+2 << endl;
cout << "1 " << i+1 << " " << i+2 << endl;
cout << "2 " << i+1 << " " << i+2 << endl;
cout << "1 " << i+1 << " " << i+2 << endl;
cout << "2 " << i+1 << " " << i+2 << endl;
}
}
return 0;
}
| 8 | CPP |
t = int(input())
while(t):
t = t-1
n = int(input())
arr = list(map(int,input().split()))
print((n//2)*6)
for i in range(0,n, 2):
print(1, i+1, i+2)
for i in range(0,n, 2):
print(2, i+1, i+2)
for i in range(0,n, 2):
print(1, i+1, i+2)
for i in range(0,n, 2):
print(2, i+1, i+2)
for i in range(0,n, 2):
print(1, i+1, i+2)
for i in range(0,n, 2):
print(2, i+1, i+2) | 8 | PYTHON3 |
import sys
import math
input = sys.stdin.readline
imp = 'IMPOSSIBLE'
t = int(input())
for test in range(t):
n = int(input())
a = list(map(int, input().split(" ")))
print(3 * n)
for i in range(n // 2):
print('2 ' + str(2 * i + 1) + ' ' + str(2 * i + 2))
print('1 ' + str(2 * i + 1) + ' ' + str(2 * i + 2))
print('1 ' + str(2 * i + 1) + ' ' + str(2 * i + 2))
print('2 ' + str(2 * i + 1) + ' ' + str(2 * i + 2))
print('1 ' + str(2 * i + 1) + ' ' + str(2 * i + 2))
print('1 ' + str(2 * i + 1) + ' ' + str(2 * i + 2))
# print('CASE #' + str(test + 1) + ': ' + str(res))
| 8 | PYTHON3 |
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
try:
# sys.setrecursionlimit(int(pow(10,6)))
sys.stdin = open("input.txt", "r")
# sys.stdout = open("../output.txt", "w")
except:
pass
def pmat(A):
for ele in A:
print(*ele,end="\n")
for _ in range(L()[0]):
n=L()[0]
A=L()
ops=[]
for i in range(0,n,2):
ops.append([1,i+1,i+2])
ops.append([2,i+1,i+2])
ops.append([1,i+1,i+2])
ops.append([2,i+1,i+2])
ops.append([1,i+1,i+2])
ops.append([2,i+1,i+2])
print(len(ops))
pmat(ops)
endtime = time.time()
# print(f"Runtime of the program is {endtime - starttime}")
| 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pi pair<int, int>
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define FIO ios_base::sync_with_stdio(0), cin.tie(0)
#define fi first
#define se second
void per(int type, int i, int j) {
cout << type << " " << i << " " << j << endl;
}
signed main() {
FIO;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
cout << (3 * n) << endl;
for (int i = 1; i <= n; i += 2) {
per(2, i, i + 1);
per(1, i, i + 1);
per(2, i, i + 1);
per(2, i, i + 1);
per(1, i, i + 1);
per(2, i, i + 1);
}
}
}
| 8 | CPP |
// Lam lai cuoc doi thoiiiiiiiiii :)))))
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<list>
#define inf 99999999999999999
#define MOD 1000000007
#define endl "\n"
#define ll long long
//#define ll unsigned long long
#define forl(i,a,b) for(ll i=a;i<=b;i++)
#define forx(i,a,b) for(ll i=a;i>=b;i--)
#define fi first
#define se second
#define maxn 205
using namespace std;
//---------------------------------------KHAI BAO BIEN----------------------------------------------
typedef pair<long long,long long> ii;
typedef pair<ii,long long> iii;
typedef pair<int,int> pii;
typedef pair<long long,ii> piii;
int tdong[5]={0,1,-1,0,0};
int tcot[5]={0,0,0,1,-1};
int tdm[9]={0,-2,-2,-1,-1,1,1,2,2};
int tcm[9]={0,-1,1,-2,2,-2,2,-1,1};
ll t,n,m;
string cong( string s1,string s2)
{
if(s1=="0" && s2=="0")return "0";
if(s1.length()>s2.length())swap(s1,s2);
s2="0"+s2;
while(s1.length()!=s2.length())
{
s1="0"+s1;
}
int nho=0,nho_1=0;
forx(i,s1.length()-1,0)
{
nho=(bool)(((int)s1[i]-48+(int)s2[i]-48)+nho_1>=10);
s1[i]=(char)((((int)s1[i]-48+(int)s2[i]-48)+nho_1)%10+48);
nho_1=nho;
//cout<<s1<<" "<<s2<<" "<<nho<<endl;
}
while(s1[0]=='0')s1.erase(0,1);
return s1;
}
ll ucln(ll a,ll b)
{
while(a!=b && a!=0 && b!=0)
{
//cout<<a<<" "<<b<<endl;
if(a>b)a=a%b;
else b=b%a;
}
return max(a,b);
}
struct fenwick_tree
{
ll tree[100005];
ll mang[100005];
void khoi_tao(ll max_n)
{
forl(i,0,max_n)tree[i]=0;
}
void update(ll to,ll value)
{
for(to;to<100004;to+=to&(-to))tree[to]=(tree[to]+value);
}
ll tinh_tong(ll to)
{
ll kq=0;
if(to!=0)for(to;to>0;to-=to&(-to))kq=(kq+tree[to])%MOD;
return kq;
}
ll sum(ll from,ll to)
{
return (tinh_tong(to)-tinh_tong(from-1))%MOD;
}
void update_gcd(ll to,ll value)
{
for(to;to<100004;to+=to&(-to))tree[to]=ucln(tree[to],value);
}
ll gcd_range(int l,int r)
{
ll kq=0;
l--;
while(r>l)
{
// cout<<r<<" "<<(r-(r&(-r)))<<" "<<l<<" "<<tree[r]<<endl;
if((r-r&(-r))>=l)
{
kq=ucln(kq,tree[r]);
r-=r&(-r);
}
else
{
kq=ucln(kq,mang[r]);
r--;
}
}
return kq;
}
};
//---------------------------------------CHUONG TRINH CON-----------------------------------------------------
struct segment_tree
{
ll lazy[200005],s_tree[200005];
void khoi_tao()
{
forl(i,1,200004){lazy[i]=0;s_tree[i]=0;}
}
void update_range(ll vt,ll r_left,ll r_right,ll t_left,ll t_right,ll value)
{
if(lazy[vt]!=0)
{
s_tree[vt]+=lazy[vt];
lazy[vt*2]+=lazy[vt];
lazy[vt*2+1]+=lazy[vt];
lazy[vt]=0;
}
if(r_left>t_right || t_left>r_right)return;
else if(r_left<=t_left && r_right>=t_right)
{
s_tree[vt]+=value;
lazy[vt*2]+=value;
lazy[vt*2+1]+=value;
return;
}
else
{
ll mid=(t_left+t_right)/2;
update_range(vt*2,r_left,r_right,t_left,mid,value);
update_range(vt*2+1,r_left,r_right,mid+1,t_right,value);
//max,min
s_tree[vt]=max(s_tree[vt*2],s_tree[vt*2+1]);
}
}
ll max_range(ll vt,ll r_left,ll r_right,ll t_left,ll t_right )
{
if(lazy[vt]!=0)
{
s_tree[vt]+=lazy[vt];
lazy[vt*2]+=lazy[vt];
lazy[vt*2+1]+=lazy[vt];
lazy[vt]=0;
}
if(r_left>t_right || r_right<t_left)return -inf;
else if(r_left<=t_left && r_right>=t_right)return s_tree[vt];
else
{
ll mid=(t_left+t_right)/2;
return max(max_range(vt*2,r_left,r_right,t_left,mid),max_range(vt*2+1,r_left,r_right,mid+1,t_right));
}
}
};
ll toi_uu_nhan(ll a,ll b,ll mod)
{
if(mod==0)return 999999999;
if(a==0 || b==0 || mod==1)return 0;
if(a<(mod/b+1))return a*b;
a=a%mod;b=b%mod;
if(a<b)swap(a,b);//a=5, b=2, mod=4
ll tam=mod/a+(bool)(mod%a!=0);//tam=1
ll mod_a=(a*tam)%mod;//mod_a=1
ll need=b/tam;//need=2
ll du=b-tam*need;//du=0
ll con_lai=du*a;//con_lai=0
//cout<<tam<<" "<<mod_a<<" "<<need<<" "<<du<<" "<<con_lai<<endl;
return (toi_uu_nhan(mod_a,need,mod)+con_lai)%mod;// ((0*1)%10 + 5) %10 =5
}
ll pow_f(ll a,ll b,ll k)
{
if(k==0)return 999999999;
if(k==1)return 0;
ll kq=1;
a%=k;
while(b>0)
{
if(b%2!=0){kq=toi_uu_nhan(kq,a,k);}
a=toi_uu_nhan(a,a,k);
b/=2;//cout<<a<<" "<<b<<" "<<kq<<endl;
}
return kq;
}
short parent[1005];
bool visit[100005];
long long d[100005],table[2005][2005];
int getmin()
{
ll dd=inf,u=0;
forl(i,1,n)if(!visit[i] && d[i]<dd){dd=d[i];u=i;}
return u;
}
void prim(int s)
{
forl(i,1,n){visit[i]=false;d[i]=inf;}
d[s]=0;
while(true)
{
int u=getmin();
//cout<<u<<endl;
if(u==0)break;
visit[u]=true;
forl(i,1,n)
{
if(!visit[i])d[i]=min(d[i],table[u][i]);
}
}
}
ll distra(int s,int t)
{
forl(i,1,n){visit[i]=false;d[i]=inf;}
d[s]=0;
while(true)
{
int u=getmin();
//cout<<u<<endl;
if(u==0 || u==t)return d[t];
visit[u]=true;
forl(i,1,n)
{
if(!visit[i])d[i]=min(d[i],max(table[u][i],d[u]));
}
}
}
int find_parent(int a)
{
if(parent[a]==a)return parent[a];
else return parent[a]=find_parent(parent[a]);
}
void join(int a,int b)
{
a=find_parent(a);
b=find_parent(b);
parent[b]=a;
}
bool check(int i,int j)
{
return(i>=1 && j>=1 && i<=n && j<=m);
}
struct edge
{
ll ii,jj,ww;
edge(int ii,int jj, int ww)
{
this->ii=ii;
this->jj=jj;
this->ww=ww;
}
};
void distra_heap(int s,int t,vector<ii> canh[])
{
forl(i,1,n){d[i]=inf;visit[i]=false;}
d[s]=0;
priority_queue<ii, vector<ii>, greater<ii> > pq;
pq.push(ii(0,s));
while(!pq.empty())
{
int u=pq.top().second;
pq.pop();
if(visit[u])continue;
visit[u]=true;
forl(i,0,canh[u].size()-1)
{
d[canh[u][i].first]=min(d[canh[u][i].first],d[u]+canh[u][i].second);
pq.push(ii( d[canh[u][i].first],canh[u][i].first));
}
}
}
bool kt[1000005];
vector<ll> snt;
void sang()
{
forl(i,1,1000001)kt[i]=false;
kt[2]=1;
snt.push_back(2);
ll vt=3;
while(vt<=1000000)
{
while(kt[vt] && vt<=1000000)vt+=2;
kt[vt]=true;snt.push_back(vt);//cout<<vt<<endl;
for(ll k=vt*vt;k<=1000000;k+=vt){if(k<1000000)kt[k]=true;}
}
}
//---------------------------------------CHUONG TRINH CHINH--------------------------------------------------
int bb[19];
void bin(int x,int sl)
{
stack<int> s;
int dem=0;
while(x>0)
{
if(x%2!=0)s.push(1);
else s.push(0);
x/=2;
dem++;
}
while(dem<sl){s.push(0);dem++;}
while(!s.empty()){cout<<s.top();s.pop();}
cout<<endl;
}
string intostring(ll a)
{
stack<int> st;
while(a>0)
{
st.push(a%10);
a/=10;
}
string s;
while(!st.empty())
{
s+=(char)(st.top()+'0');st.pop();
}
return s;
}
/*ll gt[1000005],tu[1000004],dp[1000005];
ll nck(ll n,ll k)
{
if(n<k || n<0 || k<0)return 0;
else return 1LL*gt[n]*tu[n-k]%MOD *tu[k]%MOD;
}
*/
int fn(ll s1,ll s2,ll m)
{
if(s1<=s2){return (s2-s1);}
ll tam=s1-s2;
ll kq=tam/m+(tam%m!=0);
return kq*m+s2-s1;
}
bool ch(ll n,ll adj[],ll m)
{
ll tam=fn(adj[1],adj[2],m);
forl(i,3,n)if((adj[i]+m-tam)%m!=adj[i-1])return false;
return true;
}
int main()
{
/**/#ifndef ONLINE_JUDGE
freopen("test.inp","r",stdin);
freopen("test.out","w",stdout);
#endif // ONLINE_JUDGE //『 』
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//cin.ignore();
//cout<<fixed;
//cout<<setprecision(6);
/**/
t=1;
cin>>t;
//--------------
while(t--)
{
int n,m;
cin>>n;
forl(i,1,n)cin>>m;
cout<<n*3<<endl;
forl(i,1,n/2)
{
cout<<1<<" "<<i<<" "<<i+n/2<<endl;
cout<<2<<" "<<i<<" "<<i+n/2<<endl;
cout<<1<<" "<<i<<" "<<i+n/2<<endl;
cout<<2<<" "<<i<<" "<<i+n/2<<endl;
cout<<1<<" "<<i<<" "<<i+n/2<<endl;
cout<<2<<" "<<i<<" "<<i+n/2<<endl;
}
}
//}//-------
}
| 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
const int N = 1010;
int a[N];
int main()
{
int t;
scanf("%d",&t);
while(t --)
{
int n;
scanf("%d",&n);
for(int i = 1; i <= n; i ++) scanf("%d",&a[i]);
printf("%d\n",3 * n);
for(int i = 1; i <= n; i += 2)
{
printf("1 %d %d\n",i,i + 1);
printf("2 %d %d\n",i,i + 1);
printf("1 %d %d\n",i,i + 1);
printf("1 %d %d\n",i,i + 1);
printf("2 %d %d\n",i,i + 1);
printf("1 %d %d\n",i,i + 1);
}
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int T , n , a[110000];
int main()
{
scanf("%d" , &T);
while(T--)
{
scanf("%d" , &n);
for(int i = 1 ; i <= n ; i++ ) scanf("%d" , &a[i]);
cout << 3 * n << endl;
for(int i = 1 ; i <= n ; i += 2 )
{
printf("2 %d %d\n" , i , i + 1);
printf("1 %d %d\n" , i , i + 1);
printf("2 %d %d\n" , i , i + 1);
printf("1 %d %d\n" , i , i + 1);
printf("2 %d %d\n" , i , i + 1);
printf("1 %d %d\n" , i , i + 1);
}
}
return 0;
}
/*
*/
| 8 | CPP |
import sys
from sys import stdout
import io, os
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
# input = sys.stdin.buffer.readline
P = lambda: list(map(int, input().split()))
from math import factorial as f
from collections import deque, defaultdict as dd
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, merge
mod = 10**9+7
a = ord('a')
def fast_exp(x, exp):
ans = 1
base = x
while exp:
if exp & 1:
ans *= base
base *= base
base %= mod
ans %= mod
exp >>= 1
return ans
def solve():
n = int(input())
l = P()
print(3 * n)
for i in range(1, n+1, 2):
print(2, i, i+1)
print(1, i, i+1)
print(2, i, i+1)
print(2, i, i+1)
print(1, i, i+1)
print(2, i, i+1)
tc = int(input())
for t in range(1, tc+1):
solve()
| 8 | PYTHON3 |
# cook your dish here
t = int(input())
for i in range(t):
n = int(input())
a = list(map(int,input().split()))
print((n//2)*6)
for j in range(0,n,2):
print(1,j+1,j+2)
print(2,j+1,j+2)
print(1,j+1,j+2)
print(2,j+1,j+2)
print(1,j+1,j+2)
print(2,j+1,j+2) | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int N;
int A[1010];
int main() {
int tc; scanf("%d", &tc);
while(tc--) {
scanf("%d", &N);
for(int i = 1; i <= N; i++) scanf("%d", &A[i]);
printf("%d\n", N * 3);
for(int i = 1; i <= N / 2; i++) {
int a = 2 * i - 1, b = 2 * i;
printf("1 %d %d\n", a, b);
printf("2 %d %d\n", a, b);
printf("1 %d %d\n", a, b);
printf("2 %d %d\n", a, b);
printf("1 %d %d\n", a, b);
printf("2 %d %d\n", a, b);
}
}
return 0;
} | 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define vec vector<lli>
#define vecp vector<pair<lli,lli> >
#define mod 1000000007
#define INF 1000000000000000001
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define all(x) (x).begin(),(x).end()
#define ins insert
#define shree lli t;cin>>t;while(t--)
//lli gcd(lli a,lli b){if(a==0)return b;return gcd(b%a,a);}
//lli lcm(lli a,llib){return (a*b)/gcd(a,b);}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
shree
{
lli n,i,a;
vec v;
cin>>n;
for(i=0;i<n;i++)
{
cin>>a;
v.pb(a);
}
cout<<(n/2)*6<<endl;
for(i=0;i<n;i+=2)
{
cout<<"1 "<<i+1<<" "<<i+2<<endl;
cout<<"2 "<<i+1<<" "<<i+2<<endl;
cout<<"2 "<<i+1<<" "<<i+2<<endl;
cout<<"1 "<<i+1<<" "<<i+2<<endl;
cout<<"2 "<<i+1<<" "<<i+2<<endl;
cout<<"2 "<<i+1<<" "<<i+2<<endl;
}
}
}
| 8 | CPP |
#include <bits/stdc++.h>
const long long SZ = 1e5 + 7;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
const long long MOD = 998244353;
long long opnmbr = 1;
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define vi vector<ll>
#define mi map<ll, ll>
#define umi unordered_map<ll, ll>
#define sz(x) (ll)x.size()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define mp(x,y) make_pair(x,y)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rev(a) reverse(all(a))
#define unq(a) a.erase(std::unique(all(a)),a.end());
#define max(a,b) ((a > b) ? a : b)
#define min(a,b) ((a < b) ? a : b)
#define ci(X) ll X; cin>>X
#define cii(X, Y) ll X, Y; cin>>X>>Y
#define ciii(X, Y, Z) ll X, Y, Z; cin>>X>>Y>>Z
#define ciiii(W, X, Y, Z) ll W, X, Y, Z; cin>>W>>X>>Y>>Z
#define dbg(x) cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<" "<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<" "<<#z<<"="<<(z)<<" "<<#w<<"="<<(w)<<endl;
#define kick() cout<<"Case #"<<opnmbr++<<": ";
#define start_karo ll ___t; cin>>___t; while (___t--)
#define chalo_achha_hai ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define kardia solve();
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define mem0(X) memset((X), 0, sizeof((X)))
#define mem1(X) memset((X), -1, sizeof((X)))
#define setbits(x) __builtin_popcountll(x)
#define yes() cout<<"YES"<<endl
#define no() cout<<"NO"<<endl
#define err() cout<<"===========\n";
#define errA(A) for(auto i:A) cout<<i<<" ";cout<<"\n";
#define err1(a) cout<<#a<<" "<<a<<"\n"
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n"
using namespace std;
ll powermod(ll a, ll b)
{
ll ans = 1;
while (b)
{
if (b & 1) ans = (ans * a) % MOD;
b = b / 2;
a = (a * a) % MOD;
}
return ans;
}
/* GCD and LCM of two numbers */
ll gcd(ll a, ll b)
{
if (b == 0) return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
return (a / gcd(a, b)) * b;
}
/* Prime Numbers Sieve Method */
const long long nod = 1000000;
vector<char> is_prime(nod+1, true);
vector<int> prime;
void sieve(){
is_prime[0] = is_prime[1] = false;
for (int i = 2; i * i <= nod; i++) {
if (is_prime[i]) {
for (int j = i * i; j <= nod; j += i)
is_prime[j] = false;
}
}
for(int i=0;i<=nod;i++)
{
if(is_prime[i])
prime.push_back(i);
}
}
/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
/*..................................................................................................................................................................................................*/
/*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/
void solve()
{
ci(n);
fr(i,0,n)
{
int x;
cin >>x;
}
cout<<n/2 * 6<<endl;
for(int i=0;i<n;i+=2)
{
int turn = 1;
for(int j=0;j<6;j++)
{
if(turn)
{cout<<1<<" "<<i+1<<" "<<i+2<<endl; turn = 0; }
else
{
cout<<2<<" "<<i+1<<" "<<i+2<<endl; turn = 1;
}
}
}
}
signed main()
{
chalo_achha_hai
#ifndef ONLINE_JUDGE
freopen("input.txt" , "r" , stdin); freopen("output.txt" , "w" , stdout);
#endif
//sieve();
start_karo
{
//kick()
kardia
}
// kardia
return 0;
} | 8 | CPP |
// #pragma GCC optimize("Ofast","inline","-ffast-math")
// #pragma GCC target("avx,sse2,sse3,sse4,mmx")
//#pragma GCC optimize(3)//O3
//#pragma GCC optimize(2)//O2
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<map>
#include<set>
//#include<unordered_map>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
#include<fstream>
#define X first
#define Y second
#define best 131
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define lowbit(x) x & -x
#define inf 0x3f3f3f3f
#define max(a,b) a>b?a:b
#define min(a,b) a<b?a:b
//#define int long long
//#define double long double
//#ifndef ONLINE_JUDGE freopen("data.in.txt","r",stdin);
//freopen("data.out.txt","w",stdout); #endif //文件读取
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double pai=acos(-1.0);
const int Mod=998244353;
const double eps=1e-9;
const int N=26;
const int mod=51123987;
const int maxn=1e6+10;
/*--------------------------------------------*/
inline int read()
{
int data=0,w=1; char ch=0;
while(ch!='-' && (ch<'0' || ch>'9')) ch=getchar();
if(ch=='-') w=-1,ch=getchar();
while(ch>='0' && ch<='9') data=data*10+ch-'0',ch=getchar();
return data*w;
}
/*--------------------------------------------*/
int t,n,m,a[maxn];
string s;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>t;
while(t--)
{
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
cout<<n*3<<endl;
for(int i=1;i<=n;i+=2)
{
cout<<2<<' '<<i<<' '<<i+1<<endl;
cout<<1<<' '<<i<<' '<<i+1<<endl;
cout<<1<<' '<<i<<' '<<i+1<<endl;
cout<<2<<' '<<i<<' '<<i+1<<endl;
cout<<1<<' '<<i<<' '<<i+1<<endl;
cout<<1<<' '<<i<<' '<<i+1<<endl;
}
}
return 0;
} | 8 | CPP |
t = int(input())
while t > 0:
t -= 1
n = int(input())
input()
print(6 * n // 2)
for i in range(0, n, 2):
print('2', i + 1, i + 2)
print('2', i + 1, i + 2)
print('1', i + 1, i + 2)
print('2', i + 1, i + 2)
print('2', i + 1, i + 2)
print('1', i + 1, i + 2)
# from copy import copy
#
# b = [2, 3]
# for mask in range(64):
# a = copy(b)
# for i in range(6):
# if mask >> i & 1:
# a[0] += a[1]
# else:
# a[1] -= a[0]
# # print(a)
# if a == [-2, -3]:
# print(mask) | 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define BUFF ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define IO freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define P(x) cout<<x<<endl
#define P2(x,y) cout<<x<<' '<<y<<endl
#define P3(x,y,z) cout<<x<<' '<<y<<' '<<z<<endl
#define P4(x,y,z,u) cout<<x<<' '<<y<<' '<<z<<' '<<u<<endl
#define P5(x,y,z,u,v) cout<<x<<' '<<y<<' '<<z<<' '<<u<<' '<<v<<endl
#define P6(x,y,z,u,v,w) cout<<x<<' '<<y<<' '<<z<<' '<<u<<' '<<v<<' '<<w<<endl
#define PV(x) for(auto ii:(x)){cout<<ii<<' ';}cout<<endl
#define PN(x,n) for(int ii=1;ii<=(n);ii++){cout<<x[ii]<<' ';}cout<<endl
#define PNN(x,n,m) for(int ii=1;ii<=(n);ii++){for(int jj=1;jj<=(m);jj++){cout<<x[ii][jj]<<' ';}cout<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const ll D = 0;
const ll N = 1e5 + 5;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const double eps = 1e-9;
ll n,a[N];
int solve()
{
cin>>n;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
}
P(3*n);
for(ll i=1;i<=n;i+=2)
{
//ll x=a[i],y=a[i+1];
P3(1,i,i+1);
P3(2,i,i+1);
P3(1,i,i+1);
P3(2,i,i+1);
P3(1,i,i+1);
P3(2,i,i+1);
}
return 0;
}
int main()
{
BUFF;
if(D)IO;
ll t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
} | 8 | CPP |
for _ in range(int(input())):
n=int(input())
arr=list(map(int,input().split()))
i=0
print(n//2 *6)
while i <n:
for j in range(3):
print(2,i+1,i+2)
print(1,i+1,i+2)
i+=2 | 8 | PYTHON3 |
#include <bits/stdc++.h>
#define monke_flip ios_base::sync_with_stdio(false); cin.tie(NULL);
#define random_monke srand(chrono::system_clock::now().time_since_epoch().count());
#ifdef LEL
#include <dbg.h>
#else
#define dbg(...) {/* temon kichu na; */}
#endif
using namespace std;
using ll = long long;
const int MONKE = 0;
void solve(){
int n;
cin>>n;
vector <int> v(n);
for(auto &e:v){
cin>>e;
}
cout<<3*n<<'\n';
for(int i=0;i<n;i+=2){
cout<<1<<' '<<i+1<<' '<<i+2<<'\n';
cout<<2<<' '<<i+1<<' '<<i+2<<'\n';
cout<<1<<' '<<i+1<<' '<<i+2<<'\n';
cout<<1<<' '<<i+1<<' '<<i+2<<'\n';
cout<<2<<' '<<i+1<<' '<<i+2<<'\n';
cout<<1<<' '<<i+1<<' '<<i+2<<'\n';
}
}
int main()
{
monke_flip
int t = 1;
cin>>t;
for(int tc=1; tc<=t; tc++){
solve();
}
return MONKE;
} | 8 | CPP |
/* Author : S Kowsihan */
#include<bits/stdc++.h>
using namespace std;
using namespace chrono;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x<<" "; _print(x); cerr << endl;
#else
#define debug(x);
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
void _print(ll t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(lld t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(ull t) { cerr << t; }
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) { cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}"; }
template <class T> void _print(vector <T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }
template <class T> void _print(set <T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }
template <class T> void _print(multiset <T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }
template <class T, class V> void _print(map <T, V> v) { cerr << "[ "; for (auto i : v) { _print(i); cerr << " "; } cerr << "]"; }
// void _print(pbds v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) { if (b > a) { return gcd(b, a); } if (b == 0) { return a; } return gcd(b, a % b); }
ll expo(ll a, ll b, ll mod) { ll res = 1; while (b > 0) { if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1; } return res; }
void extendgcd(ll a, ll b, ll* v) { if (b == 0) { v[0] = 1; v[1] = 0; v[2] = a; return; } extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return; } //pass an arry of size1 3
ll mminv(ll a, ll b) { ll arr[3]; extendgcd(a, b, arr); return arr[0]; } //for non prime b
ll mminvprime(ll a, ll b) { return expo(a, b - 2, b); }
bool revsort(ll a, ll b) { return a > b; }
void swap(int& x, int& y) { int temp = x; x = y; y = temp; }
ll combination(ll n, ll r, ll m, ll* fact, ll* ifact) { ll val1 = fact[n]; ll val2 = ifact[n - r]; ll val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m; }
void google(int t) { cout << "Case #" << t << ": "; }
vector<ll> sieve(int n) { int* arr = new int[n + 1](); vector<ll> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) { vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1; } return vect; }
ll mod_add(ll a, ll b, ll m) { a = a % m; b = b % m; return (((a + b) % m) + m) % m; }
ll mod_mul(ll a, ll b, ll m) { a = a % m; b = b % m; return (((a * b) % m) + m) % m; }
ll mod_sub(ll a, ll b, ll m) { a = a % m; b = b % m; return (((a - b) % m) + m) % m; }
ll mod_div(ll a, ll b, ll m) { a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m; } //only for prime m
ll phin(ll n) { ll number = n; if (n % 2 == 0) { number /= 2; while (n % 2 == 0) n /= 2; } for (ll i = 3; i <= sqrt(n); i += 2) { if (n % i == 0) { while (n % i == 0)n /= i; number = (number / i * (i - 1)); } } if (n > 1)number = (number / n * (n - 1)); return number; } //O(sqrt(N))
/*--------------------------------------------------------------------------------------------------------------------------*/
#define f(a, b, c) for (ll i = a; i < b; i += c)
#define fo(i, a, b, c) for (ll i = a; i < b; i += c)
#define fd(a, b, c) for (ll i = a; i >= b; i -= c)
#define fdo(i, a, b, c) for (ll i = a; i >= b; i -= c)
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/*--------------------------------------------------------------------------------------------------------------------------*/
void solve() {
ll TT;
cin >> TT;
while (TT--)
{
ll n;
cin >> n;
vl ar(n);
f(0, n, 1) cin >> ar[i];
ll k = 3 * n;
cout << k << endl;
f(0, n, 2) {
cout << 2 << " " << i + 1 << " " << i + 2 << endl;
cout << 2 << " " << i + 1 << " " << i + 2 << endl;
cout << 1 << " " << i + 1 << " " << i + 2 << endl;
cout << 2 << " " << i + 1 << " " << i + 2 << endl;
cout << 2 << " " << i + 1 << " " << i + 2 << endl;
cout << 1 << " " << i + 1 << " " << i + 2 << endl;
}
}
}
int main() {
#ifndef ONLINE_JUDGE
freopen("Error.txt", "w", stderr);
#endif
fastio();
auto start1 = high_resolution_clock::now();
solve();
auto stop1 = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop1 - start1);
#ifndef ONLINE_JUDGE
cerr << "Time: " << duration.count() / 1000 << endl;
#endif
}
| 8 | CPP |
for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
o = 3 * len(l)
print(o)
for i in range(1, n, 2):
print(1, i, i + 1)
print(2, i, i + 1)
print(1, i, i + 1)
print(2, i, i + 1)
print(1, i, i + 1)
print(2, i, i + 1) | 8 | PYTHON3 |
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ret(x) return cout<<x,0;
#define rety return cout<<"YES",0;
#define retn return cout<<"NO",0;
typedef long long ll;
typedef double db;
typedef long double ld;
#define stt string
#define ve vector<ll>
#define se set<ll>
#define ar array
ll mod=1e9+7,mod2=998244353;
using namespace std;
ll fac[10000000];
ll gcd(ll x, ll y)
{
if(y==0)
return x;
return gcd(y,x%y);
}
ll fexp(ll a,ll b,ll m){ll ans = 1;while(b){if(b&1)ans=ans*a%m; b/=2;a=a*a%m;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2,p);}
ll ncr(ll n, ll r,ll p)
{
if (r==0) return 1;
return (fac[n]*inverse(fac[n-r],p)%p*inverse(fac[r],p)%p)%p;
}
// ____Z-Algorithm_____
vector<ll> za(string s)
{
ll n = s.size();
vector<ll> z(n);
ll x = 0, y = 0,p=0;
for(ll i= 1; i < n; i++)
{
z[i] = max(p,min(z[i-x],y-i+1));
while(i+z[i] < n && s[z[i]] == s[i+z[i]])
{
x = i; y = i+z[i]; z[i]++;
}
}
return z;
}
void subset(ll a[],ll k)
{
for (int i = 1; i < pow(2, k); i++)
{
for (int j = 0; j < k; j++)
{
if (i & 1 << j)
{
cout<<a[j]<<" ";
}
}
cout<<endl;
}
}
vector<ll> pr(string s)
{
ll n = s.length();
vector<ll> pi(n);
for (int i = 1; i < n; i++)
{
int j = pi[i-1];
while (j > 0 && s[i] != s[j])
j = pi[j-1];
if (s[i] == s[j])
j++;
pi[i] = j;
}
return pi;
}
//---------------------------------------------------------------------/
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll t;
cin>>t;
while(t--)
{
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
cout << 3*n << endl;
for(int i = 1; i <= n; i+=2)
{
cout << 1 << " " << i << " " << i+1 << endl;
cout << 2 << " " << i << " " << i+1 << endl;
cout << 2 << " " << i << " " << i+1 << endl;
cout << 1 << " " << i << " " << i+1 << endl;
cout << 2 << " " << i << " " << i+1 << endl;
cout << 2 << " " << i << " " << i+1 << endl;
}
}
}
| 8 | CPP |
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";g++ -std=c++17 "$0")&&exec "./a.out" "$@"
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef vector<int> vi;
void solve(int TEST_CASE)
{
int n; cin>>n;
int a[n]; for(int i=0; i<n; i++) cin>>a[i];
cout<<(3*n)<<endl;
for(int i=0; i<n; i+=2) {
cout<<"1 "<<(i+1)<<" "<<(i+2)<<endl;
cout<<"1 "<<(i+1)<<" "<<(i+2)<<endl;
cout<<"2 "<<(i+1)<<" "<<(i+2)<<endl;
cout<<"1 "<<(i+1)<<" "<<(i+2)<<endl;
cout<<"1 "<<(i+1)<<" "<<(i+2)<<endl;
cout<<"2 "<<(i+1)<<" "<<(i+2)<<endl;
}
}
int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int test_cases; cin>>test_cases;
for(int i=1; i<=test_cases; i++)
solve(i);
} | 8 | CPP |
// author: sharad12arse
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define gcd __gcd
#define INF (ll)1e15
void solve(){
int n;
cin>>n;
vector<int> arr(n);
for(int i=0;i<n;i++){
cin>>arr[i];
}
cout<<3*n<<"\n";
for(int i=0;i<n;i+=2){
cout<<"1 "<<i+1<<" "<<i+2<<"\n";
cout<<"2 "<<i+1<<" "<<i+2<<"\n";
cout<<"1 "<<i+1<<" "<<i+2<<"\n";
cout<<"2 "<<i+1<<" "<<i+2<<"\n";
cout<<"1 "<<i+1<<" "<<i+2<<"\n";
cout<<"2 "<<i+1<<" "<<i+2<<"\n";
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t=1;
cin>>t;
while(t--){
solve();
}
// cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
} | 8 | CPP |
n=int(input())
for i in range(n):
k=int(input())
l=list(map(int,input().split()))
print(3*k)
for j in range(0,(k),2):
print(1,"",j+1,"",j+2)
print(2,"",j+1,"",j+2)
print(1,"",j+1,"",j+2)
print(2,"",j+1,"",j+2)
print(1,"",j+1,"",j+2)
print(2,"",j+1,"",j+2)
| 8 | PYTHON3 |
for i in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
print(3*n)
for i in range(n//2):
print(1,2*i+1,2*i+2)
print(2,2*i+1,2*i+2)
print(2,2*i+1,2*i+2)
print(1,2*i+1,2*i+2)
print(2,2*i+1,2*i+2)
print(2,2*i+1,2*i+2) | 8 | PYTHON3 |
from collections import deque
def recur(i, j):
dq = deque([(li[i], li[j], [])])
while True:
a, b, cur = dq.popleft()
dq.append([a + b, b, cur + [[1, i, j]]])
dq.append([a, b - a, cur + [[2, i, j]]])
if -a == li[i] and -b == li[j]:
return cur
for _ in range(int(input())):
n = int(input())
li = list(map(int, input().split()))
ret = []
for i in range(0, n, 2):
ret.extend(recur(i, i + 1))
print(len(ret))
for n in ret:
t, a, b = n
print(t, a + 1, b + 1) | 8 | PYTHON3 |
for i in range(int(input())):
n=int(input())
li=list(map(int,input().split()))
b=[]
for j in range(0,n,2):
if li[j]<li[j+1]:
b.append(6)
if li[j]==li[j+1]:
b.append(4)
if li[j]>li[j+1]:
b.append(6)
print(sum(b))
for j in range(0,n,2):
if li[j]<li[j+1]:
print(2, j + 1, j + 2)
print(1, j + 1, j + 2)
print(2, j + 1, j + 2)
print(1, j + 1, j + 2)
print(2, j + 1, j + 2)
print(1, j + 1, j + 2)
if li[j]==li[j+1]:
print(2, j + 1, j + 2)
print(2, j + 1, j + 2)
print(1, j + 1, j + 2)
print(1, j + 1, j + 2)
if li[j]>li[j+1]:
print(2, j + 1, j + 2)
print(1, j + 1, j + 2)
print(2, j + 1, j + 2)
print(1, j + 1, j + 2)
print(2, j + 1, j + 2)
print(1, j + 1, j + 2)
| 8 | PYTHON3 |
for _t in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
print(3 * n)
for i in range(0, n, 2):
print(1, i + 1, i + 2)
print(2, i + 1, i + 2)
print(1, i + 1, i + 2)
print(2, i + 1, i + 2)
print(1, i + 1, i + 2)
print(2, i + 1, i + 2)
| 8 | PYTHON3 |
import math
from collections import defaultdict
from heapq import heappush, heappop
DEBUG = True
def log(*args, **kwargs):
if DEBUG:
print(*args, **kwargs)
def ri():
return int(input())
def rl(f=int):
return list(map(f, input().split()))
def rs():
return input()
class Solution:
def __init__(self):
pass
def run(self):
n = ri()
a = rl()
print(n*3)
for i in range(0, n - 1, 2):
print(1, i + 1, i + 2)
a[i] += a[i + 1]
#print(a)
print(2, i + 1, i + 2)
a[i + 1] -= a[i]
#print(a)
print(1, i + 1, i + 2)
a[i] += a[i + 1]
#print(a)
print(2, i + 1, i + 2)
a[i + 1] -= a[i]
#print(a)
print(1, i + 1, i + 2)
a[i] += a[i + 1]
#print(a)
print(2, i + 1, i + 2)
a[i + 1] -= a[i]
#print('END:', a)
if __name__ == '__main__':
t = int(input())
s = Solution()
#print(s.run())
#s.run()
for i in range(t):
s.run()
# print(s.run())
| 8 | PYTHON3 |
/*
* Do smth instead of nothing and stay organized
*/
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define x first
#define y second
void solve() {
int n, x; cin >> n;
forn (i, n) cin >> x;
cout << 3 * n << '\n';
forn (i, n) {
forn (_, 3) {
cout << 1 << ' ' << i + 1 << ' ' << i + 2 << '\n';
cout << 2 << ' ' << i + 1 << ' ' << i + 2 << '\n';
}
i++;
}
}
int main(){
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t; cin >> t;
for (; t; t--) {
solve();
}
} | 8 | CPP |
# Problem: B. Lord of the Values
# Contest: Codeforces - Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2)
# URL: https://codeforces.com/problemset/problem/1523/B
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# Powered by CP Editor (https://cpeditor.org)
# ____ ____ ___ # skeon19
#| | / | | | |\ | #
#|____ |/ |___ | | | \ | # EON_KID
# | |\ | | | | \ | #
# ____| | \ ___ |____ |___| | \| # Soul_Silver
from collections import defaultdict
#from functools import reduce
#from bisect import bisect_right,bisect_left
#from sortedcontainers import SortedList, SortedSet, SortedDict
#import sympy #Prime number library
#import heapq
def main():
for _ in range(int(input())):
n=int(input())
d={}
l=list(map(int,input().split()))
count=0
for i in range(0,n,2):
x,y=l[i],l[i+1]
x+=y
d[count]=[1,i+1,i+2]
count+=1
while not(x==-l[i] and y==-l[i+1]):
#print(i,x,y)
if y>-l[i+1]:
y-=x
d[count]=[2,i+1,i+2]
count+=1
elif x>-l[i] and x+y>=-l[i]:
x+=y
d[count]=[1,i+1,i+2]
count+=1
else:
if y<-l[i+1]:
y-=x
d[count]=[2,i+1,i+2]
count+=1
else:
x+=y
d[count]=[1,i+1,i+2]
count+=1
#print("after",i,x,y)
print(count)
for i in range(count):
print(" ".join(map(str,d[i])))
###############################################################
def SumOfExpOfFactors(a):
fac = 0
lis=SortedList()
if not a&1:
lis.add(2)
while not a&1:
a >>= 1
fac += 1
for i in range(3,int(a**0.5)+1,2):
if not a%i:
lis.add(i)
while not a%i:
a //= i
fac += 1
if a != 1:
lis.add(a)
fac += 1
return fac,lis
###############################################################
div=[0]*(1000001)
def NumOfDivisors(n): #O(nlog(n))
for i in range(1,n+1):
for j in range(i,n+1,i):
div[j]+=1
###############################################################
def primes1(n): #return a list having prime numbers from 2 to n
""" Returns a list of primes < n """
sieve = [True] * (n//2)
for i in range(3,int(n**0.5)+1,2):
if sieve[i//2]:
sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)
return [2] + [2*i+1 for i in range(1,n//2) if sieve[i]]
##############################################################
def GCD(a,b):
if(b==0):
return a
else:
return GCD(b,a%b)
##############################################################
#
# 1
# / \
# 2 3
# /\ / \ \ \
#4 5 6 7 8 9
# \
# 10
class Graph:
def __init__(self):
self.Graph = defaultdict(list)
def addEdge(self, u, v):
self.Graph[u].append(v)
self.Graph[v].append(u)
#DFS Graph / tree
def DFSUtil(self, v, visited):
visited.add(v)
#print(v, end=' ')
for neighbour in self.Graph[v]:
if neighbour not in visited: #not needed if its a tree
self.DFSUtil(neighbour, visited)
def DFS(self, v):
visited = set() #not needed if its a tree
self.DFSUtil(v, visited) #Visited not needed if its a tree
#BFS Graph / tree
def BFS(self, s):
# Mark all the vertices as not visited
visited = set()
# Create a queue for BFS
queue = []
queue.append(s)
visited.add(s)
while queue:
s = queue.pop(0)
#print (s, end = " ")
for i in self.Graph[s]:
if i not in visited:
queue.append(i)
visited.add(i)
'''
g = Graph()
g.addEdge(1, 2)
g.addEdge(1, 3)
g.addEdge(2, 4)
g.addEdge(2, 5)
g.addEdge(3, 6)
g.addEdge(3, 7)
g.addEdge(3, 8)
g.addEdge(3, 9)
g.addEdge(6,10)
g.DFS(1)
g.BFS(1) '''
##############################################################
class SortedList:
def __init__(self, iterable=[], _load=200):
"""Initialize sorted list instance."""
values = sorted(iterable)
self._len = _len = len(values)
self._load = _load
self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
self._list_lens = [len(_list) for _list in _lists]
self._mins = [_list[0] for _list in _lists]
self._fen_tree = []
self._rebuild = True
def _fen_build(self):
"""Build a fenwick tree instance."""
self._fen_tree[:] = self._list_lens
_fen_tree = self._fen_tree
for i in range(len(_fen_tree)):
if i | i + 1 < len(_fen_tree):
_fen_tree[i | i + 1] += _fen_tree[i]
self._rebuild = False
def _fen_update(self, index, value):
"""Update `fen_tree[index] += value`."""
if not self._rebuild:
_fen_tree = self._fen_tree
while index < len(_fen_tree):
_fen_tree[index] += value
index |= index + 1
def _fen_query(self, end):
"""Return `sum(_fen_tree[:end])`."""
if self._rebuild:
self._fen_build()
_fen_tree = self._fen_tree
x = 0
while end:
x += _fen_tree[end - 1]
end &= end - 1
return x
def _fen_findkth(self, k):
"""Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`)."""
_list_lens = self._list_lens
if k < _list_lens[0]:
return 0, k
if k >= self._len - _list_lens[-1]:
return len(_list_lens) - 1, k + _list_lens[-1] - self._len
if self._rebuild:
self._fen_build()
_fen_tree = self._fen_tree
idx = -1
for d in reversed(range(len(_fen_tree).bit_length())):
right_idx = idx + (1 << d)
if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
idx = right_idx
k -= _fen_tree[idx]
return idx + 1, k
def _delete(self, pos, idx):
"""Delete value at the given `(pos, idx)`."""
_lists = self._lists
_mins = self._mins
_list_lens = self._list_lens
self._len -= 1
self._fen_update(pos, -1)
del _lists[pos][idx]
_list_lens[pos] -= 1
if _list_lens[pos]:
_mins[pos] = _lists[pos][0]
else:
del _lists[pos]
del _list_lens[pos]
del _mins[pos]
self._rebuild = True
def _loc_left(self, value):
"""Return an index pair that corresponds to the first position of `value` in the sorted list."""
if not self._len:
return 0, 0
_lists = self._lists
_mins = self._mins
lo, pos = -1, len(_lists) - 1
while lo + 1 < pos:
mi = (lo + pos) >> 1
if value <= _mins[mi]:
pos = mi
else:
lo = mi
if pos and value <= _lists[pos - 1][-1]:
pos -= 1
_list = _lists[pos]
lo, idx = -1, len(_list)
while lo + 1 < idx:
mi = (lo + idx) >> 1
if value <= _list[mi]:
idx = mi
else:
lo = mi
return pos, idx
def _loc_right(self, value):
"""Return an index pair that corresponds to the last position of `value` in the sorted list."""
if not self._len:
return 0, 0
_lists = self._lists
_mins = self._mins
pos, hi = 0, len(_lists)
while pos + 1 < hi:
mi = (pos + hi) >> 1
if value < _mins[mi]:
hi = mi
else:
pos = mi
_list = _lists[pos]
lo, idx = -1, len(_list)
while lo + 1 < idx:
mi = (lo + idx) >> 1
if value < _list[mi]:
idx = mi
else:
lo = mi
return pos, idx
def add(self, value):
"""Add `value` to sorted list."""
_load = self._load
_lists = self._lists
_mins = self._mins
_list_lens = self._list_lens
self._len += 1
if _lists:
pos, idx = self._loc_right(value)
self._fen_update(pos, 1)
_list = _lists[pos]
_list.insert(idx, value)
_list_lens[pos] += 1
_mins[pos] = _list[0]
if _load + _load < len(_list):
_lists.insert(pos + 1, _list[_load:])
_list_lens.insert(pos + 1, len(_list) - _load)
_mins.insert(pos + 1, _list[_load])
_list_lens[pos] = _load
del _list[_load:]
self._rebuild = True
else:
_lists.append([value])
_mins.append(value)
_list_lens.append(1)
self._rebuild = True
def discard(self, value):
"""Remove `value` from sorted list if it is a member."""
_lists = self._lists
if _lists:
pos, idx = self._loc_right(value)
if idx and _lists[pos][idx - 1] == value:
self._delete(pos, idx - 1)
def remove(self, value):
"""Remove `value` from sorted list; `value` must be a member."""
_len = self._len
self.discard(value)
if _len == self._len:
raise ValueError('{0!r} not in list'.format(value))
def pop(self, index=-1):
"""Remove and return value at `index` in sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
value = self._lists[pos][idx]
self._delete(pos, idx)
return value
def bisect_left(self, value):
"""Return the first index to insert `value` in the sorted list."""
pos, idx = self._loc_left(value)
return self._fen_query(pos) + idx
def bisect_right(self, value):
"""Return the last index to insert `value` in the sorted list."""
pos, idx = self._loc_right(value)
return self._fen_query(pos) + idx
def count(self, value):
"""Return number of occurrences of `value` in the sorted list."""
return self.bisect_right(value) - self.bisect_left(value)
def __len__(self):
"""Return the size of the sorted list."""
return self._len
def __getitem__(self, index):
"""Lookup value at `index` in sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
return self._lists[pos][idx]
def __delitem__(self, index):
"""Remove value at `index` from sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
self._delete(pos, idx)
def __contains__(self, value):
"""Return true if `value` is an element of the sorted list."""
_lists = self._lists
if _lists:
pos, idx = self._loc_left(value)
return idx < len(_lists[pos]) and _lists[pos][idx] == value
return False
def __iter__(self):
"""Return an iterator over the sorted list."""
return (value for _list in self._lists for value in _list)
def __reversed__(self):
"""Return a reverse iterator over the sorted list."""
return (value for _list in reversed(self._lists) for value in reversed(_list))
def __repr__(self):
"""Return string representation of sorted list."""
return 'SortedList({0})'.format(list(self))
# https://github.com/cheran-senthil/PyRival/blob/master/pyrival/data_structures/SortedList.py
###################################################################################################
if __name__ == '__main__':
main() | 8 | PYTHON3 |
import sys,math,bisect
from random import randint
inf = float('inf')
mod = (10**9)+7
"========================================"
def lcm(a,b):
return int((a/math.gcd(a,b))*b)
def gcd(a,b):
return int(math.gcd(a,b))
def tobinary(n):
return bin(n)[2:]
def binarySearch(a,x):
i = bisect.bisect_left(a,x)
if i!=len(a) and a[i]==x:
return i
else:
return -1
def lowerBound(a, x):
i = bisect.bisect_left(a, x)
if i:
return (i-1)
else:
return -1
def upperBound(a,x):
i = bisect.bisect_right(a,x)
if i!= len(a)+1 and a[i-1]==x:
return (i-1)
else:
return -1
def primesInRange(n):
ans = []
prime = [True for i in range(n+1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p * p, n+1, p):
prime[i] = False
p += 1
for p in range(2, n+1):
if prime[p]:
ans.append(p)
return ans
def primeFactors(n):
factors = []
while n % 2 == 0:
factors.append(2)
n = n // 2
for i in range(3,int(math.sqrt(n))+1,2):
while n % i== 0:
factors.append(i)
n = n // i
if n > 2:
factors.append(n)
return factors
def isPrime(n,k=5):
if (n <2):
return True
for i in range(0,k):
a = randint(1,n-1)
if(pow(a,n-1,n)!=1):
return False
return True
"========================================="
"""
n = int(input())
n,k = map(int,input().split())
arr = list(map(int,input().split()))
"""
from collections import deque,defaultdict,Counter
import heapq,string
for _ in range(int(input())):
n=int(input())
arr=list(map(int,input().split()))
a=1
b=2
print((n//2)*6)
for _ in range(n//2):
print(2,a,b)
print(2,a,b)
print(1,a,b)
print(2,a,b)
print(2,a,b)
print(1,a,b)
a+=2
b+=2
| 8 | PYTHON3 |
import os
import sys
from io import BytesIO, IOBase
def main():
tc = int(input())
for _ in range(tc):
n = int(input())
a = [int(x) for x in input().split()]
i = 1
j = n
print((n // 2) * 6)
for k in range(n // 2):
print(2, i, j)
print(2, i, j)
print(1, i, j)
print(2, i, j)
print(2, i, j)
print(1, i, j)
i += 1
j -= 1
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
if __name__ == "__main__":
main()
| 8 | PYTHON3 |
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
int n;
cin >> n ;
int a[n];
for(int i=0;i<n;i++)
{
cin >> a[i];
}
cout << 6*(n/2) << endl;
for(int i=1;i<=n;i+=2)
{
cout<<2<<" "<<i<<" "<<i+1<<endl;
cout<<1<<" "<<i<<" "<<i+1<<endl;
cout<<2<<" "<<i<<" "<<i+1<<endl;
cout<<2<<" "<<i<<" "<<i+1<<endl;
cout<<1<<" "<<i<<" "<<i+1<<endl;
cout<<2<<" "<<i<<" "<<i+1<<endl;
}
}
}
| 8 | CPP |
t = int(input())
for _ in range(t):
n = int(input())
a = [int(d) for d in input().split()]
print(3*n)
for i in range(1,n//2 + 1):
for j in range(3):
print(2, 2*i-1, 2*i)
print(1, 2*i-1, 2*i)
| 8 | PYTHON3 |
# Lord of the Values
t = int(input())
for _ in range(t):
n = int(input())
a = input()
print(3*n)
for i in range(0,n,2):
first = str(i+1)
second = str(i + 2)
print("1 " + first + " " + second)
print("1 " + first + " " + second)
print("2 " + first + " " + second)
print("1 " + first + " " + second)
print("1 " + first + " " + second)
print("2 " + first + " " + second)
| 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define f1( i , a , b , x) for(ll i = a; i <= (ll)b; i += x)
#define f2( i , a , b , x) for(ll i = a; i >= (ll)b; i -= x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a*b)/gcd(a,b))
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define pob pop_back
#define pof pop_front
#define mk make_pair
#define ff first
#define ss second
#define input(A,n) { \
f1(i,0,n-1,1) \
cin>>A[i] ; \
}
#define M_PI 3.14159265358979323846264338327
void fileIO()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
/**********************The actual logic**********************************************************************************************/
void solve()
{
ll n ; cin>>n ;
ll a[n] ;
for(ll i=0;i<n;i++)cin>>a[i] ;
cout<<(n/2)*6<<endl ;
for(ll i=1;i<n;i+=2)
{
cout<<"1 "<<i<<" "<<i+1<<endl ;
cout<<"2 "<<i<<" "<<i+1<<endl ;
cout<<"1 "<<i<<" "<<i+1<<endl ;
cout<<"1 "<<i<<" "<<i+1<<endl ;
cout<<"2 "<<i<<" "<<i+1<<endl ;
cout<<"1 "<<i<<" "<<i+1<<endl ;
}
}
/**********************Just the Driver Function************************************************************************************************/
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) ;
//fileIO();
ll t=1 ;
cin>>t ;
f1(i,0,t-1,1)solve() ;
return 0 ;
}
| 8 | CPP |
#include<bits/stdc++.h>
/*#include <algorithm>
#include <iostream>
#include <iterator>
#include <string.h>
#include <utility>
#include <vector>
#include <map>
#include <limits>
#include <math.h>
#include <iomanip>*/
//#pragma GCC optimize "trapv"
#define int long long
using namespace std;
const int mod=1000000007;
const int MAX=100005;
#define pb push_back
#define IO() ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl "\n"
#define fr first
#define sc second
#define all(v) v.begin(),v.end()
#define fl(i,a,b) for(int i=a;i<b;i++)
#define fle(i,a,b) for(int i=a;i<=b;i++)
#define gr greater<int>()
#define input(a,n) fl(i,0,n) { cin>>a[i]; }
#define output(a,n) fl(i,0,n) { cout<<a[i]<<" "; } cout<<"\n";
int fact(int );
int lcm(int , int );
int gcd(int , int );
bool prime[MAX+1];
const int inf=1e15;
int fact(int n){
if(n==0)
return 1;
return n*fact(n-1);
}
int gcd(int a, int b){
if (a == 0)
return b;
return gcd(b % a, a);
}
int lcm(int a, int b) {
return (a*b)/gcd(a, b);
}
int modPower(int a,int b)
{
int res = 1;
while(b)
{
if(b&1)
res = (res%mod * a%mod)%mod;
b >>= 1;
a = (a%mod * a%mod)%mod;
}
return res;
}
int log1(int x)
{
if(x==1) return 0;
return 1+log1(x/2);
}
int power(int a,int b)
{
int res = 1;
while(b)
{
if(b&1LL)
res = res*a;
b >>= 1LL;
a = a*a;
}
return res;
}
void solve()
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
cout<<n*3<<"\n";
for(int i=1;i<=n;i+=2)
{
cout<<1<<" "<<i<<" "<<i+1<<"\n";
cout<<2<<" "<<i<<" "<<i+1<<"\n";
cout<<1<<" "<<i<<" "<<i+1<<"\n";
cout<<2<<" "<<i<<" "<<i+1<<"\n";
cout<<1<<" "<<i<<" "<<i+1<<"\n";
cout<<2<<" "<<i<<" "<<i+1<<"\n";
}
}
int32_t main()
{
IO()
// freopen("D:/C++ Programs/abc_input.txt","r",stdin);
// freopen("D:/C++ Programs/abc_output.txt","w",stdout);
int T = 1;
cin>>T;
//SieveOfEratosthenes();
fle(i,1,T)
{
//cout<<"Case #"<<i<<": ";
solve();
//cout<<"\n";
}
return 0;
}
| 8 | CPP |
t = int(input())
for _ in range(t):
n = int(input())
m = [int(i) for i in input().split()]
print(n+n+n)
for i in range(1, n+1, 2):
# print(i)
print(2, i , i + 1)
print(1, i , i + 1)
print(1, i , i + 1)
print(2, i , i + 1)
print(1, i , i + 1)
print(1, i , i + 1) | 8 | PYTHON3 |
for _ in range(int(input())):
n=int(input())
ai=list(map(int,input().split()))
print(6*(n//2))
for i in range(0,n-1,2):
i+=1
print(1,i,i+1)
print(2,i,i+1)
print(1,i,i+1)
print(1,i,i+1)
print(2,i,i+1)
print(1,i,i+1)
| 8 | PYTHON3 |
from typing import List
def solve(n: int, a: List[int]) -> None:
print(n * 3)
for i in range(1, n, 2):
print(2, i, i + 1)
print(2, i, i + 1)
print(1, i, i + 1)
print(2, i, i + 1)
print(2, i, i + 1)
print(1, i, i + 1)
return
test_cases = int(input())
for _ in range(test_cases):
n = int(input())
a = list(map(int, input().split()))
solve(n, a) | 8 | PYTHON3 |
def solve():
n = int(input())
arr = [int(x) for x in input().strip().split()]
ops = []
for i in range(0, n, 2):
if arr[i] == arr[i + 1]:
ops.extend([
f'2 {i + 1} {i + 2}',
f'2 {i + 1} {i + 2}',
f'1 {i + 1} {i + 2}',
f'1 {i + 1} {i + 2}'
])
arr[i + 1] -= arr[i]
arr[i + 1] -= arr[i]
arr[i] += arr[i + 1]
arr[i] += arr[i + 1]
else:
ops.extend([
f'2 {i + 1} {i + 2}',
f'2 {i + 1} {i + 2}',
f'1 {i + 1} {i + 2}',
f'2 {i + 1} {i + 2}',
f'2 {i + 1} {i + 2}',
f'1 {i + 1} {i + 2}'
])
arr[i + 1] -= arr[i]
arr[i + 1] -= arr[i]
arr[i] += arr[i + 1]
arr[i + 1] -= arr[i]
arr[i + 1] -= arr[i]
arr[i] += arr[i + 1]
# print(arr)
print(len(ops))
for op in ops:
print(op)
if __name__=='__main__':
for _ in range(int(input().strip())):
solve() | 8 | PYTHON3 |
def values(n, A):
O = []
for i in range(0, n, 2):
j = i+1
O.extend((
(1, i+1, j+1),
(2, i+1, j+1),
(1, i+1, j+1),
(2, i+1, j+1),
(1, i+1, j+1),
(2, i+1, j+1),
))
return len(O), O
def main():
t = readint()
L = []
for _ in range(t):
n = readint()
A = readinti()
m, O = values(n, A)
L.append(str(m))
L.extend(f'{o[0]} {o[1]} {o[2]}' for o in O)
print('\n'.join(L))
##########
import sys
def readint():
return int(input())
def readinti():
return map(int, input().split())
def readintl():
return list(readinti())
def readintll(k):
return [readintl() for _ in range(k)]
def log(*args, **kwargs):
print(*args, **kwargs, file=sys.stderr)
if __name__ == '__main__':
main()
| 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
typedef complex<double> Point;
const ll mod = 1e9 + 7;
const double Pi = 3.14159265358979;
int run_test(){
int n;
cin >> n;
vector<pair<int, pair<int,int>>> ans;
for(int i = 0; i < n; i++){
int k;
cin >> k;
}
for(int i = 0; i < n; i+=2){
ans.push_back({1, {i, i+1}});
ans.push_back({2, {i, i+1}});
ans.push_back({1, {i, i+1}});
ans.push_back({2, {i, i+1}});
ans.push_back({1, {i, i+1}});
ans.push_back({2, {i, i+1}});
}
cout << ans.size() << '\n';
for(auto x: ans){
cout << x.first << " " << x.second.first + 1 << " " << x.second.second + 1<< '\n';
}
cout << '\n';
return 0;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tt;
tt = 1;
cin >> tt;
//int t_no = 1;
while(tt--){
// cout << "Case #" << t_no++ << ": ";
run_test();
}
} | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--){
int n;
cin >> n;
vector<long long> a(n);
for(int i=0;i<n;i++)cin >> a[i];
cout << 3*n << "\n";
for(int i=1;i<=n/2;i++){
for(int j=0;j<3;j++){
cout << 1 << " " << i << " " << n+1-i << "\n";
cout << 2 << " " << i << " " << n+1-i << "\n";
}
}
}
return 0;
}
| 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
//TIAS MONDAL
const ll maxn=1e5+10;
const ll mod=1e9+7;
const ll m2=1e9+7;
const ll INF64 = ll(1e18);
const ll max2=1e3+10;
const ll N = 1000001;
const ll MAXN=2e5+10;
const ll ALPHABET_SIZE = 2;
int main()
{
/*#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
//long long tt = clock();
#endif*/
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int t;
cin>>t;
while(t--)
{
int n,i;
cin>>n;
vector<int> v(n);
for(i=0;i<n;++i)
cin>>v[i];
cout<<3*n<<"\n";
for(i=1;i<=n;i+=2)
{
cout<<1<<" "<<i<<" "<<i+1<<"\n";
cout<<2<<" "<<i<<" "<<i+1<<"\n";
cout<<1<<" "<<i<<" "<<i+1<<"\n";
cout<<1<<" "<<i<<" "<<i+1<<"\n";
cout<<2<<" "<<i<<" "<<i+1<<"\n";
cout<<1<<" "<<i<<" "<<i+1<<"\n";
}
}
return(0);
}
| 8 | CPP |
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;
int main() {
int i, j, t, n, m, c;
cin >> t;
while (t--) {
cin >> n;
int a[n];
for (i = 0; i < n; i++) cin >> a[i];
cout << n * 3 << endl;
for (i = 1; i <= n; i += 2) {
for (j = 0; j < 3; j++) {
cout << "1 " << i << " " << i+1 << endl;
cout << "2 " << i << " " << i+1 << endl;
}
}
}
}
| 8 | CPP |
import os,sys,math
from io import BytesIO, IOBase
from collections import defaultdict,deque,OrderedDict
import bisect as bi
def yes():print('YES')
def no():print('NO')
def I():return (int(input()))
def In():return(map(int,input().split()))
def ln():return list(map(int,input().split()))
def Sn():return input().strip()
BUFSIZE = 8192
#complete the main function with number of test cases to complete greater than x
def find_gt(a, x):
i = bi.bisect_left(a, x)
if i != len(a):
return i
else:
return len(a)
def solve():
n=I()
l=list(In())
ans=[]
for i in range(0,n,2):
ans.append((1,i+1,i+2))
ans.append((1,i+1,i+2))
ans.append((2,i+1,i+2))
ans.append((1,i+1,i+2))
ans.append((1,i+1,i+2))
ans.append((2,i+1,i+2))
print(len(ans))
for x in ans:
print(*x)
pass
def main():
T=I()
for i in range(T):
solve()
M = 998244353
P = 1000000007
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
"""Prints the values to a stream, or to sys.stdout by default."""
sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
at_start = True
for x in args:
if not at_start:
file.write(sep)
file.write(str(x))
at_start = False
file.write(kwargs.pop("end", "\n"))
if kwargs.pop("flush", False):
file.flush()
if sys.version_info[0] < 3:
sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# endregion
if __name__ == '__main__':
main() | 8 | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.