stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int func(int n)

{

    int p=n;

    int q;

    int b[10];

    int i=0;

    while(p)

    {

      q=p%10;

      b[i]=q;

      p=p/10;

      i++;

    }



    i--;

    int o=3;

    for(int j=0;j<i;j++)

    {

        if(b[j]-b[j+1]==1)o=1;

            else

        {

            o=0;

            break;

        }

    }

    return o;

}



int main()

{

    int n;

    int a[1005];

    scanf("%d",&n);



    for(int i=0;i<n;i++)

    {

        scanf("%d",&a[i]);

    }



    int c,d;

    int ans=-1;



    for(int i=0;i<n;i++)

    {

        for(int j=0;j<n;j++)

        {

            if(i!=j)

            {

                c=a[i]*a[j];



                d=func(c);



                if(d==1 or d==3) ans=max(ans,c);

            }

        }

    }



    cout<<ans<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.197056809024893x):


#include <algorithm>

#include <bitset>

#include <cassert>

#include <cctype>

#include <climits>

#include <cmath>

#include <complex>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <ctime>

#include <functional>

#include <iomanip>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <stack>

#include <string>

#include <vector>

using namespace std;



typedef long long ll;

const int N = 1005;

const int M = 1000000007;



int nums[N];



bool check(long long num){

    int last_num=-1;

    while(num>0){

        int now = num%10;

        num/=10;



        if(last_num==-1){

            last_num = now;

        }else{

            if(now!=last_num-1){

                return false;

            }

            last_num = now;

        }



    }

    return true;

}



int main() {

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++){

        scanf("%d",&nums[i]);

    }

    long long result = -1;

    for(int i=0;i<n;i++){

        for(int j=i+1;j<n;j++){

            long long tmp = nums[i]*nums[j];

            if(check(tmp)){

                if(tmp>result)

                    result = tmp;

            }

        }

    }

    printf("%lld\n", result);

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

#include <string>

#include <map>

#include <set>

#include <cassert>

using namespace std;

#define rep(i,a,n) for (int i=a;i<n;i++)

#define per(i,a,n) for (int i=n-1;i>=a;i--)

#define pb push_back

#define mp make_pair

#define all(x) (x).begin(),(x).end()

#define fi first

#define se second

#define SZ(x) ((int)(x).size())

typedef vector<int> VI;

typedef long long ll;

typedef pair<int,int> PII;

const ll mod=1000000007;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

// head



const int N=1010;

int n,a[N],ret;

bool valid(int x) {

	VI d;

	while (x) {

		d.pb(x%10);

		x/=10;

	}

	rep(i,0,SZ(d)-1) if (d[i]!=d[i+1]+1) return 0;

	return 1;

}

int main() {

	scanf("%d",&n);

	rep(i,0,n) scanf("%d",a+i);

	ret=-1;

	rep(i,0,n) rep(j,i+1,n) if (valid(a[i]*a[j])) ret=max(ret,a[i]*a[j]);

	printf("%d\n",ret);

}

// Faster C++ solution for the same problem (measured speedup: 4.852200723265532x):


#include <algorithm>

#include <bitset>

#include <cassert>

#include <cctype>

#include <climits>

#include <cmath>

#include <complex>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <ctime>

#include <functional>

#include <iomanip>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <stack>

#include <string>

#include <vector>

using namespace std;



typedef long long ll;

const int N = 1005;

const int M = 1000000007;



int nums[N];



bool check(long long num){

    int last_num=-1;

    while(num>0){

        int now = num%10;

        num/=10;



        if(last_num==-1){

            last_num = now;

        }else{

            if(now!=last_num-1){

                return false;

            }

            last_num = now;

        }



    }

    return true;

}



int main() {

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++){

        scanf("%d",&nums[i]);

    }

    long long result = -1;

    for(int i=0;i<n;i++){

        for(int j=i+1;j<n;j++){

            long long tmp = nums[i]*nums[j];

            if(check(tmp)){

                if(tmp>result)

                    result = tmp;

            }

        }

    }

    printf("%lld\n", result);

}
// Slower C++ solution:
#include <iostream>

