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 = [int(i) for i in input().split()]

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

for i in range(M):
    if q[i]%2 != 0:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(M)]
k = [0]*N
for a,b in src:
    a,b = a-1,b-1
    k[a] += 1
    k[b] += 1
print('NO' if any(a%2 for a in k) else 'YES')

Submission status: Accepted

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

Submission status: Accepted

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

for i in count:
    if i % 2 == 1:
        print("NO")
        exit()

print("YES")

Submission status: Accepted

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

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

if all(map(lambda x: x % 2 == 0, X)):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
N, M = (int(i) for i in input().split())
DP = [False]*N
for i in range(M):
  a, b = (int(k) for k in input().split())
  for j in (a, b):
    DP[j-1] = not DP[j-1]
for i in range(N):
  if DP[i]:
    print('NO')
    break
else:
  print('YES')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
Path = [0 for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a, b = min(a, b), max(a, b)
    Path[b-1] += 1
    if a > 1:
        Path[a-1] += 1

for p in Path:
    if p % 2 != 0:
        print("NO")
        break
else: print("YES")

Submission status: Accepted

Solution code:
import sys
n, m = map(int, sys.stdin.readline().split(' '))
mlt = [0] * n
for i in range(m):
    b, c = map(int, sys.stdin.readline().split(' '))
    b -= 1
    c -= 1
    mlt[b] += 1
    mlt[c] += 1
flag = False
for i in range(n):
    if mlt[i] & 1:
        flag = True
        break
if not flag:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
import sys
n, m = map(int, sys.stdin.readline().split(' '))
a = [0] * (2 * m)
for i in range(m):
    a[2 * i], a[2 * i + 1] = map(int, sys.stdin.readline().split(' '))
a.sort()
flag = False
tmp = 0
crr = 0
for i in range(2 * m):
    nxt = a[i]
    if crr == nxt:
        tmp += 1
    else:
        if tmp & 1:
            flag = True
            break
        tmp = 1
    crr = nxt
if not flag:
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
e=[0 for i in range(n+1)]
for i in range(m):
 [a,b]=i2()
 e[a]+=1
 e[b]+=1
s="YES"
for i in range(1,n+1):
 if e[i]%2==1:
   s="NO"
print(s)

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
print('YES' if all([i % 2 == 0 for i in cnt]) else 'NO')

Submission status: Accepted

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

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

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

print('YES' if flg else 'NO')

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
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())
List=[0]*N
for i in range(M):
  a,b=map(int,input().split())
  List[a-1]+=1
  List[b-1]+=1

for i in range(N):
  if List[i]%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] = (x[a-1]+1)% 2
    x[b-1] = (x[b-1] + 1)%2

c = 0
for i in range(n):
    if x[i] == 0:
        c += 1

if c == n:
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]

N, M = inpl()
path = [True for _ in range(N+1)]

for _ in range(M):
    a, b = inpl()
    path[a] = not path[a]
    path[b] = not path[b]

if all(path):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:

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

buf = [0 for i in range(N)]
for i in range(M):
    a,b = list(map(int,input().split()))
    buf[a-1]+=1
    buf[b-1]+=1
