Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
if any([a+b ==c,a+c==b,b+c == a]):
    print('Yes')
else:
    print('No')

Fixed submission:
a =  list(map(int, input().split()))
if any([a[0]+a[1] ==a[2] ,a[0]+a[2] ==a[1] ,a[1]+a[2] == a[0]]):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

# 一度たずねた場所はループが判明しているのでそのままにする(何度移動させるかに関係なくtree構造がつながっているかを調べたい)
ans = -10 ** 18
for i in range(N):
    x = i
    loop = []
    total = 0
    while True:
        x = P[x] - 1
        loop.append(C[x])
        total += C[x]
        if x == i:
            break

    T = len(loop)
    tmp = 0
    for j in range(T):
        tmp += loop[j]
        if K < j + 1:
            break
        now = tmp
        # 一周のループが正の時のみ何度も回す価値がある。それ以外のときはそれまでの最大をとる
        if total > 0:
            loop_times = (K - (j + 1)) // T
            now += total * loop_times

        ans = max(ans, now)
print(ans)


Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

# 一度たずねた場所はループが判明しているのでそのままにする(何度移動させるかに関係なくtree構造がつながっているかを調べたい)
ans = -10 ** 18
for i in range(N):
    x = i
    loop = []
    total = 0
    while True:
        x = P[x] - 1
        loop.append(C[x])
        total += C[x]
        if x == i:
            break

    T = len(loop)
    tmp = 0
    for j in range(T):
        tmp += loop[j]
        if K < j + 1:
            break
        now = tmp
        # 一周のループが正の時のみ何度も回す価値がある。それ以外のときはそれまでの最大をとる
        if total > 0:
            loop_times = (K - (j + 1)) // T
            now += total * loop_times

        ans = max(ans, now)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

d = defaultdict(int)

# マスの数が5000以下であるため、KがNより大きい場合必ずループする
# それぞれのますが何回移動してからループに入るかを調べ残す
for i in range(N):
    idx = P[i]
    count = 0
    score = 0
    new_K = K
    while new_K > 0:
        # if (idx == P[i] and count != 0):
        #     break
        score += C[idx - 1]
        if (d[i + 1] == 0):
            d[i + 1] = score
        else:
            d[i + 1] = max(d[i + 1], score)
        idx = P[idx - 1]
        count += 1
        new_K -= 1


ans = -1 * 10 ** 10 + 7
for v in d.values():
    ans = max(ans, v)

print(ans)


Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

# 一度たずねた場所はループが判明しているのでそのままにする(何度移動させるかに関係なくtree構造がつながっているかを調べたい)
ans = -10 ** 18
for i in range(N):
    x = i
    loop = []
    total = 0
    while True:
        x = P[x] - 1
        loop.append(C[x])
        total += C[x]
        if x == i:
            break

    T = len(loop)
    tmp = 0
    for j in range(T):
        tmp += loop[j]
        if K < j + 1:
            break
        now = tmp
        # 一周のループが正の時のみ何度も回す価値がある。それ以外のときはそれまでの最大をとる
        if total > 0:
            loop_times = (K - (j + 1)) // T
            now += total * loop_times

        ans = max(ans, now)
print(ans)
Buggy python submission (verdict: Runtime Error):
import string

N = int(input())
al = string.ascii_lowercase

if (N >= 1 and N <= 26):
    print(al[N - 1])
    exit()
elif (N >= 27 and N <= 702):
    n = N // 26
    amari = N % 26
    if (amari == 0 and n != 27):
        print(al[n - 1] + al[25])
        exit()
    elif (amari == 0 and n == 27):
        print(al[25] + al[25])
        exit()
    else:
        print(al[n - 1] + al[amari - 1])
elif (N >= 703):
    s = ''
    num = 26
    while N > 26:
        amari = N % num
        N //= 26
        if (amari == 0):
            N -= 1
        if (amari == 0):
            s += al[25]
        else:
            s += al[amari - 1]
if (N == 0):
    s += al[25]
else:
    s += al[N - 1]
print(s[::-1])


Fixed submission:
import string

N = int(input())
al = string.ascii_lowercase

