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

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

int A[200005], B[200005];

inline int mod(int i, int m) { return i >= m ? i - m : i; }

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> A[i];
	for (int i = 0; i < N; ++i) cin >> B[i];

	priority_queue<pair<int, int>> pq;
	for (int i = 0; i < N; ++i) {
		if (A[i] < B[i]) {
			pq.emplace(B[i], i);
		}
		else if (A[i] > B[i]) {
			cout << -1 << '\n';
			return 0;
		}
	}

	ll ans = 0;
	while (!pq.empty()) {
		pair<int, int> p = pq.top();
		pq.pop();
		int i = p.second, d = B[mod(i - 1 + N, N)] + B[mod(i + 1, N)];
		if (B[i] - A[i] < d) {
			cout << -1 << '\n';
			return 0;
		}
		ans += (B[i] - A[i]) / d;
		B[i] -= d * ((B[i] - A[i]) / d);
		if (A[i] < B[i]) {
			pq.emplace(B[i], i);
		}
	}
	cout << ans << '\n';
	return 0;
}


Compiler output:
a.cc:3:1: error: 'typdef' does not name a type; did you mean 'typedef'?
    3 | typdef long long ll;
      | ^~~~~~
      | typedef
a.cc: In function 'int main()':
a.cc:26:9: error: 'll' was not declared in this scope
   26 |         ll ans = 0;
      |         ^~
a.cc:35:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |                 ans += (B[i] - A[i]) / d;
      |                 ^~~
      |                 abs
a.cc:41:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   41 |         cout << ans << '\n';
      |                 ^~~
      |                 abs
Language: C++

#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef pair<int,int> pii;
const int MN = 2e5+5;
int N,A[MN],B[MN];
priority_queue<pii> PQ;
int main()
{
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++){
        cin >> B[i];
        if(B[i]<A[i]){
            cout << -1;
            return 0;
        }
        if(B[i]>A[i]) PQ.emplace(B[i],i);
    }
    int v,x;
    ll ans=0;
    while(PQ.size()){
        tie(v,x) = PQ.top();
        PQ.pop();
        if(B[x]-(B[(x-1+N)%N]+B[(x+1)%N])<A[x]){
            cout << -1;
            return 0;
        }
        int cnt = (B[x]-A[x])/(B[(x-1+N)%N]+B[(x+1)%N]);
        B[x] -= cnt*(B[(x-1+N)%N]+B[(x+1)%N]);
        ans += cnt;
        if(B[x]>A[x]) PQ.emplace(B[x],x);
    }
    cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'll' was not declared in this scope
   22 |     ll ans=0;
      |     ^~
a.cc:32:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |         ans += cnt;
      |         ^~~
      |         abs
a.cc:35:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |     cout << ans;
      |             ^~~
      |             abs
Language: C++

#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 2e5+5;
int N,A[MN],B[MN];
int main()
{
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<N; i++) cin >> B[i];
    for(int i=0; i<N; i++){
        if(A[i]>B[i]){
            cout << -1;
            return 0;
        }
    }
    int ans = 0;
    while(1){
        bool ch = 0;
        for(int i=0; i<N; i++){
            for(int i=0; i<N; i++){
            if(A[i]>B[i]){
                cout << -1;
                return 0;
            }
            if(A[i]==B[i]) continue;
            if(B[i]>B[(i-1+N)%N]&&B[i]>B[(i+1)%N]){
                B[i] -= B[(i-1+N)%N]+B[(i+1)%N];
                if(A[i]>B[i]){
                    cout << -1;
                    return 0;
                }
                ans++;
                ch = 1;
                break;
            }
        }
        if(!ch){
            for(int i=0; i<N; i++){
                if(A[i]!=B[i]){
                    cout << -1;
                    return 0;
                }
            }
            break;
        }
    }
    cout << ans;
}


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

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

using namespace std;

#define N 666666
struct str{
	int val;
	int id;
	 bool operator < (const str &b)const
	 {
	 	return val<b.val;
	 } 
};
int a[N],b[N],arr[N];
priority_queue<str> q;
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		arr[i]=a[i];
	} 
	int f=1;
	for(int i=1;i<=n;i++){
		cin>>b[i];
		if(b[i]<a[i]) f=0;
		q.push((str){b[i],i});
	} 
	if(!f){
	//	cout<<"==";
		cout<<"-1";
		return 0; 
	}
	f=1;
	int ans=0;
	while(!q.empty()){
		struct str t=q.top();
		q.pop();
		int id=t.id;
		if(id==1){
			int temp=b[t.id+1]+b[n];
			if(t.val-temp<a[id]){
				f=0;
			}
			int add=(t.val-a[id])/temp;
			ans+=add;
			int cnt=(t.val-a[id])%temp;
			b[id]-=add*temp;
			int st=a[id]+cnt;
			if(cnt)
				q.push((str){st,t.id});
		}else if(id==n){
			int temp=b[t.id-1]+b[1];
			if(t.val-temp<a[id]){
				f=0;
			}
			int add=(t.val-a[id])/temp;
			ans+=add;
			int cnt=(t.val-a[id])%temp;
			b[id]-=add*temp;
			int st=a[id]+cnt;
			if(cnt)
				q.push((str){st,t.id});
		}else{
			int temp=b[t.id-1]+b[1+t.id];
			if(t.val-temp<a[id]){
				f=0;
			}
			int add=(t.val-a[id])/temp;
			ans+=add;
			int cnt=(t.val-a[id])%temp;
			int st=a[id]+cnt;
			b[id]-=add*temp;
			if(cnt)
				q.push((str){st,t.id});
		}
		if(!f){
		//	cout<<ans<<" "<<t.id<<'\n';
			break;
		}
	}
	if(!f) cout<<"-1";else cout<<ans;
	return 0;
}

