TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a,b,c=map(int,input().split())
    cunt=0
    if a==b and b==c and a%2==0:
        print(-1)
        sys.exit()
    while True:
        if a%2 or b%2 or c%2:
            print(cunt)
            break
        cunt+=1
        a1,b1,c1=a,b,c
        a=(b1+c1)//2
        b=(a1+c1)//2
        c=(a1+b1)//2
        print(a,b,c)

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a,b,c=map(int,input().split())
    cunt=0
    while True:
        if a==b and b==c:
            print(-1)
            break
        if a%2 or b%2 or c%2:
            print(cunt)
            break
        cunt+=1
        a1,b1,c1=a,b,c
        a=(b1+c1)//2
        b=(a1+c1)//2
        c=(a1+b1)//2
        print(a,b,c)

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a,b,c=map(int,input().split())
    cunt=0
    if a==b and b==c and a%2==0:
        print(-1)
        sys.exit()
    while True:
        if a%2 or b%2 or c%2:
            print(cunt)
            break
        cunt+=1
        a1,b1,c1=a,b,c
        a=(b1+c1)//2
        b=(a1+c1)//2
        c=(a1+b1)//2

if __name__=='__main__':
    main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
def(a,b,c):
  if a%2+b%2+c%2>0:
    return 0
  if a==b==c:
    return -1
  return f((b+c)//2,(c+a)//2,(a+b)//2)+1

a,b,c=map(int,input().split())
print(f(a,b,c))

def f(a,b,c):
  if a%2+b%2+c%2>0:
    return 0
  if a==b==c:
    return -1
  return f((b+c)//2,(c+a)//2,(a+b)//2)+1

a,b,c=map(int,input().split())
print(f(a,b,c))


Verdicts: Runtime Error

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
a, b, c = map(int, input().split())
if a == b == c:
    if a & 1:
        print(0)
    else:
        print(-1)
    exit()

count = 0
while True:
    if (a | b | c) & 1:
        break
    half_a = a // 2
    half_b = b // 2
    half_c = c // 2
    a = half_b + half_c
    b = half_a + half_c
    c = half_a + half_b
    count += 1
print(count)

if a == b == c:
    print(-1)
    exit()

count = 0
while True:
    if (a | b | c) & 1:
        break
    half_a = a // 2
    half_b = b // 2
    half_c = c // 2
    a = half_b + half_c
    b = half_a + half_c
    c = half_a + half_b
    count += 1
print(count)



a, b, c = map(int, input().split())
if a == b == c:
    if a & 1:
        print(0)
    else:
        print(-1)
    exit()

count = 0
while True:
    if (a | b | c) & 1:
        break
    half_a = a // 2
    half_b = b // 2
    half_c = c // 2
    a = half_b + half_c
    b = half_a + half_c
    c = half_a + half_b
    count += 1
print(count)



Verdicts: Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
a,b,c=map(int,input().split())

if a==b==c and a%2==0:
    print(-1)
else:
    num=0
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            break
        num+=1
        l0=(b+c)/2
        l1=(c+a)/2
        l2=(a+b)/2
        a,b,c=l0,l1,l2
    else:
        print(num)

a,b,c=map(int,input().split())

if a==b==c and a%2==0:
    print(-1)
else:
    num=0
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            break
        else:
            l=[(b+c)/2,(c+a)/2,(a+b)/2]
            num+=1
            l=[(l[1]+l[2])/2, (l[2]+l[0])/2, (l[0]+l[2])/2]
            a=l[0]
            b=l[1]
            c=l[2]
    else:
        print(num)

a,b,c=map(int,input().split())

if a==b==c and a%2==0:
    print(-1)
else:
    num=0
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            break
        else:
            num+=1
            l0=(b+c)/2
            l1=(c+a)/2
            l2=(a+b)/2
            a,b,c=l0,l1,l2
    else:
        print(num)

a,b,c=map(int,open(0).read().split())

def is_integer(x):
    tf=1
    for i in range(3):
        tf*=float.is_integer(l[i])
    return tf

if a==b==c:
    print(-1)
else:
    num=-1
    tf=1
    while tf!=0:
        l=[(b+c)/2,(c+a)/2,(a+b)/2]
        tf=is_integer(l)
        num+=1
        l=[(l[1]+l[2])/2, (l[2]+l[0])/2, (l[0]+l[2])/2]
    else:
        print(num)

a,b,c=map(int,open(0).read().split())

if a==b==c and a%2==0:
    print(-1)
else:
    num=0
    while true:
        if a%2==1 or b%2==1 or c%2==1:
            break
        else:
            l=[(b+c)/2,(c+a)/2,(a+b)/2]
            num+=1
            l=[(l[1]+l[2])/2, (l[2]+l[0])/2, (l[0]+l[2])/2]
            a=l[0]
            b=l[1]
            c=l[2]
    else:
        print(num)

a,b,c=map(int,open(0).read().split())

if a==b==c and a%2==0:
    print(-1)
else:
    num=0
    while true:
        if a%2==1 or b%2==1 or c%2==1:
            break
        else:
            l=[(b+c)/2,(c+a)/2,(a+b)/2]
            num+=1
            l=[(l[1]+l[2])/2, (l[2]+l[0])/2, (l[0]+l[2])/2]
            a,b,c=l[0],l[1],l[2]
    else:
        print(num)

a,b,c=map(int,input().split())

if a==b==c and a%2==0:
    print(-1)
else:
    num=0
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            break
        num+=1
        l0=(b+c)/2
        l1=(c+a)/2
        l2=(a+b)/2
        a,b,c=l0,l1,l2
    print(num)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
import sys

A, B, C = map(int, input().split())

count = 0
while True:
    a = B//2 + C//2
    b = C//2 + A//2
    c = A//2 + B//2
    count += 1
    if (a == b and b == c) or (a % 4 == 0 and b % 4 == 0 and c % 4 == 0):
        print('-1')
        sys.exit()
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        break
    A = a
    B = b
    C = c

print(count)

import sys

A, B, C = map(int, input().split())

count = 0
while True:
    a = B//2 + C//2
    b = C//2 + A//2
    c = A//2 + B//2
    count += 1
    if (A == B and B == C) or (A % 4 == 0 and B % 4 == 0 and C % 4 == 0):
        print('-1')
        sys.exit()
    if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        break
    A = a
    B = b
    C = c

print(count)

def func(A, B, C):
    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        return 0
    if A == B and B == C:
        return -1
    return func((B+C)//2, (C+A)//2, (A+B)//2) + 1


A, B, C = map(int, input().split())

ans = func(A, B, C)

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 0:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)
A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 0:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)

A,B,C =map(int,input().split())
con = 0

if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    break
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)

