Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ans=int(1)
for i in range(1,n+1):
    ans*=i
    
for i in range(1,m+1):
    ans*=i

if n==m:
    ans*=2

if abs(n-m)>1:
    ans=0

print(ans%1000000007)

Fixed submission:
n,m=map(int,input().split())
if abs(n-m)>1:
    print(0)

else:
    ans=int(1)
    for i in range(1,n+1):
        ans*=i
        ans%=1000000007
    
    for i in range(1,m+1):
        ans*=i
        ans%=1000000007

    if n==m:
        ans*=2
        ans%=1000000007
    
    print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
if abs(n-m)>1:
    print(0)

ans=int(1)
for i in range(1,n+1):
    ans*=i
    
for i in range(1,m+1):
    ans*=i

if n==m:
    ans*=2

if abs(n-m)>1:
    ans=0

print(ans%=1000000007)

Fixed submission:
n,m=map(int,input().split())
if abs(n-m)>1:
    print(0)

else:
    ans=int(1)
    for i in range(1,n+1):
        ans*=i
        ans%=1000000007
    
    for i in range(1,m+1):
        ans*=i
        ans%=1000000007

    if n==m:
        ans*=2
        ans%=1000000007
    
    print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=[0,0,0,0,0,0,0,0]
red=int(0)
for i in range(n):
    now=int(A[i]/400)
    if now<=8:
        B[now]=1
    else:
        red+=1

ans=B.count(1)
print("{} {}".format(ans,ans+red))

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
B=[0,0,0,0,0,0,0,0]
red=int(0)
for i in range(n):
    now=int(A[i]/400)
    if now<8:
        B[now]=1
    else:
        red+=1

ans=B.count(1)
if ans==0:
    ans=1
    red-=1
print("{} {}".format(ans,ans+red))

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=[0,0,0,0,0,0,0,0,0]
for i in range(n):
    now=int(A[i]/400)
    B[now]+=1

ans=int(0)
for i in range(8):
    if B[i]>0:
        ans+=1
    
print("{} {}".format(ans,ans+B[8]))

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
B=[0,0,0,0,0,0,0,0]
red=int(0)
for i in range(n):
    now=int(A[i]/400)
    if now<8:
        B[now]=1
    else:
        red+=1

ans=B.count(1)
if ans==0:
    ans=1
    red-=1
print("{} {}".format(ans,ans+red))
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=int(1)
for i in range(1,n+1):
	ans*=i
    ans%=1000000007
print(ans)

Fixed submission:
n=int(input())
ans=int(1)
for i in range(1,n+1):
    ans*=i
    ans%=1000000007
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
co=int(0)
for i in range(n):
    now=int(input())
    if now%2==1:
        co+=1
if co%2==1:
    print("NO")
else:
    print("YES")

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
co=int(0)
for i in range(n):
    if A[i]%2==1:
        co+=1
if co%2==1:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
print(n*pow(n-1,k-1))

Fixed submission:
n,k=map(int,input().split())
print(k*pow(k-1,n-1))
Buggy python submission (verdict: Runtime Error):
s=str(input())
co=int(1)
n=len(s)
A=[]
for i in range(1,n):
    if s[i]!=s[i-1]:
        A.append(co)
        co=1
    else:
        co+=1
A.append(co)
m=len(A)
how=0
if s[0]=='T':
    how=1

for i in range(how,m-how):
    if i%2!=how:
        continue

    if A[i]<A[i+1]:
        n-=2*A[i]
    else:
        n-=2*A[i+1] 
print(n)

Fixed submission:
s=str(input())
co=int(1)
n=len(s)
A=[]
for i in range(1,n):
    if s[i]!=s[i-1]:
        A.append(co)
        co=1
    else:
        co+=1
A.append(co)
m=len(A)
how=0
if s[0]=='T':
    how=1

S=int(0)
T=int(0)
for i in range(how,m-how):
    if i%2==how:##s
        S+=A[i]
    else:##t
        T+=A[i]
        if S<T:
            n-=2*S
            T=0
            S=0
        else:
            n-=2*T
            S-=T
            T=0


print(n)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a%2==0 or b%2==0 or c%2==0:
    print(0)
    exit()

print(min[a*b,b*c,c*a])

Fixed submission:
a,b,c=map(int,input().split())
if a%2==0 or b%2==0 or c%2==0:
    print(0)
    exit()
