Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
u_light = [[0]*w for _ in range(h)] #上をてらせる数
d_light = [[0]*w for _ in range(h)] #下
l_light = [[0]*w for _ in range(h)] #左
r_light = [[0]*w for _ in range(h)] #右

def count_light(i, j):
    if s[i][j] == '.':
        return 1
    else:
        return -10000

for i in range(w):
    d_light[-1][i] = count_light(-1, i)
    u_light[0][i] = count_light(0, i)
for j in range(1, h):
    for i in range(w):
        d_light[-(j+1)][i] = max(d_light[-j][i], 0) + count_light(-(j+1), i)
        u_light[j][i] = max(u_light[j-1][i], 0) + count_light(j, i)

for i in range(h):
    l_light[i][0] = count_light(i, 0)
    r_light[i][-1] = count_light(i, -1)
for j in range(1, w):
    for i in range(h):
        l_light[i][j] = max(l_light[i][j-1], 0) + count_light(i, j)
        r_light[i][-(j+1)] = max(r_light[i][-j], 0) + count_light(i, -(j+1))

score = 0
tmp_score = 0
for i in range(h):
    for j in range(w):
        tmp_score = u_light[i][j] + d_light[i][j] + l_light[i][j] + r_light[i][j]
        if tmp_score > score:
            score = tmp_score
print(score-3) # 3回ダブっているので除去


Fixed submission:
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
u_light = [[0]*w for _ in range(h)] #上をてらせる数
d_light = [[0]*w for _ in range(h)] #下
l_light = [[0]*w for _ in range(h)] #左
r_light = [[0]*w for _ in range(h)] #右

def count_light(i, j):
    if s[i][j] == '.':
        return 1
    else:
        return -10000

for i in range(w):
    d_light[-1][i] = count_light(-1, i)
    u_light[0][i] = count_light(0, i)
for j in range(1, h):
    for i in range(w):
        d_light[-(j+1)][i] = max(d_light[-j][i], 0) + count_light(-(j+1), i)
        u_light[j][i] = max(u_light[j-1][i], 0) + count_light(j, i)

for i in range(h):
    l_light[i][0] = count_light(i, 0)
    r_light[i][-1] = count_light(i, -1)
for j in range(1, w):
    for i in range(h):
        l_light[i][j] = max(l_light[i][j-1], 0) + count_light(i, j)
        r_light[i][-(j+1)] = max(r_light[i][-j], 0) + count_light(i, -(j+1))

score = 0
tmp_score = 0
for i in range(h):
    for j in range(w):
        tmp_score = u_light[i][j] + d_light[i][j] + l_light[i][j] + r_light[i][j]
        if tmp_score > score:
            score = tmp_score
print(score-3) # 3回ダブっているので除去
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop

n, m = map(int, input().split())
a = list(map(int, input().split()))
card = [list(map(int, input().split())) for _ in range(m)]
card = sorted(card, key=lambda x:-x[1])

hq = []
for i in range(n):
    heappush(hq, a[i])

ans = sum(a)
for i in range(m):
    for j in range(card[i][0]):
        num = heappop(hq)
        if num >= card[i][1]:
            heappush(hq, num)
            break
        else:
            ans += card[i][1]-num
print(ans)


Fixed submission:
from heapq import heappush, heappop

n, m = map(int, input().split())
a = list(map(int, input().split()))
card = [list(map(int, input().split())) for _ in range(m)]
card = sorted(card, key=lambda x:-x[1])

hq = []
for i in range(n):
    heappush(hq, a[i])

ans = sum(a)
for i in range(m):
    for j in range(card[i][0]):
        if hq == []:
            break
        num = heappop(hq)
        if num >= card[i][1]:
            heappush(hq, num)
            break
        else:
            ans += card[i][1]-num
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for i in range(m):
    # print(a)
    b, c = map(int, input().split())
    d = min(b, len(list(filter(lambda x: x<c, a))))
    a[0:d] = [c]*d
    a.sort()
print(sum(a))


Fixed submission:
from heapq import heappush, heappop

n, m = map(int, input().split())
a = list(map(int, input().split()))
card = [list(map(int, input().split())) for _ in range(m)]
card = sorted(card, key=lambda x:-x[1])

hq = []
for i in range(n):
    heappush(hq, a[i])