# if (N >= 1 and N <= 26):
#     print(al[N - 1])
#     exit()
# elif (N >= 27 and N <= 702):
#     n = N // 26
#     amari = N % 26
#     if (amari == 0 and n != 27):
#         print(al[n - 1] + al[25])
#         exit()
#     elif (amari == 0 and n == 27):
#         print(al[25] + al[25])
#         exit()
#     else:
#         print(al[n - 1] + al[amari - 1])
#         exit()
# elif (N >= 703):
s = ''
num = 26
while N > 26:
    amari = N % num
    N //= 26
    if (amari == 0):
        N -= 1
    if (amari == 0):
        s += al[25]
    else:
        s += al[amari - 1]
if (N == 0):
    s += al[25]
else:
    s += al[N - 1]
print(s[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
A = list(map(int, input().split()))

j = 0
ans = deque()
while j <= N - 1:
    stock = deque()
    for i in range(N):
        # iとjが同じとき
        if (i == j):
            continue

        if (A[j] % A[i] != 0):
            stock.append(A[i])

    if (len(stock) == len(A) - 1):
        ans.append(j)
    j += 1

print(len(ans))


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

table = [0 for i in range(10**6 + 1)]
ans = 0
a.sort()
a.append(10**7)
for i in range(n):
    el = a[i]
    if table[el] != 0:
        continue
    else:
        if el != a[i + 1]:
            ans += 1
    idx = el
    while idx <= 10**6:
        table[idx] += 1
        idx += el

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))


j = 0
ans = []
while j <= N - 1:
    stock = []
    for i in range(N):
        # iとjが同じとき
        if (i == j):
            continue

        if (A[j] % A[i] != 0):
            stock.append(A[i])

    if (len(stock) == len(A) - 1):
        ans.append(j)
    j += 1

print(len(ans))


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

table = [0 for i in range(10**6 + 1)]
ans = 0
a.sort()
a.append(10**7)
for i in range(n):
    el = a[i]
    if table[el] != 0:
        continue
    else:
        if el != a[i + 1]:
            ans += 1
    idx = el
    while idx <= 10**6:
        table[idx] += 1
        idx += el

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(N):
    ans *= A[i]

if (ans > 10**18):
    print(-1)
else:
    print(ans)


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

if (0 in A):
    print(0)
    exit()

ans = 1
for i in range(N):
    if (ans > 10 ** 18):
        break
    ans *= A[i]

if (ans > 10**18):
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(N):
    ans *= A[i]

if (ans > 10**18):
    print(-1)
else:
    print(ans)


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

if (0 in A):
    print(0)
    exit()

ans = 1
for i in range(N):
    if (ans > 10 ** 18):
        break
    ans *= A[i]

if (ans > 10**18):
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A, B = input().split()

print(int(math.floor(float(A) * float(B))))


Fixed submission:
n = int(input())

d = 2
ans = 0
while d * d <= n:
    if (n % d != 0):
        d += 1
        continue
    z = d
    while n % z == 0:
        n //= z
        z *= d
        ans += 1

    while n % d == 0:
        # 残りかすを除去
        n //= d

if (n != 1):
    ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

k = int(input())

# # nは組み合わせの数
# n = k**3

L = []
for i in range(1, k+1):
    for j in range(1, k+1):
        for p in range(1, k+1):
            L.append(gcd(i, j, p))

print(sum(L))

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())

L = []
for i in range(1, k+1):
    for j in range(1, k+1):
        for p in range(1, k+1):
            L.append(gcd(i, j, p))

print(sum(L))
Buggy python submission (verdict: Runtime Error):
while True:
    if ((n-k) > 10000):
        n = n // 100
    else:
        an = abs(n-k)
        if n <= an:
            break
        else:
            n = an
print(n)


Fixed submission:
import sys
N, K = map(int, input().split())

ans = N % K
ans = min(ans, abs(K-ans))
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
n, k = map(int, input().split())

while True:
    if ((n-k) > 10000):
        n = n // 10000
    else:
        an = abs(n-k)
    if n <= an:
        break
    else:
        n = min(n, an)
print(n)




Fixed submission:
import sys
N, K = map(int, input().split())