A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 0:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
  
print(con)

A,B,C =map(int,input().split())
con = 0
if A % 2 == 1 or B % 2 == 1 or C % 1 == 1:
  print(0)
  exit()
if A == B and B == C:
  print(-1)
  exit()
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
  con += 1
  D = A / 2
  E = B / 2
  F = C / 2
  A = E + F
  B = D + F
  C = D + E
print(con)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
a, b, c = [int(i) for i in input().split()]

cnt = 0
history = set()
while True:
  print(a, b, c, "-", cnt, history)
  if (a, b, c) in history:
    print(-1)
    exit(0)
  if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(cnt)
    exit(0)
  a, b, c = sorted([a, b, c])
  history.add((a, b, c))
  na = b // 2 + c // 2
  nb = a // 2 + c // 2
  nc = a // 2 + b // 2
  a = na
  b = nb 
  c = nc
  cnt += 1

a, b, c = [int(i) for i in input().split()]

cnt = 0
history = set()
while True:
  if (a, b, c) in history:
    print(-1)
    exit(0)
  if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(cnt)
    exit(0)
  a, b, c = sorted([a, b, c])
  history.add((a, b, c))
  na = b // 2 + c // 2
  nb = a // 2 + c // 2
  nc = a // 2 + b // 2
  a = na
  b = nb 
  c = nc
  cnt += 1

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
A,B,C = map(int,input().split())
cou = 0
if(A % 2 == 1 or B % 2 == 1 or C % 2 == 1):
  print("0")
