TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: At an arcade, Takahashi is playing a game called _RPS Battle_ , which is played as follows:    * The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)   * Each time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):     * R points for winning with Rock;     * S points for winning with Scissors;     * P points for winning with Paper.   * However, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)  Before the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.  The information Takahashi obtained is given as a string T. If the i-th character of T (1 \leq i \leq N) is `r`, the machine will play Rock in the i-th round. Similarly, `p` and `s` stand for Paper and Scissors, respectively.  What is the maximum total score earned in the game by adequately choosing the hand to play in each round?

Submission attempts (in order):
p = [int(i) for i in m]
n = input()    
m = n.split()
P = [int(i) for i in m]
n = input()
list = [""]*p[1]
for i, value in enumerate(n):
    list[i%p[1]] =list[i%p[1]] + value
A = 0
for i in list:
    able = [True,True,True]
    for j in i:
        if j == "r":
            if able[2]:
                A = A + P[2]
                able = [True,True,False]
            else:
                able = [True,True,True]
        if j == "s":
            if able[0]:
                A = A + P[0]
                able = [False,True,True]
            else:
                able = [True,True,True]
        if j == "p":
            if able[1]:
                A = A + P[1]
                able = [True,False,True]
            else:
                able = [True,True,True]

print(A)

n = input()    
m = n.split()
p = [int(i) for i in m]
n = input()    
m = n.split()
P = [int(i) for i in m]
n = input()
list = [""]*p[1]
for i, value in enumerate(n):
    list[i%p[1]] =list[i%p[1]] + value
A = 0
for i in list:
    able = [True,True,True]
    for j in i:
        if j == "r":
            if able[2]:
                A = A + P[2]
                able = [True,True,False]
            else:
                able = [True,True,True]
        if j == "s":
            if able[0]:
                A = A + P[0]
                able = [False,True,True]
            else:
                able = [True,True,True]
        if j == "p":
            if able[1]:
                A = A + P[1]
                able = [True,False,True]
            else:
                able = [True,True,True]

print(A)

Verdicts: Runtime Error

Accepted
Problem: At an arcade, Takahashi is playing a game called _RPS Battle_ , which is played as follows:    * The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)   * Each time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):     * R points for winning with Rock;     * S points for winning with Scissors;     * P points for winning with Paper.   * However, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)  Before the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.  The information Takahashi obtained is given as a string T. If the i-th character of T (1 \leq i \leq N) is `r`, the machine will play Rock in the i-th round. Similarly, `p` and `s` stand for Paper and Scissors, respectively.  What is the maximum total score earned in the game by adequately choosing the hand to play in each round?

Submission attempts (in order):


str1 = input().split(" ")
str2 = input().split(" ")
t = list(input())

n = int(str1[0])
k = int(str1[1])

r = int(str2[0])
s = int(str2[1])
p = int(str2[2])

result = 0
hoge = 0
for i in range(0,n):
    if i < k:
        continue

    j = i-k
    if t[i] == t[j]:
        t[i] = "_"

print(t)
pres = p * t.count("r")
rres = r * t.count("s")
sres = s * t.count("p")

print(pres + rres + sres)



str1 = input().split(" ")
str2 = input().split(" ")
t = input()

n = int(str1[0])
k = int(str1[1])

r = int(str2[0])
s = int(str2[1])
p = int(str2[2])

result = 0
douchilist = []
for i in range(0,n):
    if i >= k:
        print(t[i])
        print(t[i-k])
        if t[i] == t[i-k] and i-k not in douchilist:
            result += 0
            douchilist.append(i)
            continue

    
    if t[i] == "r":
        result += p
        continue

    if t[i] == "s":
        result += r
        continue

    if t[i] == "p":
        result += s
        continue


print(result)



str1 = input().split(" ")
str2 = input().split(" ")
t = list(input())

n = int(str1[0])
k = int(str1[1])

r = int(str2[0])
s = int(str2[1])
p = int(str2[2])

result = 0
hoge = 0
for i in range(0,n):
    if i < k:
        continue

    j = i-k
    if t[i] == t[j]:
        t[i] = "_"

pres = p * t.count("r")
rres = r * t.count("s")
sres = s * t.count("p")

