stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <string>

#include <stdio.h>

#include <queue>

#include <stack>

#include <string.h>

#include <algorithm>

#include <math.h>

#include <bits/stdc++.h>

#define ll long long

#define wtcl return

using namespace std;



inline ll read()

{

	ll s = 0, f = 1;

	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;

	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));

	return s * f ;

}

inline void out(ll x)

{

	if(x<0) putchar('-'),x=-x;

	if(x>9) out(x/10);

	putchar(x%10+'0');

}



int main()

{

	int n,k;

	cin>>n>>k;

	int num[100005];

	for(int i=0;i<n;i++)

		num[i]=read();

	sort(num,num+n);

	int ans  = 999999999;

	for(int i=0;i<=n-k;i++)

	{

		ans = min(ans,num[i+k-1]-num[i]);

	}

	cout<<ans<<endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.436491107289435x):
#include <cstdio>

#include <cctype>

#include <algorithm>



int n, k, ans = 0x7fffffff;

int a[100010];



int read() {

    int ret, f = 1;

    char ch;

    while(!isdigit(ch = getchar())) (ch == '-') && (f = -1);

    for(ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0');

    return ret * f;

}



void print(int x) {

    if(x < 0) putchar('-'), x = -x;

    if(x > 9) print(x / 10);

    putchar(x % 10 + '0');

}



int main() {

    n = read(), k = read();

    for(int i = 1; i <= n; ++i) a[i] = read();

    std::sort(a + 1, a + n + 1);

    for(int i = 1; i + k - 1 <= n; ++i) ans = std::min(ans, a[i + k - 1] - a[i]);

    print(ans);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main(){

    int n, k;

    cin >> n >> k;

    int h[n], a[n];

    for(int i = 0; i < n; i++){

        cin >> h[i];

    }

    sort(h, h+n);

    for(int i = 0; i < n-k+1; i++){

        a[i] = h[i+k-1] - h[i];

    }

    sort(a, a+(n-k+1));



    cout << a[0] << endl;

return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.662788239117906x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int main()

{

    int k,n,a[100005],b[100005];

    scanf("%d%d",&k,&n);

    for(int i=0;i<k;i++)

        scanf("%d",&a[i]);

    sort(a,a+k);

    int w=0;

    for(int i=0;i<k-n+1;i++)

    {

        b[w++]=a[i+n-1]-a[i];

    }

    int min=b[0];

    for(int j=0;j<w;j++)

    {

        if(b[j]<min)

            min=b[j];

    }

    printf("%d\n",min);

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<algorithm>



using namespace std;



int main(){

	int n,k,x,t,i,j,min;

	vector <int> v;

	cin>> n >> k;

	for(i = 0; i < n; i++){

		cin >> x;

		v.push_back(x);

	}

	sort(v.begin(),v.end());

	/*for(i = 0; i < n; i++){

		for(j = i+1; j <n; j++){

			if (v[i] > v[j] ){

				t = v[i];

				v[i] = v[j];

				v[j] = t;

			}

		}

	 	

	}*/



	i= 0;

	j=i+k-1; 

	min = v[j] - v[i];

	while(j < n){

		if( (v[j]-v[i]) < min) min =v[j]-v[i];

		i++;

		j++; 

	}

	cout << min;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.6677521373288995x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int main()

{

    int k,n,a[100005],b[100005];

    scanf("%d%d",&k,&n);

    for(int i=0;i<k;i++)

        scanf("%d",&a[i]);

    sort(a,a+k);

    int w=0;

    for(int i=0;i<k-n+1;i++)

    {

        b[w++]=a[i+n-1]-a[i];

    }

    int min=b[0];

    for(int j=0;j<w;j++)

    {

        if(b[j]<min)

            min=b[j];

    }

    printf("%d\n",min);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int main(){

int n,k;

cin>>n>>k;

vector<int> trees(n);

int min=1e9;

for(int i=0;i<n;i++){

	cin>>trees[i];

}

sort(trees.begin(),trees.end());

for(int i=0;i<=n-k;i++){

if(min>trees[i+k-1]-trees[i]){

	min=trees[i+k-1]-trees[i];

}

}

cout<<min<<endl;



return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.706603801998803x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int main()

{

    int k,n,a[100005],b[100005];

    scanf("%d%d",&k,&n);

    for(int i=0;i<k;i++)

        scanf("%d",&a[i]);

    sort(a,a+k);

    int w=0;

    for(int i=0;i<k-n+1;i++)

    {

        b[w++]=a[i+n-1]-a[i];

    }

    int min=b[0];

    for(int j=0;j<w;j++)

    {

        if(b[j]<min)

            min=b[j];

    }

    printf("%d\n",min);

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

using namespace std;

int a[100010];

int main(){

	int k,n,i,x=-1;

	cin >> n >> k;

	for(i=0;i<n;i++){

		cin >> a[i];

	}

	sort(a,a+n);

	for(i=0;i<=n-k;i++){

		if(a[i+k-1]-a[i]<x || x==-1){

			x=a[i+k-1]-a[i];

		}

	}

	cout << x << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.66064206588151x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int main()

{

    int k,n,a[100005],b[100005];

    scanf("%d%d",&k,&n);

    for(int i=0;i<k;i++)

        scanf("%d",&a[i]);

    sort(a,a+k);

    int w=0;

    for(int i=0;i<k-n+1;i++)

    {

        b[w++]=a[i+n-1]-a[i];

    }

    int min=b[0];

    for(int j=0;j<w;j++)

    {

        if(b[j]<min)

            min=b[j];

    }

    printf("%d\n",min);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

typedef long long ll;

#define dbg          cout<<"Freak"<<endl;

#define dbgg(i)      cout<<i<<endl;

#define N            1e9+7;

using namespace std;

ll t;

ll arr[200005];

int main()

{

    ll a,b,c,d,e,f,i,j;

    cin>>a>>b;

    for(i=1;i<=a;i++)

    {

        cin>>arr[i];

    }

    c=N;

    sort(arr+1,arr+a+1);

    for(i=b;i<=a;i++)

    {

        c=min(c,(arr[i]-arr[i-b+1]));

    }

    cout<<c<<endl;





return 0;



}


// Faster C++ solution for the same problem (measured speedup: 4.655674907327714x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int main()

{

    int k,n,a[100005],b[100005];

    scanf("%d%d",&k,&n);

    for(int i=0;i<k;i++)

        scanf("%d",&a[i]);

    sort(a,a+k);

    int w=0;

    for(int i=0;i<k-n+1;i++)

    {

        b[w++]=a[i+n-1]-a[i];

    }

    int min=b[0];

    for(int j=0;j<w;j++)

    {

        if(b[j]<min)

            min=b[j];

    }

    printf("%d\n",min);

    return 0;

}
// Slower C++ solution:
#include <stdio.h>

#include <iostream>

#include <algorithm>

#include <string.h>

#define ll long long 

#define inf 0x3f3f3f

using namespace std;

int main()

{

	int a[100005];

	int n,k;

	while(scanf("%d %d",&n,&k)!=EOF)

	{

		for(int i=0;i<n;i++)

		scanf("%d",&a[i]);

		sort(a,a+n);

		int mi=999999999;

		for(int i=0;i<=n-k;i++)

		{

			mi=min(mi,a[i+k-1]-a[i]);

		}

		printf("%d\n",mi);

	}

	return 0;

 } 

// Faster C++ solution for the same problem (measured speedup: 4.642839581892061x):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

int main()

{

    int k,n,a[100005],b[100005];

    scanf("%d%d",&k,&n);

    for(int i=0;i<k;i++)

        scanf("%d",&a[i]);

    sort(a,a+k);

    int w=0;

    for(int i=0;i<k-n+1;i++)

    {

        b[w++]=a[i+n-1]-a[i];

    }

    int min=b[0];

    for(int j=0;j<w;j++)

    {

        if(b[j]<min)

            min=b[j];

    }

    printf("%d\n",min);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N, K;

	cin >> N >> K;

	int h[100000];

	rep(i, N) {

		cin >> h[i];

	}

	sort(h, h + N);



	int saishou = 1e9;

	rep(i, N - K + 1) {

		saishou = min(saishou, h[i + K - 1] - h[i]);

	}

	co(saishou);



	Would you please return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.9244885011925525x):
//#include<bits/stdc++.h>

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



void pakuri_sort(int N, int A[]) {

	const int b = 8;

	int tmp[100001];

	rep(k, 4) {

		int kazu[1 << b] = {}, kazu2[1 << b] = {};

		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];

		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];

		k++;

		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];

		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];

	}

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint(), K = getint();

	int h[100000];

	rep(i, N) h[i] = getint();

	pakuri_sort(N, h);



	int saishou = 1e9;

	rep(i, N - K + 1) {

		saishou = min(saishou, h[i + K - 1] - h[i]);

	}

	printf("%d", saishou);



	Would you please return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N = getint(), K = getint();

	int h[100000];

	rep(i, N) h[i] = getint();

	sort(h, h + N);



	int saishou = 1e9;

	rep(i, N - K + 1) {

		saishou = min(saishou, h[i + K - 1] - h[i]);

	}

	co(saishou);



	Would you please return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.9168757174275x):
//#include<bits/stdc++.h>

#include<cstdio>

#include<algorithm>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char cn[cm], * ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



void pakuri_sort(int N, int A[]) {

	const int b = 8;

	int tmp[100001];

	rep(k, 4) {

		int kazu[1 << b] = {}, kazu2[1 << b] = {};

		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];

		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];

		k++;

		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;

		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];

		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];

	}

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint(), K = getint();

	int h[100000];

	rep(i, N) h[i] = getint();

	pakuri_sort(N, h);



	int saishou = 1e9;

	rep(i, N - K + 1) {

		saishou = min(saishou, h[i + K - 1] - h[i]);

	}

	printf("%d", saishou);



	Would you please return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



vector<int> h(100010);



int main()

{

  int N, K; cin >> N >> K;

  for (int i = 0; i < N; ++i) {

    cin >> h[i];

  }



  sort(h.begin(), h.begin() + N);



  int ans = 1e9;

  for (int i = 0; i <= N - K; ++i) {

    ans = min(ans, h[i+K-1] - h[i]);

  }



  cout << ans << endl;

}

// Faster C++ solution for the same problem (measured speedup: 1.4046302416014496x):
#include <bits/stdc++.h>



using namespace std;



int main()

{

  int N, K; cin >> N >> K;

  vector<int> h(N);

  for (int i = 0; i < N; ++i) cin >> h[i];



  sort(h.begin(), h.end());



  int ans = 1e9;

  for (int i = 0; i < N-K+1; i++) {

    ans = min(ans, h[i+K-1]-h[i]);

  }



  cout << ans;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<algorithm>

#include<cctype>

#include<utility>

#include<string>

#include<cmath>

#include<cstring>

#include<queue>

#include<map>

#include<climits>

 

#define REP(i, n) for(int i = 0;i < n;i++)

#define REPR(i, n) for(int i = n;i >= 0;i--)

#define FOR(i, m, n) for(int i = m;i < n;i++)

#define FORR(i, m, n) for(int i = m;i >= n;i--)

#define SORT(v, n) sort(v, v+n);

#define VSORT(v) sort(v.begin(), v.end());

#define llong long long

#define pb(a) push_back(a)

using namespace std;

typedef pair<int, int> P;

typedef long long int ll;

typedef pair<ll,ll> LLP;

#define INF 10000000000007

 

#define ARRAY_MAX 100005

 

int main(){

 

    ll n,k;

    cin >> n >> k;

    vector<ll> a(ARRAY_MAX);

    REP(i,n){

        cin >> a[i];

    }

    sort(a.begin(),a.begin()+n);

    

    ll mini = INF;

    for(int i = 0;i < n-k+1;i++){

        mini = min(mini,a[i+k-1]-a[i]);

    }

    cout << mini << endl;

 

 

 

 

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7991737329862931x):
#include<iostream>

#include<vector>

#include<algorithm>

#include<cctype>

#include<utility>

#include<string>

#include<cmath>

#include<cstring>

#include<queue>

#include<map>

#include<climits>

#include<set>

 

#define REP(i, n) for(int i = 0;i < n;i++)

#define REPR(i, n) for(int i = n;i >= 0;i--)

#define FOR(i, m, n) for(int i = m;i < n;i++)

#define FORR(i, m, n) for(int i = m;i >= n;i--)

#define SORT(v, n) sort(v, v+n);

#define VSORT(v) sort(v.begin(), v.end());

#define llong long long

#define pb(a) push_back(a)

using namespace std;

typedef pair<int, int> P;

typedef long long int ll;

typedef pair<ll,ll> LLP;

#define INF 1000000007

 

#define ARRAY_MAX 100005

 

int main(){



    int n,k;

    cin >> n >> k;

    vector<int> a(n);

    REP(i,n){

        cin >> a[i];

    }

    VSORT(a);

    int mini = INF;

    for(int i = 0;i < n-k+1;i++){

        mini = min(mini,a[i+k-1]-a[i]);

    }

    cout << mini << endl;



    return 0;

}
// Slower C++ solution:
/*Bismillahir Rahmanir Rahim*/

#include<bits/stdc++.h>

using namespace std;

int main()

{

    long long int a[100007],i,j,N,K,l;

    cin>>N>>K;

    for(i=0; i<N; i++)

        cin>>a[i];

    sort(a,a+N);

    l=a[K-1]-a[0];

    for(i=0; i<N-K+1; i++)

    {

        j=a[i+K-1]-a[i];

        if(j<l)

            l=j;

    }

    cout<<l<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.275134745166242x):
#include<stdio.h>

#include<stdlib.h>

int a[100005];

int inc(const void *a, const void *b)

{

    return *(int *)a-*(int *)b;

}

int main()

{

	int n,m,min=-1;

	scanf("%d%d",&n,&m);

	for(int i=0;i<n;i++)scanf("%d",&a[i]);

	qsort(a,n,sizeof(int),inc);

	for(int i=0;i<=(n-m);i++)

	{

		if(min==-1)min=a[i+m-1]-a[i];

		if(min>a[i+m-1]-a[i])min=a[i+m-1]-a[i];

	}

	printf("%d\n",min);

}
// Slower C++ solution:
#include <bits/stdc++.h>

const long long INF = 1LL << 60;

using namespace std;



int main() {

    int N, K;

    cin >> N >> K;

    

    vector<long long> h(N);

    for (int i = 0; i < h.size(); ++i) cin >> h[i];



    sort(h.begin(), h.end());



    long long dp[100010];

    for (int i = 0; i < 100010; ++i) dp[i]= INF;

    for (int i = 0; i < h.size() - (K - 1); ++i) dp[i] = h[i+(K-1)] - h[i];

    

    long long ans = INF;

    for (int i = 0; i < 100010; ++i) ans = min(ans, dp[i]);



    cout << ans << endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8763737901143838x):
#include <bits/stdc++.h>

const long long INF = 1LL << 60;

using namespace std;



int main() {

    int N, K;

    cin >> N >> K;



    vector<long long> h(N);

    for (int i = 0; i < h.size(); ++i) cin >> h[i];



    sort(h.begin(), h.end());



    long long ans = INF;

    for (int i = 0; i < h.size() - (K - 1); ++i) ans = min(ans, h[i+(K-1)] - h[i]);



    cout << ans << endl;

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#include <stdlib.h>

int asc(const void *a, const void *b) {

   return *(int *)a - *(int *)b;

}

#define MIN(a,b) ((a)<(b)?(a):(b))

int main(void) {

   int N, K;

   int ans = 1000000010;

   int L[1000000];

   cin >> N;

   cin >> K;

   for (int i = 0; i < N; i++) {

      cin >> L[i];

   }

   qsort(L,N,sizeof (int), asc);

   for (int i = 0; i < N - K + 1; i++) {

      ans = MIN(ans, L[i+K-1] - L[i]);

   }

   cout << ans << endl;

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.46145613986059x):
#include <stdio.h>

#include <stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))

#define ABS(a) ((a)>(0)?(a):-(a))



int asc(const void *a, const void *b) {

   return *(int *)a - *(int *)b;

}



int main(void){

   int N,K;

   int L[100000+1];

   int ans = 1000000010;

   scanf("%d%d", &N,&K);

   for (int i = 0; i < N; i++) {

      scanf("%d", &L[i]);

   }

   qsort(L,N,sizeof (int), asc);

   for (int i = 0; i < N - K +1; i++) {

      ans = MIN(ans,ABS(L[i]-L[i+(K-1)]));

   }

   printf("%d\n",ans);

   return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>

#include <sstream>

#include <iomanip>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <cctype>

#include <cstring>

#include <vector>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <map>

#include <set>

#include <algorithm>

#include <iterator>

#include <bitset>

#include <ctime>

#include<complex>

using namespace std;



#define FOR(i,a,b) for (int i = (a); i < (b); i++)

#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)

#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define FILL(a,value) memset(a, value, sizeof(a))



#define SZ(a) (int)a.size()

#define ALL(a) a.begin(), a.end()

#define PB push_back

#define MP make_pair



typedef long long LL;

typedef vector<int> VI;

typedef pair<int, int> PII;



const double PI = acos(-1.0);

const int INF = 1000 * 1000 * 1000 + 7;

const LL LINF = INF * (LL)INF;



const int MAX = 1000 * 100 + 47;

const int MOD = 1000 * 1000 * 1000 + 7;



LL T[MAX];

LL A[MAX];

LL Q[MAX];

int sz;



int main()

{

	//freopen("in.txt", "r", stdin);

	//freopen("out.txt", "w", stdout);

	ios::sync_with_stdio(false); cin.tie(0);

	int n, q;

	cin >> n >> q;

	if (q == 0)

	{

		FOR(i, 0, n) cout << "1\n";

		return 0;

	}



	FOR(i, 0, q)

	{

		LL a;

		cin >> a;

		while (sz && Q[sz - 1] >= a) sz--;

		Q[sz++] = a;

	}

	

	//cout << sz << endl;

	//FOR(i, 0, sz) cout << Q[i] << " ";

	//cout << endl;

	T[sz - 1] = 1;

	LL cnt = min(Q[0], (LL)n);



	RFOR(i, sz, 0)

	{

		LL a = Q[i];

		while (1)

		{

			int ind = lower_bound(Q, Q + sz, a) - Q;

			if (ind == 0) break;

			ind--;



			T[ind] += T[i] * (a / Q[ind]);

			a %= Q[ind];

		}



		A[cnt - 1] += (a / cnt) * T[i];

		if (a % cnt) A[a % cnt - 1] += T[i];

	}



	//FOR(i, 0, n) cout << A[i] << " ";

	//cout << endl;

	RFOR(i, n - 1, 0)

	{

		A[i] += A[i + 1];

	}



	FOR(i, 0, n) cout << A[i] << " \n";

	cout << endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.174482222282146x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

const int MAXN=100005;



int N,Q,tp;

long long q[MAXN],stk[MAXN];

long long sum[MAXN],cnt[MAXN];



int main()

{

    scanf("%d%d",&N,&Q);

    for(int i=1;i<=Q;i++)

        scanf("%lld",&q[i]);

    stk[tp=1]=N;

    for(int i=1;i<=Q;i++)

    {

        while(tp&&stk[tp]>=q[i])

            tp--;

        stk[++tp]=q[i];

    }



	cnt[tp]=1;

	for(int i=tp;i>0;i--)

	{

		long long k=stk[i];

		int p=i-1;

		while(p)

		{

			cnt[p]+=(k/stk[p])*cnt[i];

			k%=stk[p];

			p=lower_bound(stk+1,stk+p,k)-stk;

			p--;

		}

		sum[1]+=cnt[i];

		sum[k+1]-=cnt[i];

		//printf("Add(1,%lld)\n",k);

	}

	long long ans=0;

	for(int i=1;i<=N;i++)

	{

		ans+=sum[i];

		printf("%lld\n",ans);

	}



    fclose(stdin);

    fclose(stdout);

    return 0;

}
// Slower C++ solution:
#include <algorithm>

#include <iterator>

#include <iostream>

#include <cstring>

#include <cstdio>

#include <vector>

#include <stack>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;

typedef long long i64;

const int MAXN = 1e5 + 10;

const int MAXQ = 1e5 + 10;



int N, Q;



int monoTop;

i64 monoStk[MAXN], tmp[MAXN], ans[MAXN];



void solve(i64 query, i64 delta)

{

	int index = lower_bound(monoStk + 1, monoStk + monoTop + 1, query) - monoStk - 1;

	if(index <= 0)

		ans[1] += delta, ans[query + 1] -= delta;

	else

		tmp[index] += delta * (query / monoStk[index]),

		solve(query % monoStk[index], delta);

}



int main()

{

	//REDIRECT("seq");



	scanf("%d%d", &N, &Q);

	monoStk[++monoTop] = N;

	for(int i = 1; i <= Q; i++)

	{

		i64 t;

		scanf("%lld", &t);



		while(monoTop && t < monoStk[monoTop])

			monoTop--;

		monoStk[++monoTop] = t;

	}



	tmp[monoTop] = 1;

	for(int i = monoTop; i > 0; i--)

		solve(monoStk[i], tmp[i]);

	for(int i = 1; i <= N; i++)

		ans[i] += ans[i-1], printf("%lld\n", ans[i]);



	CLOSEALL();

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.094089484040773x):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

const int MAXN=100005;



int N,Q,tp;

long long q[MAXN],stk[MAXN];

long long sum[MAXN],cnt[MAXN];



int main()

{

    scanf("%d%d",&N,&Q);

    for(int i=1;i<=Q;i++)

        scanf("%lld",&q[i]);

    stk[tp=1]=N;

    for(int i=1;i<=Q;i++)

    {

        while(tp&&stk[tp]>=q[i])

            tp--;

        stk[++tp]=q[i];

    }



	cnt[tp]=1;

	for(int i=tp;i>0;i--)

	{

		long long k=stk[i];

		int p=i-1;

		while(p)

		{

			cnt[p]+=(k/stk[p])*cnt[i];

			k%=stk[p];

			p=lower_bound(stk+1,stk+p,k)-stk;

			p--;

		}

		sum[1]+=cnt[i];

		sum[k+1]-=cnt[i];

		//printf("Add(1,%lld)\n",k);

	}

	long long ans=0;

	for(int i=1;i<=N;i++)

	{

		ans+=sum[i];

		printf("%lld\n",ans);

	}



    fclose(stdin);

    fclose(stdout);

    return 0;

}