Language: C++

50#include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    if(n == 0) break;
    string ans = "";
    int c;
    int a = 0,len = 0;
    rep(i,n){
      cin >> c;
      if(a == 0){
        ans += to_string(c);
        a = c ;
        ++len;
      }
      else{
        if(c - 1 == a){
          if(i == n-1){
            if(a == c-1){
              ans += '-';
              ans += to_string(c);
            }
          }
          a = c ;
          ++len;
        }
        else{
          if(len > 1){
            ans += '-';
            ans += to_string(a);
          }
          ans += ' ';
          ans += to_string(c);
          a = c ;
          len = 0;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc:1:3: error: stray '#' in program
    1 | 50#include <bits/stdc++.h>
      |   ^
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 50#include <bits/stdc++.h>
      | ^~
a.cc:25:12: error: 'vector' does not name a type
   25 | using vi = vector<int>;
      |            ^~~~~~
a.cc:26:12: error: 'vector' does not name a type
   26 | using vl = vector<ll>;
      |            ^~~~~~
a.cc:27:14: error: 'map' does not name a type
   27 | using dict = map<string,int>;
      |              ^~~
a.cc:28:14: error: 'complex' does not name a type
   28 | using comd = complex<double>;
      |              ^~~~~~~
a.cc:29:13: error: 'pair' does not name a type
   29 | using pii = pair<int,int> ;
      |             ^~~~
a.cc:33:23: error: 'acos' was not declared in this scope
   33 | constexpr double PI = acos(-1.0) ;
      |                       ^~~~
a.cc:38:17: error: 'comd' was not declared in this scope
   38 | double CalcDist(comd p1, comd p2){
      |                 ^~~~
a.cc:38:26: error: 'comd' was not declared in this scope
   38 | double CalcDist(comd p1, comd p2){
      |                          ^~~~
a.cc:38:33: error: expression list treated as compound expression in initializer [-fpermissive]
   38 | double CalcDist(comd p1, comd p2){
      |                                 ^
a.cc:43:6: error: variable or field 'out' declared void
   43 | void out(deque < T > d)
      |      ^~~
a.cc:43:10: error: 'deque' was not declared in this scope
   43 | void out(deque < T > d)
      |          ^~~~~
a.cc:43:20: error: expected primary-expression before '>' token
   43 | void out(deque < T > d)
      |                    ^
a.cc:43:22: error: 'd' was not declared in this scope
   43 | void out(deque < T > d)
      |                      ^
a.cc:52:8: error: 'string' was not declared in this scope
   52 | T ston(string& str, T n){
      |        ^~~~~~
a.cc:52:16: error: 'str' was not declared in this scope; did you mean 'std'?
   52 | T ston(string& str, T n){
      |                ^~~
      |                std
a.cc:52:23: error: expected primary-expression before 'n'
   52 | T ston(string& str, T n){
      |                       ^
a.cc:52:25: error: expected ';' before '{' token
   52 | T ston(string& str, T n){
      |                         ^
      |                         ;
a.cc: In function 'int main()':
a.cc:60:3: error: 'cin' was not declared in this scope
   60 |   cin.tie(0);
      |   ^~~
a.cc:61:3: error: 'ios' has not been declared
   61 |   ios::sync_with_stdio(false);
      |   ^~~
a.cc:65:5: error: 'string' was not declared in this scope
   65 |     string ans = "";
      |     ^~~~~~
a.cc:71:9: error: 'ans' was not declared in this scope
   71 |         ans += to_string(c);
      |         ^~~
a.cc:71:16: error: 'to_string' was not declared in this scope
   71 |         ans += to_string(c);
      |                ^~~~~~~~~
a.cc:79:15: error: 'ans' was not declared in this scope
   79 |               ans += '-';
      |               ^~~
a.cc:80:22: error: 'to_string' was not declared in this scope
   80 |               ans += to_string(c);
      |                      ^~~~~~~~~
a.cc:88:13: error: 'ans' was not declared in this scope
   88 |             ans += '-';
      |             ^~~
a.cc:89:20: error: 'to_string' was not declared in this scope
   89 |             ans += to_string(a);
      |                    ^~~~~~~~~
a.cc:91:11: error: 'ans' was not declared in this scope
   91 |           ans += ' ';
      |           ^~~
a.cc:92:18: error: 'to_string' was not declared in this scope
   92 |           ans += to_string(c);
      |                  ^~~~~~~~~
a.cc:98:5: error: 'cout' was not declared in this scope; did you mean 'scout'?
   98 |     cout << ans << endl;
      |     ^~~~
      |     scout
a.cc:98:13: error: 'ans' was not declared in this scope
   98 |     cout << ans << endl;
      |             ^~~
a.cc:98:20: error: 'endl' was not declared in this scope
   98 |     cout << ans << endl;
      |                    ^~~~