criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int[n];
    for(int i=0;i<n;i++){
      a[i] = sc.nextInt(); 
    }
    System.out.println(maxProduct(a, n, k)%1000000007);
  }
  
  public static int maxProduct(int[] a, int n, int k){
   	Arrays.sort(a);
    int product = 1;
    if(a[n-1] == 0 && k%2 != 0){
      return 0; 
    }
    if(a[n-1] <= 0 && k%2 != 0){
      for(int i=n-1;i>=n;i--){
        product *= a[i]; 
      }
      return product;
    }
    int i = 0;
    int j = n-1;
    if(k%2 != 0){
      product *= a[j];
      j--;
      k--;
    }
    k >>= 1;
    for(int i=0;i<k;i++){
      int left = a[i]*a[i+1];
      int right = a[j]*a[j-1];
      if(left > right){
       	product *= left;
        i += 2;
      }else{
        product *= right;
        j -= 2;
      }
    }
    return product;
  }
}


Compiler output:
Main.java:34: error: variable i is already defined in method maxProduct(int[],int,int)
    for(int i=0;i<k;i++){
            ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  int N, K;
  cin >> N >> K;
  vector<ll>pl;
  vector<ll>mn;
  int ze;
  for (int i = 0; i < N; i ++) {
    ll a;
    cin >> a;
    if (a == 0) ze ++;
    if (a > 0) pl.pudh_back(a);
    if (a < 0) mn.push_back(-a);
  }
  if ((N - ze) < K) {
    cout << 0 << endl;
    return 0;
  }
  int f_pl, f_mn, s_pl, s_mn;
  s_pl = (int)pl.size();
  s_mn = (int)mn.size();
  sort(pl.begin(), pl.end());
  reverse(pl.begin(), pl.end());
  sort(mn.begin(), mn.end());
  reverse(mn.begin(), mn.end());
  f_mn = (s_mn / 2 * 2) - 1;
  f_pl = K - f_mn - 2;
  if (f_pl >= s/pl) {
    cout << 0 << endl;
    return 0;
  }
  while (f_pl + 2 < s_pl && f_mn - 1 >= 0 && 
         ((pl[f_pl + 1] * pl[f_pl + 2]) > (mn[f_mn] * mn[f_mn - 1]))) {
    f_pl += 2;
    f_mn -= 2;
  }
  ll ans = 1;
  ll m = 1e9 + 7;
  for (int i = 0; i <= f_pl; i ++) {
    ans *= pl[i];
    ans %= m;
  }
  for (int i = 0; i <= f_mn; i ++) {
    ans *= mn[i];
    ans %= m;
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: 'class std::vector<long long int>' has no member named 'pudh_back'; did you mean 'push_back'?
   14 |     if (a > 0) pl.pudh_back(a);
      |                   ^~~~~~~~~
      |                   push_back
a.cc:30:15: error: 's' was not declared in this scope
   30 |   if (f_pl >= s/pl) {
      |               ^
Language: C++

#include<bits/stdc++.h>
#define ll         long long
#define int 	   long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        1000000007
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll power(ll x, ll y){ll out = 1;while (y > 0){if (y & 1) out=(out*x)%mod;y = y>>1;x = (x*x)%mod;}return out%mod;}
ll inverse(ll a){return power(a,mod-2)%mod;}
ll answer(vector<ll>A,int k) 
{ 
	ll n = A.size();
    sort(all(A)); 
    ll product = 1; 
    if (A[n - 1] == 0 && (k & 1)) 
        return 0; 
    if (A[n - 1] <= 0 && (k & 1)) { 
        for (int i = n - 1; i >= n - k; i--) 
            product *= A[i];
            product = (product+mod)%mod; 
        return (product+mod)%mod; 
    } 
    int i = 0; 
    int j = n - 1; 
    if (k & 1) { 
        product *= A[j]; 
        product %= mod;
        product = (product+mod)%mod;
        j--; 
        k--; 
    } 
    k >>= 1; 
    for (int itr = 0; itr < k; itr++) { 
        int left_product = A[i] * A[i + 1]; 
        int right_product = A[j] * A[j - 1]; 
        if (left_product > right_product) { 
            product *= A[i];
            product%=mod;
            product = (product+mod)%mod;
            product *= A[i+1];
            product %= mod; 
            product = (product+mod)%mod;
            i += 2; 
        } 
        else { 
            product *= A[j];
            product%=mod;
            product = (product+mod)%mod;
            product *= A[j-1];
            product %= mod; 
            product = (product+mod)%mod;
            j -= 2; 
        } 
    } 
    product = (product+mod)%mod;
    return product; 
} 
void comp() {
	ll i,j,k,m,n;
	cin>>n>>k;
	vector<ll>v1;
	fl(i,n) {
		cin>>j;
		v1.pb(j);
	}
	ll ans=answer(v1,k);
	cout<<ans<<"\n";
}
int_32 main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

Compiler output:
a.cc:76:1: error: 'int_32' does not name a type
   76 | int_32 main() {
      | ^~~~~~
Language: C++

//#include<bits/stdc++.h>
#include<iostream>


#define ll          long long
#define uint        unsigned int 
#define ld          long double
#define SAM         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define mod         1000000007
#define mxn         200005
#define pb          push_back
#define pii         pair<int,int>
#define f           first
#define s           second
#define sz(x)       (int)x.size()
#define all(x)      x.begin(),x.end()

using namespace std;

int main()
{
    SAM;
    int n,k;
    cin>>n>>k;
    ll arr[n],p1=1,p2=1;
    FOR(i,0,n)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    
    for(int i=1;i<=k;i++)
    {
        p1=(p1*arr[n-i])%mod;
        p2=(p2*arr[i-1])%mod;
    }
    if(p1>=p2)
    {
        if(p1<0)
            cout<<mod-p1;
        else
            cout<<p1%mod;
    }
    else
    {
        if(p2<0)
            cout<<mod-p2;
        else
            cout<<p2%mod;
    }
    
    
    
    return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:32:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   32 |     sort(arr,arr+n);
      |     ^~~~
      |     short
Language: C++

#include <bits/stdc++.h>
#define t pow(10,9)+7
using namespace std;
void swap(long long int* a,long long int* b){
  long long int t = *a;  
  *a = *b;  
  *b = t;  
}
long int partition (long long int arr[],long int low,long int high)  
{  
    long int pivot = arr[high]; // pivot  
    long int i = (low - 1); // Index of smaller element  
  
    for (long int j = low; j <= high - 1; j++)  
    {  
        // If current element is smaller than the pivot  
        if (arr[j] < pivot)  
        {  
            i++; // increment index of smaller element  
            swap(&arr[i], &arr[j]);  
        }  
    }  
    swap(&arr[i + 1], &arr[high]);  
    return (i + 1);  
}  
void quickSort(long long int arr[],long int low,long int high)  
{  
    if (low < high)  
    {  
        /* pi is partitioning index, arr[p] is now  
        at right place */
        long int pi = partition(arr, low, high);  
  
        // Separately sort elements before  
        // partition and after partition  
        quickSort(arr, low, pi - 1);  
        quickSort(arr, pi + 1, high);  
    }  
} 
int main(){
  long int n,k;
  scanf("%ld %ld",&n,&k);
  for(long int i=0;i<n;i++){
  	scanf("%lld",&a[i]);
  }
  long long int arr[n];
  quickSort(arr, 0, n - 1);
  long long int f=1,b=1;
  for(long int i=0;i<k;i++){
  	f*=a[i];
    b*=a[n-1-i];
  }
  if(f>b){
    if(f>=0) cout<<f%t;
    else cout<<t-f;
  }
  else{
  	if(b>=0) cout<<b%t;
    else cout<<t-b;
  }
  return 0;
}

Compiler output:
a.cc: In function 'void swap(long long int*, long long int*)':
a.cc:2:19: error: expression list treated as compound expression in initializer [-fpermissive]
    2 | #define t pow(10,9)+7
      |                   ^
a.cc:5:17: note: in expansion of macro 't'
    5 |   long long int t = *a;
      |                 ^
a.cc:2:20: error: expected ',' or ';' before '+' token
    2 | #define t pow(10,9)+7
      |                    ^
a.cc:5:17: note: in expansion of macro 't'
    5 |   long long int t = *a;
      |                 ^
a.cc:2:14: error: 'pow' cannot be used as a function
    2 | #define t pow(10,9)+7
      |           ~~~^~~~~~
a.cc:7:8: note: in expansion of macro 't'
    7 |   *b = t;
      |        ^
a.cc: In function 'int main()':
a.cc:44:23: error: 'a' was not declared in this scope
   44 |         scanf("%lld",&a[i]);
      |                       ^
a.cc:50:12: error: 'a' was not declared in this scope
   50 |         f*=a[i];
      |            ^
a.cc:54:21: error: invalid operands of types 'long long int' and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%'
   54 |     if(f>=0) cout<<f%t;
      |                    ~^
      |                    |
      |                    long long int
a.cc:58:25: error: invalid operands of types 'long long int' and '__gnu_cxx::__promote<double>::__type' {aka 'double'} to binary 'operator%'
   58 |         if(b>=0) cout<<b%t;
      |                        ~^
      |                        |
      |                        long long int
Language: C++

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

typedef long long ll;
const ll mod=1e9+7;

ll n,k,zero;
ll a[200005];
vector<ll> pos,neg;

void find_pos(){
    sort(pos.begin(),pos.end(),[](const ll &a,const ll &b){
        return a>b;
    });
    sort(neg.begin(),neg.end(),[](const ll &a,const ll &b){
        return a<b;
    });
    ll res=1;
    ll pi=0,ni=0;
    while(pi+1<pos.size()&&ni+1<neg.size()&&pi+ni+2<=k){
        if(pos[pi]*pos[pi+1]>neg[ni]*neg[ni+1]){
            res=res*pos[pi]%mod*pos[pi+1]%mod;
            pi+=2;
        }else{
            res=res*neg[ni]%mod*neg[ni+1]%mod;
            ni+=2;
        }
    }
    while(pi+1<pos.size()&&pi+ni+2<=k){
        res=res*pos[pi]%mod*pos[pi+1]%mod;
        pi+=2;
    }
    while(ni+1<neg.size()&&pi+ni+2<=k){
        res=res*neg[ni]%mod*neg[ni+1]%mod;
        ni+=2;
    }
    if(pi+ni<k){
        res=res*pos[pi]%mod;
    }
    cout<<(res+mod)%mod<<endl;
}

void find_neg(){
    sort(a,a+n,[](const ll &a,const ll &b){
        return abs(a)<abs(b);
    });
    ll res=1;
    for(ll i=0;i<k;i++){
        res=res*a[i]%mod;
    }
    cout<<(res+mod)%mod<<endl;
}

ll main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>0)pos.emplace_back(a[i]);
        if(a[i]==0)zero++;
        if(a[i]<0)neg.emplace_back(a[i]);
    }
    if(neg.size()-(neg.size()&1)+pos.size()>=k&&(k&1)<=pos.size()){
        find_pos();
    }else if(zero){
        cout<<"0\n";
    }else find_neg();

    return 0;
}

Compiler output:
a.cc:54:1: error: '::main' must return 'int'
   54 | ll main(){
      | ^~
Language: C++

#include <iostream>

using namespace std;

#define MAXLEN 200009	// 可能爆内存，调试改小，提交时还原 
#define MOD 1000000007
#define mod109(x) ((x>=0) ? (x%MOD) : (0-((0-x)%MOD)))
#define inf 100000 	
#define int long long

typedef long long ll;

ll a[MAXLEN];
int n, k;  
// 在前i个数中选j个数相乘的最大结果 
ll dp[MAXLEN][MAXLEN];

signed main()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
	}
	
	// 因为可能涉及负值，直接初始化为负inf
	for(int i=0; i<=n; i++)
	{
		for(int j=0; j<=n; j++)
		{
			dp[i][j] = -inf;
		}
	}

	// 在1~i个数中，选1个数相乘最大，最大乘积就是选1~i中最大的数 
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=i; j++)
		{
			dp[i][1] = max(dp[i][1], a[j]);
		}
		
	}
	// 在前i个数中选i个，直接i个数乘起来 
	for(int i=1; i<=n; i++)
	{
		ll sum = 1;
		for(int j=1; j<=i; j++)
		{
			sum *= a[j];
		}
		dp[i][i] = sum;
	}

	// 因为第二行dp[2][2]已经确定，直接i=3开始
	for(int i=3; i<=n; i++)
	{
		for(int j=2; j<i; j++)
		{
			// 选择第i个数 
			ll res1 = dp[i-1][j-1] * a[i];
			
			// 不选第i个数 
			ll res2 = dp[i-1][j];
			
			dp[i][j] = max(res1, res2);
		}
	}
	int ans=mod109(dp[n][k])
	cout<<(ans+MOD)%MOD<<endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:9: error: expected ',' or ';' before 'cout'
   70 |         cout<<(ans+MOD)%MOD<<endl;
      |         ^~~~