print(pres + rres + sres)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: At an arcade, Takahashi is playing a game called _RPS Battle_ , which is played as follows:    * The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)   * Each time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):     * R points for winning with Rock;     * S points for winning with Scissors;     * P points for winning with Paper.   * However, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)  Before the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.  The information Takahashi obtained is given as a string T. If the i-th character of T (1 \leq i \leq N) is `r`, the machine will play Rock in the i-th round. Similarly, `p` and `s` stand for Paper and Scissors, respectively.  What is the maximum total score earned in the game by adequately choosing the hand to play in each round?

Submission attempts (in order):
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

a = 0
b = 0
c = 0


for i in range(K,N):
  if T[i] == T[i - K]:
    if T[i] == "r":
      a += 1
    if T[i] == "s":
      b += 1
    if T[i] == "p":
      c += 1
      

if a > 0:
  a = (a + 1) // 2
if b > 0:
  b = (b + 1) // 2
if c > 0:
  c = (c + 1) // 2


r = T.count("r")
s = T.count("s")
p = T.count("p")

から出せない手の数を引き、出せる手の数とスコアをかける
r = r - a
s = s - b
p = p - c

print((s * R) + (p * S) + (r * P))

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

point = {"r": P, "s": R, "p": S}
total = 0




before = ["*" for _ in range(K)]

for i,now in enumerate(T):
  
  
  if before[i % K] != now:
    total += point[now]
    before[i % K] = now
  else:
    before[i % K] = "*"

print(total)

Verdicts: Wrong Answer

Accepted
Problem: At an arcade, Takahashi is playing a game called _RPS Battle_ , which is played as follows:    * The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)   * Each time the player wins a round, depending on which hand he/she uses, he/she earns the following score (no points for a draw or a loss):     * R points for winning with Rock;     * S points for winning with Scissors;     * P points for winning with Paper.   * However, in the i-th round, the player cannot use the hand he/she used in the (i-K)-th round. (In the first K rounds, the player can use any hand.)  Before the start of the game, the machine decides the hand it will play in each round. With supernatural power, Takahashi managed to read all of those hands.  The information Takahashi obtained is given as a string T. If the i-th character of T (1 \leq i \leq N) is `r`, the machine will play Rock in the i-th round. Similarly, `p` and `s` stand for Paper and Scissors, respectively.  What is the maximum total score earned in the game by adequately choosing the hand to play in each round?

Submission attempts (in order):
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
List = [[] for k in range(K)]
for n in range(N):
    List[n % K].append(T[n])

point = {'r': P, 's': R, 'p': S}
print(List)
score = 0
for k in range(K):
    L = List[k]
    count = 1
    length = len(L)
    for i in range(length):
        try:
            if L[i] == L[i+1]:
                count += 1
            else:
                score += point[L[i]]*((count+1)//2)
                count = 1
        except:
            score += point[L[i]]*((count+1)//2)
print(score)


N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
List = [[] for k in range(K)]
for n in range(N):
    List[n % K].append(T[n])

point = {'r': P, 's': R, 'p': S}

score = 0
for k in range(K):
    L = List[k]
    count = 1
    length = len(L)
    for i in range(length):
        try:
            if L[i] == L[i+1]:
                count += 1
            else:
                score += point[L[i]]*((count+1)//2)
                count = 1
        except:
            score += point[L[i]]*((count+1)//2)
print(score)


Verdicts: Wrong Answer

Accepted
Problem: Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N).  Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph) of T containing all the vertices painted black. (If no vertex is painted black, S is the empty graph.)  Let the _holeyness_ of S be the number of white vertices contained in S. Find the expected holeyness of S.  Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as described in Notes.

Submission attempts (in order):
#f
sys.setrecursionlimit(2 * 10 ** 5 + 10)


n = int(input())
E = [[] for _ in range(n)]
mod = 10**9 + 7

for i in range(n-1):
    a,b = [int(x) for x in input().split()]
    E[a-1].append((b-1, i)) 
    E[b-1].append((a-1, i)) 
    
X = [0] * n
    
def dfs(u,e):
    num = 1
    for v,c in E[u]:
        if c != e:
            num += dfs(v,c)
    X[e] = num 
    return num

dfs(0, -1)

I = [1]
for i in range(n):
    I.append(I[-1] * pow(2, mod-2, mod) % mod)

ans = 0
for i in range(n):
    x = X[i]
    ans += (1-I[x])*(1-I[n-x]) % mod
    
ans -= n * I[1]
ans += 1 - I[n]
ans %= mod
print(ans)



#f
#change the limit of how much depth of recursive func is available. 
import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)
 

n = int(input())
E = [[] for _ in range(n)]
mod = 10**9 + 7

for i in range(n-1):
    a,b = [int(x) for x in input().split()]
    E[a-1].append((b-1, i)) 
    E[b-1].append((a-1, i)) 
    
X = [0] * n
    
def dfs(u,e):
    num = 1
    for v,c in E[u]:
        if c != e:
            num += dfs(v,c)
    X[e] = num 
    return num

dfs(0, -1)

I = [1]
inv = pow(2, mod-2, mod)
for i in range(n):
    I.append(I[-1] * inv % mod)

ans = 0
for i in range(n):
    x = X[i]
    ans += (1-I[x])*(1-I[n-x]) % mod
    
ans -= n * I[1]
ans += 1 - I[n]
ans %= mod
print(ans)



Verdicts: Runtime Error

Accepted
Problem: Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N).  Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph) of T containing all the vertices painted black. (If no vertex is painted black, S is the empty graph.)  Let the _holeyness_ of S be the number of white vertices contained in S. Find the expected holeyness of S.  Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as described in Notes.

