TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
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')

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
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")

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


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


Verdicts: Runtime Error

Wrong Answer

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

Submission attempts (in order):
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")


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


Verdicts: Wrong Answer

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

Submission attempts (in order):
from collections import Counter

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

from collections import Counter

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

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

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
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")

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("NO" if sum(s%2)else"YES")

Verdicts: Wrong Answer

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

Submission attempts (in order):
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')

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
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])

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 c)::2])

Verdicts: Wrong Answer

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

Submission attempts (in order):
N, M = map(int, input().split())  

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


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

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


Verdicts: Wrong Answer

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

Submission attempts (in order):
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')

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
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()


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"

print(main())


Verdicts: Wrong Answer

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

Submission attempts (in order):
N,M=map(int, input().split())







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

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
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)


N,M=map(int,input().split())
import collections
e =[]
for i in range(M):
    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)


Verdicts: Runtime Error

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

Submission attempts (in order):
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")

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==1:
        print("NO")
        exit()

print("YES")

Verdicts: Wrong Answer

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

Submission attempts (in order):
#! /usr/bin/env python
# -*- coding: 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')


#! /usr/bin/env python
# -*- coding: 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')


Verdicts: Wrong Answer

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

Submission attempts (in order):
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")







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

Verdicts: Runtime Error

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

Submission attempts (in order):
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)


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)%2 for g in G) else "YES"

print(ans)


Verdicts: Wrong Answer

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

Submission attempts (in order):
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")

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
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")

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

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

Verdicts: Runtime Error

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

Submission attempts (in order):
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)

import sys
from collections import Counter
read=sys.stdin.read
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)

Verdicts: Runtime Error

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

Submission attempts (in order):
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")

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


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


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Takahashi is locked within a building.  This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered.  Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1).  Takahashi will use his magic to get out of the building. In one cast, he can do the following:    * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered.   * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on.  His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so.  It is guaranteed that Takahashi is initially at a room without an exit.

Submission attempts (in order):
H,W,K = map(int,input().split())
HW = [list(input()) for i in range(H)]
for i,h in enumerate(HW):
	if "S" in h:
		y = i
		x = h.index("S")
A = [(x,y)]
m = 800
def idou(a,b):
	X = []
	for i2 in range(4):
		if i2 == 0:
			t,k = a - 1, b
		elif i2 == 1:
			t,k = a, b - 1
		elif i2 == 2:
			t,k = a + 1, b
		elif i2 == 3:
			t,k = a, b + 1
		if 0 <= t < W and 0 <= k < H and HW[k][t] == ".":
			HW[k][t] = "o"
			X.append((t,k))
	return X
cnt = 0
for p in A:
	cnt += 1
	x,y = p
	b = idou(x,y)
	A.extend(b)
	if cnt > K:
		break
M = []
for i,w in enumerate(zip(*HW)):
	#print(w)
	if "o" in w or "S" in w:
		M.append(min(i,W - i - 1))
		
for i,h in enumerate(HW):
	if "S" in h or "o" in h:
		M.append(min(i, H - i - 1))
		#print(h)
