Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
D = int(input())
strK = str(K)
lenK = len(strK)
#dp[i][smaller][k]はi桁まで見たあまりkの物の数とする.ただしsmaller=0のときはまだK以下かわかってないとする. 
dp = [[[0]*D for i in range(2)] for _ in range(lenK + 1)]
dp[0][0][0] = 1
for i in range(lenK):
    for j in range(2):
        for k in range(D):
            if j == 0:
                for l in range(int(strK[i])+1):
                    if l != int(strK[i]):    
                        if k + l < D:
                            dp[i+1][1][k+l] += dp[i][0][k]
                        else:
                            dp[i+1][1][(k+l)%D] += dp[i][0][k]
                    else:
                        if k+l < D:
                            dp[i+1][0][k+l] += dp[i][0][k]
                        else:
                            dp[i+1][0][(k+l)%D] += dp[i][0][k]
            else:
                for l in range(10):
                    if k+l < D:
                        dp[i+1][1][k+l] += dp[i][1][k]
                    else:
                        dp[i+1][1][(k+l)%D] += dp[i][1][k]
print((dp[lenK][0][0] + dp[lenK][1][0] - 1)%1000000007)

Fixed submission:
K = input()
D = int(input())
lenK = len(K)
mod = 10**9+7
#dp[i][smaller][k]はi桁まで見たあまりkの物の数とする.ただしsmaller=0のときはまだK以下かわかってないとする. 
dp = [[[0]*D for i in range(2)] for _ in range(lenK + 1)]
dp[0][0][0] = 1
for i,c in enumerate(K):
    for less in range(2):
        lim = 9 if less else int(c)
        for r in range(D):
            for d in range(lim+1):
                dp[i+1][less or d < lim][(r+d)%D] += dp[i][less][r]
                dp[i+1][less or d < lim][(r+d)%D] %= mod
print((dp[-1][0][0] + dp[-1][1][0] - 1)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python
#coding: utf-8

N, K = map(int, raw_input().split())
l = map(int, raw_input().split())

s = list(set(l))
num = range(len(s))
if len(s) <= K: print 0
else:
    for i in range(len(s)):
        num[i] = len([j for j in l if j == s[i]])
    sousa = len(s)-K
    num.sort()
    print sum(num[:sousa])


Fixed submission:
#!/usr/bin/python
#coding: utf-8

from collections import Counter

N, K = map(int, raw_input().split())
l = map(int, raw_input().split())

s = list(set(l))
num = range(len(s))
if len(s) <= K: print 0
else:
    counter = Counter(l)
    nums = counter.values()
    sousa = len(s)-K
    nums.sort()
    print sum(nums[:sousa])

Buggy python submission (verdict: Runtime Error):
s = list(set(l))
num = range(len(s))
if len(s) <= K: print 0
else:
    for i in range(len(s)):
        num[i] = len([j for j in l if j == s[i]])
    sousa = len(s)-K
    num.sort()
    print sum(num[:sousa])


Fixed submission:
#!/usr/bin/python
#coding: utf-8

from collections import Counter

N, K = map(int, raw_input().split())
l = map(int, raw_input().split())

s = list(set(l))
num = range(len(s))
if len(s) <= K: print 0
else:
    counter = Counter(l)
    nums = counter.values()
    sousa = len(s)-K
    nums.sort()
    print sum(nums[:sousa])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, raw_input().split())
l = map(int, raw_input().split())

s = list(set(l))
num = range(len(s))
if len(s) <= K: print 0
else:
    for i in range(len(s)):
        num[i] = l.count(s[i])
    sousa = len(s)-K
    num.sort()
    print sum(num[:sousa])


Fixed submission:
#!/usr/bin/python
#coding: utf-8

from collections import Counter

N, K = map(int, raw_input().split())
l = map(int, raw_input().split())

s = list(set(l))
num = range(len(s))
if len(s) <= K: print 0
else:
    counter = Counter(l)
    nums = counter.values()
    sousa = len(s)-K
    nums.sort()
    print sum(nums[:sousa])
