Problem:


Score : 500 points

Problem Statement

Takahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.

First, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.

Then, Aoki gave him M queries. The i-th of them is as follows:

Increment the number written at each edge along the path connecting vertices a_i and b_i, by one.

After Takahashi executed all of the queries, he told Aoki that, for every edge, the written number became an even number.
However, Aoki forgot to confirm that the graph Takahashi created was actually a tree, and it is possible that Takahashi made a mistake in creating a tree or executing queries.

Determine whether there exists a tree that has the property mentioned by Takahashi.

Constraints

2 ≤ N ≤ 10^5

1 ≤ M ≤ 10^5

1 ≤ a_i,b_i ≤ N

a_i ≠ b_i

Input

Input is given from Standard Input in the following format:

N M
a_1 b_1
:
a_M b_M

Output

Print YES if there exists a tree that has the property mentioned by Takahashi; print NO otherwise.

Sample Input 1

4 4
1 2
2 4
1 3
3 4

Sample Output 1

YES

For example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3 and 1-4.
In this case, the number written at every edge will become 2.

Sample Input 2

5 5
1 2
3 5
5 1
3 4
2 3

Sample Output 2

NO



Sample input:
4 4
1 2
2 4
1 3
3 4


Sample output:
YES

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
vertex_dic = {}
def add_dic(p):
    if not p in vertex_dic:
        vertex_dic[p] = 1
    else:
        vertex_dic[p] += 1
for i in range(m):
    line = list(map(int, input().split()))
    add_dic(line[0])
    add_dic(line[1])
ans = "YES"
for key, item in vertex_dic.items():
    if item%2 == 1:
        ans = "NO"
print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
cnt=[0]*n
for _ in range(m):
	a,b=map(int,input().split())
	cnt[a-1]+=1
	cnt[b-1]+=1
f=1
for i in range(n):
	if cnt[i]%2!=0:
		f=0
		break
print("YES" if f else "NO")

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
ab = [list(map(int, readline().split())) for i in range(m)]
ans = [0] * n
for a, b in ab:
    ans[a - 1] += 1
    ans[b - 1] += 1
for i in range(n):
    if ans[i] % 2 == 1:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
d=dict()
for _ in range(m):
  a,b=map(int,input().split())
  if a not in d:
    d[a]=1
  else:
    d[a]+=1
  if b not in d:
    d[b]=1
  else:
    d[b]+=1
d=list(d.items())
for node,cnt in d:
  if cnt%2:
    print('NO')
    exit()
print('YES')

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [0]*N
for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    A[a] = abs(1-A[a])
    A[b] = abs(1-A[b])
ans = "YES"
for a in A:
    if a:ans="NO"
print(ans)

Submission status: Accepted

Solution code:
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    G = [0] * (n - 1)
    for _ in range(m):
        a,b = map(int,input().split())
        if a > b:
            a,b = b,a
        a -= 1
        b -= 1
        G[a] += 1
        if b != n - 1:
            G[b] -= 1
    
    ans = 'YES'
    if G[0]%2 == 1:
        print('NO')
        return

    for i in range(1,n - 1):
        G[i] += G[i - 1]
        if G[i]%2 == 1:
            ans = 'NO'
            break
    print(ans)
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "YES"  # type: str
NO = "NO"  # type: str


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    edge_weights = [0]*(N+1)
    # edge_weights[i] = iとi+1を繋ぐへんの重み
    for i in range(M):
        edge_weights[a[i]] += 1
        edge_weights[b[i]] -= 1
    
    from itertools import accumulate

    edge_weights = list(accumulate(edge_weights))
    for i in range(N+1):
        if edge_weights[i]%2 == 0:
            continue
        else:
            print(NO)
            return
    
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m = [int(x) for x in input().split()]
cnt = [0]*(n+1)
for i in range(m):
    a,b = [int(x) for x in input().split()]
    cnt[a]+=1
    cnt[b]+=1
for i in range(n):
  if cnt[i]%2==1:
    print("NO")
    exit()
print("YES")

Submission status: Accepted

Solution code:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    N,M = map(int,input().split())
    count_list = [0]*(N+1)
    for _ in range(M):
        a,b = map(int,input().split())
        count_list[a] += 1
        count_list[b] += 1
    for c in count_list:
        if c% 2 == 1:
            print('NO')
            return
    print('YES')
    return

    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections 
N,M=map(int,input().split())
L=[]
for i in range(M):
	X,Y=map(int,input().split())
	L.append(X)
	L.append(Y)
S=collections.Counter(L)
for i,j in S.items():
	if j%2==1:
		print("NO")
		exit()