ans = N % K
ans = min(ans, abs(K-ans))
print(ans)
Buggy python submission (verdict: Runtime Error):
k= int(input())
runrun = [1,2,3,4,5,6,7,8,9]
for i in range(10, 1000000):
    si = str(i)
    lsi = len(si)
    t =False
    for i in range(lsi-1):
        if abs(int(si[i]) - int(si[i+1])) <= 1:
            t = True
        else:
            t = False
            break
    if t:
        runrun.append(int(si))
print(runrun[k-1])
        

Fixed submission:
from collections import deque

k = int(input())

q =deque([1,2,3,4,5,6,7,8,9])

num = 0

while True:
    x = q.popleft()
    num += 1
    if num == k:
        break
    y = x % 10
    if y != 0:
        q.append(10*x+y-1)
    q.append(10*x+y)
    if y != 9:
        q.append(10*x+y+1)

print(x)
Buggy python submission (verdict: Runtime Error):
s = input()

if len(s) == 6 & s[2]==s[3] & s[4]== s[5] {
    return print("Yes")
}else {
    return print("No")
}

Fixed submission:
s = input()

if len(s) == 6 and s[2]==s[3] and s[4]== s[5]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())

# 偶数足す偶数
# 奇数たす奇数
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans=0
if (n!=1):
    ans = ans+ combinations_count(n, 2)

if (m != 1):
    ans = ans + combinations_count(m, 2)
    
print(ans)

Fixed submission:
import math
n, m = map(int, input().split())

# 偶数足す偶数
# 奇数たす奇数
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans=0
if (n==0 and m>=2):
    ans = ans + combinations_count(m, 2)

elif (n>=2 and m== 0):
    ans = ans + combinations_count(n, 2)
else:
    if (n!=1):
        ans = ans+ combinations_count(n, 2)
    
    if (m != 1):
        ans = ans + combinations_count(m, 2)



print(ans)
Buggy python submission (verdict: Runtime Error):
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

key = []
for i, v in enumerate(A):
    for k, j in enumerate(v):
        if (j in B):
            key.append([i, k])

ans = [[[0, 0], [1, 0], [2, 0]], [[0, 1], [1, 1], [2, 1]], [[0, 2], [1, 2], [2, 2]], [[0, 0], [1, 1], [2, 2]], [
    [0, 2], [1, 1], [2, 0]], [[0, 0], [0, 1], [0, 2]], [[1, 0], [1, 1], [1, 2]], [[2, 0], [2, 1], [2, 2]]]

for i in ans:
    for j in i:
        if (j in key.sort()):
            print('Yes')
            exit()

print('No')


Fixed submission:
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]

key = []
for i, v in enumerate(A):
    for k, j in enumerate(v):
        if (j in B):
            key.append([i, k])

ans = [[[0, 0], [1, 0], [2, 0]], [[0, 1], [1, 1], [2, 1]], [[0, 2], [1, 2], [2, 2]], [[0, 0], [1, 1], [2, 2]], [
    [0, 2], [1, 1], [2, 0]], [[0, 0], [0, 1], [0, 2]], [[1, 0], [1, 1], [1, 2]], [[2, 0], [2, 1], [2, 2]]]

for i in ans:
    count = 0
    for j in i:
        if (j in key):
            count += 1
    if (count == 3):
        print('Yes')
        exit()

print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

count = 1
for i in range(1, N):
    if(P[1] <= P[0]):
        P.pop(0)
        count += 1
    else:
        P.pop(1)


print(count)


Fixed submission:
N = int(input())
P = list(map(int, input().split()))

count = 1
d = P[0]
for i in range(N - 1):
    if (d > P[i + 1]):
        d = min(P[i], P[i + 1])
        count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

count = 1
for i in range(1, N):
    if(P[1] <= P[0]):
        P.pop(0)
        count += 1
    else:
        P.pop(1)

print(count)


Fixed submission:
N = int(input())
P = list(map(int, input().split()))

count = 1
d = P[0]
for i in range(N - 1):
    if (d > P[i + 1]):
        d = min(P[i], P[i + 1])
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = [0] * 3
count = 0
for i in range(0, 1000):
    if (i < 10):
        s = '00' + str(i)
    elif (i >= 10 and i < 100):
        s = '0' + str(i)
    else:
        s = str(i)
    idx = 0
    for i in range(N):
        if (S[i] == s[idx]):
            ans[idx] = i + 1
            idx += 1
        if (0 not in ans):
            count += 1
            ans = [0] * 3
            break
