Language: C++

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Majk
 */

#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first

typedef long long ll;

template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

#ifndef MOD_H
#define MOD_H
template <unsigned int N> class Field {
    typedef unsigned int ui;
public:
	inline Field<N>&operator+=(const Field<N>&o) {if ((ll)v+o.v >= N) v = (ll)v+o.v-N; else v = v+o.v; return *this; }

	inline Field<N> operator+(const Field<N>&o) {Field<N>r(*this);return r+=o;};

private: ui v;
};

template<unsigned int N>ostream &operator<<(std::ostream&os,const Field<N>&f){return os<<(unsigned int)f;}


typedef Field<1000000007> FieldMod;
#endif

class B {
public:
	void solve(istream& cin, ostream& cout) {
		ll N; cin >> N;

		FieldMod X[2] = {1,0};
		FieldMod Ans=1;
		for (int i = 60; i >= 0; --i) {
			ll x = N >> i;
			if (x <= 0) continue;
			Ans = Ans*3 - X[0]*(2-x%2);
			X[x%2] = X[0] + X[1];
		}
		cout << Ans << endl;
	}
};


int main() {
	ios_base::sync_with_stdio(false);
	B solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Compiler output:
a.cc: In member function 'void B::solve(std::istream&, std::ostream&)':
a.cc:50:34: error: could not convert '1' from 'int' to 'FieldMod' {aka 'Field<1000000007>'}
   50 |                 FieldMod X[2] = {1,0};
      |                                  ^
      |                                  |
      |                                  int
a.cc:50:36: error: could not convert '0' from 'int' to 'FieldMod' {aka 'Field<1000000007>'}
   50 |                 FieldMod X[2] = {1,0};
      |                                    ^
      |                                    |
      |                                    int
a.cc:51:30: error: conversion from 'int' to non-scalar type 'FieldMod' {aka 'Field<1000000007>'} requested
   51 |                 FieldMod Ans=1;
      |                              ^
a.cc:55:34: error: no match for 'operator*' (operand types are 'FieldMod' {aka 'Field<1000000007>'} and 'int')
   55 |                         Ans = Ans*3 - X[0]*(2-x%2);
      |                               ~~~^~
      |                               |   |
      |                               |   int
      |                               FieldMod {aka Field<1000000007>}
a.cc:55:43: error: no match for 'operator*' (operand types are 'FieldMod' {aka 'Field<1000000007>'} and 'll' {aka 'long long int'})
   55 |                         Ans = Ans*3 - X[0]*(2-x%2);
      |                                       ~~~~^~~~~~~~
      |                                          |   |
      |                                          |   ll {aka long long int}
      |                                          FieldMod {aka Field<1000000007>}
a.cc: In instantiation of 'std::ostream& operator<<(std::ostream&, const Field<N>&) [with unsigned int N = 1000000007; std::ostream = std::basic_ostream<char>]':
a.cc:58:11:   required from here
   58 |                 cout << Ans << endl;
      |                         ^~~
a.cc:39:90: error: invalid cast from type 'const Field<1000000007>' to type 'unsigned int'
   39 | template<unsigned int N>ostream &operator<<(std::ostream&os,const Field<N>&f){return os<<(unsigned int)f;}
      |                                                                                          ^~~~~~~~~~~~~~~