TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N boxes arranged in a circle. The i-th box contains A_i stones.  Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.  Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

Submission attempts (in order):
def examA():
    N = I()
    A = LI()
    ans = "YES"
    cur = 0
    for a in A:
        if a%2==1:
            cur +=1
    if cur%2==1:
        ans = "NO"
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    ans = "YES"
    sumA = sum(A)
    oneA = (1+N)*N//2
    if sumA%oneA>0:
        ans = "NO"
    ope = sumA//oneA
    
    cur = 0
    for i in range(N):
        now = ope - (A[i]-A[i-1])
        if now%N>0:
#            print(now,i)
            ans = "NO"
            break
        cur += now//N
    if cur==ope:
        ans = "NO"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examB()


def examA():
    N = I()
    A = LI()
    ans = "YES"
    cur = 0
    for a in A:
        if a%2==1:
            cur +=1
    if cur%2==1:
        ans = "NO"
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    ans = "YES"
    sumA = sum(A)
    oneA = (1+N)*N//2
    if sumA%oneA!=0:
        ans = "NO"
    ope = sumA//oneA
    
    cur = 0
    for i in range(N):
        now = ope - (A[i]-A[i-1])
        if now%N!=0 or now<0:
#            print(now,i)
            ans = "NO"
            break
        cur += now//N
    if cur!=ope:
        ans = "NO"
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examB()


Verdicts: Wrong Answer

Accepted
Problem: There are N boxes arranged in a circle. The i-th box contains A_i stones.  Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.  Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

Submission attempts (in order):
n=int(input())
lis=list(map(int,input().split()))
num=(n*(n+1))//2
if sum(lis)%num!=0:
  print("No")
  exit()