Language: C++

#include <algorithm> 
#include <iostream> 
using namespace std; 

const long long int m=pow(10,9)+7;
int maxProductSubarrayOfSizeK(int A[], int n, int k) 
{ 
	sort(A, A + n); 

	int product = 1; 

	if (A[n - 1] == 0 && (k & 1)) 
		return 0; 

	if (A[n - 1] <= 0 && (k & 1)) { 
		for (int i = n - 1; i >= n - k; i--) 
			product *= A[i]%m; 
		return product; 
	} 

	int i = 0; 

	int j = n - 1; 

	if (k & 1) { 
		product *= A[j]%m; 
		j--; 
		k--; 
	} 

	k >>= 1; 
 
	for (int itr = 0; itr < k; itr++) { 

		int left_product = (A[i]%m * A[i + 1]%m)%m; 

		int right_product = (A[j]%m * A[j - 1]%m)%m; 
 
		if (left_product > right_product) { 
			product *= left_product%m; 
			i += 2; 
		} 
		else { 
			product *= right_product%m; 
			j -= 2; 
		} 
	} 

	return product; 
} 

int main() 
{ 
    long long int n,k;
    cin>>n>>k;
    int A[n];
    for(int i=0;i<n;i++)
    cin>>A[i];
	cout << maxProductSubarrayOfSizeK(A, n, k)%m; 
	return 0; 
} 


