Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
A=input())
B=input())
C=input())

card={a:A,b:B,c:C}
answer=["a":"A","b":"B","c":"C"]
turn="a"

while True:
    if len(card[turn])==0:
        break
    next_turn=card[turn][0]
    card[turn]=card[turn][1:]
    turn=next_turn

print(answer[turn])

Fixed submission:
A=input()
B=input()
C=input()

card={"a":A,"b":B,"c":C}
answer={"a":"A","b":"B","c":"C"}
turn="a"

while True:
    if len(card[turn])==0:
        break
    next_turn=card[turn][0]
    card[turn]=card[turn][1:]
    turn=next_turn

print(answer[turn])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())

List=[]
for i in range(a):
    List.append(input())

print("".join(sorted(List)))

Fixed submission:
a,b,c,=map(int,input().split())
if a+b+c==17:
  print("YES")
else:
  print("NO")

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

List=[]
for i in range(a):
    List.append(input())

print("".join(sorted(List)))

Fixed submission:
a,b,c,=map(int,input().split())
if a+b+c==17:
  print("YES")
else:
  print("NO")

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

List=[]
for i in range(a):
    List.append(input)

print("".join(sorted(List)))

Fixed submission:
a,b,c,=map(int,input().split())
if a+b+c==17:
  print("YES")
else:
  print("NO")

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

List=[]
for i in range(a):
    List.append(input)

    print("".join(sorted(List)))

Fixed submission:
a,b,c,=map(int,input().split())
if a+b+c==17:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
List=[input() for i in range(a)]

print("".join(sorted(List)))

Fixed submission:
a,b,c,=map(int,input().split())
if a+b+c==17:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
k, x = int(input())
if k*500 >= x:
  print('Yes')
else:
  print('No')

Fixed submission:
k,x = map(int, input().split())
if k*500 >= x:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import math
n=list(map(int,input().split(' ')))
ans=(n[0]*n[1])//math.gcd(n[0],n[1])
print(ans)

Fixed submission:
n=list(map(int,input().split(' ')))
import fractions
ans=(n[0]*n[1]) // fractions.gcd(n[0],n[1])
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n=list(map(int,input().split()))
ans=(n[0]*n[1])//math.gcd(n[0],n[1])
print(ans)

Fixed submission:
n=list(map(int,input().split(' ')))
import fractions
ans=(n[0]*n[1]) // fractions.gcd(n[0],n[1])
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n=list(map(int,input().split(' ')))
ans=(n[0]*n[1])//math.gcd(n[0],n[1])
print(ans)

Fixed submission:
n=list(map(int,input().split(' ')))
import fractions
ans=(n[0]*n[1]) // fractions.gcd(n[0],n[1])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0
i=0
while i+1 <= len(a):
    if a[i]!=i+1:
        del a[i]
    else:
        i+=1
if len(a)==0:
    print(-1)
else:
    print(n-len(a))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
i = 0
while i + 1 <= len(a):
    #index+1がリストの要素と違ったら
    if a[i] != i + 1:
        #正しい要素があるか確認
        if i + 1 in a:
            #正しい要素の手前まで削除
            del a[i:a.index(i + 1)]
        #正しい要素がないなら全部削除
        else:
            del a[i:]
        
    #index+1がリストの要素と同じなら次の要素へ
    else:
        i += 1
#全部消しちゃったら不可能
if len(a) == 0:
  print(-1)
#残ってる要素を引いたら壊した数になる
else:
    print(n - len(a))
Buggy python submission (verdict: Runtime Error):
a,b = map(input().split())
ab = a + b
ab = int(ab)
if (ab**0.5).is_integer() == True:
  print('Yes')
else:
  print('No')

Fixed submission:
a,b = input().split()
ab = a + b
ab = int(ab)
if (ab**0.5).is_integer() == True:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
import itertools
N, K = map(int, input().split())
pair = itertools.combinations(list(map(int, input().split())), 2)
res = [i[0] * i[1] for i in pair]
res.sort()
if len(res) != 0:
    print(res[K-1])

Fixed submission:
A, B, C = map(int, input().split())
if A == B and A == C:
    print("No")
elif A == B or A == C or B == C:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import itertools
N, K = map(int, input().split())
pair = itertools.combinations(map(int, input().split()), 2)
res = [i[0] * i[1] for i in pair]
res.sort()
if len(res) != 0:
    print(res[K-1])