Submission attempts (in order):
import sys
readline = sys.stdin.readline

N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)

parent = [0] * (N + 1)
order = []
stack = [1]
while stack:
    x = stack.pop()
    order.append(x)  
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x  
        stack.append(y)

MOD = 10**9 + 7
half = pow(2, MOD - 2, MOD)
power_inv = [1] * (N + 1)
size = [1] * (N + 1)
for i, v in enumerate(order[::-1], 1):
    p = parent[v]
    x = size[v]  
    size[p] += x  
    power_inv[i] = power_inv[i - 1] * half % MOD  # [1, 1/2, 1/4, ...]

ans = (1 - power_inv[N]) + sum((1 - power_inv[i] - power_inv[N - i] + power_inv[N]) % MOD for i in size[2:])  
ans += (1 - power_inv[N]) - N * power_inv[1]  # +  - N/2 
ans %= MOD

print(ans)

import sys
readline = sys.stdin.readline

N = int(readline())
graph = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)

parent = [0] * (N + 1)
order = []
stack = [1]
while stack:
    x = stack.pop()
    order.append(x)  
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x  
        stack.append(y)

MOD = 10**9 + 7
half = pow(2, MOD - 2, MOD)
power_inv = [1] * (N + 1)
size = [1] * (N + 1)
for i, v in enumerate(order[::-1], 1):
    p = parent[v]
    x = size[v]  
    size[p] += x  
    power_inv[i] = power_inv[i - 1] * half % MOD  # [1, 1/2, 1/4, ...]

ans = sum((1 - power_inv[i] - power_inv[N - i] + power_inv[N]) % MOD for i in size[2:])  
ans += (1 - power_inv[N]) - N * power_inv[1]  
ans %= MOD

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N).  Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph) of T containing all the vertices painted black. (If no vertex is painted black, S is the empty graph.)  Let the _holeyness_ of S be the number of white vertices contained in S. Find the expected holeyness of S.  Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as described in Notes.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10 ** 7)
edges = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append((b - 1, i))
    edges[b - 1].append((a - 1, i))
l = [0 for i in range(n)]
def dfs(cur, x):
    res = 1
    for i in edges[cur]:
        if i[1] != x:
            res += dfs(i[0], i[1])
    l[x] = res
    return res
dfs(0, -1)
l2 = [1]
i2 = pow(2, mod - 2, mod)
for i in range(n):
    l2.append(l2[-1] * i2 % mod)
cnt = 0
for i in l:
    cnt += (1 - l2[i]) * (1 - l2[n - i])
print((-n * i2 - l2[-1] + cnt + 1) % mod)

import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7
n = int(input())
edges = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append((b - 1, i))
    edges[b - 1].append((a - 1, i))
l = [0 for i in range(n)]
def dfs(cur, x):
    res = 1
    for i in edges[cur]:
        if i[1] != x:
            res += dfs(i[0], i[1])
    l[x] = res
    return res