print("YES")

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
cnt=defaultdict(lambda :0)
for i in range(m):
    cnt[ab[i][0]]+=1
    cnt[ab[i][1]]+=1

for i in cnt.values():
    if i%2!=0:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
# B - Unplanned Queries
n,m=map(int,input().split())
cnt=[0]*n
G=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    cnt[a-1]+=1
    cnt[b-1]+=1
for c in cnt:
    if c%2!=0:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
point = [0] * n
cnt = 0
for i in range(m):
    a,b = map(int,input().split())
    point[a-1] += 1
    point[b-1] += 1
    # if a > b:
    #     a,b = b,a
    # for j in range(a,b):
    #     edge[j-1] += 1
for i in range(len(point)):
    if point[i] % 2 == 1:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
table = [0] * (N + 1)
for _ in range(M):
  u, v = map(int, input().split())
  table[u] += 1
  table[v] += 1

for i in range(N + 1):
  if table[i] % 2:
    print("NO")
    exit(0)
print("YES")

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
C = [0]*N

for k in range(M):
    a, b = map(int,input().split())
    C[a-1] += 1
    C[b-1] += 1

for e in C:
    if e%2 != 0:
        print("NO")
        exit(0)
print("YES")

Submission status: Accepted

Solution code:
n, m = map(int, input().split())

ans = [0]*n
for _ in range(m):
    a, b = map(int, input().split())
    ans[a-1] += 1
    ans[b-1] += 1

for a in ans:
    if a % 2 != 0:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)

#print(g)
for i in range(n):
    if len(g[i])%2 == 1:
        print('NO')
        exit()
else:
    print('YES')

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ims = [0] * (N + 1)

for _ in range(M):
    a, b = map(lambda a: int(a) - 1, input().split())
    if a > b:
        a, b = b, a
    ims[a] += 1
    ims[b] -= 1

for i in range(1, N + 1):
    ims[i] += ims[i - 1]

print('YES' if all(c % 2 == 0 for c in ims) else 'NO')

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    cnt = [0]*N
    AB = [[int(i)-1 for i in input().split()] for j in range(M)]
    for a, b in AB:
        cnt[a] += 1
        cnt[b] += 1
    if all(c % 2 == 0 for c in cnt):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ans=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  ans[a-1]^=1
  ans[b-1]^=1
if 1 not in ans:print('YES')
else:print('NO')

Submission status: Accepted

Solution code:
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
d = [0]*(n+1)
for i in range(m):
    a,b = inm()
    d[a] += 1
    d[b] += 1
for i in range(n+1):
    if d[i]%2==1:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
cnt = [0] * (N + 1)
for _ in range(M):
    a,b = map(int, input().split())
    cnt[a] += 1
    cnt[b] += 1

flag = True if all(c % 2 == 0 for c in cnt) else False

if flag:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
A = [list(map(int,input().split())) for i in range(m)]

B = [0] * (n+1)

for i in range(m):
    B[A[i][0]] += 1
    B[A[i][1]] += 1

no = 0
for i in range(1, n+1):
    if B[i] % 2 == 1:
        no = 1
        break

if no == 0:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
D = {i: 0 for i in range(1, N + 1)}
for i in range(M):
  a, b = map(int, input().split())
  D[a] += 1
  D[b] += 1
p = 0
for i in D:
  if D[i] % 2 == 1:
    p = 1
if p == 0:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  counts = [0] * (n)
  for _ in range(m):
    a, b = map(int, input().split())
    counts[a-1] += 1
    counts[b-1] += 1
  if all([c%2==0 for c in counts]):
    print('YES')
  else:
    print('NO')

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    a = [0]*(n+1)
    for _ in range(m):
        x, y = map(int, input().split())
        a[x] += 1
        a[y] += 1
    f = True
    for i in range(n+1):
        if a[i] % 2 == 1:
            f = False
            break
    if f:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
N,M=map(int,input().split())
NL=[0 for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    NL[a-1]+=1
    NL[b-1]+=1

flg=True

for i in range(N):
    if NL[i]%2==1:
        flg=False

if flg:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(M)]
B,C=zip(*A)
D=B+C
import collections
a=collections.Counter(D)
for i in a.values():
  if i%2==1:
    print('NO')
    exit()
print('YES')

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
hen=[0 for i in range(0,N-1)]
for i in range(0,M):
    a,b=map(int,input().split())
    if a==1:
        hen[b-2]+=1
    elif b==1:
        hen[a-2]+=1
    else:
        hen[a-2]+=1
        hen[b-2]+=1

flag=0
for i in range(0,N-1):
    if hen[i]%2==1:
        flag=1