#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <cstring>

#include <stack>

#include <cctype>

#include <queue>

#include <string>

#include <vector>

#include<functional>

#include <set>

#include <map>

#include <climits>

#define lson root<<1,l,mid

#define rson root<<1|1,mid+1,r

#define fi first

#define se second

#define ping(x,y) ((x-y)*(x-y))

#define mst(x,y) ir(x,y,sizeof(x))

#define mcp(x,y) memcpy(x,y,sizeof(y))

using namespace std;

#define gamma 0.5772156649015328606065120

#define MOD 1000000007

#define inf 0x3f3f3f3f

#define N 100005

#define maxn 10005

typedef long long int LL;



int x[1010];

int main()

{

    int n,i;

    scanf("%d",&n);

    for(i=0; i<n; i++)

        scanf("%d",&x[i]);

    int ans=-1;

    int a,b,f,c,h,he;

    for(a=0; a<n; a++)

        for(b=0; b<n; b++)

        {

            if(a==b)

                continue;

            h=x[a]*x[b];

            if(h<ans)

                continue;

            he=h;

            c=h%10;

            h/=10;

            f=0;

            while(h)

            {

                int d=h%10;

                if(d==c-1)

                    c--;

                else

                {

                    f=1;

                    break;

                }

                h/=10;

            }

            if(f==0&&he>ans)

                ans=he;



        }

    printf("%d\n",ans);



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.172708561968728x):


#include <algorithm>

#include <bitset>

#include <cassert>

#include <cctype>

#include <climits>

#include <cmath>

#include <complex>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <ctime>

#include <functional>

#include <iomanip>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <stack>

#include <string>

#include <vector>

using namespace std;



typedef long long ll;

const int N = 1005;

const int M = 1000000007;



int nums[N];



bool check(long long num){

    int last_num=-1;

    while(num>0){

        int now = num%10;

        num/=10;



        if(last_num==-1){

            last_num = now;

        }else{

            if(now!=last_num-1){

                return false;

            }

            last_num = now;

        }



    }

    return true;

}



int main() {

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++){

        scanf("%d",&nums[i]);

    }

    long long result = -1;

    for(int i=0;i<n;i++){

        for(int j=i+1;j<n;j++){

            long long tmp = nums[i]*nums[j];

            if(check(tmp)){

                if(tmp>result)

                    result = tmp;

            }

        }

    }

    printf("%lld\n", result);

}
// Slower C++ solution:
#include<stdio.h>

#include<iostream>

#include<sstream>

#include<algorithm>

using namespace std;

int a[1005];

int cmp(int a,int b)

{

    return a>b;

}

int cha(int n)

{

    stringstream ss;

    ss<<n;

    string s;

    ss>>s;

    for(int i=1; s[i]; i++)

    {

        if(s[i]-1!=s[i-1])

            return 0;

    }

    return 1;

}

int main()