/*
3
1 2 3
1 2 6
1 9 6
16 9 6
31 9 6
*/

Compiler output:
a.cc:2:21: error: stray '#' in program
    2 | using namespace std;#include<bits/stdc++.h>
      |                     ^
a.cc:2:22: error: 'include' does not name a type
    2 | using namespace std;#include<bits/stdc++.h>
      |                      ^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef stack<int> S;
const int N=200200;
int n;
int a[N];
int b[N];
S s;
#define M \
	int l=(x-1+n)%n;\
	int r=(x+1)%n
void c(int x){
	M;
	if(b[x]>b[l]&&b[x]>b[r]){
		// cerr<<"< "<<x<<" "<<b[x]<<endl;
		s.push(x);
	}
}
void gg(){
	puts("-1");
	exit(0);
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	for(int i=0;i<n;i++){
		c(i);
	}
	int ans=0;
	while(!s.empty()){
		int x=s.top();
		s.pop();
		M;
		// cerr<<x<<" "<<l<<" "<<r<<endl;
		// cerr<<"["<<x<<"] "<<b[x];
		LL db=b[l]+b[r];
		LL da=b[x]-a[x];
		if(da==0){
			continue;
		}
		LL o=max(da/db,1);
		ans+=o;
		b[x]-=db*o;
		// cerr<<" => "<<b[x]<<endl;
		if(b[x]<a[x]){
			gg();
		}
		c(x);
		c(l);
		c(r);
	}
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			gg();
		}
	}
	printf("%d\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:25: error: no matching function for call to 'max(LL, int)'
   47 |                 LL o=max(da/db,1);
      |                      ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:47:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   47 |                 LL o=max(da/db,1);
      |                      ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:47:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |                 LL o=max(da/db,1);
      |                      ~~~^~~~~~~~~
Language: C++

 #include <bits/stdc++.h>
 #define ll long long
#define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define test int t; cin >> t; while(t--)
 #define inp(n) int n;cin >> n;
 #define mp make_pair
 #define pb push_back
 #define forl(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second

using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)   return a;  return gcd(b, a % b);
}

 int32_t main()
{
     fast;
    
//    test
//    {
//       
//    }
    ll n;
    cin>>n;ll ans=0;
    ll arr[200005],brr[200005];
    for(ll i=0;i<n;i++)cin>>arr[i]; for(ll j=0;j<n;j++)cin>>brr[j];
    priority_queue < pair < ll, ll> > pq;
    for(ll i=0;i<n;i++)
    {
        if(brr[i]>=arr[i])
        pq.push( mp(brr[i],i) );// check for -1 ..//
        else return cout<<"-1"<<endl,0;
    }
    int pre=-1;
    while(!pq.empty())
    {
        ll val,ind;
        auto it=pq.top();
        pq.pop();
        val=it.x;ind=it.y;
        if(pre==ind) {return cout<<"-1",0;}else pre = ind;
    
        brr[ind] = arr[ind]+(val-arr[ind])%(brr[(ind-1+n)%n]+brr[(ind+1)%n]);
        ans+=(val-arr[ind])/(brr[(ind-1+n)%n]+brr[(ind+1)%n]);
        if(b[ind]<a[ind]){return cout<<"-1",0;}
        if(brr[ind]>arr[ind])
        {
            pq.push(mp(brr[ind],ind));
        }
        
    }
    cout<<ans<<endl;
    return 0;
 }
  














Compiler output:
a.cc: In function 'int32_t main()':
a.cc:52:12: error: 'b' was not declared in this scope
   52 |         if(b[ind]<a[ind]){return cout<<"-1",0;}
      |            ^
a.cc:52:19: error: 'a' was not declared in this scope
   52 |         if(b[ind]<a[ind]){return cout<<"-1",0;}
      |                   ^
Language: C++

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

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

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


