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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    counter = 0
    done = False
    for key in cache.keys():
        if not cache[key] % 2:
            done = True
            counter += 1
            counter %= 2
    if counter or not done:
        print('NO')
    else:
        print('YES')

if __name__ == "__main__":
    run()

Submission status: Wrong Answer

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

    counter = 0
    for key in cache.keys():
        if not cache[key] % 2:
            counter += 1
            counter %= 2
    if counter:
        print('NO')
    else:
        print('YES')

if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
K=0
for _ in range(M):
    a,b=map(int,input().split())
    K+=(a+b)
    K%=2

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
K=0
for _ in range(M):
    a,b=map(int,input().split())
    K+=(a+b)
    K%=2

if K:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

# input aliases
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  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    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):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]

class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    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):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        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)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy
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
    # print(ji)
    # print(g)
    for i in range(n-1):
        if ji[i] % 2 == 1:
            for q in g[i]:
                if ji[q] % 2 == 0:
                    print("NO")
                    return

    print("YES")

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

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

Submission status: Wrong Answer

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

if sum(road)%2==0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

if N % 2 == 0 and M % 2 == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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

if N % 2 == 0 and M % 2 == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, M = map(int, input().split())
    ans = 0
    for _ in range(M):
        a, b = map(int, input().split())
        ans += abs(a-b)
    if ans & 1:
        print('NO')
    else:
        print('YES')

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import deque

def bfs():
    q = deque()
    for i in range(m):
        if c[i] == 0:
            q.append(v[i])
            while q:
                p = q.popleft()
                u = -1
                while G[p]:
                    x, y = G[p].popleft()
                    if c[y] == 1:
                        continue
                    else:
                        q.append(x)
                        u = x
                        break
                if u == v[i]:
                    c[y] = 1
                    break
                if u == -1:
                    print("NO")
                    exit()
                c[y] = 1
    print("YES")
    return

n, m = map(int, input().split())
G = [deque() for _ in range(n + 1)]
c = [0] * m
v = [0] * m
for i in range(m):
    a, b = map(int, input().split())
    G[a].append([b, i])
    G[b].append([a, i])
    v[i] = a
bfs()

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,m=LI()
  l=[0]*n

  for _ in range(m):
    a,b=LI()
    a-=1
    b-=1
    l[a]+=1
    l[b]+=1

  for i in range(n):
    if l[i]==1:
      return 'NO'

  return 'YES'

# main()
print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split(' '))
l = [0]*(N-1)
for i in range(M):
    a, b = map(int, input().split(' '))
    if 1 in [a, b]:
        a, b = sorted([a, b])
        l[b-2] += 1
    else:
        l[a - 2] += 1
        l[b - 2] += 1
for i in l:
    if i % 2 != 0:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
dic = defaultdict(list)
n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
init = a
cur = a
for i in range(m):
    if dic[cur]:
        b = dic[cur][0]
        dic[cur].remove(b)
        dic[b].remove(cur)
        cur = b
    else:
        print('NO')
        exit()
if cur == init:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
dic = defaultdict(list)
n, m = map(int, input().split())
for i in range(m):
    a, b = map(int, input().split())
    dic[a].append(b)
    dic[b].append(a)
cur = a
for i in range(m):
    if dic[cur]:
        b = dic[cur][0]
        dic[cur].remove(b)
        dic[b].remove(cur)
        cur = b
    else:
        print('NO')
        exit()
print('YES')

Submission status: Wrong Answer

Solution code:
def main():
    vertex, query = map(int, input().split())
    cnt = [0 for _ in range(vertex)]
    answer = "YES"
    for _ in range(query):
        a, b = map(lambda x: int(x) - 1, input().split())
        left = min(a, b)
        right = max(a, b)
        cnt[left] += 1
        if right < vertex - 1:
            cnt[right + 1] -= 1
    for i in range(1, vertex):
        cnt[i] += cnt[i - 1]
    odd_cnt = cnt[0] % 2
    odd_cnt_odd = 0
    for i in range(1, vertex):
        if cnt[i] % 2 == 1:
            odd_cnt += 1
        else:
            if odd_cnt % 2:
                odd_cnt_odd += 1
            odd_cnt = 0
    if odd_cnt_odd % 2 == 0:
        answer = "NO"
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    vertex, query = map(int, input().split())
    cnt = [0 for _ in range(vertex)]
    answer = "YES"
    for _ in range(query):
        a, b = map(lambda x: int(x) - 1, input().split())
        left = min(a, b)
        right = max(a, b)
        cnt[left] += 1
        if right < vertex - 1:
            cnt[right + 1] -= 1
    for i in range(1, vertex):
        cnt[i] += cnt[i - 1]
    odd_cnt = cnt[0] % 2
    for i in range(1, vertex):
        if cnt[i] % 2 == 1:
            odd_cnt += 1
        elif odd_cnt % 2 == 1:
            answer = "NO"
            break
        else:
            odd_cnt = 0
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
g=[0]*(n+1)
for _ in range(m):
  a,b=map(int,input().split())
  g[a]+=1
  g[b]+=1
  g[a]%=2
  g[b]%=2
  
