solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
import math, sys
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
MOD = int(1e9) + 7
INF = float('inf')
def solve():
n = int(input())
arr = list(map(int, input().split()))
l, r = 1, n
print(3 * n)
while l < r:
print(2, l, r)
print(1, l, r)
print(1, l, r)
print(2, l, r)
print(1, l, r)
print(1, l, r)
l += 1
r -= 1
ts = 1
ts = int(input())
for t in range(1, ts + 1):
solve()
| 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,x;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&x);
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("2 %d %d\n",i,i+1);
printf("1 %d %d\n",i,i+1);
printf("2 %d %d\n",i,i+1);
printf("2 %d %d\n",i,i+1);
}
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
#define For(i, a, b) for (int i = a; i <= b; ++ i)
#define Rof(i, a, b) for (int i = a; i >= b; -- i)
#define IOS ios :: sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
using namespace std;
const int N = 1005, mod = 998244353, dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, -1, 1}, inf = 1e9;
const ll infll = 1e18;
inline int read() { char c = getchar(); int x = 0, f = 1; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); } return x * f; }
inline ll updiv(ll a, ll b) { return a / b + (a % b > 0); } // divided a by b rounded up
inline ll qpow(ll a, ll b) { ll ans = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; }
int n,m,a[N],b[N],c[N];
char s[N];
int main() {
int T;
cin>>T;
while(T--){
cin>>n;
For(i,1,n)cin>>a[i];
printf("%d\n",3*n);
For(i,1,n/2){
int x=i*2-1,y=x+1;
printf("1 %d %d\n",x,y);
printf("2 %d %d\n",x,y);
printf("1 %d %d\n",x,y);
printf("1 %d %d\n",x,y);
printf("2 %d %d\n",x,y);
printf("1 %d %d\n",x,y);
}
}
return 0;
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test; cin>>test;
while(test--)
{
int n; cin>>n;
vector<int> ar(n);
for(int i=0;i<n;i++) cin>>ar[i];
cout<<6*(n/2)<<endl;
for(int i=0;i<n-1;i+=2)
{
cout<<"1 "<<i+1<<" "<<i+1+1<<"\n";
cout<<"2 "<<i+1<<" "<<i+1+1<<"\n";
cout<<"1 "<<i+1<<" "<<i+1+1<<"\n";
cout<<"2 "<<i+1<<" "<<i+1+1<<"\n";
cout<<"1 "<<i+1<<" "<<i+1+1<<"\n";
cout<<"2 "<<i+1<<" "<<i+1+1<<"\n";
}
}
return 0;
} | 8 | CPP |
t = int(input())
for _ in range(t):
n = int(input())
a = input()
print(3*n)
for j in range(1, n, 2):
print(f"""1 {j} {j+1}
2 {j} {j+1}
1 {j} {j+1}
1 {j} {j+1}
2 {j} {j+1}
1 {j} {j+1}""")
| 8 | PYTHON3 |
for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
print(6*(n//2))
for i in range(n//2):
j = i + n//2
l[j] = l[j] - l[i]
print("2", i+1, j+1)
l[i] = l[i] + l[j]
print("1", i+1, j+1)
l[j] = l[j] - l[i]
print("2", i+1, j+1)
l[j] = l[j] - l[i]
print("2", i+1, j+1)
l[i] = l[i] + l[j]
print("1", i+1, j+1)
l[j] = l[j] - l[i]
print("2", i+1, j+1)
| 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
vector<int> a;
int x;
for(int i=0;i<n;i++)
{
cin>>x;
a.push_back(x);
}
cout<<3*n<<endl;
for(int i=1;i<=n-1;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;
}
}
return 0;
} | 8 | CPP |
#include <bits/stdc++.h>
#define sz(x) (int)x.size()
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define all(x) x.begin(), x.end()
#define pb push_back
#define pii pair<int, int>
#define int long long
using namespace std;
void solve(){
int nVals; cin >> nVals;
vector<int> vals(nVals);
for (int& val : vals)
cin >> val;
cout << 3 * nVals << endl;
for (int i = 0; i < nVals; i += 2){
for (int j = 0; j < 3; ++j){
cout << 1 << " " << i + 1 << " " << i + 2 << endl;
vals[i] += vals[i + 1];
cout << 2 << " " << i + 1<< " " << i + 2 << endl;
vals[i + 1] -= vals[i];
}
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1; cin >> t;
while (t--)
solve();
return 0;
} | 8 | CPP |
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key, lru_cache
from itertools import accumulate, permutations
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)
def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
n = val()
l = li()
ans = []
for i in range(1, n, 2):
ans.append([1, i, i + 1])
ans.append([2, i, i + 1])
ans.append([1, i, i + 1])
ans.append([2, i, i + 1])
ans.append([1, i, i + 1])
ans.append([2, i, i + 1])
print(len(ans))
for a, b, c in ans:
print(a, b, c)
# 1 10 ** 9 => 10 ** 9 + 1, -1 => 10 ** 9, -1 => 10 ** 9, -10 ** 9 - 1 => -1, | 8 | PYTHON3 |
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1500;
int a[N];
int main()
{
int t; cin >> t;
while(t--)
{
int n; cin >> n;
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
cout << 3*n << endl;
for(int i = 0; i < n; i+=2)
{
printf("%d %d %d\n",2,i+1,i+2);
// a[i+1] -= a[i];
printf("%d %d %d\n",1,i+1,i+2);
// a[i] += a[i+1];
printf("%d %d %d\n",2,i+1,i+2);
// a[i+1] -= a[i];
printf("%d %d %d\n",1,i+1,i+2);
// a[i] += a[i+1];
printf("%d %d %d\n",2,i+1,i+2);
// a[i+1] -= a[i];
printf("%d %d %d\n",1,i+1,i+2);
// a[i] += a[i+1];
}
// for(int i = 0; i < n; i++)
// {
// cout << a[i] << " ";
// }
// cout << endl;
}
// system("pause");
} | 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
///typedef
typedef long long ll;
typedef pair<int, int> pii;
///define constant
const ll mxn = 200005;
const int mod = 1000000007;//1e9+7;
///faster io
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
///debug
#define watch(x) cerr << __LINE__ << " says: " << #x << " = " << x << "\n"
#define watch2(x,y) cout<< __LINE__ << " says: " <<#x<<" = "<<x<<" "<<#y<<" = "<<y <<endl
#define watch3(x,y,z) cout<< __LINE__ << " says: " <<#x<<" = "<<x<<" "<<#y<<" = "<<y <<" "<<#z<<" = "<<z<<endl
///program starts...........
void solve_case(int tc)
{
int n;
cin>>n;
int arr[n];
for(int i=0; i<n; i++)
{
cin>>arr[i];
}
cout<<n*3<<endl;
for(int i=0; i<n; i+=2)
{
for(int it=0; it<3; it++)
{
for(int j=1; j<=2; j++)
{
cout<<j<<" "<<i+1<<" "<<i+2<<endl;
}
}
}
return;
}
int main()
{
faster_io;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
int test_case=1;
cin>>test_case;
for(int tc=1 ; tc<=test_case; tc++)
{
solve_case(tc);
}
/// KeyPoint
/// Corner Cases
return 0;
}
| 8 | CPP |
t=int(input())
for i in range(t):
m=int(input())
s= list(map(int,input().split()))
a=m//2
print(m*3,'\n')
for i in range(1,m+1,2):
e=1+i
f=e-1
print(1," ",f," ",e,'\n')
print(2," ",f," ",e,'\n')
print(1," ",f," ",e,'\n')
print(1," ",f," ",e,'\n')
print(2," ",f," ",e,'\n')
print(1," ",f," ",e,'\n') | 8 | PYTHON3 |
# SHRi GANESHA author: Kunal Verma #
import os
import sys
#from collections import Counter
from bisect import bisect_right
from io import BytesIO, IOBase
from math import gcd, inf, sqrt, ceil
def lcm(a, b):
return (a * b) // gcd(a, b)
#MAXN = 1000004
#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, ceil(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 = Counter()
while (x != 1):
ret[spf[x]]+=1
x = x // spf[x]
return ret
def printDivisors(n):
i = 2
z = [1, n]
while i <= sqrt(n):
if (n % i == 0):
if (n / i == i):
z.append(i)
else:
z.append(i)
z.append(n // i)
i = i + 1
return z
def create(n, x, f):
pq = len(bin(n)[2:])
if f == 0:
tt = min
else:
tt = max
dp = [[inf] * n for _ in range(pq)]
dp[0] = x
for i in range(1, pq):
for j in range(n - (1 << i) + 1):
dp[i][j] = tt(dp[i - 1][j], dp[i - 1][j + (1 << (i - 1))])
return dp
def enquiry(l, r, dp, f):
if l > r:
return inf if not f else -inf
if f == 1:
tt = max
else:
tt = min
pq1 = len(bin(r - l + 1)[2:]) - 1
return tt(dp[pq1][l], dp[pq1][r - (1 << pq1) + 1])
def SieveOfEratosthenes(n):
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
x = []
for i in range(2, n + 1):
if prime[i]:
x.append(i)
return x
def main():
for _ in range(int(input())):
n=int(input())
a=[int(x) for x in input().split()]
print(6*(n//2))
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)
# Fast IO Region
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")
if __name__ == '__main__':
main()
| 8 | PYTHON3 |
/*JANVI PATEL, DAIICT ,INDIA */
#include<bits/stdc++.h>
#include <fstream>
using namespace std;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define dob double
#define mp(x,y) make_pair(x,y)
#define pi 3.1415926
#define pb(x) push_back(x)
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define ff first
#define ss second
#define forr(z,y) for(int i=z;i<y;i++)
#define rfor(z,y) for(int i=z;i>=y;i--)
#define Vp vector<pair<ll,ll>>
#define V vector
#define sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define M map
#define fix fixed<<setprecision (9)
#define gcd(a,b) __gcd( a, b)
ll i,j,x,y,k,f,z,cnt;
ll dfs(ll index,ll sum,V<ll> a)
{
if(index>=a.size())
return 0;
ll cursum = sum+a[index];
if(cursum<0)
{
cursum-=a[index];
return dfs(index+1,cursum,a);
}
if(a[index]>=0)
{
return 1+dfs(index+1,cursum,a);
}
return max(dfs(index+1,sum,a),1+dfs(index+1,cursum,a));
}
int32_t main()
{ FAST
ll t=1;
cin>>t;
while(t--)
{
ll n,m;
cin>>n;
V<ll> a;
for(i=0;i<n;i++)
{
ll a1;
cin>>a1;
a.pb(a1);
}
ll k=(n/2)*6;
cout<<k<<endl;
for(i=0;i<n;i+=2)
{
j=i+1;
cout<<1<<" "<<i+1<<" "<<j+1<<endl;
cout<<2<<" "<<i+1<<" "<<j+1<<endl;
cout<<1<<" "<<i+1<<" "<<j+1<<endl;
cout<<2<<" "<<i+1<<" "<<j+1<<endl;
cout<<1<<" "<<i+1<<" "<<j+1<<endl;
cout<<2<<" "<<i+1<<" "<<j+1<<endl;
}
}
return 0;
} | 8 | CPP |
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#include<string.h>
#define maxn 50005
#define ll long long
int a[6]={1,2,1,1,2,1};
int main()
{
int T;
cin>>T;
while(T--)
{
int n,x;
cin>>n;
for(int i=1;i<=n;i++)
cin>>x;
cout<<n*3<<endl;
for(int i=1;i<=n;i+=2)
for(int j=0;j<6;j++)
printf("%d %d %d\n",a[j],i,i+1);
}
return 0;
} | 8 | CPP |
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(){
int n;cin>>n;
vector<ll> arr(n);
for(int i=0;i<n;i++){
cin>>arr[i];
}
cout<<6*n/2<<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<<"1 "<<i+1<<" "<<i+2<<endl;
cout<<"2 "<<i+1<<" "<<i+2<<endl;
cout<<"1 "<<i+1<<" "<<i+2<<endl;
}
}
int main(){
int t;cin>>t;
while(t--){
solve();
}
} | 8 | CPP |
def solve(n: int) -> None:
arr = [2, 1, 2, 2, 1, 2]
print(3 * n)
for i in range(1, n + 1, 2):
for j in arr:
print(j, i, i + 1)
t = int(input())
for _ in range(t):
n = int(input())
input()
solve(n)
| 8 | PYTHON3 |
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n=int(input())
arr=[int(x) for x in input().split()]
ans=[]
for i in range(0,n,2):
ans.append((1,i+1,i+2))
ans.append((2,i+1,i+2))
ans.append((2,i+1,i+2))
ans.append((1,i+1,i+2))
ans.append((2,i+1,i+2))
ans.append((2,i+1,i+2))
print(len(ans))
for i in ans:
print(*i) | 8 | PYTHON3 |
import collections
import functools
import math
import sys
import bisect
def In():
return map(int, sys.stdin.readline().split())
input = sys.stdin.readline
def lord():
for _ in range(int(input())):
n = int(input())
l = input()
print(n // 2 * 6)
for i in range(0, n, 2):
for i1 in range(6):
print(i1 % 2 + 1, i+1, i + 2)
lord() | 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
template <class T> ostream &operator << (ostream &os, const vector<T> &p) { os << "["; for (auto&it : p) os << it << " "; return os << "]";}
template <class S, class T> ostream &operator << (ostream &os, const pair<S, T> &p) { return os << "(" << p.first << "," << p.second << ")";}
#ifndef ONLINE_JUDGE
#define deb(...) dbs(#__VA_ARGS__,__VA_ARGS__)
template <class T> void dbs(string str, T t) { cerr << str << ":" << t << "\n";}
template<class T, class...S> void dbs(string str, T t, S... s) { int idx = str.find(','); cerr << str.substr(0, idx) << ":" << t << ","; dbs(str.substr(idx + 1), s...);}
#else
#define deb(...){}
#endif
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define pr(x) {cout << x << '\n'; return;}
#define nl cout<< '\n'
#define rep(i,n) for(int i = 0; i < n; i++)
#define re(i,n) for(int i = 1; i <= n; i++)
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
template<class T> inline T Bit(T x, int i) { return (x >> i) & 1;}
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int N = 2e3 + 3; // check the limits
vector<pair<int, pii>> v;
void add(int i, int j) {
v.pb({1, {i, j}});
v.pb({1, {i, j}});
v.pb({2, {i, j}});
v.pb({1, {i, j}});
v.pb({1, {i, j}});
v.pb({2, {i, j}});
}
void Deltix_Round_Spring_2021(int tc) {
v.clear();
int n; cin >> n;
vi a(n); rep(i, n) cin >> a[i];
for (int i = 1; i <= n; i += 2) {
add(i, i + 1);
deb(i);
}
cout << sz(v) << '\n';
for (auto u : v) {
cout << u.fi << ' ' << u.se.fi << ' ' << u.se.se << '\n';
}
}
signed main() {
ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++) Deltix_Round_Spring_2021(i);
return 0;
} | 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define pf first
#define ps second
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define Endl '\n'
#define codejam cout<<"Case #"<<t<<": ";
#define PI 3.141592653589793238462
#define sz(x) ((int)(x).size())
#define mod 1000000007
#define forn(i,n) for(ll i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double lld;
//////////////////////////////////// DEBUGGER ///////////////////////////////////////////
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; debugger(x); cerr << endl;
#else
#define debug(x)
#endif
void debugger(ll t) {cerr << t;}void debugger(int t) {cerr << t;}void debugger(string t) {cerr << t;}void debugger(char t) {cerr << t;}void debugger(lld t) {cerr << t;}void debugger(double t) {cerr << t;}void debugger(ull t) {cerr << t;}template <class T, class V> void debugger(pair <T, V> p);template <class T> void debugger(vector <T> v);template <class T> void debugger(set <T> v);template <class T, class V> void debugger(map <T, V> v);template <class T> void debugger(multiset <T> v);template <class T, class V> void debugger(pair <T, V> p) {cerr << "{"; debugger(p.pf); cerr << ","; debugger(p.ps); cerr << "}";}template <class T> void debugger(vector <T> v) {cerr << "[ "; for (T i : v) {debugger(i); cerr << " ";} cerr << "]";}template <class T> void debugger(set <T> v) {cerr << "[ "; for (T i : v) {debugger(i); cerr << " ";} cerr << "]";}template <class T> void debugger(multiset <T> v) {cerr << "[ "; for (T i : v) {debugger(i); cerr << " ";} cerr << "]";}template <class T, class V> void debugger(map <T, V> v) {cerr << "[ "; for (auto i : v) {debugger(i); cerr << " ";} cerr << "]";}
ll gcd(ll a,ll b) {if(b==0) return a;return gcd(b,a%b);}
//////////////////////////////////// JAI SHREE RAM /////////////////////////////////////
const ll N=1e5;
void JAISHREERAM()
{
ll n,ans=0;
cin>>n;
vector<ll> a(n);
forn(i,n) cin>>a[i];
cout<<6*n/2<<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;
}
}
int main()
{
fast;
int T=1;
cin>>T;
for(int t=1;t<=T;t++)
{
// codejam
JAISHREERAM();
}
return 0;
} | 8 | CPP |
a=int(input())
import sys
input=sys.stdin.readline
for i in range(a):
n=int(input())
z=list(map(int,input().split()))
print(3*len(z))
for i in range(0,len(z),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 sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())
t = I()
for _ in range(t):
n = I()
A = LI()
print(3*n)
for i in range(n//2):
x = 2*i+1
y = 2*i+2
for a in [1,2,1,1,2,1]:
print(a,x,y)
| 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t=1;
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<<"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 |
from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
from io import BytesIO as stream
else:
from io import StringIO as stream
if sys.version_info[0] < 3:
class dict(dict):
"""dict() -> new empty dictionary"""
def items(self):
"""D.items() -> a set-like object providing a view on D's items"""
return dict.iteritems(self)
def keys(self):
"""D.keys() -> a set-like object providing a view on D's keys"""
return dict.iterkeys(self)
def values(self):
"""D.values() -> an object providing a view on D's values"""
return dict.itervalues(self)
input = raw_input
range = xrange
filter = itertools.ifilter
map = itertools.imap
zip = itertools.izip
def sync_with_stdio(sync=True):
"""Set whether the standard Python streams are allowed to buffer their I/O.
Args:
sync (bool, optional): The new synchronization setting.
"""
global input, flush
if sync:
flush = sys.stdout.flush
else:
sys.stdin = stream(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip('\r\n')
sys.stdout = stream()
register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
print(n // 2 * 6)
for i in range(1, n // 2 + 1):
for j in range(6):
if j % 2 == 0:
print(1, i * 2 - 1, i * 2)
else:
print(2, i * 2 - 1, i * 2)
| 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, a[N];
int main() {
int t;
scanf("%d", &t);
while(t--) {
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; i++) {
if(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("1 %d %d\n", i, i + 1);
printf("2 %d %d\n", i, i + 1);
printf("1 %d %d\n", i, i + 1);
}
}
}
}
| 8 | CPP |
#include<bits/stdc++.h>
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<<3*n<<"\n";
for(int i=0;i<n;i+=2){
int j=i+1;
int k=i+2;
cout<<"1 "<<j<<" "<<k<<"\n";
cout<<"2 "<<j<<" "<<k<<"\n";
cout<<"2 "<<j<<" "<<k<<"\n";
cout<<"1 "<<j<<" "<<k<<"\n";
cout<<"2 "<<j<<" "<<k<<"\n";
cout<<"2 "<<j<<" "<<k<<"\n";
}
}
} | 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define Rep(i,a,b) for(int i = a, i <= b; i++)
#define int long long
#define pii pair<int,int>
#define vi vector <int>
#define mod 1000000007
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x) //no of zero bits befor the first set bits
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
int lcm(int a, int b) { return (a / gcd(a, b)) * b; }
void start()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output1.txt", "w", stdout);
#endif
}
int32_t main()
{
start();
int t=1;;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int ans=3*n;
cout<<ans<<endl;
int k=n/2;
int pos=0;
for(int i=1;i<=k;i++)
{
int idx1=pos;
int idx2=pos+1;
idx1++;
idx2++;
pos+=2;
cout<<1<<" "<<idx1<<" "<<idx2<<endl;
cout<<2<<" "<<idx1<<" "<<idx2<<endl;
cout<<1<<" "<<idx1<<" "<<idx2<<endl;
cout<<2<<" "<<idx1<<" "<<idx2<<endl;
cout<<1<<" "<<idx1<<" "<<idx2<<endl;
cout<<2<<" "<<idx1<<" "<<idx2<<endl;
}
}
} | 8 | CPP |
import sys
from os import path
if(path.exists("input.txt")):
sys.stdin = open("input.txt",'r')
sys.stdout = open("output.txt",'w')
import math
t=int(input())
while(t):
t-=1
n=int(input())
li=list(map(int,input().split()))
print(3*n)
for i in range(1,n+1,2):
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 |
cases = int(input())
for _ in range(cases):
n = int(input())
numbers = [int(number) for number in input().split()]
print(n*3)
for i in range(0, n, 2):
for k in range(6):
print("%s %s %s" % (k%2+1, i+1, i+2))
| 8 | PYTHON3 |
from sys import stdin
def solve():
n = int(stdin.readline().strip())
_ = stdin.readline()
print(n*3)
for i in range(0,n,2):
for _ in range(3):
print(2, i+1, i+2)
print(1, i+1, i+2)
t = int(stdin.readline().strip())
for _ in range(t):
solve() | 8 | PYTHON3 |
#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x<<" "; _print(x); cerr <<"("<<__LINE__<<")"<<endl;
#else
#define debug(x)
#endif
#define vi vector<int>
#define vll vector<long long>
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define mp make_pair
typedef unsigned long long ull;
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(ld 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 solve()
{
int n;
cin>>n;
vi a(n);
for (auto x: a) cin>>x;
int j = 1;
cout<<3*n<<endl;
for (int i = 0;i<n/2;i++){
cout<<1<<" "<<j<<" "<<j+1<<endl;
cout<<1<<" "<<j<<" "<<j+1<<endl;
cout<<2<<" "<<j<<" "<<j+1<<endl;
cout<<1<<" "<<j<<" "<<j+1<<endl;
cout<<1<<" "<<j<<" "<<j+1<<endl;
cout<<2<<" "<<j<<" "<<j+1<<endl;
j = j+2;
}
}
signed main()
{
faster;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("error.txt","w",stderr);
#endif
int t;
cin >> t;
while (t--)
solve();
} | 8 | CPP |
a = '2 {0} {1}\n1 {0} {1}'
for _ in range(int(input())):
n = int(input())
l = input()
print(n * 3)
for i in range(0, n, 2):
for _ in range(3):
print(a.format(i + 1, i + 2)) | 8 | PYTHON3 |
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<int, int> pi;
const ll Mod = 998244353;
const ll INF = (ll)(1e18) + 5;
const ll N = 5e3 + 5, M = 21;
int main() {
GO;
int t; cin >> t;
while (t--) {
int n;
cin >> n;
vec a(n);
for (ll& i : a)
cin >> i;
cout << 3 * n << '\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';
}
}
return 0;
} | 8 | CPP |
#include<iostream>
using namespace std;
int t,n,s,r;
int main()
{
cin>>t;
for(int i=0;i<t;i++)
{
cin>>n;
for(int k=0;k<n;k++)
{
cin>>r;
}
cout<<3*n<<endl;
for(int j=0;j<n-1;j=j+2)
{
cout<<"1"<<" "<<j+1<<" "<<j+2<<endl;
cout<<"2"<<" "<<j+1<<" "<<j+2<<endl;
cout<<"2"<<" "<<j+1<<" "<<j+2<<endl;
cout<<"1"<<" "<<j+1<<" "<<j+2<<endl;
cout<<"2"<<" "<<j+1<<" "<<j+2<<endl;
cout<<"2"<<" "<<j+1<<" "<<j+2<<endl;
}
}
return 0;
} | 8 | CPP |
#!/usr/bin/env python
from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def main():
t = int(input())
for _ in range(t):
n = int(input())
a = [int(ai) for ai in input().split()]
print(n * 3)
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(1, i + 1, i + 2)
print(2, i + 1, i + 2)
print(1, i + 1, i + 2)
# 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")
# endregion
if __name__ == "__main__":
main()
| 8 | PYTHON3 |
def solution(n, a):
print(len(a)//2*6)
for i in range(1,len(a),2):
print('1 {} {}'.format(i,i+1))
print('2 {} {}'.format(i,i+1))
print('1 {} {}'.format(i,i+1))
print('2 {} {}'.format(i,i+1))
print('1 {} {}'.format(i,i+1))
print('2 {} {}'.format(i,i+1))
t = int(input())
for tt in range(t):
n = int(input())
a = list(map(int, input().split()))
solution(n, a) | 8 | PYTHON3 |
t = int(input())
while t:
n = int(input())
l = [int(i) for i in input().split()]
print(6*(n//2))
i = 0
while i<n:
print('2' + " " + str(i+1) + " " + str(i+2))
print('1' + " " + str(i+1) + " " + str(i+2))
print('2' + " " + str(i+1) + " " + str(i+2))
print('1' + " " + str(i+1) + " " + str(i+2))
print('2' + " " + str(i+1) + " " + str(i+2))
print('1' + " " + str(i+1) + " " + str(i+2))
i+=2
t-=1
| 8 | PYTHON3 |
t=int(input())
for i in range(t):
n=int(input())
a=list(map(int, input().split(" ")))
print((n//2)*6)
for i in range(0, n, 2):
for p in range(3):
print("1 {} {}".format(i+1, i+2))
print("2 {} {}".format(i+1, i+2)) | 8 | PYTHON3 |
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
print(n*3)
for i in range(1, n, 2):
for j in range(3):
print(1, i, i+1)
print(2, i, i+1)
###### thanking telegram for solutions ######
'''__________ ____ ___ _____________ __.___
\______ \ | \/ _____/ |/ _| |
| _/ | /\_____ \| < | |
| | \ | / / \ | \| |
|____|_ /______/ /_______ /____|__ \___|
'''
| 8 | PYTHON3 |
#include<bits/stdc++.h>
#define eb emplace_back
using namespace std;
int n;
int c[2009];
vector<int>a;
vector<vector<int>>b;
void work(){
int ans=0;
b.clear();
scanf("%d",&n);
for(int i=1;i<=n;++i){
scanf("%d",&c[i]);
}
for(int i=1;i<=n;i+=2){
ans++;
a={1,i,i+1};
b.eb(a);
ans++;
a={2,i,i+1};
b.eb(a);
ans++;
a={1,i,i+1};
b.eb(a);
ans++;
a={1,i,i+1};
b.eb(a);
ans++;
a={2,i,i+1};
b.eb(a);
ans++;
a={1,i,i+1};
b.eb(a);
}
printf("%d\n",ans);
for(auto v:b){
printf("%d %d %d\n",v[0],v[1],v[2]);
}
}
int main(){
int T;
scanf("%d",&T);
while(T--)work();
return 0;
} | 8 | CPP |
#include <iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<map>
using namespace std;
#define ll long long
const long double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
struct node {
private:
ll ans = 0;
node *left = nullptr;
node *right = nullptr;
public:
void update(ll l, ll r, ll idx, ll x) {
if (r - l == 1) {
ans = max(ans, x);
return;
}
ll m = (l + r) / 2;
ll L = 0, R = 0;
if (idx < m) {
if (left == nullptr)
left = new node;
left->update(l, m, idx, x);
L = left->ans;
} else {
if (right == nullptr)
right = new node;
right->update(m, r, idx, x);
R = right->ans;
}
if (left != nullptr)
L = left->ans;
if (right != nullptr)
R = right->ans;
ans = max(L, R);
}
ll get(ll l, ll r, ll ql, ll qr) {
if (ql <= l && r <= qr) {
return ans;
}
if (ql >= r || l >= qr)
return 0;
ll m = (l + r) / 2;
ll ret = 0;
if (!(ql >= m || l >= qr)) {
if (left != nullptr)
ret = max(ret, left->get(l, m, ql, qr));
}
if (!(ql >= r || m >= qr)) {
if (right != nullptr)
ret = max(ret, right->get(m, r, ql, qr));
}
return ret;
}
};
struct pie {
ll r, h;
};
long double volume(pie a) {
return (pi * a.r * a.r) * a.h;
}
ll not_pi_volume(pie a) {
return (a.r * a.r) * a.h;
}
int main() {
int tt;
cin >> tt;
while (tt--) {
int n;
cin >> n;
vector<ll> 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 << "2 " << 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 << "2 " << i + 1 << " " << i + 2 << "\n";
cout << "1 " << i + 1 << " " << i + 2 << "\n";
}
}
}
| 8 | CPP |
for _ in range(int(input())):
n = int(input())
l = list(map(int,input().split()))
print(n*3)
for i in range(0,n,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)
print(2,i+1,i+2)
print(2,i+1,i+2) | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define pb push_back
#define lop(i,n) for(int i=0;i<n;i++)
#define lop1(i,n) for(int i=1;i<=n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define mem(b,a) memset(a,b,sizeof(a))
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
//setbit clearbit toggle k-1, k-1
#define setbit(x,k) (x |=(1<<k))
#define clearbit(x,k) (x &= ~(1<<k))
#define togglebit(x,k) (x ^= (1<<k))
#define checkbit(x,k) (x& (1<<k))
// v.erase(unique(v.begin(),v.end()),v.end());
#define inf INT_MAX
#define nn cout<<endl
#define mn 1000000
#define ff first
#define ss second
#define gap " "
int main()
{
fast
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
ll a[n+1];
lop(i,n)
{
cin>>a[i];
}
cout<<n*3<<endl;
for(int i=0;i<n;i+=2)
{
cout<<1<<gap<<i+1<<gap<<i+2<<endl;
cout<<2<<gap<<i+1<<gap<<i+2<<endl;
cout<<1<<gap<<i+1<<gap<<i+2<<endl;
cout<<2<<gap<<i+1<<gap<<i+2<<endl;
cout<<1<<gap<<i+1<<gap<<i+2<<endl;
cout<<2<<gap<<i+1<<gap<<i+2<<endl;
}
}
}
| 8 | CPP |
for _ in range(int(input())):
n=int(input())
input()
print(3*n)
for i in range(0,n,2):
for j in range(3):
print(2,i+1,i+2)
print(1,i+1,i+2)
| 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define loop(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define eloop(i,a,b) for(int i=(int)a;i<=(int)b;++i)
#define rloop(i,a,b) for(int i=(int)a;i>=(int)b;--i)
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpi vector<pii>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define max(x,y) ((x>y)?x:y)
#define min(x,y) ((x<y)?x:y)
#define mid(s,e) (s+(e-s)/2)
#define mset(a,b,c) loop(i,0,b) a[i]=c
#define lcm(a,b) (a/__gcd(a,b))*b
#define countofbits(n) __builtin_popcount(n)
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define pi (3.141592653589)
const int INF = 1e18;
const int M = 1e9+7;
const int MM = 998244353;
int modpow(int a, int b, int mod){ int res = 1; for(; b; b >>= 1){ if(b & 1) res = res * a; res %= mod; a = a * a; a %= mod;} return res;}
int power(int a, int b) { int res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a; a = a * a; }return res; }
//bool isPrime(int n){if(n==1) return false;if(n==2) return true;for(int i=2;i*i<=n;i++){if(n%i==0)return false;}return true;}
/*
vector<bool> prime(1000001, true);
void SieveOfEratosthenes()
{
int n = 1000000;prime[0] = false;prime[1] = false;
for (int p = 2; p * p <= n; p++)
if (prime[p] == true)
for (int i = p * p; i <= n; i += p)
prime[i] = false;
} */
void solve(){
int n;cin>>n;
vi a(n);
loop(i,0,n) cin>>a[i];
int k = 3*n;
cout << k << endl;
int c=1;
loop(i,0,n/2){
loop(j,0,3){
cout << "1 " << c << " " << c+1<< endl;
cout << "2 " << c << " " << c+1<< endl;
}
c+=2;
}
return ;
}
int32_t main(){
fast_io
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
int tc = 1 ;
cin >> tc ;
while(tc--){
solve();
}
return 0;
} | 8 | CPP |
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define ll long long
void solve() {
int n;
cin >> n;
vector<int> a(n);
for(int i = 0; i < n; i += 1) {
cin >> a[i];
}
cout << n / 2 * 6 << 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;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("taskA.in", "r", stdin);
// freopen("taskA.out", "w", stdout);
int t = 1;
cin >> t;
while(t--) {
solve();
}
return 0;
}
| 8 | CPP |
'''
|\_/|
| @ @ Woof!
| <> _
| _/\------____ ((| |))
| `--' |
____|_ ___| |___.'
/_/_____/____/_______|
I am here to gaurd this code, woof!
'''
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -(float('inf'))
input = stdin.readline
def solve():
pass
t = int(input())
# t = 1
for _ in range(t):
n = int(input())
# s = input()
# n, k = map(int, input().split())
arr = list(map(int, input().split()))
print(3*n)
for i in range(0, n, 2):
for j in range(6):
print(2 if not j % 2 else 1, i + 1 , i + 2)
| 8 | PYTHON3 |
import math
import sys
#from collections import deque, Counter, OrderedDict, defaultdict
#import heapq
#ceil,floor,log,sqrt,factorial,pow,pi,gcd
#import bisect
#from bisect import bisect_left,bisect_right
input = sys.stdin.readline
def inp():
return(int(input()))
def inlt():
return(list(map(int,input().split())))
def insr():
s = input().strip()
return(list(s[:len(s)]))
def invr():
return(map(int,input().split()))
for _ in range(inp()):
n=inp()
l=inlt()
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(1,i+1,i+2)
print(2,i+1,i+2)
print(1,i+1,i+2)
| 8 | PYTHON3 |
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;
void onetest() {
int n;
cin >> n;
std::vector<int> v;
for (int i = 0;i<n;i++) {
int e;
cin >> e;
v.push_back(e);
}
cout << 6*(n/2) <<"\n";
for (int i = 0;i<n/2;i++) {
int l = i+1;
int r = v.size()-i;
cout << "1 " << l << " " << r << "\n";
cout << "2 " << l << " " << r << "\n";
cout << "1 " << l << " " << r << "\n";
cout << "1 " << l << " " << r << "\n";
cout << "2 " << l << " " << r << "\n";
cout << "1 " << l << " " << r << "\n";
}
}
int main() {
int n;
cin >> n;
for (int i = 0;i<n;i++) {
onetest();
}
return 0;
}
| 8 | CPP |
t=int(input())
def solve():
n=int(input())
arr=list(map(int,input().split()))
print(n*3)
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)
for i in range(t):
solve() | 8 | PYTHON3 |
//DAILY HUSTLE MORE
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(a,b,n) for(int a=b;a<n;a++)
#define readarr(arr,n) f(i,0,n) cin>>arr[i];
#define ll long long
#define pb push_back
#define go ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ms(a,i) memset(a,i,sizeof(a))
#define mod 1e9+7
#define w(t) int t=1; cin>>t; while(t--)
#define MOD 1000000007
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define all(x) x.begin(), x.end()
#define gcd(x,y) __gcd(x,y)
#define vi vector<int>
#define vvi vector<vector<int>>
#define mi map<int,int>
#define pi pair<int,int>
#define vpi vector<pi>
#define si set<int>
#define MSETI multiset<int>
#define inf 1e18
#define ff first
#define ss second
#define ps(x,y) fixed <<setprecision(y)<< x
#define yes cout <<"YES" << endl
#define no cout <<"NO" << endl
#define impossible cout << -1 << endl
#define endl "\n"
#define mp(x,y) make_pair(x,y)
// ----------------ON A MISSION --------------- //
void pseudo()
{
go;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
long long hcf(long long a, long long b)
{
if (b == 0) return a;
a %= b;
return
hcf(b, a);
}
long long lcm(long long a, long long b)
{
return (a * b) / hcf(a, b);
}
//---------------------------------------------------------------------------------------------------------------//
void solA()
{
int n , m ;
cin >> n >> m ;
string H ;
cin >> H ;
//
int o = 0 , z = 0 ;
f(i, 0, n)
{
if (H[i] == '1') o++ ;
else
z++ ;
}
// indices i−1 and i+1.
vi dp(n);
f(i, 0, n)
{
if (H[i] == '1')
{
dp[i] = 0;
}
else
{
dp[i]++;
if (i > 0)
{
dp [i] = dp[i] + dp[i - 1] ;
}
}
}
int end = n ;
f(i, 0, n)
{
if (H[i] == '1')
{
end = i;
break;
}
}
f(i, end , n - 1)
{
if (dp[i] > 0 and dp[i + 1] == 0)
{
int st = i + 1 - dp[i] ;
int mid = dp[i] / 2;
mid = min(m , mid) ;
f(j, st, st + mid)
{
H[j] = '1';
}
for (int k = i; k > i - mid; k--)
{
H[k] = '1';
}
}
}
////
if (end < n)
{
int M = m;
for (int k = end - 1; k >= 0 and M--; k--)
{
H[k] = '1';
}
}
if (dp[n - 1] > 0 and dp[n - 1] < n)
{
int best = n - 1 - dp[n - 1] + 1;
for (int j = best ; j < best + m and j < n; j++)
{
H[j] = '1';
}
}
cout << H << "\n" ;
}
void solB()
{
int n, i;
cin >> n;
int a[n + 1];
for (i = 1; i <= n; i++) cin >> a[i];
cout << 3 * n << endl;
for (i = 1; i <= n / 2; i++)
{
int j = n / 2 + i;
cout << "1 " << i << " " << j << endl;
cout << "2 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
cout << "2 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
cout << "2 " << i << " " << j << endl;
}
}
//-------------------------------------------------------------------------------------------------------------//
int32_t main()
{
pseudo() ;
int t ;
cin >> t ;
//t = 1 ;
while (t--)
{
solB() ;
}
return 0;
}
| 8 | CPP |
def solve():
N = int(input())
arr = list(map(int, input().split()))
print(3 * N)
for i in range(0, N, 2):
for k in range(0, 3):
print(1, i + 1, i + 2)
print(2, i + 1, i + 2)
for _ in range(int(input())):
solve()
| 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
ll n;
cin >> n;
vector<ll> v(n);
for (ll i = 0; i < n; i++)
{
cin >> v[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 << "1 " << (i + 1) << " " << (i + 2) << "\n";
cout << "2 " << (i + 1) << " " << (i + 2) << "\n";
cout << "1 " << (i + 1) << " " << (i + 2) << "\n";
}
}
int main()
{
int testcase;
cin >> testcase;
while (testcase--)
{
solve();
}
return 0;
}
| 8 | CPP |
for _ in range(int(input())):
n = int(input())
l = list(map(int,input().split()))
print((n//2)*6)
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(1,i+1,i+2)
print(2,i+1,i+2)
print(1,i+1,i+2)
| 8 | PYTHON3 |
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define FOR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define print(v) for(auto i:v) cout<<i<<" ";
#define pii pair<int,int>
#define ll long long
#define pb push_back
#define S second
#define F first
const int MOD = 1e9+7;
static const auto __optimize__ = []() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
return 0;
}();
int main()
{
int t;
cin>>t;
while(t--) {
int n;
cin>>n;
vector<int> a(n,0);
for(auto i:a) cin>>i;
cout<<3*n<<"\n";
FOR(i,0,n,2) {
cout<<1<<" "<<i+1<<" "<<i+2<<"\n";
}
FOR(i,0,n,2) {
cout<<2<<" "<<i+1<<" "<<i+2<<"\n";
}
FOR(i,0,n,2) {
cout<<1<<" "<<i+1<<" "<<i+2<<"\n";
}
FOR(i,0,n,2) {
cout<<2<<" "<<i+1<<" "<<i+2<<"\n";
}
FOR(i,0,n,2) {
cout<<1<<" "<<i+1<<" "<<i+2<<"\n";
}
FOR(i,0,n,2) {
cout<<2<<" "<<i+1<<" "<<i+2<<"\n";
}
}
return 0;
} | 8 | CPP |
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <vector>
using namespace std;
void solve() {
int n;
cin >> n;
vector <int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
// add a[j] or subtract a[i]
// x, y
// x + y, y
// x + 2y, y
// x + 2y, -y-x
// y, -y-x
// -x, -y-x
// -x, -y
cout << 3 * n << '\n';
for (int i = 0; i < n; i += 2) {
for (int j : {1, 1, 2, 1, 1, 2}) {
cout << j << ' ' << (i + 1) << ' ' << (i + 2) << '\n';
//if (j == 1)
// a[i] += a[i + 1];
//else
// a[i + 1] -= a[i];
}
}
//for (int i = 0; i < n; i++)
// cout << a[i] << (i + 1 == n ? '\n' : ' ');
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin >> T;
while (T--) {
solve();
}
}
| 8 | CPP |
for _ in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
i=1
s=3*n
print(s)
while i<=n//2:
print(1,i,n-i+1)
print(2,i,n-i+1)
print(1,i,n-i+1)
print(1,i,n-i+1)
print(2,i,n-i+1)
print(1,i,n-i+1)
i=i+1 | 8 | PYTHON3 |
t = int(input())
for _ in range(t):
n = int(input())
a = input()
print(n // 2 * 6)
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) | 8 | PYTHON3 |
for _ in range(int(input())):
n=int(input());l=list(map(int,input().split()));print(n*3)
for i in range(0,n,2):
x=" "+str(i+1)+" "+str(i+2)
for j in range(6):print(str(2-j%2)+x) | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
int n;
cin >> n;
int a[n];
for(int i = 0; i < n; i++) cin >> a[i];
cout<<(n/2)*6<<endl;
for(int i = 1; i <= n; i+=2){
int j = i + 1;
cout<<1<<" "<<i<<" "<<j<<endl;
cout<<2<<" "<<i<<" "<<j<<endl;
cout<<2<<" "<<i<<" "<<j<<endl;
cout<<1<<" "<<i<<" "<<j<<endl;
cout<<2<<" "<<i<<" "<<j<<endl;
cout<<2<<" "<<i<<" "<<j<<endl;
}
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin>> t;
while(t--)solve();
return 0;
} | 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>p;
typedef long long int ll;
ll digits(ll num)
{
ll x=0;
while(num>0)
{
x++;
num/=10;
}
return x;
}
bool find(ll num)
{
while(num>=0)
{
if(num%11==0)
return true;
num-=111;
}
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
vector<int>v(n);
for(int i=0;i<n;i++)
{
cin>>v[i];
}
ll x=6*(n/2);
cout<<x<<endl;
for(int i=0;i<n;i+=2)
{
int i1=i+1;
int i2=i+2;
cout<<1<<" "<<i1<<" "<<i2<<endl;
cout<<2<<" "<<i1<<" "<<i2<<endl;
cout<<1<<" "<<i1<<" "<<i2<<endl;
cout<<2<<" "<<i1<<" "<<i2<<endl;
cout<<1<<" "<<i1<<" "<<i2<<endl;
cout<<2<<" "<<i1<<" "<<i2<<endl;
}
}
return 0;
} | 8 | CPP |
import os, sys
from io import BytesIO, IOBase
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")
mod = 998244353
from math import ceil, gcd, log2
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
print(3*n)
for i in range(1,n,2):
f=i
s=i+1
print(1,f,s)
print(2,f,s)
print(1,f,s)
print(2,f,s)
print(1, f, s)
print(2, f, s)
| 8 | PYTHON3 |
/*
~~~JsCode~~~
*/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ldb long double
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define tr(i,a) for(auto& i:(a))
#define fr(i,a,b) for(int i=(a);i<(b);++i)
#define frv(i,a,b) for(int i=(a);i>=(b);--i)
#define vi vector<int>
#define vvi vector<vi>
#define ii pair<int,int>
#define iii pair<int,ii>
#define vii vector<ii>
#define hmax priority_queue<int>
#define hmin priority_queue<int,vi,greater<int>>
#define MOD 1000000007
//#define int ll
int MAX=1e5;
void solve(){
int n;
cin>>n;
vi a(n);
tr(e,a) cin>>e;
cout<<n*3<<"\n";
for(int i=0;i<n;i+=2){
cout<<"1 "<<i+1<<" "<<i+2<<"\n";
cout<<"2 "<<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<<"2 "<<i+1<<" "<<i+2<<"\n";
}
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifdef LOCAL_JUDGE
freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#endif
//INIT
int t=1;
cin>>t;
for(int i=1;i<=t;i++){
//cout<<"Case #"<<i<<": ";
solve();
}
return 0;
} | 8 | CPP |
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;
const ll mod = 1e9 + 7;
const ll inf = ll(8e18);
int a[N];
ll binpow (ll a, ll n) {
if (n == 0) return 1ll;
if (n % 2) return ((binpow(a, n - 1) % mod) * (a % mod)) % mod;
else {
ll b = binpow (a, n / 2ll) % mod;
return b * b % mod;
}
}
void solve()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
cout << n / 2 * 6 << endl;
for (int i = 1; i <= n / 2; i++) {
int j = n - i + 1;
cout << "2 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
cout << "2 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
}
}
int main()
{
int t = 1, x = 1;
cin >> t;
while (t--)
{
//cout << "Case #" << x++ << ": ";
solve();
}
return 0;
}
| 8 | CPP |
//jay shree ram
#include <bits/stdc++.h>
#include <type_traits>
#include <sstream>
bool COMPARE(int a, int b)
{
return a > b;
}
using comp = std::integral_constant<decltype(&COMPARE), &COMPARE>;
using namespace std;
typedef long long ll;
#define int long long
typedef long double ld;
#define INF 0x3f3f3f3f
#define mod 1000000007
#define mod2 998244353
#define fori(T, N) for (int i = T; i < N; i++)
#define forin(N, T) for (int i = N - 1; i >= T; i--)
#define forj(T, N) for (int j = T; j < N; j++)
#define fork(T, N) for (int k = T; k < N; k++)
#define all(X) X.begin(), X.end()
#define alr(X) X.rbegin(), X.rend()
#define mm cout << endl
#define PI 3.1415926535897932384626
#define mset(arr, val) memset(arr, val, sizeof(arr))
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout << fixed << setprecision(10);
int Test = 1;
cin >> Test;
while (Test--)
{
int n;
cin >> n;
int a[n];
fori(0, n) cin >> a[i];
cout << 3 * n << endl;
for (int i = 1; i < n; i += 2)
{
int j = i + 1;
cout << "2 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
cout << "2 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
cout << "1 " << i << " " << j << endl;
}
}
}
//jay bajrang bali | 8 | CPP |
# by the authority of GOD author: Kritarth Sharma #
import math,copy
from collections import defaultdict,Counter
#from itertools import permutations
def fact(n):
return 1 if (n == 1 or n == 0) else n * fact(n - 1)
def prime(n) :
if (n <= 1) :
return False
if (n <= 3) :
return True
if (n % 2 == 0 or n % 3 == 0) :
return False
i = 5
while(i * i <= n) :
if (n % i == 0 or n % (i + 2) == 0) :
return False
i = i + 6
return True
def inp():
l=list(map(int,input().split()))
return l
## code starts here
#################################################################################################################
def main():
for _ in range(int(input())):
n=int(input())
l=inp()
k=[]
for i in range(1,n+1,2):
k.append([1,i,i+1])
k.append([2,i,i+1])
k.append([1,i,i+1])
k.append([1,i,i+1])
k.append([2,i,i+1])
k.append([1,i,i+1])
print(len(k))
for i in k:
print(*i)
import os,sys
from io import BytesIO,IOBase
#Fast IO Region
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")
if __name__ == "__main__":
main()
def random():
"""My code gets caught in plagiarism check for no reason due to the fast IO template, .
Due to this reason, I am making useless functions"""
rating=100
rating=rating*100
rating=rating*100
print(rating)
def random():
"""My code gets caught in plagiarism check for no reason due to the fast IO template, .
Due to this reason, I am making useless functions"""
rating=100
rating=rating*100
rating=rating*100
print(rating)
def random():
"""My code gets caught in plagiarism check for no reason due to the fast IO template, .
Due to this reason, I am making useless functions"""
rating=100
rating=rating*100
rating=rating*100
print(rating)
def random():
"""My code gets caught in plagiarism check for no reason due to the fast IO template, .
Due to this reason, I am making useless functions"""
rating=100
rating=rating*100
rating=rating*100
print(rating) | 8 | PYTHON3 |
from sys import stdin, stdout
input, print = stdin.readline, stdout.write
from math import *
def main():
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
print(str(3 * n) + '\n')
c = n // 2
for i in range(1, c + 1):
print('1 ' + str(i) + ' ' + str(i + c) + '\n')
print('2 ' + str(i) + ' ' + str(i + c) + '\n')
print('1 ' + str(i) + ' ' + str(i + c) + '\n')
print('1 ' + str(i) + ' ' + str(i + c) + '\n')
print('2 ' + str(i) + ' ' + str(i + c) + '\n')
print('1 ' + str(i) + ' ' + str(i + c) + '\n')
main() | 8 | PYTHON3 |
/**
author: Aditya : "Specialist Soon"
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define nl '\n'
#define rep(ind, a, b) for (int ind = a; ind < b; ++ind)
#define rev(ind, a, b) for (int ind = a; ind >= b; --ind)
#define loop(n) for (int ind = 0; ind < n; --ind)
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define eb emplace_back
#define rsz resize
#define ft front()
#define bk back()
#define pf(v, ele) v.insert(v.begin(), ele)
#define ppf(v) v.erase(v.begin());
#define all(xxx) (xxx).begin(), (xxx).end()
#define rall(xxx) (xxx).rbegin(), (xxx).rend()
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define bitc(n) __builtin_popcount(n)
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<vector<int>>
#define umap unordered_map<int, int>
#define pq_max priority_queue<int>
#define pq_min priority_queue<int, vector<int>, greater<int>>
#define sum(a) (accumulate((a).begin(), (a).end(), 0LL))
#define mine(a) (*min_element((a).begin(), (a).end()))
#define maxe(a) (*max_element((a).begin(), (a).end()))
#define mini(a) (min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a) (max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, xxx) (lower_bound((a).begin(), (a).end(), (xxx)) - (a).begin())
#define uppb(a, xxx) (upper_bound((a).begin(), (a).end(), (xxx)) - (a).begin())
void test_cases()
{
// cout << "Expert by the end of month" << nl;
int n, ans;
cin >> n;
rep(i, 0, n) cin >> ans;
cout << 3 * n << nl;
for (int index = 1; index < n; index += 2)
{
cout << 1 << ' ' << index << ' ' << index + 1 << nl;
cout << 2 << ' ' << index << ' ' << index + 1 << nl;
cout << 2 << ' ' << index << ' ' << index + 1 << nl;
cout << 1 << ' ' << index << ' ' << index + 1 << nl;
cout << 2 << ' ' << index << ' ' << index + 1 << nl;
cout << 2 << ' ' << index << ' ' << index + 1 << nl;
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tc;
cin >> tc;
for (int test = 1; test <= tc; ++test)
test_cases();
return 0;
} | 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
#define fi(i,a,b) for(ll i = (a); i < (b); i++)
#define fr(i,a,b) for(ll i = (a); i >=(b); i--)
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define mp make_pair
#define pb push_back
#define inf 2e15
#define inp(arr,z) for(int i=0; i<z; i++)cin>>arr[i]
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
void solve();
int main(){
fast_cin();
chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
////freopen("output.txt", "w", stdout);
#endif
ll t;
cin >> t;
while (t--)
{solve();cout<<endl;}
chrono::high_resolution_clock::time_point t2 = chrono::high_resolution_clock::now();
chrono::duration<double, std::milli> time_span = t2 - t1;
//cout<<time_span.count();
return 0;
}
ll power(ll a , ll b ){ll r=1;ll o=a;if(b<=0)return 1;
while(b!=0){if(b%2)r*=o,b--; else {b/=2; o=o*o;}}
return r;}
void solve(){
ll n; cin>>n;
v64 a(n);
inp(a,n);
cout<<n*3<<endl;
for(int i=1; i<=n; i+=2){
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;
cout <<"1 "<<i<<" "<<i+1<<endl;
}
}
| 8 | CPP |
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
print(3 * n)
for i in range(n//2):
j = n - i - 1
for k in range(3):
print(1, i + 1, j + 1, '\n', 2, i + 1, j + 1) | 8 | PYTHON3 |
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
template <typename T> void read(T & x){
x = 0; int op = 1; char ch = getchar();
while (!isdigit(ch)){ if (ch == '-') op = -1; ch = getchar();}
while (isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48); ch = getchar();}
x*= op;
}
struct item{
int id, x, y;
};
void solve(){
int n;
read(n);
vector<int> a(n);
for (int i = 0; i < n; ++i) {
read(a[i]);
}
vector<item> res;
for (int i = 1; i <= n; i += 2) {
res.push_back({1, i, i + 1});
res.push_back({2, i, i + 1});
res.push_back({1, i, i + 1});
res.push_back({2, i, i + 1});
res.push_back({1, i, i + 1});
res.push_back({2, i, i + 1});
}
cout << res.size() << endl;
for (auto x : res){
printf("%d %d %d\n", x.id, x.x, x.y);
}
}
signed main(){
int cases;
read(cases);
while (cases--){
solve();
}
}
| 8 | CPP |
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector
#define pb push_back
#define pub pull_back
#define be begin
#define p pair<ll,ll>
#define f first
#define se second
#define um unordered_map
#define om map
#define us unordered_set
#define tr pair<ll,pair<long long int,long long int>>
#define Q queue
#define cp(v1,x,i,n) for(i=0;i<n;i++){v1[i]=x;}
#define lp(i,a,b) for(i=a;i<b;i++)
#define MAXN 10000001
#define pq priority_queue
ll spf[MAXN];
void seive()
{
spf[1]=1;
for(int i=2;i<MAXN;i++)
spf[i]=i;
for(int i=4;i<MAXN;i+=2)
spf[i]=2;
for(int i=3;i*i<MAXN;i++)
{
if(spf[i]==i) {
for(int j=i*i;j<MAXN; j+=i)
if(spf[j]==j)
spf[j]=i; }
}
}
ll printDivisors(ll n)
{
// Note that this loop runs till square root
for (ll i=2; i<=sqrt(n); i++)
{
if (n%i == 0)
{
// If divisors are equal, print only one
if (n/i == i)
return i;
else // Otherwise print both
return n/i;
}
}
return 1;
}
v<ll> getFactorization(ll x)
{
vector<ll> ret;
while(x!=1)
{
ret.push_back(spf[x]);
x = x / spf[x];
}
return ret;
}
ll gcd(ll a,ll b)
{
if(a==0)
return b;
if(b==0)
return a;
if(a==b)
return a;
if(a>b)
return gcd(a-b,b);
return gcd(a,b-a);
}
double nthRoot(int A, int N)
{
double xPre = rand() % 10;
double eps=1e-3;
double delX=INT_MAX;
double xK;
while (delX > eps)
{
xK=((N-1.0)*xPre+(double)A/pow(xPre,N-1))/(double)N;
delX=abs(xK-xPre);
xPre=xK;
}
return xK;
}
/*--------------------------------------------------------------------------Tree Algo----------------------------------------------------------------------------------*/
/*ll dp[200005][21];
static v<ll> v1[200005];
v<ll> dp1(200005);
map<ll,ll> m;
v<ll> v3;
ll en[200005],st[200005];
set<ll> *ss[200005];
void dfs(ll s,ll p1,v<ll> &v2)
{
ll c=0,d=0;
for(ll i=0;i<v1[s].size();i++)
if(v1[s][i]!=p1)
{
dfs(v1[s][i],s,v2);
if(c<ss[v1[s][i]]->size())
{
c=ss[v1[s][i]]->size();
d=v1[s][i];
}
}
if(d!=0)
ss[s]=ss[d];
else
ss[s]=new set<ll>();
ss[s]->insert(v2[s]);
for(ll i=0;i<v1[s].size();i++)
if(v1[s][i]!=p1&&v1[s][i]!=d)
{
for(auto x:*ss[v1[s][i]])
ss[s]->insert(x);
}
dp1[s]=ss[s]->size();
}
//Binary Lifting
void binary_lifting(ll s,ll p1,ll l,v<ll> &le,ll n)
{
// dfs(1,0);
for(ll i=1;(1<<i)<=n;i++)
for(ll j=0;j<=n;j++)
dp[j][i]=(dp[dp[j][i-1]][i-1]);
}
//Heavy Light Decomposition
static v<ll> HLD[200005];
v<ll> seg(200005),pos(200005),par(2501);
ll c=0;
void hld(ll s,ll p1)
{
ll d=0 ,e=0;
seg[s]=c;
pos[s]=HLD[c].size();
HLD[c].pb(s);
for(ll i=0;i<v1[s].size();i++)
{ if(v1[s][i]!=p1)
{
if(dp1[v1[s][i]]>d)
{
d=dp1[v1[s][i]];
e=v1[s][i];
}
}
}
if(e!=0)
{
par[e]=par[s];
hld(e,s);
}
for(ll i=0;i<v1[s].size();i++)
{
if(v1[s][i]!=p1&&e!=v1[s][i])
{
par[v1[s][i]]=s;
c++;
hld(v1[s][i],s);
}
}
}
//Binary Indexed Tree
v<v<ll>> BItree(200005);
void updatebit(ll i,ll n,ll val,ll j)
{
i++;
while(i<=n)
{
BItree[j][i]+=val;
i+=i&(-i);
}
}
ll getbit(ll i,ll j)
{
ll sum=0;
i++;
while(i)
{
sum+=BItree[j][i];
i-=(i&(-i));
}
return sum;
}
void bitree(v<ll> &v2)
{
for(ll i=0;i<=c;i++)
{
for(ll j=0;j<=HLD[i].size();j++)
BItree[i].pb(0);
}
for(ll i=0;i<=c;i++)
{
for(ll j=0;j<HLD[i].size();j++)
updatebit(j,HLD[i].size(),v2[HLD[i][j]],i);
}
}
*/
/*--------------------------------------------------------------------------Tree Algo----------------------------------------------------------------------------------*/
/*v<ll> vis(2501),vis1(2501);
v<p> v2[100001];
ll sum11=-77777;
v<ll> v4[2501];
/*void dfsg(ll i,ll sum,ll n)
{
vis[i]=1;
if(i==n)
{
if(sum11==-77777)
sum11=sum;
else
sum11=max(sum11,sum);
vis[i]=0;
return;
}
if(i!=n)
for(auto x:v2[i])
{
if(!vis[x.f])
{
dfsg(x.f,sum+x.se,n);
}
}
vis[i]=0;
}*/
/*
v<ll> dis[100001];
v<pair<ll,ll>> bef[1001];
/*void bfs(ll i)
{
queue<ll> q;
dis[i]=0;
q.push(i);
vis[i]=1;
while(!q.empty())
{
ll c=q.front();
q.pop();
for(auto x:v1[c])
{
if(!vis[x])
{
vis[x]=1;
q.push(x);
}
}
}
}*/
//dijsktra-------------------
/*void dijsktra(ll i,ll k)
{
pq<p,v<p>,greater<p>> q; //min heap
q.push({0,i});
while(!q.empty())
{
p c=q.top();
q.pop();
for(auto x:v2[c.se])
{
if(dis[x.f][k-1]>c.f+x.se)
{
dis[x.f][k-1]=c.f+x.se;
q.push({dis[x.f][k-1],x.f});
sort(dis[x.f].begin(),dis[x.f].end());
}
}
}
}*/
int main()
{
ll t=1,pp=0;
//cin>>t;
/* static ll p[10000003];
for(ll i=0;i<10000003;i++)
p[i]=1;
for(pp=2;pp*pp<=10000003;pp++)
{
if(p[pp]==1)
{
for(ll i=pp*pp;i<=10000003;i+=pp)
p[i]=0;
}
}
*/
cin>>t;
while(t--)
{
ll n,j=0,w,b=0,sum1=0,sum2=0,mina,maxa,e,h=0,g=0,x2=-1,y1,y2=-1,a,l=0,r,l1=0,r1=0,x1=0;
ll sum=0,i=0,y=0,q=0,c=0;
ll d=998244353;
ll k=0,k1=0,u,k2=0,k3=0,k4=0;
ll m;
string s;
cin>>n;
v<ll> v1(n);
lp(i,0,n)
{
cin>>v1[i];
}
v<tr> v2;
for(i=0;i<n;i++)
{
v2.pb({2,{i+1,i+2}});
v2.pb({1,{i+1,i+2}});
v2.pb({1,{i+1,i+2}});
v2.pb({2,{i+1,i+2}});
v2.pb({1,{i+1,i+2}});
v2.pb({1,{i+1,i+2}});
i++;
}
cout<<v2.size()<<"\n";
for(auto x: v2)
cout<<x.f<<" "<<x.se.f<<" "<<x.se.se<<"\n";
//cout<<"\n";
}
return 0;
}
| 8 | CPP |
import os
import sys
from io import BytesIO, IOBase
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 t in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
ans=[]
for i in range(0,n,2):
j=i+1
ans.extend([[1,i+1,j+1],[2,i+1,j+1],[1,i+1,j+1],[1,i+1,j+1],[2,i+1,j+1],[1,i+1,j+1]])
print(len(ans))
for i in ans:
print(*i)
| 8 | PYTHON3 |
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
//---------------------------------//
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
void hat(){
//tcT> constexpr bool needs_output_v = !is_printable_v<T> && is_iterable_v<T>;
// ts: string representation to print
long long a[0];
long long sum[0];
long long dp[0];
long long q[0];
long long minn[0];
int n,c;
scanf("%d%d",&n,&c);
for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
for(int i=1;i<=c;i++) sum[i]=sum[i-1]+a[i];
for(int i=c+1;i<=n;i++) sum[i]=sum[i-1]+a[i]-a[i-c];
for(int i=1;i<c;i++) dp[i]=dp[i-1]+a[i];
q[1]=1;
int l=1,r=1;
for(int i=1;i<=n;i++){
while(l<=r&&q[l]<=i-c) l++;
while(l<=r&&a[q[r]]>a[i]) r--;
q[++r]=i,minn[i]=a[q[l]];
}
for(int i=c;i<=n;i++){
dp[i]=min(dp[i-1]+a[i],dp[i-c]+sum[i]-minn[i]);
}
printf("%lld",dp[n]);
}
int ye_nahai(int x, char ch)
{
int n;
cin>>n;
int arr[n];
int max_ending_here = 0, max_so_far = INT_MIN;
for (int i = 0; i < n; i++) {
// include current element to previous subarray only
// when it can add to a bigger number than itself.
if (arr[i] <= max_ending_here + arr[i]) {
max_ending_here += arr[i];
}
// Else start the max subarry from current element
else {
max_ending_here = arr[i];
}
if (max_ending_here > max_so_far)
max_so_far = max_ending_here;
}
n *= 2;
vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
//sort(all(a));
for(int i = 0; i < n/2; i++){
cout<<a[i]<<" "<<a[i+n/2]<<" ";
}
cout<<endl;
cin>>n;
n *= 2;
// vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
//sort(all(a));
for(int i = 0; i < n/2; i++){
cout<<a[i]<<" "<<a[i+n/2]<<" ";
}
cout<<endl;
cin>>n;
n *= 2;
// vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
//sort(all(a));
for(int i = 0; i < n/2; i++){
cout<<a[i]<<" "<<a[i+n/2]<<" ";
}
cout<<endl;
cin>>n;
n *= 2;
//vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
//sort(all(a));
for(int i = 0; i < n/2; i++){
cout<<a[i]<<" "<<a[i+n/2]<<" ";
}
cout<<endl;
cin>>n;
n *= 2;
//vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
//sort(all(a));
for(int i = 0; i < n/2; i++){
cout<<a[i]<<" "<<a[i+n/2]<<" ";
}
cout<<endl;
cin>>n;
n *= 2;
//vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
//sort(all(a));
for(int i = 0; i < n/2; i++){
cout<<a[i]<<" "<<a[i+n/2]<<" ";
}
cout<<endl;
cin>>n;
n *= 2;
//vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
//sort(all(a));
for(int i = 0; i < n/2; i++){
cout<<a[i]<<" "<<a[i+n/2]<<" ";
}
cout<<endl;
cin>>n;
n *= 2;
//vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
//sort(all(a));
for(int i = 0; i < n/2; i++){
cout<<a[i]<<" "<<a[i+n/2]<<" ";
}
cout<<endl;
}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
//------------------------------//
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define ps(x,y) fixed<<setprecision(y)<<x
#define rep(i,a,b) for(ll i=a ; i<b ; ++i)
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll maxn = 1e6 + 4;
void solve(){
int n;
cin>>n;
int arr[n];
for(int i=0; i<n; i++)
cin>>arr[i];
cout<<(n/2)*6<<endl;
for(int i=1; i<=n; i+=2)
{
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;
cout<<2<<" "<<i<<" "<<i+1<<endl;
}
}
int main(){
IOS
int test;
cin>>test;
while(test--)
solve();
}
// integer overflow
// var vs loop var
| 8 | CPP |
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef long double LD;
const int N=10005;
int _,m,n;
int a[N];
int main(){
cin>>_;
while(_--){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
cout<<n*6/2<<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 |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9 + 7;
const int N = 3e5 + 10;
void solve() {
int n;
cin >> n;
vector<int>v(n);
for(auto &e : v) {
cin >> e;
}
cout << (n / 2) * 6 << "\n";
int c = 0;
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 << 1 << " " << i << " " << i + 1 << "\n";
cout << 2 << " " << i << " " << i + 1 << "\n";
cout << 1 << " " << i << " " << i + 1 << "\n";
c += 7;
}
// cout << c << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int tc = 1;
cin >> tc;
while(tc--) {
solve();
}
return 0;
} | 8 | CPP |
# cook your dish here
import sys
from os import path
import math
import time
from collections import defaultdict
from sys import setrecursionlimit
setrecursionlimit(10**8)
MOD = (10**9) + 7
INT_MAX = 10**9
if(path.exists('input.txt')):
sys.stdin=open('input.txt', 'r')
sys.stdout=open('output.txt','w')
def SieveOfEratosthenes(n):
prime = [True for i in range(n + 1)]
p = 2
while (p * p <= n):
if (prime[p] == True):
for i in range(p*2, n + 1, p):
prime[i] = False
p += 1
prime[0] = False
prime[1] = False
# Print all prime numbers
no_prime = []
count = 0
for i in range(len(prime)):
if prime[i]:
count += 1
no_prime.append(count)
return no_prime
def test_case():
t = int(input())
# p = SieveOfEratosthenes(10000000+2)
for _ in range(t):
n = int(input())
arr = list(map(int,input().split()))
print((n//2)*6)
for i in range(1,n+1,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)
test_case()
| 8 | PYTHON3 |
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int 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 = 0; i < n/2; i++) {
cout << 1 << " " << 2*i+1 << " " << 2*i+2 << endl;
cout << 2 << " " << 2*i+1 << " " << 2*i+2 << endl;
cout << 2 << " " << 2*i+1 << " " << 2*i+2 << endl;
cout << 1 << " " << 2*i+1 << " " << 2*i+2 << endl;
cout << 2 << " " << 2*i+1 << " " << 2*i+2 << endl;
cout << 2 << " " << 2*i+1 << " " << 2*i+2 << endl;
}
}
}
| 8 | CPP |
from sys import stdin, stdout
intn = lambda : int(stdin.readline())
strs = lambda : stdin.readline()[:-1]
lstr = lambda : list(stdin.readline()[:-1])
mint = lambda : map(int, stdin.readline().split())
lint = lambda : list(map(int, stdin.readline().split()))
out = lambda x: stdout.write(str(x)+"\n")
out_ = lambda x: stdout.write(str(x)+' ')
def main():
for _ in range(intn()):
n = intn()
a = lint()
out(3*n)
for i in range(0,n,2):
for j in range(3):
out(f'1 {i+1} {i+2}')
out(f'2 {i+1} {i+2}')
if __name__ == "__main__":
main() | 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin>>T;
while(T--){
int N;
cin>>N;
long long int A[N];
for(int i=0;i<N;i++){cin>>A[i];}
cout<<3*N<<"\n";
for(int i=0;i<N;i+=2){
cout<<2<<" "<<i+1<<" "<<i+2<<"\n";
cout<<1<<" "<<i+1<<" "<<i+2<<"\n";
cout<<2<<" "<<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 |
import sys
def answer(n, a):
num_steps = 0
ans = [] #list of 3-tuples (T, i, i+1)
for i in range(0, n, 2):
n1 = a[i]
n2 = a[i+1]
if n1 == n2:
num_steps += 4
ans.append((2, i, i+1))
ans.append((2, i, i+1))
ans.append((1, i, i+1))
ans.append((1, i, i+1))
elif n1 != n2:
num_steps += 6
ans.append((1, i, i+1))
ans.append((2, i, i+1))
ans.append((1, i, i+1))
ans.append((2, i, i+1))
ans.append((1, i, i+1))
ans.append((2, i, i+1))
print(num_steps)
for tup in ans:
print(tup[0], tup[1]+1, tup[2]+1)
return
def main():
t = int(sys.stdin.readline())
while t:
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
answer(n, a)
t -= 1
return
main() | 8 | PYTHON3 |
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int N;
int main() {
int T;
cin >> T;
for (int t = 0; t < T; t++) {
cin >> N;
vector<int> a(N);
for (int i = 0; i < N; i++)
cin >> a[i];
cout << N / 2 * 6 << 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 |
#include <bits/stdc++.h>
typedef long long ll ;
#define int ll
const int MAX=1e3+10;
const int modn=1e9+7;
const int INF=0x3f3f3f3f3f3f;
#define endl '\n'
#define cwk freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
typedef pair<int, int> PII;
int n,m,k,a[MAX],b[MAX],c[MAX];
string s;
bool check(){
for(int i=1;i<=n;i++){
if(a[i]!=c[i]) return false;
}
return true;
}
void solve(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
cout<<3*n<<'\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';
}
}
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
//cwk;
int _=1;
cin>>_;
while(_--){
solve();
}
return 0;
}
| 8 | CPP |
t=int(input())
while t:
t-=1
n=int(input())
arr=[int(c) for c in input().split()]
print(n*3)
for i in range(1,n+1,2):
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)
print(1,i,i+1)
| 8 | PYTHON3 |
from collections import Counter
def getlist():
return list(map(int,input().split()))
def main():
t = int(input())
for num in range(t):
n = int(input())
arr = getlist()
print(6*(n//2))
number = 1
while number<n:
i = 1
for typ in range(6):
if i==1:
print(i,number,number+1)
# arr[number-1] = arr[number-1]+arr[number]
i = 2
else:
print(i,number,number+1)
# arr[number] = arr[number]-arr[number-1]
i = 1
number+=2
# print(arr)
main()
| 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
#define NFS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#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 endl "\n"
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A) cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
#define ll long long int
#define ull unsigned long long
#define vll vector<long long>
#define mll map<long long,long long>
#define pll pair<long long,long long>
#define v2d vector<vll>
#define vpll vector<pll>
#define mpll map<pll>
#define all(v) v.begin(),v.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define alla(v) v,v+n
#define acc(a) accumulate(alla(a),(ll)0)
#define PB push_back
#define MP make_pair
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define mod 1000000007
#define PI 3.14159265358979323846
/*
bool prime[1000001];
ll fsp[10000001];
void sieve() {memset(prime, true, sizeof(prime));
for (ll i = 2; i * i <= 1000000; i++)if (prime[i])for (ll j = i * i; j <= 1000000; j+= i)prime[j] = false;
prime[0] = prime[1] = false;}
void fastsieve() {fsp[1]=1;for(int i=2;i<=1e7;i++) fsp[i]=i;for (int i=4;i<=1e7;i+=2) fsp[i] = 2;
for (int i=3; i*i<=1e7; i++) {if(fsp[i]==i) {for (int j=i*i; j<=1e7; j+=i)if (fsp[j]==j) fsp[j] = i;}}}
*/
ll mul(ll a,ll b) {
return ((a % mod) * (b % mod)) % mod;
}
ll add(ll a,ll b) {
return (a % mod + b % mod) % mod;
}
ll gcd(ll a, ll b){
if (b == 0)
return a;
return gcd(b, a % b);
}
ll extgcd(ll a,ll b,ll& x,ll& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
ll x1, y1;
ll d = extgcd(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return d;
}
bool isPrime(ll n){
if (n <= 1)
return false;
if (n <= 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
for (ll i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
return true;
}
bool isPowerOfTwo(ll n) {
if(n==0)
return false;
return (ceil(log2(n)) == floor(log2(n)));
}
//Prime factorization of integer n O(sqrt(n))
vector<ll> factors(ll n)
{
vector<ll> f;
for (ll x = 2; x*x <= n; x++)
{
while (n%x == 0)
{
f.push_back(x);
n /= x;
}
}
if (n > 1) f.push_back(n);
return f;
}
ll bin_exp_mod(ll a,ll n)
{
ll res=1;
a%=mod;
if(a==0)
return 0;
while(n>0)
{
if(n&1)
res=((res%mod)*(a%mod))%mod;
n=n>>1;
a=((a%mod)*(a%mod))%mod;
}
res%=mod;
return res;
}
void solve()
{
ll n,m,k;
cin>>n;
ll a[n];
fr(i,0,n)
cin>>a[i];
ll i=1,j=2;
cout<<(n*3)<<"\n";
fr(x,0,n/2)
{
cout<<"1 "<<i<<" "<<j<<"\n";
cout<<"2 "<<i<<" "<<j<<"\n";
cout<<"2 "<<i<<" "<<j<<"\n";
cout<<"1 "<<i<<" "<<j<<"\n";
cout<<"2 "<<i<<" "<<j<<"\n";
cout<<"2 "<<i<<" "<<j<<"\n";
i+=2;
j+=2;
}
}
int main() {
// your code goes here
NFS;
ll t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
| 8 | CPP |
import os
import sys
from io import BytesIO, IOBase
import math
from collections import Counter
def a(x):
print(3*len(x))
for i in range(0, len(x), 2):
for j in range(3):
print(f"2 {i+1} {i+2}")
print(f"1 {i+1} {i+2}")
def main():
q = int(parse_input())
r = []
for _ in range(q):
n = int(parse_input())
x = [int(i) for i in parse_input().split()]
a(x)
parse_input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == "__main__":
main() | 8 | PYTHON3 |
import math, sys, heapq
for t in range(int(input())):
n=int(input())
a=[int(i) for i in input().split()]
ans=[]
for i in range(1,n+1,2):
for j in range(3):
ans.append([1,i,i+1])
ans.append([2,i,i+1])
a[i-1]=a[i-1]+a[i]
a[i]=a[i]-a[i-1]
print(len(ans))
for i in ans:
print(*i) | 8 | PYTHON3 |
import sys
import bisect
input=sys.stdin.readline
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(1,n+1,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 x in ans:
print(*x) | 8 | PYTHON3 |
import math
from collections import defaultdict
t=int(input())
for _ in range(t):
n=int(input())
#n,m=map(int,input().split())
b=list(map(int,input().split()))
curr=1
ans=[]
for j in range(n//2):
i1=curr
i2=curr+1
ans.append([1, i1, i2])
ans.append([2, i1, i2])
ans.append([1, i1, i2])
ans.append([1, i1, i2])
ans.append([2, i1, i2])
ans.append([1, i1, i2])
curr+=2
print(len(ans))
for j in ans:
print(*j)
| 8 | PYTHON3 |
import sys,os,io
import math,bisect,operator,itertools
inf,mod = float('inf'),10**9+7
# sys.setrecursionlimit(10 ** 6)
from itertools import groupby,accumulate
from heapq import heapify,heappop,heappush
from collections import deque,Counter,defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int,input().split()))
test, = Neo()
for _ in range(test):
n, = Neo()
A = Neo()
i = 1
print(3*n)
while i < n:
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)
i += 2
| 8 | PYTHON3 |
"""
// Author : snape_here - Susanta Mukherjee
"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def msi(): return map(str,input().split())
def mi(): return map(int,input().split())
def li(): return list(mi())
def lsi(): return list(msi())
def read():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
def gcd(x, y):
while y:
x, y = y, x % y
return x
def lcm(x, y):
return (x*y)//(gcd(x,y))
mod=1000000007
def modInverse(b,m):
g = gcd(b, m)
if (g != 1):
return -1
else:
return pow(b, m - 2, m)
def ceil2(x,y):
if x%y==0:
return x//y
else:
return x//y+1
def modu(a,b,m):
a = a % m
inv = modInverse(b,m)
if(inv == -1):
return -999999999
else:
return (inv*a)%m
from math import log,factorial,cos,tan,sin,radians,floor,sqrt,ceil,log2
import bisect
import random
import string
from decimal import *
getcontext().prec = 50
abc="abcdefghijklmnopqrstuvwxyz"
pi=3.141592653589793238
def gcd1(a):
if len(a) == 1:
return a[0]
ans = a[0]
for i in range(1,len(a)):
ans = gcd(ans,a[i])
return ans
def mykey(x):
return len(x)
def checkper_sq(n):
def check(n,mod):
for i in range(mod):
if (i*i)%mod == n%mod:
return True
return False
for i in range(3,101):
if not check(n,i):
return False
return True
def main():
for _ in range(ii()):
n=ii()
a=li()
ans = 6*(n//2)
print(ans)
for i in range(n//2):
j = 2*i+1
print(1,j,j+1)
print(2,j,j+1)
print(1,j,j+1)
print(2,j,j+1)
print(1,j,j+1)
print(2,j,j+1)
# print("Case #",end="")
# print(_+1,end="")
# print(": ",end="")
# print(ans)
#9836
# 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")
# endregion
if __name__ == "__main__":
#read()
main() | 8 | PYTHON3 |
for I in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
print(3*n)
for I in range(0,n,2):
I +=1
z=lambda a: print(a,I,I+1)
z(2);z(1);z(2);z(2);z(1);z(2)
| 8 | PYTHON3 |
import math
from collections import Counter
from itertools import permutations, combinations
import fractions
def show(a,b):
print(1, a, b) # a+b b
print(1, a, b) # a+2b b
print(2, a, b) # a+2b -a-b
print(1, a, b) # -b -a-b
print(1, a, b) # -a -a-b
print(2, a, b) # -a -b
def solve(test):
n = int(input())
#n, m = [int(s) for s in input().split(" ")]
#s = input()
a = [int(s) for s in input().split(" ")]
print(3*n)
for i in range(n//2):
first = i
last = n-i-1
show(first+1, last+1)
t = int(input())
for _ in range(t):
solve(_+1)
"""
n = int(input())
a = [int(s) for s in input().split(" ")]
a, b = [int(s) for s in input().split(" ")]
s = input()
ans =
"""
| 8 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int inf = int(1e9) + 15;
#define pb push_back
#define fi first
#define se second
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define sz(x) (int)x.size()
ll time() {return chrono::system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
const double PI = acos(-1);
const double PPI = 2 * PI;
void solve()
{
int n;
cin >> n;
vector<int> a(n);
for (auto& t : a)
cin >> t;
vector< array<int, 3> > logging;
for (int i = 0; i < n; i += 2)
{
logging.pb({1, i + 1, i + 2});
logging.pb({2, i + 1, i + 2});
logging.pb({1, i + 1, i + 2});
logging.pb({2, i + 1, i + 2});
logging.pb({1, i + 1, i + 2});
logging.pb({2, i + 1, i + 2});
}
cout << sz(logging) << '\n';
for (auto it : logging)
cout << it[0] << " " << it[1] << " " << it[2] << '\n';
}
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _LOCAL_
system("color a");
#endif // _LOCAL_
int t;
cin >> t;
while (t--)
solve();
}
| 8 | CPP |
#include <iostream>
#include <array>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <tuple>
#include <string>
#include <fstream>
#include <iomanip>
#include <random>
#include <numeric>
#include <new>
#include <sstream>
#include <streambuf>
#include <cstring>
using namespace std;
#define ar array
#define ss second
#define ll long long
#define ff first
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) (int)a.size()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pr pair
#define vi vector<int>
#define vl vector<ll>
#define vt vector
#define pb push_back
#define mp make_pair
string to_string(char c) {
return string(1, c);
}
string to_string(bool b) {
return b ? "true" : "false";
}
string to_string(const char* s) {
return string(s);
}
string to_string(string s) {
return s;
}
string to_string(vector<bool> v) {
string res;
for (int i = 0; i < sz(v); ++i) res += char('0' + v[i]);
return res;
}
template<size_t S> string to_string(bitset<S> b) {
string res;
for (int i = 0; i < S; ++i) res += char('0' + b[i]);
return res;
}
template<class T> string to_string(T v) {
bool f = 1;
string res;
for (int i = 0; i < sz(v); ++i) {
if (!f) res += ' ';
f = 0;
res += to_string(v[i]);
}
return res;
}
ll binpow (ll a, ll n, ll m) {
ll res = 1;
while (n) {
if (n & 1) res *= a, res %= m;
a *= a;
a %= m;
n >>= 1;
}
return res;
}
ll __gcd(ll a, ll b) {
return b ? __gcd(b, a % b) : a;
}
template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(array<A, S>& a);
template<class T> void read(T& x) {
cin >> x;
}
void read(double& d) {
string t;
read(t);
d = stod(t);
}
void read(long double& d) {
string t;
read(t);
d = stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
read(h);
read(t...);
}
template<class A> void read(vt<A>& x) {
for (auto& a : x) read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
for (auto& a : x) read(a);
}
template<class A> void write(A x) {
cout << to_string(x);
}
template<class H, class... T> void write(const H& h, const T&... t) {
write(h);
write(t...);
}
void print() {
write("\n");
}
template<class H, class... T> void print(const H& h, const T&... t) {
write(h);
if (sizeof...(t))
write(' ');
print(t...);
}
void DBG() {
cerr << "]" << endl;
}
template<class H, class... T> void DBG(H h, T... t) {
cerr << to_string(h);
if (sizeof...(t))
cerr << ", ";
DBG(t...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
const int MOD = 1e9 + 7; //1073741824;
const int N = 2e6 + 5;
const ll INF = 9e18;
const int M = 3e3 + 5;
int a[N];
struct ans {
int type, i, j;
};
void solve() {
int n;
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i];
vt<ans> A;
for(int i = 1; i <= n / 2; ++i) {
ans cur;
cur.type = 1, cur.i = i, cur.j = n - i + 1;
A.pb(cur);
a[cur.i] += a[cur.j];
cur.type = 2;
A.pb(cur), A.pb(cur);
a[cur.j] -= a[cur.i] * 2;
cur.type = 1;
A.pb(cur);
a[cur.i] += a[cur.j];
cur.type = 2;
A.pb(cur);
a[cur.j] -= a[cur.i];
A.pb(cur);
a[cur.j] -= a[cur.i];
}
/* for(int i = 1; i <= n; ++i) cout << a[i] << " ";
cout << "\n";*/
cout << sz(A) << "\n";
for(auto x : A) cout << x.type << " " << x.i << " " << x.j << "\n";
}
int main() {
/*freopen(".in", "r", stdin);
freopen(".out", "w", stdout);*/
// for(int i s)
ios::sync_with_stdio(false);
cin.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
// a b a a b b a b
// 0 1 1 1 3 3 3 4 | 8 | CPP |
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
int n;
cin >> n;
vector<int> v(n);
for(int i = 0; i < n; i++)
cin >> v[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 << "1 " << i << " " << i+1 << endl;
cout << "1 " << i << " " << i+1 << endl;
cout << "2 " << i << " " << i+1 << endl;
cout << "1 " << i << " " << i+1 << endl;
}
}
return 0;
}
| 8 | CPP |
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define MMM 1000000007
using namespace std;
ll POW(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;
}
/* Problems to do: Topic
-> Little Girl and Maximum Sum -> Fenwick tree
*/
/*
---------------------------------------------------------------------------------------------------------------------------------------------------
(Problem related to this snippet: "Linova and Kingdom, source: Codeforces")
->LEVEL OF ANY NODE(stored in Level)
->COUNT OF NODES IN SUBTREE(stored in dp)
->*{subtract 1 if you want to know count of nodes below a specified node}*
vector<ll>adj[250005];
ll dp[250005];
ll Level[250005];
void dfs(ll node, ll level = 0, ll parent = -1)
{
ll cnt = 0;
Level[node] = level;
for(auto &it: adj[node])
{
if(it != parent)
{
dfs(it, level + 1, node);
cnt += dp[it];
}
}
dp[node] = 1 + cnt;
}
---------------------------------------------------------------------------------------------------------------------------------------------------
*/
class DSU{
public:
map<int,int>children;
std::vector<int>rk,par;
int N;
DSU(int n)
{
for(int i= 0; i <= n; i++){
par.push_back(i);
rk.push_back(0);
}
N = n;
}
//Return the parent of node x
int get(int x)
{
return x == par[x] ? x : par[x] = get(par[x]);
}
//Checks if they both have same parent or not
bool same_set(int x, int y){
return (get(x) == get(y));
}
void Union(int x, int y)
{
x = get(x), y = get(y);
if(rk[x] > rk[y])
{
par[y] = x;
}
else if(rk[x] < rk[y])
{
par[x] = y;
}
else
{
par[x] = y;
rk[y]++;
}
}
//Setting the number of children parent has;
void setChildren()
{
for(int i = 1; i <= N; i++)
{
children[get(i)]++;
}
}
//Returns the total number of nodes parent of x is connected to
//Parent is also included in count
int get_size(int x){
return children[get(x)];
}
};
vector<int>adj[700000];
int main()
{
Fast;
ll t;
cin >> t;
while(t--)
{
ll n;
cin >> n;
ll arr[n];
for(ll i = 0; i < n; i++)
{
cin >> arr[i];
}
cout << 6 * (n / 2) << "\n";
for(ll i = 0; i < n; i++)
{
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";
i++;
}
}
return 0;
} | 8 | CPP |
for _ in range(int(input())):
n = int(input())
arr = list(map(int,input().split()))
print(n//2 * 6)
for i in range(1,n+1,2):
for j in range(6):
tmp = str(j%2 + 1)+" "+str(i)+" "+str(i+1)
print(tmp)
| 8 | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.