Language: C++

// in the name of GOD
#include <bits/stdc++.h>
#define  S second
#define  F first
#define pb push_back
#define sz(cp) 1LL*cp.size()
#define tm are_you_now_tm_is_define_?
#define ta(c) c-'a'+1 
//#define int long long
using namespace std;
typedef long long ll ;
typedef long double ld ;
typedef pair < ll , ll > pii ;
const int maxn = 1e5 + 10 ;
int n , q , _n;
ll Ans[maxn] , path[maxn] ;
vector<pii>v[maxn] ;
vector<int>add[maxn] ;
vector<ll>mv ;

void get_yal(int i , ll w1){
	if(w1 <= n){
		add[w1].pb(i) ;
		return ;
	}
	int j = min(1LL*i-1,upper_bound(mv.begin(),mv.end(),w1)-mv.begin()-1) ;
	v[j].pb(pii(i,w1/mv[j])) ;
	get_yal(i,w1%mv[j]);
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> q ; _n = n ;
	mv.resize(q) ;
	for(int y = 0 ; y < q ; y++)
	cin >> mv[y] ;
	for(int y = q-2 ; y+1 ; y--)
	mv[y] = min(mv[y] , mv[y+1]) ;
	if(mv[0] <= n)
	n = mv[0] ;
	else
	reverse(mv.begin(),mv.end()),mv.pb(n),reverse(mv.begin(),mv.end()),q++;
	mv.pb(1LL*1e18+10) ; path[q-1] = 1;
	for(int y = 0 ; y < q ; y++)
	get_yal(y,mv[y]) ;
	for(int y = q-1 ; y+1 ; y--)
	for(auto A : v[y])
	path[y] += A.S*path[A.F] ;
	for(int y = n ; y ; y--){
		Ans[y] += Ans[y+1] ;
		for(auto A : add[y])
		Ans[y] += path[A] ;
	}
	for(int y = 1 ; y <= _n ; y++)
	cout << Ans[y] << endl ;
	return 0 ;
}


Compiler output:
a.cc: In function 'void get_yal(int, ll)':
a.cc:26:20: error: no matching function for call to 'min(long long int, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)'
   26 |         int j = min(1LL*i-1,upper_bound(mv.begin(),mv.end(),w1)-mv.begin()-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:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:26:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type' {aka 'long int'})
   26 |         int j = min(1LL*i-1,upper_bound(mv.begin(),mv.end(),w1)-mv.begin()-1) ;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:26:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |         int j = min(1LL*i-1,upper_bound(mv.begin(),mv.end(),w1)-mv.begin()-1) ;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~