dfs(0, -1)
l2 = [1]
i2 = pow(2, mod - 2, mod)
for i in range(n):
    l2.append(l2[-1] * i2 % mod)
cnt = 0
for i in l:
    cnt += (1 - l2[i]) * (1 - l2[n - i])
print((-n * i2 - l2[-1] + cnt + 1) % mod)

Verdicts: Runtime Error

Accepted
Problem: Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N).  Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph) of T containing all the vertices painted black. (If no vertex is painted black, S is the empty graph.)  Let the _holeyness_ of S be the number of white vertices contained in S. Find the expected holeyness of S.  Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as described in Notes.

Submission attempts (in order):
import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

import sys
from collections import defaultdict
input = sys.stdin.readline

N = int(input())
G = [[] for _ in range(N+1)]
for v in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

v2i = [0 for _ in range(N+1)]
def itt(v, p):
    cn = 0
    ms = []
    for u in G[v]:
        if u == p:
            continue
        un = itt(u, v)
        ms.append(un)
        cn += un
    if p != None:
        ms.append(N-1-cn)
    v2i[v] = ms
    return cn+1
itt(1, None)
r = 0
for v in range(1, N+1):
    ff = v2i[v]
    for f in ff:
        r += 2- 1
xx = power(2,N-1)
print((div(N*xx-N-r, xx*2%mod))%mod)


import sys
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod
    
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def div(a, b):
    return mul(a, power(b, mod-2))

import sys
input = sys.stdin.readline


N = int(input())

d2 = [1]
inverse = [0, 1]
for _ in range(N):
    d2.append(2*d2[-1]%mod)
for i in range( 2,  10):
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )

G = [[] for _ in range(N+1)]
for v in range(N-1):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)

v2i = [0 for _ in range(N+1)]
def itt(v, p):
    cn = 0
    ms = []
    for u in G[v]:
        if u == p:
            continue
        un = itt(u, v)
        ms.append(un)
        cn += un
    if p != None:
        ms.append(N-1-cn)
    v2i[v] = ms
    return cn+1
itt(1, None)
r = 0
for v in range(1, N+1):
    ff = v2i[v]
    for f in ff:
        r += d2[f] - 1 % mod
r = N*d2[N-1]-N-r
for _ in range(N):
    r = r*500000004 % mod
print(r)


Verdicts: Wrong Answer

Accepted
Problem: Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N).  Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph) of T containing all the vertices painted black. (If no vertex is painted black, S is the empty graph.)  Let the _holeyness_ of S be the number of white vertices contained in S. Find the expected holeyness of S.  Since the answer is a rational number, we ask you to print it \bmod 10^9+7, as described in Notes.

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

N = int(input())
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    edge[x].append(y)
    edge[y].append(x)


memo = [[] for _ in range(N + 1)]


def dfs(s, p=-1):
    res = 1
    for t in edge[s]:
        if t == p:
            continue
        size = dfs(t, s)
        memo[s].append(size)
        res += size
    if N != res:
        memo[s].append(N - res)
    return res


dfs(1)
exit()


cnt = 0
for lis in memo[1:]:
    if len(lis) == 1:
        continue
    
    tmp = pow(2, N - 1, mod) - 1  
    for x in lis:
        black = pow(2, x, mod) - 1
        tmp = (tmp - black + mod) % mod
    cnt = (cnt + tmp) % mod

div = pow(2, N, mod)
ans = cnt * pow(div, mod - 2, mod) % mod
print(ans)

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

N = int(input())
edge = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    x, y = map(int, input().split())
    edge[x].append(y)
    edge[y].append(x)


memo = [[] for _ in range(N + 1)]


def dfs(s, p=-1):
    sub_tree = []
    res = 1
    for t in edge[s]:
        if t == p:
            continue
        size = dfs(t, s)
        sub_tree.append(size)
        res += size
    if N != res:
        sub_tree.append(N - res)
    memo[s].extend(sub_tree)
    return res


dfs(1)
pow2 = [1] * (N + 1)
for i in range(1, N + 1):
    pow2[i] = pow2[i - 1] * 2 % mod

cnt = 0
for lis in memo[1:]:
    if len(lis) == 1:
        continue
    
    tmp = pow2[N - 1] - 1  
    for x in lis:
        black = pow2[x] - 1
        tmp = (tmp - black + mod) % mod
    cnt = (cnt + tmp) % mod

