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

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)
n,m = map(int, input().split())
for _ in range(m):
  a, b = map(int, input().split())
  dic[a] += 1
  dic[b] += 1
flag = True
for k,v in dic.items():
  if v % 2 == 1:
    flag = False
    break
if flag:
  print("YES")
else:
  print("NO")

Solution (Python):
from collections import defaultdict
n,m = map(int, input().split())
d = defaultdict(int)

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

for i in d:
  if d[i]%2 ==1:
    print ('NO')
    exit()
print('YES')

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	
	n, m = tin()
	
	dd=[0]*(n+1)
	for _ in range(m):
		a, b = tin()
		dd[a] += 1
		dd[b] += 1
	for v in dd:
		if v % 2 == 1:
			return 'NO'
	else:
		return 'YES'
		
	
	

isTest=False

def pa(*vl):
	if not isTest:
		return
	for v in vl:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

for i in range(N-1):
    if r[i]%2==1:
        print("NO")
        break
else:
    print("YES")

Solution (Python):
from collections import Counter

n, m = map(int, input().split())
graph = []
for _ in range(m):
    graph.extend([int(i) for i in input().split()])
    
cnt = Counter(graph)
ans = 'YES'
for i in cnt.values():
    if i % 2 != 0:
        ans = 'NO'
        break
print(ans)

Solution (Python):
from collections import Counter

n, m = map(int, input().split())
graph = []
for _ in range(m):
    graph.extend([int(i) for i in input().split()])
    
cnt = Counter(graph)
ans = 'YES'
for i in cnt.values():
    if i % 2 != 0:
        ans = 'NO'
        break
print(ans)

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

D = [0] * N

for a, b in ab:
  a -= 1
  b -= 1
  D[a] += 1
  D[b] += 1

ans = True
for x in D:
  if x % 2 == 1:
    ans = False

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

Solution (Python):
N,M,*ab=open(0).read().split()
from collections import*
C=Counter(ab)
print('YNEOS'[any(v%2 for v in C.values())::2])

Solution (Python):
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    AB = [[int(x) for x in input().split()] for _ in range(M)]

    c = collections.Counter()
    for a, b in AB:
        c[a] += 1
        c[b] += 1

    for k in c.keys():
        if c[k] % 2 == 1:
            print("NO")
            return
    else:
        print("YES")


if __name__ == '__main__':
    main()

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

flag = True
for i in range(N):
    if(cntNode[i] % 2 != 0):
        flag = False
        break
if(flag):
    print('YES')
else:
    print('NO')

Solution (Python):

import sys

sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math








INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())


def run():
    N, M = mapline()
    cache = {}
    for i in range(M):
        a, b = mapline()
        cache[a] = cache.get(a, 0) + 1
        cache[b] = cache.get(b, 0) + 1

    for key in cache.keys():
        if cache[key] % 2:
            print('NO')
            return

    print('YES')
    return

if __name__ == "__main__":
    run()

Solution (Python):
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))



N,M=mint()
C=[0]*(N+1)
for _ in range(M):
    a,b=mint()
    C[a]+=1
    C[b]+=1
judge(all([c%2==0 for c in C]),['YES','NO'])

Solution (Python):

def resolve():
    N, M = map(int, input().split())

    CNT = [0] * N
    for _ in range(M):
        x, y = map(lambda x: int(x) - 1, input().split())
        CNT[x] += 1
        CNT[y] += 1

    for c in CNT:
        if c % 2 == 1:
            print("NO")
            return
    else:
        print("YES")


if __name__ == "__main__":
    resolve()

Solution (Python):
N, M = map(int, input().split())
l = [0] * (N+1)
for i in range(M):
  a, b = map(int, input().split())
  l[a] += 1
  l[b] += 1
  
flag = True
for i in range(N+1):
  if l[i] % 2 == 1:
    flag = False
    break
if flag:
  print('YES')
else:
  print('NO')

Solution (Python):
import sys

from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, m = input_int_list()
    nodes = defaultdict(int)
    for _ in range(m):
        a, b = input_int_list()
        nodes[a] += 1
        nodes[b] += 1

    for k, v in nodes.items():
        if v % 2 == 1:
            print("NO")
            return
    print("YES")

    return


if __name__ == "__main__":
    main()

Solution (Python):
n,m=map(int,input().split())
d=[0 for i in range(n)]
for i in range(m):
  a,b=map(lambda x:int(x)-1,input().split())
  d[a]^=1
  d[b]^=1

print("NO" if sum(d) else "YES")

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

Solution (Python):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

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

