Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

A = ""
B = ""

for i in range(N):
	A += input()



for i in range(M):
	if i % 2 == 0:
		B += input()
	else:
		B += input()[::-1]

if B in A:
	print("Yes")
else:
	print("No")

Fixed submission:


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

if A == 1 and B != 1:
	print('Alice')
	exit()

if B == 1 and A != 1 :
	print('Bob')
	exit()
if A > B:
	print('Alice')
	exit()
	
if B > A:
	print('Bob')
	exit()

if A == B:
	print('Draw')
	exit()
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())

Ans = 0

for x in range(K+1):
	for y in range(K+1):
		for z in range(K+1):
			if x + y + z == S:
				Ans += 1

print(Ans)
	

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

Ans = 0

for x in range(K+1):
	for y in range(K+1):
		if 0 <= S - x - y <= K:
			Ans += 1

print(Ans)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int,input().split())

lis = []

Ans = 0

for i in range(b - a + 1):
	lis.append(b)
	b -= 1

for i in range(len(lis)):
	if lis[i] % x == 0:
		Ans += 1

print(Ans)
	

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

print(b//x - ( a - 1 )//x)
Buggy python submission (verdict: Runtime Error):
x = input() y = input() z = input()
print(z) print(x) print(y)

Fixed submission:
x,y,z = map(int,input().split())

print(z,x,y)
Buggy python submission (verdict: Runtime Error):
S = str(input())
T = str(input())
n = 0

for i in len(S):
  if S[i] != T[i]:
    n += 1

print(n)

Fixed submission:
S = str(input())
T = str(input())
n = 0

for i in range(len(S)):
  if S[i] != T[i]:
    n += 1
    
print(n)
Buggy python submission (verdict: Runtime Error):
n=int(input())

alphabet=[None] + [chr(i) for i in range(97,97+26)]

if n<27:
    print(alphabet[n])
    exit()
    
rest=[]
while n!=0:
    rest.append(n%26)
    n = n // 26
rest.reverse()

if rest[-1]==0:
    for i in range(len(rest)-1):
        rest[i]=26
    rest.pop(-1)

ans=''
for i in range(len(rest)):
    ans+=alphabet[rest[i]]
print(ans)


Fixed submission:
n=int(input())

alphabet=[None] + [chr(i) for i in range(97,97+26)]

rest=[]
while n!=0:
    rest.append(n%26)
    n = n // 26
rest.reverse()

for i in range(len(rest)-1):
    if rest[len(rest)-1-i]<=0:
        rest[len(rest)-1-i]+=26
        rest[len(rest)-2-i]-=1
if rest[0]<=0:
    rest=rest[1:]

ans=''
for i in range(len(rest)):
    ans+=alphabet[rest[i]]
print(ans)

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

alphabet=[None] + [chr(i) for i in range(97,97+26)]

if n<27:
    print(alphabet[n])
    exit()
rest=[]
while n!=0:
    rest.append(n%26)
    n = n // 26
rest.reverse()

ans=''
for i in range(len(rest)):
    ans+=alphabet[rest[i]]
print(ans)


Fixed submission:
n=int(input())

alphabet=[None] + [chr(i) for i in range(97,97+26)]

rest=[]
while n!=0:
    rest.append(n%26)
    n = n // 26
rest.reverse()

for i in range(len(rest)-1):
    if rest[len(rest)-1-i]<=0:
        rest[len(rest)-1-i]+=26
        rest[len(rest)-2-i]-=1
if rest[0]<=0:
    rest=rest[1:]

ans=''
for i in range(len(rest)):
    ans+=alphabet[rest[i]]
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
def change_dict_key(d, old_key, new_key, default_value=None):
    d[new_key] = d.pop(old_key, default_value)

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

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    if b in a_cnt.keys():
        if c in a_cnt.keys():
            a_cnt[c]+=a_cnt[b]
            tmp=a_cnt[b]
            a_cnt.pop(b)
        else:
            change_dict_key(a_cnt,b,c)
    if i==0:
        ans=0
        for key,value in a_cnt.items():
            ans+=key*value
        print(ans)
    else:
        ans+=(c-b)*tmp
        print(ans)

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

sum=0
num=[0]*(10**5+1)
for i in range(n):
    sum+=a[i]
    num[a[i]]+=1

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    sum+=(c-b)*num[b]
    print(sum)
    num[c]+=num[b]
    num[b]=0

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
def change_dict_key(d, old_key, new_key, default_value=None):
    d[new_key] = d.pop(old_key, default_value)

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

q=int(input())
for _ in range(q):
    b,c=map(int,input().split())
    if b in a_cnt.keys():
        if c in a_cnt.keys():
            a_cnt[c]+=a_cnt[b]
            a_cnt.pop(b)
        else:
            change_dict_key(a_cnt,b,c)
    ans=0
    for key,value in a_cnt.items():
        ans+=key*value
    print(ans)


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

sum=0
num=[0]*(10**5+1)
for i in range(n):
    sum+=a[i]
    num[a[i]]+=1

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    sum+=(c-b)*num[b]
    print(sum)
    num[c]+=num[b]
    num[b]=0
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

ans=1
for i in range(n):
    ans*=a[i]

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


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

ans=1
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        exit()
print(ans)

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

ans=1
for i in range(n):
    ans*=a[i]
if ans>10**18:
    print(-1)
    exit()
print(ans)


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

ans=1
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

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

max = 0
for i in range(N+1):
    value = math.floor(A*i/B) - A*math.floor(i/B)
    if value > max:
        max=value
print(max)


Fixed submission:
import math

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

def f(x):
    return math.floor(A*x/B) - A*math.floor(x/B)
print(f(min(N,B-1)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

answer=[0]*n
for i in range(n):
    answer[a[i]-1]+=1

for i in range(n):
    print(answer[i])

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

answer=[0]*n
for i in range(n-1):
    answer[a[i]-1]+=1

for i in range(n):
    print(answer[i])

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

answer=[0]*n
for i in range(n):
    answer[a[i]-1]+=1

for i in range(n):
    print(answer[i])



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

answer=[0]*n
for i in range(n-1):
    answer[a[i]-1]+=1

for i in range(n):
    print(answer[i])

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

for i in range(n):
    print(a.count(i+1))


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

answer=[0]*n
for i in range(n-1):
    answer[a[i]-1]+=1

for i in range(n):
    print(answer[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math

k=int(input())

sum=0
for l in range(k):
    for m in range(k):
        for n in range(k):
            tmp=l+1
            tmp=math.gcd(tmp,m+1)
            tmp=math.gcd(tmp,n+1)
            sum+=tmp

print(sum)




Fixed submission:
import math

k=int(input())

sum=0
for l in range(k):
    for m in range(k):
        tmp=math.gcd(l+1,m+1)
        for n in range(k):
            gcd=math.gcd(tmp,n+1)
            sum+=gcd

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n-1):
    for j in range(i+1,n):
        k = 2*j -i
        if k <= n-1:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                ans -= 1

print(ans)


Fixed submission:
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2*j -i
        if k <= n-1:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                ans -= 1

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

list=[]


if N%K==0:
    print(0)
else:
    while N not in list:
        list.append(N)
        N=abs(N-K)
    print(min(list))


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

print(min(N%K,K-N%K))

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

list=[]

while N not in list:
    list.append(N)
    N=abs(N-K)

print(min(list))


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

print(min(N%K,K-N%K))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

balls = []
for k in range(n):
    ball=[a[i] for i in range(n) if i!=k]
    balls.append(ball)

ans = []
for k in range(n):
    cnt=0
    for i in range(len(balls)-1):
        for j in range(i+1,len(balls)-1):
            if balls[k][i]==balls[k][j]:
                cnt+=1
    print(cnt)


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

count={}
for ak in a:
    if ak not in count:
        count[ak] = 0
    count[ak] += 1

sum=0
for key in count:
    sum += count[key]*(count[key]-1) // 2

for ak in a:
    print(sum-(count[ak]-1))
Buggy python submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split()]

flag=0
for i in range(1,1050):
    if int(i*0.08)==A and int(i*0.1)==B:
        ans = i
        flag=1
        break

if flag==1:
    print(ans)
else:
    print(-1)


Fixed submission:
S=input()

if S=='AAA' or S=='BBB':
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
j=0
for i in range(1,100001):
    if int(i*0.08) == A and int(i*0.1) == B:
        j =1
        ans = i
        break
if j == 1:
    print(ans)
else:
    print(-1)

Fixed submission:
S=input()

if S=='AAA' or S=='BBB':
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split()]

flag=0
for i in range(1,10000):
    if int(i*0.08)==A and int(i*0.1)==B:
        ans = i
        flag=1
        break

if flag==1:
    print(ans)
else:
    print(-1)


Fixed submission:
S=input()

if S=='AAA' or S=='BBB':
    print('No')
else:
    print('Yes')

Buggy python submission (verdict: Runtime Error):
A,B = [int(i) for i in input().split()]

flag=0
for i in range(1,10000):
    if int(i*0.08)==A and int(i*0.1)==B:
        ans = i
        flag=1
        break
if flag==1:
    print(ans)
else:
    print(-1)


Fixed submission:
S=input()

if S=='AAA' or S=='BBB':
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    query = list(input().split())
    if int(query[0])==1:
        s = s[::-1]
    elif int(query[0])==2:
        if int(query[1])==1:
            s = query[2] + s
        elif int(query[1])==2:
            s = s + query[2]

print(s)


Fixed submission:
s = input()
q = int(input())
cnt = 0
left = ''
right = ''
for i in range(q):
    query = list(input().split())
    if int(query[0])==1:
        cnt += 1
    elif int(query[0])==2:
        if int(query[1])==1:
            if cnt%2==0:
                left = query[2] + left
            else:
                right = right + query[2]
        elif int(query[1])==2:
            if cnt%2==0:
                right = right + query[2]
            else:
                left = query[2] + left

if cnt%2==0:
    print(left+s+right)
else:
    s=left+s+right
    s=s[::-1]
    print(s)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
sc = [ list(map(int,input().split())) for _ in range(m)]

ans = [0] * n
change_cnt = [0] * n
if n >= 2:
    ans[0]=1
for i in range(n):
    for j in range(m):
        if i+1 == sc[j][0]:
            if ans[i] != sc[j][1]:
                ans[i] = sc[j][1]
                change_cnt[i] += 1
                if change_cnt[i] > 1:
                    print(-1)
                    exit()

if n>=2:
    if ans[0]==0:
        print(-1)
        exti()

answer = ''
for i in range(len(ans)):
    answer += str(ans[i])

print(int(answer))


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

ans = [0] * n
change_cnt = [0] * n
if n >= 2:
    ans[0]=1
for i in range(n):
    for j in range(m):
        if i+1 == sc[j][0]:
            if ans[i] != sc[j][1]:
                ans[i] = sc[j][1]
                change_cnt[i] += 1
                if change_cnt[i] > 1:
                    print(-1)
                    exit()

if n>=2:
    if ans[0]==0:
        print(-1)
        exit()

answer = ''
for i in range(len(ans)):
    answer += str(ans[i])

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

answers=[]
for i in range(min(x),max(x)):
    sum=0
    for j in range(n):
        sum+=(x[j]-i)**2
    answers.append(sum)

print(min(answers))


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

answers=[]
for i in range(min(x)-1,max(x)+1):
    sum=0
    for j in range(n):
        sum+=(x[j]-i)**2
    answers.append(sum)

print(min(answers))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int,input().split()))

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)