if flag==0:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
lst = [0]*(n+1)
for _ in range(m):
    a,b = map(int,input().split())
    lst[a] += 1
    lst[b] += 1
res = True
for i in range(1, n+1):
    if lst[i]%2!=0:
        res=False
        break
print('YES' if res else 'NO')

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(int)
for _ in range(M):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2 != 0:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
L = [0]*(N+1)
for _ in range(M):
    a,b = map(int, input().split())
    L[a] += 1
    L[b] += 1

ans = "YES"
for l in L:
    if l%2 == 1:
        ans = "NO"
        break
print(ans)

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    D=defaultdict(int)
    for _ in range(M):
        a,b = MI()
        D[a]+=1
        D[b]+=1
    for v in D.values():
        if v&1:
            print("NO")
            return 
    print("YES")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(m)]
cnt=defaultdict(lambda :0)

for i in range(m):
    for j in range(2):
        cnt[ab[i][j]]+=1

for i in cnt.values():
    if i%2!=0:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
import sys
#sys.setrecursionlimit(10**9)
input = sys.stdin.readline
n, m = map(int, input().split())
d = {}
for i in range(n):
    d[i] = 0

for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    d[a] += 1
    d[b] += 1

for v in d.values():
    if v%2 != 0:
        print('NO')
        exit()
else:
    print('YES')

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    G = [[] for i in range(N)]
    for i in range(M):
        x, y = (int(i)-1 for i in input().split())
        G[x].append(y)
        G[y].append(x)

    for i in range(N):
        if len(G[i]) % 2:
            return print("NO")
    else:
        return print("YES")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    count = [0] * N
    for _ in range(M):
        a, b = map(int, input().split())
        a, b = min(a, b), max(a, b)
        if a > 1: count[a-1] += 1
        count[b-1] += 1
    
    for i, a in enumerate(count):
        if a % 2 > 0: 
            print("NO")
            break
    else: print("YES")

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ki = [0] * (n+1)

for i in range(m):
        a, b = map(int, input().split())
        ki[a] += 1
        ki[b] -= 1
cant = 0
for i in range(n):
        ki[i+1] += ki[i]
        if ki[i+1]%2: cant = 1
print("YNEOS"[cant::2])

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
import collections
table=collections.defaultdict(int)
for i in range(M):
  a,b=map(int,input().split())
  table[a]+=1
  table[b]+=1
flag=True
for x in table:
  if table[x]%2==1:
    flag = False
    break
if flag:
  print("YES")
else:
  print("NO")

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
# 木だったらなんでもOK?
# いもす法

edge = [0] * (N + 1)
for _ in range(M):
    a, b = map(int, input().split())
    edge[a] += 1
    edge[b] -= 1

ans = "YES"
for i in range(N):
    edge[i + 1] += edge[i]
    if edge[i + 1] % 2 == 1:
        ans = "NO"
        break

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter as C
N,M,*A=map(int, open(0).read().split())
print("YNEOS"[any(a&1 for a in C(A).values())::2])

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
freq = [True]*N
for i in range(M):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if freq[a]:
        freq[a] = False
    else:
        freq[a] = True

    if freq[b]:
        freq[b] = False
    else:
        freq[b] = True

ans = all(freq)
if ans:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
from collections import Counter
N, M = map(int, input().split())
countab = Counter()
for i in range(M):
    a, b = map(int, input().split())
    countab[a] += 1
    countab[b] += 1
ans = True
for k, v in countab.items():
    if v % 2 == 0:
        continue
    ans = False
    break
if ans:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
n,m= map(int, input().split())
vs = [0] * (n + 1)
for _ in range(m):
    a,b= map(int, input().split())
    vs[a] += 1
    vs[b] += 1
ans = "YES"
for i in range(n + 1):
    if vs[i] % 2 == 1:
        ans = "NO"
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int, input().split( ))
cnt = [0]*n
#出現奇数回は不可
#出現偶数回なら勝手になる
for i in range(m):
    ai,bi = map(int, input().split( ))
    ai-=1;bi-=1
    cnt[ai]+=1;cnt[bi]+=1

for i in range(n):
    if cnt[i]%2:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
lists=[0 for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    lists[a-1]+=1
    lists[b-1]+=1
flag=True
for i in range(n):
    if lists[i]%2!=0:
        flag=False
        break
if flag:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
from sys import stdin
n,m = map(int,stdin.readline().rstrip().split())
ab = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
li = [0 for _ in range(n+1)]
for a,b in ab:
    li[a] += 1
    li[b] += 1
for i in li:
    if i%2 == 1:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(m)]
cnt=[0]*(n+1)
for i in range(m):
  cnt[ab[i][0]]+=1
  cnt[ab[i][1]]+=1
