Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  Int N = in();
  int Q = in();

  vector<Int> A;
  A.push_back(N);
  for (int i = 0; i < Q; ++i) {
    Int x = lin();
    while (!A.empty() && A.back() >= x) {
      A.pop_back();
    }
    A.push_back(x);
  }
  Q = A.size();
  reverse(A.begin(), A.end());

  vector<Int> W(max(A.back(), N), 0), WX(Q, 0);
  WX[0] = 1;
  for (int i = 0; i + 1 < Q; ++i) {
    Int pos = A[i];
    for (int j = i + 1; pos > 0 && j < Q; ) {
      int jj = upper_bound(A.begin() + j, A.end(), pos, [] (const Int& a, const Int& b) {
        return a > b;
      }) - A.begin();
      if (jj < Q) {
        WX[jj] += WX[i] * (pos / A[jj]);
        pos %= A[jj];
      }
      j = jj + 1;
    }#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  Int N = in();
  int Q = in();

  vector<Int> A;
  A.push_back(N);
  for (int i = 0; i < Q; ++i) {
    Int x = lin();
    while (!A.empty() && A.back() >= x) {
      A.pop_back();
    }
    A.push_back(x);
  }
  Q = A.size();
  reverse(A.begin(), A.end());

  vector<Int> W(max(A.back(), N), 0), WX(Q, 0);
  WX[0] = 1;
  for (int i = 0; i + 1 < Q; ++i) {
    Int pos = A[i];
    for (int j = i + 1; pos > 0 && j < Q; ) {
      int jj = upper_bound(A.begin() + j, A.end(), pos, [] (const Int& a, const Int& b) {
        return a > b;
      }) - A.begin();
      if (jj < Q) {
        WX[jj] += WX[i] * (pos / A[jj]);
        pos %= A[jj];
      }
      j = jj + 1;
    }
    if (pos > 0) {
      W[pos - 1] += WX[i];
    }
  }
  W[A[Q - 1] - 1] += WX[Q - 1];

  for (int v = A.back() - 2; v >= 0; --v) {
    W[v] += W[v + 1];
  }
  for (int v = 0; v < N; ++v) {
    printf("%lld\n", W[v]);
  }

  return 0;
}

    if (pos > 0) {
      W[pos - 1] += WX[i];
    }
  }
  W[A[Q - 1] - 1] += WX[Q - 1];

  for (int v = A.back() - 2; v >= 0; --v) {
    W[v] += W[v + 1];
  }
  for (int v = 0; v < N; ++v) {
    printf("%lld\n", W[v]);
  }

  return 0;
}


Compiler output:
a.cc:67:6: error: stray '#' in program
   67 |     }#include <cstdio>
      |      ^
a.cc: In function 'int main()':
a.cc:67:7: error: 'include' was not declared in this scope
   67 |     }#include <cstdio>
      |       ^~~~~~~
a.cc:67:16: error: 'cstdio' was not declared in this scope; did you mean 'stdin'?
   67 |     }#include <cstdio>
      |                ^~~~~~
      |                stdin
a.cc:88:1: error: expected primary-expression before 'using'
   88 | using namespace std;
      | ^~~~~
a.cc:97:1: error: a template declaration cannot appear at block scope
   97 | template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
      | ^~~~~~~~
a.cc:99:1: error: a template declaration cannot appear at block scope
   99 | template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
      | ^~~~~~~~
a.cc:101:11: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  101 | double fin() { double x; scanf("%lf", &x); return x; }
      |           ^~
a.cc:101:11: note: remove parentheses to default-initialize a variable
  101 | double fin() { double x; scanf("%lf", &x); return x; }
      |           ^~
      |           --
a.cc:101:11: note: or replace parentheses with braces to value-initialize a variable
a.cc:101:14: error: a function-definition is not allowed here before '{' token
  101 | double fin() { double x; scanf("%lf", &x); return x; }
      |              ^
a.cc:102:8: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  102 | Int lin() { Int x; scanf("%lld", &x); return x; }
      |        ^~
a.cc:102:8: note: remove parentheses to default-initialize a variable
  102 | Int lin() { Int x; scanf("%lld", &x); return x; }
      |        ^~
      |        --
a.cc:102:8: note: or replace parentheses with braces to value-initialize a variable
a.cc:102:11: error: a function-definition is not allowed here before '{' token
  102 | Int lin() { Int x; scanf("%lld", &x); return x; }
      |           ^
a.cc:104:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
  104 | int main() {
      |         ^~
a.cc:104:9: note: remove parentheses to default-initialize a variable
  104 | int main() {
      |         ^~
      |         --
a.cc:104:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:104:12: error: a function-definition is not allowed here before '{' token
  104 | int main() {
      |            ^