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: Wrong Answer

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for j in range(0,3):
    for i in range(0,M):
      if p[i][0]==j or p[i][1]==j:
        count+=1
    if count%2==1:
      print("NO")
      sys.exit()
  else: 
    print("YES")

Submission status: Wrong Answer

Solution code:
from collections import Counter

n,m = map(int,input().split())
s = ""
for i in range(m):
    s = s + input()
counter = Counter(s)
for i in range(n+1):
    if counter[str(i)] % 2 != 0:
        print("NO")
        break
if i == n -1:
    print("YES")

Submission status: Wrong Answer

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for j in range(0,1):
    for i in range(0,M):
      if p[i][0]==j or p[i][1]==j:
        count+=1
    if count%2==1:
      print("NO")
      sys.exit()
  else: 
    print("YES")

Submission status: Wrong Answer

Solution code:
from collections import Counter

n,m = map(int,input().split())
s = ""
for i in range(m):
    s += input()
counter = Counter(s)
for i in range(n+1):
    if counter[str(i)] % 2 != 0:
        print("NO")
        break
if i == n -1:
    print("YES")

Submission status: Wrong Answer

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for i in range(0,M):
    if p[i][0]==1 or p[i][1]==1:
      count+=1
  if count%2==1:
    print("NO")
    sys.exit()
  else: 
    print("YES")

Submission status: Wrong Answer

Solution code:
from collections import Counter

n,m = map(int,input().split())
s = ""
for i in range(m):
    s = s + input()
for i in range(n):
    counter = Counter(s)
    if counter[str(i)] % 2 != 0:
        print("NO")
        break
if i == n -1:
    print("YES")

Submission status: Wrong Answer

Solution code:
from collections import Counter

n,m = map(int,input().split())
s = ""
for i in range(m):
    a,b = input().split()
    s = s + a + b

for i in range(n):
    counter = Counter(s)
    if counter[str(i)] % 2 != 0:
        print("NO")
        break
if i == n -1:
    print("YES")

Submission status: Wrong Answer

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for i in range(0,M):
    if p[i][0]==1 or p[i][1]==1:
      count+=1
  if count%2==0:
    print("YES")
  else: 
    print("NO")

Submission status: Wrong Answer

Solution code:
N,M = map(int,raw_input().split())
node_list = [0 for l in range(N)]
for i in range(M):
    items = map(int,raw_input().split())
    node_list[items[0]-1]+=1
    node_list[items[1]-1]+=1
flag=True
for i in range(N):
    if node_list[i]%2==1:
        print 'NO'
        flag=False

if flag:
    print 'YES'

Submission status: Wrong Answer

Solution code:

N,M = map(int,raw_input().split())
node_list = [0 for l in range(N)]
for i in range(M):
    items = map(int,raw_input().split())
    node_list[items[0]-1]+=1
    node_list[items[1]-1]+=1

for n in range(N):
    if n%2==1:
        print 'NO'
        p=2
        break

Submission status: Wrong Answer

Solution code:
N,M = map(int,raw_input().split())
node_list = [0 for l in range(N)]
for i in range(M):
    items = map(int,raw_input().split())
    node_list[items[0]-1]+=1
    node_list[items[1]-1]+=1
p=1
for n in range(N):
    if n%2==1:
        print 'NO'
        p=2
        break

if p==1:
    print 'YES'

Submission status: Wrong Answer

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1 or M<=N/2:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1 or M==1:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:

N,M = map(int,raw_input().split())
node_list = [0 for l in range(N)]
for i in range(M):
    items = map(int,raw_input().split())
    node_list[items[0]-1]+=1
    node_list[items[1]-1]+=1
flag=True
for n in range(N):
    if n%2==1:
        print 'No'
        flag = False
        break
if flag:
    print 'YES'

Submission status: Wrong Answer

Solution code:

N,M = map(int,raw_input().split())
node_list = [0 for l in range(N)]
for i in range(M):
    items = map(int,raw_input().split())
    node_list[items[0]-1]+=1
    node_list[items[1]-1]+=1