flag=True
for i in range(1,n+1):
  if cnt[i]%2!=0:flag=False
print('YES' if flag else 'NO')

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
a=[0]*n
for i in range(m):
    a[l[i][0]-1]+=1
    a[l[i][1]-1]+=1
for i in range(n):
    if a[i]%2==1:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

Solution code:


N,M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(M)]

"""
なんかどこかのノードを軸にする（root扱いする）
a -> bまでの辺を1増やす = root -> a と、root -> b までの辺を1増やす。
全ての辺のコストが偶数なら、この足す処理が偶数回されてるはず。
間にどのノードが入るかとかあるけど、奇数回足される（奇数回出てくる）なら、ダメな気がする
少なくとも木ではあるのだから、あるaからあるbに行くときに必ずとおるrootがあるはずなので、これでいいんじゃなかろうか
"""

arr = [0] * N
for a,b in ab:
    arr[a-1] += 1
    arr[b-1] += 1

ans = "YES"
for n in arr:
    if n % 2 == 1:
        ans = "NO"

print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
d = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    d[a-1] ^= 1
    d[b-1] ^= 1
ans = 0
for j in range(n):
    ans |= d[j]
if ans:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
import sys


N, M = map(int, input().split())

d = {i:0 for i in range(1, N+1)}

for i in range(M):
  a, b = map(int, input().split())
  d[a] += 1
  d[b] += 1
  
for v in d.values():
  if v % 2 == 0:
    continue
  else:
    print("NO")
    sys.exit()
    
print("YES")

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    n,m = inpm()
    cnt = [0 for _ in range(n)]
    for _ in range(m):
        a,b = inpm()
        a -= 1
        b -= 1
        cnt[a] += 1
        cnt[b] += 1
    for i in range(n):
        if cnt[i]%2 == 1:
            print('NO')
            return
    print('YES')
 
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import Counter
read=sys.stdin.read
n,m=map(int,input().split())
a=list(map(int,read().split()))
c=Counter(a)
ans="YES"
for i in c.values():
  if i%2:
    ans="NO"
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n,m=map(int,input().split())
s=np.zeros(n+1)
for i in range(m):
    a,b=map(int,input().split())
    s[a]+=1
    s[b]+=1
print("NO" if sum(s%2)else"YES")

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
X = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    X[a-1] ^= 1
    X[b-1] ^= 1

print("YES" if sum(X) == 0 else "NO")

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    l[a-1]+=1
    l[b-1]+=1
for i in l:
    if i%2==1:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
ans = [0]*n

for i in range(m):
    a,b = map(int, input().split())
    a-=1
    b-=1
    ans[a]+=1
    ans[b]+=1
    ans[a]%=2
    ans[b]%=2
if any(ans):
    print('NO')
else:
    print('YES')

Submission status: Accepted

Solution code:
from collections import Counter
N,M=map(int, input().split())
Q=[]
for _ in range(M):
    a,b=map(int, input().split())
    Q.append(a)
    Q.append(b)
C=Counter(Q)
for c in C.values():
    if c&1:
        print('NO')
        exit()
print('YES')

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
k = 0
while True:
    if 2**k>=N:
        break
    k += 1
A = [0 for i in range(2**k+1)]
for _ in range(M):
    a,b = map(int,input().split())
    if b<a:
        a,b = b,a
    A[a] += 1
    A[b] -= 1
B = [0 for i in range(2**k+2)]
for i in range(2**k+1):
    B[i+1] = B[i]+A[i]
flag = 0
for i in range(2**k+1):
    if B[i]%2==1:
        flag = 1
        break
if flag==0:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
cntAB = {i:0 for i in range(1,N+1)}
for _ in range(M):
  a,b = map(int,input().split())
  cntAB[a] += 1
  cntAB[b] += 1
for key, num in cntAB.items():
  if num%2 == 1:
    print('NO')
    exit()
print('YES')

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
x=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  x[a-1]+=1
  x[b-1]+=1
ans="YES"
for i in range(n):
  if x[i]%2:ans="NO"
print(ans)

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
s = [0] * (10 ** 5+1)
for a,b in ab:
  s[a] += 1
  s[b] += 1
if any([i % 2 for i in s]):
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]

U = [0] * (N + 2)
for A, B in AB:
  U[A + 1] += 1
  U[B + 1] -= 1
#print("U:", U)

for u in U:
  if u % 2:
    print("NO")
    exit()
print("YES")

Submission status: Accepted

Solution code:
import sys
imput = sys.stdin.readline

