Language: C++

#include <iostream>
#include <vector>
#include <stack>
#include <deque>
#include <map>
#include <cmath>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <numeric>

//SFPA stands for Shortest Path Faster Algorithm, which is an improvement of the Bellman–Ford algorithm.

//if you would like this program to run faster, use pair or vector instead of map in Edge.
template<class T>
using Edge = std::pair<T, T>; //for this algorithm, an edge must have "successor" and "cost" keys.
template<class T>
using Graph = std::vector<std::vector<Edge<T> > >;

//V is the number of the vertices of the graph. The id of a vertex in the graph must be in [0,V).
template<class T>
std::vector<T> BellmanFord(Graph<T> &graph, const T &start){
    const T V = graph.size();
    const T distanceSup = std::numeric_limits<T>::max();
    const T distanceInf = std::numeric_limits<T>::min();
    const T zero = static_cast<T>(0);

    std::vector<T> distance(V, distanceSup);
    distance[start] = zero;

    std::deque<T> queue;
    std::vector<bool> isInQueue(V,false);
    std::vector<T> count(V,zero);
    queue.emplace_back(start);
    isInQueue[start] = true;
    ++count[start];
    T distanceTmp;
    T pred, suc;
    while(!queue.empty()){
        pred = queue.front();
        queue.pop_front();
        isInQueue[pred] = false;
        for(auto &edge : graph[pred]){
            suc = edge.first;
            distanceTmp = distance[pred] > distanceInf ? distance[pred] + edge.second : distanceInf;
            if(distance[suc] > distanceTmp){
                distance[suc] = distanceTmp;
                if(!isInQueue[suc]){
                    queue.emplace_back(suc)
                    if(distance[queue.back()] < distance[queue.front()]){
                        queue.pop_back();
                        queue.emplace_front(suc);
                    }
                    isInQueue[suc] = true;
                    if(++count[suc] >= V){
                        distance[suc] = distanceInf;
                    }
                }
            }
        }
    }

    return distance;
}

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;

    auto id = [&N](int a,int b){
        if(a > b){
            using std::swap;
            swap(a,b);
        }
        return (a*(2*N-a-1))/2 + b - a -1;
    };

    int i,j;
    Graph<int> graph((N*(N-1))/2+1);
    int root = graph.size()-1;
    int pred, suc;
    for(i=0; i<N; ++i){
        pred = root;
        for(j=0; j<N-1; ++j){
            std::cin >> suc;
            suc = id(i,--suc);
            graph[pred].emplace_back(suc,-1);
            pred = suc;
        }
    }

    auto dist = BellmanFord(graph,root);
    auto days = *std::min_element(dist.begin(),dist.end());
    if(days <= std::numeric_limits<int>::min()){
        std::cout << -1 << std::endl;
    }else{
        std::cout << -days << std::endl;
    }

    return 0;
}


Compiler output:
a.cc: In function 'std::vector<T> BellmanFord(Graph<T>&, const T&)':
a.cc:50:44: error: expected ';' before 'if'
   50 |                     queue.emplace_back(suc)
      |                                            ^
      |                                            ;
   51 |                     if(distance[queue.back()] < distance[queue.front()]){
      |                     ~~