Buggy python submission (verdict: Runtime Error):
print("YES") if input().replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") == "" else print("NO")


Fixed submission:
print("YES") if input().replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") == "" else print("NO")
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    l = []
    
    if(n<0 or n>1000000000):
        main()
    
    h1 = int(n/500)*1000
    ar = n - (h1/int(n/500))
    h1+=int(ar/5)*5
    h2 = int(n/5)*5

    l.append(h1)
    l.append(h2)
    print(max(l))

main()

Fixed submission:
def main():
    n = int(input())
    l = []
    
    if(n<0 or n>1000000000):
        main()
    
    
    if(n!=0):
        h1 = int(n/500)*1000
        ar = n - (int(n/500)*500)
        h1+=int(ar/5)*5
        h2 = int(n/5)*5
        
        l.append(h1)
        l.append(h2)
        print(max(l))
    else:
        print(0)

main()
Buggy python submission (verdict: Runtime Error):
k,n=map(int,input().split())
list=list(input().split())
dif_list=[]

for i in range(n):
  if i == 0:
    dif_list.append(k-list[-1]+list[0])
  else:
    dif_list.append(list[i]-list[i-1])

print(k-max(dif_list))

Fixed submission:
k,n=map(int,input().split())
list=list(map(int,input().split()))
dif_list=[]

for i in range(n):
  if i == 0:
    dif_list.append(k-list[-1]+list[0])
  else:
    dif_list.append(list[i]-list[i-1])

print(k-max(dif_list))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
digit=1
num=k
while n>=k:
  num *= k
  digit += 1

print(digit)
  

Fixed submission:
import math
n,k=map(int,input().split())
print(int(math.log(n,k)) + 1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
list=list(map(int,input().split()))

ave=int(sum(list)/len()list)

ans=0
for i in list:
  ans+= pow((i-ave),2)

print(ans)


Fixed submission:
n=int(input())
list=list(map(int,input().split()))
min_tairyoku=10000000000000000000
tairyoku=[]
for i in range(min(list),max(list)+1):
    t=0
    for j in list:
        t += (j-i) ** 2
    tairyoku.append(t)
print(min(tairyoku))

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

ave=int(sum(list)/len()list)

ans=0
[ans+= pow((i-ave),2) for i in list]

print(ans)

Fixed submission:
n=int(input())
list=list(map(int,input().split()))
min_tairyoku=10000000000000000000
tairyoku=[]
for i in range(min(list),max(list)+1):
    t=0
    for j in list:
        t += (j-i) ** 2
    tairyoku.append(t)
print(min(tairyoku))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input())

if a==b and b== c and a== c:
  print('No')
else:
  print('Yes')

Fixed submission:
a,b,c=map(int,input().split())

if a==b and b==c and a==c:
  print('No')

elif a!=b and a!= c and b!= c:
    print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
# coding: UTF-8
import os

def remove_empty(target_list: list):
    empty_removed_list = [x for x in target_list if x]
    return empty_removed_list

def get_stdin_str_list():
    input_str = input().strip()
    input_str_list = input_str.split()
    return input_str_list

def get_stdin_int_list():
    input_str_list = get_stdin_str_list()
    input_int_list = list(map(input_str_list, int))
    return input_int_list


S = get_stdin_str_list()
if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Fixed submission:
# coding: UTF-8
import os

def remove_empty(target_list: list):
    empty_removed_list = [x for x in target_list if x]
    return empty_removed_list

def get_stdin_str_list():
    input_str = input().strip()
    input_str_list = input_str.split()
    return input_str_list

def get_stdin_int_list():
    input_str_list = get_stdin_str_list()
    input_int_list = list(map(input_str_list, int))
    return input_int_list


S = get_stdin_str_list()[0]
if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# coding: UTF-8
import os

def remove_empty(target_list: list):
    empty_removed_list = [x for x in target_list if x]
    return empty_removed_list

