Problem p03647 (C++)

Buggy submission (status: Runtime Error):
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

#define _SCL_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#define push_back pb
#define make_pair mp
#define first x
#define second y

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <ciso646>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#ifdef LOCAL
// #include <vld.h>
#endif // LOCAL
using namespace std;

typedef long long ll;
typedef long double ld;

#define speedup                                                                \
  cout.tie(nullptr);                                                           \
  cin.tie(nullptr);                                                            \
  ios_base::sync_with_stdio(false)
#define coutdouble                                                             \
  cout << setprecision(20);                                                    \
  cout << fixed

#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

/*------CommentInInteractive--------*/
#ifndef LOCAL
#define endl "\n"
#endif // LOCAL
/*----------------------------------*/
const int INF = 1000 * 1000 * 1000 + 322;
const ll LLINF = 2LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL + 57;
const ll MOD = 1000 * 1000 * 1000 + 7;
const int RMOD = MOD - 2;
const int N = 100 * 1000 + 57;
const int P1M = 1336337; // Large prime ( ~1M )
const int P1K = 1009;    // Big prime ( ~1K )
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932384626433832795;
/*------------------------------------------------IO_OPERATORS---------------------------------------------*/
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << " " << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty())
    return _out;
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T> inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v)
    _in >> _i;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const set<T> &_s) {
  if (_s.empty())
    return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const multiset<T> &_s) {
  if (_s.empty())
    return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_set<T> &_s) {
  if (_s.empty())
    return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_multiset<T> &_s) {
  if (_s.empty())
    return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const map<T, U> &_m) {
  if (_m.empty())
    return _out;
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it)
    _out << ", (" << _it->first << ": " << _it->second << ')';
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const unordered_map<T, U> &_m) {
  if (_m.empty())
    return _out;
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it)
    _out << ", (" << _it->first << ": " << _it->second << ')';
  return _out;
}
/*--------------------------------------------------IO_FILES-----------------------------------------------*/
const char *infile =
#ifdef LOCAL
    "input.txt"
#else
    ""
#endif // LOCAL
    ;
const char *outfile =
#ifdef LOCAL
    ""
#else
    ""
#endif // LOCAL
    ;

/*-------------------------------------------------ALLOCATOR----------------------------------------------*/
// #define ALLOC_LOCAL
#ifdef ALLOC_LOCAL
const int ML_ = 200;
char mem_[ML_ * 1000000];
size_t ptr = 0;
void *operator new(size_t cnt) {
  if (ptr + cnt < sizeof mem_) {
    ptr += cnt;
    return mem_ + ptr - cnt;
  } else {
    ptr = cnt;
    return mem_;
  }
}
void operator delete(void *) {}
#endif // ALLOC_LOCAL
/*----------------------------------------------------MATHS------------------------------------------------*/
inline ll gcd(ll a, ll b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll pwm(ll xx, ll pow, ll MD = MOD) {
  ll mlt = 1;
  while (pow) {
    if (pow & 1) {
      mlt *= xx;
      xx *= xx;
      pow >>= 1;
      xx %= MD;
      mlt %= MD;
    } else {
      pow >>= 1;
      xx *= xx;
      xx %= MD;
    }
  }
  return mlt;
}
inline ll pw(ll xx, int pow) {
  ll mlt = 1;
  while (pow) {
    if (pow & 1) {
      mlt *= xx;
      xx *= xx;
      pow >>= 1;
    } else {
      pow >>= 1;
      xx *= xx;
    }
  }
  return mlt;
}
inline ll inv(ll r) { return pwm(r, RMOD); }
/*--------------------------------------------------------------------------------------------------------*/

set<int> g[N];

inline void solve(ld tt) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].insert(v);
    g[v].insert(u);
  }
  for (auto u : g[1]) {
    if (g[u].find(n) != g[u].end()) {
      cout << "POSSIBLE\n";
      return;
    }
  }
  cout << "IMPOSSIBLE\n";
}

int main() {
  ld tt = clock();

  if (*infile != '\0')
    freopen(infile, "r", stdin);
  if (*outfile != '\0')
    freopen(outfile, "w", stdout);

  speedup;
  coutdouble;

  // int tst = 1;
  // cin >> tst;
  // scanf("%d", &tst);
  // while (tst-- > 0) {
  // while(true)
  solve(tt);
  // cout << "/*-----------------*/\n";
  // }

#ifdef LOCAL
  cout << "Time: " << ((ld)clock() - tt) / CLOCKS_PER_SEC << endl;
  while (true)
    ;
#endif // LOCAL
  return 0;
}

Fixed submission:
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

#define _SCL_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#define push_back pb
#define make_pair mp
#define first x
#define second y

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <ciso646>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#ifdef LOCAL
// #include <vld.h>
#endif // LOCAL
using namespace std;

typedef long long ll;
typedef long double ld;

#define speedup                                                                \
  cout.tie(nullptr);                                                           \
  cin.tie(nullptr);                                                            \
  ios_base::sync_with_stdio(false)
#define coutdouble                                                             \
  cout << setprecision(20);                                                    \
  cout << fixed

#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

/*------CommentInInteractive--------*/
#ifndef LOCAL
#define endl "\n"
#endif // LOCAL
/*----------------------------------*/
const int INF = 1000 * 1000 * 1000 + 322;
const ll LLINF = 2LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL + 57;
const ll MOD = 1000 * 1000 * 1000 + 7;
const int RMOD = MOD - 2;
const int N = 200 * 1000 + 57;
const int P1M = 1336337; // Large prime ( ~1M )
const int P1K = 1009;    // Big prime ( ~1K )
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932384626433832795;
/*------------------------------------------------IO_OPERATORS---------------------------------------------*/
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << " " << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty())
    return _out;
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T> inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v)
    _in >> _i;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const set<T> &_s) {
  if (_s.empty())
    return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const multiset<T> &_s) {
  if (_s.empty())
    return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_set<T> &_s) {
  if (_s.empty())
    return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_multiset<T> &_s) {
  if (_s.empty())
    return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it)
    _out << ' ' << *_it;
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const map<T, U> &_m) {
  if (_m.empty())
    return _out;
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it)
    _out << ", (" << _it->first << ": " << _it->second << ')';
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const unordered_map<T, U> &_m) {
  if (_m.empty())
    return _out;
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it)
    _out << ", (" << _it->first << ": " << _it->second << ')';
  return _out;
}
/*--------------------------------------------------IO_FILES-----------------------------------------------*/
const char *infile =
#ifdef LOCAL
    "input.txt"
#else
    ""
#endif // LOCAL
    ;
const char *outfile =
#ifdef LOCAL
    ""
#else
    ""
#endif // LOCAL
    ;

/*-------------------------------------------------ALLOCATOR----------------------------------------------*/
// #define ALLOC_LOCAL
#ifdef ALLOC_LOCAL
const int ML_ = 200;
char mem_[ML_ * 1000000];
size_t ptr = 0;
void *operator new(size_t cnt) {
  if (ptr + cnt < sizeof mem_) {
    ptr += cnt;
    return mem_ + ptr - cnt;
  } else {
    ptr = cnt;
    return mem_;
  }
}
void operator delete(void *) {}
#endif // ALLOC_LOCAL
/*----------------------------------------------------MATHS------------------------------------------------*/
inline ll gcd(ll a, ll b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll pwm(ll xx, ll pow, ll MD = MOD) {
  ll mlt = 1;
  while (pow) {
    if (pow & 1) {
      mlt *= xx;
      xx *= xx;
      pow >>= 1;
      xx %= MD;
      mlt %= MD;
    } else {
      pow >>= 1;
      xx *= xx;
      xx %= MD;
    }
  }
  return mlt;
}
inline ll pw(ll xx, int pow) {
  ll mlt = 1;
  while (pow) {
    if (pow & 1) {
      mlt *= xx;
      xx *= xx;
      pow >>= 1;
    } else {
      pow >>= 1;
      xx *= xx;
    }
  }
  return mlt;
}
inline ll inv(ll r) { return pwm(r, RMOD); }
/*--------------------------------------------------------------------------------------------------------*/

set<int> g[N];

inline void solve(ld tt) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].insert(v);
    g[v].insert(u);
  }
  for (auto u : g[1]) {
    if (g[u].find(n) != g[u].end()) {
      cout << "POSSIBLE\n";
      return;
    }
  }
  cout << "IMPOSSIBLE\n";
}

int main() {
  ld tt = clock();

  if (*infile != '\0')
    freopen(infile, "r", stdin);
  if (*outfile != '\0')
    freopen(outfile, "w", stdout);

  speedup;
  coutdouble;

  // int tst = 1;
  // cin >> tst;
  // scanf("%d", &tst);
  // while (tst-- > 0) {
  // while(true)
  solve(tt);
  // cout << "/*-----------------*/\n";
  // }

#ifdef LOCAL
  cout << "Time: " << ((ld)clock() - tt) / CLOCKS_PER_SEC << endl;
  while (true)
    ;
#endif // LOCAL
  return 0;
}