Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
input = raw_input
S = input()
n = len(S) # N-1
s = S


up_count = 0
down_count = 0

for i, c in enumerate(S):
    if c == "<":
        start_i = i
        break
    down_count += 1

nums = []
for num in reversed(range(down_count+1)):
    nums.append(num)

up = True
for c in S[start_i:]: 
    if c == "<":
        if not up: # down->up
            if up_count >= down_count:
                for num in range(1, up_count+1):
                    nums.append(num)
                for num in reversed(range(0, down_count)):
                    nums.append(num)
            else:
                for num in range(0, up_count):
                    nums.append(num)
                for num in reversed(range(1, down_count+1)):
                    nums.append(num)
                 
            down_count = 0
            up_count = 1
            up = True
        else:
            up_count += 1
    else:
        if up:
            up = False
            down_count = 1
        else:
            down_count += 1
        

if up:
    for num in range(up_count+1):
        nums.append(num)
else:
    if up_count >= down_count:
        for num in range(1, up_count+1):
            nums.append(num)
        for num in reversed(range(0, down_count)):
            nums.append(num)
    else:
        for num in range(0, up_count):
            nums.append(num)
        for num in reversed(range(1, down_count+1)):
            nums.append(num)

out = sum(nums)
print(out)

Fixed submission:
input = raw_input
S = input()
n = len(S) # N-1
s = S


up_count = 0
down_count = 0

start_i = None
for i, c in enumerate(S):
    if c == "<":
        start_i = i
        break
    down_count += 1

if start_i is None:
    start_i = n

nums = []
for num in reversed(range(down_count+1)):
    nums.append(num)

up = True
for c in S[start_i:]: 
    if c == "<":
        if not up: # down->up
            if up_count >= down_count:
                for num in range(1, up_count+1):
                    nums.append(num)
                for num in reversed(range(0, down_count)):
                    nums.append(num)
            else:
                for num in range(0, up_count):
                    nums.append(num)
                for num in reversed(range(1, down_count+1)):
                    nums.append(num)
                 
            down_count = 0
            up_count = 1
            up = True
        else:
            up_count += 1
    else:
        if up:
            up = False
            down_count = 1
        else:
            down_count += 1
        

if up:
    for num in range(up_count+1):
        nums.append(num)
else:
    if up_count >= down_count:
        for num in range(1, up_count+1):
            nums.append(num)
        for num in reversed(range(0, down_count)):
            nums.append(num)
    else:
        for num in range(0, up_count):
            nums.append(num)
        for num in reversed(range(1, down_count+1)):
            nums.append(num)

out = sum(nums)
print(out)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

#input = raw_input
N, M = map(int, input().split(" "))
prices = sorted(map(int, input().split(" ")), reverse=True)


count = 0
cur_prices = []
for i in range(M):
    if i <= N-1:
        cur_prices = cur_prices + [prices[i]]

    max_i = np.argmax(cur_prices)
    cur_prices[max_i] /= 2 
    count += 1

out = int(np.floor(cur_prices).sum()) + sum(prices[i+1:])
print(out)

Fixed submission:
from heapq import heappush, heappop

input = raw_input
N, M = map(int, input().split(" "))

prices = []
for price in map(int, input().split(" ")):
    heappush(prices, -price)


for i in range(M):
    max_p = - (heappop(prices))
    half_p = max_p // 2
    heappush(prices, - half_p)

out = - sum(prices)
print(out)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

#input = raw_input
N, M = map(int, input().split(" "))
prices = list(map(int, input().split(" ")))

prices = np.asarray(prices)

for i in range(M):
    #max_p = max(prices) 
    max_i = prices.argmax() 
    #max_i = prices.index(max_p)
    prices[max_i] //=  2 

#out = sum(prices)
out = prices.sum()
print(out)

Fixed submission:
from heapq import heappush, heappop

input = raw_input
N, M = map(int, input().split(" "))

prices = []
for price in map(int, input().split(" ")):
    heappush(prices, -price)