flag=True
for n in range(N):
    if n%2==1:
        print 'NO'
        flag = False
        break
if flag:
    print 'YeS'

Submission status: Wrong Answer

Solution code:
N,M = map(int,raw_input().split())
node_list = [0 for l in range(N)]
for i in range(M):
    items = map(int,raw_input().split())
    node_list[items[0]-1]+=1
    node_list[items[1]-1]+=1
flag=True
for n in range(N):
    if n%2==1:
        print 'NO'
        flag = False
        break
if flag:
    print 'YES'

Submission status: Wrong Answer

Solution code:
N,M = map(int,raw_input().split())
node_list = [0 for l in range(N)]
for i in range(M):
    items = map(int,raw_input().split())
    node_list[items[0]-1]+=1
    node_list[items[1]-1]+=1
flag=False
for n in range(N):
    if n%2==1:
        flag=True
        
if flag:
    print 'NO'
else:
    print 'YES'

Submission status: Wrong Answer

Solution code:
import sys

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

    if M & 1:
        print('NO')
        return

    ncnt = [0]*N

    for i in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a -= 1
        b -= 1

        ncnt[a] += 1
        ncnt[b] += 1

    if all(ni & 1 == 0 for ni in ncnt):
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from sys import stdin
from itertools import repeat
def main():
    n, m = map(int, stdin.readline().split())
    dat = map(int, stdin.read().split(), repeat(10, 2 * m))
    c = [0] * (n + 1)
    for x in dat:
        c[x] += 1
    for i in xrange(n + 1):
        if c[i] == 1:
            print "NO"
            return
    print "YES"
main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
rr = lambda: stdin.readline().strip()
rrM = lambda: map(int, rr().split())

N, M = rrM()
A = [tuple(rrM()) for _ in xrange(M)]
from collections import Counter
from collections import defaultdict as ddic

graph = ddic(list)
for u,v in A:
    graph[u].append(v)
    graph[v].append(u)

def solve(graph, M):
    if M == 0: return True
    for root, v in graph.iteritems():
        if len(v) > 0: break
    anchor = root
    while M:
        if not graph[root]: return False
        root = graph[root].pop()
        M -= 1
    return anchor == root
    

print "YES" if solve(graph, M) else "NO"

Submission status: Time Limit Exceeded

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
road = [0]*(N-1)
for _ in range(M):
    l,r=map(int,input().split())
    for i in range(l-1,r-1):
        road[i]+=1
if sum(road)%2==0:
    print('YES')
else:
    print('NO')

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

cnt = Counter(sum(ab, []))
ans = all(cnt[i] % 2 == 0 for i in cnt)
print('YES' if ans else 'NO')

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

cnt = Counter(sum(ab, []))
ans =  all(cnt[i] % 2 == 0 for i in cnt)
print('YES' if ans else 'NO')

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

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

ctr = Counter(sum(X, []))
if all(v % 2 == 0 for v in ctr.values()):
    print("YES")
else:
    print("NO")

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
c=sum([list(map(int,input().split())) for i in range(m)],[])
from collections import Counter as co
for i in co(c).values():
    if i%2:print("NO");exit()
print("YES")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def solve():
  n,m = (int(i) for i in input().split())
  a = []
  b = []
  for i in range(m):
    a1,b1 = (int(i) for i in input().split())
    a.append(a1)
    b.append(b1)
  ans = 'YES'
  for i in range(1,n+1):
   if (a.count(i)+b.count(i))%2 == 1:
    ans ='NO'
  return ans
                   
  
if __name__ == '__main__':
  print(solve())

Submission status: Time Limit Exceeded

Solution code:
*c,=open(0).read().split()[2:]
print('YNEOS'[any(c.count(i)%2for i in set(c))::2])

Submission status: Time Limit Exceeded

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n,m = li()

cnt = Counter([])
for _ in range(m):
    cnt += Counter(li())
    