max = 0
for i in range(n-k+1):
    s=sum(p[i:i+k])
    if s > max:
        max = s
        max_id = i

print(sum(e_p[max_id:max_id+k]))



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

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)


ans = []
s = sum(e_p[:k])
ans.append(s)
for i in range(1,n-k+1):
    s -= e_p[i-1]
    s += e_p[i+k-1]
    ans.append(s)
print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int,input().split()))

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)

max = 0
for i in range(n-k+1):
    s = sum(e_p[i:i+k])
    if s > max:
        max = s

print(max)


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

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)


ans = []
s = sum(e_p[:k])
ans.append(s)
for i in range(1,n-k+1):
    s -= e_p[i-1]
    s += e_p[i+k-1]
    ans.append(s)
print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int,input().split()))

e_p = []
for i in range(n):
    e_p.append(sum(range(1,p[i]+1)) / p[i])

max = 0
for i in range(n-k+1):
    s = sum(e_p[i:i+k])
    if s > max:
        max = s

print(max)


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

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)


ans = []
s = sum(e_p[:k])
ans.append(s)
for i in range(1,n-k+1):
    s -= e_p[i-1]
    s += e_p[i+k-1]
    ans.append(s)
print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int,input().split()))

e_p = []
for i in range(n):
    e_p.append(sum(range(1,p[i]+1)) / p[i])