for i in range(M):
    max_p = - (heappop(prices))
    half_p = max_p // 2
    heappush(prices, - half_p)

out = - sum(prices)
print(out)

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np

input = raw_input
N, M = map(int, input().split(" "))

prices = list(map(int, input().split(" ")))
for i in range(M):
    max_p = max(prices) 
    max_i = prices.index(max_p)
    prices[max_i] //=  2 

out = sum(prices)
print(out)

Fixed submission:
from heapq import heappush, heappop

input = raw_input
N, M = map(int, input().split(" "))

prices = []
for price in map(int, input().split(" ")):
    heappush(prices, -price)


for i in range(M):
    max_p = - (heappop(prices))
    half_p = max_p // 2
    heappush(prices, - half_p)

out = - sum(prices)
print(out)
Buggy python submission (verdict: Runtime Error):
input = raw_input
#import numpy as np

N, M = map(int, input().split())

values = [[] for i in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    if M >= A:
        values[A].append(B)

#print(values)
out = 0
elms = []
for i in range(1, M+1):
    new_elms = sorted(values[i], reverse=True)[:M-i+1]
    elms += new_elms
    if len(elms) >= 1:
        max_val = max(elms)
        out += max_val
        elms.remove(max_val)

print(out)

Fixed submission:
x, y = map(int, input().split())

l = [x+y, x-y, x*y]
print(max(l))
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())


s = []
for i in range(N):
    s0 = input()  
    c = collections.Counter(s0)
    s.append(c)

count = 0
for i in range(N):
    for j in range(i+1, N):
        if s[i] == s[j]:
            count += 1

print(count)

Fixed submission:
import collections
import math

N = int(input())

al = "abcdefghijklmnopqrstuvwxyz"
al_dict = {}
for i, c in enumerate(al):
    al_dict[c] = i

ss = []
for i in range(N):
    counts = [0 for i in range(26)]
    for char in input():
        ind = al_dict[char]
        counts[ind] += 1
    counts = [str(count) for count in counts]
    key = ",".join(counts)
    #c = collections.Counter(s0)
    #print(tuple(c))
    ss.append(key)

#print(ss)
cc = collections.Counter(ss)

#print(cc)
out = 0
for count in cc.values():
    if count == 1:
        continue
    out += math.factorial(count) // (math.factorial(count-2) * 2)
print(out)

#for s in ss:
#    for  in s[i+1]:
#        if s[i] == s[j]:
#            count += 1

#print(count)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
s = []
for i in range(N):
    s.append(sorted(input()))

count = 0
for i in range(N):
    for j in range(i+1, N):
        if s[i] == s[j]:
            count += 1

print(count)

Fixed submission:
import collections
import math

N = int(input())

al = "abcdefghijklmnopqrstuvwxyz"
al_dict = {}
for i, c in enumerate(al):
    al_dict[c] = i

ss = []
for i in range(N):
    counts = [0 for i in range(26)]
    for char in input():
        ind = al_dict[char]
        counts[ind] += 1
    counts = [str(count) for count in counts]
    key = ",".join(counts)
    #c = collections.Counter(s0)
    #print(tuple(c))
    ss.append(key)

#print(ss)
cc = collections.Counter(ss)

#print(cc)
out = 0
for count in cc.values():
    if count == 1:
        continue
    out += math.factorial(count) // (math.factorial(count-2) * 2)
print(out)

#for s in ss:
#    for  in s[i+1]:
#        if s[i] == s[j]:
#            count += 1

#print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(elm) for elm in input().split(" ")] 

As = [int(elm) for elm in input().split(" ")] 

dic = {}
keys= []
for A in As:
    if A not in keys:
        dic[A] = 1
        keys.append(A)
    else:
        dic[A] += 1

Bs = []
Cs = []
for i in range(M):
    B, C = [int(elm) for elm in input().split(" ")] 

    if C not in keys:
        dic[C] = B
        keys.append(C)
    else:
        dic[C] += B

    #Bs.append(B)
    #Cs.append(C)