int main(){
  
  int n;
  cin>>n;
  int a[n],b[n];
  REP(i,n){
    cin>>a[i];
  }
  REP(i,n){
    cin>>b[i];
  }
  priority_queue<pair<int, int>> q;
  REP(i,n){
    q.push(make_pair(b[i],i));
  }
  long long ans = 0;
  while(!q.empty()){
    int val = q.top().first;
    int i = q.top().second;
    q.pop();
    if(val == a[i]){
      continue;
    }
    if(val < a[i]){
      cout<<-1<<endl;
      retrurn 0;
    }
    int l = i - 1, r = i + 1;
    if(l < 0){
      l = n - 1;
    }
    if(r >= n){
      r = 0;
    }
    long long cnt;
    cnt = (b[i] - a[i])/(b[l] + b[r]);
    ans += cnt;
    b[i] -= cnt*(b[l] + b[r]);
    q.push(make_pair(b[i],i));
  }
  cout<<ans<<endl; 
  return 0; 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:91:7: error: 'retrurn' was not declared in this scope
   91 |       retrurn 0;
      |       ^~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

struct bnum { ll i; ll n; };

auto bgr = [](bnum x, bnum y) { return x.n<y.n; };

int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  ll B[N]; rep(i,N) cin >> B[i];
  priority_queue<bnum,vector<bnum>,decltype(bgr)> pb(bgr);
  rep(i,N) pb.push({i,B[i]});

  ll result = 0;
  while (pb.size()) {
    bnum now = pb.top(); pb.pop();
    int l = (now.i-1+N)%N, r = (now.i+1)%N;
    int count = (now.n-A[now.i]) / (B[l]+B[r]);
    if (count) {
      no = 0;
      B[now.i] -= count * (B[l]+B[r]);
      result += count;
      if (B[now.i]!=A[now.i]) pb.push({now.i,B[now.i]});
    }
    else if (B[now.i]!=A[now.i]) { result = -1; break; }
  }
  cout << result << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:7: error: 'no' was not declared in this scope; did you mean 'now'?
   34 |       no = 0;
      |       ^~
      |       now
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 9;

int n, ans, a[N], b[N];

inline int nxt(int x) {
	return x == n ? 1 : x + 1;
}

inline int lxt(int x) {
	return x == 1 ? n : x - 1;
}

typedef pair<int, int> P;

priority_queue<P> que;

void solve() {
	for (int i = 1; i <= n; ++i) {
		que.push(make_pair(b[i], i));
	}
	while (!que.empty()) {
		P top = que.top(); que.pop();
		if (a[x] == b[x]) continue
		int x = top.second;
		int p = b[lxt(x)] + b[nxt(x)];
		if (b[x] - p < a[x]) {
			puts("-1");
			return ;
		} else {
			int d = (b[x] - a[x]) / p;
			ans += d;
			b[x] -= d * p;
			que.push(make_pair(b[x], x));
		}
	}
	printf("%d\n", ans);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) 	
		scanf("%d", &a[i]);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &b[i]);
	solve();
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:27:23: error: 'x' was not declared in this scope
   27 |                 if (a[x] == b[x]) continue
      |                       ^
a.cc:27:43: error: expected ';' before 'int'
   27 |                 if (a[x] == b[x]) continue
      |                                           ^
      |                                           ;
   28 |                 int x = top.second;
      |                 ~~~
Language: C++

#include<Bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

typedef unsigned long long ULL;

const int maxn=2e5+5;
const ULL P=1e9+7;

struct QST{
	int i,b;
};
bool operator < (const QST &a,const QST &b) {return a.b<b.b;}

int n,a[maxn],b[maxn];
ULL hs[maxn];
priority_queue<QST> Q;

int main()
{
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	fo(i,1,n) scanf("%d",&b[i]);
	
	hs[0]=1;
	fo(i,1,n) hs[i]=hs[i-1]*P;
	ULL hsa=0, hsb=0;
	fo(i,1,n) hsa+=hs[i]*a[i], hsb+=hs[i]*b[i];
	
	fo(i,1,n) Q.push((QST){i,b[i]});
	int ans=0;
	while (!Q.empty() && hsa!=hsb)
	{
		QST tp=Q.top(); Q.pop();
		int i=tp.i;
		if (b[i]>a[i] && b[i]>=b[i%n+1]+b[(i==1)?n:i-1])
		{
			int sum=b[i%n+1]+b[(i==1)?n:i-1];
			if (a[i]>sum && (b[i]-a[i])%sum!=0) {ans=-1; break;}
			int d=min(b[i]-a[i],b[i]-b[i]%sum);
			hsb=hsb-b[i]*hs[i]+(b[i]-d)*hs[i];
			b[i]-=d;
			ans+=d/sum;
			if (hsa==hsb) break;
			Q.push((QST){i,b[i]});
		}
	}
	if (hsa!=hsb) ans=-1;
	
	printf("%d\n",ans);
}

Compiler output:
a.cc:1:9: fatal error: Bits/stdc++.h: No such file or directory
    1 | #include<Bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,a[200010],b[200010]
long long ans=0;
bool w=false;
struct node{
	int pos,val;
	bool operator <(const node &b)const{
		return val<b.val;
	}
};
priority_queue<node>q;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		node tmp={i,b[i]};
		q.push(tmp);
	}
	while(q.size()){
		node now=q.top();q.pop();
		int l=(now.pos-2+n)%n+1,r=now.pos%n+1;
      	if(b[now.pos]==a[now.pos]) continue;
		if(b[now.pos]-b[l]-b[r]<a[now.pos]){
			puts("-1");
			return 0;
		}
		int d=b[now.pos]-a[now.pos];
		ans+=d/(b[l]+b[r]);
		b[now.pos]=d%(b[l]+b[r])+a[now.pos];
		if(b[now.pos]==a[now.pos]) continue;
		node tmp={now.pos,b[now.pos]};
		q.push(tmp);
	}
	printf("%lld\n",ans); 
}


Compiler output:
a.cc:4:1: error: expected initializer before 'long'
    4 | long long ans=0;
      | ^~~~
a.cc: In function 'int main()':
a.cc:17:29: error: 'b' was not declared in this scope
   17 |                 scanf("%d",&b[i]);
      |                             ^
a.cc:24:12: error: 'b' was not declared in this scope
   24 |         if(b[now.pos]==a[now.pos]) continue;
      |            ^
