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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from random import *
from functools import reduce,partial
from time import time
from pprint import pprint

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

def identity(x):
    """Return the input itself."""
    return x

def constant(c):
    """Return an function which always
    returns the input constant c."""
    def const_function(const,*args):
        return const
    return partial(const_function,c)

def inc(c = 1):
    """Return a function which reads an input x and returns x + c as output.
    By default, c equals 1."""
    return lambda x: x + c

def add(*args):
    """Return the sum of the input."""
    def add2(x,y): return x + y
    return reduce(add2,args)

def mapv(f,*lst):
    """Return a vector of the result of map."""
    return list(map(f,*lst))

def vector(*args):
    """Return a vector of input parameters."""
    return args

def sequence(n,f = constant(0)):
    """Return a vector of length n, and initialize the i'th
    item with f(i).By default the vector will initialized with 0."""
    return [f(i) for i in range(0,n)]

def matrix(n,m,f = constant(0)):
    """Return a 2-dim vector which contains n vectors with length m.
    The j's item of vector i will be initialized by f(i,j).By default,
    the vector will be initialized with 0."""
    return [[f(i,j) for j in range(0,m)] for i in range(0,n)]

def flat(v):
    """Return a flat vector which contains the elements of v in their
    origin order.If the input is not a vector, return a vector which
    only contains the input."""
    if not isinstance(v,list): return [v]
    if not v: return []
    return reduce(add,mapv(flat,v))

def partition(v,f = identity):
    """Partition vector v by f(v[i]).
    e.g. partition([1,2,3,1,2,3],identity()) == {1:[1,1,1], 2:[2,2], 3:[3]}
    By default, the vector will be partitioned by identity function."""
    result = {}
    for item in v:
        key = f(item)
        s = result.get(key)
        if s:
            s.append(item)
        else:
            result.update({key:[item]})
    return result

def getValue(key):
    """Return a function which returns the value of key in a hash-map.
    If the key do not exist, it will throw an error."""
    return lambda x: x[key]

def mapValue(f,m):
    """Replace each value in hash-map m with f(value).
    Return the new hash-map."""
    res = {}
    for key in m:
        res.update({key: f(m[key])})
    return res

p = 1000000000 + 7

n,m = readln()
c = sequence(n)
for i in range(0,m):
    a,b = readln()
    c[a-1] += 1
    c[b-1] += 1
ans = 'YES'
for count in c:
    if count % 2 == 1:
        ans = 'NO'
print(ans)

Submission status: Accepted

Solution code:
N,M = map(int, raw_input().split())
C = [0]*N
for _ in range(M):
    a,b = map(int, raw_input().split())
    C[a-1] += 1
    C[b-1] += 1
ok = True
for c in C:
    if c%2!=0:
        ok = False
print "YES" if ok else "NO"

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

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


def main():
    n,m = LI()
    d = collections.defaultdict(int)
    for _ in range(m):
        a,b = LI()
        d[a] += 1
        d[b] += 1
    for c in d.values():
        if c % 2 == 1:
            return 'NO'
    return 'YES'


print(main())

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
cntNode = [0]*N
for i in range(N):
    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: Runtime Error

Solution code:
N,M = map(int,input().split())
cntNode = [0]*N
for i in range(N):
    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: Runtime Error

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

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

    # 「全ての頂点が偶数回登場する」は必要条件
    # 奇数回登場する頂点があると、それに繋がる辺の中に必ず奇数になる辺が出るから
    # 深さ1の木を考えると、全ての頂点が偶数回登場するならば、
    # 葉iの登場回数=葉iに繋がる辺の数字より、全ての辺の数字が偶数
    if len([i for i in cnt if i % 2 == 0]) == N:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    resolve()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict
# d = defaultdict(int)で0で初期化
# d = defaultdict(lambda: 100)で100で初期化
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
es = [defaultdict(int) for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    es[a][b] += 1
    es[b][a] += 1
    if es[a][b] == 2:
        es[a].pop(b)
        es[b].pop(a)

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
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: Runtime Error

Solution code:
"""
rootを決めて、aから必ずrootを通ってbに到達するとする
aとbのlcaより上は、+2されることになるので、実質通っていないのと同値
どんな木であっても、自分自身が偶数回(0を含む)でてこないと
ノードの値は偶数にはなりえない
"""
n, m = map(int, input().split())
cnts = [0] * (n+1) 
for i in range(n):
    a,b = map(int, input().split())
    cnts[a] += 1
    cnts[b] += 1
if all([c%2 == 0 for c in cnts]):
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n+1)}
for _ in range(n):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n)}
for _ in range(n):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n)}
for _ in range(n):
    a, b = map(int, input().split())
    if a != 1:
        d[a] = 1 if a not in d else d[a] + 1
    if b != 1:
        d[b] = 1 if b not in d else d[b] + 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A,B,C = map(int,input().split())