keys = sorted(keys, reverse=True)

count = 0
out = 0

for key in keys:
    b = dic[key]
    if b < N - count:
        out += (key * b) 
        count += b
    else:
        out += (key * (N-count))
        break

print(out)

Fixed submission:
N, M = [int(elm) for elm in input().split(" ")] 

As = sorted([int(elm) for elm in input().split(" ")], reverse=True)


BCs = []
for i in range(M):
    B, C = [int(elm) for elm in input().split(" ")] 
    BCs.append([B, C])

BCs = sorted(BCs, key=lambda x: -x[1])

out = 0
bc_i = 0
count = 0
B, C = BCs[bc_i]

for A in As:
    if C >= A and bc_i < M:
        while C >= A: 
            #print("plus", B, C, "A", A)
            out += (B*C)

            count += B
            bc_i += 1
            if bc_i == M or count > N:
                break
            B, C = BCs[bc_i]
            
    if count > N:
        out -= C * (count-N)
        break
    elif count == N:
        break

    out += A
    #print("plus", A)
    count += 1

print(out)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(elm) for elm in input().split(" ")] 

As = [int(elm) for elm in input().split(" ")] 

Bs = []
Cs = []
for i in range(M):
    B, C = [int(elm) for elm in input().split(" ")] 
    As += ([C] * B)

t = sorted(As, reverse=True)
out = sum(t[:N])
print(out)

Fixed submission:
N, M = [int(elm) for elm in input().split(" ")] 

As = sorted([int(elm) for elm in input().split(" ")], reverse=True)


BCs = []
for i in range(M):
    B, C = [int(elm) for elm in input().split(" ")] 
    BCs.append([B, C])

BCs = sorted(BCs, key=lambda x: -x[1])

out = 0
bc_i = 0
count = 0
B, C = BCs[bc_i]

for A in As:
    if C >= A and bc_i < M:
        while C >= A: 
            #print("plus", B, C, "A", A)
            out += (B*C)

            count += B
            bc_i += 1
            if bc_i == M or count > N:
                break
            B, C = BCs[bc_i]
            
    if count > N:
        out -= C * (count-N)
        break
    elif count == N:
        break

    out += A
    #print("plus", A)
    count += 1

print(out)
Buggy python submission (verdict: Runtime Error):
#input = raw_input

res = None
G = None

def dfs(jibun_v, p, jibun_c):
    global res
    global G

    res[jibun_v] = jibun_c
    #print(jibun_v, p, jibun_c)

    tonari_nodes = G[jibun_v]
    for tonari_v, w in tonari_nodes:
        #if tonari_v == p or res[tonari_v] != -1:
        if tonari_v == p or res[tonari_v] != -1:
            continue

        if w % 2 == 0:
            tonari_c = jibun_c
        else:
            tonari_c = 1 - jibun_c

        dfs(tonari_v, jibun_v, tonari_c)
    

def main():
    N= int(input())

    global G
    G = [[] for _ in range(N)]

    for i in range(N-1):
        u, v, w = map(int, input().split(" "))
        u -= 1
        v -= 1
        w = w % 2
        G[u].append([v, w])
        G[v].append([u, w])

    global res
    res = [-1 for _ in range(N)]
    
    jibun_v = 0
    p = -1
    jibun_c = 0
    dfs(jibun_v, p, jibun_c)

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

main()
        

Fixed submission:
import math

N, K = [int(elm) for elm in input().split(" ")] 

K2 = math.log2(K)

out = sum([ (0.5) ** int(math.ceil(K2 - math.log2(me))) if me < K else 1 for me in range(1, N+1)]) / N

print(out)

Buggy python submission (verdict: Runtime Error):
#input = raw_input

res = None
G = None