while(cou < 10*7):
  cou += 1
  A = B/2 + C/2
  B = A/2 + C/2
  C = A/2 + B/2
  if(A % 2 == 1 or B % 2 == 1 or C % 2 == 1):
    print(str(cou))
    break
  else:
    pass
print("-1")

A,B,C = map(int,input().split())
cou = 0
if(A % 2 == 1 or B % 2 == 1 or C % 2 == 1):
  print("0")
  exit()
while(cou < 10**6):
  cou += 1
  a = A
  b = B
  c = C
  A = b/2 + c/2
  B = a/2 + c/2
  C = a/2 + b/2
  if(A % 2 == 1 or B % 2 == 1 or C % 2 == 1):
    print(str(cou))
    exit()
  else:
    pass
print("-1")

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
a,b,c=map(int,input().rstrip().split(' '))
if(a==b and b==c):
	if(a%2==0):
    	print(-1)
	else:
		print(0)
else:
	n=0
	while(a%2==0 and b%2==0 and c%2==0):
		n+=1
		tmp_a=(b+c)/2
		tmp_b=(a+c)/2
		tmp_c=(b+a)/2
		a=tmp_a
		b=tmp_b
		c=tmp_c
	print(n)


a,b,c=map(int,input())
if(a==b and b==c):
	print(-1)
else:
	n=0
	while(a%2==0 and b%2==0 and c%2==0):
		n+=1
    	a=(b+c)/2
    	b=(a+c)/2
    	c=(b+a)/2
	print(n)
    

a,b,c=map(int,input().rstrip().split(' '))
if(a==b and b==c):
	if(a%2==0):
		print(-1)
	else:
		print(0)
else:
	n=0
	while(a%2==0 and b%2==0 and c%2==0):
		n+=1
		tmp_a=(b+c)/2
		tmp_b=(a+c)/2
		tmp_c=(b+a)/2
		a=tmp_a
		b=tmp_b
		c=tmp_c
	print(n)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
A, B, C = map(int, input().split())
count = 0
ABC = []
while True:
    if A % 2 ==0 and B % 2 == 0 and C % 2 == 0:
        nA = B/2 + C/2
        nB = A/2 + C/2
        nC = A/2 + B/2
        A, B, C = nA, nB, nC
        ABC.append([A, B, C])
        count += 1
        if [A, B, C] in ABC:
            count = -1
            break
    else:
        break
print(count)

A, B, C = map(int, input().split())
count = 0
ABC = []
while True:
    if A % 2 ==0 and B % 2 == 0 and C % 2 == 0:
        nA = B/2 + C/2
        nB = A/2 + C/2
        nC = A/2 + B/2
        A, B, C = nA, nB, nC
        count += 1
        if [A, B, C] in ABC:
            count = -1
            break
        ABC.append([A, B, C])
    else:
        break
print(count)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
ms = list(map(int,input().split()))
ans=0
if len(set(ms))==1 and ms[0]%2==0:
    print(-1)
else:
    while(not any([i%2==0 for i in ms])):
        l = [0]*3
        for i in range(3):
            x = ms[i]/2
            if i==0:
                l[1]+=x
                l[2]+=x
            elif i==1:
                l[0]+=x
                l[2]+=x
            elif i==2:
                l[0]+=x
                l[1]+=x
        ms = l[:]
        ans+=1
    print(ans)

ms = list(map(int,input().split()))
if len(set(ms))==1 and ms[0]%2==0:
    print(-1)
