criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

// x未満となる最初
int find_index(const vector<ll> &a, int x) {
    if (a.front() < x) return 0;
    int l = 0, r = a.size();
    do {
        int cur = (l + r) / 2;
        if (a[cur] >= x) l = cur;
        else r = cur;
    } while(r - l > 1);
    return r;
}

int main() {
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    vector<ll> sum(n);
    sum[0] = a[0];
    for (int i = 1; i < n; ++i) {
        sum[i] = a[i] + sum[i - 1];
    }
    int l = 0, r = 200000;
    do {
        ll p = (l + r) / 2;
        ll s = 0, t = 0;
        for (int i = 0; i < n; ++i) {
            ll j = find_index(a, p - a[i]);
            s += j;
            t += j * a[i];
            if (j > 0) t += sum[j - 1];
        }

        if (r - l == 1) {
            cout << (t - p * (s - m)) << endl;
            return 0;
        }

        if (s >= m) l = p
        else r = p
    } while(true);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:26: error: expected ';' before 'else'
   62 |         if (s >= m) l = p
      |                          ^
      |                          ;
   63 |         else r = p
      |         ~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100005];
ll p[100005];
int n;
ll m;
bool check(int x){
    ll numtaken = 0;
    for (int i = 0; i < n; i++){
        int k = a+n-lower_bound(a,a+n,mid-a[i]);
        numtaken += k;
    }
    return numtaken >= m;
}
int main(){
    scanf("%d%lld",&n,&m);
    p[0] = 0;
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for (int i = 0; i < n; i++){
        p[i+1] = p[i] + a[i];
    }
    int lo = 0, hi = 2e5+1;
    ll ans = 0;
    while (lo + 1 < hi){
        int mid = (lo+hi)/2;
        if (check(mid)){
            lo = mid;
        }
        else hi = mid;
    }
    if (lo+1 == hi){
        if (check(hi)){
            lo = hi;
        }
        else hi = lo;
    }
    ll numtaken = 0;
    ll sum = 0;
    for (int i = 0; i < n; i++){
        int k = a+n-lower_bound(a,a+n,lo-a[i]);
        numtaken += k;
        sum += p[n]-p[n-k]+(ll)k*a[i];
    }
    ans = sum-(numtaken-m)*lo;
    printf("%lld",ans);
}


Compiler output:
a.cc: In function 'bool check(int)':
a.cc:11:39: error: 'mid' was not declared in this scope
   11 |         int k = a+n-lower_bound(a,a+n,mid-a[i]);
      |                                       ^~~
Language: C++

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}