print(count)


Fixed submission:
N = int(input())
S = input()

count = 0
for p in range(10):
    s = S.find(str(p))
    if s == -1:
        continue
    for q in range(10):
        t = S.find(str(q), s + 1)
        if t == -1:
            continue
        for r in range(10):
            u = S.find(str(r), t + 1)
            if u != -1:
                count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Ali = list(map(int,input().split()))
L = sorted(Ali)
li = []
[li.append(Ali.index(L[i])+1) for i in range(N)]

print(' '.join(map(str, li)))


Fixed submission:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
for i, v in enumerate(A):
    d[i + 1] = v
ans = []
d_swap = {v: k for k, v in d.items()}
sd = sorted(d_swap.items())
for i, v in enumerate(sd):
    ans.append(v[1])
print(' '.join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Ali = list(map(int,input().split()))
L = Ali[:]

L.sort()
li = []
for i in range(N):
    li.append(Ali.index(L[i])+1)

print(' '.join(map(str, li)))


Fixed submission:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
for i, v in enumerate(A):
    d[i + 1] = v
ans = []
d_swap = {v: k for k, v in d.items()}
sd = sorted(d_swap.items())
for i, v in enumerate(sd):
    ans.append(v[1])
print(' '.join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N = int(input())
Ali = list(map(int,input().split()))
L = copy.deepcopy(Ali)

L.sort()
li = []
for i in range(N):
    li.append(Ali.index(L[i])+1)

print(' '.join(map(str, li)))


Fixed submission:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
for i, v in enumerate(A):
    d[i + 1] = v
ans = []
d_swap = {v: k for k, v in d.items()}
sd = sorted(d_swap.items())
for i, v in enumerate(sd):
    ans.append(v[1])
print(' '.join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import sys
N = int(input())
Ali = list(map(int,input().split()))
L = copy.deepcopy(Ali)

L.sort()
li = []
for i in range(N):
    li.append(Ali.index(L[i])+1)

for i in range(N):
    sys.stdout.write(str(li[i])+' ')


Fixed submission:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
for i, v in enumerate(A):
    d[i + 1] = v
ans = []
d_swap = {v: k for k, v in d.items()}
sd = sorted(d_swap.items())
for i, v in enumerate(sd):
    ans.append(v[1])
print(' '.join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import sys
N = int(input())
Ali = list(map(int,input().split()))
L = copy.deepcopy(Ali)

L.sort()
li = []
for i in range(N):
    li.append(Ali.index(L[i])+1)

for i in range(N):
    sys.stdout.write(str(li[i])+' ')


Fixed submission:
from collections import defaultdict
d = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
for i, v in enumerate(A):
    d[i + 1] = v
ans = []
d_swap = {v: k for k, v in d.items()}
sd = sorted(d_swap.items())
for i, v in enumerate(sd):
    ans.append(v[1])
print(' '.join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())

list1 = list(map(int,input().split()))
list1.sort()
list1.reverse()

i=0
s = math.floor(list1[0]/2)

if n==1:
    print(math.floor(list[1]/(2**m)))
    # 処理終了
    exit() 

while True:
    while True:
        if i+1 > n:
            break
        if list1[i] < s or m == 0:
            break
        list1[i] = math.floor(list1[i]/2)
        m -= 1
        i += 1
    if m==0:
        break
    list1.sort()
    list1.reverse()
    s = math.floor(list1[0]/2)
    i = 0
print(sum(list1))


Fixed submission:
import math
n,m = map(int,input().split())

list1 = list(map(int,input().split()))
list1.sort()
list1.reverse()
i = 0
s = math.floor(list1[0]/2)
 
if n == 1:
    print(math.floor(list1[0]/(2**m)))
    exit()
 
while True:
    while True:
        if i+1 > n:
            break
        if list1[i] < s or m == 0:
            break
        list1[i] = math.floor(list1[i]/2)
        m -= 1
        i += 1
    if m == 0:
        break
    list1.sort()
    list1.reverse()
    s = math.floor(list1[0]/2)
    i = 0
print(sum(list1))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
 
N=int(input())
A=list(map(int,input().split()))
 
XOR=0
for a in A:
    XOR^=a

for i in range(N):
    A[i] &=~XOR

USED=[0]*N

for bi in range(60,-1,-1):
    for i in range(N):
        if USED[i]==0 and A[i] & (1<<bi)!=0:
            USED[i]=1
            useind=i
            break
    else:
        continue
    
    for i in range(N):
        if i==useind:
            continue
        if A[i] & (1<<bi)!=0:
            A[i]^=A[useind]

ANS=0
for a in A:
    ANS^=a

print(2*ANS+XOR)




Fixed submission:
import sys
input = sys.stdin.readline
 
N=int(input())
A=list(map(int,input().split()))
 
XOR=0
for a in A:
    XOR^=a
 
for i in range(N):
    A[i] &=~XOR
    
USED=[0]*N
 
for bi in range(60,-1,-1):
    for i in range(N):
        if USED[i]==0 and A[i] & (1<<bi)!=0:
            USED[i]=1
            useind=i
            break
    else:
        continue
 
    for i in range(N):
        if i==useind:
            continue
        if A[i] & (1<<bi)!=0:
            A[i]^=A[useind]
            
ANS=0
for a in A:
    ANS^=a
 
print(2*ANS+XOR)
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int, input().split()))

L = B[:]
for i in range(N - 1):
    if (i >= N - 2):
        break
    elif (i == 0 and B[0] > B[1]):
        p = L.pop(0)
        L.append(p)
    elif (B[i] > B[i + 1]):
        L.pop(i)

if (len(L) == 1):
    print(sum(B) * 2)
else:
    print(sum(L) + L[-2])


Fixed submission:
N = int(input())
B = list(map(int, input().split()))

ans = B[0] + B[-1]
for i in range(1, N - 1):
    ans += min(B[i], B[i - 1])

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int, input().split()))