def get_stdin_str_list():
    input_str = input().strip()
    input_str_list = input_str.split()
    return input_str_list

def get_stdin_int_list():
    input_str_list = get_stdin_str_list()
    input_int_list = list(map(input_str_list, int))
    return input_int_list

X = get_stdin_int_list()[0]
n_500 = int(X / 500)
X = X % 500
n_5 = int(X/5)

p = n_500*1000 + n_5*5
print(p)

Fixed submission:
# coding: UTF-8
import os

def remove_empty(target_list: list):
    empty_removed_list = [x for x in target_list if x]
    return empty_removed_list

def get_stdin_str_list():
    input_str = input().strip()
    input_str_list = input_str.split()
    return input_str_list

def get_stdin_int_list():
    input_str_list = get_stdin_str_list()
    input_int_list = list(map(int, input_str_list))
    return input_int_list

X = get_stdin_int_list()[0]
n_500 = int(X / 500)
X = X % 500
n_5 = int(X/5)

p = n_500*1000 + n_5*5
print(p)

Buggy python submission (verdict: Runtime Error):
# coding: UTF-8
import os

def remove_empty(target_list: list):
    empty_removed_list = [x for x in target_list if x]
    return empty_removed_list

def get_stdin_str_list():
    input_str = input().strip()
    input_str_list = input_str.split()
    return input_str_list

def get_stdin_int_list():
    input_str_list = get_stdin_str_list()
    input_int_list = list(map(input_str_list, int))
    return input_int_list

X = get_stdin_int_list()[0]
n_500 = int(X / 500)
X = X % 500
n_5 = int(X/5)

p = n_500*1000 + n_5*5

Fixed submission:
# coding: UTF-8
import os

def remove_empty(target_list: list):
    empty_removed_list = [x for x in target_list if x]
    return empty_removed_list

def get_stdin_str_list():
    input_str = input().strip()
    input_str_list = input_str.split()
    return input_str_list

def get_stdin_int_list():
    input_str_list = get_stdin_str_list()
    input_int_list = list(map(int, input_str_list))
    return input_int_list

X = get_stdin_int_list()[0]
n_500 = int(X / 500)
X = X % 500
n_5 = int(X/5)

p = n_500*1000 + n_5*5
print(p)
Buggy python submission (verdict: Runtime Error):
# input() は 'python3' で正常に動く
N = int(input())
S = input()

str_list = list(S)
str_trsf = []

for item in str_list:
    str_trsf.extend(chr(N - (ord('Z') - ord(item)) + ord('A') if ord(item) + N > ord('Z') else chr(ord(item) + N)))

print(''.join(str_trsf))

Fixed submission:
# input() は 'python3' で正常に動く
N = int(input())
S = input()
 
str_list = list(S)
str_trsf = []
 
for item in str_list:
    str_trsf.extend(chr(N - (ord('Z') - ord(item) + 1) + ord('A')) if ord(item) + N > ord('Z') else chr(ord(item) + N))

print(''.join(str_trsf))
Buggy python submission (verdict: Runtime Error):
l=[]
for i in range(3):
  l.append(list(map(int,input().split())))
n=int(input())
l1=[]
for i in range(n):
  l1.append(int(input())
for i in range(len(l)):
    for j in range(len(l)):
        if(l[i][j] in l1):
            l[i][j]=0
f=0
if((l[0][0]==0 and l[0][1]==0 and l[0][2]==0) or (l[1][0]==0 and l[1][1]==0 and l[1][2]==0) or (l[2][0]==0 and l[2][1]==0 and l[2][2]==0))
    f=1
elif((l[0][0]==0 and l[1][0]==0 and l[2][0]==0) or (l[0][1]==0 and l[1][1]==0 and l[2][1]==0) or (l[0][2]==0 and l[1][2]==0 and l[2][2]==0))
    f=1
elif((l[0][0]==0 and l[1][1]==0 and l[2][2]==0) or (l[0][2]==0 and l[1][1]==0 and l[2][0]==0)):
    f=1
if(f==1):
    print("Yes")
else:
    print("No")

Fixed submission:
l=[]
for i in range(3):
  l.append(list(map(int,input().split())))
n=int(input())
l1=[]
for i in range(n):
  l1.append(int(input()))
for i in range(len(l)):
    for j in range(len(l)):
        if(l[i][j] in l1):
            l[i][j]=0
f=0
if((l[0][0]==0 and l[0][1]==0 and l[0][2]==0) or (l[1][0]==0 and l[1][1]==0 and l[1][2]==0) or (l[2][0]==0 and l[2][1]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][0]==0 and l[2][0]==0) or (l[0][1]==0 and l[1][1]==0 and l[2][1]==0) or (l[0][2]==0 and l[1][2]==0 and l[2][2]==0)):
    f=1
