TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
N, L, T=map(int, input().split())
XW=[list(map(int, input().split())) for _ in range(N)]
X_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]
X_.sort()
A0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L
P0_=X_.index(A0_)
if P0_>0:
    X_=X_[P0_:]+X_[:P0_]
    
if XW[0][1]==1:
    C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)
else:
    C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)
    
if X_[0]==X_[1] and XW[0][1]==1:
  C0_=round((C0_-1)%N)
'''
if C0_>0:
  X_=X_[N-C0_:]+X_[:N-C0_]
'''
print(*X_, sep='\n')

N, L, T=map(int, input().split())
XW=[list(map(int, input().split())) for _ in range(N)]
X_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]
X_.sort()
A0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L
P0_=X_.index(A0_)
if P0_>0:
    X_=X_[P0_:]+X_[:P0_]
    
if XW[0][1]==1:
    C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)
else:
    C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)
    
if N>1 and X_[0]==X_[1] and XW[0][1]==1:
  C0_=round((C0_-1)%N)

if C0_>0:
  X_=X_[N-C0_:]+X_[:N-C0_]

print(*X_, sep='\n')

Verdicts: Runtime Error

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
N, L, T = map(int, input().split())
X = [0 for i in range(N)]
W = [0 for i in range(N)]
E = [0 for i in range(N)]
count = 0
for i in range(N):
    X[i], W[i] = map(int, input().split())
    if W[i] == 1:
        end = X[i] + T
        end = end % L
    if W[i] == 2:
        end = X[i]-T
        end = end % L
        if end < 0:
            end += L
    E[i] = end
    shu = L / 2.0
    if i > 0 and W[i] == 2 and  W[0] == 1:
        sa = X[i] -X[0]
        if sa < 0:
            sa += L
        gikan = sa / 2.0
        count += (T - gikan ) // shu + 1

    if i > 0 and W[i] == 1 and  W[0] == 2:
        sa = X[0] -X[i]
        if sa < 0:
            sa += L
        gikan = sa / 2.0
        count -= (T - gikan ) // shu + 1

print(E)
count = count % N
if count < 0:
    count += N
count = int(count)
print(count)
basho = E[0]
E.sort()
ind = E.index(basho)
result = [0 for i in range(N)]
for i in range(N):
    newind = ind + i
    if newind >= N :
        newind -= N
    result[count] = E[newind]
    count += 1
    if count >= N:
        count -= N

for i in range(N):
    print(result[i])

N, L, T = map(int, input().split())
X = [0 for i in range(N)]
W = [0 for i in range(N)]
E = [0 for i in range(N)]
count = 0
for i in range(N):
    X[i], W[i] = map(int, input().split())
    if W[i] == 1:
        end = X[i] + T
        end = end % L
    if W[i] == 2:
        end = X[i]-T
        end = end % L
        if end < 0:
            end += L
    E[i] = end
    shu = L / 2.0
    if i > 0 and W[i] == 2 and  W[0] == 1:
        sa = X[i] -X[0]
        if sa < 0:
            sa += L
        gikan = sa / 2.0
        count += (T - gikan ) // shu + 1
        if (T - gikan) % shu == 0:
            count -= 1

    if i > 0 and W[i] == 1 and  W[0] == 2:
        sa = X[0] -X[i]
        if sa < 0:
            sa += L
        gikan = sa / 2.0
        count -= (T - gikan ) // shu + 1

#print(E)
count = count % N
if count < 0:
    count += N
count = int(count)
#print(count)
basho = E[0]
E.sort()
ind = E.index(basho)
result = [0 for i in range(N)]
for i in range(N):
    newind = ind + i
    if newind >= N :
        newind -= N
    result[count] = E[newind]
    count += 1
    if count >= N:
        count -= N

for i in range(N):
    print(result[i])


Verdicts: Wrong Answer

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
# C
import numpy as np
N, L, T = map(int, input().split())
X = list()
W = list()
positions = list()
for _ in range(N):
    x, w = map(int, input().split())
    X.append(x)
    W.append(w)
    if w == 1:
        positions.append((x + T) % L)
    else:
        positions.append((x - T) % L)

# find which is the position
cnt_conf = 0
for i in range(N):
    if W[i] != W[0]:
        cnt_conf += (2*T - (X[i] - X[0])) // L + 1
n0 = cnt_conf % N
if W[0] == 1:
    p0 = (X[0] + T) % L
else:
    p0 = (X[0] - T) % L

positions.sort()

# find index
if W[0] == 1:
    num = np.argmax(np.arange(N)[positions==p0])