def dfs(jibun_v, p, jibun_c):
    global res
    global G

    res[jibun_v] = jibun_c
    #print(jibun_v, p, jibun_c)

    tonari_nodes = G[jibun_v]
    for tonari_v, w in tonari_nodes:
        #if tonari_v == p or res[tonari_v] != -1:
        if tonari_v == p or res[tonari_v] != -1:
            continue

        if w % 2 == 0:
            tonari_c = jibun_c
        else:
            tonari_c = 1 - jibun_c

        dfs(tonari_v, jibun_v, tonari_c)
    

def main():
    N= int(input())

    global G
    G = [[] for _ in range(N)]

    for i in range(N-1):
        u, v, w = map(int, input().split(" "))
        u -= 1
        v -= 1
        w = w % 2
        G[u].append([v, w])
        G[v].append([u, w])

    global res
    res = [-1 for _ in range(N)]
    
    jibun_v = 0
    p = -1
    jibun_c = 0
    dfs(jibun_v, p, jibun_c)

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

main()
        

Fixed submission:
import math

N, K = [int(elm) for elm in input().split(" ")] 

K2 = math.log2(K)

out = sum([ (0.5) ** int(math.ceil(K2 - math.log2(me))) if me < K else 1 for me in range(1, N+1)]) / N

print(out)
Buggy python submission (verdict: Runtime Error):
#import numpy as np
#ins = [int(input()) for _ in range(5)] 

times = []
#for num in ins:
tmp = []
for _ in range(5):
    num = int(input())
    if num % 10 == 0:
        time = num
    else:
        time = num - num % 10 + 10
    times.append(time)
    tm = num % 10
    if tm >= 1:
        tmp.append(tm)
    #print(num)
    yobun = min(tmp)

#tmp = np.asarray(ins) % 10
#tmp = tmp[tmp >= 1]
#yobun = np.min(tmp)

if yobun == 0:
    yobun = 10

all_time = sum(times) - (10-yobun)
print(all_time)

Fixed submission:

times = []
#for num in ins:
tmp = []
for _ in range(5):
    num = int(input())
    if num % 10 == 0:
        time = num
    else:
        time = num - num % 10 + 10
    times.append(time)
    tm = num % 10
    if tm >= 1:
        tmp.append(tm)
    #print(num)

if len(tmp) == 0:
    tmp = [0]

yobun = min(tmp)
if yobun == 0:
    yobun = 10

all_time = sum(times) - (10-yobun)
print(all_time)

Buggy python submission (verdict: Runtime Error):
import numpy as np
ins = [int(input()) for _ in range(5)] 

times = []
for num in ins:
    if num % 10 == 0:
        time = num
    else:
        time = num - num % 10 + 10
    times.append(time)
    #print(num)

tmp = np.asarray(ins) % 10
tmp = tmp[tmp >= 1]
yobun = np.min(tmp)

if yobun == 0:
    yobun = 10

all_time = np.sum(times) - (10-yobun)
print(all_time)

Fixed submission:

times = []
#for num in ins:
tmp = []
for _ in range(5):
    num = int(input())
    if num % 10 == 0:
        time = num
    else:
        time = num - num % 10 + 10
    times.append(time)
    tm = num % 10
    if tm >= 1:
        tmp.append(tm)
    #print(num)

if len(tmp) == 0:
    tmp = [0]

yobun = min(tmp)
if yobun == 0:
    yobun = 10

all_time = sum(times) - (10-yobun)
print(all_time)
Buggy python submission (verdict: Runtime Error):
N, M = [int(elm) for elm in input().split(" ")]
bridges = [[int(elm) for elm in input().split(" ")] for _ in range(M)]

#graph = {}
#for node in range(1, N+1):
#    graph[node] = [node]
#    #graph_mem[node] = []

#graph_n_mem = [0] + [1 for i in range(N)]
graph_n_mem = [0] + [1] * N
n_all_pairs = N * (N-1) // 2

parent = [-1] * (N+1)