N,M = map(int,input().split())
V = [0 for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    V[a-1] += 1
    V[b-1] += 1
print('YES' if all([v%2==0 for v in V]) else 'NO')

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
F = [0]*(n+1)
for _ in range(m):
  a, b = map(int, input().split())
  F[a] += 1
  F[b] += 1
for i in F:
  if i%2:
    print("NO")
    exit()
print("YES")

Submission status: Accepted

Solution code:
N,M=map(int,input().split())

B=[0]*N

for i in range(M):
    a,b=map(int,input().split())
    B[a-1]+=1
    B[b-1]+=1

for i in range(N):
    if B[i]%2==1:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys
input = sys.stdin.readline


count = defaultdict(int)
n, m = map(int, input().split())
for _ in range(m):
    a, b = map(int, input().split())
    count[a] += 1
    count[b] += 1

for cnt in count.values():
    if cnt % 2 != 0:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

Solution code:
from collections import defaultdict

N, M = map(int, input().split())
ab = [[int(i) for i in input().split()] for _ in range(M)]

cnt = defaultdict(int)
for a, b in ab :
    if a > b :
        a, b = b, a
        
    if a == 1 :
        cnt[(a, b)] += 1
    else :
        cnt[(1, a)] += 1
        cnt[(1, b)] += 1
        
flag = True
for i in cnt.values() :
    if i % 2 == 1 :
        flag = False
        
if flag :
    print('YES')
else :
    print('NO')

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
AB = [0 for _ in range(N)]
for i in range(M):
	a, b = map(int, input().split())
	AB[a-1] += 1
	AB[b-1] += 1
for i in range(N):
	if AB[i]%2 or AB[i]%2:
		print("NO")
		exit()
print("YES")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
t = [0] * (N + 1)
for _ in range(M):
  u, v = map(int, input().split())
  t[u] += 1
  t[v] += 1
for i in range(1, N + 1):
  if t[i] % 2:
    print("NO")
    exit(0)
print("YES")

Submission status: Accepted

Solution code:
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())

edge = np.zeros(n, dtype=int)
for _ in range(m):
    a, b = map(int, readline().split())
    edge[a - 1] += 1
    edge[b - 1] -= 1

np.add.accumulate(edge, out=edge)
if all(edge % 2 == 0):
    ans = "YES"
else:
    ans = "NO"

print(ans)

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
ab=[0]*N
for _ in range(M):
  a,b=map(int,input().split())
  ab[a-1]+=1
  ab[b-1]+=1
  
for i in range(N):
  if ab[i]%2==1:
    print("NO")
    exit()
print("YES")

Submission status: Accepted

Solution code:
N, M = map(int,input().split(' '))
A = []
B = set() #奇数のものだけ入れる
for i in range(M):
    a,b = map(int,input().split(' '))
    A.append([a,b])
    if a in B:
        B.remove(a)
    else:
        B.add(a)
    if b in B:
        B.remove(b)
    else:
        B.add(b)

if len(B) == 0:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
nodes = [0] * (N+1) #0は使わない
for i in range(M):
    a, b = rl()
    nodes[a] += 1
    nodes[b] += 1

print('YES' if all(x%2==0 for x in nodes) else 'NO')

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
cnt = [0]*(N+10)
for i in range(M):
    a,b = map(int,input().split())
    cnt[a]+=1
    cnt[b]+=1

for c in cnt:
    if c%2 == 1:
        print('NO')
        import sys
        sys.exit()
print('YES')

Submission status: Accepted

Solution code:
import sys
from collections import Counter
read = sys.stdin.read

N, M, *ab = map(int, read().split())
answer = [1 for i in Counter(ab).values() if i % 2 == 1]

if not answer:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
def examB():
    N, M = LI()
    cur = [0]*N
    for i in range(M):
        a, b = LI()
        cur[a-1] +=1
        cur[b-1] +=1
    ans = "YES"
    for j in cur:
        if j%2==1:
            ans = "NO"
            break
    print(ans)


import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
c = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    c[a - 1] += 1
    c[b - 1] += 1
for i in range(n):
    if c[i] % 2:
        print('NO')
        exit(0)
print('YES')

Submission status: Accepted

Solution code:
from collections import defaultdict
N, M = map(int, input().split())
es = defaultdict(list)
for i in range(M):
  a, b = map(int, input().split())
  es[a-1] += [b-1]
  es[b-1] += [a-1]

for e in es.keys():
  if len(es[e])%2==1:
    print('NO')
    break
else:
  print('YES')

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  l[a-1]+=1
  l[b-1]+=1
b=True
for i in range(n):
  if l[i]%2==1:
    b=False
if b:
  print("YES")
else:
  print("NO")