ans = sum(a)
for i in range(m):
    for j in range(card[i][0]):
        if hq == []:
            break
        num = heappop(hq)
        if num >= card[i][1]:
            heappush(hq, num)
            break
        else:
            ans += card[i][1]-num
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())
ans = 0
for i in range(n):
    a = max(math.ceil(math.log2(k/(i+1))), 0)
    ans += 1/(n*2**a)
print(ans)


Fixed submission:
import math
n, k = map(int, input().split())
ans = 0
for i in range(n):
    a = max(math.ceil(math.log2(k/(i+1))), 0)
    ans += 0.5**a
print(ans/n)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
n = int(input())
edge = [[] for _ in range(n)]

for i in range(n-1):
    s, g, d = map(int, input().split())
    edge[s-1].append((g, d%2))
    edge[g-1].append((s, d%2))

ans = [None for _ in range(n)]

def set_color(x, col):
    ans[x-1] = col
    print(ans, edge[x-1])
    for g, d in edge[x-1]:
        if ans[g-1] == None:
            set_color(g, d^col)

set_color(1, 0)
for i in range(n):
    print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n=int(input())
edge=[[]for i in range(n+1)]

for i in range(n-1):
    u,v,w=map(int,input().split())
    if w%2==0:
        edge[u].append((v,1))
        edge[v].append((u,1))
    else:
        edge[u].append((v,-1))
        edge[v].append((u,-1))
        
color=[None]*(n+1)

def set_color(x,col):
    color[x]=col
    
    for i,j in edge[x]:
        if color[i] is None:
            set_color(i,j*col)

set_color(1,1)
for i in color[1:]:
    print((i+1)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())
edge = [[] for _ in range(n)]

for i in range(n-1):
    s, g, d = map(int, input().split())
    edge[s-1].append((g, d%2))
    edge[g-1].append((s, d%2))

ans = [None for _ in range(n)]

def set_color(x, col):
    ans[x-1] = col
    print(ans, edge[x-1])
    for g, d in edge[x-1]:
        if ans[g-1] == None:
            set_color(g, d^col)

set_color(1, 0)
for i in range(n):
    print(ans[i])


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n=int(input())
edge=[[]for i in range(n+1)]

for i in range(n-1):
    u,v,w=map(int,input().split())
    if w%2==0:
        edge[u].append((v,1))
        edge[v].append((u,1))
    else:
        edge[u].append((v,-1))
        edge[v].append((u,-1))
        
color=[None]*(n+1)

def set_color(x,col):
    color[x]=col
    
    for i,j in edge[x]:
        if color[i] is None:
            set_color(i,j*col)