int main(){
  
  long long n;
  long long m;
  cin>>n>>m;
  vector<long long> a(n);
  REP(i,n){
    cin>>a[i];
  }
  sort(ALL(a), greater<long long>);
  long long temp = 2*m/(2*n-1);
  long long ans = 0;
  REP(i,temp){
    ans += (2*n-1)*a[i];
  }
  ans += a[temp] * (2*m)%(2*n-1);
  cout<<ans<<endl;
    
  return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:76:34: error: expected primary-expression before ')' token
   76 |   sort(ALL(a), greater<long long>);
      |                                  ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

long long bin_search(long long l, long long r, long long x, vector<long long> &A){
    long long mid=(l+r)/2;
    if(mid==l){
        return mid;
    }

    if(A[mid]>=x){
        return bin_search(mid, r, x, A);
    }else{
        return bin_search(l, mid, x, A);
    }

}

long long N, M;
long long bin_search2(long long l, long long r, vector<long long> &A){
    long long mid=(l+r)/2;
    if(mid==l){
        return mid;
    }

    long long cnt =0;
    for(int i=0; i<N; i++){
        cnt+=bin_search(0, N, mid-A[i], &A);
    }

    if(cnt>=M){
        return bin_search2(mid, r, A);
    }else{
        return bin_search2(l, mid, A);
    }
}

int main(){
    cin >> N >> M;
    vector<long long> A(N,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    cout_vec(A);

    long long x = bin_search2(0,MOD, A);
    long long ans=0;
    for(int i=0; i<N; i++){
        ans+=A[i]*bin_search(0,MOD,x,A);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'long long int bin_search2(long long int, long long int, std::vector<long long int>&)':
a.cc:51:41: error: invalid initialization of non-const reference of type 'std::vector<long long int>&' from an rvalue of type 'std::vector<long long int>*'
   51 |         cnt+=bin_search(0, N, mid-A[i], &A);
      |                                         ^~
a.cc:28:80: note: in passing argument 4 of 'long long int bin_search(long long int, long long int, long long int, std::vector<long long int>&)'
   28 | long long bin_search(long long l, long long r, long long x, vector<long long> &A){
      |                                                             ~~~~~~~~~~~~~~~~~~~^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

long long bin_search(int l, int r, int x, vector<int> &A){
    int mid=(l+r)/2;
    if(mid==l){
        return mid;
    }

    if(A[mid]>=x){
        return bin_search(mid, r, x, A);
    }else{
        return bin_search(l, mid, x, A);
    }

}

long long N, M;
long long bin_search2(int l, int r, vector<int> &A){
    int mid=(l+r)/2;
    if(mid==l){
        return mid;
    }

    long long cnt =0;
    for(int i=0; i<N; i++){
        cnt+=bin_search(0, N, mid-A[i], vector<int> &A);
    }

    if(cnt>=M){
        return bin_search2(mid, r, A);
    }else{
        return bin_search2(l, mid, A);
    }
}

int main(){
    cin >> N >> M;
    vector<long long> A(N,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    cout_vec(A);

    long long x = bin_search2(0,MOD, A);
    long long ans=0;
    for(int i=0; i<N; i++){
        ans+=A[i]*bin_search(0,MOD,x,A);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'long long int bin_search2(int, int, std::vector<int>&)':
a.cc:51:53: error: expected primary-expression before '&' token
   51 |         cnt+=bin_search(0, N, mid-A[i], vector<int> &A);
      |                                                     ^
a.cc: In function 'int main()':
a.cc:70:38: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
   70 |     long long x = bin_search2(0,MOD, A);
      |                                      ^
a.cc:43:50: note: in passing argument 3 of 'long long int bin_search2(int, int, std::vector<int>&)'
   43 | long long bin_search2(int l, int r, vector<int> &A){
      |                                     ~~~~~~~~~~~~~^
a.cc:73:38: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
   73 |         ans+=A[i]*bin_search(0,MOD,x,A);
      |                                      ^
a.cc:28:56: note: in passing argument 4 of 'long long int bin_search(int, int, int, std::vector<int>&)'
   28 | long long bin_search(int l, int r, int x, vector<int> &A){
      |                                           ~~~~~~~~~~~~~^
Language: C++

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}



int main(){
  
  long long n;
  long long m;
  cin>>n>>m;
  vector<long long> a(n);
  REP(i,n){
    cin>>a[i];
  }
  sort(ALL(a), greater<int>);
  long long temp = 2*m/(2*n-1);
  long long ans = 0;
  REP(i,temp){
    ans += (2*n-1)*a[i];
  }
  cout<<ans<<endl;
    
  return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:76:28: error: expected primary-expression before ')' token
   76 |   sort(ALL(a), greater<int>);
      |                            ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

long long bin_search(int l, int r, int x, vector<int> &A){
    int mid=(l+r)/2;
    if(mid==l){
        return mid;
    }

    if(A[mid]>=x){
        return bin_search(mid, r, x, A);
    }else{
        return bin_search(l, mid, x, A);
    }

}

long long N, M;
long long bin_search2(int l, int r, vector<int> &A){
    int mid=(l+r)/2;
    if(mid==l){
        return mid;
    }

    long long cnt =0;
    for(int i=0; i<N; i++){
        cnt+=bin_search(0, N, mid-A[i], vector<int> &A);
    }

    if(cnt>=M/2){
        return bin_search2(mid, r, A);
    }else{
        return bin_search2(l, mid, A);
    }
}

int main(){
    cin >> N >> M;
    vector<long long> A(N,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    cout_vec(A);

    long long x = bin_search2(0,MOD, A);
    long long ans=0;
    for(int i=0; i<N; i++){
        ans+=2*A[i]*bin_search(0,MOD,x,A);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'long long int bin_search2(int, int, std::vector<int>&)':
a.cc:51:53: error: expected primary-expression before '&' token
   51 |         cnt+=bin_search(0, N, mid-A[i], vector<int> &A);
      |                                                     ^
a.cc: In function 'int main()':
a.cc:70:38: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
   70 |     long long x = bin_search2(0,MOD, A);
      |                                      ^
a.cc:43:50: note: in passing argument 3 of 'long long int bin_search2(int, int, std::vector<int>&)'
   43 | long long bin_search2(int l, int r, vector<int> &A){
      |                                     ~~~~~~~~~~~~~^
a.cc:73:40: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'std::vector<long long int>'
   73 |         ans+=2*A[i]*bin_search(0,MOD,x,A);
      |                                        ^
a.cc:28:56: note: in passing argument 4 of 'long long int bin_search(int, int, int, std::vector<int>&)'
   28 | long long bin_search(int l, int r, int x, vector<int> &A){
      |                                           ~~~~~~~~~~~~~^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,m;
    cin >> n >> m;
    long long y=n*n;
    long long a[n],b[y];
    for(long long i=0;i<n;i++){
        cin >> a[i]
    }
    for(long long i=0;i<n;i++){
        for(long long j=0;j<n;j++){
            b[(i*n)+j]=a[i]+a[j];
        }
    }
    long long k;
    for(int i=0;i<y;i++){
        for(int j=0;j<y;j++){
            if(b[i]>b[j]){
                k=b[i];
                b[i]=b[j];
                b[j]=k;
            }
        }
    }
    long long z=0;
    for(long long i=m-1;i>-1;i--){
        z=z+b[i];
    }
    cout << z;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:20: error: expected ';' before '}' token
    9 |         cin >> a[i]
      |                    ^
      |                    ;
   10 |     }
      |     ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main() {
    int N, M; cin >> N >> M;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    vector<ll> B(N+1,0); REP(i,N) B[i+1]=B[i]+A[i];
    sort(all(A),greater<ll>());
    ll ans = 0;
    REP(i,N) {
        ll tmo = B[i+1]*(i+1);
        vector<ll> v;
        REP(j,i+1)FOR(l,i+1,N){
            v.push_back(A[j]+A[l]);
            v.push_back(A[j]+A[l]);
        }
        sort(all(v),greater<ll>);
        REP(j,M-(i+1)*(i+1)) tmp+=v[j];
        ans = max(ans,tmp); 
    }
    cout << ans << endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:22:32: error: expected primary-expression before ')' token
   22 |         sort(all(v),greater<ll>);
      |                                ^
a.cc:23:30: error: 'tmp' was not declared in this scope; did you mean 'tmo'?
   23 |         REP(j,M-(i+1)*(i+1)) tmp+=v[j];
      |                              ^~~
      |                              tmo
a.cc:24:23: error: 'tmp' was not declared in this scope; did you mean 'tmo'?
   24 |         ans = max(ans,tmp);
      |                       ^~~
      |                       tmo
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll(i)=0;i<(n);i++)

int main(){
  ll n,m,ans=0;cin>>n>>m;
  vector<ll> a(n,0),b(n*n,0);
  REP(i,n) cin>>x.at(i);
  REP(i,n) REP(j,n){
    b.at(i*n+j) = a.at(i)+a.at(j);
  }
  sort(b.begin(),b.end(),greater<int>());
  REP(i,m) ans+=b.at(i);
  
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:17: error: 'x' was not declared in this scope
    9 |   REP(i,n) cin>>x.at(i);
      |                 ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 


int main()
{ 
    int n;
    cin>>n;
    LL m;
    cin>>m;
    LL a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    LL s[n];
    for(int i=0;i<n;i++){
        if(i==0){s[0]=a[0];}
        else{s[i]=s[i-1]+a[i];}
    }
    
    LL min=2;
    LL max=10000000001;
    LL x[n];//0以上の人と握手する。
    LL p=0;//回数
    while(max-min>1){
        LL k=(max+min)/2;
        LL cnt=0;
        for(int i=0;i<n;i++){
            int Min=0;
            int Max=n-1;
            if(a[n-1]<k-a[i]){x[i]=n;}
            else if(a[0]>=k-a[i]){cnt=cnt+n;x[i]=0;}
            else{
                while(Max-Min>1){
                    int K=(Max+Min)/2;
                    if(a[K]>=k-a[i]){Max=K;}
                    else{Min=K;}
                }
                cnt=cnt+n-Min-1;
                x[i]=Min+1;
            }
        }
        if(cnt<m){max=k;}
        else{min=k;}
    }
    LL s[n];
    for(int i=0;i<n;i++){
        if(i==0){s[0]=a[0];}
        else{s[i]=s[i-1]+a[i];}
    }
    /*for(int i=0;i<n;i++){
        cout<<i<<' '<<a[i]<<' '<<s[i]<<' '<<x[i]<<endl;
    }*/
    for(int i=0;i<n;i++){p=p+n-x[i];}
    LL ans=0;
    for(int i=0;i<n;i++){
        if(x[i]>0){ans=ans+a[i]*(n-x[i])+s[n-1]-s[x[i]-1];}
        else{ans=ans+a[i]*n+s[n-1];}
    }
    ans=ans+min*(m-p);
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:8: error: redeclaration of 'LL s [n]'
   55 |     LL s[n];
      |        ^
a.cc:24:8: note: 'LL s [n]' previously declared here
   24 |     LL s[n];
      |        ^
Language: C++

#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>
#include<atcoder/all>



using namespace std;
using namespace atcoder;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };


using mint = modint1000000007;

struct node {
	int id;
	unordered_set<int> link;
	unordered_map<int, int> dp;
};
ll N;
vector<node> nod;

ll f(int ind, int par) {
	ll sum = 1;
	for (int c : nod[ind].link) {
		if (c == par)continue;
		nod[ind].dp[c] = f(c, ind);
		sum += nod[ind].dp[c];
	}
	if (par != -1) {
		nod[ind].dp[par] = N - sum;
	}
	return sum;
}

int main() {
	cin >> N;
	nod.resize(N);
	REP(i, 0, N)nod[i].id = i;
	REP(i, 0, N - 1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		nod[a].link.insert(b);
		nod[b].link.insert(a);
	}
	f(0, -1);
	mint sum = 0;
	REP(i, 0, N) {
		mint tmp = mint{ 2 }.pow(N - 1) - 1;
		for (int c : nod[i].link) {
			tmp -= (mint{ 2 }.pow(nod[i].dp[c]) - 1);
		}
		sum += tmp;
	}
	mint ans = sum * mint{ 2 }.pow(N).inv();
	PRI(ans.val());
	return 0;
}


Compiler output:
a.cc:20:9: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   20 | #include<boost/multiprecision/cpp_int.hpp>
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>
#include<atcoder/modint.hpp>



using namespace std;
using namespace atcoder;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };


using mint = modint1000000007;

struct node {
	int id;
	unordered_set<int> link;
	unordered_map<int, int> dp;
};
ll N;
vector<node> nod;

ll f(int ind, int par) {
	ll sum = 1;
	for (int c : nod[ind].link) {
		if (c == par)continue;
		nod[ind].dp[c] = f(c, ind);
		sum += nod[ind].dp[c];
	}
	if (par != -1) {
		nod[ind].dp[par] = N - sum;
	}
	return sum;
}

int main() {
	cin >> N;
	nod.resize(N);
	REP(i, 0, N)nod[i].id = i;
	REP(i, 0, N - 1) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		nod[a].link.insert(b);
		nod[b].link.insert(a);
	}
	f(0, -1);
	mint sum = 0;
	REP(i, 0, N) {
		mint tmp = mint{ 2 }.pow(N - 1) - 1;
		for (int c : nod[i].link) {
			tmp -= (mint{ 2 }.pow(nod[i].dp[c]) - 1);
		}
		sum += tmp;
	}
	mint ans = sum * mint{ 2 }.pow(N).inv();
	PRI(ans.val());
	return 0;
}


Compiler output:
a.cc:20:9: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   20 | #include<boost/multiprecision/cpp_int.hpp>
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl







using ll = long long;
const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;


ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}

int n;
vector<int> g[maxn];

int par[maxn];
int siz[maxn];
vector<int> subtrees[maxn];

void dfs(int at, int p=0) {
    siz[at]=1;
    for (int to: g[at]) {
	if (to == p) continue;
	dfs(to, at);
	par[to] = at;
	siz[at] += siz[to];
    }
}


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

    cin>>n;
    for (int i=0; i<n-1; i++) {
	int u,v; cin>>u>>v;
	g[u].push_back(v);
	g[v].push_back(u);
    }

    dfs(1);

    
    for (int at=1; at<=n; at++) {
	ll tot = 0;
	for (to: g[at]) {
	    if (to==par[at]) continue;
	    tot += siz[to];
	    subtrees[at].push_back(siz[to]);
	}
	ll up = n-1-tot;
	if (up>0) subtrees[at].push_back(up);
    }


    ll res = 0;
    for (int i=1; i<=n; i++) {
	ll all = pw(2,n-1);
	all --;
	for (ll x: subtrees[i]) {
	    all -= (pw(2,x)-1);
	    all %= mod;
	}
	res += all;
	res %= mod;
    }

    res %= mod;
    res += mod;
    res %= mod;

    ll ans = res*pw(pw(2,n),mod-2)%mod;
    cout<<ans<<endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:61:16: error: found ':' in nested-name-specifier, expected '::'
   61 |         for (to: g[at]) {
      |                ^
      |                ::
a.cc:61:14: error: 'to' has not been declared
   61 |         for (to: g[at]) {
      |              ^~
a.cc:67:9: error: expected primary-expression before 'if'
   67 |         if (up>0) subtrees[at].push_back(up);
      |         ^~
a.cc:66:25: error: expected ')' before 'if'
   66 |         ll up = n-1-tot;
      |                         ^
      |                         )
   67 |         if (up>0) subtrees[at].push_back(up);
      |         ~~               
a.cc:61:13: note: to match this '('
   61 |         for (to: g[at]) {
      |             ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#include "../Algo/NumberTheory/modulo.h"

ModuloOps MOD(1e9+7);

vector<long long> pw2;
vector<long long> invPw2;

long long calc(vector<int> &a) {
    auto all = 1ll;
    for (auto sz: a) {
        all = MOD.mul(all, invPw2[sz]);
    }
    auto bad = all;
    for (auto sz: a) {
        MOD.inc(bad, MOD.mul(MOD.mul(all, pw2[sz]), MOD.sub(1, invPw2[sz])));
    }
    auto res = MOD.div(MOD.sub(1, bad), 2);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    //n = 2e5;
    cin >> n;
    pw2.assign(n+1, 1ll);
    for (int i = 1; i <= n; i++) {
        pw2[i] = MOD.mul(pw2[i-1], 2);
    }
    invPw2.assign(n+1, 1ll);
    for (int i = 1; i <= n; i++) {
        invPw2[i] = MOD.div(1, pw2[i]);
    }
    vector<vector<int>> g(n);
    for (int i = 0; i < n-1; i++) {
        int u, v;
        cin >> u >> v;
        //v = i+1; u = i+2;
        u--; v--;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    long long ans = 0;
    function<int(int, int)> enter;
    enter = [&] (int v, int p) {
        vector<int> a;
        a.reserve(g[v].size());
        int tot = 1;
        for (int u: g[v]) {
            if (u != p) {
                int sz = enter(u, v);
                a.push_back(sz);
                tot += sz;
            }
        }
        if (p != -1) {
            a.push_back(n-tot);
        }
        MOD.inc(ans, calc(a));
        return tot;
    };
    enter(0, -1);
    cout << ans << endl;
}



Compiler output:
a.cc:5:10: fatal error: ../Algo/NumberTheory/modulo.h: No such file or directory
    5 | #include "../Algo/NumberTheory/modulo.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

constexpr int MOD = 1e9 + 7; // 1e9 + 7

#include "Modint.h"

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<vector<int>> G(N);
  F0R(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  // 頂点ごとに、白として含まれるのは何通りであるか数える

  // ・頂点は白
  // ・内部になる（黒にはさまれる）
  //   = 全 - 内部にならない（余事象）

  // 内部になる = 頂点からのびている部分木のうち2つ以上に黒が含まれる
  // 内部にならない = 高々1方向にしか黒が含まれない

  // 全 - 内部にならない
  // 全：2^(N-1) 頂点は白なので、自由にできる頂点はN-1
  // 内部にならない：
  // ・全部白
  //   1
  // ・ちょうど1個の部分木のみに黒がある
  //   個Ciの部分木のサイズをTCiと置く
  //   
  //   Σ(2^(TCi)-1)
  //   i
  //   2^(TCi) ... 部分木それぞれの頂点が白か黒か
  //   -1      ... 黒は一つ必要なので、全部白のパターンを引く

  vector<mint<MOD>> two(N+1);
  two[0] = 1;
  F0R(i, N) {
    two[i + 1] = two[i] * 2;
  }

  vector<int> vs(N);

  mint<MOD> result = (two[N - 1] - 1) * N;

  auto dfs = [&](auto dfs, int v, int p)->int {
    int r = 1;
    for (auto c : G[v]) {
      if (c == p) continue;

      int cv = dfs(dfs, c, v);
      result -= two[cv] - 1;
      r += cv;
    }

    // 親側の部分木
    int pv = N - r;
    result -= two[pv] - 1;
    return r;
  };
  dfs(dfs, 0, -1);

  result /= two[N];
  cout << result;
}
#endif


Compiler output:
a.cc:42:10: fatal error: Modint.h: No such file or directory
   42 | #include "Modint.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
constexpr int N = 200'225, P = 1000'000'007;
vector<int> g[N];
int sz[N], p2[N],  n, ans, inv2 = (P + 1) / 2;
int dfs(int u, int p) {
  sz[u] = 1;
  for (int v : g[u])
    if (v != p)
      sz[u] += dfs(v, u);
  if (p != 0)
    ans = (ans + (int64_t) (1 + P - p2[sz[u]]) * (1 + P - p2[n - sz[u]]) % P) % P;
  return sz[u];
}
int main() {
  p2[0] = 1;
  for (int i = 1; i < N; ++i)
    p2[i] = (int64_t) p2[i - 1] * inv2 % P;
  cin >> n;
  ans = (P - (int64_t)n * inv2 % P) % P;
  for (int i = 1, v, u; i < n; ++i) {
    in >> v >> u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs(1, 0);
  cout << (int64_t)(ans + (int64_t)(1 + P - p2[n]) % P) % P << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'in' was not declared in this scope; did you mean 'i'?
   22 |     in >> v >> u;
      |     ^~
      |     i
Language: C++

#include <bits/stdc++.h>
using namespace std;
constexpr int N = 200'225, P = 1000'000'007;
vector<int> g[N];
int sz[N], p2[N],  n, ans, inv2 = (P + 1) / 2;
int dfs(int u, int p) {
  sz[u] = 1;
  for (int v : g[u])
    if (v != p)
      sz[u] += dfs(v, u);
  if (p != 0)
    ans = (ans + (int64_t) (1 + P - p2[sz[u]]) * (1 + P - p2[n - sz[u]]) % P) % P;
  return sz[u];
}
int main() {
  p2[0] = 1;
  for (int i = 1; i < N; ++i)
    p2[i] = (int64_t) p2[i - 1] * inv2 % P;
  in >> n;
  ans = (P - (int64_t)n * inv2 % P) % P;
  for (int i = 1, v, u; i < n; ++i) {
    in >> v >> u;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs(1, 0);
  cout << (int64_t)(ans + (int64_t)(1 + P - p2[n]) % P) % P << '\n';
}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: 'in' was not declared in this scope; did you mean 'yn'?
   19 |   in >> n;
      |   ^~
      |   yn
Language: C++

#include <bits/stdc++.h>
#include "../lib/math/comb.hpp"

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int n;
vll po2;
ll ans = 0;

int dfs(int now, int prev, const vvi &tr) {
  vi sizes;
  ll su = 0;
  for(int i=0;i<SZ(tr[now]);++i) {
    int nxt = tr[now][i];
    if(nxt == prev) continue;
    sizes.push_back(dfs(nxt, now, tr));
    su += sizes.back();
  }
  if(n > su + 1) sizes.push_back(n - su - 1);
  //cout << now << ":";
  //printv(sizes);
  //cout << endl;
  ll tmp = po2[n-1];
  for(int i=0;i<SZ(sizes);++i) {
    tmp += po2[sizes[i]];
    tmp %= MOD;
  }
  tmp += MOD - (SZ(sizes) - 1);
  tmp %= MOD;
  ans += po2[n] + MOD - tmp;
  ans %= MOD;
  //cout << now << ":" << po2[n] - tmp + n - 2 << endl;
  return su + 1;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> n;
  vvi tr(n);
  
  for(int i=0;i<n-1;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    tr[a].push_back(b);
    tr[b].push_back(a);
  }

  Combination<MOD> comb(500000);

  po2.resize(500000);
  po2[0] = 1;
  for(int i=1;i<500000;++i) {
    po2[i] = po2[i-1] * 2 % MOD;
  }

  ll inv = comb.getinv(2);
  ll invpow = 1;
  for(int i=0;i<n;++i) {
    invpow *= inv;
    invpow %= MOD;
  }

  dfs(0, -1, tr);
  cout << ans * invpow % MOD << endl;

}


Compiler output:
a.cc:2:10: fatal error: ../lib/math/comb.hpp: No such file or directory
    2 | #include "../lib/math/comb.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include "../lib/math/comb.hpp"

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int n;
vll po2;
ll ans = 0;

int dfs(int now, int prev, const vvi &tr) {
  vi sizes;
  ll su = 0;
  for(int i=0;i<SZ(tr[now]);++i) {
    int nxt = tr[now][i];
    if(nxt == prev) continue;
    sizes.push_back(dfs(nxt, now, tr));
    su += sizes.back();
  }
  if(n > su + 1) sizes.push_back(n - su - 1);
  //cout << now << ":";
  //printv(sizes);
  //cout << endl;
  ll tmp = po2[n-1];
  for(int i=0;i<SZ(sizes);++i) {
    tmp += po2[sizes[i]];
    tmp %= MOD;
  }
  tmp += MOD - SZ(sizes) + 1;
  tmp %= MOD;
  ans += po2[n] - tmp;
  ans %= MOD;
  //cout << now << ":" << po2[n] - tmp + n - 2 << endl;
  return su + 1;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> n;
  vvi tr(n);
  
  for(int i=0;i<n-1;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    tr[a].push_back(b);
    tr[b].push_back(a);
  }

  Combination<MOD> comb(300000);

  po2.resize(300000);
  po2[0] = 1;
  for(int i=1;i<300000;++i) {
    po2[i] = po2[i-1] * 2 % MOD;
  }

  ll inv = comb.getinv(2);
  ll invpow = 1;
  for(int i=0;i<n;++i) {
    invpow *= inv;
    invpow %= MOD;
  }

  dfs(0, -1, tr);
  cout << ans * invpow % MOD << endl;

}


Compiler output:
a.cc:2:10: fatal error: ../lib/math/comb.hpp: No such file or directory
    2 | #include "../lib/math/comb.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
 
//足したり引いたりすると勝手にmodをとってくれる
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
 
//コンビネーションのライブラリ
struct combination {
    //factのなかに階乗を求めている
    //ifactのなかに階乗逆元を求めている
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int n;
vector<int> to[202020]; //隣接リスト

mint ans;

//v 今見てる頂点 p　親　
int dfs(int v, int p = -1){
    int res = 1;
    vector<int> ts //部分木サイズのリスト
    
    for (int u : to[v]){
        if (u == p) continue //親だったら無視する
        int t = dfs(u, v); //潜る
        res += t; //u以下の部分木のサイズを足す
        ts.push_back(t);
    }
    
    if (p != -1){
        ts.push_back(n-res); //親方向の部分木のサイズを求める
    }
    
    // mint(2).pow(n-1)　全事象
    
    mint now = mint(2).pow(n-1) - 1; //????
    
    for (int t : ts){
        //２の部分木サイズ-1
        now -= mint(2).pow(t)-1; //????
    }
    ans += now;
    return res; //その頂点v以下の部分木のサイズを返す
}

int main(){
    cin >> n;
    
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        
        a--, b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    
    dfs(0);
    ans /= mint(2).pow(n);
    cout << ans.x << endl;
}

Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:91:5: error: expected initializer before 'for'
   91 |     for (int u : to[v]){
      |     ^~~
a.cc:99:9: error: 'ts' was not declared in this scope; did you mean 'to'?
   99 |         ts.push_back(n-res); //親方向の部分木のサイズを求める
      |         ^~
      |         to
a.cc:106:18: error: 'ts' was not declared in this scope; did you mean 't'?
  106 |     for (int t : ts){
      |                  ^~
      |                  t
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
const int mod=1000000007;
int modpow(int a,int b){
	if(b==0)return 1;
	if(b==1)return a%mod;
	if(b%2)return modpow(a,b-1)*a%mod;
	int memo=modpow(a,b/2);
	return memo*memo%mod;
}
int n,a[200010],b[200010],cnt[200010],dp
vector<int>v[200010];
signed main(){
	cin>>n;
	rep(i,n-1){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
		cnt[a[i]]++,cnt[b[i]]++;
	}
	rep(i,n-1){
		if(cnt[a[i]]>=2&&cnt[b[i]]>=2){
			v[a[i]].pb(b[i]);
			v[b[i]].pb(a[i]);
		}
	}
	//v:次数1の頂点を除いた木
	//この大きさの総和 / (2^N) を求めたい
	
	return 0;
}


Compiler output:
a.cc:15:1: error: expected initializer before 'vector'
   15 | vector<int>v[200010];
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:25:25: error: 'v' was not declared in this scope
   25 |                         v[a[i]].pb(b[i]);
      |                         ^
Language: C++

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

std::vector<int> G[200'010];
long long cnt[200'010];//iを頂点とする部分木内の頂点の個数(i自身は含まない)
long long dp[200'010];//iが白かつ黒で作られる部分木に含まれない塗り方の数
void dfs(int v, int p){
  for(int nv:G[v]){
    if(nv == p)continue;
    dfs(nv, v);
    cnt[v] += 1 + cnt[nv];
    dp[v] += 
  }
  dp[]
}
int main(){
  using namespace std;
  int n;
  cin>>n;
  int a[n], b[n];
  REP(i,n){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:78:3: error: expected primary-expression before '}' token
   78 |   }
      |   ^
a.cc:79:6: error: expected primary-expression before ']' token
   79 |   dp[]
      |      ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll MOD = 1000000007; ll HALF = 500000004;
ll n;
ll ans = 0;
vector<ll> pows(200000);
vector<vector<ll> > adj(200000);

ll dfs(ll x, ll p, ll &ans) {
	ll cnt = 1LL;
	ll tmp = 1LL - pows[n-1] + MOD*2;
	for (auto v : adj[x])
	{
		if (v == p) continue;
		ll w = dfs(v, x);
		tmp -= pows[n-1-w] - pows[n-1] - MOD*2;
		cnt += w;
	}
	if (n > cnt) tmp -= pows[cnt-1] - pows[n-1] - MOD*2;
	tmp = (tmp * HALF) % MOD;
	ans = (ans + tmp) % MOD;

	return cnt;
}


int main() {
	cin >> n;
	pows[0] = 1;
	for (int i = 0; i < 199999; ++i) pows[i+1] = (pows[i] * HALF) % MOD;
	for (int i = 0; i < n-1; ++i)
	{
		ll a, b; cin >> a >> b;
		adj[a-1].push_back(b-1);
		adj[b-1].push_back(a-1);
	}

	dfs(0, -1, ans);

	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'll dfs(ll, ll, ll&)':
a.cc:17:27: error: too few arguments to function 'll dfs(ll, ll, ll&)'
   17 |                 ll w = dfs(v, x);
      |                        ~~~^~~~~~
a.cc:11:4: note: declared here
   11 | ll dfs(ll x, ll p, ll &ans) {
      |    ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define Mod 1000000007
#define int long long
#define LL long long
#define MN 400005
int ksm(int a,int x){
 	LL ans=1,w=a;
   	while(x){
   		if(x&1)ans=ans*w%Mod;
   		w=w*w%Mod;
   		x>>=1;
   	}
   	return ans;
}
int n,bin[MN],fa[MN],siz[MN];
LL f[3];
vector<int>edge[MN];
void dfs(int x){
 	siz[x]=1;
   	for(int i=0;i<edge[x].size();++i)
   		if(fa[x]!=edge[x][i]){
   			fa[edge[x][i]]=x;
   			dfs(edge[x][i]);
   			siz[x]+=siz[edge[x][i]];
   		}
}
signed main(){
  	scanf("%d",&n);
   	bin[0]=1;
   	for(int i=1;i<=n;++i)bin[i]=(bin[i-1]<<1)%Mod;
   	for(int i=1;i<n;++i){
   		int x,y;
   		scanf("%d%d",&x,&y);
   		edge[x].push_back(y);
   		edge[y].push_back(x);
   	}
   	dfs(1);
   	LL ans=0,inv2=ksm(2,Mod-2);
   	for(int x=1;x<=n;++x){
   		f[0]=1;f[1]=f[2]=0;
   		for(int i=0;i<edge[x].size();++i){
   			int v=edge[x][i],tmp;
   			if(fa[x]==v) tmp=bin[n-siz[x]];
   			else tmp=bin[siz[v]];
   			LL P=ksm(tmp,Mod-2);
   		//	cerr<<x<<" "<<v<<": "<<P<<endl;
   			f[2]+=f[1]*(1ll-P+Mod)%Mod;
   			f[1]=((f[1]*(P))%Mod+f[0]*(1ll-P+Mod)%mod)%Mod;
   			f[0]=f[0]*(P)%Mod;
   		}
   		(ans+=f[2]*inv2%Mod)%=Mod;
   //		cerr<<x<<": "<<f[2]<<endl;
   	}
   	printf("%lld\n",ans%Mod);
   	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:63: error: 'mod' was not declared in this scope; did you mean 'Mod'?
   49 |                         f[1]=((f[1]*(P))%Mod+f[0]*(1ll-P+Mod)%mod)%Mod;
      |                                                               ^~~
      |                                                               Mod
Language: Java

import java.io.*;
import java.util.*;

public class Solution {

    public static int[] KR = new int[]{1, 0, -1, 0, 1, -1, 1, -1};
    public static int[] KC = new int[]{0, 1, 0, -1, 1, 1, -1, -1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        int n = in.nextInt();
        int[][] grid = new int[m][n];

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                grid[i][j] = in.nextInt();
            }
        }

        int max = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                int val = findRegion(grid, i, j);
                if (max < val) {
                    max = val;
                }
            }
        }

        System.out.println(max);
    }

    public static int findRegion(int[][] grid, int r, int c) {
        if (grid[r][c] == -1 || grid[r][c] == 0) {
            return 0;
        }

        grid[r][c] = -1;

        int sum = 0;
        for (int i = 0; i < KR.length; i++) {
            if (r + KR[i] >= 0 && r + KR[i] < grid.length &&
                    c + KC[i] >= 0 && c + KC[i] < grid[0].length) {
                sum += findRegion(grid, r + KR[i], c + KC[i]);
            }
        }

        return 1 + sum;

    }

}

Compiler output:
Main.java:4: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error
Language: Java

import java.io.*;
import java.util.*;

public class Solution {
  private static InputReader in;
  private static PrintWriter out;
  public static int N,M;
  public static int[][] grid;
  public static boolean[][] vis;

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out, true);
    N = in.nextInt();
    M = in.nextInt();
    grid = new int[N][M];
    for (int i = 0; i < N; i++) for (int j = 0; j < M; j++)
      grid[i][j] = in.nextInt();
    
    int max = 0;
    vis = new boolean[N][M];
    for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) {
      if (vis[i][j] || grid[i][j] == 0) continue;
      max = Math.max(max, dfs(i,j));
    }
    out.println(max);
    out.close();
    System.exit(0);
  }
  
  public static int dfs(int i, int j) {
    if (i < 0 || j < 0 || i >= N || j >= M || vis[i][j] || grid[i][j] == 0) return 0;
    int c = 1;
    vis[i][j] = true;
    c += dfs(i+1,j);
    c += dfs(i,j+1);
    c += dfs(i-1,j);
    c += dfs(i,j-1);
    c += dfs(i+1,j+1);
    c += dfs(i+1,j-1);
    c += dfs(i-1,j+1);
    c += dfs(i-1,j-1);
    return c;
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }
  }


}

Compiler output:
Main.java:4: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error
Language: C++

#include<iostream>
using namespace std;

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  
  long long ans=N+1;
  if(A%2 == B%2){
    ans = abs(A-B)/2;
    cout << ans << endl;
    
    return 0;
  }
  
  
  if((A-1)<=(N-B)){
    ans = A;
  	ans += abs(B-A-1)/2;
  
  	cout << ans << endl;
    return 0;
  }
  else{
    ans = N-B+1;
    ans += abs(B-A-1)/2;
    
    cout << ans << endl;
    return 0;
  }
  
  

Compiler output:
a.cc: In function 'int main()':
a.cc:30:4: error: expected '}' at end of input
   30 |   }
      |    ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<iostream>
using namespace std;

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  
  long long ans=N+1;
  if(A%2 == B%2){
    ans == abs(A-B)/2;
    cout << ans << endl;
  }
  
  long long C;
  if((A-1)>=(N-B)){
    C=B, B=A, A=C;
  }
  ans == A;
  ans += abs(B-A-1)/2;
  
  cout << ans << endl;
  
  retrun 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:3: error: 'retrun' was not declared in this scope
   23 |   retrun 0;
      |   ^~~~~~