cnt = [0]*(N+1)
for m in map(int,read().split()):
    cnt[m] += 1

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

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

Solution (Python):
N,M=list(map(int,input().split()))
l=[0]*N
for i in range(M):
   a,b=map(int,input().split())
   a-=1;b-=1
   l[a]+=1
   l[b]+=1
l=[i for i in l if i%2!=0]
print("YES") if len(l)==0 else print("NO")

Solution (Python):
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
print("YES" if all([cnt[i] % 2 == 0 for i in range(N)]) else "NO")

Solution (Python):
N, M, *ab = map(int, open(0).read().split())
ans = [0] * N
for a, b in zip(*[iter(ab)] * 2):
    ans[a - 1] += 1
    ans[b - 1] -= 1
print("NO") if any(a % 2 for a in ans) else print("YES")

Solution (Python):
from itertools import accumulate

N, M, *ab = map(int, open(0).read().split())
acc = [0] * (N + 1)
for a, b in zip(*[iter(ab)] * 2):
    if a > b:
        a, b = b, a
    acc[a - 1] += 1
    acc[b - 1] -= 1
acc = list(accumulate(acc, initial=0))
print("NO") if any(a % 2 for a in acc) else print("YES")

Solution (Python):
n,m=map(int,input().split())
from collections import Counter as co

from itertools import chain
flatten=chain.from_iterable
print("YES" if all(i%2==0 for i in co(flatten([list(map(int,input().split())) for i in range(m)])).values()) else "NO")

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

for i in range(N):
	if cnt[i] % 2 != 0:
		print("NO")
		exit()
print("YES")

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

for c in cnts:
    if c%2 == 1:
        print('NO')
        exit()
else:
    print('YES')

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

Solution (Python):
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

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

if all(x == 0 for x in cnt):
    print("YES")
else:
    print("NO")

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

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

for u in cnt:
    if u & 1:
        print("NO")
        exit()

print("YES")

Solution (Python):
n,m = map(int,input().split())
c = [0]*(n+1)
for i in range(m):
    a,b = map(int,input().split())
    c[a] += 1
    c[b] += 1

for i in c:
    if i%2:
        print("NO")
        exit()
print("YES")

Solution (Python):
class Imos_1:
    def __init__(self,N):
        self.len=N
        self.list=[0]*(N+1)

    def Add(self,F,T,C=1):
        self.list[F]+=C
        self.list[T+1]-=C

    def Cumulative_Sum(self):
        Y=[0]*(self.len)
        S=0
        for i in range(self.len):
            S+=self.list[i]
            Y[i]=S

        return Y

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

for _ in range(M):
    a,b=map(int,input().split())
    a,b=min(a,b),max(a,b)
    I.Add(a,b-1,1)

J=I.Cumulative_Sum()

F=True
for k in J:
    F&=not(k%2)

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

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

Solution (Python):
N,M = map(int,input().split())
ver = [0] * N
for i in range(M):
    a,b = map(int,input().split())
    ver[a-1] += 1
    ver[b-1] += 1
ans = 'YES'
for i in range(N):
    if ver[i] % 2 != 0:
        ans = 'NO'
print(ans)

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

l=[0 for _ in range(n)]

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

c=0
for i in range(n):
  if l[i]%2==1:
    c+=1
    break

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

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

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

def solve():
    N, M = MAP()
    d = defaultdict(int)
    for i in range(M):
        a, b = MAP()
        d[a] += 1
        d[b] += 1

    ans = "YES"
    for x in d.values():
        if x % 2 == 1:
            ans = "NO"
    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):
import sys
def input():return sys.stdin.readline().strip()
from collections import Counter

def main():
    N, M = map(int, input().split())
    A = []
    B = []
    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)

    ca = Counter(A)
    cb = Counter(B)
    c = ca + cb
    
    if all(count%2 == 0 for count in c.values()):
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

Solution (Python):

from collections import defaultdict
import sys

N, M = (int(x) for x in input().split())
freq = defaultdict(int)

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

for k in freq:
    if freq[k] % 2 == 1:
        print ("NO")
        sys.exit(0)

print ("YES")

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())

from collections import deque
def main():
    n, m = mi()
    cc = [0]*n
    for _ in range(m):
        a, b = mi()
        a -= 1
        b -= 1 
        cc[a] += 1
        cc[b] += 1
    for x in cc:
        if x%2 == 1:
            print('NO')
            return
    print('YES')



if __name__ == '__main__':
    main()