#def get_parent(child_node, tmp_nodes=[]):
def get_parent(child_node):
    parent_node = parent[child_node]

    if parent_node != -1:
        #tmp_nodes.append(child_node)
        #out = get_parent(parent_node, tmp_nodes)
        out = get_parent(parent_node)
    else:
        out = child_node
        #if len(tmp_nodes) >= 1:
        #    tmp_nodes = tmp_nodes[:-1]
        #    for tmp_node in tmp_nodes:
        #        parent[tmp_node] = out
    return out


outs = []
out = n_all_pairs
for A, B in reversed(bridges):
    #A = graph[A][0]
    #B = graph[B][0]

    A = get_parent(A)
    B = get_parent(B)

    if A != B:
        n_b = graph_n_mem[B]
        n_a = graph_n_mem[A]
        graph_n_mem[A] += graph_n_mem[B]
        graph_n_mem[B] = 0

        parent[B] = A

        #old_graph_B = graph[B]
        #graph[A] += graph[B]
        #for node in old_graph_B:
        #    graph[node] = graph[A]
        
        out -= n_a * n_b

    outs.append(out)

outs = outs[::-1]
outs = outs[1:] + [n_all_pairs]
for out in outs:
    print(out)


Fixed submission:
A, B, C = list(map(int, input().split(" ")))

n = B // A
out = min(n, C)
print(out)

Buggy python submission (verdict: Runtime Error):
N, M = [int(elm) for elm in input().split(" ")]
bridges = [[int(elm) for elm in input().split(" ")] for _ in range(M)]

class Graph:
    pass

graph = {}
for node in range(1, N+1):
    graph[node] = [node]
    #graph_mem[node] = []

graph_n_mem = [0] + [1 for i in range(N)]
n_all_pairs = N * (N-1) // 2

#def delete_graph(B):
#    pass

def calc_out(n_list):
    out = n_all_pairs
    for elm in n_list:
        if elm <= 1:
            continue
        tmp = elm * (elm-1) // 2
        out -= tmp
    return out

outs = []
for A, B in reversed(bridges):
    #print(graph_n_mem)
    #print("before AB", A, B)
    A = graph[A][0]
    B = graph[B][0]
    #print(graph_n_mem, "AB", A, B)
    if graph[A] != graph[B]:
        #graph_n_mem[A] += len(graph[B])
        graph_n_mem[A] += graph_n_mem[B]
        graph_n_mem[B] = 0

        graph[A] += graph[B]
        for node in graph[A]:
            graph[node] = graph[A]
            
        #graph_mem[A] += graph_mem[B]
        

    out = calc_out(graph_n_mem)
    outs.append(out)

outs = outs[::-1]
outs = outs[1:] + [n_all_pairs]
for out in outs:
    print(out)

Fixed submission:
A, B, C = list(map(int, input().split(" ")))

n = B // A
out = min(n, C)
print(out)
Buggy python submission (verdict: Runtime Error):
import math

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

d = math.gcd(A, B)

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

ass = list(set(divisor(d)))
#print(ass)
out = ass[-K]
print(out)

Fixed submission:
from fractions import gcd

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

d = gcd(A, B)

def divisor(n):
    #for i in range(1,int(n**0.5)+1):
    ass = [i for i in range(1, n+1) if n % i == 0]
    return ass

ass = divisor(d)
#print(ass)
out = ass[-K]
print(out)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
h_list = list(map(int, input().split(" ")))

h_dict = {}
for elm_i, elm in enumerate(h_list):
    try:
        h_dict[elm].append(elm_i)
    except:
        h_dict[elm] = [elm_i]

h_list = np.asarray(h_list)