Fixed submission:
A, B, C = map(int, input().split())
if A == B and A == C:
    print("No")
elif A == B or A == C or B == C:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import itertools
N, K = map(int, input().split())
input_n = list(map(int, input().split()))
pair = itertools.combinations(input_n, 2)
res = [i[0] * i[1] for i in pair]
res.sort()
print(res[K-1])

Fixed submission:
A, B, C = map(int, input().split())
if A == B and A == C:
    print("No")
elif A == B or A == C or B == C:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
from collections import  Counter
N = int(input())
votes = [input() for i in range(N)]
count = dict(Counter(votes))
max_vote = max(count.values())
res = []
for i in count:
    if count[i] == max_vote:
        res.append(i)
        continue
res.sort()
for i in res:
    print(i)

Fixed submission:
A, B, C = map(int, input().split())
if A == B and A == C:
    print("No")
elif A == B or A == C or B == C:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
votes = [input() for i in range(N)]
votes_set = set(votes)
temp = {}
for i in votes_set:
    count = votes.count(i)
    if count in temp:
        temp[count].append(i)
    else:
        temp[votes.count(i)] = [i]
max_vote = max(temp.keys())
temp[max_vote].sort()
for i in temp[max_vote]:
    print(i)

Fixed submission:
from collections import  Counter
N = int(input())
votes = [input() for i in range(N)]
count = dict(Counter(votes))
max_vote = max(count.values())
res = []
for i in count:
    if count[i] == max_vote:
        res.append(i)
        continue
res.sort()
for i in res:
    print(i)
Buggy python submission (verdict: Runtime Error):
K = int(input("Enter k: "))
X = int(input("Enter x: "))

if K * 500 >= X:
    print("Yes")
else:
    print("No")


Fixed submission:
K, X = map(int, input().split())

if K*500 >= X:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
k = int(input("Enter k: "))
x = int(input("Enter x: "))
if (k * 500 > x):
    print("Yes")
else:
    print("No")


Fixed submission:
K, X = map(int, input().split())

if K*500 >= X:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

def solve(S, query):
    flag = False
    S = list(S)
    for q in query:
        command = q.split()
        T = int(command[0])
        if T == 1:
            flag = not flag
        elif T == 2:
            F = int(command[1])
            C = command[2]
            if (not flag and F == 1) or (flag and F == 2):
                S.insert(0, C)
            else:
                S.append(C)
    if flag:
        S.reverse()
    return ''.join(S)


def main():
    S = input()
    Q = int(input())
    query = [input() for n in range(Q)]
    print(solve(S, query))


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-

def main():
    S = input()
    Q = int(input())
    flag = False
    head = []
    tail = []
    for n in range(Q):
        query = input()
        if query[0] == '1':
            flag = not flag
        elif query[0] == '2':
            command = query.split()
            F = int(command[1])
            C = command[2]
            if (not flag and F == 1) or (flag and F == 2):
                head.append(C)
            else:
                tail.append(C)
    result = ''.join(reversed(head)) + S + ''.join(tail)
    if flag:
        result = result[::-1]
    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

def solve(S, query):
    for q in query:
        command = q.split()
        T = int(command[0])
        if T == 1:
            S = S[::-1]
        elif T == 2:
            F = int(command[1])
            C = command[2]
            if F == 1:
                S = C + S
            elif F == 2:
                S += C
    return S


def main():
    S = input()
    Q = int(input())
    query = [input() for n in range(Q)]
    print(solve(S, query))


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-

def main():
    S = input()
    Q = int(input())
    flag = False
    head = []
    tail = []
    for n in range(Q):
        query = input()
        if query[0] == '1':
            flag = not flag
        elif query[0] == '2':
            command = query.split()
            F = int(command[1])
            C = command[2]
            if (not flag and F == 1) or (flag and F == 2):
                head.append(C)
            else:
                tail.append(C)
    result = ''.join(reversed(head)) + S + ''.join(tail)
    if flag:
        result = result[::-1]
    print(result)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = [int(y) for y in input().split(' ')]
count = 0
while N >= A:
  count += 1
  N -= A+B
if A == 0:
  print(0)
elif N > 0:
  print(count*A + N)
else:
  print(count*A)

Fixed submission:
N, A, B = [int(y) for y in input().split(' ')]
count = N // (A+B)
residue = N % (A+B)
 