max = 0
for i in range(n-k+1):
    if sum(e_p[i:i+k]) > max:
        max = sum(e_p[i:i+k])

print(max)


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

e_p = []
for i in range(n):
    e_p.append(0.5*p[i]+0.5)


ans = []
s = sum(e_p[:k])
ans.append(s)
for i in range(1,n-k+1):
    s -= e_p[i-1]
    s += e_p[i+k-1]
    ans.append(s)
print(max(ans))
Buggy python submission (verdict: Runtime Error):
import math

a,b,x=map(int,input().split())

if x==a**2*b/2:
    print(45.0)
elif x>a**2*b/2:
    print(90.0-math.degrees(math.atan(a**3/(2*a**2*b-2*x))))
else:
    print(90.0-math.degrees(math.atan(2*x/(a*b**2))))


Fixed submission:
import math

a,b,x=map(int,input().split())

if x==a**2*b:
    print(0.0)
elif x>a**2*b/2:
    print(90.0-math.degrees(math.atan(a**3/(2*a**2*b-2*x))))
else:
    print(90.0-math.degrees(math.atan(2*x/(a*b**2))))

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

a,b,x=map(int,input().split())

if x>=a**2*b/2:
    print(90.0-math.degrees(math.atan(a**3/(2*a**2*b-2*x))))