def calc(group, past_out, group_start):
    out = 0
    while True:
        #print("group", group)
        min_val = min(group)
        group -= min_val
        out += min_val
        #zero_list = np.where(group == 0)[0]
        #print("outs", past_out, out, group)
        #print("zero0", zero_list)
        zero_list = h_dict[past_out + out]
        #print("zero_all", zero_list, group_start)
        zero_list = [elm_i - group_start for elm_i in zero_list if elm_i >= group_start and elm_i < group_start + len(group)]
        #print("zero", zero_list)

        cond1 = group.shape[0] - 1 in zero_list
        cond2 = 0 in zero_list

        if group.shape[0] == 1:
            #assert group[0] == 0
            break
        else:
            if cond1: 
                zero_list = zero_list[:-1]
                group = group[:-1]
            if cond2:
                group_start += 1
                zero_list = zero_list[1:]
                group = group[1:]

            if not cond1 and not cond2:
                break

            if group.shape[0] == 0:
                break


    if group.shape[0] <= 1:
        pass
    else:
        start_i = -1
        past_out = out
        for end_i in zero_list:
            child_group = group[start_i+1: end_i]
            #print("child_group", child_group)
            out += calc(child_group, past_out, group_start+start_i+1)
            start_i = end_i

        child_group = group[start_i+1:]
        if child_group.shape[0] >= 1:
            #print("child_group", child_group)
            out += calc(child_group, past_out, group_start+start_i+1)

    return out

out = calc(h_list, 0, 0)
print(out)

Fixed submission:
inputs=  sorted(list(map(int, input().split(" "))))

out = inputs[0] * inputs[1] // 2

print(out)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M = list(map(int, input().split(" ")))
A_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]
B_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]

out = 1
a_next_i = 0
b_next_i = 0
for x in range(N*M, 1, -1):
    cond1 = a_next_i < N and x == A_list[a_next_i]
    cond2 = b_next_i < M and x == B_list[b_next_i]
    if cond1 and cond2:
        kosuu = 1
        a_next_i += 1
        b_next_i += 1
    elif cond1:
        kosuu = b_next_i
        a_next_i += 1
    elif cond2:
        kosuu = a_next_i
        b_next_i += 1
    else:
        kosuu = a_next_i * b_next_i - (N * M - x)
    out *= kosuu
    out = out % 1000000007
   
print(out)

Fixed submission:
inp = sorted(list(map(int, input().split(" "))))

s = [1, 4, 7, 9]

if inp == s:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M = list(map(int, input().split(" ")))
A_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]
B_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]

out = 1
a_next_i = 0
b_next_i = 0
for x in range(N*M, 1, -1):
    cond1 = a_next_i < N and x == A_list[a_next_i]
    cond2 = b_next_i < M and x == B_list[b_next_i]
    if cond1 and cond2:
        kosuu = 1
        a_next_i += 1
        b_next_i += 1
    elif cond1:
        kosuu = b_next_i
        a_next_i += 1
    elif cond2:
        kosuu = a_next_i
        b_next_i += 1
    else:
        kosuu = a_next_i * b_next_i - (N * M - x)
    out *= kosuu
    out = out % 1000000007
   
print(out)

Fixed submission:
import numpy as np

N, M = list(map(int, input().split(" ")))
A_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]
B_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]

out = 1
a_next_i = 0
b_next_i = 0
for x in range(N*M, 1, -1):
    #if x in A_list and x in B_list:
    if a_next_i < N and x == A_list[a_next_i] and b_next_i < M and x == B_list[b_next_i]:
        kosuu = 1
        a_next_i += 1
        b_next_i += 1
    #elif x in A_list:
    elif a_next_i < N and x == A_list[a_next_i]:
        #kosuu = np.sum(B_list >= x)
        kosuu = b_next_i
        a_next_i += 1
    #elif x in B_list:
    elif b_next_i < M and x == B_list[b_next_i]:
        #kosuu = np.sum(A_list >= x)
        kosuu = a_next_i
        b_next_i += 1
    else:
        #kosuu = np.sum(A_list >= x) * np.sum(B_list >= x) - (N * M - x)
        kosuu = a_next_i * b_next_i - (N * M - x)
    out *= kosuu
    out = out % 1000000007
   
print(out)

#print(A_list)
#print(B_list)