x=[a*b,b*c,c*a]
print(min(x))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if	a*b*c==5*5*7
	print("YES")
else
	print("NO")

Fixed submission:
a,b,c=map(int,input().split())
if	a*b*c==5*5*7:
	print("YES")
else:
	print("NO")
Buggy python submission (verdict: Runtime Error):
n,m=int(input()),10**9+7
print((pow(10,p,m)-2*pow(9,p,m)+pow(8,p,m))%m)

Fixed submission:
n,m=int(input()),10**9+7
print((pow(10,n,m)-2*pow(9,n,m)+pow(8,n,m))%m)
Buggy python submission (verdict: Runtime Error):
h,w,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b,c=[0]*h,[0]*w
for t1,t2 in a:
    b[t1-1]+=1
    c[t2-1]+=1
bm,cm=max(b),max(c)
b1,c1=[],[]
d=[]
for x,y in a:
    d.append((x-1,y-1))
d=set(d)
for i in range(h):
    if b[i]==bm:
        b1.append(i)
for i in range(w):
    if c[i]==cm:
        c1.append(i)
f=1
for i in b1:
    for j in c1:
        if (i,j) not in d:
            f=0
print(bm+cm-f)

Fixed submission:
import math
n,x,t=map(int,input().split())
print(math.ceil(n/x)*t)
Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b,c=[0]*h,[0]*w
for t1,t2 in a:
    b[t1-1]+=1
    c[t2-1]+=1
bm,cm=max(b),max(c)
b1,c1=[],[]
d=[]
for x,y in a:
    d.append((x-1,y-1))
d=set(d)
for i in range(h):
    if b[i]==bm:
        b1.append(i)
for i in range(w):
    if c[i]==cm:
        c1.append(i)
f=1
for i in b1:
    for j in c1:
        if (i,j) not in d:
            f=0
print(bm+cm-f)

Fixed submission:
h,w,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b,c=[0]*h,[0]*w
for t1,t2 in a:
    b[t1-1]+=1
    c[t2-1]+=1
bm,cm=max(b),max(c)
b1,c1=[],[]
d=[]
for x,y in a:
    d.append((x-1,y-1))
d=set(d)
for i in range(h):
    if b[i]==bm:
        b1.append(i)
for i in range(w):
    if c[i]==cm:
        c1.append(i)
for i in b1:
    for j in c1:
        if (i,j) not in d:
            print(bm+cm)
            exit()