{

    int n;

    while(~scanf("%d",&n))

    {

        for(int i=0; i<n; i++)

        {

            scanf("%d",&a[i]);

        }

        sort(a,a+n,cmp);

        int ans=-1;

        for(int i=0; i<n; i++)

        {

            for(int j=0; j<n; j++)

            {

                if(i==j)continue;

                if(cha(a[i]*a[j]))

                {

                    ans=a[i]*a[j];

                    break;

                }

            }

            if(ans!=-1)

                break;

        }

        printf("%d\n",ans);

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.323823436341394x):


#include <algorithm>

#include <bitset>

#include <cassert>

#include <cctype>

#include <climits>

#include <cmath>

#include <complex>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <ctime>

#include <functional>

#include <iomanip>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <stack>

#include <string>

#include <vector>

using namespace std;



typedef long long ll;

const int N = 1005;

const int M = 1000000007;



int nums[N];



bool check(long long num){

    int last_num=-1;

    while(num>0){

        int now = num%10;

        num/=10;



        if(last_num==-1){

            last_num = now;

        }else{

            if(now!=last_num-1){

                return false;

            }

            last_num = now;

        }



    }

    return true;

}



int main() {

    int n;

    scanf("%d",&n);

    for(int i=0;i<n;i++){

        scanf("%d",&nums[i]);

    }

    long long result = -1;

    for(int i=0;i<n;i++){

        for(int j=i+1;j<n;j++){

            long long tmp = nums[i]*nums[j];

            if(check(tmp)){

                if(tmp>result)

                    result = tmp;

            }

        }

    }

    printf("%lld\n", result);

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define rep(i, a, n) for(int i = a; i < n; i++)

#define repb(i, a, b) for(int i = a; i >= b; i--)

#define all(a) a.begin(), a.end()

#define o(a) cout << a << endl

#define int long long

using namespace std;

typedef pair<int, int> P;



struct UF{

    vector<int> par;

    vector<int> sz;

    void init(int n){

        par.resize(n);

        sz.resize(n, 1);

        rep(i, 0, n) par[i] = i;

    }

    int find(int x){

        if(x == par[x]) return x;

        return par[x] = find(par[x]);

    }

    void unite(int x, int y){

        x = find(x); y = find(y);

        if(x == y) return;

        if(sz[x] < sz[y]) swap(x, y);

        sz[x] += sz[y];

        par[y] = x;

    }

    bool same(int x, int y){

        return find(x) == find(y);

    }

};



vector<int> lp[100010];//langauge id

vector<int> ls[100010];//person id

int n, m;



signed main(){

    cin >> n >> m;

    rep(i, 0, n){

        int k;

        cin >> k;

        rep(j, 0, k){

            int in;

            cin >> in;

            in--;

            lp[i]. push_back(in);

            ls[in]. push_back(i);

        }

    }

    UF uf;

    uf.init(n);

    rep(i, 0, m){

        if(ls[i].size() == 0) continue;

        rep(j, 1, ls[i].size()){

            uf.unite(ls[i][0], ls[i][j]);

        }

    }

    bool f = true;

    rep(i, 1, n){

        if(!uf.same(0, i)) f = false;

    }

    o((f ? "YES" : "NO"));

}

// Faster C++ solution for the same problem (measured speedup: 6.320604646773514x):
#include <bits/stdc++.h>

using namespace std;

using i64 = int64_t;

using vi = vector<i64>;

using vvi = vector<vi>;



int main() {

    int n, m;

    cin >> n >> m;

    vvi adj(n + m);

    for (int i = 0; i < n; i++) {

        int k;

        cin >> k;

        for (int j = 0; j < k; j++) {

            int a;

            cin >> a;

            a--;

            adj[i].push_back(n + a);

            adj[n + a].push_back(i);

        }

    }



    vi visited(n + m);

    function<void(int, int)> dfs = [&](int v, int p) {

        visited[v] = 1;

        for (int s : adj[v]) {

            if (s != p && !visited[s]) {

                dfs(s, v);

            }

        }

    };



    dfs(0, -1);



    int ok = 1;

    for (int i = 0; i < n; i++) {

        if (!visited[i]) {

            ok = 0;

            break;

        }

    }

    cout << (ok ? "YES" : "NO") << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define rep(i, a, n) for(int i = a; i < n; i++)

#define repb(i, a, b) for(int i = a; i >= b; i--)

#define all(a) a.begin(), a.end()

#define o(a) cout << a << endl

#define int long long

using namespace std;

typedef pair<int, int> P;



struct UF{

    vector<int> par;

    vector<int> sz;

    void init(int n){

        par.resize(n);

        sz.resize(n, 1);

        rep(i, 0, n) par[i] = i;

    }

    int find(int x){

        if(x == par[x]) return x;

        return par[x] = find(par[x]);

    }

    void unite(int x, int y){

        x = find(x); y = find(y);

        if(x == y) return;

        if(sz[x] < sz[y]) swap(x, y);

        sz[x] += sz[y];

        par[y] = x;

    }

    bool same(int x, int y){

        return find(x) == find(y);

    }

};



vector<int> lp[100010];//langauge id

vector<int> ls[100010];//person id

int n, m;



signed main(){

    cin >> n >> m;

    rep(i, 0, n){

        int k;

        cin >> k;

        rep(j, 0, k){

            int in;

            cin >> in;

            in--;

            lp[i]. push_back(in);

            ls[in]. push_back(i);

        }

    }

    UF uf;

    uf.init(n);

    rep(i, 0, m){

        if(ls[i].size() == 0) continue;

        rep(j, 1, ls[i].size()){

            uf.unite(ls[i][0], ls[i][j]);

        }

    }

    bool f = true;

    rep(i, 1, n){

        if(!uf.same(0, i)) f = false;

    }

    o((f ? "YES" : "NO"));

}

// Faster C++ solution for the same problem (measured speedup: 6.269250501579512x):
#include <bits/stdc++.h>

#define rep(i, a, n) for(int i = a; i < n; i++)

#define int long long

using namespace std;

typedef pair<int, int> P;

const int mod = 1000000007;

const int INF = 1e18;



struct UF{

    vector<int> par, sz;

    UF(){}

    UF(int n):par(n), sz(n, 1){

        iota(par.begin(), par.end(), 0);

    }

    int find(int x){

        if(x == par[x]) return x;

        return par[x] = find(par[x]);

    }

    void unite(int x, int y){

        x = find(x); y = find(y);

        if(x == y) return;

        if(sz[x] < sz[y]) swap(x, y);

        sz[x] += sz[y];

        par[y] = x;

    }

    bool same(int x, int y){

        return find(x) == find(y);

    }

};



signed main(){

    cin.tie(nullptr);

    ios::sync_with_stdio(false);

    int n, m;

    cin >> n >> m;

    UF uf(m);

    vector<int> cnt(m);

    rep(i, 0, n){

        int k;

        cin >> k;

        vector<int> l(k);

        rep(j, 0, k){

            cin >> l[j];

            l[j]--;

            cnt[l[j]]++;

        }

        rep(j, 0, k - 1){

            uf.unite(l[j], l[j + 1]);

        }

    }

    bool f = true;

    int id = -1;

    rep(i, 0, m){

        if(cnt[i]){

            if(id == -1) id = uf.find(i);

            else{

                if(uf.find(i) != id) f = false;

            }

        }

    }

    if(f) cout << "YES" << endl;

    else cout << "NO" << endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define mem(s,t) memset(s,t,sizeof(s))

#define pb(s) push_back(s)

#define inf 0x3f3f3f3f

#define mn 100010

typedef long long ll;

using namespace std;

bool nusd[mn],musd[mn];

queue<int> q;

vector<int> K[mn],L[mn];

int main()

{

	int n,m;scanf("%d%d",&n,&m);

	for(int i=0;i<n;++i){

		int k,l;scanf("%d",&k);

		while(k--){

			scanf("%d",&l);

			L[i].pb(l);

			K[l].pb(i);

		}

	}

	int e=0;

	nusd[0]=1;

	q.push(e);

	while(!q.empty()){

		e=q.front();q.pop();

		for(int i=0;i<L[e].size();++i){

			int t=L[e][i];

			if(musd[t])continue;

			musd[t]=1;

			for(int j=0;j<K[t].size();++j){

				int p=K[t][j];

				if(nusd[p])continue;

				nusd[p]=1;

				q.push(p);

			}

		}

	}

	bool ok=1;

	for(int i=0;i<n&&ok;++i){

		if(!nusd[i])ok=0;

	}

	if(ok)printf("YES");else printf("NO");



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.5089578573841065x):
// In the name of God



#include <bits/stdc++.h>



using namespace std;



const int N = 1e5+5;



int p[2 * N];



int find_set(int u) {

	if(p[u] == u) return u;

	return p[u] = find_set(p[u]);

}



void union_set(int u, int v) {

	int pu = find_set(u);

	int pv = find_set(v);

	p[pu] = pv;

}



int main() {

	ios_base::sync_with_stdio(false);

	cin.tie(0);

	for(int i = 0; i < 2 * N; i++) p[i] = i;

	int n, m;

	cin >> n >> m;

	for(int i = 0; i < n; i++) {

		int k;

		cin >> k;

		for(int j = 0; j < k; j++) {

			int x;

			cin >> x;

			x--;

			union_set(i, n + x);

		}

	}

	set<int> s;

	for(int i = 0; i < n; i++) s.insert(find_set(i));

	if(s.size() == 1) cout << "YES";

	else cout << "NO";

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int n;

int par[100010];

int Rank[100010];



void init(int n)

{

    for (int i = 0; i < n; i++)

    {

        par[i] = i;

        Rank[i] = 0;

    }

}

int find(int x)

{

    if (par[x] == x)

    {

        return x;

    }

    else

    {

        return par[x] = find(par[x]);

    }

}

void unit(int x, int y)

{

    x = find(x);

    y = find(y);

    if (x == y)

        return;



    if (Rank[x] < Rank[y])

    {

        par[x] = y;

    }

    else

    {

        par[y] = x;

        if (Rank[x] == Rank[y])

            Rank[x]++;

    }

}

bool same(int x, int y)

{

    return find(x) == find(y);

}



signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);



    int m;

    cin >> n >> m;

    vector<int> cnt[100010];

    for (int i = 0; i < n; i++)

    {

        int k;

        cin >> k;

        for (int j = 0; j < k; j++)

        {

            int a;

            cin >> a;

            a--;

            cnt[a].push_back(i);

        }

    }

    init(n);

    for (int i = 0; i < m; i++)

    {

        for (int j = 0; j < cnt[i].size(); j++)

        {

            unit(cnt[i][0], cnt[i][j]);

        }

    }

    bool f = true;

    for (int i = 0; i < n; i++)

    {

        f = f && same(0, i);

    }

    if (f)

        cout << "YES" << endl;

    else

        cout << "NO" << endl;

}

// Faster C++ solution for the same problem (measured speedup: 3.5367078999071295x):
#include <bits/stdc++.h>

#define INF 1e18

#define int long long

#define Rep(i, a, n) for (int i = (a); i < (n); i++)

#define rep(i, n) Rep(i, 0, n)

#define all(a) (a).begin(), (a).end()

using namespace std;

typedef pair<int, int> P;

typedef pair<int, P> PP;

const int mod = 1000000007;



#define N 200010

int par[N], Rank[N], SIZE[N];



void init(int n)

{

    rep(i, n)

    {

        par[i] = i;

        Rank[i] = 0;

        SIZE[i] = 1;

    }

}

int find(int x)

{

    if (par[x] == x)

        return x;

    else

        return par[x] = find(par[x]);

}

void unit(int x, int y)

{

    x = find(x);

    y = find(y);

    if (x == y)

        return;



    if (Rank[x] < Rank[y])

    {

        par[x] = y;

        SIZE[y] += SIZE[x];

    }

    else

    {

        par[y] = x;

        SIZE[x] += SIZE[y];

        if (Rank[x] == Rank[y])

            Rank[x]++;

    }

}

bool same(int x, int y)

{

    return find(x) == find(y);

}



signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);



    int n, m;

    cin >> n >> m;

    init(n + m);

    rep(i, n)

    {

        int k;

        cin >> k;

        rep(j, k)

        {

            int l;

            cin >> l;

            l += (n - 1);

            unit(i, l);

        }

    }

    rep(i, n) if (!same(0, i))

    {

        cout << "NO" << endl;

        return 0;

    }

    cout << "YES" << endl;

}
// Slower C++ solution:


#include <bits/stdc++.h>



using namespace std;



#define lli long long int

#define REP(i,s,l) for(lli i=s;i<l;i++)

#define DEBUG 0

#define INF (1LL<<50)

#define MOD 1000000007



signed main(){



	lli n,m;

	cin>>n>>m;



	/*言語を話せる人たちをまとめる*/

	map<lli,vector<lli>> l;



	/*また、j番目の人が話せる言語もまとめる*/

	map<lli,vector<lli>> p;



	for(lli i=0;i<n;i++){

		lli k;

		cin>>k;

		REP(j,0,k){

			lli tmp;

			cin>>tmp;

			l[tmp].push_back(i);

			p[i].push_back(tmp);

		}

	}



	lli lflag[100100]={0};

	lli pflag[100100]={0};



	/*0番目の人が話せる言語にアクセスする*/

	pflag[0]=1;

	queue<lli> q;

	q.push(0);



	while(q.size()){

		lli top = q.front();

		q.pop();

		if(DEBUG)cout<<"topPerson="<<top<<endl;

		/*この人は何の言語を話せる?*/

		for(auto e:p[top]){

			if(DEBUG)cout<<"Lang="<<e<<endl;

			if(lflag[e]==0){

				lflag[e]=1;

				/*この言語を話せる人をqにつっこみまくる*/

				for(auto f:l[e]){

					if(DEBUG)cout<<"nextPerson="<<f<<endl;

					if(pflag[f]==0){

						if(DEBUG)cout<<"push!"<<f<<endl;

						pflag[f]=1;

						q.push(f);

					}

				}

			}

		}

	}



	lli cnt=0;

	for(lli i=0;i<100100;i++){

		if(pflag[i])cnt++;

	}

	if(DEBUG)cout<<"cnt="<<cnt<<endl;

	if(cnt==n)cout<<"YES"<<endl;

	else cout<<"NO"<<endl;



	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.7139072333515686x):
#include <bits/stdc++.h>

 

using namespace std;

 

#define lli long long int

#define REP(i,s,n) for(int i=s;i<n;i++)

#define MOD 1000000007

#define NUM 2520

#define DEBUG 0

#define mp(a,b) make_pair(a,b)

#define SORT(V) sort(V.begin(),V.end())

#define PI (3.141592653589794)

#define INF (1LL<<50)





typedef struct UnionFind{

	vector<lli> par; //par[i]:iの親番号 par[3] = 2 : 3の親が2

	vector<lli> size;//size[i]:iの大きさ 自分のみのときは1,根っこにsizeを持たせる*/



	UnionFind(int N){/*最初はすべてが根であると初期化*/

		REP(i,0,N){

			par.push_back(i);

			size.push_back(1);

		}

	}



	lli root(lli x){/*データxが属する木の根を再起で得る root(x) = {xの木の根}}*/

		if(par[x] == x)return x;

		return par[x] = root(par[x]);

	}



	void unite(lli x,lli y){/*xとyの併合*/

		lli rx = root(x);

		lli ry = root(y);

		if(rx == ry)return;

		par[rx] = ry; /*xとyの根が同じじゃない: xの根をrxをyの根ryに変更する */

		lli resize = size[rx] + size[ry];

		size[rx] = resize;

		size[ry] = resize;

	}



	bool same(lli x,lli y){

		lli rx = root(x);

		lli ry = root(y);

		return rx == ry;

	}



	lli getSize(lli x){

		lli rx = root(x);

		return size[rx];

	}

};





signed main(){



	lli n,m;

	cin>>n>>m;



	UnionFind uf(n);



	map<lli,vector<lli>> lang;

	REP(i,0,n){

		lli k;

		cin>>k;

		REP(j,0,k){

			lli now;

			cin>>now;

			lang[now].push_back(i);

		}

	}



	for(auto e:lang){

		REP(i,1,e.second.size()){

			uf.unite(e.second.at(i-1),e.second.at(i));

		}

	}



	if(DEBUG)cout<<"ufSize="<<uf.getSize(0)<<endl;

	if(uf.getSize(0)==n){

		cout<<"YES"<<endl;

	}

	else{

		cout<<"NO"<<endl;

	}







	return 0;

}