if A*2 == B+C and B*2 == A+C and C*2 == A+B:
    print(-1)
    exit()
ans = 0
for i in range(10000):
    a = A//2
    b = B//2
    c = C//2
    if A%2 == 0 and B%2 == 0 and C%2 == 0:
        ans += 1
        A = b+c
        B = a+c
        C = a+b
    else:
        print(ans)
        exit()

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline


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

    if all(c % 2 == 0 for c in count):
        ans = "YES"
    else:
        ans = "NO"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

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

    for i in cnt:
        if i % 2:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    resolve()

Submission status: Runtime Error

Solution code:
#AGC014-B Unplanned Queries
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,m = map(int,readline().split())
dic1 = defaultdict(int)
for i in range(n):
    a,b = map(int,readline().split())
    dic1[a] += 1
    dic1[b] += 1

for i in dic1.values():
    if not even(i):
        print("NO")
        exit()
print("YES")

Submission status: Runtime Error

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

im_b = [0]*(n)

for i in range(n):
    im_b[ab[i][0]-1] += 1
    im_b[ab[i][1]-1] -= 1

if im_b[0] % 2 == 1:
    print('NO')
    exit()

#im_a = [0]*(n)
#im_a[0] = im_b[0]

for i in range(n-1):
    #print(i)
    if im_b[i] % 2 == 1:
        print('NO')
        exit()

print('YES')

Submission status: Runtime Error

Solution code:
c = [0]*10**5
for i in open(0).read().split()[2::]: c[int(i)] ^= 1
print("NO" if any(c) else "YES")

Submission status: Runtime Error

Solution code:
c = [0]*10**5
for i in open(0).read().split()[::2]: c[int(i)] ^= 1
print("NO" if any(c) else "YES")

Submission status: Runtime Error

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

s = []
for _ in range(n):
    a,b = map(int,input().split())
    s.append(a)
    s.append(b)
    
c = Counter(s)
d = list(c.values())

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

Submission status: Runtime Error

Solution code:
#13
a,b,c = map(int,input().split())
cnt = 0
if  a%2 == 1 or b%2 == 1 or c%2 == 1:
    print(0)

while a%2 == b%2 == c%2 == 0:
    if a==b==c:
        print('-1')
        break
    else:
        a,b,c = b//2+c//2,c//2+a//2+a//2+b//2
        cnt+=1

print(cnt)

Submission status: Runtime Error

Solution code:
#13
a,b,c = map(int,input().split())
cnt = 0
if  a%2 == 1 or b%2 == 1 or c%2 == 1:
    print(0)

while a%2 == b%2 == c%2 == 0:
    if a==b==c:
        print('-1')
        break
    else:
        a,b,c = b//2+c//2,c//2+a//2+a//2+b//2
        cnt+=1
        print(a,b,c)

print(cnt)

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/agc014/tasks/agc014_b
# 条件を満たすものが存在するかの判別問題

# クエリをグラフにして考えてみる
# a-bを結ぶすべての経路は木上のa-b間の経路を必ず通る
# つまりa-b間の経路の数が偶数である必要がある。すべてのノードに対してエッジが偶数個つながっているかを確認すればよい

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a * b // g


N, M = read_ints()

n_edges = [0] * N
for _ in ra(M):
    a, b = read_ints()
    n_edges[a - 1] += 1
    n_edges[b - 1] += 1

for n in n_edges:
    if n & 1:
        print('NO')
        exit()
print('YES')

Submission status: Runtime Error

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], 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: Runtime Error

Solution code:
わからん

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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(m):
  if l[i]%2!=1:
    b=False
if b:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
def main():
    n, m = map(int, input().split())
    ab = [sorted(list(map(int, input().split()))) for _ in [0] * n]
    l = [0] * (n - 1)
    for i in range(m):
        a, b = ab[i]
        if a != 1:
            l[a-2]+=1
        l[b - 2] += 1
    l=[i%2 for i in l]
    if sum(l) > 0:
        print("NO")
    else:
        print("YES")