else:
    ans=0
    while(all([i%2==0 for i in ms])):
        l = [0]*3
        for i in range(3):
            x = ms[i]/2
            if i==0:
                l[1]+=x
                l[2]+=x
            elif i==1:
                l[0]+=x
                l[2]+=x
            elif i==2:
                l[0]+=x
                l[1]+=x
        ms = l[:]
        ans+=1
    print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
a,b,c = map(int,input().split())
i=0
if a==b==c :
	print("-1")
else:
    while a%2==0 and b%2==0 and c%2==0:
        a/2
        b/2
        c/2
        i+=1
          
print(i)

a,b,c=list(map(int,input().split()))
n=0
H=[]
while True:
  S=[a,b,c]
  if S in H:
    print("-1")
    exit()
  H.append(S)
  if a%2!=0 and b%2!=0 and c%2!=0:
    print(n)
    exit()
  else:
    A=a/4
    B=b/4
    C=c/4
    a=a/2+B+C
    b=b/2+A+C
    c=c/2+A+B
    n+=1

a,b,c=list(map(int,input().split()))
n=0
H=[]
while True:
  S=[a,b,c]
  if S in H:
    print("-1")
    exit()
  H.append(S)
  if a%2!=0 or b%2!=0 or c%2!=0:
    print(n)
    exit()
  else:
    A=a/2
    B=b/2
    C=c/2
    a=int(B+C)
    b=int(A+C)
    c=int(A+B)
    n+=1

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
A, B, C = map(int,input().split())

ans = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    if A == B and A == C:
        print(-1)
        exit()
    a = (B+C)//2
    b = (A+C)//2
    c = (A+B)//2
    A = a
    B = b
    C = c
    print(A,B,C)
    ans += 1

print(ans)

A, B, C = map(int,input().split())

ans = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    if A == B and A == C:
        print(-1)
        exit()
    a = (B+C)//2
    b = (A+C)//2
    c = (A+B)//2
    A = a
    B = b
    C = c
    ans += 1

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
a,b,c = map(int,input().split())

if a == b == c:
  if a%2 = 0:
    print(-1)
    exit()
  else:
    print(0)
    exit()
ans = 0
while(a%2 == b%2 == c%2 == 0):
  temp_a = (b+c)//2
  temp_b = (a+c)//2
  temp_c = (b+a)//2
  ans += 1
  a = temp_a
  b = temp_b
  c = temp_c
print(ans)

a,b,c = map(int,input().split())

if a == b == c:
  if a%2 == 0:
    print(-1)
    exit()
  else:
    print(0)
    exit()
ans = 0
while(a%2 == b%2 == c%2 == 0):
  temp_a = (b+c)//2
  temp_b = (a+c)//2
  temp_c = (b+a)//2
  ans += 1
  a = temp_a
  b = temp_b
  c = temp_c
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
A, B, C = (int(i) for i in input().split()) 


result = 0
memory = []
while True:
    memory.append(sorted([A, B, C]))

    a = A / 2
    b = B / 2
    c = C / 2

    A = b + c
    B = a + c
    C = a + b


    for m in memory:
        l = sorted([A, B, C])
        if m[0] == l[0] and m[1] == l[1] and m[2] == l[2]:
            result = -1
    
    if result == -1:
        break



    if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
        break

    

print(result)




A, B, C = (int(i) for i in input().split()) 






result = 0
memory = [[A, B, C]]
while True:
    if A % 2 != 0 or B % 2 != 0 or C % 2 != 0:
        break
    else:
        result += 1
    
    a = A / 2
    b = B / 2
    c = C / 2

    A = b + c
    B = a + c
    C = a + b

    l = sorted([A, B, C])
    for m in memory:
        if m[0] == l[0] and m[1] == l[1] and m[2] == l[2]:
            result = -1
            break
    
    if result == -1:
        break

	

    

    memory.append(l)
    

print(result)




Verdicts: Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
print(-1)

a,b,c=map(int,input().split())
if a%2==b%2==c%2==0 and a==b==c:print(-1)


