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

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

struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
              return x>a.x;
    }
};
struct S
{
    int x,y,z;

    bool operator<(const S &a)const{
              return x<a.x;
    }
};

vector<int> v;
//bitset<4001000> b;
int a,c,i,b,k,n,d,e,m;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
long long l[1114000];

long long o[1114211];
int j[2];
int dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};


long long x,y,mod=1000000007;
long long z;

P u[555320];
//stack<int> s;

//set<int> s;
queue<int> q;

//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
//list<int> l;
//string r1,r;
//char r[1152][1111];
//deque<int> de;
bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y>b.y;
}

long long f(int a)
{
    if(a<0) return 0;
    else
    return o[a];
}
long long p(long long a,long long b)
{
    if(!b) return 1;
    long long x=p(a,b>>1);
    x*=x,x%=mod;
    if(b&1) x*=a,x%=mod;
    return x;
}

long long g(int a,int b)
{
    if(b<a) return 0;
    return f(b)*(p(f(a),mod-2)*p(f(b-a,mod-2))%mod)%mod;
}



int main()
{
    scanf("%d",&a);
    if(a==2)
    {
        puts("1");
        return 0;
    }
    o[0]=1;
    for(int t=1;t<=a;t++)
        o[t]=o[t-1]*t%mod;
    //l[0]=1;
    //for(int t=1;t<=a;t++)
     //   l[t]=p(o[t],mod-2);
    for(int t=2;t<a;t++)
    {
        y=x;
        x=f(a-t-1)*f(t)%mod*g(a-t-1,t-1)%mod;
        z+=(x-y+mod)%mod*t%mod;
        z%=mod;
        //printf("##%lld\n",x);
        //printf("%lld %lld %lld\n",f(a-t-1),f(t),g(a-t-1,t-1));
    }
    printf("%lld",z);
}



Compiler output:
a.cc: In function 'long long int g(int, int)':
a.cc:74:35: error: too many arguments to function 'long long int f(int)'
   74 |     return f(b)*(p(f(a),mod-2)*p(f(b-a,mod-2))%mod)%mod;
      |                                  ~^~~~~~~~~~~
a.cc:56:11: note: declared here
   56 | long long f(int a)
      |           ^
a.cc:74:33: error: too few arguments to function 'long long int p(long long int, long long int)'
   74 |     return f(b)*(p(f(a),mod-2)*p(f(b-a,mod-2))%mod)%mod;
      |                                ~^~~~~~~~~~~~~~
a.cc:62:11: note: declared here
   62 | long long p(long long a,long long b)
      |           ^
Language: C++

/*

参考にした提出
https://agc023.contest.atcoder.jp/submissions/2435072

*/


#include<cstddef>
#include<cstdint>
#include<cstdio>

using uint64 = std::uint_fast64_t;

constexpr uint64 M = 1000000007;

template<std::size_t N>
struct Fact {
	uint64 val[N], v2[N];
	constexpr Fact() :val(), v2() {
		val[0] = 1;
		for (std::size_t i = 1; i < N; ++i) val[i] = val[i - 1] * i % M;
		for (std::size_t i = 1; i < N; ++i) v2[i] = val[i - 1] * val[i] % M;
		for (std::size_t i = 1; i < N; ++i) val[i] = val[i] * i % M;
	}
};

template<std::size_t N, uint64 F>
struct IFact {
	uint64 val[N];
	constexpr IFact() : val() {
		val[N - 1] = F;
		for (std::size_t i = N - 1; i; --i) val[i - 1] = val[i] * i % M;
	}
};

constexpr auto fact = Fact<1000000>();
constexpr auto ifact = IFact<1000000, 498215386>();

int main() {
	unsigned int n;
	uint64 ans;
	scanf("%u", &n);
	const std::size_t N = n;
	for (std::size_t i = (N + 1) >> 1; i < N - 1; ++i) {
		ans += fact.v2[i] * ifact.val[(i << 1) - N] % M;
	}
	ans %= M;
	long long unsigned int o = fact.val[N - 1] < ans ? fact.val[N - 1] + M - ans : fact.val[N - 1] - ans;
	printf("%llu\n", o);
	return 0;
}


Compiler output:
a.cc:37:37:   in 'constexpr' expansion of 'Fact<1000000>()'
a.cc:22:17: error: 'constexpr' loop iteration count exceeds limit of 262144 (use '-fconstexpr-loop-limit=' to increase the limit)
   22 |                 for (std::size_t i = 1; i < N; ++i) val[i] = val[i - 1] * i % M;
      |                 ^~~
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

const LL MOD = 1000000007;

LL mod_pow(LL v, LL n){
    if(n <= 0) return 1;
    LL res = mod_pow(v, n/2);
    res = res * res % MOD;
    if(n & 1) res = res * v % MOD;
    return res;
}

vector<LL> mod_factorial(LL n){
    vector<LL> res(n);
    res[0] = 1;
    for(LL i = 1; i <= n; ++i){
        res[i] = res[i-1] * i % MOD;
    }
    return res;
}

LL permutation(LL n, LL m, vector<LL>& factorial){
    if(m < 0 || n < m) return 0;
    if(m == 0) return 1;
    LL res = factorial[n];
    res = res * mod_pow(factorial[m-1], MOD-2) % MOD;
    return res;
}

