Problem p02823 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define int ll
#define maxn 1000005
#define mod 10007LL
#define inf 1000000007LL
namespace lib {
using namespace std;
class fastio {
private:
#define _NUMLEN 111
  char _num[_NUMLEN], _ch;
  int _f, _head;
  bool _useSTD;

public:
  inline void ioSTD() {
    _useSTD = 1;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
  }
  inline void gc(char &_c) {
    if (_useSTD)
      cin >> _c;
    else
      _c = getchar();
  }
  inline void pc(char _c) {
    if (_useSTD)
      cout << _c;
    else
      putchar(_c);
  }
  template <typename _T> inline fastio &operator-(_T &_x) {
    if (_useSTD)
      cin >> _x;
    else {
      _x = 0;
      while (!isdigit(_ch))
        _f |= _ch == '-', gc(_ch);
      while (isdigit(_ch))
        _x = (_x << 1) + (_x << 3) + (_ch ^ 48), gc(_ch);
      _f && (_x = -_x, _f = 0);
    }
    return *this;
  }
  template <typename _T> inline fastio &operator+(_T _x) {
    if (_useSTD)
      cin >> _x;
    else {
      _T _k;
      if (_x == 0) {
        pc('0'), pc(' ');
        return *this;
      }
      if (_x < 0)
        pc('-'), _x = -_x;
      while (_x > 0)
        _k = _x / 10, ++_head, _num[_head] = (_x - (_k << 1) - (_k << 3)) ^ 48,
        _x = _k;
      while (_head > 0)
        pc(_num[_head]), --_head;
      pc(' ');
    }
    return *this;
  }
  template <typename _T> inline fastio &operator>>(_T &_x) {
    cin >> _x;
    return *this;
  }
  template <typename _T> inline fastio &operator<<(_T _x) {
    cout << _x;
    return *this;
  }
#define endln pc('\n')
  fastio() { _f = 0, _head = 0, _useSTD = 0, _ch = ' '; }
} io;
inline void fileio(string _r, string _w) {
  if (_r[0] != '-')
    freopen(_r.c_str(), "r", stdin);
  if (_w[0] != '-')
    freopen(_w.c_str(), "w", stdout);
}
#define mem(_x, _set) memset(_x, _set, sizeof(_x))
} // namespace lib
using namespace lib;

signed main() {
  //	fileio("tt.in","tt.out");
  //	io.ioSTD();
  ll n, a, b;
  io - n - a - b;
  if ((b - a) % 2 == 0)
    io + (b - a) / 2;
  else
    io + min((a + b - 1) / 2, (n - a + n - b + 1) / 2);
  return 1;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define int ll
#define maxn 1000005
#define mod 10007LL
#define inf 1000000007LL
namespace lib {
using namespace std;
class fastio {
private:
#define _NUMLEN 111
  char _num[_NUMLEN], _ch;
  int _f, _head;
  bool _useSTD;

public:
  inline void ioSTD() {
    _useSTD = 1;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
  }
  inline void gc(char &_c) {
    if (_useSTD)
      cin >> _c;
    else
      _c = getchar();
  }
  inline void pc(char _c) {
    if (_useSTD)
      cout << _c;
    else
      putchar(_c);
  }
  template <typename _T> inline fastio &operator-(_T &_x) {
    if (_useSTD)
      cin >> _x;
    else {
      _x = 0;
      while (!isdigit(_ch))
        _f |= _ch == '-', gc(_ch);
      while (isdigit(_ch))
        _x = (_x << 1) + (_x << 3) + (_ch ^ 48), gc(_ch);
      _f && (_x = -_x, _f = 0);
    }
    return *this;
  }
  template <typename _T> inline fastio &operator+(_T _x) {
    if (_useSTD)
      cin >> _x;
    else {
      _T _k;
      if (_x == 0) {
        pc('0'), pc(' ');
        return *this;
      }
      if (_x < 0)
        pc('-'), _x = -_x;
      while (_x > 0)
        _k = _x / 10, ++_head, _num[_head] = (_x - (_k << 1) - (_k << 3)) ^ 48,
        _x = _k;
      while (_head > 0)
        pc(_num[_head]), --_head;
      pc(' ');
    }
    return *this;
  }
  template <typename _T> inline fastio &operator>>(_T &_x) {
    cin >> _x;
    return *this;
  }
  template <typename _T> inline fastio &operator<<(_T _x) {
    cout << _x;
    return *this;
  }
#define endln pc('\n')
  fastio() { _f = 0, _head = 0, _useSTD = 0, _ch = ' '; }
} io;
inline void fileio(string _r, string _w) {
  if (_r[0] != '-')
    freopen(_r.c_str(), "r", stdin);
  if (_w[0] != '-')
    freopen(_w.c_str(), "w", stdout);
}
#define mem(_x, _set) memset(_x, _set, sizeof(_x))
} // namespace lib
using namespace lib;

signed main() {
  //	fileio("tt.in","tt.out");
  //	io.ioSTD();
  ll n, a, b;
  io - n - a - b;
  if ((b - a) % 2 == 0)
    io + (b - a) / 2;
  else
    io + min((a + b - 1) / 2, (n - a + n - b + 1) / 2);
  return 0;
}