else:
    print(90.0-math.degrees(math.atan(2*x/(a*b**2))))


Fixed submission:
import math

a,b,x=map(int,input().split())

if x==a**2*b:
    print(0.0)
elif x>a**2*b/2:
    print(90.0-math.degrees(math.atan(a**3/(2*a**2*b-2*x))))
else:
    print(90.0-math.degrees(math.atan(2*x/(a*b**2))))
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

n=int(input())
l=sorted(list(map(int,input().split())))

ans=0
for i in range(n):
    for j in range(i+1,n):
        ans+=bisect_left(l[j+1:], l[i]+l[j])

print(ans)


Fixed submission:
from bisect import bisect_left
N = int(input())
L = sorted(list(map(int, input().split())))
 
ans = 0
for i in range(N):  # １番短い棒
    for j in range(i + 1, N):  # 真ん中の長さの棒
        ans += bisect_left(L, L[i] + L[j]) - (j + 1)
 
print(ans)

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left

n=int(input())
l=sorted(list(map(int,input().split())))

ans=0
for i in range(n):
    for j in range(i+1,n):
        ans+=bisect.bisect_left(l[j+1:], l[i]+l[j])

print(ans)


Fixed submission:
from bisect import bisect_left
N = int(input())
L = sorted(list(map(int, input().split())))
 
ans = 0
for i in range(N):  # １番短い棒
    for j in range(i + 1, N):  # 真ん中の長さの棒
        ans += bisect_left(L, L[i] + L[j]) - (j + 1)
 
print(ans)

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

n=int(input())
l=sorted(list(map(int,input().split())))

ans=0
for i in range(n):
    for j in range(i+1,n):
        ans+=bisect.bisect_left(l[j+1:], l[i]+l[j])

print(ans)


Fixed submission:
from bisect import bisect_left
N = int(input())
L = sorted(list(map(int, input().split())))
 
ans = 0
for i in range(N):  # １番短い棒
    for j in range(i + 1, N):  # 真ん中の長さの棒
        ans += bisect_left(L, L[i] + L[j]) - (j + 1)
 
print(ans)

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

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

l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        ans+=bisect.bisect_left(l[j+1:], l[i]+l[j])

print(ans)


Fixed submission:
from bisect import bisect_left
N = int(input())
L = sorted(list(map(int, input().split())))
 
ans = 0
for i in range(N):  # １番短い棒
    for j in range(i + 1, N):  # 真ん中の長さの棒
        ans += bisect_left(L, L[i] + L[j]) - (j + 1)
 
print(ans)

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

l.sort()
l.reverse()
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]<l[j]+l[k]:
                ans+=1
            else:
                break

print(ans)


Fixed submission:
from bisect import bisect_left
N = int(input())
L = sorted(list(map(int, input().split())))
 
ans = 0
for i in range(N):  # １番短い棒
    for j in range(i + 1, N):  # 真ん中の長さの棒
        ans += bisect_left(L, L[i] + L[j]) - (j + 1)
 
print(ans)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

