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<pair<ll, int>> pque;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		cin >> b[i];
		if(b[i] != a[i]) pque.push(make_pair(b[i], i));
	}
	ll cnt = 0;
	while(pque.size()) {
		pair<ll, int> p = pque.top(); pque.pop();
		int pos = p.second;
		ll minus = b[(pos - 1 + n) % n] + b[(pos + 1) % n];
		ll c = b[pos] / minus;
		b[pos] -= minus * c; //b[pos] %= minus;
		cnt += c;
		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:68:46: error: no matching function for call to 'std::priority_queue<std::pair<long long int, int> >::push(std::tuple<long long int, long long int, int>)'
   68 |                 if(b[pos] > a[pos]) pque.push(make_tuple(b[pos], a[pos], pos));
      |                                     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:10:
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int>, std::allocator<std::pair<long long int, int> > >; _Compare = std::less<std::pair<long long int, int> >; value_type = std::pair<long long int, int>]'
  736 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note:   no known conversion for argument 1 from 'std::tuple<long long int, long long int, int>' to 'const std::priority_queue<std::pair<long long int, int> >::value_type&' {aka 'const std::pair<long long int, int>&'}
  736 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<long long int, int>; _Sequence = std::vector<std::pair<long long int, int>, std::allocator<std::pair<long long int, int> > >; _Compare = std::less<std::pair<long long int, int> >; value_type = std::pair<long long int, int>]'
  744 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note:   no known conversion for argument 1 from 'std::tuple<long long int, long long int, int>' to 'std::priority_queue<std::pair<long long int, int> >::value_type&&' {aka 'std::pair<long long int, int>&&'}
  744 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~