L = B[:]
for i in range(N - 1):
    if (i >= N - 2):
        break
    elif (i == 0 and B[0] > B[1]):
        p = L.pop(0)
        L.append(p)
    elif (B[i] > B[i + 1]):
        L.pop(i)

print(L)
if (len(L) == 1):
    print(sum(B) * 2)
else:
    print(sum(L) + L[-2])


Fixed submission:
N = int(input())
B = list(map(int, input().split()))

ans = B[0] + B[-1]
for i in range(1, N - 1):
    ans += min(B[i], B[i - 1])

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int, input().split()))

L = B[:]
for i in range(N - 1):
    if (i >= N - 2):
        break
    elif (B[i] > B[i + 1]):
        L.pop(i)

if (len(B) == 1):
    print(sum(B) * 2)
else:
    print(sum(L) + L[-2])


Fixed submission:
N = int(input())
B = list(map(int, input().split()))

ans = B[0] + B[-1]
for i in range(1, N - 1):
    ans += min(B[i], B[i - 1])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

ans = []
count = 0
for i in range(N):
    for j in range(i + count, N):
        if (j == N - 1):
            ans.append(count)
            count = 0
            break
        if (H[j] < H[j + 1]):
            ans.append(count)
            count = 0
            break
        else:
            count += 1

print(max(ans))


Fixed submission:
N = int(input())
H = list(map(int, input().split()))

ans = []
count = 0
for j in range(N):
    if (j == N - 1):
        ans.append(count)
        count = 0
        break
    if (H[j] < H[j + 1]):
        ans.append(count)
        count = 0
        continue
    elif (H[j] >= H[j + 1]):
        count += 1

print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))

ans = []
count = 0
for i in range(N):
    for j in range(i, N):
        if (j == N - 1):
            ans.append(count)
            count = 0
            break
        if (H[j] < H[j + 1]):
            ans.append(count)
            count = 0
            break
        else:
            count += 1

print(max(ans))


Fixed submission:
N = int(input())
H = list(map(int, input().split()))

ans = []
count = 0
for j in range(N):
    if (j == N - 1):
        ans.append(count)
        count = 0
        break
    if (H[j] < H[j + 1]):
        ans.append(count)
        count = 0
        continue
    elif (H[j] >= H[j + 1]):
        count += 1

print(max(ans))