Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import factorial

N, A, B = map(int, input().split())
V = sorted(list(map(int, input().split())), reverse=True)

print(sum(V[:A]) / A)
if V[0] == V[A - 1]:
    n = sum([1 for v in V if v == V[0]])
    print(sum([factorial(n) // factorial(r) // factorial(n - r)
               for r in range(A, B + 1)]))
else:
    n = sum([1 for v in V if v == V[A - 1]])
    r = sum([1 for v in V[:A] if v == V[A - 1]])
    print(factorial(n) // factorial(r) // factorial(n - r))


Fixed submission:
from math import factorial

N, A, B = map(int, input().split())
V = sorted(list(map(int, input().split())), reverse=True)

print(sum(V[:A]) / A)
if V[0] == V[A - 1]:
    n = sum([1 for v in V if v == V[0]])
    print(sum([factorial(n) // factorial(r) // factorial(n - r)
               for r in range(A, min(n, B) + 1)]))
else:
    n = sum([1 for v in V if v == V[A - 1]])
    r = sum([1 for v in V[:A] if v == V[A - 1]])
    print(factorial(n) // factorial(r) // factorial(n - r))
Buggy python submission (verdict: Runtime Error):
import math

n, m = map(int, input().split())
A = 0
arr = [int(x) for x in input().split()]
A = sum(arr)
x = A/(4 * m)
count = 0
for i in range(n):
	if arr[m] >= x:
		count +=1
	else: break
if count >= m:
	print("Yes")
else: print("No")



Fixed submission:
n, m = map(int, input().split())
A = 0
arr = [int(i) for i in input().split() ]
arr.sort(reverse = True)
A = sum(arr)
x = A/(4 * m)
count = 0
for i in arr:
	if i >= x:
		count +=1
	else:
		break

if count >= m:
	print("Yes")
else: print("No")

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

n, m = map(int, input().split())
sum = 0
arr = [int(x) for x in input().split()]
for i in range(n):
	sum += arr[i]
x = math.ceil(sum/(4 * m))
count = 0
for i in range(m):
	if arr[m] >= x:
		count +=1
	else: break
if count >= m:
	print("Yes")
else: print("No")



Fixed submission:
n, m = map(int, input().split())
A = 0
arr = [int(i) for i in input().split() ]
arr.sort(reverse = True)
A = sum(arr)
x = A/(4 * m)
count = 0
for i in arr:
	if i >= x:
		count +=1
	else:
		break

if count >= m:
	print("Yes")
else: print("No")

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
sum = 0
arr = [int(x) for x in input().split()]
for i in range(n):
	sum += arr[i]
x = sum/(4 * m)
count = 0
for i in range(m):
	if arr[m] >= x:
		count +=1
	else: break
if count >= m:
	print("Yes")
else: print("No")



Fixed submission:
n, m = map(int, input().split())
A = 0
arr = [int(i) for i in input().split() ]
arr.sort(reverse = True)
A = sum(arr)
x = A/(4 * m)
count = 0
for i in arr:
	if i >= x:
		count +=1
	else:
		break

if count >= m:
	print("Yes")
else: print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt = (n // 1000) * 2000
n -= (n // 1000) * 1000
cnt += (n // 5) * 5
print(cnt)

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
	print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt = (n // 1000) * 2000
n -= (n // 1000) * 1000
cnt += (n // 5) * 5
print(cnt)

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
a=set(map(int,input().split()))
if len(set)==2:
  print("Yes")
else:
  print("No")
  

Fixed submission:
s = set(map(int, input().split()))
if len(s) == 2:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
lst=set(map(int,input().split(" ")))
if len(set)==2:
  print("Yes")
else:print("No")

Fixed submission:
s = set(map(int, input().split()))
if len(s) == 2:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
n=int(input())
lst=list(map(int,input().split()))

for i in range(0,n):
    if lst[i]%2==0:
        if lst[i]%3==0 or lst[i]%5==0:
            x=1
            
        else: x=0
if x==1:print("APPROVED")
else: print("DENIED")

Fixed submission:
s = set(map(int, input().split()))
if len(s) == 2:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
ans=[]
for i in range(0,3):
    ele=int(input())
    ans.append(ele)
    
anns=set(ans)
if len(anns)==2:
    print("Yes")
else: print("No")

Fixed submission:
s = set(map(int, input().split()))
if len(s) == 2:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a-=1
else:  b-=1
print(a, b)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a-= 1
else: b -= 1
print(a, b)

Buggy python submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a-=1
else:
    b-=1
print(a, b)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a-= 1
else: b -= 1
print(a, b)

Buggy python submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a-=1
elif:b-=1
print(a, b)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a-= 1
else: b -= 1
print(a, b)

Buggy python submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a-=
elif:b-=
print(a, b)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a-= 1
else: b -= 1
print(a, b)

Buggy python submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a--
elif u==t:
    b--
print("{} {}".format(a,b))

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a-= 1
else: b -= 1
print(a, b)

Buggy python submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a--
elif u==t:
    b--
print({} {},format(a,b))

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a-= 1
else: b -= 1
print(a, b)
Buggy python submission (verdict: Runtime Error):
s=input()
for i in len(s):
    s[i]="x"
print(s)

Fixed submission:
s=len(input())
print("x"*s)
Buggy python submission (verdict: Runtime Error):
n=map(int,input())
lst=len(set(map(int,input(split))))
if n==lst:
    print("YES")
else:  print("NO")

Fixed submission:
n=input()
lst=input().split()
if len(lst)==len(set(lst)):
    print("YES")
else: print("NO")
Buggy python submission (verdict: Runtime Error):
n=int(input())
text=[input() for i in range(n)]
print("".join(sorted(text)))

Fixed submission:
ans=list(map(int,input().split()))
if ans.count(5)==2 and ans.count(7)==1:
    print("YES")
else: print("NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
text=[input() for i in range(n)]
print("".join(sorted(text)))

Fixed submission:
ans=list(map(int,input().split()))
if ans.count(5)==2 and ans.count(7)==1:
    print("YES")
else: print("NO")
Buggy python submission (verdict: Runtime Error):
n=int(input())
text=[input() for i in range(n)]
print("".join(sorted(text)))

Fixed submission:
n,l=map(int,input().split())
text=[input() for i in range(n)]
print("".join(sorted(text)))

Buggy python submission (verdict: Runtime Error):
n=int(input())
text=[input() for i in range(n)]
print("".join(sorted(text)))

Fixed submission:
n,l=map(int,input().split())
text=[input() for i in range(n)]
print("".join(sorted(text)))
Buggy python submission (verdict: Time Limit Exceeded):
# B
R, G, B = map(int, input().split())
K = int(input())
ans = 'No'

num = 0

while (True):
    if  (num == K):
        break
        
    if (R > G):
        G *= 2
        num += 1
        
    if (R < G):
        break
    
while (True):
    if  (num == K):
        break
        
    if (G > B):
        B*= 2
        num += 1
        
    if (G < B):
        break

if (R < G and G < B):
    ans = 'Yes'
    
print(ans)

Fixed submission:
# B
R, G, B = map(int, input().split())
K = int(input())
ans = 'No'

num = 0

while (True):
    if  (num == K):
        break
        
    if (R >= G):
        G *= 2
        num += 1
        
    if (R < G):
        break
    
while (True):
    if  (num == K):
        break
        
    if (G >= B):
        B *= 2
        num += 1
        
    if (G < B):
        break

if (R < G and G < B):
    ans = 'Yes'
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# C
N, K = map(int, input().split())
A = list(map(int, input().split()))

num = 1
cnt = 0
lst = []
for i in range(N):
    if (i < K):
        num *= A[i]
    else:
        lst.append(num)
        num = (num // A[cnt]) * A[i]
        cnt += 1
lst.append(num)

for i in range(len(lst) - 1):
    if (lst[i] < lst[i+1]):
        print('Yes')
    else:
        print('No')

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

cnt = 0
for i in range(K, N):
    if (A[cnt] < A[i]):
        print('Yes')
    else:
        print('No')
    cnt += 1
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = lsit(map(int,input().split()))

stack = [a[0]]
s = 0
for i in range(1,n):
    if a[i]<stack[-1]:
        s = s + abs(a[i] - stack[-1])
    else:
        stack.append(a[i])
print(s)

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

stack = [a[0]]
s = 0
for i in range(1,n):
    if a[i]<stack[-1]:
        s = s + abs(a[i] - stack[-1])
    else:
        stack.append(a[i])
print(s)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
for i in range(n-1,-1,-1):
    if a[i]<a[i-1]:
        s = s + abs(a[i] - a[i-1])
print(s)

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

stack = [a[0]]
s = 0
for i in range(1,n):
    if a[i]<stack[-1]:
        s = s + abs(a[i] - stack[-1])
    else:
        stack.append(a[i])
print(s)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
for i in range(0,N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (A[i]!=A[k]!=A[j]):
        if (A[i]+A[j])>A[k]:
          cnt+=1
        
print(cnt)

Fixed submission:
s = input()
if s == 'RRR':
  print(3)
elif s=='RSR' or s=='SRS' or s=='SSR' or s=='RSS':
  print(1)
elif s == s=='RRS' or s=='SRR':
  print(2)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
cnt = 0
A.sort()
for i in range(0,N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (A[i]+A[j])>A[k] and (A[j]+[k])>A[i] and (A[i]+A[k])>A[j] and 
      A[i]!=A[k] and A[j]!=A[k] and A[i]!=A[j]:
        cnt+=1
        
print(cnt)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
for i in range(0,N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (A[i]!=A[j]!=A[k]):
        if (A[i]+A[j])>A[k]:
          cnt+=1
        
print(cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(0,N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if (A[i]+A[j])>A[k] and (A[j]+[k])>A[i] and (A[i]+A[k])>A[j] and 
      A[i]!=A[k] and A[j]!=A[k] and A[i]!=A[j]:
        cnt+=1
        
print(cnt)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
cnt = 0
for i in range(0,N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if (A[i]!=A[j]!=A[k]):
        if (A[i]+A[j])>A[k]:
          cnt+=1
        
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s=[input() for _ in range(n)]
m = int(input())
t=[input() for _ in range(m)]
 
res=0
for i in set(s):
    res=max(s.count(i)-t.count(i),ans)
print(res)

Fixed submission:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
 
res=0
for i in set(s):
    res=max(s.count(i)-t.count(i),res)
print(res)

Buggy python submission (verdict: Runtime Error):
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
 
res=0
for i in set(s):
    res=max(s.count(i)-t.count(i),ans)
print(res)

Fixed submission:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
 
res=0
for i in set(s):
    res=max(s.count(i)-t.count(i),res)
print(res)
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
s = 0
for i in range(n+1):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s = s+1
print(s)

Fixed submission:
n, d = map(int, input().split())
s = 0
for i in range(n):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s += 1
print(s)

Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
s == 0
for i in range(n+1):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s = s+1
print(s)

Fixed submission:
n, d = map(int, input().split())
s = 0
for i in range(n):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s += 1
print(s)

Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
s == 0
for i in range(n+1):
	x, y = map(int,input().split())
	if x**2+y**2 <= d**2:
		s = s+1
print(s)

Fixed submission:
n, d = map(int, input().split())
s = 0
for i in range(n):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s += 1
print(s)

Buggy python submission (verdict: Runtime Error):
n, d = map(int,input().split())
s == 0
for i in range(n):
	x, y = map(int,input().split())
	if x**2+y**2 <= d**2:
		s = s+1
	else:
			s = s
print(s)

Fixed submission:
n, d = map(int, input().split())
s = 0
for i in range(n):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s += 1
print(s)

Buggy python submission (verdict: Runtime Error):
n, d = map(int,input().split())
s == 0
for i in range(n):
	x, y = map(int,input().split())
	if x**2+y**2 <= d**2:
		s = s+1
		else:
			s = s
print(s)

Fixed submission:
n, d = map(int, input().split())
s = 0
for i in range(n):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s += 1
print(s)

Buggy python submission (verdict: Runtime Error):
n, d = map(int,input().split())
s == 0
for i in range(n):
	x, y = map(int,input().split())
	if x**2 + y**2 <= d**2:
		s = s + 1
		else:
			s = s
print(s)

Fixed submission:
n, d = map(int, input().split())
s = 0
for i in range(n):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s += 1
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
s = 7
if k%2 == 0 or k%5 == 0:
	print(-1)
else:
	while s%k != 0:
		s = 10*s+7
	s = str(s)
	print(len(s))

Fixed submission:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
s = 7
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	while s%k != 0:
		s = 10*s+7
	s = str(s)
	print(len(s))

Fixed submission:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())
s = 7
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	while s%k != 0:
		s = 10*s+7
		s = str(s)
	print(len(s))

Fixed submission:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())
s = 7
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	while s%k != 0:
		s = 10*s+7
	print(len(s))

Fixed submission:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	s = 7
	while s%k != 0:
		s = 10*s+7
	print(len(s))

Fixed submission:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	s = 7
	while s%k != 0:
		s = 10*s+7
	print(len(s))

Fixed submission:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())
if k%2 = 0:
	print(-1)
elif k%5 = 0:
	print(-1)
else:
	s = 7
	while s%k != 0:
		s = 10*s+7
	print(len(s))

Fixed submission:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().ssplit())
print(a * b)


Fixed submission:
a, b = map(int, input().split())
print(a * b)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
if len(t - s) == 1:
	print("Yes")
else:
	print("No")

Fixed submission:
s = input()
t = input()

same = 0
for i in range(len(s)):
	if s[i] == t[i]:
		same += 1

if same == len(s) and len(t) - len(s) == 1:
	print("Yes")

else:
	print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
a = s[i] == t[i]
b = len(t) - len(s) == 1
if for i in range(len(s)):
  a and b:
print("Yes")
else:
  print("No")


Fixed submission:
s = input()
t = input()

same = 0
for i in range(len(s)):
	if s[i] == t[i]:
		same += 1

if same == len(s) and len(t) - len(s) == 1:
	print("Yes")

else:
	print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
a = for i in range(len(s)):
  s[i] == t[i]
b = len(t) - len(s) == 1
if a and b:
  print("Yes")
else:
  print("No")


Fixed submission:
s = input()
t = input()

same = 0
for i in range(len(s)):
	if s[i] == t[i]:
		same += 1

if same == len(s) and len(t) - len(s) == 1:
	print("Yes")

else:
	print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
a = for i in range(len(s)):
  s[i] == t[i]

if len(s) - len(t) == -1 and a:
  print("yes")
else:
  print("no")

Fixed submission:
s = input()
t = input()

same = 0
for i in range(len(s)):
	if s[i] == t[i]:
		same += 1

if same == len(s) and len(t) - len(s) == 1:
	print("Yes")

else:
	print("No")

Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())
if len(t) - len(s) == 1 and for i in range(len(t)):
  s[i] == t[i] 
  print("yes")
else:
  print("no")

Fixed submission:
s = input()
t = input()

same = 0
for i in range(len(s)):
	if s[i] == t[i]:
		same += 1

if same == len(s) and len(t) - len(s) == 1:
	print("Yes")

else:
	print("No")
Buggy python submission (verdict: Runtime Error):
x, y, z = map(input().split(,))
print(x y z)

Fixed submission:
x, y, z = input().split(",")
print(x, y, z)
Buggy python submission (verdict: Time Limit Exceeded):
import copy

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

INF = 10 ** 8


def rec(rest_ope, now_d, now_hand):

    if rest_ope == 0:
        return sum(now_hand)

    max_price = -INF

    if len(now_d) > 0:
        left_d = copy.copy(now_d)
        left_hand = copy.copy(now_hand)
        left_hand.append(left_d.pop(0))

        max_price = max(max_price, rec(rest_ope - 1, left_d, left_hand))

        right_d = copy.copy(now_d)
        right_hand = copy.copy(now_hand)
        right_hand.append(right_d.pop(-1))

        max_price = max(max_price, rec(rest_ope - 1, right_d, right_hand))

    if len(now_hand) > 0:
        drop_hand = copy.copy(now_hand)
        drop_hand.pop(drop_hand.index(min(drop_hand)))  # 最小値を削除

        max_price = max(max_price, rec(rest_ope - 1, now_d, drop_hand))

    # do nothing
    max_price = max(max_price, rec(rest_ope - 1, now_d, now_hand))

    return max_price


print(rec(K, V, []))


Fixed submission:
import copy

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

INF = 10 ** 8


# mode 0: can pop left, pop right, drop
#      1: can pop right, drop
#      2: can drop
#      3: can not do anything
def rec(rest_ope, now_d, now_hand, mode):

    if rest_ope == 0:
        return sum(now_hand)

    max_price = -INF

    if len(now_d) > 0:
        if mode == 0:
            left_d = copy.copy(now_d)
            left_hand = copy.copy(now_hand)
            left_hand.append(left_d.pop(0))

            max_price = max(max_price, rec(rest_ope - 1, left_d, left_hand, 0))

        if mode <= 1:
            right_d = copy.copy(now_d)
            right_hand = copy.copy(now_hand)
            right_hand.append(right_d.pop(-1))

            max_price = max(max_price, rec(rest_ope - 1, right_d, right_hand, 1))

    if len(now_hand) > 0:
        if mode <= 2:
            drop_hand = copy.copy(now_hand)
            drop_hand.pop(drop_hand.index(min(drop_hand)))  # 最小値を削除

            max_price = max(max_price, rec(rest_ope - 1, now_d, drop_hand, 2))

    # do nothing
    max_price = max(max_price, rec(rest_ope - 1, now_d, now_hand, 3))

    return max_price


print(rec(K, V, [], 0))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]


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

cards = [0] * (N + 1)

for i in range(M):
    L, R = map(int, input().split())

    for j in range(L, R + 1):
        cards[j] += 1

print(cards.count(M))


Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]


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

l_max = 1
r_min = N

for i in range(M):
    L, R = map(int, input().split())

    l_max = max(l_max, L)
    r_min = min(r_min, R)

print(max(r_min - l_max + 1, 0))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input():
    return sys.stdin.readline()[:-1]


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

BC_list = []

for i in range(M):
    B, C = map(int, input().split())

    BC_list.append({
        'B': B,
        'C': C
    })


BC_list.sort(reverse=True, key=lambda x: x['C'])

A_last = min(A)

for pair in BC_list:

    if pair['C'] < A_last:
        break

    for _ in range(pair['B']):
        A.append(pair['C'])

A.sort(reverse=True)

print(sum(A[0:N]))


Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]


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

BC_list = []

for i in range(M):
    B, C = map(int, input().split())

    BC_list.append({
        'B': B,
        'C': C
    })

BC_list.sort(reverse=True, key=lambda x: x['C'])

A_last = min(A)

limit_count = 0

for pair in BC_list:

    if pair['C'] < A_last:
        break

    for _ in range(pair['B']):
        A.append(pair['C'])

    limit_count += pair['B']
    if limit_count > N:
        break

A.sort(reverse=True)

print(sum(A[0:N]))
Buggy python submission (verdict: Time Limit Exceeded):
import fractions

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

A.sort(reverse=True)

#A[1] = A[0]

max_gcd = 1

for i in range(N):
    gcd_num = -1

    for j, a in enumerate(A):
        if i == j:
            continue

        if gcd_num == -1:
            gcd_num = a
            continue

        gcd_num = fractions.gcd(gcd_num, a)

    max_gcd = max(max_gcd, gcd_num)

print(max_gcd)


Fixed submission:
import fractions

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

left = [0] * (N + 1)
right = [0] * (N + 1)

for i in range(N):
    left[i + 1] = fractions.gcd(A[i], left[i])

for i in reversed(range(N)):
    right[i] = fractions.gcd(A[i], right[i + 1])

max_gcd = 1

for i in range(N):

    l = left[i]
    r = right[i + 1]

    gcd_num = fractions.gcd(l, r)

    max_gcd = max(max_gcd, gcd_num)

print(max_gcd)