m = min(M)
print((m + K - 1) // K)

import math
H,W,K = map(int,input().split())
HW = [list(input()) for i in range(H)]
for i,h in enumerate(HW):
	if "S" in h:
		y = i
		x = h.index("S")
A = [(x,y)]
m = 800
def idou(a,b):
	X = []
	for i2 in range(4):
		if i2 == 0:
			t,k = a - 1, b
		elif i2 == 1:
			t,k = a, b - 1
		elif i2 == 2:
			t,k = a + 1, b
		elif i2 == 3:
			t,k = a, b + 1
		if 0 <= t < W and 0 <= k < H and HW[k][t] == ".":
			HW[k][t] = "o"
			X.append((t,k))
	return X
cnt = 0
while cnt < K:
	cnt += 1
	B = []
	for p in A:
		x,y = p
		b = idou(x,y)
		B.extend(b)
	A = B[:]
M = []
for i,w in enumerate(zip(*HW)):
	#print(w)
	if "o" in w or "S" in w:
		M.append(min(i,W - i - 1))
		
for i,h in enumerate(HW):
	if "S" in h or "o" in h:
		M.append(min(i, H - i - 1))
		#print(h)
m = min(M)
print((m + K - 1) // K + 1)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi is locked within a building.  This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered.  Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1).  Takahashi will use his magic to get out of the building. In one cast, he can do the following:    * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered.   * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on.  His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so.  It is guaranteed that Takahashi is initially at a room without an exit.

Submission attempts (in order):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque
from math import ceil

def dist(h,w,x,y):
    return min(x-1,h-x,y-1,w-y)

h,w,k=map(int,input().split())
delta=[[1,0],[0,1],[-1,0],[0,-1]]
MAP=[]
A=['#']*(w+2)
MAP.append(A)
for i in range(h):
    s=input()
    for j,t in enumerate(s):
        if t=='S':
            sx,sy=i+1,j+1
    MAP.append(list(s))
MAP.append(A)
d=[[-1]*(w+2) for _ in range(h+2)]
d[sy][sx]=0
P=[]
q=deque()
q.append((sx,sy))
while q:
    x,y=q.popleft()
    if d[x][y]>k:
        break
    P.append([x,y])
    for dx,dy in delta:
        if d[y+dy][x+dx]==-1 and MAP[y+dy][x+dx]=='.':
            q.append((y+dy,x+dx))
            d[y+dy][x+dx]=d[y][x]+1
ans=float('inf')
for x,y in P:
    ans=min(ans,1+ceil(dist(h,w,x,y)/k))
print(ans)

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
from collections import deque
from math import ceil

h,w,k=map(int,input().split())
MAP=[]
for i in range(h):
    s=list(input().strip())
    for j,t in enumerate(s):
        if t=='S':
            sx,sy=i,j
    MAP.append(s)
delta=[[1,0],[0,1],[-1,0],[0,-1]]
q=deque()
q.append((sx,sy,k))
dist=float('inf')
Visited=[[False]*w for _ in range(h)]
Visited[sx][sy]=True
while q:
    x,y,t=q.popleft()
    dist=min(dist,x,y,h-1-x,w-1-y)
    if not dist:
        break
    if t:
        t-=1
        for dx,dy in delta:
            if MAP[x+dx][y+dy]=='.' and not Visited[x+dx][y+dy]:
                q.append((x+dx,y+dy,t))
                Visited[x+dx][y+dy]=True
print(1+ceil(dist/k))

Verdicts: Runtime Error

Accepted
Problem: Takahashi is locked within a building.  This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the room is not locked and can be freely entered. Takahashi is currently at the room where A_{i,j}= `S`, which can also be freely entered.  Each room in the 1-st row, 1-st column, H-th row or W-th column, has an exit. Each of the other rooms (i,j) is connected to four rooms: (i-1,j), (i+1,j), (i,j-1) and (i,j+1).  Takahashi will use his magic to get out of the building. In one cast, he can do the following:    * Move to an adjacent room at most K times, possibly zero. Here, locked rooms cannot be entered.   * Then, select and unlock at most K locked rooms, possibly zero. Those rooms will remain unlocked from then on.  His objective is to reach a room with an exit. Find the minimum necessary number of casts to do so.  It is guaranteed that Takahashi is initially at a room without an exit.

Submission attempts (in order):
import itertools, math
H, W, K = [int(_) for _ in input().split()]
A = [list(input()) for _ in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if A[i][j] == 'S':
        break
stack = [[i, j, 0]]
cand = []
while stack:
    h, w, dist = stack.pop()
    print(h, w, dist)
    A[h][w] = '#'
    cand += [[h, w]]
    if dist < K:
        for nh, nw in [[h - 1, w], [h + 1, w], [h, w - 1], [h, w + 1]]:
            if 0 <= nh < H and 0 <= nw < W and A[nh][nw] == '.':
                stack += [[nh, nw, dist + 1]]
ans = float('inf')
for hw in cand:
    h, w = hw
    ans = min([
        ans,
        math.ceil(h / K),
        math.ceil((H - 1 - h) / K),
        math.ceil(w / K),
        math.ceil((W - 1 - w) / K)
    ])
print(ans + 1)


import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [list(input()) for _ in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if A[i][j] == 'S':
        break
Q = collections.deque([[i, j, 0]])
sH = set()
sW = set()
while Q:
    h, w, dist = Q.popleft()
    sH.add(h)
    sW.add(w)
    if dist < K:
        for nh, nw in [[h - 1, w], [h + 1, w], [h, w - 1], [h, w + 1]]:
            if 0 <= nh < H and 0 <= nw < W and A[nh][nw] == '.':
                A[nh][nw] = '#'
                Q += [[nh, nw, dist + 1]]
print(1 + min([
    math.ceil(_ / K)
    for _ in (min(sH), H - 1 - max(sH), min(sW), W - 1 - max(sW))
]))


Verdicts: Wrong Answer

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
def main():
    line=input()
    line=line.split(' ')
    n=line[0]
    t=line[1]
    line=input()
    line=line.split(' ')
    total=0
    for i in range(1,n):
        total+=min(t,line[i]-line[i-1])
    print(total)
    

if __name__=='__main__':
    main()

def main():
    line = input()
    line = line.split(' ')
    n = int(line[0])
    t = int(line[1])
    line = input()
    line = line.split(' ')
    total = 0
    for i in range(1, n):
        total += min(t, int(line[i]) - int(line[i - 1]))
    print(total+t)


if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
N,W = map(int,input().split())

items = [tuple(map(int,input().split())) for i in range(N)]

from collections import defaultdict
dp = defaultdict(int) # w -> v
dp[0] = 0

for w,v in items:
  for tw,tv in list(dp.items()):
    if tw+w <= W:
      dp[tw+w] = max(tv+v, dp[tw+w])

print(max(dp.values()))

f=lambda:map(int,input().split())
N,T=f()
q=list(f())
print(T+sum(min(q[i+1]-q[i],T) for i in range(N-1)))

Verdicts: Runtime Error

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
N, T=map(int, input().split())
a=list(map(int, input().split()))

ans=T

for i in range(N-1):
    space=a[i+1]-a[i]
    if space>=T:
        ans+=T
    else:
        loss=T-space
        ans+=T-loss


N, T=map(int, input().split())
a=list(map(int, input().split()))

ans=T

for i in range(N-1):
    space=a[i+1]-a[i]
    if space>=T:
        ans+=T
    else:
        loss=T-space
        ans+=T-loss

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
N, T = map(int, input().split())
t = list(map(int, input().split()))

res = 0
for i in range(N - 1):
    res += min(T, t[i + 1] - t[i])

if t[-2] + T <= t[-1]:
    res += T 

print(res)


N, T = map(int, input().split())
t = list(map(int, input().split()))

res = 0
for i in range(N - 1):
    res += min(T, t[i + 1] - t[i])

res += T

print(res)


Verdicts: Runtime Error

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
n, T, *t = map(int, open(0).read().split())
print(sum(min(t[i+1] - t[i], T) for i in range(n)))

n, T, *t = map(int, open(0).read().split())
print(sum(min(t[i+1] - t[i], T) for i in range(n-1)) + T)

Verdicts: Runtime Error

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = T

for i in range(1, N):
    ans = min(T, t[i]-t[i-1])
print(ans)


N, T = map(int, input().split())
t = list(map(int, input().split()))
print(T+sum(min(T, t[i]-t[i-1]) for i in range(1, N)))


Verdicts: Wrong Answer

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
# N,T=map(int,input().split())
# s=list(map(int, input().split()))
N=9
T=10
t=[0,3,5,7,100,110,200,300,311]
ans=0
t_diff=[t[i+1]-t[i] for i in range(N-1)]
print(t_diff)
for i in t_diff:
    if i>T:
        ans+=T
    else:
        ans+=i

print(ans+T)




N,T=map(int,input().split())
s=list(map(int, input().split()))

t=[0,3,5,7,100,110,200,300,311]
ans=0
t_diff=[t[i+1]-t[i] for i in range(N-1)]
print(t_diff)
for i in t_diff:
    if i>T:
        ans+=T
    else:
        ans+=i

print(ans+T)




N,T=map(int,input().split())
t= list(map(int,input().split()))
ans=0
t_diff=[t[i+1]-t[i] for i in range(N-1)]
for i in t_diff:
    if i>T:
        ans+=T
    else:
        ans+=i

print(ans+T)




Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
N,T=map(int,input().split())
a=list(map(int,input().split()))
keep=0
ans=0

for i in range(N):
  if keep<=a[i]:
    ans+=T
    keep+=a[i]+T
print(ans)
    
    
  

n,t=map(int,input().split())
a=list(map(int,input().split()))
keep=0
ans=0
for i in range(n):
    if keep<=a[i]:
        ans+=t
        keep=a[i]+t
    else:
        ans=ans+t-(keep-a[i])
        keep=a[i]+t
print(ans)
        

Verdicts: Wrong Answer

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
N, T = input().split()

f = None
p = None
ans = 0
for t in map(int, input().split())
  if f is None:
    f = t
    p = t - f

  ans += T
  rest = p + T - (t - f)
  if rest > 0:
    ans -= rest

  p = t - f

print(ans)

N, T = map(int, input().split())

f = None
p = None
ans = 0
for t in map(int, input().split()):
  if f is None:
    f = t
    p = f - T

  ans += T
  rest = p + T - (t - f)
  if rest > 0:
    ans -= rest
  p = t - f

print(ans)


Verdicts: Runtime Error

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0
for i in range(1,N):
  ans += min(T, t[i] - t[i-1])

print(ans)

N, T = map(int, input().split())
t = list(map(int, input().split()))

ans = T
for i in range(1,N):
  ans += min(T, t[i] - t[i-1])

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
N,T = map(int,input().split())
A = list(map(int,input().split()))
LST = []

ans = 0
nxt = -1
for a in A:
  if nxt < a:
    nxt = a + T
    ans += T
  
print(ans)



N,T = map(int,input().split())
A = list(map(int,input().split()))
LST = []

for a in A:
  LST.append((a,1))
  LST.append((a+T,-1))
  
LST.sort()

prev = -1
s = 0
ans = 0
for x,y in A:
  if y == 1:
    if s == 0:
      prev = x
    else:
      s += 1
  elif y == -1:
    s -= 1
    if s == 0:
      ans += (x - prev)
  
print(ans)



N,T = map(int,input().split())
A = list(map(int,input().split()))
LST = []

for a in A:
  LST.append((a,1))
  LST.append((a+T,-1))
  
LST.sort()

prev = -1
s = 0
ans = 0
for x,y in LST:
  if y == 1:
    if s == 0:
      prev = x
    else:
      s += 1
  elif y == -1:
    s -= 1
    if s == 0:
      ans += (x - prev)
  
print(ans)



N,T = map(int,input().split())
A = list(map(int,input().split()))

ans = 0
for i in range(N-1):
  ans += min(T,A[i+1] - A[i])
  
print(ans+T)



Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
N,T = map(int,input().split());
t = [int(x) for x in input().split()];

end = 0;
ans = 0;
for i in range(N) :
    if end > t[i] :
        ans += t[i] + T - end;
        else :
        ans += T;
    end += t[i] + T;
    #print(ans,end);

print(ans); 

N,T = map(int,input().split());
t = [int(x) for x in input().split()];

end = 0;
ans = 0;
for i in range(N) :
    if end > t[i] :
        ans += t[i] + T - end;
    else :
        ans += T;
    end = t[i] + T;
    #print(ans,end);

print(ans); 

Verdicts: Runtime Error

Accepted
Problem: In a public bath, there is a shower which emits water for T seconds when the switch is pushed.  If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.  N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it.  How long will the shower emit water in total?

Submission attempts (in order):
n,t=map(int,input().split())
oyu=list(map(int,input.split()))
inl=[]
ans=n*t
for i in range(n-1):
  inl.append(oyu[i+1]-oyu[i])
for i in range(n-1):
  if inl[i]<t:
    ans-=t-inl[i]
print(ans)

n,t=map(int,input().split())
oyu=list(map(int,input().split()))
inl=[]
ans=n*t
for i in range(n-1):
  inl.append(oyu[i+1]-oyu[i])
for i in range(n-1):
  if inl[i]<t:
    ans-=t-inl[i]
print(ans)


Verdicts: Runtime Error

Accepted