Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n = int(input())
A = deque([int(input()) for _ in range(n)])
ans = []

for _ in range(n):
    tmp = A.popleft()
    print(max(A))
    A.append(tmp)


Fixed submission:
from collections import deque
n = int(input())
A = [int(input()) for _ in range(n)]
# ans = []
#
# for _ in range(n):
#     tmp = A.popleft()
#     print(max(A))
#     A.append(tmp)

# 時間がかかるのはソートだけ。
sorted_A = sorted(A, reverse=True)
max_val = sorted_A[0]
second_val = sorted_A[1]

for i in range(n):
    # 索引は速いらしい
    if A[i] != max_val:
        print(max_val)
    else:
        print(second_val)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = [int(input()) for _ in range(n)]
ans = []

for i in range(len(A)):
    tmp = A.pop(i)
    print(max(A))
    A.insert(i, tmp)


Fixed submission:
from collections import deque
n = int(input())
A = [int(input()) for _ in range(n)]
# ans = []
#
# for _ in range(n):
#     tmp = A.popleft()
#     print(max(A))
#     A.append(tmp)

# 時間がかかるのはソートだけ。
sorted_A = sorted(A, reverse=True)
max_val = sorted_A[0]
second_val = sorted_A[1]

for i in range(n):
    # 索引は速いらしい
    if A[i] != max_val:
        print(max_val)
    else:
        print(second_val)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))

i = 0
D = 0

if L[0] > X:
    print(1)
    exit()
elif L[0] == X:
    print(2)
    exit()

while D <= X and i <= N:
    D += L[i]
    i += 1

print(i)


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

i = 0
D = 0
cnt = 1

for i in range(N):
    D += L[i]
    if D <= X:
        cnt += 1
print(cnt)

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

i = 0
D = 0

if L[0] > X:
    print(1)
    exit()

while D <= X and i <= N:
    D += L[i]
    i += 1

print(i)


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

i = 0
D = 0
cnt = 1

for i in range(N):
    D += L[i]
    if D <= X:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
A, B = input().split(" ")
if A >= 13:
    print(B)
elif 6 <= A <= B:
    print(int(B/2))
else:
    print(0)

Fixed submission:
A, B = list(map(int, input().split(" ")))
if A >= 13:
    print(B)
elif 6 <= A <= B:
    print(int(B/2))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

V_C = []
diff = 0

for i in range(N):
    V_C.append([V[i], C[i]])

for i in range(1, N+1):
    combs = list(combinations(V_C, i))
    for comb in combs:
        price = 0
        cost = 0
        for c in comb:
            price += c[0]
            cost += c[1]
            p_c = price - cost
            if p_c > diff:
                diff = p_c

print(diff)


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

V_C = zip(V, C)
ans = 0

for x in V_C:
    diff = x[0] - x[1]
    ans += diff if diff >= 0 else 0

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

cnt = 1

