Language: C++

#include <bits/stdc++.h>
using namespace std;
namespace IO
{
	const int __S=(1<<20)+5;char __bua[__S],*__H,*__T;
	inline char getc()
	{
		if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
		if(__H==__T) return -1;return *__H++;
	}
	template <class __I>inline void read(__I &__x)
	{
		__x=0;int __fg=1;char __c=getc();
		while(!isdigit(__c)&&__c!='-') __c=getc();
		if(__c=='-') __fg=-1,__c=getc();
		while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
		__x*=__fg;
	}
	inline void readd(double &__x)
	{
		__x=0;double __fg=1.0;char __c=getc();
		while(!isdigit(__c)&&__c!='-') __c=getc();
		if(__c=='-') __fg=-1.0,__c=getc();
		while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
		if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
		double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
		__x=__x*__fg;
	}
	inline void reads(char *__s,int __x)
	{
		char __c=getc();int __tot=__x-1;
		while(__c<'!'||__c>'~') __c=getc();
		while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
		__s[++__tot]='\0';
	}
	char __obua[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
	inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
	inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
	template <class __I>inline void print(__I __x)
	{
		if(!__x) putc('0');
		if(__x<0) putc('-'),__x=-__x;
		while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
		while(__qr) putc(__qu[__qr--]);
	}
	inline void prints(const char *__s,const int __x)
	{
		int __len=strlen(__s+__x);
		for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
	}
	inline void printd(double __x,int __d)
	{
		long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
		while(__d--)
		{
			double __y=__x*10.0;__x*=10.0;
			int __c=(int)floor(__y);
			putc(__c+'0');__x-=floor(__y);
		}
	}
	inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
#define ll long long
ll n,m,tot,x,t[200005],a[200005],a[200005],ans[200005];stack<ll>sta;
void gao(int x,ll y)
{
	if(!x) return;int t=upper_bound(a+1,a+tot+1,x)-a-1;
	if(!t) ans[1]+=y,ans[x+1]-=y;else a[t]+=x/a[t]*y,gao(x%a[t],y);
}
int main()
{
	read(n);read(m);a[++tot]=n;
	for(int i=1;i<=m;i++){read(x);while(tot&&a[tot]>=x) tot--;a[++tot]=x;}
	a[tot]=1;for(int i=tot;i>=2;i--) a[i-1]+=a[i]*(a[i]/a[i-1]),gao(a[i]%a[i-1],a[i]);
	ans[1]+=a[1];ans[a[1]+1]-=a[1];for(int i=1;i<=n;i++) ans[i]+=ans[i-1];
	for(int i=1;i<=n;i++) print(ans[i]),el();flush();
}

Compiler output:
a.cc: In function 'char IO::getc()':
a.cc:8:39: error: '__buf' was not declared in this scope; did you mean '__bua'?
    8 |                 if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
      |                                       ^~~~~
      |                                       __bua
a.cc: At global scope:
a.cc:36:32: error: '__obuf' was not declared in this scope; did you mean '__obua'?
   36 |         char __obua[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
      |                                ^~~~~~
      |                                __obua
a.cc: In function 'void IO::flush()':
a.cc:37:36: error: '__obuf' was not declared in this scope; did you mean '__obua'?
   37 |         inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
      |                                    ^~~~~~
      |                                    __obua
a.cc: In function 'void IO::putc(char)':
a.cc:38:58: error: '__oT' was not declared in this scope; did you mean '__oS'?
   38 |         inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
      |                                                          ^~~~
      |                                                          __oS
a.cc: In function 'void IO::print(__I)':
a.cc:43:28: error: '__qu' was not declared in this scope; did you mean '__qr'?
   43 |                 while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
      |                            ^~~~
      |                            __qr
a.cc:44:34: error: '__qu' was not declared in this scope; did you mean '__qr'?
   44 |                 while(__qr) putc(__qu[__qr--]);
      |                                  ^~~~
      |                                  __qr
a.cc: At global scope:
a.cc:64:34: error: redefinition of 'long long int a [200005]'
   64 | ll n,m,tot,x,t[200005],a[200005],a[200005],ans[200005];stack<ll>sta;
      |                                  ^
a.cc:64:24: note: 'long long int a [200005]' previously declared here
   64 | ll n,m,tot,x,t[200005],a[200005],a[200005],ans[200005];stack<ll>sta;
      |                        ^