if A == 0:
  print(0)
elif residue > A:
  print(count*A + A)
elif residue > 0:
  print(count*A + residue)
else:
  print(count*A)
Buggy python submission (verdict: Runtime Error):
n = int(input())
 
numbers = list(map(int, input().split(' ')))
approved = False
 
for num in numbers:
  if (num % 2 == 0):
  	if (num % 3 == 0) or (num % 5 == 0):
      approved = True
      continue
  	else:
      approved = False
      print('DENIED')
      break
if approved:
  print('APPROVED')

Fixed submission:
n = int(input())
 
numbers = list(map(int, input().split(' ')))
approved = True
 
for num in numbers:
  if (num % 2 == 0):
    if (num % 3 == 0) or (num % 5 == 0):
      approved = True
      continue
    else:
      approved = False
      print('DENIED')
      break
if approved:
  print('APPROVED')

Buggy python submission (verdict: Runtime Error):
n = int(input())
 
numbers = list(map(int, input().split(' ')))
approved = False
 
for num in numbers:
  if (num % 2 == 0):
  	if (num % 3 == 0) or (num % 5 == 0):
    	approved = True
    	continue
  	else:
    	approved = False
    	print('DENIED')
    	break
if approved:
  print('APPROVED')

Fixed submission:
n = int(input())
 
numbers = list(map(int, input().split(' ')))
approved = True
 
for num in numbers:
  if (num % 2 == 0):
    if (num % 3 == 0) or (num % 5 == 0):
      approved = True
      continue
    else:
      approved = False
      print('DENIED')
      break
if approved:
  print('APPROVED')

Buggy python submission (verdict: Runtime Error):
n = int(input())

numbers = map(int, input().split(' '))
approved = False

for num in numbers[1::2]:
  if (num % 3 == 0) or (num % 5 == 0):
    approved = True
    continue
  else:
    approved = False
    print('DENIED')
    break
if approved:
  print('APPROVED')

Fixed submission:
n = int(input())
 
numbers = list(map(int, input().split(' ')))
approved = True
 
for num in numbers:
  if (num % 2 == 0):
    if (num % 3 == 0) or (num % 5 == 0):
      approved = True
      continue
    else:
      approved = False
      print('DENIED')
      break
if approved:
  print('APPROVED')
Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
#a, b = map(int, input().split())
#a, b, c, x = map(int, [input() for i in range(4)])

N, M = map(int, input().split())
L = []
R = []
LR_and = []
sum_list = []

for i in range(M):
    LR = input().split()
    L.append(int(LR[0]))
    R.append(int(LR[1]))

for i in range(M):
    for j in range(R[i] - L[i] + 1):
        LR_and.append(L[i] + j)

for i in range(len(LR_and)):
    if LR_and.count(LR_and[i]) == M:
        sum_list.append(str(LR_and[i]))

final_list = list(set(sum_list))

print(len(final_list))

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
LR_and = []
sum_list = []

for i in range(M):
    LR = input().split()
    L.append(int(LR[0]))
    R.append(int(LR[1]))

max_L = max(L)
min_R = min(R)