a.cc:25:20: error: 'b' was not declared in this scope
   25 |                 if(b[now.pos]-b[l]-b[r]<a[now.pos]){
      |                    ^
a.cc:29:23: error: 'b' was not declared in this scope
   29 |                 int d=b[now.pos]-a[now.pos];
      |                       ^
a.cc:30:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |                 ans+=d/(b[l]+b[r]);
      |                 ^~~
      |                 abs
a.cc:36:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   36 |         printf("%lld\n",ans);
      |                         ^~~
      |                         abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,a[200010],b[200010]
long long ans=0;
bool w=false;
struct node{
	int pos,val;
	bool operator <(const node &b)const{
		return val<b.val;
	}
};
priority_queue<node>q;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		node tmp={i,b[i]};
		q.push(tmp);
	}
	while(q.size()){
		node now=q.top();q.pop();
		int l=(now.pos-2+n)%n+1,r=now.pos%n+1;
		if(b[now.pos]-b[l]-b[r]<a[now.pos]){
			puts("-1");
			return 0;
		}
		int d=b[now.pos]-a[now.pos];
		ans+=d/(b[l]+b[r]);
		b[now.pos]=d%(b[l]+b[r])+a[now.pos];
		if(b[now.pos]==a[now.pos]) continue;
		node tmp={now.pos,b[now.pos]};
		q.push(tmp);
	}
	printf("%lld\n",ans); 
}


Compiler output:
a.cc:4:1: error: expected initializer before 'long'
    4 | long long ans=0;
      | ^~~~
a.cc: In function 'int main()':
a.cc:17:29: error: 'b' was not declared in this scope
   17 |                 scanf("%d",&b[i]);
      |                             ^
a.cc:24:20: error: 'b' was not declared in this scope
   24 |                 if(b[now.pos]-b[l]-b[r]<a[now.pos]){
      |                    ^
a.cc:28:23: error: 'b' was not declared in this scope
   28 |                 int d=b[now.pos]-a[now.pos];
      |                       ^
a.cc:29:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |                 ans+=d/(b[l]+b[r]);
      |                 ^~~
      |                 abs
a.cc:35:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |         printf("%lld\n",ans);
      |                         ^~~
      |                         abs
Language: C++


#include <bits/stdc++.h>
#include <sys/time.h>
#include <unistd.h>
using namespace std;
#define i64         int64_t
#define rep(i, n)   for(i64 i = 0; (i) < ((i64)(n)); ++(i))
#define bit(n)      (((i64)1)<<((i64)(n)))
#define sz(v)       ((i64)((v).size()))



void kill()
{
  cout << -1 << endl;
  exit(0);
}

int main()
{
  i64 n;
  cin >> n;
  vector<i64> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];

  priority_queue<pair<i64, i64>> q;
  rep(i, n) q.push(make_pair(b[i], i));

  i64 ans = 0;
  while(0 < sz(q)){
    // DEBUG(q);
    i64 i = q.top().second;
    q.pop();
    if(b[i] == a[i]) continue;
    if(b[i] < a[i]) kill();

    i64 prev = (i - 1 + n) % n;
    i64 next = (i + 1 + n) % n;
    i64 total = b[prev] + b[next];
    i64 times = (b[i]- a[i]) / total;
    // DEBUG(b[i], total, times);
    if(times == 0) kill();
    ans += times;
    b[i] -= total * times;
    q.push(make_pair(b[i], i));
  }

  cout << ans << endl;
}
#endif


Compiler output:
a.cc:51:2: error: #endif without #if
   51 | #endif
      |  ^~~~~