else:
    num = np.argmin(np.arange(N)[positions==p0])
for i in range(N):
    print(positions[(num - n0 + i) % N])

# C
import numpy as np
N, L, T = map(int, input().split())
X = list()
W = list()
positions = list()
for _ in range(N):
    x, w = map(int, input().split())
    X.append(x)
    W.append(w)
    if w == 1:
        positions.append((x + T) % L)
    else:
        positions.append((x - T) % L)

# find which is the position
cnt_conf = 0
for i in range(N):
    if W[i] != W[0]:
        cnt_conf += (2*T - (X[i] - X[0])) // L + 1
n0 = cnt_conf % N
if W[0] == 1:
    p0 = (X[0] + T) % L
else:
    p0 = (X[0] - T) % L

positions.sort()

# find index
if W[0] == 1:
    num = np.argmax(np.arange(N)[positions==p0])
else:
    num = np.argmin(np.arange(N)[positions==p0])
for i in range(N):
    print(positions[(num - n0 + i) % N])

# C
N, L, T = map(int, input().split())
X = list()
W = list()
positions = list()
for _ in range(N):
    x, w = map(int, input().split())
    X.append(x)
    W.append(w)
    if w == 1:
        positions.append((x + T) % L)
    else:
        positions.append((x - T) % L)

# find which is the position
cnt_conf = 0
if W[0] == 1:
    for i in range(N):
        if W[i] != W[0]:
            cnt_conf += (2*T - (X[i] - X[0])) // L + 1
    n0 = cnt_conf % N
    p0 = (X[0] + T) % L
else:
    for i in range(N):
        if W[i] != W[0]:
            cnt_conf += (2*T - (X[0] + L - X[i])) // L + 1
    n0 = -cnt_conf % N
    p0 = (X[0] - T) % L

positions.sort()

# find index
if W[0] == 1:
    num = max([n for n in range(N) if positions[n]==p0])
else:
    num = min([n for n in range(N) if positions[n]==p0])

for i in range(N):
    print(positions[(num - n0 + i) % N])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
n, l, t = map(int, input().split())

arr = []
for i in range(n):
    x, w = map(int, input().split())

    if w == 1:
        arr.append((x+t) % l)
        s += (x+t) // l
    else: # W == 2:
        arr.append((x-t) % l)
        s += (x-t) // l

arr.sort()
s %= n
arr = arr[s:] + arr[:s]
print(*[i for i in arr], sep='\n')

n, l, t = map(int,input().split())

c = []
s = 0

for i in range(n):
    x, w = map(int,input().split())
    if w == 1:
        c.append((x+t)%l)
        s += (x+t)//l
    else: # w == 2:
        c.append((x-t)%l)
        s += (x-t)//l

c.sort()
s %= n
c = c[s:] + c[:s]
print(c)

print([i for i in c], sep='\n')

n, l, t = map(int,input().split())

c = []
s = 0

for i in range(n):
    x, w = map(int,input().split())
    if w == 1:
        c.append((x+t)%l)
        s += (x+t)//l
    else: # w == 2
        c.append((x-t)%l)
        s += (x-t)//l

c.sort()
s %= n
c = c[s:] + c[:s]
print(*[i for i in c], sep='\n')

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, L, T = map(int, readline().split())
    position = []
    
    
    count = 0
    for i in range(N):
        x,w = map(int, readline().split())
        if w==1:
            count += (x+T)//L
            position.append((x+T)%L)
        else:
            if x-T<0:
                count += (x-T+1)//L
            position.append((x-T)%L)
    position.sort()
    if count>=0:
        ans = position[count:] + position[:count]
    print(ans)


if __name__ == '__main__':
    main()

import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, L, T = map(int, readline().split())
    position = []
    
    
    count = 0
    for i in range(N):
        x,w = map(int, readline().split())
        if w==1:
            count += (x+T)//L
            position.append((x+T)%L)
        else:
            if x-T<0:
                count += (x-T+1)//L
            position.append((x-T)%L)
    position.sort()
    count %= N
    ans = position[count:] + position[:count]
    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main()

Verdicts: Runtime Error

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
from bisect import bisect_left
n, l, t = map(int, input().split())
ants = [list(map(int, input().split())) for _ in range(n)]
bnts = []
diff = []

for i in range(n):
	x, w = ants[i][0], 3 - 2*ants[i][1]
	bnts.append((x + t*w) % l)
	if i == 0:
		zero = bnts[-1]
	if ants[i][1] != ants[0][1]:
		if ants[0][1] == 1:
			diff.append(x - ants[0][0])
		else:
			diff.append(l - (x - ants[0][0]))