exist = True
for v in cnt.values():
    if v%2:
        exist = False
        break

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

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
n,m=map(int,input().split())
l=[]
for _ in range(m):
  a,b=map(int,input().split())
  if a>b:a,b=b,a
  l.extend([(i,i+1) for i in range(a,b)])
c=Counter(l)
*v,=filter(lambda x:x%2,c.values())
if v:
  print("NO")
else:
  print("YES")

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


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


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, AB):
    c = Counter(reduce(add, AB))
    for v in c.values():
        if v % 2 != 0:
            return 'NO'
    return 'YES'


def main():
    N, M = read_int_n()
    AB = [read_int_n() for _ in range(M)]
    print(slv(N, M, AB))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
N, M = map(int, input().split())
print("YES" if all(x % 2 == 0 for x in Counter(sum([list(map(int, input().split())) for _ in range(M)], [])).values()) else "NO")

Submission status: Time Limit Exceeded

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

    i = 0
    AB = []
    while i < M:
        a, b = map(int, input().split())
        AB += [a, b]
        i += 1

    i = 1
    while i <= N:
        if AB.count(i) % 2 > 0:
            print('NO')
            break
        i += 1
    else:
        print('YES')

main()

Submission status: Time Limit Exceeded

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=[]
for i in range(0,M):
  p.append(list(map(int, input().split())))
  count.append(0)
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for j in range(0,M):
    for i in range(0,M):
      if p[i][0]==j or p[i][1]==j:
        count[j]+=1
  for j in range(0,M):
    if count[j]%2==1:
      print("NO")
      sys.exit()
  print("YES")

Submission status: Time Limit Exceeded

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for j in range(1,min(100,M)):
    for i in range(0,M):
      if p[i][0]==j or p[i][1]==j:
        count+=1
    if count%2==1:
      print("NO")
      sys.exit()
  else: 
    print("YES")

Submission status: Time Limit Exceeded

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for j in range(0,M,200):
    for i in range(0,M):
      if p[i][0]==j or p[i][1]==j:
        count+=1
    if count%2==1:
      print("NO")
      sys.exit()
  else: 
    print("YES")

Submission status: Time Limit Exceeded

Solution code:
import sys
# 整数の入力
N,M=list(map(int, input().split()))
p=[]
q=0
count=0
for i in range(0,M):
  p.append(list(map(int, input().split())))
for i in range(0,M):
  q+=p[i][0]-p[i][1]
if q%2==1:
  print("NO")
else:
  for j in range(0,M):
    for i in range(0,M):
      if p[i][0]==j or p[i][1]==j:
        count+=1
    if count%2==1:
      print("NO")
      sys.exit()
  else: 
    print("YES")

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N, M = map(int, raw_input().split())
Q = [map(int, raw_input().split()) for _ in range(M)]

cnt = Counter()
for q in Q:
    cnt += Counter(q)

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    n, m = map(int, input().split())

    path = list(0 for _ in range(n - 1))
    for _ in range(m):
        x, y = sorted(map(int, input().split()))
        for i in range(x - 1, y - 1):
            path[i] += 1

    ans = "YES" if all(cnt % 2 == 0 for cnt in path) else "NO"
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

n,m = map(int,input().split())
s = ""
for i in range(m):
    a,b = input().split()
    s = s + a + b
n_max = 5
for i in range(n_max):
    counter = Counter(s)
    if counter[str(i)] % 2 != 0:
        print("NO")
        break
if i == n_max -1:
    print("YES")

Submission status: Time Limit Exceeded

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

count = [0 for i in range(N)]

for aibi in ab:
    ai = aibi[0]
    bi = aibi[1]

    if bi < ai:
        tmp = ai
        ai = bi
        bi = tmp

    for j in range(ai - 1, bi - 1):
        count[j] += 1

yes_or_no = True
for num in count:
    if num % 2 == 1:
        yes_or_no = False

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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():
	#a = int(input())
	n, m = tin()
	#s = input()
	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
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
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
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

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()

Submission status: Accepted

Solution code:
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'])

Submission status: Accepted

Solution code:

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()

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
import sys
# sys.setrecursionlimit(100000)
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()

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:

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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)