Solution (Python):
def agc014_b():
    n, m = map(int, input().split())
    deg = [0]*n
    for _ in range(m):
        a, b = map(lambda x: int(x)-1, input().split())
        deg[a] += 1
        deg[b] += 1
    for k in deg:
        if k%2 == 1:
            return print('NO')
    print('YES')

if __name__ == '__main__':
    agc014_b()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m=MI()
counter=[0 for i in range(n)]
for i in range(m):
    a,b=MI()
    counter[a-1]+=1
    counter[b-1]+=1
for i in range(n):
    if counter[i]%2==1:
        print("NO")
        sys.exit()
print("YES")

Solution (Python):
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    counter = defaultdict(int)
    for _ in range(M):
        A, B = map(lambda x: int(x) - 1, input().split())
        counter[A] += 1
        counter[B] += 1
    is_valid = True
    for v in counter.values():
        if v % 2 == 1:
            is_valid = False
            break
    if is_valid:
        print('YES')
    else:
        print('NO')


if __name__ == '__main__':
    main()

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, M = LI()
    cnt = [0] * N
    for _ in range(M):
        a, b = LI_()
        cnt[a] += 1
        cnt[b] += 1

    
    
    
    
    if len([i for i in cnt if i % 2 == 0]) == N:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    resolve()

Solution (Python):
N, M = map(int, input().split())
a = [0 for i in range(M)]
b = [0 for i in range(M)]
for i in range(M):
	a[i], b[i] = map(int, input().split())
	a[i] -= 1
	b[i] -= 1

cnt = [0 for i in range(N)]
for i in range(M):
	cnt[a[i]] += 1
	cnt[b[i]] += 1
for i in cnt:
	if i % 2 == 1:
		print("NO")
		break
else:
	print("YES")

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

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

edge=[0]*(n+1)

for _ in range(m):
    a,b=map(int,input().split())
    a,b=min(a,b),max(a,b)
    edge[a]+=1
    edge[b]-=1

for i in range(1,n+1):
    edge[i]+=edge[i-1]

for i in range(1,n):
    if edge[i]%2==1:
        print('NO')
        break
else:
    print('YES')

Solution (Python):
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter



input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  
    fac = [0] * SIZE  
    finv = [0] * SIZE  
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    
    
    
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    
    return X.flatten().tolist()[0]

class TwoDimGrid:
    
    def __init__(self, h, w, wall="
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        
        
        
        
        
def fprint(c):
    print(c)
    sys.stdout.flush()
def solve():
    n, m = getList()
    g = [[] for i in range(n+1)]
    ji = [0 for i in range(n+1)]


    for i in range(m):
        a, b = getList()
        g[a].append(b)
        g[b].append(a)
        ji[a] += 1
        ji[b] += 1
    
    
    ni = 0
    for i in range(1, n+1):
        if ji[i] % 2 == 1:
            for q in g[i]:
                if ji[q] % 2 == 0:
                    print("NO")
                    return
        else:
            ni += 1
    if ni < 2:
        print("NO")
        return
    print("YES")

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

Solution (Python):
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [0] * (n + 1)
for _ in range(m):
    x, y = map(int, input().split())
    a[x] = (a[x] + 1) & 1
    a[y] = (a[y] + 1) & 1
print("YES" if sum(a) == 0 else "NO")

Solution (Python):
import numpy as np
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = np.zeros(n + 1, dtype=int)
for _ in range(m):
    x, y = map(int, input().split())
    a[x] = (a[x] + 1) & 1
    a[y] = (a[y] + 1) & 1
print("YES" if np.sum(a) == 0 else "NO")

Solution (Python):
from collections import defaultdict


import sys
sys.setrecursionlimit(10000000)
input = sys.stdin.readline
n, m = map(int, input().split())
es = [defaultdict(int) for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a][b] += 1
    es[b][a] += 1
    if es[a][b] == 2:
        es[a].pop(b)
        es[b].pop(a)

def dfs(v, p, r):
    for i in es[v]:
        if i != p:
            es[i].pop(v)
            es[v].pop(i)
            if i == r:
                return - 1
            else:
                return dfs(i, v, r)
    return - 2

for i in range(n):
    if es[i]:
        if dfs(i, -1, i) == -2:
            print("NO")
            exit()
print("YES")

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

ans = "YES"
for i in range(n):
    if cnt[i] % 2 == 1:
        ans = "NO"
        break

print(ans)

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

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


tree=[0]*n

for _ in range(m):
    x,y=map(int,input().split())
    tree[x-1]+=1
    tree[y-1]+=1

for item in tree:
    if item%2==1:
        print("NO")
        exit()

print("YES")

Solution (Python):
def solve(n, m, a, b):
    D = {(i+1): 0 for i in range(n)}
    for v in a + b:
        D[v] += 1
    ok = len(list(
        filter(lambda num: num % 2 == 0, D.values())
    )) == n
    return "YES" if ok else "NO"

n, m = map(int, input().split())
ab = [map(int, input().split()) for i in range(m)]
a, b = zip(*ab)
print(solve(n, m, a, b))

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())
count = defaultdict(int)
for _ in range(M):
    a, b = map(int, input().split())
    count[a] += 1
    count[b] += 1