flag=True
for bf in buf:
    if bf%2==1:
        flag=False
        break

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

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
agc014 B
"""

from collections import Counter
n, m = map(int, input().split())

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

for a in range(1, n+1):
    if cnt[a] % 2 == 1:
        print('NO')
        exit()

print('YES')

Submission status: Accepted

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

for num in nums:
    if num % 2:
        print('NO')
        break
else:
    print('YES')

Submission status: Accepted

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

n,m = li()

cnt = [0]*n
for _ in range(m):
    a,b = li_()
    cnt[a] += 1
    cnt[b] += 1
    
exist = True
for c in cnt:
    if c%2:
        exist = False
        break

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

Submission status: Accepted

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 defaultdict

n,m  = li()
query = []
for _ in range(m):
    mi,ma = li()
    if mi > ma:
        mi,ma = ma,mi
        
    query.append((mi,ma))

root = defaultdict(list)
for l,r in query:
    root[l].append(r)


even = -1
odd = -1
for k, v in root.items():
    if len(v)%2 == 0 and even == -1:
        even = k
        
    elif len(v)%2 == 1 and odd == -1:
        odd = k

# 偶数個つながっているノードをルートに
top = even
dist = [0]*n
for l,r in query:
    if l==top:
        dist[r-1] += 1
    
    elif r==top:
        dist[l-1] += 1
    
    else:
        dist[r-1] += 1
        dist[l-1] += 1
        
exist = False
if top != -1 and all([disti % 2 == 0 for disti in dist]):
    exist = True
    

# 奇数個つながっているノードをルートに
top = odd
dist = [0]*n
for l,r in query:
    if l==top:
        dist[r-1] += 1
    
    elif r==top:
        dist[l-1] += 1
    
    else:
        dist[r-1] += 1
        dist[l-1] += 1
        
if top != -1 and all([disti % 2 == 0 for disti in dist]):
    exist = True

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

Submission status: Accepted

Solution code:
import sys
N,M=map(int,input().split())
table=[]
for i in range(M):
    x,y=map(int,input().split())
    x,y=x-1,y-1
    if x>y:
        x,y=y,x
    table.append((x,y))
L=[0]*N
for x,y in table:
    if x==0:
        L[y]+=1
    else:
        L[x]+=1
        L[y]+=1
for s in L:
    if s%2==1:
        print('NO')
        sys.exit()
print('YES')

Submission status: Accepted

Solution code:
n, m=map(int, raw_input().split())
odd=[False]*(n+1)
for i in range(m):
	a, b=map(int, raw_input().split())
	odd[a]=not odd[a]
	odd[b]=not odd[b]
print "NO" if any(odd) else "YES"

Submission status: Accepted

Solution code:
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
X=[0 for i in range(N)]
for i in range(M):
    X[a[i]]+=1
    X[b[i]]+=1
for i in range(N):
    if X[i]%2==1:
        print("NO")
        exit()
print("YES")

Submission status: Accepted

Solution code:
from collections import Counter
N, M = map(int, input().split())
cnt = Counter(int(s) for _ in range(M) for s in input().split())
if all(v % 2 == 0 for v in cnt.values()):
    print('YES')
else:
    print('NO')

Submission status: Accepted

Solution code:
from itertools import accumulate as ac
n,m=map(int,input().split())
l=[0]*(n+1)
for _ in range(m):
  a,b=map(int,input().split())
  if a>b:a,b=b,a
  l[a]+=1
  l[b]-=1

*l,=ac(l)
*l,=filter(lambda x:x%2,l)
if l:
  print("NO")
else:
  print("YES")

Submission status: Accepted

Solution code:
n,m = (int(i) for i in input().split())
x = [0 for i in range(n)]
for _ in range(m):
	a,b = (int(i)-1 for i in input().split())
	x[a],x[b] = 1-x[a],1-x[b]
if sum(x): print("NO")
else: print("YES")

Submission status: Accepted

Solution code:
from collections import Counter

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

ok = True
for value in c.values():
	if value % 2 == 1:
		ok = False
		break
if ok:
	print("YES")
else:
	print("NO")

Submission status: Accepted

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()
    for a, b in AB:
        c[a] += 1
        c[b] += 1
    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: Accepted

Solution code:
N, M = map(int, input().split())
L = [True] * (N+1)
for i in range(M):
    a, b = map(int, input().split())
    L[a] = not L[a]
    L[b] = not L[b]
if False in L:
    print("NO")
else:
    print("YES")

Submission status: Accepted

Solution code:
#py aa.py
#import pandas as pd
n,m = map(int,input().split())
a = []
for i in range(n+1):
	a.append(0)
for i in range(m):
	x,y = map(int,input().split())
	a[x] += 1
	a[y] += 1
ans = True
for i in range(n+1):
	if a[i]%2!=0:
		ans = False

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

#a,b = map(int,input().split())
#s = input()

Submission status: Accepted

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

N, M = map(int, input().split())
# a = []
# b = []
count = [True] * N
for m in range(M):
    a_, b_ = map(int, input().split())
    a_ -= 1
    b_ -= 1
    # a.append(a_)
    # b.append(b_)
    count[a_] = count[a_] ^ True
    count[b_] = count[b_] ^ True

# count = [0] * N
# for m in range(M):
#     count[a[m]]
for m in range(M):
    if not count[m]:
        print("NO")
        sys.exit(0)
print("YES")

Submission status: Accepted

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

Submission status: Accepted

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

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

if all(map(lambda x: x%2==0, node)):
    print("YES")
else:
    print("NO")

Submission status: Accepted

Solution code:
def read():
    return int(input())


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


def readmap():
    return map(int, input().split())


N, M = readmap()
cnt = [0] * N
for _ in range(M):
    a, b = readmap()
    cnt[a-1] += 1
    cnt[b-1] += 1

for i in range(N):
    if cnt[i] % 2:
        print("NO")
        quit()

print("YES")

Submission status: Accepted

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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

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

main()

Submission status: Accepted

Solution code:
from collections import Counter

n,m=[int(i) for i in input().split()]
a=[]
for i in range(m):
  s,e=[int(i) for i in input().split()]
  a.append(s)
  a.append(e)

c=Counter(a)
for i,j in c.most_common():
  if j % 2 !=0:
    print('NO')
    break
else:
  print('YES')

Submission status: Accepted

Solution code:
from collections import Counter

n, q = map(int, input().split())
c = Counter()
for _ in range(q):
    u, v = map(int, input().split())
    c[u] += 1
    c[v] += 1

safe = all(c[x] % 2 == 0 for x in c)
print('YES' if safe else 'NO')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M=[int(i) for i in input().split()]
flag=[True for i in range(N)]

for i in range(M):
        for j in input().split():
                j=int(j)-1
                flag[j]=flag[j]^True
#答え
ans=True
for i in flag:
        if not i:
                ans=False
                break
if ans:
        print("YES")
else:
        print("NO")

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    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")
            return
    print("YES")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
MAX_N = 10 ** 5 + 10
if __name__ == "__main__":
    N,M = map(int, input().split())
    deg = [0] * MAX_N
    for x in range(M):
        a,b = map(int, input().split())
        deg[a] += 1
        deg[b] += 1
    for x in range(MAX_N):
        if (deg[x] % 2 != 0):
            print ("NO")
            exit()
    print ("YES")

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().strip().split())
ar = [0]*n
for _ in range(m):
	for v in map(int, raw_input().strip().split()):
		ar[v-1]+=1
answ = "YES"
for x in ar:
	if x % 2 != 0:
		answ = "NO"
		break
print answ

Submission status: Accepted

Solution code:
from collections import defaultdict

def unplanned_queries():
	n, m = map(int, raw_input().split(" "))
	a = []
	for i in range(m):
		a.append(map(int, raw_input().split(" ")))
	dic = defaultdict(int)
	for i in range(m):
		dic[a[i][0]] += 1
		dic[a[i][1]] += 1
	for key,value in dic.iteritems():
		if value%2!=0:
			print "NO"
			return
	print "YES"


if __name__ == "__main__":
	unplanned_queries()

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
t=0
for i in range(m):
	u,v=map(int,input().split())
	t^=u^v
print("NO" if t else "YES")

Submission status: Accepted

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

Submission status: Accepted

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

for x in frq:
   if x % 2 == 1:
      print "NO"
      exit(0)
print "YES"

Submission status: Accepted

Solution code:
N,M = map(int, raw_input().split())
hist = [0 for i in range(N)]
for i in range(M):
  a,b = map(int, raw_input().split())
  hist[a-1] += 1
  hist[b-1] += 1
for v in hist:
  if v%2 == 1:
    print 'NO'
    break
else : print 'YES'

Submission status: Accepted

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

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

ans = 'YES' if all([x % 2 == 0 for x in li]) else 'NO'
print(ans)

Submission status: Accepted

Solution code:
N, M = map(int, raw_input().split())
Q = [map(int, raw_input().split()) for _ in range(M)]
 
cnt = [0 for _ in range(N)]
for a, b in Q:
    cnt[a-1] += 1
    cnt[b-1] += 1
 
for k in range(N):
    if cnt[k] % 2 != 0:
        print "NO"
        exit()
print "YES"

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import chain

n, m = map(int, input().split())
c = Counter(chain.from_iterable(map(int, input().split()) for _ in range(m)))
print('NO' if any(i % 2 for i in c.values()) else 'YES')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

    ncnt = [0]*N

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

        ncnt[a] ^= 1
        ncnt[b] ^= 1

    print('NO' if any(ni for ni in ncnt) else 'YES')

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

    for i in AB:
        if i % 2 > 0:
            print('NO')
            break
    else:
        print('YES')

main()

Submission status: Accepted

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

cnt = [0 for _ in range(N)]
for a, b in Q:
    cnt[a-1] += 1
    cnt[b-1] += 1

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

Submission status: Accepted

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

for i in a:
    count[i-1] += 1
for i in b:
    count[i-1] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

	n=[]
	for j in range(N):
		n.append(0)

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

	flag = 0
	for i in range(N):
		if(n[i]%2==1):
			flag +=1

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for x in range(m)]
field = [0 for x in range(n + 2)]
cfield = field[:]

for a1, a2 in a:
    field[a1] += 1
    field[a2] -= 1

for i in range(1, n):
    cfield[i] = field[i] + cfield[i - 1]
    if cfield[i] & 1:
        print("NO")
        break
else:
    print("YES")

Submission status: Accepted

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:
    print("YES")

Submission status: Accepted

Solution code:
import sys

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

    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: Accepted

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:
        flag=False


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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 'YES'
for i in range(1, N + 1):
    if dict[i] % 2 == 1:
        ans = 'NO'
        break
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

def main():
    n, q = map(int, input().split())
    c = Counter()
    for _ in range(q):
        u, v = map(int, input().split())
        c[u] += 1
        c[v] += 1

    safe = all(c[x] % 2 == 0 for x in c)
    print('YES' if safe else 'NO')

main()

Submission status: Accepted

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

for aibi in ab:
    ai = aibi[0]
    bi = aibi[1]
    if ai != 1 and bi != 1:
        count[ai - 1] += 1
        count[bi - 1] += 1
    else:
        if ai == 1:
            count[bi - 1] += 1
        else:
            count[ai - 1] += 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:
# coding: utf-8

from collections import Counter

n, m = map(int, raw_input().split())
q = [flatten for i in range(0, m) for flatten in raw_input().split()]

counter = Counter(q)
for word, cnt in counter.most_common():
    if cnt % 2 != 0:
        print "NO"
        exit()

print "YES"

Submission status: Accepted

Solution code:
N, M = list(map(int, input().split()))
top = []
for i in range(N):
	top.append(0)
for i in range(M):
	a, b = list(map(int, input().split()))
	top[a - 1] += 1
	top[b - 1] += 1
judge = "YES"
for i in range(N):
	if top[i] % 2 == 1:
		judge = "NO"
		break
	else:
		pass
print(judge)

Submission status: Accepted

Solution code:
def main():
    n, m = [int(_) for _ in raw_input().split()]
    g = [[] for _ in xrange(n)]
    for i in xrange(m):
        a, b = [int(_) - 1 for _ in raw_input().split()]
        g[a].append(b)
        g[b].append(a)

    for i in xrange(n):
        while g[i]:
            j = g[i].pop()
            g[j].remove(i)
            while g[j]:
                k = g[j].pop()
                g[k].remove(j)
                j = k
                if i == j:
                    break
            else:
                return "NO"

    return "YES"

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

Submission status: Accepted

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

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

for a_i,b_i in [ map(int,input().split()) for _ in range(M) ]:
	lis[a_i-1] += 1
	lis[b_i-1] += 1

for x in lis:
	if x%2==1:
		print("NO")
		quit()
print("YES")

Submission status: Accepted

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
    f = 0
    for i in xrange(n + 1):
        if c[i] & 1:
            print "NO"
            return
    print "YES"
main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
d = {}
for i in range(M):
	for i in [int(i) for i in input().split()]:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
for i in d.values():
	if i%2:
		print("NO")
		break
else:
	print("YES")

Submission status: Accepted

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

res = 'YES'
for d in deg:
    if d % 2 == 1:
        res = 'NO'
print(res)

Submission status: Accepted

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

l = [0 for i in range(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")
		break
else:
	print("YES")

Submission status: Accepted

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

import numpy as np
N,M = map(int, input().split())

counter = np.zeros(N+1)
for m in range(M):
    a, b = map(int, input().split())
    counter[a] += 1
    counter[b] -= 1

cnt = 0
succ = True
for n in range(N+1):
    cnt += counter[n]
    if cnt % 2:
        succ = False
        break
if succ:
    print("YES")
else:
    print("NO")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map( int, input().split() )
imos = [ 0 for i in range( N + 1 ) ]
for i in range( M ):
  a, b = map( int, input().split() )
  imos[ a - 1 ] += 1
  imos[ b - 1 ] -= 1
for i in range( 1, N ):
  imos[ i ] += imos[ i - 1 ]
print( "NO" if any( imos[ i ] & 1 for i in range( N ) ) else "YES" )

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().split())
deg = [0]*n
for i in xrange(m):
    a, b = map(int, raw_input().split())
    deg[a-1] += 1
    deg[b-1] += 1
print "YES"*all(d % 2 == 0 for d in deg)or"NO"