print(bm+cm-1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b,c=[0]*h,[0]*w
for t1,t2 in a:
    b[t1-1]+=1
    c[t2-1]+=1
bm,cm=max(b),max(c)
b1,c1=[],[]
d=[]
for x,y in a:
    d.append((x-1,y-1))
d=set(d)
for i in range(h):
    if b[i]==bm:
        b1.append(i)
for i in range(w):
    if c[i]==cm:
        c1.append(i)
f=1
for i in b1:
    for j in c1:
        if (i,j) not in d:
            f=0
print(bm+cm-f)

Fixed submission:
h,w,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
b,c=[0]*h,[0]*w
for t1,t2 in a:
    b[t1-1]+=1
    c[t2-1]+=1
bm,cm=max(b),max(c)
b1,c1=[],[]
d=[]
for x,y in a:
    d.append((x-1,y-1))
d=set(d)
for i in range(h):
    if b[i]==bm:
        b1.append(i)
for i in range(w):
    if c[i]==cm:
        c1.append(i)
for i in b1:
    for j in c1:
        if (i,j) not in d:
            print(bm+cm)
            exit()
print(bm+cm-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=[[] for _ in range(n+10)]
for i in range(1,n+1):
    for j in range(1,n+1):
        if i*j>=n+2:
            break
        ans[i*j].append(i)
a=0
for i in range(n+1):
    a+=i*len(ans[i])
print(a)

Fixed submission:
n,a=int(input()),0
for x in range(1,n+1):
    y=n//x
    a+=y*(y+1)*x//2
print(a)
Buggy python submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
l,r=-1,10**19
while r-l>1:
    m=(l+r)//2
    b=0
    for w,d in a:
        b+=(m-w+d)//d
    if b<k:
        l=m
    else:
        r=m
print(r+1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
q=int(input())
l=[0]*10**6
s=sum(a)
for i in range(n):
    l[a[i]]+=1
for i in range(q):
    b,c=map(int,input().split())
    s+=(c-b)*l[b]
    l[c]+=l[b]
    l[b]=0
    print(s)
Buggy python submission (verdict: Runtime Error):
def ra(a): #圧縮された要素を非保持
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll

n=int(input())
a=list(map(int,input().split()))
b=[1]*(10**6+10)
c=0
d=ra(a)
for i in d:
    if i!=1:
        c-=i
for i in range(n):
    e=a[i]
    for j in range(2,10**6+4):
        b[a[i]*j]=0
        if a[i]*(j+1)>=10**6+5:
            break
for i in range(n):
    c+=b[a[i]]
print(c)

Fixed submission:
n,x=int(input()),10**6+100
a,b,c=list(map(int,input().split())),[0]*(2*x),0
for i in a:
    b[i]+=1
for i in range(x):
    c+=1 if b[i]==1 else 0
    if b[i]==0:
        continue
    for j in range(1,x):
        if i*j>=x:
            break
        b[i*j]=0
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[1]*(2*10**6)
c=0
for i in range(n):
    j=a[i]
    while j<19*10**5:
        b[j+a[i]]=0
        j+=a[i]
a.sort()
if a==[a[0]]*n:
    c-=1
for i in range(n-1):
    if a[i]==a[i+1]:
        c-=1
        f=1
        if f==0:
            c-=1
    else:
        f=0
for i in range(n):
    c+=b[a[i]]
print(c)

Fixed submission:
n,x=int(input()),10**6+100
a,b,c=list(map(int,input().split())),[0]*(2*x),0
for i in a:
    b[i]+=1
for i in range(x):
    c+=1 if b[i]==1 else 0
    if b[i]==0:
        continue
    for j in range(1,x):
        if i*j>=x:
            break
        b[i*j]=0
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=1
for i in range(n):
    b*=a[i]
print(b if b<=10**18 else -1)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    b*=a[i]
    if b>10**18:
        print(-1)
        exit()
print(b)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
a=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted(a,key=lambda x:x[1])
if n%2==1:
    print(b[n//2][1]-a[n//2][0]+1)
else:
    print((b[n//2-1][1]+b[n//2][1])-(a[n//2-1][0]-a[n//2][0]))//2)

Fixed submission:
n=int(input())
a=sorted([list(map(int,input().split())) for i in range(n)])
b=sorted(a,key=lambda x:x[1])
if n%2==1:
    print(b[n//2][1]-a[n//2][0]+1)
else:
    print((b[n//2-1][1]+b[n//2][1])-(a[n//2-1][0]+a[n//2][0])+1)
Buggy python submission (verdict: Time Limit Exceeded):
import queue
n,x,y=map(int,input().split())
edge=[[i-1,i+1] for i in range(n)]
edge[0],edge[-1]=[1],[n-2]
edge[x-1].append(y-1)
edge[y-1].append(x-1)
inf=10**6
ans=[0]*n
for i in range(n):
    q=queue.deque([i])
    dist=[inf]*n
    dist[i]=1
    while q:
        a=q.pop()
        for e in edge[a]:
            if dist[e]==inf:
                q.appendleft(e)
                dist[e]=dist[a]+1
    for v in dist:
        ans[v-1]+=1
for i in range(n-1):
    print(ans[i+1]//2)

Fixed submission:
import queue
n,x,y=map(int,input().split())
edge=[[i-1,i+1] for i in range(n)]
edge[0],edge[-1]=[1],[n-2]
edge[x-1].append(y-1)
edge[y-1].append(x-1)
inf=10**6
ans=[0]*n
for i in range(n):
    q=queue.deque([i])
    dist=[inf]*n
    dist[i]=1
    while q:
        a=q.pop()
        for e in edge[a]:
            if dist[e]==inf:
                q.appendleft(e)
                dist[e]=dist[a]+1
    for v in dist:
        ans[v-1]+=1
for i in range(n-1):
    print(ans[i+1]//2)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a>9:
    print(b)
else:
    print(b+(100＊(10-a))

Fixed submission:
a,b=map(int,input().split())
if a>=10:
    print(b)
else:
    print(b+(100*(10-a)))
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
inf=10**9
dp=[inf]*(h+10**5)
dp[0]=0
#dp[i]=モンスターの体力をi減らすのに魔力が最低でいくつ必要か
for i in range(h):
    for a,b in l:
        dp[i+a]=min(dp[i+a],dp[i]+b)
ans=10**9
for i in range(10**5):
    ans=min(ans,dp[i+h])
print(ans)

Fixed submission:
h,n=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
inf=10**9
dp=[inf]*(h+10**5)
dp[0]=0
#dp[i]=モンスターの体力をi減らすのに魔力が最低でいくつ必要か
for i in range(h):
    for a,b in l:
        dp[i+a]=min(dp[i+a],dp[i]+b)
ans=10**9
for i in range(10**5):
    ans=min(ans,dp[i+h])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
from fractions import gcd
def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
b=lcm(a)
c=0
for i in range(n):
    c+=(b//a[i])%(10**9+7)
print(c%(10**9+7))

Fixed submission:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
a=list(map(int,input().split()))
b=0
l=lcm_list(a)
for i in range(n):
    b+=l//a[i]
print(b%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
a=list(map(int,input().split()))
b=0
l=lcm_list(a)
for i in range(n):
    b+=l//a[i]
print(b%(10**9+7))

Fixed submission:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
a=list(map(int,input().split()))
b=0
l=lcm_list(a)
for i in range(n):
    b+=l//a[i]
print(b%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
w,l=0,[0]*n
for i in range(m):
    p,s=input().split()
    p,f=int(p)-1,l[p]>=0
    if s=='AC':
        w+=l[p]*f
        l[p]=-1
    else:
        l[p]+=f
print(l.count(-1),w)

Fixed submission:
n,m=map(int,input().split())
a=[]
for i in range(n):
    a.append([0,0])
b=[]
c=0
d=0
for i in range(m):
    b.append(list(input().split()))
    b[i][0]=int(b[i][0])
a=sorted(a,key=lambda x:x[0])
for i in range(m):
    if b[i][1]=='WA':
        if a[b[i][0]-1][0]==0:
            a[b[i][0]-1][1]+=1
    else:
        if a[b[i][0]-1][0]==0:
            a[b[i][0]-1][0]=1
for i in range(n):
    c+=a[i][0]
    if a[i][0]==1:
        d+=a[i][1]
print(c,d)
Buggy python submission (verdict: Time Limit Exceeded):
import queue

def bfs(maze,h,w,sy,sx,gy,gx):
    dist=[[-1 for _ in range(w)] for _ in range(h)]
    q=queue.deque([[sy,sx]])
    dist[sy][sx]=0
    while q:
        y,x=q.popleft()
        for dy,dx in d:
            ny,nx=y+dy,x+dx
            if 0<=ny<h and 0<=nx<w and dist[ny][nx]==-1 and maze[ny][nx]!='#':
                dist[ny][nx]=dist[y][x]+1
                q.append([ny,nx])
    return dist[gy][gx]

h,w=map(int,input().split())
a=[input() for _ in range(h)]
d=[[1,0],[0,1],[-1,0],[0,-1]]
ans=0
for sy in range(h):
    for sx in range(w):
        for gy in range(h):
            for gx in range(w):
                if a[sy][sx]!='#' and a[gy][gx]!='#':
                    ans=max(ans,bfs(a,h,w,sy,sx,gy,gx))
print(ans)

Fixed submission:
import queue

def bfs(maze,h,w,sy,sx):
    dist=[[-1 for _ in range(w)] for _ in range(h)]
    q=queue.deque([[sy,sx]])
    dist[sy][sx]=0
    while q:
        y,x=q.popleft()
        for dy,dx in d:
            ny,nx=y+dy,x+dx
            if 0<=ny<h and 0<=nx<w and dist[ny][nx]==-1 and maze[ny][nx]!='#':
                dist[ny][nx]=dist[y][x]+1
                q.append([ny,nx])
    return max([max(i) for i in dist])

h,w=map(int,input().split())
a=[input() for _ in range(h)]
d=[[1,0],[0,1],[-1,0],[0,-1]]
ans=0
for sy in range(h):
    for sx in range(w):
        if a[sy][sx]!='#':
            ans=max(ans,bfs(a,h,w,sy,sx))
print(ans)

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

def bfs(maze,h,w,sy,sx,gy,gx):
    dist=[[-1 for _ in range(w)] for _ in range(h)]
    q=queue.deque([[sy,sx]])
    dist[sy][sx]=0
    while q:
        y,x=q.popleft()
        for dy,dx in d:
            ny,nx=y+dy,x+dx
            if 0<=ny<h and 0<=nx<w and dist[ny][nx]==-1 and maze[ny][nx]!='#':
                dist[ny][nx]=dist[y][x]+1
                q.append([ny,nx])
    return dist[gy][gx]

h,w=map(int,input().split())
a=[input() for _ in range(h)]
d=[[1,0],[0,1],[-1,0],[0,-1]]
ans=0
for sy in range(h):
    for sx in range(w):
        for gy in range(h):
            for gx in range(w):
                if a[sy][sx]!='#' and a[gy][gx]!='#':
                    ans=max(ans,bfs(a,h,w,sy,sx,gy,gx))
print(ans)

Fixed submission:
import queue

def bfs(maze,h,w,sy,sx):
    dist=[[-1 for _ in range(w)] for _ in range(h)]
    q=queue.deque([[sy,sx]])
    dist[sy][sx]=0
    while q:
        y,x=q.popleft()
        for dy,dx in d:
            ny,nx=y+dy,x+dx
            if 0<=ny<h and 0<=nx<w and dist[ny][nx]==-1 and maze[ny][nx]!='#':
                dist[ny][nx]=dist[y][x]+1
                q.append([ny,nx])
    return max([max(i) for i in dist])

h,w=map(int,input().split())
a=[input() for _ in range(h)]
d=[[1,0],[0,1],[-1,0],[0,-1]]
ans=0
for sy in range(h):
    for sx in range(w):
        if a[sy][sx]!='#':
            ans=max(ans,bfs(a,h,w,sy,sx))
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a,c,e,f=[],[],0,0
for i in range(n):
    a.append(int(input()))
    b=[]
    for i in range(a[-1]):
        b.append(list(map(int,input().split())))
    c.append(b)
for i in range(2**n):
    d=bin(i)[2:-1]+bin(i)[-1]
    d='0'*(n-len(d))+d
    for j in range(n):
        if d[j]==1:
            e+=1
    for j in range(n):
        if d[j]==0:
            continue
        for k in range(a[j]):
            if d[c[j][k][0]]!=c[j][k][1]:
                g=True
                continue
    if g:
        continue
    f=max(e,f)
print(f)

Fixed submission:
n=int(input())
s=[]
ans=0
for i in range(n):
    a=int(input())
    s.append([list(map(int,input().split())) for _ in range(a)])
for i in range(2**n):
    bit=bin(i)[2:].zfill(n)
    flag=1
    for j in range(n):
        if bit[j]=='0':
            continue
        for sh in s[j]:
            if int(bit[sh[0]-1])!=sh[1]:
                flag=0
    if flag:
        ans=max(ans,bit.count('1'))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
ans=0
for i in range(1000):
    i=str(i).zfill(3)
    a=0
    for c in s:
        if c==i[a]:
            a+=1
        if a==3:
            ans+=1
            break
print(ans)

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(1000):
    i=str(i).zfill(3)
    a=0
    for c in s:
        if c==i[a]:
            a+=1
        if a==3:
            ans+=1
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
import collections
n=int(input())
a,b,c,d=[],[],[],[]
for i in range(n):
    b.append([])
for i in range(n-1):
    a.append(list(map(int,input().split())))
for i in range(n-1):
    j=0
    d.append(a[i][0])
    d.append(a[i][1])
    while True:
        if j not in b[a[i][0]-1] and j not in b[a[i][1]-1]:
            c.append(j)
            b[a[i][0]-1].append(j)
            b[a[i][1]-1].append(j)
            break
        j+=1
print(collections.Counter(d).most_common()[0][1])
for i in range(n-1):
    print(c[i]+1)


Fixed submission:
a=['SUN','MON','TUE','WED','THU','FRI','SAT']
print(7-a.index(input()))
Buggy python submission (verdict: Runtime Error):
import math
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
z=list(map(int,input().split()))
print(len(set(factorize(math.gcd(z[0],z[1]))))+1)

Fixed submission:
import math
def euclid(a,b):
    if b==0:
        return a
    else:
        return euclid(b,a%b)
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
z=list(map(int,input().split()))
print(len(set(factorize(euclid(z[0],z[1]))))+1)

Buggy python submission (verdict: Runtime Error):
import math
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
z=list(map(int,input().split()))
print(len(set(factorize(math.gcd(z[0],z[1]))))+1)

Fixed submission:
import math
def euclid(a,b):
    if b==0:
        return a
    else:
        return euclid(b,a%b)
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
z=list(map(int,input().split()))
print(len(set(factorize(euclid(z[0],z[1]))))+1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
z=list(map(int,input().split()))
a,b,c=[],[],z[2]-z[1]
for i in range(z[2]):
    a.append(int(input()))
for i in range(z[0]):
    b.append(a.count(i+1))
for i in range(z[0]):
    if c-b[i]>=0:
        print('No')
    else:
        print('Yes')

Fixed submission:
n,k,q=map(int,input().split())
a,b=[int(input()) for _ in range(q)],[0]*n
for i in a:
    b[i-1]+=1
for i in b:
    print('Yes' if i+k-q>0 else 'No')

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
z=list(map(int,input().split()))
a,b,c=[],[],z[2]-z[1]
for i in range(z[2]):
    a.append(int(input()))
for i in range(z[0]):
    if c-a.count(i+1)>=0:
        print('No')
    else:
        print('Yes')

Fixed submission:
n,k,q=map(int,input().split())
a,b=[int(input()) for _ in range(q)],[0]*n
for i in a:
    b[i-1]+=1
for i in b:
    print('Yes' if i+k-q>0 else 'No')

Buggy python submission (verdict: Time Limit Exceeded):
z=list(map(int,input().split()))
a=[]
b=[]
for i in range(z[2]):
    a.append(int(input()))
for i in range(z[0]):
    if z[2]-a.count(i+1)>=z[1]:
        print('No')
    else:
        print('Yes')


Fixed submission:
n,k,q=map(int,input().split())
a,b=[int(input()) for _ in range(q)],[0]*n
for i in a:
    b[i-1]+=1
for i in b:
    print('Yes' if i+k-q>0 else 'No')
Buggy python submission (verdict: Runtime Error):
n=list(map(int,input().split()))
s=input()
a,b,c=[],s[0],0
if n[0]==1:
    print('0')
for i in range(n[0]-1):
    if b==s[i+1]:
        c+=1
    else:
        a.append(c)
        c=0
    b=s[i+1]
if c!=0:
    a.append(c)
if s[-2]==s[-1]:
    a[-1]+=1
else:
    a.append(1)
if n[1]>=len(a)//2:
    print(n[0]-1)
else:
    print(sum(a)+2*n[1]-1)

Fixed submission:
import sys
n=list(map(int,input().split()))
s=input()
a,b,c=[],s[0],0
if n[0]==1:
    print('0')
    sys.exit()
for i in range(n[0]-1):
    if b==s[i+1]:
        c+=1
    else:
        a.append(c)
        c=0
    b=s[i+1]
if c!=0:
    a.append(c)
if s[-2]==s[-1]:
    a[-1]+=1
else:
    a.append(1)
if n[1]>=len(a)//2:
    print(n[0]-1)
else:
    print(sum(a)+2*n[1]-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
a,b=0,[]
for i in range(1000000):
    if h[i]<h[i+1]:
        b.append(i-a)
        a=i+1
    if i+2==len(h):
        b.append(i-a+1)
        break
print(max(b))

Fixed submission:
import sys
n=int(input())
h=list(map(int,input().split()))
a,b=0,[]
if len(h)==1:
    print('0')
    sys.exit()
for i in range(1000000):
    if h[i]<h[i+1]:
        b.append(i-a)
        a=i+1
    if i+2==len(h):
        b.append(i-a+1)
        break
print(max(b))

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
a,b=0,[]
for i in range(1000000):
    if h[i]<h[i+1]:
        b.append(i-a)
        a=i+1
    if i+2==len(h):
        b.append(i-a+1)
        break
print(b)

Fixed submission:
import sys
n=int(input())
h=list(map(int,input().split()))
a,b=0,[]
if len(h)==1:
    print('0')
    sys.exit()
for i in range(1000000):
    if h[i]<h[i+1]:
        b.append(i-a)
        a=i+1
    if i+2==len(h):
        b.append(i-a+1)
        break
print(max(b))