elif((l[0][0]==0 and l[1][1]==0 and l[2][2]==0) or (l[0][2]==0 and l[1][1]==0 and l[2][0]==0)):
    f=1
if(f==1):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
	for j in range(i+1,i+3):
    	if(j<len(l)):
      		dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n])

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
    for j in range(i+1,i+3):
        if(j<len(l)):
      	    dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
	for j in range(i+1,i+3):
    	if(j<len(l)):
      		dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n])


Fixed submission:
n=int(input())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
    for j in range(i+1,i+3):
        if(j<len(l)):
      	    dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
    for j in range(i+1,i+k+1):
        if(j<len(l)):
      	    dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n-1])

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
    for j in range(i+1,i+k+1):
        if(j<len(l)):
      	    dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

d = deque(list(input()))
for _ in range(int(input())):
    a = input()
    if a[0] == '1':
        d.reverse()
    elif a[2] == '1':
        d.appendleft(a[4])
    else:
        d.append(a[4])
print(*d, sep='')


Fixed submission:
from collections import deque

d = deque(list(input()))
flag = 1
for _ in range(int(input())):
    a = input()
    if a[0] == '1':
        flag *= -1
    elif a[2] == '1' and flag == 1:
        d.appendleft(a[4])
    elif a[2] == '1' and flag == -1:
        d.append(a[4])
    elif a[2] == '2' and flag == 1:
        d.append(a[4])
    else:
        d.appendleft(a[4])
if flag == -1:
    d.reverse()
print(*d, sep='')
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
if len(c) == 1:
    print(s[0])
    exit()
a = c.most_common()[0][1]
d = collections.deque()
for i in range(n):
    if c.most_common()[i][1] == a:
        d.append(c.most_common()[i][0])
    else:
        break
for i in sorted(list(d)):
    print(i)


Fixed submission:
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
if len(c) == 1:
    print(s[0])
    exit()
a = c.most_common()[0][1]
b = c.most_common()
d = collections.deque()
for i in range(n):
    if b[i][1] == a:
        d.append(b[i][0])
    else:
        break
for i in sorted(list(d)):
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
x = []
for _ in range(n):
    x.append(input())
c = collections.Counter(x)
a = c.most_common()[0][1]
y = []
if len(c) == 1:
    print(x[0])
    exit()
for i in range(n):
    if c.most_common()[i][1] == a:
        y.append(c.most_common()[i][0])
    else:
        break
for i in sorted(y):
    print(i)


Fixed submission:
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
if len(c) == 1:
    print(s[0])
    exit()
a = c.most_common()[0][1]
b = c.most_common()
d = collections.deque()
for i in range(n):
    if b[i][1] == a:
        d.append(b[i][0])
    else:
        break
for i in sorted(list(d)):
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(1, n + 1):
    if i in a:
        cnt += 1
        a = a[a.index(i):]
    else:
        break
if cnt == 0:
    print(-1)
else:
    print(n - cnt)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
cnt = 0
x = 1
for i in a:
    if i == x:
        cnt += 1
        x += 1
if cnt == 0:
    print(-1)