main()

Submission status: Runtime Error

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

flag = 1
for i in num:
    if i % 2 != 0:
        flag = 0

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

Submission status: Runtime Error

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

flag = 1
for i in num:
    if num % 2 != 0:
        flag = 0

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

Submission status: Runtime Error

Solution code:
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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
g=[[]*for _ in range(n+1)]
for _ in range(m):
  u,v=map(int,input().split())
  g[u].append(v)
  g[v].append(u)
flag=True
for i in range(1,n+1):
  if g[i]%2==0:
    continue
  else:
    flag=False
    break
if flag==True:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
def main():
    N, M = map(int, input().split())
    cnt = [0] * N
    for _ in range(N):
        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")
            return
    print("YES")


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
import collections
e =[]
for i in range(N):
    ta,tb =map(int,input().split())
    e.extend([ta,tb])
c = collections.Counter(e)
#print(c)
ans = "YES"
for i in c:
    if c[i]%2 != 0:
        ans = "NO"
print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
import collections
e =[]
for i in range(N):
    ta,tb =map(int,input().split())
    e.extend([ta,tb])
c = collections.Counter(e)
print(c)
ans = "YES"
for i in c:
    if c[i]%2 != 0:
        ans = "NO"
print(ans)

Submission status: Runtime Error

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

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

Submission status: Runtime Error

Solution code:
l=[0]*2**14
for i in open(0).read().split()[2:]:l[int(i)]+=1
print('YNEOS'[any(i%2for i in l)::2])

Submission status: Runtime Error

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

q = [0] * N
for _ in range(N):
    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: Runtime Error

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

Solution code:
N, M = (int(i) for i in input().split())
DP = [False]*N
for i in range(M):
  a, b = (int(i) for i 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: Runtime Error

Solution code:
N, M = (int(i) for i in input().split())
DP[N] = [False]*N
for i in range(M):
  a, b = (int(i) for i 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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Solution code:
N,M=map(int,input().split())
a=[0 for i in range(N)]
b=[0 for i in range(N)]
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: Runtime Error

Solution code:
from collections import Counter
n,m = map(int,input().split())
lis = []
il = set()
key = 0
for i in range(n):
    a,b = map(int,input().split())
    lis.append(a)
    lis.append(b)
    il.add(a)
    il.add(b)
for h in range(len(il)):
    try:
        if lis.count(h+1) % 2 == 1:
            print("NO")
            key = 1
            break
    except:
        continue
if key == 0:
    print("YES")

Submission status: Runtime Error

Solution code:
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: Runtime Error

Solution code:
N,M = map(int, raw_input().split())
hist = {}
for i in range(N):
  a,b = map(int, raw_input().split())
  if a in hist:
    hist[a] += 1
  else:
    hist[a] = 1
  if b in hist:
    hist[b] += 1
  else:
    hist[b] = 1

for v in hist.values():
  if v%2 == 1:
    print 'NO'
    break
else : print 'YES'

Submission status: Runtime Error

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(M)]
    for i in AB:
        j = i[0] - 1
        end = i[1] - 1
        while j < end:
            edge[j] += 1
            j += 1

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

main()

Submission status: Runtime Error

Solution code:
N = int(input())

l = [0 for i in range(N)]
ad = [[] for i in range(N)]
de1 = [0 for i in range(N)]

for i in range(N-1):
	a,b = map(int,input().split())
	l[a-1] += 1
	l[b-1] += 1
	ad[a-1].append(b-1)
	ad[b-1].append(a-1)

for i in range(N):
	if l[i] == 1:
		de1[ad[i][0]] += 1

for i in range(N):
	if de1[i] >= 2:
		print("First")
		break
else:
	print("Second")

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
	N, M=map(int, input().split())
	a=[]
	b=[]
	for i in range(M):
		x,y=[int(i) for i in input().split()]
		a.append(x)
		b.append(y)
		n=[]
		for j in range(N):
			n.append(0)

	for i in range(N):
		n[a[i]-1]+=1
		n[b[i]-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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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,M,int(M/10)):
    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: Runtime Error

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,M,int(M/100)):
    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: Runtime Error

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,M/100):
    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: Runtime Error

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[i]%2==1:
  print("NO")
else:
  print("YES")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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