li=[lis[i]-lis[i-1]-sum(lis)//num for i in range(n)]
ans=0
for k in range(n):
  if -li[k]%n!=0:
    print("No")
    exit()
  ans+=-li[k]//n
if ans == sum(lis)//num:print("Yes")
else:print("No")


n=int(input())
lis=list(map(int,input.split()))
num=(n*(n+1))//2
if sum(lis)%num!=0:
  print("No")
  exit()
li=[lis[i]-lis[i-1]-sum(lis)//num for i in range(n)]
ans=0
for k in range(n):
  if -li[k]%n!=0:
    print("No")
    exit()
  ans+=-li[k]//n
if ans == sum(lis)//num:print("Yes")
else:print("No")

n = int(input())
lis = list(map(int,input().split()))
if sum(lis) % n != 0:
  print("NO")
  exit()
num = sum(lis) // n
li = [lis[i] -lis[i-1] -num for i in range(n)]
ans = 0
for i in range(n):
  if li[i] % n != 0:
    print("NO")
    exit()
  ans += li[i] // n
if ans == num:
  print("YES")
else:
  print("NO")

n=int(input())
lis=list(map(int,input().split()))
num=(n*(n+1))//2
if sum(lis)%num!=0:
  print("NO")
  exit()
ans=0
for k in range(n):
  if -(lis[i]-lis[i-1]-sum(lis)//num)%n!=0:
    print("NO")
    exit()
  ans+=-(lis[i]-lis[i-1]-sum(lis)//num)//n
if ans == sum(lis)//num:print("YES")
else:print("NO")


n = int(input())
lis = list(map(int,input().split()))
if sum(lis) % sum([i for i in range(1,n+1)]) != 0:
    print("NO")
    exit()
key = sum(lis) // sum([i for i in range(1,n+1)])
li = [-lis[i]+lis[i-1]+key for i in range(n)]
for num in li:
    if num < 0 or num % n != 0:
        print("NO")
        exit()
print("YES")

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: There are N boxes arranged in a circle. The i-th box contains A_i stones.  Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.  Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

Submission attempts (in order):
import sys
N=int(input())
A=list(map(int,input().split()))
total=0
for i in range(N):
  total+=A[i]
if total*2/((N+1)*N)%1!=0:
  print("NO")
  sys.exit()
times=int(total*2/((N+1)*N))
if (times-A[0]+A[N-1])/N%1! or times-A[0]+A[N-1]<0=0:
  print("NO")
  sys.exit()
B=(times-A[0]+A[N-1])/N
for i in range(N-1):
  B+=(times-A[i+1]+A[i])/N
  if (times-A[i+1]+A[i])/N%1!=0 or times-A[i+1]+A[i]<0:
    print("NO")
    sys.exit()
if B==times:
  print("YES")
else:
  print("NO")

import sys
N=int(input())
A=list(map(int,input().split()))
total=0
for i in range(N):
  total+=A[i]
if total*2/((N+1)*N)%1!=0:
  print("NO")
  sys.exit()
times=int(total*2/((N+1)*N))
if (times-A[0]+A[N-1])/N%1!=0 or times-A[0]+A[N-1]<0:
  print("NO")
  sys.exit()
B=(times-A[0]+A[N-1])/N
for i in range(N-1):
  B+=(times-A[i+1]+A[i])/N
  if (times-A[i+1]+A[i])/N%1!=0 or times-A[i+1]+A[i]<0:
    print("NO")
    sys.exit()
if B==times:
  print("YES")
else:
  print("NO")

Verdicts: Runtime Error

Accepted
Problem: There are N boxes arranged in a circle. The i-th box contains A_i stones.  Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.  Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

Submission attempts (in order):
N=int(input())
A=[int(i) for i in input().split()]
ans=True

if sum(A)%(int((N*(N+1))/2))!=0:
        ans=False
k=sum(A)*2/(N*(N+1))


d=[A[i+1]-A[i]-k for i in range(N-1)]
d.append(A[0]-A[N-1]-k)
for i in range(N):
        if d[i]%N!=0:
                ans=False
if ans:
        print("Yes")
else:
        print("No")

N=int(input())
A=[int(i) for i in input().split()]
ans=True

if sum(A)*2%(N*(N+1))!=0:
        ans=False
k=sum(A)*2/(N*(N+1))


d=[A[i+1]-A[i]-k for i in range(N-1)]
d.append(A[0]-A[N-1]-k)
for i in range(N):
        if d[i]>0 or d[i]%N!=0:
                ans=False
if ans:
        print("YES")
else:
        print("NO")

Verdicts: Wrong Answer

Accepted
Problem: There are N boxes arranged in a circle. The i-th box contains A_i stones.  Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.  Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

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

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    A.append(A[0])
    diff = set()
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.add(a1 - a2)

    return 'Yes' if len(diff) <= 2 else 'NO'


print(main())


n=int(input())
a=list(map(int,input().split()))
q,m=divmod(sum(a),n*(n+1)//2)
print('YNEOS'[any([(y-x-q)%n or y-x>q or m for x,y in zip(a[:-1],a[1:])])::2])

Verdicts: Wrong Answer

Accepted
Problem: There are N boxes arranged in a circle. The i-th box contains A_i stones.  Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.  Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

Submission attempts (in order):
N = int(input())
src = map(int,input().split())
S = sum(src)
M = N*(N+1)//2

if S%M:
    print('NO')
    exit()

K = S//M
mem = [src[i] - K*i for i in range(N)]
mem.append(mem[0])
for a,b in zip(mem,mem[1:]):
    if (a-b)%N:
        print('NO')
        exit()
print('YES')

N = int(input())
A = list(map(int,input().split()))
suma = sum(A)
unit = N*(N+1)//2
if suma % unit:
    print('NO')
    exit()
ope = suma // unit

d = A[0]-A[-1]
for a,b in zip(A,A[1:]):
    if (b-a)%N != d%N:
        print('NO')
        exit()

AA = A + [A[0]]
k = 0
for a,b in zip(AA,AA[1:]):
    if b-a > ope:
        print('NO')
        exit()
    k += (ope - (b-a)) // N

print('YES' if k==ope else 'NO')

Verdicts: Runtime Error

Accepted
Problem: There are N boxes arranged in a circle. The i-th box contains A_i stones.  Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.  Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

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

K = sum(A) / sum(range(1, N+1))
for i in range(-1,N-1):
    D = A[i+1] - A[i] - K 

for d in D:
    if not (d <= 0 and d % N == 0):
        print("NO")
        break
else:
    print("YES")


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

K = sum(A) / sum(range(1, N+1))
D = []
for i in range(-1,N-1):
    D.append(A[i+1] - A[i] - K )

for d in D:
    if not (d <= 0 and d % N == 0):
        print("NO")
        break
else:
    print("YES")


Verdicts: Runtime Error

Accepted
Problem: There are N boxes arranged in a circle. The i-th box contains A_i stones.  Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.  Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
sa = sum(a)
stone = n*(n+1)//2
if sa % stone:
    print("No")
    exit()
a.append(a[0])
k = sa//stone
d = [a[i+1]-a[i] - k for i in range(n)]
for i in d:
    if i%n:
        print("No")
        exit()
print("Yes")

n = int(input())
a = list(map(int, input().split()))
sa = sum(a)
stone = n*(n+1)//2
if sa % stone:
    print("NO")
    exit()
a.append(a[0])
k = sa//stone
d = [a[i+1]-a[i] - k for i in range(n)]
for i in d:
    if i%n or i>0:
        print("NO")
        exit()
print("YES")


Verdicts: Wrong Answer

Accepted
Problem: There are N boxes arranged in a circle. The i-th box contains A_i stones.  Determine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:    * Select one box. Let the box be the i-th box. Then, for each j from 1 through N, remove exactly j stones from the (i+j)-th box. Here, the (N+k)-th box is identified with the k-th box.  Note that the operation cannot be performed if there is a box that does not contain enough number of stones to be removed.

Submission attempts (in order):
N = int(input())
A = [int(_) for _ in input().split()]

def solve(N, A):
    k = N * (N + 1) // 2
    s = sum(A)
    if s % k > 0:
        return False
    m = s // k
    # print(k, s, m)
    rs = []
    for i in range(N):
        p = A[i - 1]
        q = A[i]
        delta = q - p
        y = m - delta
        print(p, q, delta, y, N)
        if y % N > 0:
            return False
        rs.append(y // N)
    # print("*", rs)
    return True

if solve(N, A):
    print("YES")
else:
    print("NO")


N = int(input())
A = [int(_) for _ in input().split()]

def solve(N, A):
    k = N * (N + 1) // 2
    s = sum(A)
    if s % k > 0:
        return False
    m = s // k
    # print(k, s, m)
    rs = []
    for i in range(N):
        p = A[i - 1]
        q = A[i]
        delta = q - p
        y = m - delta
        
        if y % N > 0:
            return False
        x = y // N
        rs.append(x)
    # print("*", rs)
    R = 0
    for i in range(N):
        x = rs[i]
        l = (N - i) % N + 1
        R += l * x
    # print(1, R)
    if R != A[0]:
        return False
    for i in range(1, N):
        R += m - rs[i]
        R -= rs[i] * (N - 1)
        # print(i, R)
        if R != A[i]:
            return False
    return True

def solve(N, A):
    k = N * (N + 1) // 2
    s = sum(A)
    if s % k > 0:
        return False
    m = s // k
    for i in range(N):
        x = A[i - 1] - A[i] + m
        if x < 0 or (x % N) > 0:
            return False
    return True

if solve(N, A):
    print("YES")
else:
    print("NO")


Verdicts: Wrong Answer

Accepted
Problem: There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.  Currently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repeatedly performing the following operation:    * Select a pair of different leaves. Then, remove exactly one stone from every vertex on the path between those two vertices. Here, a _leaf_ is a vertex of the tree whose degree is 1, and the selected leaves themselves are also considered as vertices on the path connecting them.  Note that the operation cannot be performed if there is a vertex with no stone on the path.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
a = list(map(int, input().split()))
adj = [[] for _ in range(n)]
for _ in range(n-1):
	s, t = map(int, input().split())
	adj[s-1].append(t-1)
	adj[t-1].append(s-1)
par = [-1 for _ in range(n)]
aff = [0 for _ in range(n)]

def dfs(x, p):
	for v in adj[x]:
		if v == p:
			continue
		aff[x] += 1
		par[v] = x
		dfs(v, x)
	return
dfs(0, -1)
af_lis = [[] for _ in range(n)]
zero = [i for i in range(n) if aff[i] == 0]

def check(x):
	if af_lis[x] == []:
		af_lis[par[x]].append(a[x])
		aff[par[x]] -= 1
		if aff[par[x]] == 0:
			zero.append(par[x])
		return
	s, ma = sum(af_lis[x]), max(af_lis[x])
	if ma*2 > s:
		s_mi = ma
	else:
		s_mi = (s+1)//2
	if s_mi <= a[x] <= s:
		if par[x] == -1:
			if 2*a[x] != s:
				print("NO")
				sys.exit()
			else:
				return
		af_lis[par[x]].append(2*a[x] - s)
		aff[par[x]] -= 1
		if aff[par[x]] == 0:
			zero.append(par[x])
		return
	else:
		print("NO")
		sys.exit()
		return

while zero:
	check(zero.pop())

print("YES")

import sys
sys.setrecursionlimit(10**6)
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
a = list(map(int, input().split()))
adj = [[] for _ in range(n)]
for _ in range(n-1):
	s, t = map(int, input().split())
	adj[s-1].append(t-1)
	adj[t-1].append(s-1)
par = [-1 for _ in range(n)]
aff = [0 for _ in range(n)]

def dfs(x, p):
	for v in adj[x]:
		if v == p:
			continue
		aff[x] += 1
		par[v] = x
		dfs(v, x)
	return
dfs(0, -1)
af_lis = [[] for _ in range(n)]
zero = [i for i in range(n) if aff[i] == 0]

def check(x):
	if af_lis[x] == []:
		af_lis[par[x]].append(a[x])
		aff[par[x]] -= 1
		if aff[par[x]] == 0:
			zero.append(par[x])
		return
	s, ma = sum(af_lis[x]), max(af_lis[x])
	if ma*2 > s:
		s_mi = ma
	else:
		s_mi = (s+1)//2
	if s_mi <= a[x] <= s:
		if par[x] == -1:
			if len(af_lis[x]) > 1 and 2*a[x] != s:
				print("NO")
				sys.exit()
			elif len(af_lis[x]) == 1 and a[x] != s:
				print("NO")
				sys.exit()
			return
		af_lis[par[x]].append(2*a[x] - s)
		aff[par[x]] -= 1
		if aff[par[x]] == 0:
			zero.append(par[x])
		return
	else:
		print("NO")
		sys.exit()
		return

while zero:
	check(zero.pop())

print("YES")

Verdicts: Wrong Answer

Accepted
Problem: There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.  Currently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repeatedly performing the following operation:    * Select a pair of different leaves. Then, remove exactly one stone from every vertex on the path between those two vertices. Here, a _leaf_ is a vertex of the tree whose degree is 1, and the selected leaves themselves are also considered as vertices on the path connecting them.  Note that the operation cannot be performed if there is a vertex with no stone on the path.

Submission attempts (in order):
import sys
sys.setrecursionlimit(500000)
N = int(input())
A = [0] + list(map(int, input().split()))
E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

def dfs(v, p=0):
    a = A[v]
    b = []
    for u in E[v]:
        if u!=p:
            b.append(dfs(u, v))
    if len(b)==0:
        return a
    sum_b, max_b = sum(b), max(b)
    if a < 2*max_b-sum_b or a < 2*sum_b or a > sum_b:
        print("NO")
        exit()
    return 2 * a - sum_b

ans = dfs(1)
if (ans==0 and len(E[1])>1) or (ans==A[1] and len(E[1])==1):
    print("YES")
else:
    print("NO")


import sys
sys.setrecursionlimit(500000)
N = int(input())
A = [0] + list(map(int, input().split()))
E = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b)
    E[b].append(a)

def dfs(v, p=0):
    a = A[v]
    b = []
    for u in E[v]:
        if u!=p:
            b.append(dfs(u, v))
    if len(b)==0:
        return a
    sum_b, max_b = sum(b), max(b)
    if a < max_b or 2 * a < sum_b or a > sum_b:
        print("NO")
        exit()
    return 2 * a - sum_b

v = 1
ans = dfs(v)
if (ans==0 and len(E[v])>1) or (ans==A[v] and len(E[v])==1):
    print("YES")
else:
    print("NO")


Verdicts: Wrong Answer

Accepted
Problem: There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.  Currently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repeatedly performing the following operation:    * Select a pair of different leaves. Then, remove exactly one stone from every vertex on the path between those two vertices. Here, a _leaf_ is a vertex of the tree whose degree is 1, and the selected leaves themselves are also considered as vertices on the path connecting them.  Note that the operation cannot be performed if there is a vertex with no stone on the path.

Submission attempts (in order):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
A = list(map(int, input().split()))
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)
C = [a if len(T[i]) == 1 else a*2 for i, a in enumerate(A)]
D = tuple(c for c in C)
def dfs(v, par=-1):
  for nv in T[v]:
    if nv != par:
      if not dfs(nv, v):
        return False
  if C[v] < 0:
    return False
  if par == -1:
    return C[v] == 0
  if C[v] > D[par]//2:
    return False
  C[par] -= C[v]
  return True
if dfs(0):
  print("YES")
else:
  print("NO")

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
A = list(map(int, input().split()))
T = [[] for _ in range(n)]
for _ in range(n-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  T[a].append(b)
  T[b].append(a)
C = [a if len(T[i]) == 1 else a*2 for i, a in enumerate(A)]
def dfs(v, par=-1):
  for nv in T[v]:
    if nv != par:
      if not dfs(nv, v):
        return False
  if C[v] < 0:
    return False
  if par == -1:
    return C[v] == 0
  if C[v] > A[par] or C[v] > A[v]:
    return False
  C[par] -= C[v]
  return True
if dfs(0):
  print("YES")
else:
  print("NO")

Verdicts: Wrong Answer

Accepted
Problem: There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.  Currently, there are A_i stones placed on vertex i. Determine whether it is possible to remove all the stones from the vertices by repeatedly performing the following operation:    * Select a pair of different leaves. Then, remove exactly one stone from every vertex on the path between those two vertices. Here, a _leaf_ is a vertex of the tree whose degree is 1, and the selected leaves themselves are also considered as vertices on the path connecting them.  Note that the operation cannot be performed if there is a vertex with no stone on the path.

Submission attempts (in order):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def readln(ch):
    _res = list(map(int,str(input()).split(ch)))
    return _res

n = int(input())
a = readln(' ')
e = [set([]) for i in range(0,n+1)]
for i in range(1,n):
    s = readln(' ')
    e[s[0]].add(s[1])
    e[s[1]].add(s[0])
rt = 1
now = n
v = [0 for i in range(0,n+1)]
q = v[:]
q[now] = rt
v[rt] = 1
for i in range(1,n):
    s = q[n-i+1]
    for p in e[s]:
        if v[p] == 0:
            v[p] = 1
            now = now - 1
            q[now] = p

res = 'YES'
up = [0 for i in range(0,n+1)]
for i in range(1,n+1):
    k = q[i]
    if len(e[k]) == 1:
        sum = a[k-1]
    else:
        sum = a[k-1] * 2
    up[k] = sum
    for son in e[k]:
        up[k] = up[k] - up[son]
        if up[k] > a[k-1]: res = 'NO'
    if up[k] < 0:
        res = 'NO'
    if len(e[k]) > 1 and up[k] > a[k-1]:
        res = 'NO'

if up[rt] != 0 : res = 'NO'
print(res)


print('NO')

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

def readln(ch):
    _res = list(map(int,str(input()).split(ch)))
    return _res

n = int(input())
a = readln(' ')
e = [set([]) for i in range(0,n+1)]
for i in range(1,n):
    s = readln(' ')
    e[s[0]].add(s[1])
    e[s[1]].add(s[0])
rt = 1
now = n
v = [0 for i in range(0,n+1)]
q = v[:]
q[now] = rt
v[rt] = 1
for i in range(1,n):
    s = q[n-i+1]
    for p in e[s]:
        if v[p] == 0:
            v[p] = 1
            now = now - 1
            q[now] = p

res = 'YES'
up = [0 for i in range(0,n+1)]
for i in range(1,n+1):
    k = q[i]
    if len(e[k]) == 1:
        sum = a[k-1]
    else:
        sum = a[k-1] * 2
    up[k] = sum
    for son in e[k]:
        up[k] = up[k] - up[son]
        if up[son] > a[k-1] and len(e[k]) > 1: res = 'NO'
    if up[k] < 0:
        res = 'NO'
    if len(e[k]) > 1 and up[k] > a[k-1]:
        res = 'NO'

if up[rt] != 0 : res = 'NO'
print(res)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n




def solve():
    # n, m = [int(x) for x in input().split()]
    n = int(input())
    ans = n // 11
    n %= 11
    if n >= 6:
        n -= 6
        ans += 1
    if n >= 5:
        ans += 1
    print(ans)
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""


# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n




def solve():
    # n, m = [int(x) for x in input().split()]
    n = int(input())
    ans = (n // 11)*2
    n %= 11
    if n >= 6:
        n -= 6
        ans += 1
    if n >= 5:
        ans += 1
    print(ans)
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""


# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n




def solve():
    # n, m = [int(x) for x in input().split()]
    n = int(input())
    ans = (n // 11)*2
    n %= 11

    if n > 6:
        ans += 2
    elif n:
        ans += 1
    print(ans)
    
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

R s
S p
P r

"""


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
x=int(input())
ans=0
for i in range(100000000000):
  if (i+1)%2==1:
    x-=5
    ans+=1
    if x<=0:
      print(ans)
      break
  else:
    x-=6
    if x<=0:
      print(ans)
      break
    
    

x=int(input())

cnt=x%11

ans=2*(x//11)
if cnt>=1 and cnt<=6:
    ans+=1
elif cnt>=7 and cnt<=10:
    ans+=2

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
x = int(input())
ans = 2*(x//11)
if 1<=x//11<=6:
  ans += 1
elif 7<=x//11:
  ans += 2
print(ans)

x = int(input())
ans = 2*(x//11)
if 1<=x%11<=6: 
  ans += 1
elif 7<=x%11: 
  ans += 2
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
x = int(input())

ans = (x / 11) * 2
sub = x % 11
if sub <= 6:
    ans += 1
else:
    ans += 2

print(ans)

x = int(input())

ans = (x // 11) * 2
sub = x % 11
if sub >= 7:
    ans += 2
elif 0 < sub <= 6:
    ans += 1

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
x = int(input())
a = (x // 11) * 2
b = x % 11
if b == 0:
    print(a)
elif b <= 7:
    print(a + 1)
else:
    print(a + 2)
 

x = int(input())

a = (x // 11) * 2
b = x % 11
if b == 0:
    print(a)
elif b <= 6:
    print(a + 1)
else:
    print(a + 2)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


x = I()
if x <= 6:
    ans = 1
elif x <= 11:
    ans = 2
else:
    ans = (x // 11) * 2
    if x % 11 == 0:
        pass
    elif x % 11 <= 6:
        ans += 1
    elif x % 11 <= 10:
        ans += 2

    print(ans)


import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


x = I()
if x <= 6:
    ans = 1
elif x <= 11:
    ans = 2
else:
    ans = (x // 11) * 2
    if ans % 11 != 0:
        ans += 1

    print(ans)


#
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


x = I()
if x <= 6:
    ans = 1
elif x <= 11:
    ans = 2
else:
    ans = (x // 11) * 2
    if x % 11 == 0:
        pass
    elif x % 11 <= 6:
        ans += 1
    elif x % 11 <= 10:
        ans += 2
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
x = int(input())
count = 0
q, mod = divmod(x, 11)
count += q*2
if mod > 0:
	if(mod <= 6):
    	count += 1
	else:
    	count += 2
print(count)

x = int(input())
count = 0
q, mod = divmod(x, 11)
count += q*2
if mod > 0:
    if(mod <= 6):
        count += 1
    else:
        count += 2
print(count)

Verdicts: Runtime Error

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
X = int(input())

N=X/11
P=X%11

if(P>6):
    print(2*N+2)
else:
    print(2*N+1)

X = int(input())

N=((X-1)//11)*2
P=(X-1)%11

if(P>5):
    print(N+2)
else:
    print(N+1)

Verdicts: Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
Num = list(input().split())
C = Counter(Num)
v = len(C)
odd = len(list(filter(lambda x: x % 2 == 1, C.values())))
even = v - odd
print(odd+even//2*2)


x = int(input())

r = x % 11
if r == 0:
    ans = x//11*2
elif r > 6:
    ans = x//11*2+2
else:
    ans = x//11*2+1
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
N = int(input())

X = N // 11
M = N % 11
print(X, M)
if M == 0:
    print(X * 2)
elif M > 6:
    print(X * 2 + 2)
else:
    print(X * 2 + 1)


N = int(input())

X = N // 11
M = N % 11
if M == 0:
    print(X * 2)
elif M > 6:
    print(X * 2 + 2)
else:
    print(X * 2 + 1)


Verdicts: Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
x = input()
y = x % 11
if y > 0:
    cnt = 1
    if y > 6:
        cnt += 1
else:
    cnt = 0
    
print(x // 11 + cnt)


x = int(input())
y = x % 11
if y > 0:
    cnt = 1
    if y > 6:
        cnt += 1
else:
    cnt = 0
    
print((x // 11) * 2 + cnt)

Verdicts: Runtime Error

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
a = int(input())
print((a + 4.5) // 5.5)


a = int(input())
print(int((a + 4.5) // 5.5))


Verdicts: Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
import sys

cin = sys.stdin
cin = open("in.txt", "r")

x = int(cin.readline())
c = x//11
cnt = c*2
r = x%11
# print(r)
if r>0:
    cnt +=1
    if r>6:
        cnt +=1

print(cnt)


import sys

cin = sys.stdin

x = int(cin.readline())
c = x//11
cnt = c*2
r = x%11
# print(r)
if r>0:
    cnt +=1
    if r>6:
        cnt +=1

print(cnt)


Verdicts: Runtime Error

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
N=int(input())
if N%11==0:
  print(2*N//11)
elif N%11>6:
  print(N*2//11+2)
else:
  print(2*N//11+1)


N=int(input())
if N%11==0:
  print(N//11)
elif N%11>6:
  print(N*2//11+2)
else:
  print(2*N//11+1)


x = int(input())
if x % 11 > 6:
    print(2*x//11+2)
else:
    print(2*x//11+1)


x = int(input())
a = x//11
if x % 11 == 0:
    print(2*a)
elif x % 11 > 6:
    print(2*a+2)
else:
    print(2*a+1)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.  Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:    * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.  For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Submission attempts (in order):
x=int(input())
ans=0
chk=0
ans=ans+(x//11)*2
chk=x%11
if chk>6:
	ans=ans+2
if chk>0:
	ans=ans+1
print(ans)

x=int(input())
ans=0
chk=0
ans=ans+(x//11)*2
chk=x%11
if chk>6:
	ans=ans+2
elif chk>0:
	ans=ans+1
print(ans)

Verdicts: Wrong Answer

Accepted