bnts.sort()
num = 0
quo, mod = t//l, t%l
num += quo * len(diff) * 2
diff.sort()
diff += [d+l for d in diff]
num += bisect_left(diff, mod*2)
num %= n
for i in range(n):
	if bnts[i] == zero:
		if ants[0][0] == 1:
			true_zero = (i-num) % n
		else:
			true_zero = (i+num) % n

ans = bnts[true_zero:] + bnts[:true_zero]
print(*ans, sep="\n")

from bisect import bisect_left, bisect
n, l, t = map(int, input().split())
ants = [list(map(int, input().split())) for _ in range(n)]
bnts = []
diff = []

for i in range(n):
	x, w = ants[i][0], 3 - 2*ants[i][1]
	bnts.append((x + t*w) % l)
	if i == 0:
		zero = bnts[-1]
	if ants[i][1] != ants[0][1]:
		if ants[0][1] == 1:
			diff.append(x - ants[0][0])
		else:
			diff.append(l - (x - ants[0][0]))

bnts.sort()
num = 0
quo, mod = t//l, t%l
num += quo * len(diff) * 2
diff.sort()
diff += [d+l for d in diff]

num += bisect(diff, mod*2)
num %= n
for i in range(n):
	if bnts[i] == zero:
		if ants[0][1] == 1:
			true_zero = (i-num) % n
		else:
			if i < n-1:
				if bnts[i+1] == zero:
					#pass
					num -= 1
			true_zero = (i+num) % n

ans = bnts[true_zero:] + bnts[:true_zero]
print(*ans, sep="\n")

Verdicts: Wrong Answer

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
# -*- coding: utf-8 -*-
def new_place(ant, l, t):
    x = ant[0]
    w = ant[1]
    a = t%l
    if w == 1:
        new = x + a
        if new >= l:
            new -= l
    else:
        new = x - a
        if new < 0:
            new += l
    return new

def num_cross(ant1, ant2, l, t):
    if ant1[1] == ant2[1]:
        return 0
    else:
        if ant1[1] == 1:
            if t <= (ant2[0] - ant1[0])/2:
                return 0
            else:
                return(t - (ant2[0] - ant1[0])/2)//l + 1
        else:
            if t - (ant1[0] + l -ant2[0])/2 <= 0:
                return 0
            else:
                return(t - (ant1[0] + l -ant2[0])/2)//l + 1