for i in range(1, N):
    if H[i] >= max(H[:i]:
        cnt += 1

print(cnt)


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

cnt = 1

for i in range(1, N):
    if H[i] >= max(H[:i]):
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = input()
ranges = [list(map(int, input().split())) for _ in range(q)]

cnt = 0
cnt_list = [0]
# インデックスの要素 = インデックスから始まる文字が"AC"
for i in range(n - 1):
    if s[i:i + 2] == "AC":
        cnt += 1
        cnt_list.append(cnt)

for start, end in ranges:
    print(cnt_list[end-1] - cnt_list[start-1])


Fixed submission:
n, q = map(int, input().split())
s = input()
ranges = [list(map(int, input().split())) for _ in range(q)]

cnt = 0
cnt_list = []
# インデックスの要素 = インデックスから始まる文字が"AC"
for i in range(n):
    if i < 1:
        cnt_list.append(0)
        continue
    if s[i-1:i+1] == "AC":
        cnt += 1
    cnt_list.append(cnt)

for start, end in ranges:
    print(cnt_list[end-1] - cnt_list[start-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ranges = [list(map(int, input().split())) for _ in range(q)]

for start, end in ranges:
    print(s.count('AC', start-1, end))


Fixed submission:
n, q = map(int, input().split())
s = input()
ranges = [list(map(int, input().split())) for _ in range(q)]

cnt = 0
cnt_list = []
# インデックスの要素 = インデックスから始まる文字が"AC"
for i in range(n):
    if i < 1:
        cnt_list.append(0)
        continue
    if s[i-1:i+1] == "AC":
        cnt += 1
    cnt_list.append(cnt)

for start, end in ranges:
    print(cnt_list[end-1] - cnt_list[start-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ranges = [list(map(int, input().split())) for _ in range(q)]

for start, end in ranges:
    print(s.count('AC', start-1, end))


Fixed submission:
n, q = map(int, input().split())
s = input()
ranges = [list(map(int, input().split())) for _ in range(q)]

cnt = 0
cnt_list = []
# インデックスの要素 = インデックスから始まる文字が"AC"
for i in range(n):
    if i < 1:
        cnt_list.append(0)
        continue
    if s[i-1:i+1] == "AC":
        cnt += 1
    cnt_list.append(cnt)

for start, end in ranges:
    print(cnt_list[end-1] - cnt_list[start-1])
Buggy python submission (verdict: Runtime Error):
from collections import deque
s = deque(input())

cnt = 0
i = 1

while i < len(s):
    while len(s) != 0 and s[i - 1] != s[i]:
        s.pop(i)
        s.pop(i - 1)
        i -= 1
        cnt += 2
    i += 1

print(cnt)


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

if B // A < C:
    print(B // A)
else:
    print(C)
Buggy python submission (verdict: Runtime Error):
s = list(input())

cnt = 0
i = 0

while i < len(s):
    while len(s) != 0 and s[i] != s[i + 1]:
        s.pop(i)
        s.pop(i)
        cnt += 2
        i -= 1
    i += 1

print(cnt)


Fixed submission:
s = list(input())

# Note: init
# cnt = 0
# i = 1
#
# while i < len(s):
#     while len(s) != 0 and s[i - 1] != s[i]:
#         s.pop(i)
#         s.pop(i - 1)
#         i -= 1
#         cnt += 2
#     i += 1
#
# print(cnt)


cnt = min(s.count("0"), s.count("1"))
print(cnt*2)

Buggy python submission (verdict: Runtime Error):
from collections import deque
s = deque(input())

cnt = 0
i = 1

while i < len(s):
    while len(s) != 0 and s[i - 1] != s[i]:
        s.pop(i)
        s.pop(i - 1)
        i -= 1
        cnt += 2
    i += 1

print(cnt)


Fixed submission:
s = list(input())

# Note: init
# cnt = 0
# i = 1
#
# while i < len(s):
#     while len(s) != 0 and s[i - 1] != s[i]:
#         s.pop(i)
#         s.pop(i - 1)
#         i -= 1
#         cnt += 2
#     i += 1
#
# print(cnt)


cnt = min(s.count("0"), s.count("1"))
print(cnt*2)

Buggy python submission (verdict: Runtime Error):
from collections import deque
s = deque(input())

cnt = 0
i = 1

while i < len(s):
    while len(s) != 0 and s[i - 1] != s[i]:
        s.pop(i)
        s.pop(i - 1)
        i -= 1
        cnt += 2
    i += 1

print(cnt)


Fixed submission:
s = list(input())

# Note: init
# cnt = 0
# i = 1
#
# while i < len(s):
#     while len(s) != 0 and s[i - 1] != s[i]:
#         s.pop(i)
#         s.pop(i - 1)
#         i -= 1
#         cnt += 2
#     i += 1
#
# print(cnt)


cnt = min(s.count("0"), s.count("1"))
print(cnt*2)

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

cnt = 0
i = 1

while i < len(s):
    while len(s) != 0 and s[i - 1] != s[i]:
        s.pop(i)
        s.pop(i - 1)
        i -= 1
        cnt += 2
    i += 1

print(cnt)


Fixed submission:
s = list(input())

# Note: init
# cnt = 0
# i = 1
#
# while i < len(s):
#     while len(s) != 0 and s[i - 1] != s[i]:
#         s.pop(i)
#         s.pop(i - 1)
#         i -= 1
#         cnt += 2
#     i += 1
#
# print(cnt)


cnt = min(s.count("0"), s.count("1"))
print(cnt*2)
Buggy python submission (verdict: Runtime Error):
count_50 = int(inpiut())
count_100 = int(inpiut())
count_500 = int(inpiut())
target = int(input())
count = 0

for num_50 in range(0, count_50 + 1):
    total = num_50 * 50
    if total == target:
        count += 1
        continue
    for num_100 in range(0, count_100 + 1):
        total_2 = num_50 * 50 + num_100 * 100
        if total_2 == target:
            count += 1
            continue
        for num_500 in range(0, count_500+1):
            total_3 = num_50 * 50 + num_100 * 100 + num_500 * 500
            if total_3 == target:
                count += 1
                continue
print(count)

Fixed submission:
count_500 = int(input())
count_100 = int(input())
count_50 = int(input())
target = int(input())
count = 0

for num_50 in range(0, count_50 + 1):
    total = num_50 * 50
    if total == target:
        count += 1
        continue
    for num_100 in range(0, count_100 + 1):
        total_2 = num_50 * 50 + num_100 * 100
        if total_2 == target:
            count += 1
            continue
        for num_500 in range(0, count_500+1):
            total_3 = num_50 * 50 + num_100 * 100 + num_500 * 500
            if total_3 == target:
                count += 1
                continue
print(count)
Buggy python submission (verdict: Runtime Error):
from typing import *

a, b, c, d = list(input())

operators = ["+", "-"]

for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            equation = a+op1+b+op2+c+op3+d
            if eval(equation) == 7:
                print(equation+"=7")
                exit()




Fixed submission:
a, b, c, d = list(input())

operators = ["+", "-"]

for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            equation = a+op1+b+op2+c+op3+d
            if eval(equation) == 7:
                print(equation+"=7")
                exit()

Buggy python submission (verdict: Runtime Error):
a, b, c, d = input().split()

operators = ["+", "-"]

for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            equation = a+op1+b+op2+c+op3+d
            if eval(equation) == 7:
                print(equation+"=7")
                exit()

Fixed submission:
a, b, c, d = list(input())

operators = ["+", "-"]

for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            equation = a+op1+b+op2+c+op3+d
            if eval(equation) == 7:
                print(equation+"=7")
                exit()
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0

for x in range(0, K+1):
    for y in range(0, K+1):
        z = S-x-y
        if x + y + z == S and 0 <= z <= K:
            count += 1

print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0

for x in range(0, K+1):
    for y in range(0, K+1):
        z = S-x-y
        if 0 <= z <= K:
            count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0

for x in range(0, K+1):
    for y in range(0, K+1):
        for z in range(0, K+1):
            if x + y+ z == S:
                count += 1

print(count)

Fixed submission:
K, S = map(int, input().split())
count = 0

for x in range(0, K+1):
    for y in range(0, K+1):
        z = S-x-y
        if 0 <= z <= K:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
h,a = map(int,input().split())
if h%a == 0:
    print(h//a)
else:
print((h//a)+1)

Fixed submission:
h,a = map(int,input().split())
if h%a == 0:
    print(h//a)
else:
    print((h//a)+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
for i in range(len(s)):
  if s[i] != s[k-1]:
    s[i] = "*"
print(s)


Fixed submission:
input()
S=input()
k=int(input())
for s in S:print(s if s==S[k-1] else "*",end="")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
for i in range(len(s))
	if s[i] != s[k-1]
  		s[i] = "*"
print(s)


Fixed submission:
input()
S=input()
k=int(input())
for s in S:print(s if s==S[k-1] else "*",end="")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
for i in range(length(s))
	if s[i] != s[k-1]
  		s[i] = "*"
print(s)


Fixed submission:
input()
S=input()
k=int(input())
for s in S:print(s if s==S[k-1] else "*",end="")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
for i in range(length(s))
	if s[i] != s[k]
  		s[i] = "*"
print(s)


Fixed submission:
input()
S=input()
k=int(input())
for s in S:print(s if s==S[k-1] else "*",end="")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
for i in range(length(s))
	if s[i] != s[k]
  		s[i] = *
print(s)


Fixed submission:
input()
S=input()
k=int(input())
for s in S:print(s if s==S[k-1] else "*",end="")

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
for i in range(length(s))
	if s[i] != s[k]
  		s[i] = *


Fixed submission:
input()
S=input()
k=int(input())
for s in S:print(s if s==S[k-1] else "*",end="")
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print((a*b)//2)


Fixed submission:
a,b,c = map(int,input().split())
print(a*b//2)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b//2)


Fixed submission:
a,b,c = map(int,input().split())
print(a*b//2)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b/2)

Fixed submission:
a,b,c = map(int,input().split())
print(a*b//2)

Buggy python submission (verdict: Runtime Error):
a = int(input)
b = int(input)
print(a*b/2)

Fixed submission:
a,b,c = map(int,input().split())
print(a*b//2)
Buggy python submission (verdict: Runtime Error):
n,t = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(n)]
ls1 = []
for i in range(n):
    if ls[i][1] <= t:
        ls1.append(ls[i][0])
print(min(ls1))


Fixed submission:
n,t = map(int,input().split())
ls = [list(map(int,input().split())) for i in range(n)]
ls1 = []
for i in range(n):
    if ls[i][1] <= t:
        ls1.append(ls[i][0])
if len(ls1) == 0:
    print("TLE")
else:
    print(min(ls1))
Buggy python submission (verdict: Runtime Error):
a,b,c,d=[int(input()) for i in range(4)]
ls = list[a+c,a+d,b+c,b+d]
print(min(ls))

Fixed submission:
a,b,c,d=[int(input()) for i in range(4)]
print(min(a+c,a+d,b+c,b+d))
Buggy python submission (verdict: Runtime Error):
n = int(input())
lsn=[int(input()) for i in range(n)]
m = int(input())
lsm=[int(input()) for i in range(m)]
ls = []
for i in range(n):
  ls.append(lsn.count(lsn[i])-lsm.count(lsn[i]))
if max(ls) <= 0:
  print(0)
else:
  print(max(ls))

Fixed submission:
n = int(input())
lsn=[(input()) for i in range(n)]
m = int(input())
lsm=[(input()) for i in range(m)]
ls = []
for i in range(n):
  ls.append(lsn.count(lsn[i])-lsm.count(lsn[i]))
if max(ls) <= 0:
  print(0)
else:
  print(max(ls))
Buggy python submission (verdict: Runtime Error):
n = input()
ls = [int(input()) for i in range(n)]
ls = list(set(ls))
print(len(ls))


Fixed submission:
n = int(input())
ls = [int(input()) for i in range(n)]
ls = set(ls)
print(len(ls))

Buggy python submission (verdict: Runtime Error):
n = input()
ls = [int(input()) for i in range(n)]
ls = set(ls)
print(len(ls))

Fixed submission:
n = int(input())
ls = [int(input()) for i in range(n)]
ls = set(ls)
print(len(ls))
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = 0
m = int(n**0.5)
for i in range(np.ceil(m)):
    if i**2 > n:
        break
    a += 1
print(a**2)

Fixed submission:
print(int(int(input())**.5)**2)
Buggy python submission (verdict: Runtime Error):
print("Yes" if input() == reversed(input()) else "No")

Fixed submission:
N = input()
print("Yes" if N[0] == N[2]  else "No")
Buggy python submission (verdict: Runtime Error):
a = input()
b = len(a)
b = b-2
print(a[0]+b+a[b+1])


Fixed submission:
a = input()
b = len(a)
print(a[0]+str(b-2)+a[b-1])

Buggy python submission (verdict: Runtime Error):
a = input()
b = len(a)
print(a[0]+(b-2)+a[b-1])

Fixed submission:
a = input()
b = len(a)
print(a[0]+str(b-2)+a[b-1])
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
A=a
B=b
if a>=k:
    A=a-k
elif a<k:
    B=b-(k-a)
    A=0
    if B<0
       　B=0
else:
    A=0
    B=0
    
print(A,B)

Fixed submission:
a,b,k=map(int,input().split())
#食べられた後のa
A=a
#食べられた後のb
B=b
K=k

if a>=k:
    A=a-k
    print(A,B)
elif a<k:
    B=b-(k-a)
    A=0
    if k-a>=b:
        B=0
    print(A,B)
else:
    A=0
    B=0
    print(A,B)

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
A=a
B=b
K=k

if a>=k:
    A=a-k
    print(A,B)
if a<k:
    B=b-(k-a)
    A=0
    if k-a>=b:
        B=0
    print(A,B)
else:
    A,B=0
    print(A,B)

Fixed submission:
a,b,k=map(int,input().split())
#食べられた後のa
A=a
#食べられた後のb
B=b
K=k

if a>=k:
    A=a-k
    print(A,B)
elif a<k:
    B=b-(k-a)
    A=0
    if k-a>=b:
        B=0
    print(A,B)
else:
    A=0
    B=0
    print(A,B)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N, A, B = map(int, input().split())
count = 0
while True:
    for i in range(A):
        N -= 1
        count += 1
        if N == 0:
            print(count)
            sys.exit()
    for j in range(B):
        N -= 1
        if N == 0:
            print(count)
            sys.exit()

Fixed submission:
N, A, B = map(int, input().split())
answer = N // (A+B) * A
remainder = N % (A+B)
answer += min(remainder, A)
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
A = list(map(int, input().split()))

for i in range(len(A)):
    for j in range(i+1, len(A)):
        if A[i] == A[j]:
            print('NO')
            sys.exit()

print('YES')


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
for i in range(N-1):
    if A[i] == A[i+1]:
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
ans = 1
flag = True
for i in range(1, N):
    for j in range(i-1, -1, -1):
        if P[j] < P[i]:
            flag = False

    if not flag:
        flag = True
    else:
        ans += 1 
print(ans)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ans = 0
mi = N
for i in range(N):
    mi = min(mi, P[i])
    if mi == P[i]: ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import sys
sys.setrecursionlimit(200000)
A, B = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

Fixed submission:
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(A, B))

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

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

def lcm(x, y):
    if x == 0 or y == 0:
        return 0
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

Fixed submission:
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(A, B))

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

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

Fixed submission:
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [int(i) for i in input().split()]
count = 0

for a in range(N):
    for b in range(a+1, N):
        for c in range(b+1, N):
            if L[a]>=L[b]+L[c] or L[b]>=L[c]+L[a] or L[c]>=L[a]+L[b]:
                pass
            else:
                count += 1

print(count)

Fixed submission:
import bisect
N = int(input())
L = [int(i) for i in input().split()]
L.sort()
count = 0
for a in range(N-2):
    for b in range(a+1, N-1):
        count += bisect.bisect_left(L, L[a]+L[b])-b-1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = [int(i) for i in input().split()]
move_old = 0
for i in range(0,len(H)):
    move_new = 0
    for j in range(i+1, len(H)):
        # print(i+j)
        if H[i] >= H[j]:
            move_new += 1
        else:
            break
        i = i + 1
    if move_old < move_new:
        move_old = move_new

print(move_old)

Fixed submission:
N = int(input())
H = [int(i) for i in input().split()]
ans = 0
tmp = 0
for i in range(0, N-1):
    if H[i] >= H[i+1]:
        tmp += 1
    else:
        tmp = 0
    ans = max(ans, tmp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if i + j + k == S:
                count += 1

print(count)


Fixed submission:
K, S = map(int, input().split())
count = 0
for i in range(K+1):
    for j in range(K+1):
        k = S - i - j
        if k >= 0 and k <= K:
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
    a,b=map(int,input().split())
    if b<a:
      print("No")
    else:
      print("Yes")

Fixed submission:
a,b=map(int,input().split())
if b<a:
	print("No")
else:
	print("Yes")