LL combination(LL n, LL m, vector<LL>& factorial){
    if(m < 0 || n < m) return 0;
    if(m == 0) return 1;
    LL res = permutation(n, m, factorial);
    res = res * mod_pow(factorial[m], MOD-2) % MOD;
    return res;
}

int main(){
    LL n;
    cin >> n;
    if(n == 2){
        cout << 1 << endl;
        return 0;
    }
    if(n == 3){
        cout << 4 << endl;
        return 0;
    }
    vector<LL> factorial = mod_factorial(n+1);
    vector<LL> equal_or_less(n+1);
    for(LL k = 0; k < n; ++k){
        LL part1 = factorial[k] * factorial[n-1-k] % MOD;
        LL part2 = combination(k-1, n-1-k, factorial);
        equal_or_less[k] = part1 * part2 % MOD;
    }
    LL ans = 0;
    for(LL k = (n+1)/2; k+1 <= n; ++k){
        assert(k-1 >= n-k-1);
        LL part1 = (equal_or_less[k] - equal_or_less[k-1] + MOD) % MOD;
        LL part2 = part1 * k % MOD;
        ans = (ans + part2) % MOD;
    }
    cout << ans << endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:79:9: error: 'assert' was not declared in this scope
   79 |         assert(k-1 >= n-k-1);
      |         ^~~~~~
a.cc:11:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
   10 | #include <cmath>
  +++ |+#include <cassert>
   11 |
Language: C++

#include<iostream>
using namespace std;
const int DIV=1000000000+7;
long myPow(long x, long n, long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
long fact(long i,long j){//i*i+1*....*i+j-1
    if(j==0)
        return 1;
    else
        return fact(i,j-1)*(i+j-1) % DIV;
}

int main(){
    long N;
    cin >> N;
    
    long m;
    if(N%2==0)
        m=N/2;
        
    else
        m=(N-1)/2;
    long A[m];
//    long kaijo = fact(1,N-m-1);
    A[0] = fact(1,N-1);
//    A[m-1] = kaijo*kaijo*(N-m);
    for(long i=1;i<m;i++){
     //   A[i] = A[i-1];
     //   A[i] /= (N-i)*(N-i-1);
     //   A[i] *=  (N-i-i)*(N-i-i-1);
    A[i]=fact(1,N-i-1)*frac(N-i-i-1,i);
//        cout<<"Ai:"<<A[i]<<endl;
    }
    long ret;
    for(int i=0;i<m;i++){
        A[i] %= DIV;
    }
    ret = A[0] * (N-1);
    for(int i=1;i<m;i++){
        ret -= A[i];
//        cout<<"i:"<<i<<endl;
    }
    ret %= DIV;
    cout << ret << endl;
    

}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:24: error: 'frac' was not declared in this scope
   37 |     A[i]=fact(1,N-i-1)*frac(N-i-i-1,i);
      |                        ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = 2000005, MOD = 1000000007;
int f[N], finv[N], act[N];

inline void add(int &a, int b) {
    a += b;
    if (a >= MOD) {
        a -= MOD;
    }
}

inline void sub(int &a, int b) {
    a -= b;
    if (a < 0) {
        a += MOD;
    }
}

inline int mul(int a, int b) {
    return (ll)a * b % MOD;
}

void precalc() {
    f[0] = 1;
    for (int i = 1; i < N; i++) {
        f[i] = mul(f[i - 1], i);
    }
    finv[0] = finv[1] = 1;
    for (int i = 2; i < N; i++) {
        finv[i] = (MOD - mul(MOD / i, finv[MOD % i])) % MOD;
    }
    for (int i = 2; i < N; i++) {
        finv[i] = mul(finv[i - 1], finv[i]);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(cout.fixed);
    cout.precision(20);
    precalc();
    int n;
    cin >> n;
    for (int k = (n + 1) / 2; k < n; k++) {
        act[k] = mul(mul(f[k - 1], f[k]), finv[2 * k - n]);
    }
    ll res = 0;
    for (int k = (n + 1) / 2; k < n; k++) {
        int realact = act[i];
        sub(realact, act[k - 1]);
        add(res, mul(k, realact));
    }
    cout << res << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:27: error: 'i' was not declared in this scope
   56 |         int realact = act[i];
      |                           ^
a.cc:58:13: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka 'long long int'}
   58 |         add(res, mul(k, realact));
      |             ^~~
a.cc:11:22: note:   initializing argument 1 of 'void add(int&, int)'
   11 | inline void add(int &a, int b) {
      |                 ~~~~~^
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int N = 2000005, MOD = 1000000007;
int f[N], finv[N], act[N];

inline add(int &a, int b) {
    a += b;
    if (a >= MOD) {
        a -= MOD;
    }
}

inline sub(int &a, int b) {
    a -= b;
    if (a < 0) {
        a += MOD;
    }
}

inline int mul(int a, int b) {
    return (ll)a * b % MOD;
}

void precalc() {
    f[0] = 1;
    for (int i = 1; i < N; i++) {
        f[i] = mul(f[i - 1], i);
    }
    finv[0] = finv[1] = 1;
    for (int i = 2; i < N; i++) {
        finv[i] = (MOD - mul(MOD / i, finv[MOD % i])) % MOD;
    }
    for (int i = 2; i < N; i++) {
        finv[i] = mul(finv[i - 1], finv[i]);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(cout.fixed);
    cout.precision(20);
    precalc();
    int n;
    cin >> n;
    for (int k = (n + 1) / 2; k < n; k++) {
        act[k] = mul(mul(f[k - 1], f[k]), finv[2 * k - n]);
    }
    ll res = 0;
    for (int k = (n + 1) / 2; k < n; k++) {
        int realact = act[i];
        sub(realact, act[k - 1]);
        add(res, mul(k, realact));
    }
    cout << res << "\n";
}


Compiler output:
a.cc:11:8: error: ISO C++ forbids declaration of 'add' with no type [-fpermissive]
   11 | inline add(int &a, int b) {
      |        ^~~
a.cc: In function 'int add(int&, int)':
a.cc:16:1: warning: no return statement in function returning non-void [-Wreturn-type]
   16 | }
      | ^
a.cc: At global scope:
a.cc:18:8: error: ISO C++ forbids declaration of 'sub' with no type [-fpermissive]
   18 | inline sub(int &a, int b) {
      |        ^~~
a.cc: In function 'int sub(int&, int)':
a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
   23 | }
      | ^
a.cc: In function 'int main()':
a.cc:56:27: error: 'i' was not declared in this scope
   56 |         int realact = act[i];
      |                           ^
a.cc:58:13: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'll' {aka 'long long int'}
   58 |         add(res, mul(k, realact));
      |             ^~~
a.cc:11:17: note:   initializing argument 1 of 'int add(int&, int)'
   11 | inline add(int &a, int b) {
      |            ~~~~~^
Language: C++

#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using bigint = boost::multiprecision::int256_t;

bigint M = 1000000007, m = 335790106025098313, n = 489373567, mask = 1152921504606846975;

inline bigint MR(bigint A){
    return (A + M * (m * A & mask)) >> 60;
}

inline bigint Prod(bigint lhs, bigint rhs){
    return MR(MR(lhs * rhs) * n);
}

long long int N;
bigint fact[10010101], ifact[10010101], ans;

int main(){
    scanf("%lld", &N);
    fact[0] = 1;
    for(int i = 1; i < N; ++i){
        fact[i] = Prod(fact[i - 1], i);
    }
    bigint n = M - 2, r = fact[N - 1];
    ifact[N - 1] = 1;
    while(n){
        if(n & 1){
            ifact[N - 1] = ifact[N - 1] * r % M;
        }
        n /= 2;
        r = r * r % M;
    }
    for(int i = N - 1; i > 0; --i){
        ifact[i - 1] = Prod(ifact[i], i);
    }
    ans = fact[N - 1] * (N - 1);
    for(int i = N / 2; i < N - 1; ++i){
        ans += M - Prod(Prod(fact[i], fact[i - 1]), ifact[i * 2 - N]);
    }
    ans %= M;
    cout << ans << endl;
    return 0;
}

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

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <boost/math/special_functions/factorials.hpp>
 
int64_t score(int n) {
  if (n == 2)
    return 1;
  if (n == 3)
    return 4;
  if (n == 4)
    return 16;
  return ((boost::math::factorial<int>(n-2) + score(n-1)) * (n-1) -2 * boost::math::factorial<int>(n-3)) % (10000000007);
}
 
int main() {
  int n;
  std::cin >> n;
  std::cout << score(n) << std::endl;
}

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

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <boost/math/special_functions/factorials.hpp>
 
int64_t score(int n) {
  if (n == 2)
    return 1;
  if (n == 3)
    return 4;
  if (n == 4)
    return 16;
  return ((boost::math::factorial(n-2) + score(n-1)) * (n-1) -2 * boost::math::factorial(n-3)) % (10000000007);
}
 
int main() {
  int n;
  std::cin >> n;
  std::cout << score(n) << std::endl;
}

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


Copy
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <boost/math/special_functions/factorials.hpp>
 
int64_t score(int n) {
  if (n == 2)
    return 1;
  if (n == 3)
    return 4;
  if (n == 4)
    return 16;
  return ((boost::math::factorial(n-2) + score(n-1)) * (n-1) -2 * boost::math::factorial(n-3)) % (10000000007);
}
 
int main() {
  int n;
  std::cin >> n;
  std::cout << score(n) << std::endl;
}

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

#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;

using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");
int mem[1000001][1000001]={};
ll int dp[1000001][1000001]={};

int dp(a,b){
    if(mem[a][b]==1) return dp[a][b];
    if(a==2&&b==1) return 1;
    if(a>b*2) return 0;
    if(a<b+2) return 0;
    mem[a][b]=1;
    return dp[a][b]=dp[a-1][b-1]+dp[a-2][b-1];
}
main(){
    int n;
    cin>>n;
    ll int ans=0;
    ll int per[1000001]={};
per[0]=1;
ll int temp=1;
rep2(i,1,1000000){
    per[i]=temp;
    temp*=(i+1);
    temp%=MOD;
}
    rep2(i,n%2+1,n-1)
    {
        ans+=dp[n][i]*per(n-i);
        ans%=MOD;
    }
    cout<<ans;
    return 0;
}

Compiler output:
a.cc:12:5: error: conflicting declaration 'int dp'
   12 | int dp(a,b){
      |     ^~
a.cc:10:8: note: previous declaration as 'long long int dp [1000001][1000001]'
   10 | ll int dp[1000001][1000001]={};
      |        ^~
a.cc:12:8: error: 'a' was not declared in this scope
   12 | int dp(a,b){
      |        ^
a.cc:12:10: error: 'b' was not declared in this scope
   12 | int dp(a,b){
      |          ^
a.cc:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   20 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:34:26: error: 'per' cannot be used as a function
   34 |         ans+=dp[n][i]*per(n-i);
      |                       ~~~^~~~~
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

ll N;

ll f(ll n){
	if(n==0) return 1;
	else return (n*frac(n))%mod;
}


int main(){
	cin>>N;
	ll ninzuu[N+1]={};
	ll frac[N+3]={};
	for(ll i=0;i<=N;i++) frac[i]=f(i);
	ll sum=0;
	if(N%2==0){
		for(ll i=N/2;i<=N;i++){
			if(i==N/2) ninzuu[i]=frac[i];
			else{
				ninzuu[i]=(frac[i]*frac[N-i]-ninzuu[i-1])%mod;
			}
			sum+=(i*ninzuu[i])%mod;
		}
	}
	else{
		for(ll i=(N+1)/2;i<=N;i++){
				ninzuu[i]=(frac[i]*frac[N-i]-ninzuu[i-1])%mod;
			sum+=(i*ninzuu[i])%mod;
		}
		
	}
	cout<<(sum)%mod<<endl;
	
	
	
	  return 0;
  }



Compiler output:
a.cc: In function 'll f(ll)':
a.cc:31:24: error: 'frac' was not declared in this scope
   31 |         else return (n*frac(n))%mod;
      |                        ^~~~
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

ll N;

ll frac(ll n){
	if(n==0) return 1;
	else return (n*frac(n))%mod;
}


int main(){
	cin>>N;
	ll ninzuu[N+1]={};
	ll frac[N+3];
	for(ll i=0;i<=N;i++) frac[i]=frac(i);
	ll sum=0;
	if(N%2==0){
		for(ll i=N/2;i<=N;i++){
			if(i==N/2) ninzuu[i]=frac[i];
			else{
				ninzuu[i]=(frac[i]*frac[N-i]-ninzuu[i-1])%mod;
			}
			sum+=(i*ninzuu[i])%mod;
		}
	}
	else{
		for(ll i=(N+1)/2;i<=N;i++){
				ninzuu[i]=(frac[i]*frac[N-i]-ninzuu[i-1])%mod;
			sum+=(i*ninzuu[i])%mod;
		}
		
	}
	cout<<(sum)%mod<<endl;
	
	
	
	  return 0;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:39:42: error: 'frac' cannot be used as a function
   39 |         for(ll i=0;i<=N;i++) frac[i]=frac(i);
      |                                      ~~~~^~~
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

ll N;

ll frac(int n){
	if(n==0) return 1;
	else return (n*frac(n))%mod;
}


int main(){
	cin>>N;
	ll ninzuu[N+1]={};
	ll frac[N+3];
	Rep(i,N+1) frac[i]=frac(i);
	ll sum=0;
	if(N%2==0){
		for(int i=N/2;i<=N;i++){
			if(i==N/2) ninzuu[i]=frac[i];
			else{
				ninzuu[i]=(frac[i]*frac[N-i]-ninzuu[i-1])%mod;
			}
			sum+=(i*ninzuu[i])%mod;
		}
	}
	else{
		for(int i=(N+1)/2;i<=N;i++){
				ninzuu[i]=(frac[i]*frac[N-i]-ninzuu[i-1])%mod;
			sum+=(i*ninzuu[i])%mod;
		}
		
	}
	cout<<(sum)%mod<<endl;
	
	
	
	  return 0;
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:39:32: error: 'frac' cannot be used as a function
   39 |         Rep(i,N+1) frac[i]=frac(i);
      |                            ~~~~^~~
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <deque>

using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
typedef map<int,int> mint;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef deque<pair<ll,ll>> dep;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=1e9+1000;
const int mod=1e9+7;
ll infi=1e18+100;

ll N;

ll frac(ll n){
	if(n==0) return 1;
	else return (n*frac(n))%mod;
}


int main(){
	cin>>N;
	ll ninzuu[N+1]={};
	ll frac[N+3];
	Rep(i,N+1) frac[i]=frac(i);
	ll sum=0;
	if(N%2==0){
		for(int i=N/2;i<=N;i++){
			if(i==N/2) ninzuu[i]=frac[i];
			else{
				ninzuu[i]=(frac[i]*frac[N-i]-ninzuu[i-1])%mod;
			}
			sum+=(i*ninzuu[i])%mod;
		}
	}
	else{
		for(int i=(N+1)/2;i<=N;i++){
				ninzuu[i]=(frac[i]*frac[N-i]-ninzuu[i-1])%mod;
			sum+=(i*ninzuu[i])%mod;
		}
		
	}
	cout<<(sum)%mod<<endl;
	
	
	
	  return 0;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:39:32: error: 'frac' cannot be used as a function
   39 |         Rep(i,N+1) frac[i]=frac(i);
      |                            ~~~~^~~
Language: C++

#include<bits/stdc++.h>
#define For(i,j,k)  for(ll i=j;i<=k;++i)
#define Dow(i,j,k)  for(ll i=k;i>=j;--i)
#define ll long long
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read()
{
	ll t=0,f=1;char c=gc();
	while(!isdigit(c))  {if(c=='-') f=-1;c=gc();}
	while(isdigit(c))   t=t*10+c-'0',c=gc();
	return t*f;
}
inline void write(ll x){if(x<0) {putchar('-');write(-x);return;}if(x>=10)    write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
inline void write_p(ll x){write(x);putchar(' ');}

ll n,mod=1e9+7,fac[1000010],N[1000010],ans,f[1000010],sum;
ll ksm(ll x,ll y){ll ans=1;while (y){if (y&1)(ans*=x)%=mod;(x*=x)%=mod;y>>=1;}return ans;}
ll	p(ll n,ll m){return fac[n]*N[m]%mod;}
ll C(ll n,ll m){return fac[n]*N[m]%mod*N[n-m]%mod;}
int main()
{
	n=read();
	if (n==2){puts("1");return 0;}
	fac[0]=1;
	For(i,1,n)
		fac[i]=fac[i-1]*i%mod;
	N[n]=ksm(fac[n],mod-2);
	Dow(i,0,n-1)N[i]=N[i+1]*(i+1)%mod;
	for (ll i=1;i<n;i++)if (i*2>=n)
	{
		f[i]=C((n-2-(i*2-n))/2+i*2-n,i*2-n)*fac[i]%mod*fac[n-1-i]%mod;
		(ans+=(f[i]-f[i-1])*i%mod+mod);
		ans%=mod;
	}
	writeln(ans);


Compiler output:
a.cc: In function 'int main()':
a.cc:41:22: error: expected '}' at end of input
   41 |         writeln(ans);
      |                      ^
a.cc:27:1: note: to match this '{'
   27 | {
      | ^
Language: Java

import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;
aaaaaaaaaaaaaaaa
public class Main{
	static Scanner s=new Scanner(System.in);
	
	int factsum[]=new int[1000001],fact[]=new int[1000001];
	private static final int MOD=1000000007;
	{
		factsum[1]=1;
		for(int i:rep(2,1000000)) {
			fact[i]=factsum[i]=(int)(((long)i*factsum[i-1])%MOD);
			factsum[i]+=fact[i-1];
			factsum[i]%=MOD;
		}
	}
	void solve(){
		int n=gInt();
		int min=(n+1)/2;
		int max=n-1;
		long r=0;
		for(int firstfill:rep(min,max)) {
			long v=(long)firstfill*fact[firstfill]%MOD*(factsum[n-1]-factsum[firstfill]+1)%MOD;
			System.err.println(v);
			r+=v;
			r%=MOD;
		}
		System.out.println(r);
	}

	public static void main(String[] $){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}


Compiler output:
Main.java:7: error: class, interface, enum, or record expected
aaaaaaaaaaaaaaaa
^
1 error
Language: C++

#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int n, s, x[100010];
long long p[100010];
ll ans,l,r;
int t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>s;
	l=1,r=n;
    for (int i=1;i<=n;i++)cin>>x[i]>>p[i]
    t=(p[1]>=p[n])?x[n]:x[1];
    while(1){
        if(s<x[l]||s>x[r]) break;
        if (p[l]>=p[r]) p[l] += p[r], --r, ans += abs(x[l] - t), t = x[l];
        else p[r] += p[l], ++l, ans += abs(x[r] - t), t = x[r];
    }
    ans += max(s-t,t-s);
	cout<<ans;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:35:42: error: expected ';' before 't'
   35 |     for (int i=1;i<=n;i++)cin>>x[i]>>p[i]
      |                                          ^
      |                                          ;
   36 |     t=(p[1]>=p[n])?x[n]:x[1];
      |     ~
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;

inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int maxn = 1e5 + 10;
int n, s, a[maxn], p[maxn], pos; ll ans;
int dfs(int l, int r)
{
	if (r <= pos)
	{
		ans = abs(s - a[l]);
		return a[l];
	}
	else if (l > pos)
	{
		ans = abs(a[r] - s);
		return a[r];
	}
	int np;
	if (p[l] >= p[r])
	{
		p[l] += p[r], np = dfs(l, r - 1), ans += abs(a[r] - np);
		return a[r];
	}
	else
	{
		p[r] += p[l], np = dfs(l + 1, r), ans += abs(np - a[l]);
		return a[l];
	}
}
int main()
{
	n = read(), s = read();
	for (int i = 1; i <= n; i ++)
		a[i] = read(), p[i] = read();
	pos = upper_bound(a + 1, a + 1 + n, s) - a - 1;
	dfs(1, n);
	printf("%lld\n", ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:15: error: 'upper_bound' was not declared in this scope
   46 |         pos = upper_bound(a + 1, a + 1 + n, s) - a - 1;
      |               ^~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;

int main(){
  int n,s;
  long long a[100000],b[100000],ko;
  cin>>n>>s;
  for (int i=0;i<n;i++) {
    cin>>a[i]>>b[i];
  }
	int x=0,y=n-1;
	while (x<=y){
      if (s<=a[x]){
        ko+=a[y]-s;
        break;
      }
      if (s>=a[y]){
        ko+=s-a[x];
        break;
      }
      if (b[x]>=b[y]){
        ko+=a[y]-a[x];
        while (x<y && b[x]>=b[y]){
          b[x]+=b[y--];
        }
      }
      else{
        ko+=a[y]-a[x];
        while (l<y && b[x]<b[y]) {
          b[y]+=b[x++];
        }
      }
    }
  cout<<ko;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:16: error: 'l' was not declared in this scope
   29 |         while (l<y && b[x]<b[y]) {
      |                ^
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node{
	int num,p;
}a[100010];
int s,n;
long long ans;
bool cmp(node a,node b)
{
	return a.p<b.p;
}
int main()
{
	scanf("%d%d",&n,&s);
	for(int i=1;i<=n;i++)
	scanf("%d%d",&a[i].p,&a[i].num);
	sort(a+1,a+n+1,cmp);
	int L=1,R=n;
	int bef=-1;

	while(a[L].p<=s && a[R].p=>s)
	{
		int now;
		if(a[L].num>=a[R].num)
		{
			now=false;
			a[L].num+=a[R].num;
		}
		else
		{
			now=true;
			a[R].num+=a[L].num;
		}
		if(now!=bef)
		{
			ans+=a[R].p-a[L].p;
			bef=now;
		}
		if(a[L].num>=a[R].num) R--;
		else L++;
	}
	if(a[L].p<s) ans+=s-a[L].p;
	else ans+=a[R].p-s;
	printf("%lld",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:35: error: expected primary-expression before '>' token
   23 |         while(a[L].p<=s && a[R].p=>s)
      |                                   ^
Language: C++

#include <bits/stdc++.h>

const int N = 100000;

int x[N];
long long p[N];

int main()
{
    int n, s;
    scanf("%d%d", &n, &s);
    for (int i = 0, a; i < n; ++ i) {
        scanf("%d%d", x + i, &a);
        p[i] = a;
    }
    int i = 0;
    int j = n - 1;
    while (x[i] < s && s < x[j]) {
        if (p[i] > p[j]) {
            p[i] += p[j];
            ord.push_back(x[j --]);
        } else {
            p[j] += p[i];
            ord.push_back(x[i ++]);
        }
    }
    if (x[j] <= s) {
        for (; i <= j; ++ i) {
            ord.push_back(x[i]);
        }
    } else {
        for (; i <= j; -- j) {
            ord.push_back(x[j]);
        }
    }
    ord.push_back(s);
    long long result = 0LL;
    for (size_t i = ord.size() - 1; i; i --) {
        result += std::abs(ord[i] - ord[i - 1]);
    }
    printf("%lld\n", result);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:13: error: 'ord' was not declared in this scope
   21 |             ord.push_back(x[j --]);
      |             ^~~
a.cc:24:13: error: 'ord' was not declared in this scope
   24 |             ord.push_back(x[i ++]);
      |             ^~~
a.cc:29:13: error: 'ord' was not declared in this scope
   29 |             ord.push_back(x[i]);
      |             ^~~
a.cc:33:13: error: 'ord' was not declared in this scope
   33 |             ord.push_back(x[j]);
      |             ^~~
a.cc:36:5: error: 'ord' was not declared in this scope
   36 |     ord.push_back(s);
      |     ^~~
Language: C++

#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 200010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,S;

int x[maxn],Ans[maxn],cnt;

ll p[maxn];

int main(){
	read(n,S);
	REP(i,1,n)read(x[i],p[i]);
	ll ans=0;
	int l=1,r=n;
	while(x[l]<S&&s<x[r]){
		if(p[l]>=p[r]){
			p[l]+=p[r];
			Ans[++cnt]=x[r];
			r--;
		}
		else{
			p[r]+=p[l];
			Ans[++cnt]=x[l];
			l++;
		}
	}
	if(x[l]>S)RREP(i,r,l)Ans[++ans]=x[i];
	if(x[r]<S)REP(i,l,r)Ans[++ans]=x[i];
	Ans[++cnt]=S;
	REP(i,1,cnt-1)ans+=abs(Ans[i]-Ans[i+1]);
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:23: error: 's' was not declared in this scope
   57 |         while(x[l]<S&&s<x[r]){
      |                       ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std ;
const int N = 200010 ; 
struct rec{
	int a,b,id ;
	friend inline bool operator < (const rec x,const rec y){
		return 1ll*x.a*y.b < 1ll*x.b*y.a ;  
	}
};
priority_queue<rec> q ;
int n,fa[N],f[N],cnt[N][2] ; 
inline int get(int x){
	return x == f[x] ? x : f[x] = get(f[x]) ; 
}
int main(){
	//freopen("in.txt","r",stdin) ; 
	cin >> n ;
	for(int i = 2 ; i <= n ; i++) scanf("%d",&fa[i]),f[i] = i ; 
	for(int i = 1 ; i <= n ; i++){ int val ; scanf("%d",&val) ; cnt[i][val]++ ; }
	for(int i = 2 ; i <= n ; i++) q.push((rec){cnt[i][0],cnt[i][1],i}) ;
	f[1] = 1 ; long long ans = 0 ;
	while(!q.empty()){
		rec x = q.top() ; q.pop() ; 
		int id = get(x.id),a = x.a,b = x.b ;  
		if(cnt[id][0] != a || cnt[id][1] != b) continue ;
		int y = get(fa[id]) ;
		ans += 1ll*cnt[y][1]*a ;
		cnt[y][0] += a ; cnt[y][1] += b ;
		f[id] = y ;
		if(y > 1) q.push((rec){cnt[y][0],cnt[y][1],y}) ; 
	}
	cout << ans << endl; 
	return 0 ; 
}

Compiler output:
a.cc:12:1: error: 'priority_queue' does not name a type
   12 | priority_queue<rec> q ;
      | ^~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:22:39: error: 'q' was not declared in this scope
   22 |         for(int i = 2 ; i <= n ; i++) q.push((rec){cnt[i][0],cnt[i][1],i}) ;
      |                                       ^
a.cc:24:16: error: 'q' was not declared in this scope
   24 |         while(!q.empty()){
      |                ^
Language: C++

#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MKP make_pair

const int N=2e5+5;
ll ans;
int n,fa[N],pre[N],val[N],num[N];
int find(int x) {return fa[x]==x?fa[x]:fa[x]=find(fa[x]);}

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

struct Node {
	ll sum[2];int id;
	Node operator + (const Node&b) const {return (Node){sum[0]+b.sum[0],sum[1]+b.sum[1],id};}
	bool operator == (const Node&b) const {return sum[0]==b.sum[0]&&sum[1]==b.sum[1]&&id==b.id;}
	bool operator < (const Node&b) const {
		if(sum[0]*b.sum[1]==sum[1]*b.sum[0])
			return (sum[0]==b.sum[0])?((sum[1]==b.sum[1])?id<b.id:sum[1]<b.sum[1]):sum[0]<b.sum[0];
		return sum[0]*b.sum[1]<sum[1]*b.sum[0];
	}
}P[N];
struct Queue {
    priority_queue <Node> q1,q2;
    inline void add(Node t) {q1.push(t);}
    inline void del(Node t) {q2.push(t);}
    Node top() {
        while(!q1.empty()&&!q2.empty()&&q1.top()==q2.top()) q1.pop(),q2.pop();
        return q1.top();
    }
}Q;

int main() {
	IN(n);
	for(int i=2;i<=n;++i) IN(pre[i]);
	for(int i=1;i<=n;++i) IN(val[i]),fa[i]=i;
	for(int i=1;i<=n;++i) P[i].sum[0]=!val[i],P[i].sum[1]=val[i],P[i].id=i;
	for(int i=2;i<=n;++i) Q.add(P[i]);
	for(int i=2;i<=n;++i) {
		Node now=Q.top;Q.del(now);
		int u=now.id,f=find(pre[u]);
		if(f!=1) Q.del(P[f]);
		ans+=P[f].sum[1]*P[u].sum[0],P[f]=P[f]+P[u],fa[u]=f;
		if(f!=1) Q.add(P[f]);
	}
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:28: error: invalid use of non-static member function 'Node Queue::top()'
   51 |                 Node now=Q.top;Q.del(now);
      |                          ~~^~~
a.cc:38:10: note: declared here
   38 |     Node top() {
      |          ^~~
Language: C++

#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MKP make_pair

const int N=2e5+5;
ll ans;
int n,fa[N],pre[N],val[N],num[N];
int find(int x) {return fa[x]==x?fa[x]:fa[x]=find(fa[x]);}

template <typename _Tp> inline void IN(_Tp&x) {
	char ch;bool flag=0;x=0;
	while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	if(flag) x=-x;
}

struct Node {
	ll sum[2];int id;
	Node operator + (const Node&b) const {return (Node){sum[0]+b.sum[0],sum[1]+b.sum[1],id};}
	bool operator == (const Node&b) const {return sum[0]==b.sum[0]&&sum[1]==b.sum[1]&&id==b.id;}
	bool operator < (const Node&b) const {
		if(sum[0]*b.sum[1]==sum[1]*b.sum[0])
			return (sum[0]==b.sum[0])?((sum[1]==b.sum[1])?id<b.id:sum[1]<b.sum[1]):sum[0]<b.sum[0];
		return sum[0]*b.sum[1]<sum[1]*b.sum[0];
	}
}P[N];
struct Queue {
    priority_queue <Node> q1,q2;
    inline void add(Node t) {q1.push(t);}
    inline void del(Node t) {q2.push(t);}
    Node top() {
        while(!q1.empty()&&!q2.empty()&&q1.top()==q2.top()) q1.pop(),q2.pop();
        return q1.top();
    }
}Q;

int main() {
	IN(n);
	for(int i=2;i<=n;++i) IN(pre[i]);
	for(int i=1;i<=n;++i) IN(val[i]),fa[i]=i;
	for(int i=1;i<=n;++i) P[i].sum[0]=!val[i],P[i].sum[1]=val[i],P[i].id=i;
	for(int i=2;i<=n;++i) Q.add(P[i]);
	while(S.size()>1) {
		Node now=Q.top;Q.del(now);
		int u=now.id,f=find(pre[u]);
		if(f!=1) Q.del(P[f]);
		ans+=P[f].sum[1]*P[u].sum[0],P[f]=P[f]+P[u],fa[u]=f;
		if(f!=1) Q.add(P[f]);
	}
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:15: error: 'S' was not declared in this scope
   50 |         while(S.size()>1) {
      |               ^
a.cc:51:28: error: invalid use of non-static member function 'Node Queue::top()'
   51 |                 Node now=Q.top;Q.del(now);
      |                          ~~^~~
a.cc:38:10: note: declared here
   38 |     Node top() {
      |          ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
inline int read(){
	register int x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
int n,a[N],b[N],f[N],si[N],fa[N];
int find(int x){
	return f[x]?f[x]=find(f[x]):x;
}
struct each{
	int x,y,id;
	each (int xx=0,int yy=0,int dd=0){
		x=xx,y=yy,id=dd;
	}
	operator < (const each k) const{
		return x*k.y<k.x*y;
	}
};
priority_queue<each>que;
long long ans;
int main(){
	//freopen("1.out","w",stdout);
	//freopen("1.in","r",stdin);
	n=read();
	for(int i=2;i<=n;i++)	fa[i]=read();
	for(int i=1;i<=n;i++)	a[i]=read();
	for(int i=1;i<=n;i++)	si[i]=1;
	for(int i=2;i<=n;i++)
		if(!a[i])	f[i]=find(fa[i]),si[f[i]]+=si[i];
	for(int i=1;i<=n;i++)	if(a[i])	b[i]=1,ans+=(--si[i]);
	for(int i=2;i<=n;i++)	if(a[i])	que.push(each(si[i],b[i],i));
	for(int i=1;i<=n;i++)	fa[i]=find(fa[i]);
	for(int i=1;i<=n;i++)	f[i]=0;
	while(!que.empty()){
		each x=que.top();	que.pop();
		int k=x.id,y=find(fa[k]);
		if(!y||x.x!=si[k])	continue;
		ans+=1LL*b[y]*x.x,si[y]+=si[k],b[y]+=b[k],f[k]=y;
		que.push(each(si[y],b[y],y));
	}
	printf("%lld\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int read()':
a.cc:5:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    5 |         register int x=0;
      |                      ^
a.cc:6:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
    6 |         register char ch=getchar();
      |                       ^~
a.cc: At global scope:
a.cc:20:9: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
   20 |         operator < (const each k) const{
      |         ^~~~~~~~
Language: C++

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

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct node{int x,y;}G[N];
struct semi{int x,t;};
inline operator <(const node &A,const node &B)
{
	return 1ll*A.x*B.y<1ll*B.x*A.y;
}
inline operator <(const semi &A,const semi &B)
{
	return G[A.x]<G[B.x];
}
int fa[N],p[N],n,tim[N];
priority_queue<semi> q;
inline int getfa(int x)
{
	return fa[x]==x? x:fa[x]=getfa(fa[x]);
}
int main()
{
	n=read(); 
	for(int i=2;i<=n;i++) p[i]=read();
	for(int i=1;i<=n;i++)
	{
		int xx=read();
		if(!xx) G[i].x++; else G[i].y++;
		q.push((semi){i,++tim[i]});
		fa[i]=i;
	}
	long long Ans=0;
	while(!q.empty())
	{
		while(q.top().t!=tim[q.top().x]&&!q.empty()) q.pop();
		if(q.empty()) break;
		semi tmp=q.top(); q.pop();
		if(tmp.x==1) continue;
		int lx=tmp.x,gs=getfa(p[lx]);
		Ans+=1ll*G[gs].y*G[lx].x;
		fa[lx]=gs; G[gs].x+=G[lx].x;
		G[gs].y+=G[lx].y;
		if(gs!=1) q.push((semi){gs,++tim[gs]});
	}
	cout << Ans << endl;
	return 0;
}

Compiler output:
a.cc:14:8: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
   14 | inline operator <(const node &A,const node &B)
      |        ^~~~~~~~
a.cc:18:8: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive]
   18 | inline operator <(const semi &A,const semi &B)
      |        ^~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	int s;
	cin >> s;
	int sum = 700;
	if (s[0] == 'o')
		sum += 100;
	if (s[1] == 'o')
		sum += 100;
	if (s[2] == 'x')
		sum += 100;
	cout << sum << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: invalid types 'int[int]' for array subscript
   11 |         if (s[0] == 'o')
      |              ^
a.cc:13:14: error: invalid types 'int[int]' for array subscript
   13 |         if (s[1] == 'o')
      |              ^
a.cc:15:14: error: invalid types 'int[int]' for array subscript
   15 |         if (s[2] == 'x')
      |              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int counter=0;
  cin >> s;
  if(s[0]=="o") ++counter;
  if(s[1]=="o") ++counter;
  if(s[2]=="o") ++counter;
  
    cout << 700+100*counter << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    8 |   if(s[0]=="o") ++counter;
a.cc:9:10: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    9 |   if(s[1]=="o") ++counter;
a.cc:10:10: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   10 |   if(s[2]=="o") ++counter;
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  int counter=0;
  cin >> s;
  if(s[0]=="o") ++counter
  if(s[1]=="o") ++counter
  if(s[2]=="o") ++counter
  
    cout << 700+100*counter << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    8 |   if(s[0]=="o") ++counter
a.cc:8:26: error: expected ';' before 'if'
    8 |   if(s[0]=="o") ++counter
      |                          ^
      |                          ;
    9 |   if(s[1]=="o") ++counter
      |   ~~
Language: C++

//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
int main()
{
	MaRiaMa;
	string s;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'o')
			sum += 100;
	}
	
	cout << 700 + sum;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:6:19: error: 'ios' has not been declared
    6 | #define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
      |                   ^~~
a.cc:10:9: note: in expansion of macro 'MaRiaMa'
   10 |         MaRiaMa;
      |         ^~~~~~~
a.cc:6:44: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    6 | #define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
      |                                            ^~~
a.cc:10:9: note: in expansion of macro 'MaRiaMa'
   10 |         MaRiaMa;
      |         ^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:6:56: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
    6 | #define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
      |                                                        ^~~~
a.cc:10:9: note: in expansion of macro 'MaRiaMa'
   10 |         MaRiaMa;
      |         ^~~~~~~
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:11:9: error: 'string' was not declared in this scope
   11 |         string s;
      |         ^~~~~~
a.cc:11:9: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:12:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   12 |         cin >> s;
      |         ^~~
      |         std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:12:16: error: 's' was not declared in this scope
   12 |         cin >> s;
      |                ^
a.cc:20:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |         cout << 700 + sum;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~