flag = True
for k, v in count.items():
    if v % 2 == 1:
        flag = False
if flag:
    print("YES")
else:
    print("NO")

Solution (Python):
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
road = [0]*(N)
for _ in range(M):
    l,r=map(int,input().split())
    road[l-1]+=1
    road[r-1]-=1
road = list(itertools.accumulate(road))[:-1]

flag=0
for ro in road:
    if ro%2==1:
        print('NO')
        exit()
print('YES')

Solution (Python):
from collections import defaultdict
N, M = map(int, input().split())
c = defaultdict(int)
for _ in range(M):
    a, b = map(int, input().split())
    c[a] += 1
    c[b] += 1

flag = True
for k, v in c.items():
    if v % 2 != 0:
        flag = False
if flag:
    print("YES")
else:
    print("NO")

Solution (Python):
from collections import Counter
n,m,*ab = map(int,open(0).read().split())
a = Counter(ab)
for i in a.values():
  if i%2 != 0:
    print("NO")
    break
else:
  print("YES")

Solution (Python):

def main():
	
	
	n , m = map(int , input().split())
	deg = [0 for i in range(n+2)]
	for i in range(m):
		x , y = map(int , input().split())
		deg[x]+=1
		deg[y]+=1
	f=0
	
	
	for i in range(1, n+1):
		if deg[i]%2==1:
			f = 1
	if f:
		print("NO")
	else:
		print("YES")
if __name__=="__main__":
	main()

Solution (Python):

def main():
	n , m = map(int , input().split())
	deg = [0 for i in range(n+2)]
	for i in range(m):
		x , y = map(int , input().split())
		deg[x]+=1
		deg[y]+=1
	f=0
	for i in range(1, n+1):
		if deg[i]%2==1:
			f = 1
	if f:
		print("NO")
	else:
		print("YES")
if __name__=="__main__":
	main()

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    odds = set()
    for _ in range(M):
        for c in read_ints():
            if c in odds:
                odds.discard(c)
            else:
                odds.add(c)
    if odds:
        return 'NO'
    return 'YES'


if __name__ == '__main__':
    print(solve())

Solution (Python):
n,m = map(int,input().split())
nm = [list(map(int,input().split())) for _ in range(m)]

cnt = [0] * n

for n,m in nm:
    cnt[n-1] += 1
    cnt[m-1] += 1

if all([i % 2 == 0 for i in cnt]):
    print('YES')
else:
    print('NO')

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

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

Solution (Python):


n, m = map(int, input().split())
edges = [0] * n
ab = []
for _ in range(m):
    a, b = map(int, input().split())
    ab.append((a, b))

for a, b in ab:
    edges[a - 1] += 1
    edges[b - 1] += 1

for e in edges:
    if e % 2 == 1:
        print('NO')
        break
else:
    print('YES')

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
ab = (list(map(int, input().split())) for _ in range(m))

cnt = defaultdict(int)
for a, b in ab:
    cnt[a] += 1
    cnt[b] += 1
ans = all(cnt[i] % 2 == 0 for i in cnt)
print('YES' if ans else 'NO')

Solution (Python):
from collections import defaultdict

n, m = map(int, input().split())
ab = (list(map(int, input().split())) for _ in range(m))

cnt = defaultdict(int)
for a, b in ab:
    cnt[a] += 1
    cnt[b] += 1
ans = all(cnt[i] % 2 == 0 for i in cnt)
print('YES' if ans else 'NO')

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import accumulate

    n, m = map(int, readline().split())
    c = [0] * n

    for i in range(m):
        a, b = map(int, readline().split())
        a, b = a - 1, b - 1
        a, b = min(a, b), max(a, b)
        c[a] += 1
        c[b] -= 1

    d = list(accumulate(c))

    if all((x % 2 == 0 for x in d)):
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

a, b = ZIP(M)

a_cnt, b_cnt = Counter(a), Counter(b)

for i in range(1, N+1):
	if (a_cnt[i]+b_cnt[i])%2 != 0:
		print("NO")
		break
else:
	print("YES")