def main():
    N, L, T = map(int, input().split())
    ants = []
    for i in range(N):
        ants.append(list(map(int, input().split())))
    new = []
    output = []
    # answer  = []
    
    #     output.append(int(input()))
    for ant in ants:
        new.append(new_place(ant, L, T))
    print(new)
    sum = 0
    for i in range(1, N):
        # print(int(num_cross(ants[0], ants[i], L, T)))
        sum += int(num_cross(ants[0], ants[i], L, T))
    if ants[0][1] == 1:
        ant_num = (1+sum)%N
    else:
        ant_num = N*(1+(-1)*(1-sum)//N) - (-1)*(1-sum)
    print(ant_num)
    for i in range(ant_num, N):
        # answer.append(new[i])
        print(new[i])
    for i in range(ant_num):
        # answer.append(new[i])
        print(new[i])
    # if answer == output:
    #     print('OK')
    # else:
    #     print('No')
        
        
        
        
        
        #     print(ii)
        #     # print(new[ii])

    
if __name__ == '__main__':
    main()

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



N, L, T = map(int, readline().split())
XW = np.array(read().split(), np.int64)
X = XW[::2]
W = XW[1::2]

speed = np.where(W == 1, 1, -1)

Y = X + speed * T

n = (Y // L - X // L).sum()
n %= N

Y %= L
Y.sort()
Y = np.concatenate((Y[n:], Y[:n]))

print('\n'.join(map(str, Y.tolist())))


Verdicts: Wrong Answer

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
normal_ant = [i for i, direction in ants if direction==1]
counter_ant = [i for i, direction in ants if direction==2]
cnt = (t // l) * len(normal_ant) + sum([1 for i in normal_ant if i + t%l >= l])
counter_cnt = (t // l) * len(counter_ant) + sum([1 for i in counter_ant if i - t%l < 0])
final_pos = sorted([(i-t)%l for i in counter_ant] + [(i+t)%l for i in normal_ant])
print(*final_pos[(cnt-counter_cnt)%n:] + final_pos[:(cnt-counter_cnt)%n], sep='\n')

n, l, t = list(map(int, input().split()))
ants = []
for i in range(n):
    ants.append(list(map(int, input().split())))
normal_ant = [i for i, direction in ants if direction==1]
counter_ant = [i for i, direction in ants if direction==2]
cnt = (t // l) * len(normal_ant) + sum([1 for i in normal_ant if i + t%l >= l])
counter_cnt = (t // l) * len(counter_ant) + sum([1 for i in counter_ant if i - t%l < 0])
final_pos = sorted([(i-t)%l for i in counter_ant] + [(i+t)%l for i in normal_ant])
print(*final_pos[(cnt-counter_cnt)%n:] + final_pos[:(cnt-counter_cnt)%n], sep='\n')

Verdicts: Runtime Error

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
from math import floor
n,l,t=map(int,input().split())
li=[]
s=0
first=1
xmin=l
xminind=0
for _ in range(n):
  x,w=map(int,input().split())
  if first==1:
    xf=x
    wf=w
    first=0
  if w==1:
    x1=(x+t)%l
  else:
    x1=(x-t)%l
  if x1<xmin:
    xmin=x1
    xminind=_
  if wf!=w:
    tf=(x-xf)/2
    if t>tf:
      s+=1
      s+=floor((t-tf)/(l/2))
  li.append(x1)

li.sort()
for _ in range(n):
  print(li[(_+s+xminind)%n])

from math import floor
n,l,t=map(int,input().split())
li=[]
zero=0
for _ in range(n):
  x,w=map(int,input().split())
  
  if w==1:
    zero+=(x+t)//l
    x1=(x+t)%l
  else:
    zero+=(x-t)//l
    x1=(x-t)%l
  li.append(x1)
zero%=n
li.sort()
li=li[zero:]+li[:zero]
for _ in range(n):
  print(li[_])

Verdicts: Wrong Answer

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
N,L,T=map(int,input().split())
X=[0 for i in range(N)]
W=[0 for i in range(N)]
for i in range(N):
    X[i],W[i]=map(int,input().split())
    W[i]=-2*W[i]+3
Y0=((T*W[0])+X[0])%L
Y=sorted([((T*W[i])+X[i])%L for i in range(N)])
R=[0 for i in range(N)]
Z=0
for i in range(1,N):
    if W[i]==W[0]:
        R[i]=0
    else:
        if T*2<abs(X[i]-X[0]):
            R[i]=0
        else:
            R[i]=1+(T*2-abs(X[i]-X[0]))//L
    Z+=W[0]*R[i]
Z%=N
Q=[]
A=0
for i in range(Z,N):
    if Y[i]==Y0:
        A=i
        break
for i in range(A,N):
    Q.append(Y[i])
for i in range(A):
    Q.append(Y[i])
for i in range(N):
    print(Q[i])


N,L,T=map(int,input().split())
X=[0 for i in range(N)]
W=[0 for i in range(N)]
D=0
for i in range(N):
    X[i],W[i]=map(int,input().split())
    W[i]=-2*W[i]+3
    D+=(X[i]+T*W[i])//L
D%=N
Y=sorted([((T*W[i])+X[i])%L for i in range(N)])
for i in range(N):
    print(Y[(D+i)%N])

Verdicts: Wrong Answer

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
import math
temp=input().split()
N=int(temp[0])
L=int(temp[1])
T=int(temp[2])
XW=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in range(N):
	if XW[i][1]==1:
		XW[i][0]+=T
	else:
		XW[i][0]-=T
	count+=math.floor(XW[i][0]/L)

#print(count)
#print(len())
newX=[]
for i in range(N):
	newX.append(XW[i][0]%L)
newX.sort()
print(newX)
for i in range(N):
	print(newX[(i+count)%N]%L)

import math
temp=input().split()
N=int(temp[0])
L=int(temp[1])
T=int(temp[2])
XW=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in range(N):
	if XW[i][1]==1:
		XW[i][0]+=T
	else:
		XW[i][0]-=T
	count+=math.floor(XW[i][0]/L)
if XW[0][1]==1:
	for i in range(1,N):
		if XW[i][0]<XW[0][0]:
			count+=int((XW[0][0]-XW[i][0])/L)+1
else:
	for i in range(1,N):
		if XW[i][0]>XW[0][0]:
			count+=int((XW[i][0]-XW[0][0])/L)+1
print(count)
for i in range(N):
	print(XW[(i+count)%N][0]%L)

import math
temp=input().split()
N=int(temp[0])
L=int(temp[1])
T=int(temp[2])
XW=[[int(j) for j in input().split()] for i in range(N)]
count=0
for i in range(N):
	if XW[i][1]==1:
		XW[i][0]+=T
	else:
		XW[i][0]-=T
	count+=math.floor(XW[i][0]/L)
newX=[]
for i in range(N):
	newX.append(XW[i][0]%L)
newX.sort()
#print(newX)
for i in range(N):
	print(newX[(i+count)%N]%L)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

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

n, l, t = map(int, input().split())
XW = [list(map(int, input().split())) for _ in range(n)]
L = []
cnt = 0
for i, xw in enumerate(XW):
  x, w = xw
  if w == 1:
    L.append((x+t)%l)
    if l-x > t:
      continue
    cnt -= 1 + (t-(l-x))//l
  else:
    L.append((x-t)%l)
    if x > t:
      continue
    cnt += 1 + (t-x)//l
x_0, w_0 = XW[cnt%n]
f = L.index((x_0+t*(3-2*w_0))%l)
for i in range(f, f+n):
  print(L[i%n])

f=lambda:map(int,input().split())
n,l,t=f()
X=[0]*n
b=0
for i in range(n):x,w=f();x+=t*(3-2*w);b+=x//l;X[i]=x%l
X.sort()
for i in range(n):print(X[(i+b)%n])

Verdicts: Wrong Answer

Accepted
Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):
n,l,t =  map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
las = [0]*n
for i in range(n):
  las[i] = (x[i][0]+(t if x[i][1]==1 else -t))%l
han = []
for i in range(1,n):
  if x[i][1] != x[0][1]:
    if x[0][1] ==1:
      han.append(x[i][1]-x[0][0])
    else:
      han.append(l-x[i][0]+x[0][0])
su = 0
t*=2
su += len(han)*(t//l)
t%=l
for i in han:
  if t> i:
    su+=1
su%=(n)
ii = las[0]
las.sort()
basyo = las.index(ii)
for i in range(basyo,n):
  if las[basyo] == las[i]:
    basyo+=1
    break
las.extend(las)
ans = [0]*n
z = 0
for i in range(basyo,basyo+n):
  ans[(su+z)%n] = las[i]
  z += 1
for i in ans:
  print(i)

n,l,t =  map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
las = [0]*n
for i in range(n):
  las[i] = (x[i][0]+(t if x[i][1]==1 else -t))%l
han = []
for i in range(1,n):
  if x[i][1] != x[0][1]:
    if x[0][1] ==1:
      han.append(x[i][0]-x[0][0])
    else:
      han.append(l-x[i][0]+x[0][0])
su = 0
t*=2
su += (len(han))*(t//l)
t%=l
for i in han:
  if t> i:
    su+=1
if x[0][1] == 2:
  su=(-su)%n
else:
  su%=(n)
ii = las[0]
las.sort()
basyo = las.index(ii)
for i in range(basyo+1,n):
  if las[basyo] == las[i]:
    if x[0][1] == 2:
      basyo+=1
  break
las.extend(las)
ans = [0]*n
z = 0
for i in range(basyo,basyo+n):
  ans[(su+z)%n] = las[i]
  z += 1
for i in ans:
  print(i)

Verdicts: Wrong Answer

Accepted
Problem: On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.  For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.  That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.

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

xs = 0
for i in range(N):
    xs += i  * X[i]
    xs -= (N - i - 1) * X[i]
    xs %= MOD
ys = 0
for i in range(M):
    ys += i  * Y[i]
    ys -= (M - i - 1) * Y[i]
    ys %= MOD
print(xs * ys % MOD)


import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

xs = 0
for i in range(N):
    xs += i  * X[i]
    xs -= (N - i - 1) * X[i]
    xs %= MOD
ys = 0
for i in range(M):
    ys += i  * Y[i]
    ys -= (M - i - 1) * Y[i]
    ys %= MOD
print(xs * ys % MOD)




Verdicts: Runtime Error

Accepted
Problem: On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.  For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.  That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.

Submission attempts (in order):
INF=10**9+7
L=[int(i)-1 for i in input().split()]
x=[int(i)   for i in input().split()]
y=[int(i)   for i in input().split()]
x.sort()
y.sort()

X=[x[i+1]-x[i] for i in range(L[0])]
Y=[y[i+1]-y[i] for i in range(L[1])]

usingX=[0 for i in range(L[0])]
usingY=[0 for i in range(L[1])]

if L[0]%2==0:
	for i in range(L[0]):
		temp=min(i,L[0]-i-1)
		temp+=1
		usingX[i]+=int(temp*(temp+1)/2)
		#print(usingX)
		usingX[i]+=temp*int(L[0]/2-temp)
		#print(usingX)
		usingX[i]*=2
		#print()
else:
	for i in range(L[0]):
		temp=min(i,L[0]-i-1)
		temp+=1
		usingX[i]+=int(temp*(temp+1)/2)
		usingX[i]+=temp*int((L[0]-1)/2-temp)
		usingX[i]*=2
		
		usingX[i]+=temp
	#temp=int((L[0]-1)/2)
	#usingX[temp]-=(temp+1)*2


if L[1]%2==0:
	for i in range(L[1]):
		temp=min(i,L[1]-i-1)
		temp+=1
		usingY[i]+=int(temp*(temp+1)/2)
		
		usingY[i]+=temp*int(L[1]/2-temp)
		
		usingY[i]*=2
		#print()
else:
	for i in range(L[1]):
		temp=min(i,L[1]-i-1)
		temp+=1
		usingY[i]+=int(temp*(temp+1)/2)
		usingY[i]+=temp*int((L[1]-1)/2-temp)
		usingY[i]*=2
		
		usingY[i]+=temp
	#temp=int((L[1]-1)/2)
	#usingY[temp]-=(temp+1)*2	

print(usingX)
print(usingY)
for i in range(L[0]):
	X[i]*=usingX[i]
for j in range(L[1]):
	Y[j]*=usingY[j]
ans=sum(X)*sum(Y)
print(ans%INF)

INF=10**9+7
L=[int(i)-1 for i in input().split()]
x=[int(i)   for i in input().split()]
y=[int(i)   for i in input().split()]
x.sort()
y.sort()

X=[x[i+1]-x[i] for i in range(L[0])]
Y=[y[i+1]-y[i] for i in range(L[1])]

usingX=[0 for i in range(L[0])]
usingY=[0 for i in range(L[1])]

if L[0]%2==0:
	for i in range(L[0]):
		temp=min(i,L[0]-i-1)
		temp+=1
		usingX[i]+=int(temp*(temp+1)/2)
		#print(usingX)
		usingX[i]+=temp*int(L[0]/2-temp)
		#print(usingX)
		usingX[i]*=2
		#print()
else:
	for i in range(L[0]):
		temp=min(i,L[0]-i-1)
		temp+=1
		usingX[i]+=int(temp*(temp+1)/2)
		usingX[i]+=temp*int((L[0]-1)/2-temp)
		usingX[i]*=2
		
		usingX[i]+=temp
	#temp=int((L[0]-1)/2)
	#usingX[temp]-=(temp+1)*2


if L[1]%2==0:
	for i in range(L[1]):
		temp=min(i,L[1]-i-1)
		temp+=1
		usingY[i]+=int(temp*(temp+1)/2)
		
		usingY[i]+=temp*int(L[1]/2-temp)
		
		usingY[i]*=2
		#print()
else:
	for i in range(L[1]):
		temp=min(i,L[1]-i-1)
		temp+=1
		usingY[i]+=int(temp*(temp+1)/2)
		usingY[i]+=temp*int((L[1]-1)/2-temp)
		usingY[i]*=2
		
		usingY[i]+=temp
	#temp=int((L[1]-1)/2)
	#usingY[temp]-=(temp+1)*2	

#print(usingX)

for i in range(L[0]):
	X[i]*=usingX[i]
for j in range(L[1]):
	Y[j]*=usingY[j]
ans=sum(X)*sum(Y)
print(ans%INF)

Verdicts: Wrong Answer

Accepted
Problem: On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.  For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.  That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.

Submission attempts (in order):
mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xl=0
yl=0
for i in range(1,n):
  l=i-1
  r=i+1
  while l>=0:
    xl=(xl+x[i]-x[l])%mod
    l-=1
  while r<n:
    xl=(xl+x[r]-x[i])%mod
    r+=1
for i in range(1,m):
  l=i-1
  u=i+1
  while l>=0:
    yl=(yl+y[i]-y[l])%mod
    l-=1
  while u<m:
    yl=(yl+y[u]-y[i])%mod
    u+=1
print(xl*yl%mod)

mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
xl=0
xt=0
yl=0
yt=0
for i in range(n-1):
  if i==0:
    for j in range(1,n):
      xt+=x[j]-x[i]
    xl=xt
  else:
    xt-=(x[i]-x[i-1])*(n-i)
    xl=(xl+xt)%mod
for i in range(m-1):
  if i==0:
    for j in range(1,m):
      yt+=y[j]-y[i]
    yl=yt
  else:
    yt-=(y[i]-y[i-1])*(m-i)
    yl=(yl+yt)%mod
print(xl*yl%mod)

Verdicts: Wrong Answer

Accepted
Problem: On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.  For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.  That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.

Submission attempts (in order):
import itertools


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

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

    x_len = 0
    y_len = 0

    for i in range(n):
        x_len += (2 * i - n + 1) * x[i] % (10 ** 9 + 7)
        print(x_len)

    for j in range(m):
        y_len += (2 * j - m + 1) * y[j] % (10 ** 9 + 7)
        print(y_len)

    print(x_len * y_len % (10 ** 9 + 7))


if __name__ == '__main__':
    main()


import itertools


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

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

    x_len = 0
    y_len = 0

    for i in range(n):
        x_len += (2 * i - n + 1) * x[i] % (10 ** 9 + 7)
        # print(x_len)

    for j in range(m):
        y_len += (2 * j - m + 1) * y[j] % (10 ** 9 + 7)
        # print(y_len)

    print(x_len * y_len % (10 ** 9 + 7))


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.  For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.  That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.

Submission attempts (in order):
mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
ansx=0
cum=x[0]
for i in range(1,n):
    ansx+=(i*x[i]-cum+mod)%mod
    ansx%=mod
    cum+=x[i]
ansy=0
cum=y[0]
for i in range(1,m):
    ansy+=(i*y[i]-cum+mod)%mod
    ansy%=mod
    cum+=y[i]
print(ansx,ansy)
print((ansx*ansy)%mod)


mod=10**9+7
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
ansx=0
cum=x[0]
for i in range(1,n):
    ansx+=(i*x[i]-cum+mod)%mod
    ansx%=mod
    cum+=x[i]
ansy=0
cum=y[0]
for i in range(1,m):
    ansy+=(i*y[i]-cum+mod)%mod
    ansy%=mod
    cum+=y[i]
#print(ansx,ansy)
print((ansx*ansy)%mod)


Verdicts: Wrong Answer

Accepted
Problem: How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?    * The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.   * For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.  Find the count modulo 10^9+7.

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

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+10)
dp_cum = [0] * (N+10)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[-1] + 1
answer %= MOD
print(answer)

import sys
input = sys.stdin.readline

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+10)
dp_cum = [0] * (N+10)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[N] + 1
answer %= MOD
print(answer)

Verdicts: Wrong Answer

Accepted
Problem: How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?    * The n-th and subsequent elements are all equal. That is, if n \leq i,j, a_i = a_j.   * For every integer i, the a_i elements immediately following the i-th element are all equal. That is, if i < j < k\leq i+a_i, a_j = a_k.  Find the count modulo 10^9+7.

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

res_v = np.zeros(n + 1, dtype='int64')
res_v_cumsum = np.zeros(n + 1, dtype='int64')
res_v[0] = 0
res_v[1] = 1
res_v[2] = 1
res_v_cumsum[0] = 0
res_v_cumsum[1] = 1
res_v_cumsum[2] = 2

M = 1000000007

for k in range(3, n):
    res_v[k] = (1 + res_v_cumsum[k-1] - res_v[k-2]) % M
    res_v_cumsum[k] = (res_v_cumsum[k-1] + res_v[k]) % M

print((((res_v_cumsum[n-2] * (((n-1) * (n-1)) % M)) % M) + ((res_v_cumsum[n-1] * (n-1)) % M) + n + (n-1)*(n-1)%M) % M)

n = int(input())

if n == 1:
    print(1)
else:
    res_v = [0]*(n + 1)
    res_v_cumsum = [0]*(n + 1)
    res_v[0] = 0
    res_v[1] = 1
    res_v[2] = 1
    res_v_cumsum[0] = 0
    res_v_cumsum[1] = 1
    res_v_cumsum[2] = 2

    M = 1000000007

    for k in range(3, n):
        res_v[k] = (1 + res_v_cumsum[k-1] - res_v[k-2]) % M
        res_v_cumsum[k] = (res_v_cumsum[k-1] + res_v[k]) % M
    #print(res_v)
    print((((res_v_cumsum[n-2] * (((n-1) * (n-1)) % M)) % M) + ((res_v_cumsum[n-1] * (n-1)) % M) + n + (n-1)*(n-1)%M) % M)

Verdicts: Runtime Error

Accepted
Problem: There are 3N participants in _AtCoder Group Contest_. The _strength_ of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.  Find the maximum possible sum of the strengths of N teams.

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

N = int(input())
a = input().split()

total = 0
a2 = sorted(a, reverse=True)
i = N + 1
j = 2 * N

for id in range(i, j+1):
	total += int(a2[id])

print(total)

# -*- coding: utf-8 -*-

N = int(input())
a = input().split()

total = 0
a2 = sorted(a)
i = N + 1
j = 2 * N

for id in range(i, j+1):
	print(id)
	total += int(a2[id])

print(total)

# -*- coding: utf-8 -*-
 
N = int(input())
a = list(map(int, input().split()))
 
total = 0
a2 = sorted(a, reverse=True)
 
for id in range(N):
	total += a2[2*id+1]
 
print(total)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are 3N participants in _AtCoder Group Contest_. The _strength_ of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.  Find the maximum possible sum of the strengths of N teams.

Submission attempts (in order):
N=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[2::2]))


N=int(input())
a=sorted(list(map(int,input().split())))
print(sum(a[N::2]))


Verdicts: Wrong Answer

Accepted
Problem: There are 3N participants in _AtCoder Group Contest_. The _strength_ of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.  Find the maximum possible sum of the strengths of N teams.

Submission attempts (in order):
n,*aa=map(int, open(0).read().split())

aa.sort(reverse=True)

sum(aa[1::2][:n])

n,*aa=map(int, open(0).read().split())

aa.sort(reverse=True)

print(sum(aa[1::2][:n]))

Verdicts: Wrong Answer

Accepted
Problem: There are 3N participants in _AtCoder Group Contest_. The _strength_ of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.  Find the maximum possible sum of the strengths of N teams.

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


print(sum(a[1:2*n:2]))

N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)

print(sum(a[1:2*n:2]))

n=int(input())
a=sorted(list(map(int, input().split())), reverse=True)
print(sum(a[1:2*n:2]))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are 3N participants in _AtCoder Group Contest_. The _strength_ of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.  Find the maximum possible sum of the strengths of N teams.

Submission attempts (in order):
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in range(n):
  ans += a[i*2+1]
print(ans)

n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
ans = 0
for i in range(n):
  ans += a[i*2+1]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are 3N participants in _AtCoder Group Contest_. The _strength_ of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.  Find the maximum possible sum of the strengths of N teams.

Submission attempts (in order):

def main():
    # sort -> first 1/3 as smallest ones
    # the sum of 2nd ones: 1111 23 23 23 23
    N, *A = map(int, open(0).read().split())
    A.sort()
    ans = sum(A[N::2])
    print()


if __name__ == "__main__":
    main()


def main():
    # sort -> first 1/3 as smallest ones
    # the sum of 2nd ones: 1111 23 23 23 23
    N, *A = map(int, open(0).read().split())
    A.sort()
    ans = sum(A[N::2])
    print(ans)


if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: There are 3N participants in _AtCoder Group Contest_. The _strength_ of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.  Find the maximum possible sum of the strengths of N teams.

Submission attempts (in order):
N=int(input())
a = sorted(list(map(int,input().split())))
ans=0
for i in range(2*N):
  tmp=a.pop(0)
  if i%2==1:
    ans+=tmp
print(ans)

N=int(input())
a = sorted(list(map(int,input().split())),reverse=True)
ans=0
for i in range(N):
  ans+=a[2*i+1]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are 3N participants in _AtCoder Group Contest_. The _strength_ of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.  Find the maximum possible sum of the strengths of N teams.

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

print(sum(N//3:2N//3))

N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

print(sum( a[N//3:2*N//3] ))

N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

#print(a)
print(sum( a[1:2*N:2] ))



Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There are 3N participants in _AtCoder Group Contest_. The _strength_ of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.  The strength of a team is defined as the second largest strength among its members. For example, a team of participants of strength 1, 5, 2 has a strength 2, and a team of three participants of strength 3, 2, 3 has a strength 3.  Find the maximum possible sum of the strengths of N teams.

Submission attempts (in order):
#bin/usr/env python3

N = int(input())
a = input()
x = 0

a = a.split()
a.sort

for i in range(N):
	x += int(a[-(2*i+2)])
	
print(x)

n = int(input())
a_s = input().split()
a_s = [int(a) for a in a_s]

a_s.sort(reverse=True)

total = 0
for i in range(n):
    total += a_s[i*2 + 1]

print(total)

Verdicts: Wrong Answer

Accepted