a,b,c=map(int,input().split())
if a%2==b%2==c%2==0 and a==b==c:print(-1);exit()
else:
    ans=0
    while a%2==b%2==c%2==0:
        a,b,c=b//2+c//2,a//2+c//2,a//2+b//2
        ans+=1
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
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[i]%2 == 1:
    ans ='NO'
  return ans
                   
  
if __name__ == '__main__':
  print(solve())

def solve():
  a,b,c = (int(i) for i in input().split())
  queue = [[a,b,c]] 
  ct = 0
  while ct <100000000:
    if a%2 ==1 or b%2 ==1 or c%2 == 1: break
    
    tmpa = a//2
    tmpb = b//2
    tmpc = c//2
    a = tmpb+tmpc
    b = tmpa+tmpc
    c = tmpa+tmpb
    if [a,b,c] in queue: 
      return -1
    else:
      ct += 1
      queue.append([a,b,c])
      
  return ct
                   
  
if __name__ == '__main__':
  print(solve())

Verdicts: Runtime Error

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
a,b,c = map(int,input().split())

x = 0
y = 0
z = 0

while a%2 == 0:
  x += 1
while b%2 == 0:
  y += 1
while c%2 == 0:
  z += 1
  
if a == b == c:
  print(-1)
else:
  print(min(a,b,c))

x,y,z = map(int,input().split())

ans = 0

s = []

while True:
    if x%2 == 0 and y%2 == 0 and z%2 == 0:
        ans += 1
        if [x,y,z] in s:
            print(-1)
            break
        else:
            s.append([x,y,z])
    else:
        print(ans)
        break
    
    x,y,z = y//2+z//2,x//2+z//2,x//2+y//2

Verdicts: Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
a, b, c = map(int, input().split())

if a == b == c:
    print(-1)
    exit()

if a%2!=0 or b%2!=0 or c%2!=0:
  	print(0)
    exit()

N = (a+b+c)//3
cnt = 1
while N:
    if N%2 != 0: break
    N //= 2
    cnt += 1
    
print(cnt)

a, b, c = map(int, input().split())
 
if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
    print(0)    
    exit() 
    
if a == b == c:
    print(-1)
    exit()
    
cnt = 0
while (a % 2 == 0 and b % 2 == 0 and c % 2 == 0): 
    a, b, c = (b+c)//2, (a+c)//2, (a+b)//2
    cnt += 1
 
print(cnt)

Verdicts: Runtime Error

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
A, B, C = map(int, input().split())


def cnt(N):
    cnt = 0
    while N % 2 == 0:
        cnt += 1
        N //= 2

    return cnt


if A == B == C and A % 2 == 0:
    print(-1)
elif len(set([cnt(A), cnt(B), cnt(C)])) <= 2:
    print(min(cnt(A), cnt(B), cnt(C)))
else:
    print(min(cnt(A), cnt(B), cnt(C)) + 1)



A, B, C = map(int, input().split())