Language: C++

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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n],b[n];
	multiset<pair<long long,int>> memo;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin>>b[i];
		memo.insert(make_pair(b[i],i));
	}
	int cnt=0;
	long long ans=0LL;
	while (cnt!=n)
	{
		for (auto i = memo.end(); ; --i)
		{
			if (i==memo.end())
			{
				--i;
			}
			auto p=*i;
			if (a[p.second]==b[p.second])
			{
				memo.erase(i);
				++cnt;
				break;
			}
			int l=(p.second-1+n)%n,r=(p.second+1)%n;
			if (b[p.second]>b[l]+b[r])
			{
				while (a[p.second!=b[p.second]]&&b[p.second]>p[l]+p[r])
				{
					b[p.second]-=b[l]+b[r];
					++ans;
				}
				if (a[p.second]==b[p.second])
				{
					++cnt;
				}
				else
				{
					memo.insert(make_pair(b[p.second],p.second));
				}
				break;
			}
			if (i==memo.begin())
			{
				cout<<"-1\n";
				return 0;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:39:79: error: no match for 'operator[]' (operand types are 'std::pair<long long int, int>' and 'int')
   39 |                                 while (a[p.second!=b[p.second]]&&b[p.second]>p[l]+p[r])
      |                                                                               ^
a.cc:39:84: error: no match for 'operator[]' (operand types are 'std::pair<long long int, int>' and 'int')
   39 |                                 while (a[p.second!=b[p.second]]&&b[p.second]>p[l]+p[r])
      |                                                                                    ^
Language: C++

#include <bits/stdc++.h>
#define int long long
using namespace std;
//typedef long long ll;
int A[100005],B[100005];
int main()
{
	int N;
	scanf("%lld",&N);
	ll cnt = 0;
	for(int i = 1;i <= N;i ++)
		scanf("%lld",&A[i]);
	for(int i = 1;i <= N;i ++)
		scanf("%lld",&B[i]);
	while(true)
	{
		bool has = 0,has2 = 1;
		for(int i = 1;i <= N;i ++)
		{
			if(A[i] != B[i]) has2 = 0;
			int i0 = i == 1?N:i-1;
			int i2 = i == N?1:i+1;
			if(B[i0]+B[i2] == 0)
			{
				has2 = has = 0;
				break;
			}
			if(B[i]-A[i] >= B[i0]+B[i2])
			{
				int r = (B[i]-A[i])/(B[i0]+B[i2]);
				cnt += r;B[i] -= r*(B[i0]+B[i2]);has = 1;
				i -= 2;
			}
		}
		/*
		for(int i = 1;i <= N;i ++)
			printf("%lld%c",B[i],i == N?'\n':' ');
		*/
		if(has2)
		{
			printf("%lld\n",cnt);
			return 0;
		}
		if(!has)
		{
			printf("-1\n");
			return 0;
		}
	}
	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:10:9: error: 'll' was not declared in this scope
   10 |         ll cnt = 0;
      |         ^~
a.cc:31:33: error: 'cnt' was not declared in this scope; did you mean 'int'?
   31 |                                 cnt += r;B[i] -= r*(B[i0]+B[i2]);has = 1;
      |                                 ^~~
      |                                 int
a.cc:41:41: error: 'cnt' was not declared in this scope; did you mean 'int'?
   41 |                         printf("%lld\n",cnt);
      |                                         ^~~
      |                                         int
Language: C++

#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <numeric>
#include <set>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

using i64 = int64_t;

int main() {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<i64> A, B;
  copy_n(istream_iterator<i64>(cin), N, back_inserter(A));
  copy_n(istream_iterator<i64>(cin), N, back_inserter(B));

  i64 sumA = accumulate(begin(A), end(A), 0LL);
  i64 sumB = accumulate(begin(B), end(B), 0LL);

  set<pair<i64, int>> S;
  for (auto i = 0u; i < B.size(); ++i) {
    S.emplace(B[i], i);
  }

  auto ret = [&]() -> i64 {
    i64 ret = 0;
    while (sumB > sumA) {
      const auto it_max = --S.end();
      auto i = it_max->second;
      S.erase(it_max);

      i64 l = B[(i - 1 + N) % N];
      i64 r = B[(i + 1) % N];

      i64 k = min((B[i] - max(l, r) + l + r - 1) / (l + r),
                  (sumB - sumA) / (l + r));
      if (k <= 0) return -1;

      ret += k;

      sumB -= k * (l + r);
      B[i] -= k * (l + r);

      if (B[i] <= 0) return -1;
      S.emplace(B[i], i);
    }

    return std::equal(A.begin(), A.end(), B.begin()) ? ret : -1;
  }();

  cout << ret << '\n';
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:10: error: 'istream_iterator' was not declared in this scope
   21 |   copy_n(istream_iterator<i64>(cin), N, back_inserter(A));
      |          ^~~~~~~~~~~~~~~~
a.cc:8:1: note: 'std::istream_iterator' is defined in header '<iterator>'; this is probably fixable by adding '#include <iterator>'
    7 | #include <vector>
  +++ |+#include <iterator>
    8 | 
a.cc:21:30: error: expected primary-expression before '>' token
   21 |   copy_n(istream_iterator<i64>(cin), N, back_inserter(A));
      |                              ^
a.cc:22:30: error: expected primary-expression before '>' token
   22 |   copy_n(istream_iterator<i64>(cin), N, back_inserter(B));
      |                              ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long
const int N = 3e5 + 233;
int a[N], b[N], n;
inline int F(int x) { return b[x] - a[x]; } 
inline int get(int x) {
	if (!x) x = n; if (x == n + 1) x = 1;
	return b[x];
}
inline int G(int x) { return get(x - 1) + get(x + 1); } 
struct node_t {
	int id;
	friend bool operator < (node_t x, node_t y) {
		return make_pair(F(x.id) - G(x.id), x.id) > make_pair(F(y.id) - G(x.id), y.id);
	}
};
set <node_t> s;

signed main(void) {
	read(n);
	rep (i, n) read(a[i]);
	rep (i, n) read(b[i]);
	rep (i, n) if (F(i)) s.insert((node_t) {i});
	int ans = 0;
	while (!s.empty()) {
		node_t u = *s.begin(); s.erase(s.begin());
		int la = F(u.id), per = G(u.id);
		if (la < per) return cout << -1 << "\n", 0;
		int cnt = floor((long double) la / per);
		b[u.id] -= cnt * per;
		ans += cnt;
		function <void(int)> re = [&](int u) {
			node_t t = (node_t) {u};
			if (s.count(t)) s.erase(t);
			if (F(u)) s.insert(t);h
		};
		re(get(u.id - 1)); re(get(u.id + 1)); re(u.id);
	}
	cout << ans << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   35 |         rep (i, n) read(a[i]);
      |              ^
a.cc:2:29: note: in definition of macro 'rep'
    2 | #define rep(i, n) for (rint i = 1; i <= (n); i ++)
      |                             ^
a.cc:36:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |         rep (i, n) read(b[i]);
      |              ^
a.cc:2:29: note: in definition of macro 'rep'
    2 | #define rep(i, n) for (rint i = 1; i <= (n); i ++)
      |                             ^
a.cc:37:14: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |         rep (i, n) if (F(i)) s.insert((node_t) {i});
      |              ^
a.cc:2:29: note: in definition of macro 'rep'
    2 | #define rep(i, n) for (rint i = 1; i <= (n); i ++)
      |                             ^
a.cc: In lambda function:
a.cc:49:47: error: 'h' was not declared in this scope
   49 |                         if (F(u)) s.insert(t);h
      |                                               ^
Language: C++

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

#define ll long long
#define in ({ll x=0;int o=0,c=getchar();for(;!isdigit(c);c=getchar()) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})

#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bitnum(x) __builtin_popcountll(x)
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1

#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
////////////////////////////////////////// HUX
#define int ll
const int N=2e5+5;
int n,cnt;
int a[N],b[N];

priority_queue<pi> h;
int LEF(int x){return x==1?n:x-1;}
int RIG(int x){return x==n?1:x+1;}
main()
{
  //  freopen("hx.inp","r",stdin);
    n=in;
    FOR(i,1,n) a[i]=in;
    FOR(i,1,n) b[i]=in;
    FOR(i,1,n) h.push({b[i],i});
    for(;h.size();)
    {
        int v=h.top().x,x=h.top().y;h.pop();
        ll B=b[LEF(x)]+b[RIG(x)];

        if(v<a[x]||v<Ba) return cout<<"-1",0;

        cnt+=v/B;
        v%=B;b[x]=v;

        if(v!=a[x]) h.push({v,x});
    }
    cout<<cnt;
}


Compiler output:
a.cc:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:53:22: error: 'Ba' was not declared in this scope; did you mean 'B'?
   53 |         if(v<a[x]||v<Ba) return cout<<"-1",0;
      |                      ^~
      |                      B
Language: C++

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

#define ll long long
#define in ({ll x=0;int o=0,c=getchar();for(;!isdigit(c);c=getchar()) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})

#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bitnum(x) __builtin_popcountll(x)
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1

#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
////////////////////////////////////////// HUX
#define int ll
const int N=2e5+5;
int n,cnt;
int a[N],b[N];

priority_queue<pi> h;
int LEF(int x){return x==1?n:x-1;}
int RIG(int x){return x==n?1:x+1;}
main()
{
  //  freopen("hx.inp","r",stdin);
    n=in;
    FOR(i,1,n) a[i]=in;
    FOR(i,1,n) b[i]=in;
    FOR(i,1,n) h.push({b[i],i});
    for(;h.size();)
    {
        int v=h.top().x,x=h.top().y;h.pop();
=        if(v<a[x]) return cout<<"-1",0;
        v-=b[LEF(x)]+b[RIG(x)];b[x]=v;
        cnt++;
        if(v!=a[x]) h.push({v,x});
    }
    cout<<cnt;
}


Compiler output:
a.cc:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:51:1: error: expected primary-expression before '=' token
   51 | =        if(v<a[x]) return cout<<"-1",0;
      | ^
a.cc:51:10: error: expected primary-expression before 'if'
   51 | =        if(v<a[x]) return cout<<"-1",0;
      |          ^~
Language: C++

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

#define int ll
#define ll long long
#define in ({ll x=0;int o=0,c=getchar();for(;!isdigit(c);c=getchar()) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})

#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bitnum(x) __builtin_popcountll(x)
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1

#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
////////////////////////////////////////// HUX
const int N=2e5+5;
int n,cnt;
int a[N],b[N];

priority_queue<pi> h;
int LEF(int x){return x==1?n:x-1;}
int RIG(int x){return x==n?1:x+1;}
main()
{
    freopen("hx.inp","r",stdin);
    n=in;
    FOR(i,1,n) a[i]=in;
    FOR(i,1,n) b[i]=in;
    FOR(i,1,n) h.push({b[i],i});
    for(;h.size();)
    {
        int v=h.top().x,x=h.top().y;h.pop();
=        if(v<a[x]) return cout<<"-1",0;
        v-=b[LEF(x)]+b[RIG(x)];b[x]=v;
        cnt++;
        if(v!=a[x]) h.push({v,x});
    }
    cout<<cnt;
}


Compiler output:
a.cc:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:51:1: error: expected primary-expression before '=' token
   51 | =        if(v<a[x]) return cout<<"-1",0;
      | ^
a.cc:51:10: error: expected primary-expression before 'if'
   51 | =        if(v<a[x]) return cout<<"-1",0;
      |          ^~
Language: C++

#include <bits/stdc++.h>
#define ff(i, x, y) for(int i = x;i <= y;i++)
#define fs(i, x, y) for(int i = x;i >= y;i--)
#define maxn 200005
using namespace std;
typedef long long ll;
typedef struct node {
    int id, val;
    node(int a1, int a2) {
        id = a1;
        val = a2;
    }
};
bool operator <(const node &a1, const node &a2) {
    if(a1.val <= a2.val) return true;
    return false;
}
int a[maxn], b[maxn], n;
priority_queue<node>p;
int main() {
    scanf("%d", &n);
    ff(i, 1, n)
    scanf("%d", &a[i - 1]);
    ff(i, 1, n)
    scanf("%d", &b[i - 1]);
    ff(i, 1, n) {
        if(a[i - 1] < b[i - 1])
            p.push(node(i - 1, b[i - 1]));
      	else if(a[i - 1] > b[i - 1]) {
          print("-1");
       	  return 0;
        } 
    }
    int flag = 1;
    ll ans = 0;
    while(!p.empty()){
        node temp = p.top();
        p.pop();
        int pos = temp.id, v = temp.val;
        //printf("%d\n", v);
        int mod;
        if(pos == 0)
            mod = b[n - 1] + b[1];
        else if(pos == n - 1)
            mod = b[0] + b[n - 2];
        else
            mod = b[pos - 1] + b[pos + 1];
        if(v <= mod) {
            flag = 0;
            break;
        }
        v = (b[pos] - a[pos]) % mod;
        ans += (b[pos] - a[pos]) / mod;
        b[pos] = a[pos] + v;
        if(v == 0);
        else
            p.push(node(pos, b[pos]));
    }
    while(!p.empty()) {
        p.pop();
    }
    if(flag)
        printf("%lld", ans);
    else
        printf("-1");
    return 0;
}

Compiler output:
a.cc:7:1: warning: 'typedef' was ignored in this declaration
    7 | typedef struct node {
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:30:11: error: 'print' was not declared in this scope; did you mean 'rint'?
   30 |           print("-1");
      |           ^~~~~
      |           rint
Language: C++

#include <bits/stdc++.h>
#define ff(i, x, y) for(int i = x;i <= y;i++)
#define fs(i, x, y) for(int i = x;i >= y;i--)
#define maxn 200005
using namespace std;
typedef long long ll;
typedef struct node {
    int id, val;
    node(int a1, int a2) {
        id = a1;
        val = a2;
    }
};
bool operator <(const node &a1, const node &a2) {
    if(a1.val <= a2.val) return true;
    return false;
}
int a[maxn], b[maxn], n;
priority_queue<node>p;
int main() {
    scanf("%d", &n);
    ff(i, 1, n)
    scanf("%d", &a[i - 1]);
    ff(i, 1, n)
    scanf("%d", &b[i - 1]);
    ff(i, 1, n) {
        if(a[i - 1] < b[i - 1])
            p.push(node(i - 1, b[i - 1]));
      	else if(a[i - 1] > b[i - 1]) {
          print("-1");
       	  return;
        } 
    }
    int flag = 1;
    ll ans = 0;
    while(!p.empty()){
        node temp = p.top();
        p.pop();
        int pos = temp.id, v = temp.val;
        //printf("%d\n", v);
        int mod;
        if(pos == 0)
            mod = b[n - 1] + b[1];
        else if(pos == n - 1)
            mod = b[0] + b[n - 2];
        else
            mod = b[pos - 1] + b[pos + 1];
        if(v <= mod) {
            flag = 0;
            break;
        }
        v = (b[pos] - a[pos]) % mod;
        ans += (b[pos] - a[pos]) / mod;
        b[pos] = a[pos] + v;
        if(v == 0);
        else
            p.push(node(pos, b[pos]));
    }
    while(!p.empty()) {
        p.pop();
    }
    if(flag)
        printf("%lld", ans);
    else
        printf("-1");
    return 0;
}

Compiler output:
a.cc:7:1: warning: 'typedef' was ignored in this declaration
    7 | typedef struct node {
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:30:11: error: 'print' was not declared in this scope; did you mean 'rint'?
   30 |           print("-1");
      |           ^~~~~
      |           rint
a.cc:31:11: error: return-statement with no value, in function returning 'int' [-fpermissive]
   31 |           return;
      |           ^~~~~~
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
	int n; cin >> n;
	vector<ll> a(n), b(n);
	priority_queue<tuple<ll, ll, int>> pque;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
		if(b[i] != a[i]) pque.push(make_tuple(b[i], a[i], i));
	}
	int cnt = 0;
	while(pque.size()) {
		cnt ++;
		tuple<ll, ll, int> t = pque.top(); pque.pop();
		if(pque.size()) tuple<ll, ll, int> tnext = pque.top();
		int pos = get<2>(t); ll bnext = 0;
		if(pque.size()) bnext = get<0>(tnext);
		ll minus = b[(pos - 1 + n) % n] + b[(pos + 1) % n];
		b[pos] -= (((b[pos] - bnext) / minus) >= 1 ? ((b[pos] - bnext) / minus) : 1)  * minus;
		if(b[pos] != a[pos]) pque.push(make_tuple(b[pos], a[pos], pos));
		if(b[pos] < a[pos]) {
			cout << -1 << endl;
			return;
		}
	}
	cout << cnt << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:66:48: error: 'tnext' was not declared in this scope; did you mean 'bnext'?
   66 |                 if(pque.size()) bnext = get<0>(tnext);
      |                                                ^~~~~
      |                                                bnext
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
	int n; cin >> n;
	vector<ll> a(n), b(n);
	priority_queue<tuple<ll, ll, int>> pque;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
		if(b[i] != a[i]) pque.push(make_tuple(b[i], a[i], i));
	}
	int cnt = 0;
	while(pque.size()) {
		cnt ++;
		tuple t = pque.top(); pque.pop();
		int pos = get<2>(t);
		b[pos] -= (b[(pos - 1 + n) % n] + b[(pos + 1) % n];
		if(b[pos] != a[pos]) pque.push(make_tuple(b[pos], a[pos], pos));
	}
	cout << cnt << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:65:67: error: expected ')' before ';' token
   65 |                 b[pos] -= (b[(pos - 1 + n) % n] + b[(pos + 1) % n];
      |                           ~                                       ^
      |                                                                   )
Language: C++

#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
int pre(int x){if(x==1)return n;return x-1;}
int nxt(int x){if(x==n)return 1;return x+1;}

int main(){
    int n;
    cin >> n;
    priority_queue<pair<int,int > > pq;
    vector<int> a(n), b(n);
    for(int i = 1; i <= n; i++)cin>>a[i];
    for(int i = 1; i <= n; i++)
	{
		cin>>b[i];
		if(b[i]<a[i])return puts("-1"),0;
		else if(b[i]>a[i])q.push({b[i],i});
	}

    ll ans = 0;
    while(!pq.empty()){
        pair<int,int> p = pq.top(); pq.pop();
        int i = p.second;
        int unit = b[(i-1+n)%n] + b[(i+1)%n];
        if((b[i]-a[i])/unit == 0){
            cout << -1 << endl;
            return 0;
        }
        ans += (b[i]-a[i])/unit;
        b[i] -= (b[i]-a[i])/unit*unit;
        if(b[i] > a[i]) pq.push({b[i], i});
    }

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

Compiler output:
a.cc: In function 'int pre(int)':
a.cc:6:31: error: 'n' was not declared in this scope
    6 | int pre(int x){if(x==1)return n;return x-1;}
      |                               ^
a.cc: In function 'int nxt(int)':
a.cc:7:22: error: 'n' was not declared in this scope
    7 | int nxt(int x){if(x==n)return 1;return x+1;}
      |                      ^
a.cc: In function 'int main()':
a.cc:19:35: error: 'q' was not declared in this scope
   19 |                 else if(b[i]>a[i])q.push({b[i],i});
      |                                   ^
Language: C++

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>

#include <queue>

using namespace std;


typedef pair <int, int> pr;


const int N = 2e5 + 10;


int a[N], b[N];
int n;

priority_queue <pr> q;

int main()
{
	scanf("%d", &n);
	
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
	
	for (int i = 1; i <= n; i++) q.push(make_pair(b[i], i));
	
	LL Ans = 0;
	
	while (!q.empty())
	{
		pr now = q.top(); q.pop();
		int val = now.first, id = now.second;
		if (val == a[id]) continue;
		if (val < a[id]) return 0 & puts("-1");
		int w = val - a[id]; 
		int num = b[id < n ? id + 1 : 1] + b[id > 1 ? id - 1 : n];
		if (num > w) return 0 & puts("-1");
		Ans += w / num;
		b[id] -= (w / num) * num;
		q.push(make_pair(b[id], id));
	}
	
	printf("%lld\n", Ans);
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:9: error: 'LL' was not declared in this scope
   32 |         LL Ans = 0;
      |         ^~
a.cc:43:17: error: 'Ans' was not declared in this scope
   43 |                 Ans += w / num;
      |                 ^~~
a.cc:48:26: error: 'Ans' was not declared in this scope
   48 |         printf("%lld\n", Ans);
      |                          ^~~
Language: C++

#include<iostream>
#include<queue>
#define int long long
using namespace std;
priority_queue<pair<int,int> > lis;
const int N=2e5+2;
int ar[N],ar1[N];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,z,val,mod,num=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}	
	for(i=1;i<=n;i++){
		cin>>ar1[i];
		if(ar1[i]<ar[i]){
			cout<<-1;
			return 0;
		}
		if(ar1[i]!=ar[i]){
			lis.push({ar1[i],i});
		}
	}
	while(lis.size()){
		j=lis.top().first;
		k=lis.top().second;
		lis.pop();
		if(k==1){
			l=n;
		}
		else{
			l=k-1;
		}
		z=k%n+1;
		mod=ar1[z]+ar1[l];
		val=max(ar[k],j%mod);
		i=(j-val)/mod;
		if(i==0){
			cout<<-1;
			return 0;
		}
		j-=i*mod;
		num+=i;
		ar1[k]=j;
		if(j!=ar[k]){
			lis.push({j,k});
		}
	}
	cout<<num;
}

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

#include<bits/stdc++.h>

using namespace std;

#define ff(i, a, b) for(int i = (a); (i <= (b)); ++i)
#define FF(i, a, b) for(int i = (a); (i >= (b)); --i)
#define ll long long

const int M = 1000000000 + 7;
const int N = 100000 + 10;

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

int n, a[N], b[N], nex[N], pre[N];

bool check(int i) {
    return b[i] - b[nex[i]] - b[pre[i]] >= a[i];
}

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("", "r" , stdin);
    //freopen("", "w", stdout);
    cin >> n;
    ff(i, 1, n) cin >> a[i];

    ff(i, 1, n) nex[i] = i + 1, pre[i] = i - 1;
    nex[n] = 1;
    pre[1] = n;

    set<re> q;
    ff(i, 1, n) {
        cin >> b[i];
        if (check(i)) q.insert({b[i], i});
    }

    ll res = 0;
    while (!q.empty()) {
        int i = q.begin()->y;
        q.erase(q.begin());

        int tmp = (b[i] - a[i]) / (b[nex[i]] + b[pre[i]]);
        cnt = 0;
        res += tmp;
        b[i] -= tmp * (b[nex[i]] + b[pre[i]]);

        if (check(nex[i])) q.insert({b[nex[i]], nex[i]});
        if (check(pre[i])) q.insert({b[pre[i]], pre[i]});

        //cout << i << " " << b[i] << endl;
    }


    ff(i, 1, n)
    if (b[i] != a[i]) res = -1;

    cout << res << endl;
}
//This code belongs to s34vv1nd


Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   48 |         cnt = 0;
      |         ^~~
      |         int