else:
    print(n - cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
x = 2020202020
for i in range(1, n):
    x = min(x, abs(sum(a[:i]) - sum(a[i:])))
print(x)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
x = 0
y = sum(a)
ans = 2020202020
for i in range(n - 1):
    x += a[i]
    y -= a[i]
    ans = min(ans, abs(x - y))
print(ans)
Buggy python submission (verdict: Runtime Error):
print((int(input()+1)//2-1)

Fixed submission:
n=int(input())
if n%2==0:
    print(n//2-1)
else:
    print((n-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.index(i)+1,end=' ')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append([a[i],i+1])
b.sort()
for i in b:
    print(i[1],end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    print(a.index(i+1)+1,end=' ')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    b.append([a[i],i+1])
b.sort()
for i in b:
    print(i[1],end=' ')
Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
n = math.gcd(a, b)
k = int(n**0.5)
cnt = 1
for i in range(2, k + 1):
    if n == 1:
        break
    elif n % i == 0:
        while n % i == 0:
            n //= i
        cnt += 1
if n != 1:
    cnt += 1
print(cnt)


Fixed submission:
import fractions
a, b = map(int, input().split())
n = fractions.gcd(a, b)
k = int(n**0.5)
cnt = 1
for i in range(2, k + 1):
    if n == 1:
        break
    elif n % i == 0:
        while n % i == 0:
            n //= i
        cnt += 1
if n != 1:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    x = a.index(max(a))
    a[x] //= 2
print(sum(a))


Fixed submission:
import heapq
n, m = map(int, input().split())
a = [int(i) * (-1) for i in input().split()]
heapq.heapify(a)
for i in range(m):
    x = heapq.heappop(a) * (-1) // 2
    heapq.heappush(a, x * (-1))
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
x=[]
c=0
for i in range(n-1):
    if h[i]>=h[i+1]:
        c+=1
        x.append(c)
    else:
        c=0
        x.append(c)
print(max(x))

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
x=[]
c=0
if n==1:print(0)
else:
    for i in range(n-1):
        if h[i]>=h[i+1]:
            c+=1
            x.append(c)
        else:
            c=0
            x.append(c)
    print(max(x))
Buggy python submission (verdict: Time Limit Exceeded):
x = []
cnt = 0
for _ in range(int(input())):
    a = sorted(input())
    cnt += x.count(a)
    x.append(a)
print(cnt)


Fixed submission:
import collections
n = int(input())
x = [''.join(sorted(input())) for _ in range(n)]
a = collections.Counter(x)
print(sum(i * ~-i // 2 for i in a.values()))

Buggy python submission (verdict: Time Limit Exceeded):
x = []
cnt = 0
for _ in range(int(input())):
    a = sorted(input())
    if a in x:
        cnt += x.count(a)
    x.append(a)
print(cnt)


Fixed submission:
import collections
n = int(input())
x = [''.join(sorted(input())) for _ in range(n)]
a = collections.Counter(x)
print(sum(i * ~-i // 2 for i in a.values()))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[sorted(input())]
c=0
for i in range(n-1):
    a=sorted(input())
    c+=s.count(a)
    s.append(a)
print(c)

Fixed submission:
import collections
n = int(input())
x = [''.join(sorted(input())) for _ in range(n)]
a = collections.Counter(x)
print(sum(i * ~-i // 2 for i in a.values()))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[input()for i in range(n)]
cnt=0
for i in range(n):
    for j in range(i,n):
        if sorted(s[i])==sorted(s[j]):
            cnt+=1
print(cnt-n)

Fixed submission:
import collections
n = int(input())
x = [''.join(sorted(input())) for _ in range(n)]
a = collections.Counter(x)
print(sum(i * ~-i // 2 for i in a.values()))
Buggy python submission (verdict: Time Limit Exceeded):
n,*a=map(int,open(0))
for i in range(n):
    x=a[i]
    a[i]=0
    print(max(a))
    a[i]=x

Fixed submission:
n,*a=map(int,open(0))
b=sorted(a)
for i in range(n):
    if a[i]==b[-1]:
        print(b[-2])
    else:
        print(b[-1])
Buggy python submission (verdict: Runtime Error):
import math

a,b,c,d=map(int,input().split())
x=c*d//math.gcd(c,d)
print(b-~-a-(b//c-~-a//c)-(b//d-~-a//d)+b//x-~-a//x)

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
x=c*d//fractions.gcd(c,d)
print(b-~-a-(b//c-~-a//c)-(b//d-~-a//d)+b//x-~-a//x)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
x=c*d//math.gcd(c,d)
print(b-~-a-(b//c-~-a//c)-(b//d-~-a//d)+b//x-~-a//x)

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
x=c*d//fractions.gcd(c,d)
print(b-~-a-(b//c-~-a//c)-(b//d-~-a//d)+b//x-~-a//x)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
if n == 2:
    print(max(a))
    exit()
x = [a[0], gcd(a[0], a[1])]
y = [gcd(a[-2], a[-1]), a[-1]]
for i in range(1, n - 2):
    x.append(gcd(x[i], a[i + 1]))
    y.insert(0, gcd(y[0], a[-i - 2]))
ans = max(x[-1], y[0])
for i in range(n - 2):
    ans = max(ans, gcd(x[i], y[i + 1]))
print(ans)


Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
if n == 2:
    print(max(a))
    exit()
x = [a[0], gcd(a[0], a[1])]
for i in range(n - 3):
    x.append(gcd(x[i + 1], a[i + 2]))
ans = x[-1]
y = a[-1]
for i in range(1, n - 1):
    z = gcd(y, a[-i])
    ans = max(ans, gcd(x[-i - 1], z))
    y = z
print(max(ans, gcd(y, a[1])))

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
if n == 2:
    print(max(a))
    exit()
x = [a[0], gcd(a[0], a[1])]
y = [gcd(a[-2], a[-1]), a[-1]]
for i in range(1, n - 2):
    x.append(gcd(x[i], a[i + 1]))
    y.insert(0, gcd(y[0], a[-i - 2]))
x.insert(0, y[0])
y.append(x[-1])
ans = 0
for i in range(n):
    ans = max(ans, gcd(x[i], y[i]))
print(ans)


Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
if n == 2:
    print(max(a))
    exit()
x = [a[0], gcd(a[0], a[1])]
for i in range(n - 3):
    x.append(gcd(x[i + 1], a[i + 2]))
ans = x[-1]
y = a[-1]
for i in range(1, n - 1):
    z = gcd(y, a[-i])
    ans = max(ans, gcd(x[-i - 1], z))
    y = z
print(max(ans, gcd(y, a[1])))

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
if n == 2:
    print(max(a))
    exit()
x = [a[0], gcd(a[0], a[1])]
for i in range(1, n - 2):
    x.append(gcd(x[i], a[i + 1]))
y = [gcd(a[-2], a[-1]), a[-1]]
for i in range(3, n):
    y.insert(0, gcd(y[0], a[-i]))
x.insert(0, y[0])
y.append(x[-1])
ans = 0
for i in range(n):
    ans = max(ans, gcd(x[i], y[i]))
print(ans)


Fixed submission:
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
if n == 2:
    print(max(a))
    exit()
x = [a[0], gcd(a[0], a[1])]
for i in range(n - 3):
    x.append(gcd(x[i + 1], a[i + 2]))
ans = x[-1]
y = a[-1]
for i in range(1, n - 1):
    z = gcd(y, a[-i])
    ans = max(ans, gcd(x[-i - 1], z))
    y = z
print(max(ans, gcd(y, a[1])))
Buggy python submission (verdict: Runtime Error):
s=input()
x=[]
c=0
for i in range(len(s)):
    if s[i]in['A','C','G','T']:
        c+=1
    else:
        x.append(c)
        c=0
print(max(x))

Fixed submission:
s=input()
x=[]
c=0
for i in range(len(s)):
    if s[i]in['A','C','G','T']:
        c+=1
        x.append(c)
    else:
        c=0
        x.append(c)
print(max(x))