def check(A, B, C):
    if A & 1 or B & 1 or C & 1:
        return 0
    if A == B == C:
        return -1
    return 1 + check((A + B) // 2, (B + C) // 2, (C + A) // 2)


answer = check(A, B, C)
print(answer)


Verdicts: Wrong Answer

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
# coding: utf-8

a, b, c = map(int, input().rstrip().split())
count = 0

while True:
    elif a == b and b == c and c == a :
        count = -1 if a % 2 == 1 else 0
        break
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 :
        a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
        count += 1
    else:
        break
print(count)

# coding: utf-8

a, b, c = map(int, input().rstrip().split())
count = 0

while True:
    elif a == b and b == c and c == a :
        count = -1 if a % 2 == 1 else 0
        break
    if a % 2 == 0 and b % 2 == 0 and c % 2 == 0 :
        a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
        count += 1
    else:
        break
print(count)

# coding: utf-8

a, b, c = map(int, input().rstrip().split())
count = 0

while True:
    if a == b and b == c and c == a :
        count = -1 if a % 2 == 0 else 0
        break
    elif a % 2 == 0 and b % 2 == 0 and c % 2 == 0 :
        a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
        count += 1
    else:
        break
print(count)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
def resolve():
    A,B,C = map(int,input().split())
    count = 0
    if A == C and A == B:
        if A % 2 == 1:
            print(0)
        else:
            print(-1)
    else:
        while (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):
            tmpA = (B + C) / 2 
            tmpB = (A + C) / 2 
            tmpC = (A + B) / 2
            A = tmpA
            B = tmpB
            C = tmpC
            count = count + 1
        print(count)
resolve():

def resolve():
    A,B,C = map(int,input().split())
    count = 0
    if A == C and A == B:
        if A % 2 == 1:
            print(0)
        else:
            print(-1)
    else:
        while (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):
            tmpA = (B + C) / 2 
            tmpB = (A + C) / 2 
            tmpC = (A + B) / 2
            A = tmpA
            B = tmpB
            C = tmpC
            count = count + 1
        print(count)
resolve()

Verdicts: Runtime Error

Accepted
Problem: Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:    * Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.  This action will be repeated until there is a person with odd number of cookies in hand.  How many times will they repeat this action? Note that the answer may not be finite.

Submission attempts (in order):
a,b,c=map(int,input().split())

ans=0
if a==b==c:
  print(-1)
else:
  while a%2==0 and b%2==0 and c%2==0:
    num_a,num_b,num_c=a/2,b/2,c/2
    a=num_b+num_c
    b=num_a+num_c
    c=num_a+num_b
    print(a,b,c)
    ans+=1
  print(ans)

a,b,c=454,414,444

ans=0
if a==b==c:
  print("-1")
else:
  while a%2==0 and b%2==0 and c%2==0:
    num_a,num_b,num_c=a/2,b/2,c/2
    a=num_b+num_c
    b=num_a+num_c
    c=num_a+num_b
    ans+=1
  
print(ans)

a,b,c=map(int,input().split())

if a%2!=0 or b%2!=0 or c%2!=0:
  print(0)
  exit()
elif a==b==c:
  print(-1)
  exit()
    
ans=0  

while a%2==0 and b%2==0 and c%2==0:
  num_a,num_b,num_c=a/2,b/2,c/2
  a=num_b+num_c
  b=num_a+num_c
  c=num_a+num_b
  ans+=1
print(ans)


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



def main():
    vertex, query = map(int, input().split())
    cnt = [0 for _ in range(vertex)]
    for _ in range(query):
        a, b = map(lambda x: int(x) - 1, input().split())
        cnt[a] += 1
        cnt[b] += 1
    print("YES" if all(cnt[i] % 2 == 0 for i in range(vertex)) else "NO")


if __name__ == '__main__':
    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 = (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)

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)

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)

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)

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)

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

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)

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


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


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


n,m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
s = [0] * (10 ** 5+1)
for a,b in ab:
  s[a] += 1
  s[b] += 1
if any([i % 2 for i in s]):
  print("NO")
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())
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')


n, m = map(int, input().split())
d = {i: 0 for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2:
        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 _ 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')

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 len(g[i])%2==0:
    continue
  else:
    flag=False
    break
if flag==True:
  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):
c = [0]*10**5
for i in open(0).read().split()[::2]: c[int(i)] ^= 1
print("NO" if any(c) else "YES")

c = [0]*10**5
for i in open(0).read().split()[2:]: c[int(i)-1] ^= 1
print("NO" if any(c) else "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):
# 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")


# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, M = map(int, input().split())
node = [0]*(N)
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    node[a] ^= 1
    node[b] ^= 1

if any(node):
    print("NO")
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,*ab=open(0).read().split()
from collections import*
C=Counter(ab)
print('YNeos'[any(v%2 for v in C.values())::2])

N,M,*ab=open(0).read().split()
from collections import*
C=Counter(ab)
print('YNEOS'[any(v%2 for v in C.values())::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())

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

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

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


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


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


Verdicts: Runtime Error

Runtime Error

Accepted