Language: C++

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-8
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;
const double pi = acos(-1);

struct edge{
	int u,v,w;
	edge(){u=v=w=0;}
	edge(int _u, int _v, int _w){
		u = _u;
		v = _v;
		w = _w;
	}
};

int n,i,j,k,t;
int coba[60];

int get(int val, int base){
	int i=0, j=1;
	while(base*j <= val){
		i++;
		j*=base;
	}
	return i;
}

int main(){
	scanf("%d", &n);
	if(n <=60){
		printf("%d %d\n", 2,n);
		for(i=0;i<n;++i)
			printf("%d %d %d\n", 1, 2, i);
	}
	else{
		vector<edge> e;
		vector<pii> sisa;
		int tmp = get(n, 2), manode = tmp+1;
		int wew = pow(2, tmp-1);
		for(i=1;i<=tmp;++i){
			e.pb({i, i+1, 0});
			e.pb({i, i+1, wew});
			wew /= 2;
			coba[tmp-i] = i+1;
		}
		for(const pii &x : sisa){
			for(i=0;i<x.se;++i){
				e.pb({x.fi, now, i});
			}
		}
		if(n > pow(2, tmp)){
			int sum = 0;
			while(n){
				int x = n - pow(2, tmp);
				e.pb({1, coba[get(x, 2)], sum+=pow(2, tmp)});
				n = x;
				tmp = get(n, 2);
				if(!tmp)
					break;
			}
		}
		printf("%d %d\n", manode, (int) e.size());
		for(const edge &x : e){
			printf("%d %d %d\n", x.u, x.v, x.w);
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:45: error: 'now' was not declared in this scope; did you mean 'pow'?
   65 |                                 e.pb({x.fi, now, i});
      |                                             ^~~
      |                                             pow
a.cc:65:37: error: no matching function for call to 'std::vector<edge>::push_back(<brace-enclosed initializer list>)'
   65 |                                 e.pb({x.fi, now, i});
      |                                 ~~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = edge; _Alloc = std::allocator<edge>; value_type = edge]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<edge>::value_type&' {aka 'const edge&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = edge; _Alloc = std::allocator<edge>; value_type = edge]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<edge>::value_type&&' {aka 'edge&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~