div = pow2[N]
ans = cnt * pow(div, mod - 2, mod) % mod
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

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

if abs(A-B)%2==0:
	print(int(abs(A-B)//2))
else:
	min(N-B,A-1)+1+((B=A-1)//2)

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

if abs(A-B)%2==0:
	print(int(abs(A-B)//2))
else:
	print(min(N-B,A-1)+1+((B-A-1)//2))

Verdicts: Runtime Error

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

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

diff = B - A

if diff % 2 == 0:
    ans = diff / 2
else:
    
    d1 = A - 1  
    ans1 = d1 + (diff - 1) / 2 + 1

    
    d2 = N - B  
    ans2 = d2 + (diff - 1) / 2 + 1

    ans = min(ans1, ans2)
    # print(ans1, ans2)

print(ans)


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

diff = B - A

if diff % 2 == 0:
    ans = diff / 2
else:
    
    d1 = A - 1  
    ans1 = d1 + (diff + 1) // 2

    
    d2 = N - B  
    ans2 = d2 + (diff + 1) // 2

    ans = min(ans1, ans2)

print(ans)


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

diff = B - A

if diff % 2 == 0:
    ans = diff // 2
else:
    
    d1 = A - 1  
    ans1 = d1 + (diff + 1) // 2

    
    d2 = N - B  
    ans2 = d2 + (diff + 1) // 2

    ans = min(ans1, ans2)

print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
n,a,b=map(int,input().split())
y=(b-a-1)/2
if (a-1)<=(n-b):
  print(int(y+a))
else:
  print(int(y+1+n-b))

n,a,b=map(int,input().split())
y=(b-a-1)//2
if (b-a)%2==0:
  print(int((b-a)//2))
else:
  if (a-1)<(n-b):
    print(int(y+a))
  else:
    print(int(y+1+n-b))



Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
n,a,b = map(int,input().split())
diff = abs(a-b)

if diff%2==0:
  print(diff/2)
else :
  print(min(a - 1, n - b) + 1 + diff // 2)

n,a,b = map(int,input().split())
diff = abs(a-b)
 
if diff%2==0:
  print(diff//2)
else :
  print(min(a - 1, n - b) + 1 + diff // 2)

Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

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

if (a-b)%2==0:
  print((a-b)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)

n,a,b=[int(x) for x in input().split()]

if (a-b)%2==0:
  print((a+b)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)

n,a,b=[int(x) for x in input().split()]

if (a-b)%2==0:
  print((a+b)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)

n,a,b=[int(x) for x in input().split()]

if (a+b)%2==0:
  print((b-a)//2)
else:
  print(min(a-1,n-b)+1+(b-a-1)//2)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

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

if a+b % 2 == 0:
  print( math.abs(a-(a+b)/2) )
else:
  if max(a,b) <= n/2:
    print(max(a,b))
  elif min(a,b) > n/2:
    print(min(a,b))
  else:
    print(n-min(a,b),max(a,b)-1)

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

dev =  b - ((a + b) // 2)
adjust = min(a-1,n-b) + 1 + ( (b-a-1) // 2 )

if (a+b) % 2 == 0:
  print(dev)
else:
  print(adjust)

Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
n, m, v, p = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = p
c = [0]
cnt = 0
for i in range(n):
  
  cnt += a[i]
  c.append(cnt)
for i in range(p,n):
  h = a[i]+m
  free = v - (p-1) - (n-i)
  d = h * (i-p+1) - (c[i]-c[p-1]) 
  if d >= free*m:
    ans += 1
print(ans)

n, a, b = map(int, input().split())
if abs(a-b)%2==0:
  print(abs(a-b)//2)
else:
  m = min(a,b)
  M = max(a,b)
  if M - m == 1:
    if m-1 < n-M:
      print((M-1))
    else:
      print((n-m))
  else:
    if m-1 < n-M:
      print((m-1)+1+(M-m-1)//2)
    else:
      print((n-M)+1+(M-m-1)//2)

Verdicts: Runtime Error

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
n, a, b = (int(i) for i in input().split()) 
dif = abs(a-b)

if dif % 2 == 0:
    print(dif/2)
else:
    if 2*n - a -b >= a + b:
        print(int((a + b-1)/2))
    else:
        print(int((2*n - a -b - 1)/2))

n, a, b = (int(i) for i in input().split()) 
dif = b-a

if dif % 2 == 0:
    print(dif//2)
else:
    if a + b - 2 <= 2*n - a -b:
        print(((a + b - 1)//2))
    else:
        print(((2*n - a - b + 1)//2))

Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
N, A, B = [int(i) for i in input().split()]
ans = []
if (B-A)%2 == 0:
    print((B-A)/2)
else:
    print((B-A)//2+1+min([A-1,N-B]))

N, A, B = [int(i) for i in input().split()]
print(int((B-A)//2)) if (B-A)%2 == 0 else print(int((B-A)//2+1+min([A-1,N-B])))


Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
n, a, b = [int(i) for i in input().split()]
if b - a % 2 == 0:
    print((b - a) // 2)
else:
    print(min(b - 1, n - a))

n, a, b = [int(i) for i in input().split()]
if (b - a) % 2 == 0:
    print((b - a) // 2)
else:
    print(min(a - 1, n - b) + 1 + (b - a - 1) // 2)

Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
import sys
input = sys.stdin.readline


def main():
    N, A, B = map(int, input().split())
    if B - A % 2 == 0:
        print((B-A)//2)
    else:
        print(min(B-1, N-A))




if __name__ == '__main__':
    main()


import sys
input = sys.stdin.readline


def main():
    N, A, B = map(int, input().split())
    if (B - A) % 2 == 0:
        print((B-A)//2)
    else:
        a = (A-1) + (B-A-1)//2 + 1
        b = (N-B) + (B-A-1)//2 + 1
        print(min(a, b))




if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

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

if a % 2 == b % 2:
  print((b - a) / 2)
else:
  distA = a - 1
  distB = n - b
  if distA < distB:
    ans = distA + (b - distA - 1) // 2
    if b - distA % 2 == 1:
      print(ans)
    else:
      print(ans + 1)
  else:
    ans = distB + (n - (a + distB)) // 2
    if a + distB % 2 == n % 2:
      print(ans)
    else:
      print(ans + 1)
      


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

if a % 2 == b % 2:
  print((b - a) // 2)
else:
  distA = a - 1
  distB = n - b
  if distA < distB:
    ans = distA + (b - distA - 1) // 2
    if b - distA % 2 == 1:
      print(ans)
    else:
      print(ans + 1)
  else:
    ans = distB + (n - (a + distB)) // 2
    if a + distB % 2 == n % 2:
      print(ans)
    else:
      print(ans + 1)
      


Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

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

a, b = min(a,b), max(a,b)

if (b-a) % 2 == 0:
    print(b-a//2)
    exit(0)

d = min(a - 1, n - a)
print(d + 1 + (b-a-1)//2)


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

a, b = min(a,b), max(a,b)

if (b-a) % 2 == 0:
    print(b-a//2)
    exit(0)

d = min(a - 1, n - b)
print(d + 1 + (b-a-1)//2)


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

a, b = min(a,b), max(a,b)

if (b-a) % 2 == 0:
    print((b-a)//2)
    exit(0)

d = min(a - 1, n - b)
print(d + 1 + (b-a-1)//2)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

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

if C%2==0:
  print(C//2)
else:
  dist_a=A-1
  dist_b=N-B
  base=min(dist_a,dist_b)
  print(base+(B-A+1)//2)

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

if C%2==0:
  print(C/2/)
else:
  dist_a=A-1
  dist_b=N-B
  base=min(dist_a,dist_b)
  print(base+(B-A+1)//2)

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

if C%2==0:
  print(C//2)
else:
  dist_a=A-1
  dist_b=N-B
  base=min(dist_a,dist_b)
  print(base+(B-A+1)//2)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
N,a,b = map(int,input().split())
sub = b-a
if(sub%2==0):
    print(sub/2)
else:
    print(b-1)

N,a,b = map(int,input().split())
sub = b-a
if(sub%2==0):
    print(sub/2)
else:
    if(N-b < a-1):
        print(N-a)
    else:
        print(b-1)


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

if (B-A) % 2 == 0:
    ans = (B-A) / 2
else:
    if (A-1) < (N-B) or (A-1) == (N-B):
        count = A
        a = 1
        b = B - count
        count += (b-a)/2
    else:
        count = (N-B) + 1
        a = A + count
        b = N
        count += (b-a)/2
    ans = count

print(ans)
        

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

if (A-B) % 2 == 0:
    ans = (B-A) / 2
else:
    if (A-1) < (N-B) or (A-1) == (N-B):
        count = A
        a = 1
        b = B - count
        count += (b-a)/2
    else:
        count = (N-B) + 1
        a = A + count
        b = N
        count += (b-a)/2
    ans = count

print(ans)
        

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

if (A-B) % 2 == 0:
    ans = (B-A) / 2
else:
    if (A-1) < (N-B) or (A-1) == (N-B):
        count = A
        a = 1
        b = B - count
        count += (b-a)/2
    else:
        count = (N-B) + 1
        a = A + count
        b = N
        count += (b-a)/2
    ans = count

print(ans)
        

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

if (B-A) % 2 == 0:
    ans = (B-A) // 2
else:
    if (A-1) < (N-B):
        count = A
        a = 1
        b = B - count
        count += (b-a)//2
    else:
        count = (N-B) + 1
        a = A + count
        b = N
        count += (b-a)//2
    ans = count

print(ans)
        

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
# coding: utf-8
N,A,B=map(int,input().split())

if A-B%2==0:
    ans=abs(A-B)//2
else:
    if A>B:
        ans=min(N-B,A-1)
    else:
        ans=min(N-A,B-1)

print(ans)



# coding: utf-8
N,A,B=map(int,input().split())

if abs(A-B)%2==0:
    ans=(B-A)//2
else:
    m1=N-B
    m2=A-1
    
    ans=min(m1+(N-A-m1-1)//2+1,m2+(B-1-m2-1)//2+1)

print(ans)



Verdicts: Wrong Answer

Accepted
Problem: 2N players are running a competitive table tennis training on N tables numbered from 1 to N.  The training consists of _rounds_. In each round, the players form N pairs, one pair per table. In each pair, competitors play a match against each other. As a result, one of them wins and the other one loses.  The winner of the match on table X plays on table X-1 in the next round, except for the winner of the match on table 1 who stays at table 1.  Similarly, the loser of the match on table X plays on table X+1 in the next round, except for the loser of the match on table N who stays at table N.  Two friends are playing their first round matches on distinct tables A and B. Let's assume that the friends are strong enough to win or lose any match at will. What is the smallest number of rounds after which the friends can get to play a match against each other?

Submission attempts (in order):
import numpy as np

val = input().split(' ')
N = int(val[0])
A = int(val[1])
B = int(val[2].strip())

if B - A % 2 == 0:
    print((B-A)/2)
else:
    if A - 1 > N - B:
        diff = N - B
    else:
        diff = A - 1
    print(diff + 1 + (B - A) / 2)


import numpy as np

val = input().split(' ')
N = int(val[0])
A = int(val[1])
B = int(val[2].strip())

if B - A % 2 == 0:
    print((B-A)/2)
else:
    max = np.power(10, 18)
    if A - 1 > max - B:
        diff = max - B
    else:
        diff = A - 1
    print(diff + 1 + (B - A) / 2)


import numpy as np

val = input().split(' ')
N = int(val[0])
A = int(val[1])
B = int(val[2].strip())

if B - A % 2 == 0:
    print((B-A)/2)
else:
    max = np.power(10, 18)
    if A - 1 > max - B:
        diff = max - B
    else:
        diff = A - 1
    print(diff + 1 + int((B - A - 1) / 2))


import numpy as np

val = input().split(' ')
N = int(val[0])
A = int(val[1])
B = int(val[2].strip())

if B - A % 2 == 0:
    print((B-A)/2)
else:
    if A - 1 > N - B:
        diff = N - B
    else:
        diff = A - 1
    print(diff + 1 + int((B - A - 1) / 2))


val = input().split(' ')
N = int(val[0])
A = int(val[1])
B = int(val[2].strip())

if (B - A) % 2 == 0:
    print((B-A)//2)
else:
    diff = N - B if A - 1 > N - B else A - 1
    flip = diff + 1
    distance = (B - A - 1) // 2
    print(flip + distance)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted