Problem p03647 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <unordered_map>

#define rep(i, n) for (i = 1; i <= n; i++)
#define Rep(i, n) for (i = 0; i < n; i++)
#define For(i, a, b) for (i = a; i <= b; i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara, val) memset(ara, val, sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d", &x)
#define sii(x, y) scanf("%d %d", &x, &y)
#define siii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sl(x) scanf("%lld", &x)
#define sll(x, y) scanf("%lld %lld", &x, &y)
#define slll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)
#define ss(ch) scanf("%s", ch)
#define pi(x) printf("%d", x)
#define pii(x, y) printf("%d %d", x, y)
#define piii(x, y, z) printf("%d %d %d", x, y, z)
#define pl(x) printf("%lld", x)
#define pll(x, y) printf("%lld %lld", x, y)
#define plll(x, y, z) printf("%lld %lld %lld", x, y, z)
#define ps(ch) printf("%s", ch)
#define Afridi 0
#define NL printf("\n")
#define D(x) cout << #x << " = " << x << endl
#define DD(x, y) cout << #x << " = " << x << " " << #y << " = " << y << endl
#define Max 100005
#define PI 3.141592653589793
#define FI freopen("in.txt", "r", stdin)
#define FO freopen("out.txt", "w", stdout)
#define mod 1000000007
#define INF (LL)1e18

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

LL bigmod(LL b, LL p) {
  if (p == 0)
    return 1;
  LL my = bigmod(b, p / 2);
  my *= my;
  my %= mod;
  if (p & 1)
    my *= b, my %= mod;
  return my;
}
int setb(int n, int pos) { return n = n | (1 << pos); }
int resb(int n, int pos) { return n = n & ~(1 << pos); }
bool checkb(int n, int pos) { return (bool)(n & (1 << pos)); }

LL n, dist[Max], par[Max], s[Max], m;
vector<LL> g[Max];

int main() {
  // FI;
  LL i, x, y, j;
  sll(n, m);
  rep(i, m) {
    sll(x, y);
    g[x].pb(y);
    g[y].pb(x);
  }
  rep(i, n) {
    if (sz(g[i])) {
      sort(g[i].begin(), g[i].end());
      reverse(g[i].begin(), g[i].end());
    }
  }
  LL flag = 0;
  Rep(i, sz(g[1])) {
    LL u = g[1][i];
    Rep(j, sz(g[u])) {
      LL v = g[u][j];
      if (v == n) {
        flag = 1;
      }
      break;
    }
    if (flag)
      break;
  }
  if (flag)
    puts("POSSIBLE");
  else
    puts("IMPOSSIBLE");
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#include <unordered_map>

#define rep(i, n) for (i = 1; i <= n; i++)
#define Rep(i, n) for (i = 0; i < n; i++)
#define For(i, a, b) for (i = a; i <= b; i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara, val) memset(ara, val, sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d", &x)
#define sii(x, y) scanf("%d %d", &x, &y)
#define siii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sl(x) scanf("%lld", &x)
#define sll(x, y) scanf("%lld %lld", &x, &y)
#define slll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)
#define ss(ch) scanf("%s", ch)
#define pi(x) printf("%d", x)
#define pii(x, y) printf("%d %d", x, y)
#define piii(x, y, z) printf("%d %d %d", x, y, z)
#define pl(x) printf("%lld", x)
#define pll(x, y) printf("%lld %lld", x, y)
#define plll(x, y, z) printf("%lld %lld %lld", x, y, z)
#define ps(ch) printf("%s", ch)
#define Afridi 0
#define NL printf("\n")
#define D(x) cout << #x << " = " << x << endl
#define DD(x, y) cout << #x << " = " << x << " " << #y << " = " << y << endl
#define Max 300005
#define PI 3.141592653589793
#define FI freopen("in.txt", "r", stdin)
#define FO freopen("out.txt", "w", stdout)
#define mod 1000000007
#define INF (LL)1e18

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

LL bigmod(LL b, LL p) {
  if (p == 0)
    return 1;
  LL my = bigmod(b, p / 2);
  my *= my;
  my %= mod;
  if (p & 1)
    my *= b, my %= mod;
  return my;
}
int setb(int n, int pos) { return n = n | (1 << pos); }
int resb(int n, int pos) { return n = n & ~(1 << pos); }
bool checkb(int n, int pos) { return (bool)(n & (1 << pos)); }

LL n, dist[Max], par[Max], s[Max], m;
vector<LL> g[Max];

int main() {
  // FI;
  LL i, x, y, j;
  sll(n, m);
  rep(i, m) {
    sll(x, y);
    g[x].pb(y);
    g[y].pb(x);
  }
  rep(i, n) {
    if (sz(g[i])) {
      sort(g[i].begin(), g[i].end());
      reverse(g[i].begin(), g[i].end());
    }
  }
  LL flag = 0;
  Rep(i, sz(g[1])) {
    LL u = g[1][i];
    Rep(j, sz(g[u])) {
      LL v = g[u][j];
      if (v == n) {
        flag = 1;
      }
      break;
    }
    if (flag)
      break;
  }
  if (flag)
    puts("POSSIBLE");
  else
    puts("IMPOSSIBLE");
  return 0;
}