Compiler output:
a.cc:5:23: error: 'pow' was not declared in this scope
    5 | const long long int m=pow(10,9)+7;
      |                       ^~~
Language: C++

#include<bits/stdc++.h>
#define int long long
#define ll long long
using namespace std;
const ll Mod = 1e9+9;
vector <ll> neg, pos;
ll ans, n, k;

ll mul(vector<ll> a, int start, int end)
{
	ll ans=1;
	for(int i=start; i<=end; i++)
		ans = ans * a[i] % Mod;
	return ans;
}

int main()
{
	cin>>n>>k;
	for(int i=1; i<=n; i++)
	{
		ll x;
		cin>>x;
		//只处理正数和负数，0不处理
		if(x>0) pos.push_back(x);
		if(x<0) neg.push_back(x);
	}
	sort(pos.begin(), pos.end());
	sort(neg.begin(), neg.end());

	//分类讨论
	unsigned long sizeSum = pos.size() + neg.size();
	// 1.正数和负数的个数不足k，必然有0的存在
	if(sizeSum < k)
	{
		ans=0;
	}
	// 2.正数和负数的个数恰好为k
	else if(sizeSum == k)
	{
		//2.1 k与n相等，必须选这k个数，没有0
		if(k==n)
		{
			ans = mul(pos, 0, pos.size()-1) * mul(neg, 0, neg.size()-1)%Mod;
		}
		//2.2 k<n，有0的存在
		else
		{
			//2.2.1 可得正数解当且仅当：正数全部选中，负数全部选中且为偶数个
			if(neg.size()%2==0)
			{
				ans = mul(pos, 0, pos.size()-1) * mul(neg, 0, neg.size()-1)%Mod;
			}
			//2.2.2 负数是奇数个，全部选中结果为负数，不全部选中可得0，ans=0
			else
			{
				ans=0;
			}
		}
	}
	//3.正数和负数的个数大于k，情况比较复杂
	//sum>k
	else
	{
		// 3.1没有正数，负数和0中选k个
		if(pos.size() == 0)
		{
			//3.1.1 k是偶数
			if(k%2==0)
			{
				ans = mul(neg, 0, k-1);
			}
			//3.1.2 k是奇数
			else
			{
				//有0
				if(sizeSum < n)
					ans=0;
				//没有0，必须从所有负数中选奇数个数>=累乘绝对值小的
				else//逆向选k个
					ans = mul(neg, neg.size()-k, neg.size()-1);
			}
		}
		//3.2 没有负数
		else if(neg.size() == 0)//逆向选k个
			ans = mul(pos, pos.size()-k, pos.size()-1);
		//3.3 有正数也有负数
		else
		{
			int posStart;
			int negEnd;
			//3.3.1 正数不足k个
			if(k>=pos.size())
			{
				//假定正数全部选中，剩余偶数个负数，等会再来挪动标尺
				if((k-pos.size()) % 2 == 0)
				{
					//负数选择的截止下标
					negEnd = k - pos.size() - 1;
					//正数选择的起始下标
					posStart = 0;
				}
				else
				{
					//剩余个数是奇数，正数先少选一个
					//正数选择的起始下标
					posStart = 1;
					//负数选择的起始下标
					negEnd = k - pos.size();
				}
			}
			//正数多于k个，假定从正数中先选最大的k个
			else
			{
				//k是偶数
				if(k%2==0)
				{
					negEnd = -1;
					posStart = pos.size() - k;
				}
				//k是奇数，先少选一个
				else
				{
					negEnd = -1;
					posStart = pos.size() - k - 1;
				}
			}

			//双标尺移动
			while(negEnd + 2 < neg.size() && posStart + 2 < pos.size() &&
				neg[negEnd + 1] * neg[negEnd +2] > pos[posStart] * pos[posStart + 1])
			{
				negEnd += 2;
				posStart += 2;
			}
			ans = mul(neg, 0, negEnd) * mul(pos, posStart, pos.size()-1) % Mod;
		}
	}
	cout<<(ans+Mod)%Mod<<endl;

	return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

負のやつを偶数とるか奇数とるか、0をとるか
で場合分け

Compiler output:
a.cc:1:1: error: extended character 、 is not valid in an identifier
    1 | 負のやつを偶数とるか奇数とるか、0をとるか
      | ^
a.cc:1:1: error: '\U00008ca0\U0000306e\U00003084\U00003064\U00003092\U00005076\U00006570\U00003068\U0000308b\U0000304b\U00005947\U00006570\U00003068\U0000308b\U0000304b\U000030010\U00003092\U00003068\U0000308b\U0000304b' does not name a type
    1 | 負のやつを偶数とるか奇数とるか、0をとるか
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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;

int main(){
  using namespace std;
  long long n;
  cin>>n;
  long long u[n], v[n];
  REP(i, n){
    cin>>u[i]>>v[i];
    u[i]--; v[i]--;
    if(u[i] > v[i]) swap(u[i], v[i]);
  }
  
  long long ans = 0;
  for(long long l = 1; l <= n; l++){
    ans += (n + l)(n - l + 1) / 2 - (l - 1)(n - l + 1);
  }
  REP(i, n){
    ans -= (u[i] + 1) * (n - v[i]);
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:19: error: expression cannot be used as a function
   82 |     ans += (n + l)(n - l + 1) / 2 - (l - 1)(n - l + 1);
      |            ~~~~~~~^~~~~~~~~~~
a.cc:82:44: error: expression cannot be used as a function
   82 |     ans += (n + l)(n - l + 1) / 2 - (l - 1)(n - l + 1);
      |                                     ~~~~~~~^~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll ans=0;
ll x,y;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)  ans+=i*(n-i+1);
    for(int i=1;i<n;i++)
    {
       scanf("%lld%lld",&x,&y);
	   if(x>y)  swap(x,y);
	   ans-=u*(n-v+1);  	
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:17: error: 'u' was not declared in this scope
   15 |            ans-=u*(n-v+1);
      |                 ^
a.cc:15:22: error: 'v' was not declared in this scope
   15 |            ans-=u*(n-v+1);
      |                      ^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

using ll =  long long;

int main() {
    ll n, u, v;
    cin >> n;
    ll ans = (n * (n+1) * (2*n+1) / 6 + n * (n+1) / 2) / 2;
    for(int i=0;i<n-1;++i) {
        cin >> u >> v;
        if(u < v) ans -= u*(N-v+1);
        else ans -= v*(N-u+1);
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:29: error: 'N' was not declared in this scope
   14 |         if(u < v) ans -= u*(N-v+1);
      |                             ^
a.cc:15:24: error: 'N' was not declared in this scope
   15 |         else ans -= v*(N-u+1);
      |                        ^
Language: Java

package ACB173;

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

public class f {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		
		long ans = 0;
		
		for(int i = 1; i <= n; i++)
			ans += i * (n - i + 1);
		
		for(int i = 1; i < n; i++)
		{
			int a = in.nextInt();
			int b = in.nextInt();
			int l = Math.min(a, b);
			int r = Math.max(a, b);
			ans -= l * (n - r + 1);
		}
		
		System.out.println(ans);

	}

}


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

#include <bits/stdc++.h>

using namespace std;

#define long long long
#define INF 1e18
#define MOD (long) (1e9 + 7)
#define double __float128

struct Node
{
    long k;
    long count;
    bool visited = false;
    vector<long> adj;
};

long solve(Node &r, auto &nodes, long n)
{
    r.count = rr.k * (n - r.k + 1);
    long total = r.count;
    long count = 0;
    r.visited = true;
    for (auto &i : r.adj) {
        Node &u = nodes[i];
        if (u.visited) continue;
        total += solve(u, nodes, n);
        long x = min(r.k, u.k) * (n - max(r.k, u.k) + 1);
        total -= x;
    }
    return total;
}

int main()
{
    long n;
    cin >> n;

    vector<Node> nodes(n+1);
    for (long i = 1; i <= n; i++) {
        nodes[i].k = i;
    }
    for (long i = 0; i < n-1; i++) {
        long u, v;
        cin >> u >> v;
        nodes[u].adj.push_back(v);
        nodes[v].adj.push_back(u);
    }
    long ans = solve(nodes[1], nodes, n);
    printf("%lld\n", ans);
}


Compiler output:
a.cc:18:21: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   18 | long solve(Node &r, auto &nodes, long n)
      |                     ^~~~
a.cc: In function 'long long int solve(Node&, auto:28&, long long int)':
a.cc:20:15: error: 'rr' was not declared in this scope; did you mean 'r'?
   20 |     r.count = rr.k * (n - r.k + 1);
      |               ^~
      |               r
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 19, Mod = 1e9 + 7;
ll n;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    ll tot = 0;
    ll m = n - 1;
    for (ll i = 1; i * i <= m; i ++)
        if (m % i == 0)
        {
            if (i != 1)
                tot ++;
            if (m / i != i)
                tot ++;
        }
    vector < ll > A;
    for (ll i = 1; i * i <= n; i ++)
        if (n % i == 0)
        {
            A.push_back(i);
            if (n / i != i)
                A.push_back(n / i);
        }
    for(ll a :: A)
    {
        if (a == 1)
            continue;
        ll tmp = n, c = 0;
        while (tmp % a == 0)
            tmp /= a, c = 1;
        if (c == 0)
            continue;
        if (tmp % a == 1)
            tot ++;
    }
    printf("%lld\n", tot);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:12: error: 'a' has not been declared
   29 |     for(ll a :: A)
      |            ^
a.cc:29:18: error: qualified-id in declaration before ')' token
   29 |     for(ll a :: A)
      |                  ^
a.cc:29:18: error: expected ';' before ')' token
   29 |     for(ll a :: A)
      |                  ^
      |                  ;
a.cc:29:18: error: expected primary-expression before ')' token
a.cc:29:18: error: expected ';' before ')' token
   29 |     for(ll a :: A)
      |                  ^
      |                  ;
a.cc:31:13: error: 'a' was not declared in this scope
   31 |         if (a == 1)
      |             ^
a.cc:34:22: error: 'a' was not declared in this scope
   34 |         while (tmp % a == 0)
      |                      ^
a.cc:38:19: error: 'a' was not declared in this scope
   38 |         if (tmp % a == 1)
      |                   ^
Language: C++

#include <iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

// int main() {
//     int N;
//     cin >> N;
//     ll edges = 0;
//     rep(k,N-1) {
//         ll i, j;
//         cin >> i >> j;
//         if (j < i) swap(i,j);
//         edges += i * (N - j + 1);
//     }
//     ll vertices = 0;
//     for (int k = 1; k <= N; ++k) {
//         vertices += (N - k + 1) * (N-k+2)/2;
//     }
//     cout << vertices - edges << endl;
//     return 0;
// }

int main() {
    ll n; cin >> n;
    ll sum = 0;
    FOR(i, 1, n)
        sum += (2 + n - i) * (n - i + 1) / 2;
    FOR(i, 1, n - 1) {
        ll u, v; cin >> u >> v;
        if (u > v) swap(u, v);
        sum -= u * (n - v + 1);
    }
    cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:9: error: 'i' was not declared in this scope
   28 |     FOR(i, 1, n)
      |         ^
a.cc:28:5: error: 'FOR' was not declared in this scope
   28 |     FOR(i, 1, n)
      |     ^~~
Language: C++

#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main() {
    long long int N;
    cin >> N;

    int n = N * (N+1) * (N+2) / 6;

    vector< pair<int, int> > u(N);
    for(int i = 0; i < N; i++) {
        cin >> u[i].first >> u[i].second;
    }
    
    for(int i = 0; i < N; i++) {
        if ( u[i].first < u[i].second) N -= u[i].first * (N + 1 - u[i].second);
        if ( u[i].first > u[i].second) N -= u[i].second * (N + 1 - u[i].first);
    }

    cout << n - m;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:17: error: 'm' was not declared in this scope
   23 |     cout << n - m;
      |                 ^
Language: C++

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

#define ll long long

#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
int main(){
    int n;
    cin >> n;
    vector<int> adj[n+1];
    ll result = 0;

    // Connected components = Total no of vertices - Total no of edges
    
    // Total no of vertices
    for(ll i=1; i<=n; i++)
	result += i * (i+1)/2;

    // Total no of edges
    for(llin i=1; i<n; i++){
	ll  a, b;
	cin >> a >> b;
	if(a > b)
	    swap(a, b);
	ll edges = a * (n - b + 1);
	result -= edges;
    }
    cout << result << "\n";
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'llin' was not declared in this scope
   21 |     for(llin i=1; i<n; i++){
      |         ^~~~
a.cc:21:19: error: 'i' was not declared in this scope
   21 |     for(llin i=1; i<n; i++){
      |                   ^
Language: C++

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

typedef long long ll;
#define endl "\n"

int32_t main()
{
	ios_base::sync_with_stdio(nullptr);
  	cin.tie(nullptr);
  	cout.tie(nullptr);
  
	ll n;
	cin>>n ;
	ll ans=0;
	for(ll i=1;i<=n;i++)
		ans+=i*(n-i+1);

	for(ll i=1;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		if(x>y) swap(x,y);
		ans-=x*(n-y+1);
	}

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

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:9:35: error: converting to 'bool' from 'std::nullptr_t' requires direct-initialization [-fpermissive]
    9 |         ios_base::sync_with_stdio(nullptr);
      |                                   ^~~~~~~
In file included from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
                 from a.cc:1:
/usr/include/c++/14/bits/ios_base.h:803:26: note:   initializing argument 1 of 'static bool std::ios_base::sync_with_stdio(bool)'
  803 |     sync_with_stdio(bool __sync = true);
      |                     ~~~~~^~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define Int long long




int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    Int n;
    cin>>n;
    Int cv=(n*(n+1))/2;
  	cv*=n;
  	cv=0;
  	for(int i = 1;i<=n;i++)
    {
        //Int j = (n*(n+1))/2;
      	cv+=(i)*(n-i+1);
        //cv-=j;
    }
    for(int i = 1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
      	cv-=(min(x,y)*(n-max(x,y)+1);
    }
    cout<<cv<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:37: error: expected ')' before ';' token
   27 |         cv-=(min(x,y)*(n-max(x,y)+1);
      |             ~                       ^
      |                                     )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define Int long long




int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    Int n;
    cin>>n;
    Int cv=(n*(n+1))/2;
  	cv*=n;
  	for(int i = 1;i<=n;i++)
    {
        Int j = (n*(n+1))/2;
      	j-=(i)*(n-i+1);
        cv-=j;
    }
    for(int i = 1;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
      	cv-=(min(x,y)*(n-max(x,y)+1);
    }
    cout<<cv<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:37: error: expected ')' before ';' token
   26 |         cv-=(min(x,y)*(n-max(x,y)+1);
      |             ~                       ^
      |                                     )
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n;
	scanf("%d",&n);
	ll ans=n*(n+1)*(n+2)/6;
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if(u>v) swap(u,v);
		ans-=*u*(n-v+1); 
	}
	printf("%lld\n",ans); 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:22: error: invalid type argument of unary '*' (have 'int')
   12 |                 ans-=*u*(n-v+1);
      |                      ^~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll sol = 0;
	for(int i = 0; i < n; i++){
		sol += (i + 1) * 1LL * (n - i);
	}
	for(int i = 0; i < n - 1; i++){
		int l, r;
		cin >> l >> r;
		int mini = min(l, r);
		int maxi = max(l, r);
		sol -= (n - mini) * 1LL * (n - maxi + 1);
	}
	cout << sol < <'\n';
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:23: error: expected primary-expression before '<' token
   21 |         cout << sol < <'\n';
      |                       ^
Language: C++

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

public class Main {
    public static void main(String[] args) throws Exception {
        InputStream inputStream;
        OutputStream outputStream;
        if(System.getProperty("ONLINE_JUDGE") == null) {
            File input = new File("test.inp");
            inputStream = new FileInputStream(input);
        }
        else {
            inputStream = System.in;
        }
        outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        public void solve(InputReader in, PrintWriter out) {
            int n;
            n = in.nextInt();
            long ans = 0;
            for(int i = 1;i <= n;++i){
                ans += (long)i * (long)(n - i + 1);
            }
            for(int i = 1;i < n;++i){
                int u,v;
                u = in.nextInt();
                v = in.nextInt();
                if(u > v){
                    int tmp = u;
                    u = v;
                    v = tmp;
                }
                ans -= (long)u * (long)(n - v + 1);
            }
            out.println(ans);
        }

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

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            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());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = reader.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}




Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main {
      | ^~~~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
int main() {
	int N;
	cin >> N;
	long long V = 0;
	long long E = 0;
	for (int i = 1; i <= N; ++i) {
		V += long long(i)*(N - i + 1);
	}
	for (int n = 0; n < N - 1; ++n) {
		int a, b;
		cin >> a >> b;
		if (a>b) {
			swap(a, b);
		}
		E += long long(a)*(N - b + 1);
	}
	long long ans = V - E;
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:22: error: expected primary-expression before 'long'
    9 |                 V += long long(i)*(N - i + 1);
      |                      ^~~~
a.cc:17:22: error: expected primary-expression before 'long'
   17 |                 E += long long(a)*(N - b + 1);
      |                      ^~~~
Language: Java

import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Vector;

public class cf {
    public static Scanner r=new Scanner(System.in);
    public static void main(String[] args) {
        int n=r.nextInt();
        int sum=0;
        int cur=0;
        for(int i=1;i<=n;++i){
            cur+=i;
            sum+=cur;
        }
        for(int i=0;i<n-1;++i){
            int x,y;
            x=r.nextInt()-1;
            y=r.nextInt()-1;
            int a=Math.min(x,y);
            int b=Math.max(x,y);
            sum-=(a+1)*(n-b);
        }
        System.out.println(sum);
    }
}


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

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

int n;
const int sz = 2e5+5;
vector<int> adj[sz];
ll dp[sz];

void solve(){
    cin >> n;
    for(int i = 0; i < n-1; ++i){
        int u, v;
        cin >> u >> v;
        --u, --v;
        if(u > v) swap(u, v);
        adj[u].push_back(v);
    }
    
    dp[n] = 0;
    for(int i = n-1; i >= 0; --i){
        dp[i] = dp[i+1] + n-i;
        for(int node : adj[i]){
            dp[i] -= n-node;
        }a
    }

    int ans = 0;
    for(int i = 0; i < n; ++i) ans += dp[i];
    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:25:10: error: 'a' was not declared in this scope
   25 |         }a
      |          ^
Language: C

#include <stdio.h>
int main(void){
  long long i,j,n,m,k,a,b,c,h,w,r=0,l,t,tmp;
  scanf("%lld",&n);
  r=n*(n+1)*(n+2);r/=6;
  for(i=0;i<n-1;i++){
    scanf("%lld%lld",&a,&b);
    if(a>b){tmp=a; a=b; b=tmp}
    k=a*(n+1-b);
    r-=k;
  }
  printf("%lld\n",r);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:8:30: error: expected ';' before '}' token
    8 |     if(a>b){tmp=a; a=b; b=tmp}
      |                              ^
      |                              ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)


int main(){
    ll n;
    cin >> n;
    ll ans = n*(n+1)*(n+2)/6;
    rep(i, n-1) {
        ll u, v;
        cin >> u >> v;
        if (u>v) swap(u, v);
        ans -= (u)*(n-v+1);
    }
    
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:5: error: 'll' was not declared in this scope
    8 |     ll n;
      |     ^~
a.cc:9:12: error: 'n' was not declared in this scope; did you mean 'yn'?
    9 |     cin >> n;
      |            ^
      |            yn
a.cc:10:7: error: expected ';' before 'ans'
   10 |     ll ans = n*(n+1)*(n+2)/6;
      |       ^~~~
      |       ;
a.cc:12:11: error: expected ';' before 'u'
   12 |         ll u, v;
      |           ^~
      |           ;
a.cc:13:16: error: 'u' was not declared in this scope
   13 |         cin >> u >> v;
      |                ^
a.cc:13:21: error: 'v' was not declared in this scope
   13 |         cin >> u >> v;
      |                     ^
a.cc:15:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   15 |         ans -= (u)*(n-v+1);
      |         ^~~
      |         abs
a.cc:18:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

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

ll n, ans;

int main() {
  cin >> n;
  ans = (n+2)*(n+1)*(n)/6;
  for(int i = 0; i < n-1; ++i) {
    int u, v;
    cin >> u >> v;
    if(u > v) swap(u, v);
    ans -= u*(n+1-v);
  }
  cout << ans << endl;
  
  return 0;
}

Compiler output:
a.cc:4:1: error: 'll' does not name a type
    4 | ll n, ans;
      | ^~
a.cc: In function 'int main()':
a.cc:7:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |   cin >> n;
      |          ^
      |          yn
a.cc:8:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
    8 |   ans = (n+2)*(n+1)*(n)/6;
      |   ^~~
      |   abs
Language: C++

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

//////////////////////////////   End Macros

void solve()
{
  ll N;
  cin >> N;
  ll ans = N * (N + 1) * (N + 2) / 6;
  rep(i, N - 1)
  {
    ll u, v;
    cin >> u >> v;
    if (u > v)
      swap(u, v);
    ans -= u * (N - v + 1);
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:8:3: error: 'll' was not declared in this scope
    8 |   ll N;
      |   ^~
a.cc:9:10: error: 'N' was not declared in this scope
    9 |   cin >> N;
      |          ^
a.cc:10:5: error: expected ';' before 'ans'
   10 |   ll ans = N * (N + 1) * (N + 2) / 6;
      |     ^~~~
      |     ;
a.cc:11:7: error: 'i' was not declared in this scope
   11 |   rep(i, N - 1)
      |       ^
a.cc:11:3: error: 'rep' was not declared in this scope
   11 |   rep(i, N - 1)
      |   ^~~
a.cc:19:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const ll MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<int>graph[MAX];
ll n,parent[MAX];
bool visit[MAX];
ll dfs(ll src)
{
    visit[src]=1;
    ll res=0;
    if(parent[src]<src)
        res=(src-parent[src])*(n-src+1);
    else
        res=src*(parent[src]-src);
    for(int i=0; i<graph[src].size(); i++)
    {
        int child=graph[src][i];
        if(!visit[child])
        {
            parent[child]=src;
            res+=dfs(child);
        }
    }
    return res;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    cin>>n;
    for(int i=1; i<n; i++)
    {
        ll u,v;
        cin>>u>>v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    cout<<dfs(1)<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'll dfs(ll)':
a.cc:19:5: error: reference to 'visit' is ambiguous
   19 |     visit[src]=1;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:16:6: note:                 'bool visit [1000000]'
   16 | bool visit[MAX];
      |      ^~~~~
a.cc:28:13: error: reference to 'visit' is ambiguous
   28 |         if(!visit[child])
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:16:6: note:                 'bool visit [1000000]'
   16 | bool visit[MAX];
      |      ^~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;


signed main(){

	int n;
	cin >> n;

    i64 ans = n * (n + 1) * (n + 2) / 6;
    for(int i = 0; i < n - 1; ++i){
		int u, v;
		cin >> u >> v;
		if(u > v)
			swap(u, v);
        --u;
        ans -= (u + 1) * (n - v + 1);
    }
    cout << ans << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:11:5: error: 'i64' was not declared in this scope
   11 |     i64 ans = n * (n + 1) * (n + 2) / 6;
      |     ^~~
a.cc:18:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |         ans -= (u + 1) * (n - v + 1);
      |         ^~~
      |         abs
a.cc:20:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   20 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

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

long long n;

int main() {
  cin >> n;
  g.resize(n);
  long long sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    long long x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    sum -= x * (n - y + 1);
  }
  for (int i = 0; i < n; ++i) sum += (long long)(i + 1) * (i + 2) / 2;

  cout << sum << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'g' was not declared in this scope
    8 |   g.resize(n);
      |   ^
Language: C

#include <stdio.h>

int main() {
int i, j,u,v,sum=0;
 scanf("%d",&n);
 for(i=1;i<=n;i++){
 scanf("%d %d",&u,&v);
 for(;u<=v;u++){
   sum+=v-u+1;
 }
 }
printf("%d",sum);
}

Compiler output:
main.c: In function 'main':
main.c:5:14: error: 'n' undeclared (first use in this function)
    5 |  scanf("%d",&n);
      |              ^
main.c:5:14: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <bits/stdc++.h>

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

// Prerequisite:
// $ sudo apt-get install libboost-all-dev
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using bigint = boost::multiprecision::cpp_int;
using decfloat = boost::multiprecision::cpp_dec_float_50;

int main() {
  in(ll, n);
  bigint ans = 0;
  for (ll i = n; i >= 1; --i) ans += i * (n + 1 - i);
  dbg(ans);
  rep(i, n - 1) {
    in(ll, u, v);
    if (u > v) swap(u, v);
    int x = u * (n - (v - 1));
    dbg(x);
    ans -= x;
  }
  cout << ans << endl;
}


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

// seabreeeze //
 
#include<bits/stdc++.h>
 
using namespace std;
 
#define lli long long
lli M=1e9+7;
lli MOD=1e9+7;
 
#define MAXN 2000006 
 
// Template function //
lli powermod(lli x, lli y)  
{  
    lli res = 1;  
    x = x % MOD;
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % MOD;  
        y = y>>1;   
        x = (x*x) % MOD;  
    }  
    return res;  
}
lli modinv(lli x)
{
    return powermod(x,MOD-2);
}
// Template functions end //
 
// Custom funtions //
void preprocess()
{

}

int mex(int a[],int n)
{
    vector<int> c(n+1,0);
    for(int i=0;i<n;i++)
    {
        c[a[i]]=1;
    }
    for(int i=0;i<n+1;i++)
    {
        if(c[i]==0)
        return i;
    }
    return 0;
}
 
// Custom functions end //
 
int main()
{
    lli q=1;
    // cin>>q;
    time_t start, end;
    time(&start);
    preprocess();
    for(lli tc=1;tc<=q;tc++)
    {
        // Start solution //
        int n,k;
        cin>>n;
        vector<int> v(n,1);
        int x,y;
        for(int i=0;i<n-1;i++)
        {
            cin>>x>>y;
            if(x<y)
            {
                swap(x,y);
            }
            v[x-1] = 1;
        }
        x=1;
        y=1;
        for(int i=1;i<n;i++)
        {
            if(v[i])
            {
                x--;
                else x++;
            }
            y+=x;
        }
        cout<<y<<endl;
        // End Solution //
        end:;
    }
    
    time(&end);
    // cout<<fixed<<double(end - start)<<setprecision(10)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:17: error: expected '}' before 'else'
   87 |                 else x++;
      |                 ^~~~
a.cc:85:13: note: to match this '{'
   85 |             {
      |             ^
a.cc:91:15: error: 'y' was not declared in this scope
   91 |         cout<<y<<endl;
      |               ^
a.cc: At global scope:
a.cc:96:9: error: expected constructor, destructor, or type conversion before '(' token
   96 |     time(&end);
      |         ^
a.cc:98:5: error: expected unqualified-id before 'return'
   98 |     return 0;
      |     ^~~~~~
a.cc:99:1: error: expected declaration before '}' token
   99 | }
      | ^
Language: C++

#include<iostream>
int main()
{
	int D;
    scanf("%d",D);
    int C[26];
    for(int a = 0; a < 26; a++)
    {
        scanf("%d",C[a]);
    }
    int SCORE[365][26]
    for(int a = 0; a < 365; a++)
    {
        for(int b ; b <26; b++)
        {
        	scanf("%d",SCORE[a][b]);
        }
    }
    int HUMAN[26] = {0};
    int KEKKA[365] = {0};
    for(int a = 0; a < 365; a++)
    {
    	for(int b = 0; b <26; b++)
        {
        	HUMAN[b] += C[b];
        }
        int GOUKEI[26] = {0};
        for(int c = 0; c <26; c++)
        {
            GOUKEI[c] = SCORE[a][c] + HUMAN[c];
        }
        for(int c = 0; c < 26; c++)
        {
            int n = 0;
            if(n < GOUKEI[c])
            {
                n = GOUKEI[c];
                KEKKA[a] = c;
            }
        }
        HUMAN[KEKKA[a]] = 0;
    }
	for(int a =0; a < 365; a++)
    {
    	printf("%d\n",KEKKA[a]);
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: expected initializer before 'for'
   12 |     for(int a = 0; a < 365; a++)
      |     ^~~
a.cc:12:20: error: 'a' was not declared in this scope
   12 |     for(int a = 0; a < 365; a++)
      |                    ^
a.cc:30:25: error: 'SCORE' was not declared in this scope
   30 |             GOUKEI[c] = SCORE[a][c] + HUMAN[c];
      |                         ^~~~~