if max_L <= min_R:
    print(min_R - max_L + 1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import functools
import math

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

max_koyaku_num = functools.reduce(math.gcd, a)

print(max_koyaku_num)

Fixed submission:
import functools

def gcd(num1, num2):
    r = num1 % num2
    while (r > 0):
        num1 = num2
        num2 = r
        r = num1 % num2
    return num2

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

max_koyaku_num = functools.reduce(gcd, a)

print(max_koyaku_num)

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

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

max_koyaku_num = functools.reduce(math.gcd, a)  #最大公約数って英語でなんて言うん？

print(max_koyaku_num)

Fixed submission:
import functools

def gcd(num1, num2):
    r = num1 % num2
    while (r > 0):
        num1 = num2
        num2 = r
        r = num1 % num2
    return num2

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

max_koyaku_num = functools.reduce(gcd, a)

print(max_koyaku_num)
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
ball_str=""
for i in range(10**100):
    if len(ball_str)<=N:
        ball_str+="b"*A+"r"*B
    else:
        break
print(ball_str[:N].count("b"))

Fixed submission:
N,A,B = map(int,input().split())
set_cnt=N//(A+B)
amari=N%(A+B)
if amari > A:
    amari_A = A
else:
    amari_A = amari
print(A*set_cnt+amari_A)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
cnt=True
for i in range(Q):
    query_list=input().split()
    if query_list[0] == "1":
        cnt=(cnt==False)
    else:
        if cnt:
            if query_list[1] == "1":
                S=query_list[2]+S
            else:
                S+=query_list[2]
        else:
            if query_list[1] == "1":
                S+=query_list[2]
            else:
                S=query_list[2]+S
if cnt:
    print(S)
else:
    print(S[::-1])

Fixed submission:
from collections import deque
S = deque(input().rstrip())
Q=int(input())
cnt=True
for i in range(Q):
    query_list=input().split()
    if query_list[0] == "1":
        cnt=(cnt==False)
    else:
        if cnt:
            if query_list[1] == "1":
                S.appendleft(query_list[2])
            else:
                S.append(query_list[2])
        else:
            if query_list[1] == "1":
                S.append(query_list[2])
            else:
                S.appendleft(query_list[2])
if cnt:
    print("".join(S))
else:
    print("".join(reversed(S)))

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
cnt=0
for i in range(Q):
    query_list=input().split()
    if query_list[0] == "1":
        cnt+=1
    else:
        if cnt%2==0:
            if query_list[1] == "1":
                S=query_list[2]+S
            else:
                S+=query_list[2]
        else:
            if query_list[1] == "1":
                S+=query_list[2]
            else:
                S=query_list[2]+S
if cnt%2==0:
    print(S)
else:
    print(S[::-1])

Fixed submission:
from collections import deque
S = deque(input().rstrip())
Q=int(input())
cnt=True
for i in range(Q):
    query_list=input().split()
    if query_list[0] == "1":
        cnt=(cnt==False)
    else:
        if cnt:
            if query_list[1] == "1":
                S.appendleft(query_list[2])
            else:
                S.append(query_list[2])
        else:
            if query_list[1] == "1":
                S.append(query_list[2])
            else:
                S.appendleft(query_list[2])
if cnt:
    print("".join(S))
else:
    print("".join(reversed(S)))

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
for i in range(Q):
    query_list=input().split()
    if query_list[0] == "1":
        S=S[::-1]
    else:
        if query_list[1] == "1":
            S=query_list[2]+S
        else:
            S+=query_list[2]
print(S)

Fixed submission:
from collections import deque
S = deque(input().rstrip())
Q=int(input())
cnt=True
for i in range(Q):
    query_list=input().split()
    if query_list[0] == "1":
        cnt=(cnt==False)
    else:
        if cnt:
            if query_list[1] == "1":
                S.appendleft(query_list[2])
            else:
                S.append(query_list[2])
        else:
            if query_list[1] == "1":
                S.append(query_list[2])
            else:
                S.appendleft(query_list[2])
if cnt:
    print("".join(S))
else:
    print("".join(reversed(S)))
Buggy python submission (verdict: Runtime Error):
input_number = int(input())
input_str = input()
abc_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
abc_list = abc_list + abc_list
for i in len(input_str):
    output_str += abc_list[abc_list.index(input_str[i]) + input_number]
print(output_str)

Fixed submission:
input_number = int(input())
input_str = input()
abc_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
abc_list = abc_list + abc_list
output_str = ""
for i in range(len(input_str)):
    output_str += abc_list[abc_list.index(input_str[i]) + input_number]
print(output_str)

Buggy python submission (verdict: Runtime Error):
input_number = int(input())
input_str = input()
abc_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
abc_list = abc_list + abc_list
for i in len(input_str):
    output_str += abc_list[abc_list.index(input_str[i]) + input_number]

Fixed submission:
input_number = int(input())
input_str = input()
abc_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
abc_list = abc_list + abc_list
output_str = ""
for i in range(len(input_str)):
    output_str += abc_list[abc_list.index(input_str[i]) + input_number]
print(output_str)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A > 9 or B > 9:
  print(-1)
else:
  print(A*B)

Fixed submission:
A,B = input().split()
A = int(A)
B = int(B)
if A > 9 or B > 9:
  print(-1)
else:
  print(A*B)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
max_int = int(N**0.5)
for v in range(max_int,N+1):
    if N % v == 0:
        w = int(N/v)
        print(v+w-2)
        break
    else:
        pass

Fixed submission:
input_number = int(input())
walk_count = int(1000000000000)
number_list_A = range(1,1000001)
#number_list_B = number_list_A

for a in number_list_A:
	if input_number % a == 0:
		b = input_number / a
		new_walk_count = int(a + b - 2)
	if new_walk_count < walk_count:
		walk_count = new_walk_count
	new_walk_count = 1000000000000

print(walk_count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
value_list = input().split()
value_list.sort()
i = 0

for i in range(N):
	if i == 0:
		new_value = int(value_list[i])
	else:
		new_value = (new_value + int(value_list[i])) / 2
    i += 1

print(new_value)

Fixed submission:
a = int(input())
s = input()
if a < 3200:
  s = 'red'
print(s)

Buggy python submission (verdict: Runtime Error):
N = int(input())
value_list = input().split()
value_list.sort()
i = 0
#value_list.reverse()
#print(value_list)
for i in range(N):
	if i == 0:
		new_value = int(value_list[i])
	else:
		new_value = (new_value + int(value_list[i])) / 2

print(new_value)

Fixed submission:
a = int(input())
s = input()
if a < 3200:
  s = 'red'
print(s)
Buggy python submission (verdict: Runtime Error):
N = int(input())
price_list = []
append = pricelist.append
for i in range(N):
	p = int(input)
    append(p)
pricelist.sort(reverse=True)
pricelist[0] = pricelist[0] / 2
print(sum(pricelist))

Fixed submission:
N = int(input())
price_list = []
append = price_list.append
for i in range(N):
    p = int(input())
    append(p)
price_list.sort(reverse=True)
price_list[0] = price_list[0] // 2
print(sum(price_list))
Buggy python submission (verdict: Time Limit Exceeded):
import math

N, M = list(map(int, input().split()))
price = list(map(int, input().split()))
total = sum(price)
for i in range(M):
    max_index = price.index(max(price))
    discount = math.ceil(max(price) / 2)
    total -= discount
    price[max_index] -= discount
print(total)

Fixed submission:
import heapq

N, M = list(map(int, input().split()))
price = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(price)

for i in range(M):
    max_price = -(heapq.heappop(price))
    new_price = max_price // 2
    heapq.heappush(price, -(max_price // 2))

print(-(sum(price)))

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

for i in range(M):
    price.sort(reverse=True)
    price[0] = math.floor(price[0] / 2)
print(sum(price))

Fixed submission:
import heapq

N, M = list(map(int, input().split()))
price = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(price)

for i in range(M):
    max_price = -(heapq.heappop(price))
    new_price = max_price // 2
    heapq.heappush(price, -(max_price // 2))

print(-(sum(price)))
Buggy python submission (verdict: Runtime Error):
A, B, C = sorted(map(int, input().split()))

def calculate(P, Q, R):
    num = 0
    if abs(P - Q) % 2 == 0:
        num += abs(P - Q) // 2
    else:
        num += 1 + (abs(P - Q) + 1) // 2
        P += 1
        R += 1

    if  P - R >= 0:
        if abs(P - R) % 2 == 0:
            num += abs(P - R) // 2
        else:
            num += 1 + (abs(P - R) + 1) // 2

    else:
        num += abs(P - R)

    return num

ans = min(calculate(C, B, A), calculate(C, A, B), calculate(B, A, C))

print(ans)

Fixed submission:
S = input()
if len(S) == 3 and "a" in S and "b" in S and "c" in S:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
A, B, C = sorted(map(int, input().split()))

def calculate(P, Q, R):
    num = 0
    if abs(P - Q) % 2 == 0:
        num += abs(P - Q) // 2
    else:
        num += 1 + (abs(P - Q) + 1) // 2
        P += 1
        R += 1

    if abs(P - R) % 2 == 0:
        num += abs(P - R) // 2
    else:
        num += 1 + (abs(P - R) + 1) // 2

    return num

ans = min(calculate(C, B, A), calculate(C, A, B), calculate(B, A, C))

print(ans)

Fixed submission:
S = input()
if len(S) == 3 and "a" in S and "b" in S and "c" in S:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
m = int(input())
return 24-m+24

Fixed submission:
m = int(input())
print(24-m+24)

Buggy python submission (verdict: Runtime Error):
m = int(input())
return 24-m

Fixed submission:
m = int(input())
print(24-m+24)