a,b=map(int,input().split())

gcd=gcd(a,b)

f=[]
for i in range(2,int(gcd(a,b)**0.5)+1):
    while gcd%i==0:
        gcd=gcd//i
        f.append(i)
        break
print(len(set(f))+1)


Fixed submission:
from fractions import gcd

a,b=map(int,input().split())

gcd=gcd(a,b)
ab_gcd=gcd

f=[]
for i in range(2,int(ab_gcd**0.5)+1):
    while gcd%i==0:
        gcd=gcd//i
        f.append(i)
if gcd!=1:
    f.append(gcd)

print(len(set(f))+1)

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

a,b=map(int,input().split())

gcd_num=gcd(a,b)
first_gcd=gcd_num

f=[]
while gcd_num!=1:
    for i in range(2,int(math.sqrt(first_gcd))+2):
        if gcd_num%i==0:
            gcd_num=gcd_num//i
            f.append(i)
            break
print(len(set(f))+1)


Fixed submission:
from fractions import gcd

a,b=map(int,input().split())

gcd=gcd(a,b)
ab_gcd=gcd

f=[]
for i in range(2,int(ab_gcd**0.5)+1):
    while gcd%i==0:
        gcd=gcd//i
        f.append(i)
if gcd!=1:
    f.append(gcd)

print(len(set(f))+1)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce
import itertools

a,b=map(int,input().split())

cd = []
for i in range(1,gcd(a,b)+1):
    if a%i==0 and b%i==0:
        cd.append(i)

for i in range(len(cd)):
    for comb in itertools.combinations(cd,len(cd)-i):
        for pair in itertools.combinations(comb,2):
            if gcd(pair[0],pair[1])!=1:
                break
        else:
            print(len(comb))
            exit()


Fixed submission:
from fractions import gcd

a,b=map(int,input().split())

gcd=gcd(a,b)
ab_gcd=gcd

f=[]
for i in range(2,int(ab_gcd**0.5)+1):
    while gcd%i==0:
        gcd=gcd//i
        f.append(i)
if gcd!=1:
    f.append(gcd)

print(len(set(f))+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

for i in range(m):
    a[a.index(max(a))]=max(a)//2

print(sum(a))


Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)

for i in range(m):
    max=heapq.heappop(a)
    heapq.heappush(a,(max*(-1)//2)*(-1))

print(sum(a)*(-1))
Buggy python submission (verdict: Runtime Error):
import math

n=int(input())

dic={}
for i in range(n):
    s=''.join(sorted(input()))
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
ans=0
for n in dic.values():
    ans += math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

print(ans)


Fixed submission:
import math

n=int(input())

dic={}
for i in range(n):
    s=''.join(sorted(input()))
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

ans=0
for n in dic.values():
    if n>1:
        ans += math.factorial(n) // (math.factorial(n-2) * math.factorial(2))


print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
max=0
for i in range(len(S)):
  if (S[i]=="A" or S[i]=="T" or S[i]=="C" or S[i]=="G"):
    l+=1
  else:
    if max<l:
      max=l
    l=0
print(l)

Fixed submission:
S=input()
max=0
l=0
for s in S:
  if (s=="A" or s=="T" or s=="C" or s=="G"):
    l+=1
  else:
    if max<l:
      max=l
    l=0
if max<l:
  max=l
print(max)

Buggy python submission (verdict: Runtime Error):
S=input()
max=0
for i in range(len(S)):
  if S[i]=="A" or S[i]=="T" or S[i]=="C" or S[i]=="G":
    l+=1
  else:
    if max<l:
      max=l
    l=0
print(l)

Fixed submission:
S=input()
max=0
l=0
for s in S:
  if (s=="A" or s=="T" or s=="C" or s=="G"):
    l+=1
  else:
    if max<l:
      max=l
    l=0
if max<l:
  max=l
print(max)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import *

n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
dis=[]
for i in range(1,m):
    dis.append(x[i]-x[i-1])

if n>=m:
    print(0)
else:
    for i in range(n-1):
        dis.remove(max(dis))
    print(sum(dis))


Fixed submission:
from itertools import *

n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
dis=[]
for i in range(1,m):
    dis.append(x[i]-x[i-1])
dis.sort()

if n>=m:
    print(0)
else:
    for i in range(n-1):
        dis.pop(-1)
    print(sum(dis))