def bfs(x):
q = set()
visited[x] = 1
q.add(x)
c = 0
n = 1
while len(q) != 0:
v = q.pop()
if not visited[v]:
n += 1
visited[v] = 1
for i in g[v]:
if not visited[i]:
q.add(i)
c += 1
return c, n
n, m = map(int, input().split())
g = {}
visited = [0 for _ in range(n+1)]
for _ in range(m):
a, b = map(int, input().split())
try:
g[a].append(b)
except:
g[a] = [b]
try:
g[b].append(a)
except:
g[b] = [a]
y = 'YES'
for i in g.keys():
y, n = bfs(i)
if y != (n*(n-1))//2:
y = 'NO'
break
else:
y = "YES"
print(y)
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
#include <set>
#include <limits>
#include <algorithm>
#include <cfenv>
#include <sstream>
#include <fstream>
#include <queue>
// #define ll long long
// #define yes "YES"
// #define no "NO"
#define en endl
#define phb push_back
using namespace std;
using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
// using i128 = __int128;
//--------------------------------------//
// https://trap.jp/post/1224/
#define FOR1(a) for (ll _ = 0; _ < ll(a); ++_)
#define FOR2(i, a) for (ll i = 0; i < ll(a); ++i)
#define FOR3(i, a, b) for (ll i = a; i < ll(b); ++i)
#define FOR4(i, a, b, c) for (ll i = a; i < ll(b); i += (c))
#define FOR1_R(a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR2_R(i, a) for (ll i = (a)-1; i >= ll(0); --i)
#define FOR3_R(i, a, b) for (ll i = (b)-1; i >= ll(a); --i)
#define overload4(a, b, c, d, e, ...) e
#define overload3(a, b, c, d, ...) d
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FOR_R(...) overload3(__VA_ARGS__, FOR3_R, FOR2_R, FOR1_R)(__VA_ARGS__)
template <typename T, typename U>
vector<T> cumsum(vector<U> &A, int off = 1)
{
int N = A.size();
vector<T> B(N + 1);
FOR(i, N) { B[i + 1] = B[i] + A[i]; }
if (off == 0)
B.erase(B.begin());
return B;
}
template <class T>
constexpr T infty = 0;
template <>
constexpr int infty<int> = 1'000'000'000;
template <>
constexpr ll infty<ll> = ll(infty<int>) * infty<int> * 2;
template <>
constexpr u32 infty<u32> = infty<int>;
template <>
constexpr u64 infty<u64> = infty<ll>;
// template <>
// constexpr i128 infty<i128> = i128(infty<ll>) * infty<ll>;
template <>
constexpr double infty<double> = infty<ll>;
template <>
constexpr long double infty<long double> = infty<ll>;
template <typename T, typename U>
T ceil(T x, U y)
{
return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U>
T floor(T x, U y)
{
return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T, typename U>
T SUM(const vector<U> &A)
{
T sum = 0;
for (auto &&a : A)
sum += a;
return sum;
}
void YES(bool t = 1)
{
string s;
s = (t) ? "YES" : "NO";
cout << s << en;
}
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1)
{
string s;
s = (t) ? "Yes" : "No";
cout << s << en;
}
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1)
{
string s;
s = (t) ? "yes" : "no";
cout << s << en;
}
void no(bool t = 1) { yes(!t); }
unsigned int factorial(unsigned int n)
{
unsigned int ret = 1;
for (int i = 1; i <= n; ++i)
ret *= i;
return ret;
}
ll divisors(ll n)
{
ll s = 0;
for (int i = 1; i * i <= n; i++)
{
if (n % i == 0)
{
if (i != n / i)
{
s += 2;
}
else
s++;
}
}
return s;
}
//--------------------------------------//
ll n, m, x, y, nodes, edges;
vector<bool> visited(150001, false);
void dfs(int node, const vector<vector<int>> &g)
{
visited[node] = 1;
nodes++;
for (auto i : g[node])
{
edges++;
if (!visited[i])
dfs(i, g);
}
}
int main()
{
cin >> n >> m;
vector<vector<int>> g(n + 1, vector<int>());
FOR1(m)
{
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
for (int i = 1; i <= n; i++)
{
nodes = 0;
edges = 0;
if (!visited[i])
{
dfs(i, g);
edges /= 2;
ll corr = (nodes * (nodes - 1)) / 2;
if (edges != corr)
{
NO(1);
return 0;
}
}
}
YES(1);
return 0;
}
1131F - Asya And Kittens | 1475F - Unusual Matrix |
133B - Unary | 1547A - Shortest Path with Obstacle |
624A - Save Luke | 1238A - Prime Subtraction |
1107C - Brutality | 1391B - Fix You |
988B - Substrings Sort | 312A - Whose sentence is it |
513A - Game | 1711E - XOR Triangle |
688A - Opponents | 20C - Dijkstra |
1627D - Not Adding | 893B - Beautiful Divisors |
864B - Polycarp and Letters | 1088A - Ehab and another construction problem |
1177B - Digits Sequence (Hard Edition) | 1155B - Game with Telephone Numbers |
1284A - New Year and Naming | 863B - Kayaking |
1395B - Boboniu Plays Chess | 1475D - Cleaning the Phone |
617B - Chocolate | 1051B - Relatively Prime Pairs |
95B - Lucky Numbers | 1692D - The Clock |
1553D - Backspace | 1670D - Very Suspicious |