Language: C++

include <bits/stdc++.h>                                                                                                                                                                        
                                                                                                                                                                                                
using namespace std;                                                                                                                                                                            
                                                                                                                                                                                                
typedef pair<int,int> pii;                                                                                                                                                                      
                                                                                                                                                                                                
main(){                                                                                                                                                                                         
  int L; cin >> L;                                                                                                                                                                              
  if(L==1){                                                                                                                                                                                     
    printf("%d %d\n",2,1);                                                                                                                                                                      
    printf("%d %d %d\n",1,2,0);                                                                                                                                                                 
    return 0;                                                                                                                                                                                   
  }                                                                                                                                                                                             
  int maxi = 0;                                                                                                                                                                                 
  vector<pair<int,pii> > arr;                                                                                                                                                                   
  int i = 1, a = 1;                                                                                                                                                                             
  int last = 2;                                                                                                                                                                                 
  while(a*2 <= L){                                                                                                                                                                              
    arr.push_back(pair<int,pii>(i,pii(i+1,0)));                                                                                                                                                 
    arr.push_back(pair<int,pii>(i,pii(i+1,a)));                                                                                                                                                 
    maxi = max(maxi,i+1); last = i +1;                                                                                                                                                          
    a*=2; i++;                                                                                                                                                                                  
  }                                                                                                                                                                                             
  if(L != (1<<(i-1))){                                                                                                                                                                          
    int before = 0;                                                                                                                                                                             
    i--;                                                                                                                                                                                        
    int t = i;                                                                                                                                                                                  
    while(i--){                                                                                                                                                                                 
      if(L & (1<<i)){                                                                                                                                                                           
        arr.push_back(pair<int,pii>((i+1),pii(last,before + (1<<t))));                                                                                                                          
        before += 1<<t; t--;                                                                                                                                                                    
      }                                                                                                                                                                                         
    }                                                                                                                                                                                           
  }                                                                                                                                                                                             
  printf("%d %d\n",maxi,(int)arr.size());                                                                                                                                                       
  for(i=0;i<arr.size();++i){                                                                                                                                                                    
    printf("%d %d %d\n",arr[i].first,arr[i].second.first,arr[i].second.second);                                                                                                                 
  }                                                                                                                                                                                             
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc:5:9: error: 'pair' does not name a type
    5 | typedef pair<int,int> pii;
      |         ^~~~
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:10: error: 'cin' was not declared in this scope
    8 |   int L; cin >> L;
      |          ^~~
a.cc:10:5: error: 'printf' was not declared in this scope
   10 |     printf("%d %d\n",2,1);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | include <bits/stdc++.h>
a.cc:15:3: error: 'vector' was not declared in this scope
   15 |   vector<pair<int,pii> > arr;
      |   ^~~~~~
a.cc:15:10: error: 'pair' was not declared in this scope
   15 |   vector<pair<int,pii> > arr;
      |          ^~~~
a.cc:15:15: error: expected primary-expression before 'int'
   15 |   vector<pair<int,pii> > arr;
      |               ^~~
a.cc:19:5: error: 'arr' was not declared in this scope
   19 |     arr.push_back(pair<int,pii>(i,pii(i+1,0)));
      |     ^~~
a.cc:19:24: error: expected primary-expression before 'int'
   19 |     arr.push_back(pair<int,pii>(i,pii(i+1,0)));
      |                        ^~~
a.cc:19:28: error: 'pii' was not declared in this scope
   19 |     arr.push_back(pair<int,pii>(i,pii(i+1,0)));
      |                            ^~~
a.cc:20:24: error: expected primary-expression before 'int'
   20 |     arr.push_back(pair<int,pii>(i,pii(i+1,a)));
      |                        ^~~
a.cc:21:12: error: 'max' was not declared in this scope; did you mean 'maxi'?
   21 |     maxi = max(maxi,i+1); last = i +1;
      |            ^~~
      |            maxi
a.cc:30:9: error: 'arr' was not declared in this scope
   30 |         arr.push_back(pair<int,pii>((i+1),pii(last,before + (1<<t))));
      |         ^~~
a.cc:30:28: error: expected primary-expression before 'int'
   30 |         arr.push_back(pair<int,pii>((i+1),pii(last,before + (1<<t))));
      |                            ^~~
a.cc:30:32: error: 'pii' was not declared in this scope
   30 |         arr.push_back(pair<int,pii>((i+1),pii(last,before + (1<<t))));
      |                                ^~~
a.cc:35:30: error: 'arr' was not declared in this scope
   35 |   printf("%d %d\n",maxi,(int)arr.size());
      |                              ^~~
a.cc:35:3: error: 'printf' was not declared in this scope
   35 |   printf("%d %d\n",maxi,(int)arr.size());
      |   ^~~~~~
a.cc:35:3: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'