print("Yes" if 1-max(g) else "No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
g=[0]*(n+1)
for _ in range(m):
  a,b=map(int,input().split())
  g[a]+=1
  g[b]+=1
  g[a]%=2
  g[b]%=2
  
print("Yes" if max(g) else "No")

Submission status: Wrong Answer

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

ok = True
for c in c_list:
    if c % 2 != 0:
        ok = False
if ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print("Yes" if all(c[i]%2 == 0 for i in range(N+1)) else "No")

Submission status: Wrong Answer

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

tree = [0 for _ in range(n+1)]
for _i in range(m):
    a, b = map(int, input().split())
    tree[a] += 1
    tree[b] += 1
if all(i%2==0 for i in tree):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

for c in count:
    if c%2==0:
        print("NO")
        exit()

print("YES")

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
#a-bのパスに書かれた数を＋１していく
#最終　全部偶数
#木
#奇数回しか出てこないところは端っこじゃダメ
#偶数回は端っこOK
#0は必ず端
#奇数回はだめ
D={} 
for i in range(N):
  D[i+1]=0
for i in range(M):
  a,b=map(int, input().split())
  D[a]+=1
  D[b]+=1

odds=0
evens=0
for v in D.values():
    if v%2==0:
        evens+=1
    else:
        odds+=1
if odds==0:
    print("YES")
else:
    if evens>=odds*2:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
#a-bのパスに書かれた数を＋１していく
#最終　全部偶数
#木
#奇数回しか出てこないところは端っこじゃダメ
#偶数回は端っこOK
#0は必ず端
#奇数回はだめ
D={} 
for i in range(N):
  D[i+1]=0
for i in range(M):
  a,b=map(int, input().split())
  D[a]+=1
  D[b]+=1

odds=0
evens=0
for v in D.values():
    if v%2==0:
        evens+=1
    else:
        odds+=1
if odds==0:
    print("Yes")
else:
    if evens>=odds*2:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, m = LI()
    l = [0] * n
    for i in range(m):
        a, b = LI_()
        l[a] ^= 1
        l[b] ^= 1
    print("No" if sum(l) else "Yes")
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flg=True

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

if flg:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import heapq
def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

n,w = map(int,input().split()) #n:頂点数　w:辺の数
edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y = map(int,input().split())
    x-=1
    y-=1
    z=1
    edge[x].append([z,y]) #有向辺
    edge[y].append([z,x]) #有向辺
#print(dijkstra_heap(0))
l=dijkstra_heap(0)
ans=0
for i in range(n):
    if l[i]%2==1:
        ans+=1
if ans%2==0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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):
    r[l[i][0]-1]+=1
    if l[i][0]-1!=l[i][1]-2:
        r[l[i][1]-2]+=1
#print(r,l)
for i in range(n-1):
    if r[i]%2==1:
        print('NO')
        break
else:
    print('YES')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

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

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

for u in U:
  if u % 2:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

G = [[] for i in range(N)]

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

ans = "NO" if any(len(g) for g in G) else "YES"

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())  # N頂点, M個のクエリ

counter = [0] * N

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

flag = True
for i in range(len(counter)):
    if counter[i] % 2 != 0:
        flag = False


if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    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 range(N+1):
        if C[i] % 2 == 1:
            return "NO"
    return "YES"

main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)

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

V = set()
E = [set() for _ in range(N)]
for a,b in AB:
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)
  V.add(a)
  V.add(b)
print(E)
print(len(V))

visited = [0] * N
def dfs(u,v,count):
  visited[u] = count
  count += 1
  res = False
  for t in E[u]:
    if t != v:
      #print(t,u,visited[t],count)
      if visited[t] > 0:
        if visited[t] == 1:
          if count == len(V) + 1:
            return True
          else:
            return False
      else:
        res |= dfs(t,u,count)
  return res

print('YES' if dfs(AB[0][0]-1,-1,1) else 'NO')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)

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

E = [set() for _ in range(N)]
for a,b in AB:
  a -= 1
  b -= 1
  E[a].add(b)
  E[b].add(a)

visited = [0] * N
def dfs(u,v,count):
  visited[u] = count
  count += 1
  res = False
  for t in E[u]:
    if t != v:
      #print(t,u,visited[t],count)
      if visited[t] == 1:
        if count == M + 1:
          return True
        else:
          return False
      res |= dfs(t,u,count)
  return res

print('YES' if dfs(AB[0][0],-1,1) else 'NO')

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
if m%2==1:print("NO")
else:print("YES")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if M % 2 == 0:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
n,_,*l=map(int,open(0).read().split())
c=[0]*-~n
for a,b in zip(l[::2],l[1::2]):
	c[a]^=1;c[b]^=1
print("YNEOS"[any(i for i in l)::2])

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
cnt = [True]*N
for _ in range(M):
    a, b = map(int, input().split())
    cnt[a-1] = ~cnt[a-1]; cnt[b-1] = ~cnt[b-1]
print('YES' if all(cnt) else 'NO')

Submission status: Wrong Answer

Solution code:
n,_,*t=open(0).read().split();print('YNEOS'[int(n)>len(set(sorted(t)[::2]))::2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Solution code:
n, m = map(int, input().split())
if m % 2 == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

# 正答確認用

def main():
    print("YES")

if __name__ == "__main__": main()

Submission status: Wrong Answer

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:
		answ = "NO"
		break
print answ

Submission status: Wrong Answer

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 cnt:
    if cnt[k] % 2 != 0:
        print "NO"
        exit()
if M % 2 != 0:
    print "NO"
    exit()
print "YES"

Submission status: Wrong Answer

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

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

    edge = [0 for i in range(N - 1)]
    for i in AB:
        s = i[0] - 1
        e = i[1] - 1
        while s < e:
            edge[s] += 1
            s += 1

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

main()

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(1,min(10,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()
  if M>10:
    for j in range(M-10,M+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()
  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(1,min(40,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: 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(1,min(20,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: 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(1,min(10,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: Wrong Answer

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 cnt:
    if cnt[k] % 2 != 0:
        print "NO"
        exit()
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,30):
    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")