set_color(1,1)
for i in color[1:]:
    print((i+1)//2)

Buggy python submission (verdict: Runtime Error):
import networkx as nx
graph = nx.Graph() #無向グラフを作成
directed_graph = nx.DiGraph() #有向グラフを作成

n = int(input())
for i in range(n-1):
    tree = list(map(int, input().split()))
    graph.add_edge(tree[0], tree[1])
    graph.edges[tree[0], tree[1]]['range'] = tree[2]
for i in range(n):
    graph.nodes[i+1]['color'] = 0

print(0)
for i in range(1,n):
    path = nx.shortest_path(graph, source=1, target=i+1)
    graph.nodes[i+1]['color'] = sum([graph.edges[path[i], path[i+1]]['range'] for i in range(len(path)-1)])%2
    print(graph.nodes[i+1]['color'])


Fixed submission:
import sys
sys.setrecursionlimit(10**6)

n=int(input())
edge=[[]for i in range(n+1)]

for i in range(n-1):
    u,v,w=map(int,input().split())
    if w%2==0:
        edge[u].append((v,1))
        edge[v].append((u,1))
    else:
        edge[u].append((v,-1))
        edge[v].append((u,-1))
        
color=[None]*(n+1)

def set_color(x,col):
    color[x]=col
    
    for i,j in edge[x]:
        if color[i] is None:
            set_color(i,j*col)

set_color(1,1)
for i in color[1:]:
    print((i+1)//2)
Buggy python submission (verdict: Runtime Error):
import math

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

l = [a[0] for _ in range(n+2)]
r = [a[-1] for _ in range(n+2)]

for i in range(n):
    l[i+1] = math.gcd(l[i], a[i])
    r[-(i+2)] = math.gcd(r[-(i+1)], a[-(i+1)])
l[0] = r[0] = l[-1] = r[-1] = 0

ans = [math.gcd(l[i], r[i+2]) for i in range(n)]
print(max(ans))


Fixed submission:
import fractions as math

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

l = [a[0] for _ in range(n+2)]
r = [a[-1] for _ in range(n+2)]

for i in range(n):
    l[i+1] = math.gcd(l[i], a[i])
    r[-(i+2)] = math.gcd(r[-(i+1)], a[-(i+1)])
l[0] = r[0] = l[-1] = r[-1] = 0

ans = [math.gcd(l[i], r[i+2]) for i in range(n)]
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
for i in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count('AC'))


Fixed submission:
n, q = map(int, input().split())
s = input()
ans = [0 for _ in range(n)]
count = 0
for i in range(1, n):
    a = s[i-1]
    b = s[i]
    if a == 'A' and b == 'C':
        count += 1
    ans[i] = count

for i in range(q):
    l, r = map(int, input().split())
    print(ans[r-1]-ans[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
import queue
n, m = map(int, input().split())
bridges = [map(int, input().split()) for _ in range(m)]

nodes = [[] for _ in range(n)] # いける島のリスト
ans = n*(n-1)//2
ans_list = []
q = queue.Queue()
for i in range(m):
    ans_list.append(ans)
    # 順番に橋をかけていく
    a, b = bridges[-(i+1)]
    if not a in nodes[b-1]:
        nodes[b-1].append(a)
        nodes[a-1].append(b)
        ans -= 1
    q.put((a,b))
    q.put((b,a))
    while not q.empty():
        # print(nodes)
        a,b = map(int, q.get())
        for j in nodes[a-1]:
            if not j in nodes[b-1] and j != b:
                nodes[b-1].append(j)
                nodes[j-1].append(b)
                ans -= 1
                q.put((j,b))
        for j in nodes[b-1]:
            if not j in nodes[a-1] and j != a:
                nodes[a-1].append(j)
                nodes[j-1].append(a)
                ans -= 1
                q.put((j,a))
# print(nodes)
for i in range(m):
    print(ans_list[-i-1])


Fixed submission:
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

n, m = map(int, input().split())
bridges = [map(int, input().split()) for _ in range(m)]
nodes = [[] for _ in range(n)] # いける島のリスト
ans = n*(n-1)//2
ans_list = []
u = UnionFind(n)
for i in range(m):
    ans_list.append(ans)
    # 順番に橋をかけていく
    a, b = bridges[-(i+1)]
    if u.isSameGroup(a, b):
        continue
    else:
        ans -= u.Count(a)*u.Count(b)
        u.Unite(a, b)

# print(nodes)
for i in range(m):
    print(ans_list[-i-1])
Buggy python submission (verdict: Runtime Error):
import fraction

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

ans = a[0]
for i in range(n-1):
    ans = fraction.gcd(ans, a[i+1])
print(ans)


Fixed submission:
import fractions

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

ans = a[0]
for i in range(n-1):
    ans = fractions.gcd(ans, a[i+1])
print(ans)

Buggy python submission (verdict: Runtime Error):
import math

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

ans = a[0]
for i in range(n-1):
    ans = math.gcd(ans, a[i+1])
print(ans)


Fixed submission:
import fractions

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

ans = a[0]
for i in range(n-1):
    ans = fractions.gcd(ans, a[i+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
n, x = map(int, input().split())
ans = 0
layer = [1 for _ in range(n+1)]
patty = [1 for _ in range(n+1)]
for i in range(1,n+1):
    layer[i] = 2*layer[i-1]+3
    patty[i] = 2*patty[i-1]+1
def eat(n, x):
    global ans
    # print(n ,x ,layer[n], patty[n], ans)
    if x == 0:
        print(ans)
        sys.exit()
    if layer[n] <= x:
        ans += patty[n]
        x -= layer[n]
        return x
    else:
        x -= 1
        x = eat(n-1, x)
        x -= 1
        ans += 1
        x = eat(n-1, x)
        x -= 1
x = eat(n, x)


Fixed submission:
import sys
n, x = map(int, input().split())
ans = 0
layer = [1 for _ in range(n+1)]
patty = [1 for _ in range(n+1)]
for i in range(1,n+1):
    layer[i] = 2*layer[i-1]+3
    patty[i] = 2*patty[i-1]+1
def eat(n, x):
    if n == 0:
        return 1
    if x == 1:
        return 0
    elif x <= 1+layer[n-1]:
        return eat(n-1, x-1)
    elif x == 2+layer[n-1]:
        return patty[n-1]+1
    elif x <= 2+2*layer[n-1]:
        return patty[n-1]+1+eat(n-1, x-2-layer[n-1])
    else:
        return 2*patty[n-1]+1
ans = eat(n, x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
lr = []
for _ in range(k):
    l, r = map(int, input().split())
    for i in range(l, r + 1):
        lr.append(i)
lr = set(lr)
lr = sorted(lr)
dp = [0] * (n + 1)
dp[n] = 1
for i in range(n, 1, -1):
    for step in lr:
        if step <= i:
            dp[i - step] += dp[i] % 998244353
            dp[i - step] %= 998244353
        else:
            break
print(dp[1])

Fixed submission:
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(k)]
mod = 998244353

dp = [0] * n
dp[0] = 1

acc = 0

for i in range(1, n):
    for l, r in lr:
        if i - l >= 0:
            acc += dp[i - l]
            acc %= mod
        if i - r - 1 >= 0:
            acc -= dp[i - r - 1]
            acc %= mod
        dp[i] = acc

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aaa = list(map(int, input().split()))
mod = 1000000007
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        ans += aaa[i] * aaa[j] % mod
        ans %= mod
print(ans)

Fixed submission:
n = int(input())
aaa = list(map(int, input().split()))
mod = 1000000007
c_sum = [0] * n
c_sum[n - 1] = aaa[n - 1]
ans = 0

for i in range(n - 2, 0, -1):
    c_sum[i] = (c_sum[i + 1] + aaa[i]) % mod

for i in range(n - 1):
    ans += aaa[i] * c_sum[i + 1] % mod
    ans %= mod

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aaa = map(int, input().split())
ans = 1
for a in aaa:
    ans *= a
print(int(ans) if ans <= 10 ** 18 else -1)

Fixed submission:
import sys
read = sys.stdin.readline
n = int(input())
aaa = list(map(int, read().split()))
aaa.sort()
ans = 1
for a in aaa:
    ans *= a
    if ans == 0:
        break
    if ans > 10 ** 18:
        ans = -1
        break
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aaa = map(int, input().split())
ans = 1
for a in aaa:
    ans *= a
print(int(ans) if ans <= 10 ** 18 else -1)

Fixed submission:
import sys
read = sys.stdin.readline
n = int(input())
aaa = list(map(int, read().split()))
aaa.sort()
ans = 1
for a in aaa:
    ans *= a
    if ans == 0:
        break
    if ans > 10 ** 18:
        ans = -1
        break
print(int(ans))
Buggy python submission (verdict: Runtime Error):
s = input().split()
a = int(s[0])
b, c = map(int, s[1].split())
print(a * b + a * c // 100)

Fixed submission:
from decimal import Decimal
a, b = map(str, input().split())
num = list(str(Decimal(a) * Decimal(b)))
ans = ''
for i in num:
    if i == '.':
        break
    ans += i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors

for i in make_divisors(x):
    for a in range(i + 1):
        b = a - i
        if a ** 5 - b ** 5 == x:
            print(str(a) + ' ' + str(b))
            break


Fixed submission:
x = int(input())
for a in range(-500, 500):
    for b in range(-500, 500):
        n = a ** 5 - b ** 5
        if n == x:
            print(a, end=" ")
            print(b)
            break
    else:
        continue
    break
Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b, n = map(int, input().split())
ans = 0
for x in range(1, n + 1):
    tmp = math.floor(a * x / b) - a * math.floor(x / b)
    ans = max(ans, tmp)
print(ans)

Fixed submission:
import math
a, b, n = map(int, input().split())
x = min(b - 1, n)
ans = math.floor(a * x / b) - a * math.floor(x / b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())
s = input()
r_list = []
g_list = []
b_list = []
r_append = r_list.append
g_append = g_list.append
b_append = b_list.append
cnt = 0
for i, j in enumerate(s):
    if j == 'R':
        r_append(i)
    if j == 'G':
        g_append(i)
    if j == 'B':
        b_append(i)
for r in r_list:
    for g in g_list:
        for b in b_list:
            if not(r * 2 == g + b or g * 2 == r + b or b * 2 == r + g):
                cnt += 1
print(cnt)

Fixed submission:
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r_list = []
g_list = []
b_list = []
cnt = 0
for i, j in enumerate(s):
    if j == 'R':
        r_list.append(i)
    if j == 'G':
        g_list.append(i)
    if j == 'B':
        b_list.append(i)
for r in r_list:
    for g in g_list:
        for b in b_list:
            if not(r * 2 == g + b or g * 2 == r + b or b * 2 == r + g):
                cnt += 1
print(cnt)

Fixed submission:
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
r_list = []
g_list = []
b_list = []
cnt = 0
for i, j in enumerate(s):
    if j == 'R':
        r_list.append(i + 1)
    if j == 'G':
        g_list.append(i + 1)
    if j == 'B':
        b_list.append(i + 1)
for r in r_list:
    for g in g_list:
        for b in b_list:
            if r * 2 != g + b and g * 2 != r + b and b * 2 != r + g:
                cnt += 1
print(cnt)


Fixed submission:
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k, n = map(int, input().split())
a_list = list(map(int, input().split()))
ans = k
for i in a_list:
    seq_list = a_list
    for j in range(n):
        if i == 0 and a_list[j] > k / 2:
            seq_list[j] = a_list[j] - k
        else:
            seq_list[j] = a_list[j] - i
    max_a = max(seq_list)
    min_a = min(seq_list)
    seq_dis = max_a - min_a
    ans = min(seq_dis, ans)
print(ans)

Fixed submission:
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + k)
dis = [a1 - a0 for a0, a1 in zip(a, a[1:])]
print(k - max(dis))

Buggy python submission (verdict: Time Limit Exceeded):
k, n = map(int, input().split())
a_list = list(map(int, input().split()))
ans = k
for i in a_list:
    seq_list = [0] * n
    if i == 0:
        for j in range(n):
            if a_list[j] > k / 2:
                seq_list[j] = a_list[j] - k
            else:
                seq_list[j] = a_list[j]

    else:
        for j in range(n):
            seq_list[j] = a_list[j] - i
    max_a = max(seq_list)
    min_a = min(seq_list)
    seq_dis = max_a - min_a
    ans = min(seq_dis, ans)
print(ans)

Fixed submission:
k, n = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + k)
dis = [a1 - a0 for a0, a1 in zip(a, a[1:])]
print(k - max(dis))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dict = {}
for _ in range(n):
    s = input()
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 0
max_list = [k for k, v in dict.items() if v == max(dict.values())]
max_list.sort()
for i in max_list:
    print(i)

Fixed submission:
n = int(input())
dict = {}
for _ in range(n):
    s = input()
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 0
max_val = max(dict.values())
max_list = [k for k, v in dict.items() if v == max_val]
max_list.sort()
for i in max_list:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
pl = list(map(int, input().split()))
pl_max = 0
num_max = 0
s = 0
ans = 0
for m in range(n - k + 1):
    if pl_max < sum(pl[m:m + k]):
        pl_max = sum(pl[m:m + k])
        num_max = m
for i in range(num_max, num_max + k):
    for j in range(1, pl[i] + 1):
        s += j
    ans += s / pl[i]
    s = 0
print(ans)

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:k])
res = tmp
for i in range(n - k):
    tmp -= p[i]
    tmp += p[i + k]
    res = max(res, tmp)
print((res + k) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
pl = list(map(int, input().split()))
pl_i = []
pl_max = 0
s = 0
for i in range(n):
    for j in range(1, pl[i]+1):
        s += j
    pl_i.append(s / pl[i])
    s = 0
for m in range(n - k + 1):
    pl_max = max(pl_max, sum(pl_i[m:m + k]))
print(pl_max)


Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = sum(p[:k])
res = tmp
for i in range(n - k):
    tmp -= p[i]
    tmp += p[i + k]
    res = max(res, tmp)
print((res + k) / 2)
Buggy python submission (verdict: Runtime Error):
from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a, b = int()
for i, x in enumerate(permutations(range(1, n + 1), n)):
    if x == p:
        a = i
    if x == q:
        b = i
print(abs(a - b))

Fixed submission:
from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
a, b = 0, 0
for i, x in enumerate(permutations(range(1, n + 1), n)):
    if x == p:
        a = i
    if x == q:
        b = i
print(abs(a - b))