Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())

ans = -1

for i in range(1,N+1):
    if int(i*1.08) == N:
        ans = i

if ans =! -1:
    print(ans)
else:
    print(":(")


Fixed submission:
N = int(input())

ans = -1

for i in range(1,N+1):
    if int(i*1.08) == N:
        ans = i

if ans != -1:
    print(ans)
else:
    print(":(")

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

ans = -1

for i in range(1,N+1):
    if int(int(i)*1.08) == N:
        ans = i

if ans =! -1:
    print(ans)
else:
    print(":(")


Fixed submission:
N = int(input())

ans = -1

for i in range(1,N+1):
    if int(i*1.08) == N:
        ans = i

if ans != -1:
    print(ans)
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())

count = 0
r = math.gcd(a,b)
for i in range (1,r+1):
    if r % i == 0 :
        count += 1
print(count)


Fixed submission:
number = int(input())

count = 0
for i in range (1,number+1):
    if i % 2 == 1:
        count += 1
answer = count / number
print(answer)
Buggy python submission (verdict: Runtime Error):
M,N = map(int, input().split())
count = 0
for _ in range(M):
    a, b = map(int, input().split())
    X = a*a + b*b
    if X <= N*N:
        count += 1
 
print(count)

Fixed submission:
X = int(input())
 
if X >= 30:
    print("Yes")
 
else:
    print("No")

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

a=0

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

Fixed submission:
X = int(input())
 
if X >= 30:
    print("Yes")
 
else:
    print("No")

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

A = 0

for i in range(N):
  X,Y = map(int, input().split())
  
for g in range(N):
  if X**2 + Y**2 <= D**2:
    A += 1
    
print(A)

Fixed submission:
X = int(input())
 
if X >= 30:
    print("Yes")
 
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = Counter(A).most_common()

MAXN = max(A)
B = [False]*(MAXN+1)
for c in C:
    B[c[0]] = True
ans = 0
for i in range(MAXN + 1):
    if B[i]:
        if C[i]==1:
            ans += 1
        B[i::i] = [False]*(MAXN//i)
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = Counter(A)

MAXN = max(A)
B = [False]*(MAXN+1)
for c in C.most_common():
    B[c[0]] = True
ans = 0
for i in range(MAXN + 1):
    if B[i]:
        if C[i]==1:
            ans += 1
        B[i::i] = [False]*(MAXN//i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop,heappush
N,M = map(int,input().split())
T = [[] for i in range(N)]
for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    T[a].append(b)
    T[b].append(a)

INF = float("inf")
D = [INF]*N
A = [0]*N
Q = [[0,0,-1]]
while Q:
    d,v,p = heappop(Q)
    if d >= D[v]:continue
    A[v] = p
    D[v] = d
    d += 1
    for c in T[v]:
        heappush(Q,[d,c,v])
if INF in D:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(A[i]+1)

Fixed submission:
from heapq import heappop,heappush
N,M = map(int,input().split())
T = [[] for i in range(N)]
for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    T[a].append(b)
    T[b].append(a)

INF = float("inf")
D = [INF]*N
A = [0]*N
Q = [[0,0,-1]]
while Q:
    d,v,p = heappop(Q)
    if d >= D[v]:continue
    A[v] = p
    D[v] = d
    d += 1
    for c in T[v]:
        if c == p:continue
        if d >= D[c]:continue
        heappush(Q,[d,c,v])
if INF in D:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(A[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop,heappush
N,M = map(int,input().split())
T = [[] for i in range(N)]
for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    T[a].append(b)
    T[b].append(a)

INF = float("inf")
D = [INF]*N
A = [0]*N
Q = [[0,0,-1]]
while Q:
    d,v,p = heappop(Q)
    if d >= D[v]:continue
    A[v] = p
    D[v] = d
    d += 1
    for c in T[v]:
        heappush(Q,[d,c,v])
if INF in D:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(A[i]+1)

Fixed submission:
from heapq import heappop,heappush
N,M = map(int,input().split())
T = [[] for i in range(N)]
for i in range(M):
    a,b = map(lambda x:int(x)-1,input().split())
    T[a].append(b)
    T[b].append(a)

INF = float("inf")
D = [INF]*N
A = [0]*N
Q = [[0,0,-1]]
while Q:
    d,v,p = heappop(Q)
    if d >= D[v]:continue
    A[v] = p
    D[v] = d
    d += 1
    for c in T[v]:
        if c == p:continue
        if d >= D[c]:continue
        heappush(Q,[d,c,v])
if INF in D:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(A[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

D = [0]
for i in range(N):
    D.append(A[i]+D[i])
ans = 0
for i in range(N):
    a = i+A[i]
    S = D[N]-D[i+1]
    for absij in range(1,N-a):
        j = a+absij
        if absij>S:break
        if A[i]+A[j]==j-i:
            ans+=1
        S-=A[j]
print(ans)

Fixed submission:
from collections import Counter

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

L = [A[i]+i for i in range(N)]
R = [j-A[j] for j in range(N)]

l = Counter(L)
r = Counter(R)

ans = 0
for i in l.keys():
    ans += l[i]*r[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,M,Q = map(int,input().split())

numbers = deque([[i+1] for i in range(M)])

for i in range(N):
    a = deque([])
    while numbers:
        l = numbers.pop()
        b = l[-1]
        for j in range(b,M+1):
            a.append(l+[j])
    numbers = a

X = []
for i in range(Q):
    a,b,c,d = map(int,input().split())
    X.append((a,b,c,d))

ans = 0
while numbers:
    cnt = 0
    L = numbers.pop()
    for x in X:
        a,b,c,d = x
        if L[b-1]-L[a-1]==c:
            cnt+=d
    ans = max(ans,cnt)
print(ans)

Fixed submission:
from collections import deque
N,M,Q = map(int,input().split())

numbers = deque([[i+1] for i in range(M)])

for i in range(N):
    a = deque([])
    while numbers:
        l = numbers.pop()
        b = l[-1]
        for j in range(b,M+1):
            a.append(l+[j])
    numbers = a

X = []
for i in range(Q):
    a,b,c,d = map(int,input().split())
    X.append((a,b,c,d))

ans = 0
while numbers:
    cnt = 0
    L = numbers.pop()
    for x in X:
        a,b,c,d = x
        if L[b-1]-L[a-1]==c:
            cnt+=d
    ans = max(ans,cnt)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

from collections import defaultdict
mod = 2019
N = len(S)
D = defaultdict(int)
S = S[::-1]
ans = 0
T = [0]
D[0]+=1
for i in range(N):
    s = int(S[i])*pow(10,i)
    T.append((T[i]+s)%mod)
    ans += D[T[i+1]]
    D[T[i+1]]+=1
print(ans)

Fixed submission:
S = input()

from collections import defaultdict
mod = 2019
N = len(S)
D = defaultdict(int)
S = S[::-1]
ans = 0
T = 0
D[0]+=1
for i in range(N):
    s = int(S[i])*pow(10,i,mod)
    T = (T+s)%mod
    ans += D[T]
    D[T]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
mod = 2019
S = input()
N = len(S)

S = S[::-1]
A = []
for i in range(N):
    s = int(S[i])*pow(10,i)
    A.append(s%mod)
B = [0]
for i in range(N):
    s = B[i]+A[i]
    B.append(s%mod)

D = defaultdict(int)
for i in range(N+1):
    D[B[i]]+=1
ans = 0
for key in D.keys():
    m = D[key]
    ans += m*(m-1)//2
print(ans)

Fixed submission:
S = input()

from collections import defaultdict
mod = 2019
N = len(S)
D = defaultdict(int)
S = S[::-1]
ans = 0
T = 0
D[0]+=1
for i in range(N):
    s = int(S[i])*pow(10,i,mod)
    T = (T+s)%mod
    ans += D[T]
    D[T]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
mod = 2019
S = input()
N = len(S)

S = S[::-1]
A = []
for i in range(N):
    s = int(S[i])*pow(10,i)
    A.append(s%mod)
B = [0]
for i in range(N):
    s = B[i]+A[i]
    B.append(s%mod)

C = Counter(B)
ans = 0
for key in C.keys():
    m = C[key]
    ans += m*(m-1)//2
print(ans)

Fixed submission:
S = input()

from collections import defaultdict
mod = 2019
N = len(S)
D = defaultdict(int)
S = S[::-1]
ans = 0
T = 0
D[0]+=1
for i in range(N):
    s = int(S[i])*pow(10,i,mod)
    T = (T+s)%mod
    ans += D[T]
    D[T]+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
mod = 2019
S = input()
N = len(S)

S = S[::-1]
A = []
for i in range(N):
    s = int(S[i])*pow(10,i)
    A.append(s%mod)
B = [0]
for i in range(N):
    s = B[i]+A[i]
    B.append(s%mod)

C = Counter(B)
ans = 0
for key in C.keys():
    m = C[key]
    ans += m*(m-1)//2
print(ans)

Fixed submission:
S = input()

from collections import defaultdict
mod = 2019
N = len(S)
D = defaultdict(int)
S = S[::-1]
ans = 0
T = 0
D[0]+=1
for i in range(N):
    s = int(S[i])*pow(10,i,mod)
    T = (T+s)%mod
    ans += D[T]
    D[T]+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

C = [0]*3
for i in range(N):
    c = "RGB".index(S[i])
    C[c]+=1

K = 0
for i in range(N-2):
    for j in range(i,N):
        k = 2*j-i
        if k>=N:break
        if len(set([S[i],S[j],S[k]]))==3:
            K+=1
print(C[0]*C[1]*C[2]-K)

Fixed submission:
N = int(input())
S = input()

C = [0]*3
for i in range(N):
    c = "RGB".index(S[i])
    C[c]+=1

K = 0
for i in range(N-2):
    for j in range(i,N):
        k = 2*j-i
        if k>=N:break
        if len(set([S[i],S[j],S[k]]))==3:
            K+=1
print(C[0]*C[1]*C[2]-K)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
A = "0123456789"
S = [i for i in range(1,10)]
Q = [str(i) for i in range(1,10)]
while Q:
    q = Q.pop(0)
    D = []
    if q[-1]=="0":
        D = [q+"0",q+"1"]
    elif q[-1]=="9":
        D = [q+"0",q+"1"]
    else:
        a = A.index(q[-1])
        D = [q+A[a-1],q+A[a],q+A[a+1]]
    for d in D:
        S.append(int(d))
        if len(d)<11:
            Q.append(d)
S.sort()
print(S[K-1])

Fixed submission:
K = int(input())
A = "0123456789"
S = []
def f(n):
    global A,S
    if len(n)>10:return
    if n[-1]=="0":
        D=(n+"0",n+"1")
    elif n[-1]=="9":
        D=(n+"9",n+"8")
    else:
        a = A.index(n[-1])
        D=(n+A[a],n+A[a-1],n+A[a+1])
    for d in D:
        S.append(int(d))
        f(d)

for i in range(1,10):
    S.append(i)
    f(str(i))
S.sort()
print(S[K-1])
Buggy python submission (verdict: Runtime Error):
H,N = map(int,input().split())
A = list(map(int,input().split()))
if sum(A)>=H:print("yes")
else:print("No")H,N = map(int,input().split())
A = list(map(int,input().split()))
if sum(A)>=H:print("yes")
else:print("No")

Fixed submission:
H,N = map(int,input().split())
A = list(map(int,input().split()))
if sum(A)>=H:print("Yes")
else:print("No")
Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))

Fixed submission:
H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))

Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH):
        if j+a>MAXH-1:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))

Fixed submission:
H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))

Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
A = []
for i in range(N):
    a,b = map(int,input().split())
    A.append((a,b))
MAXH = H+10000
DP = [float("inf")]*(MAXH)
DP[0] = 0
for i in range(0,MAXH):
    for a in A:
        if i-a[0]<0:continue
        DP[i] = min(DP[i],DP[i-a[0]]+a[1])
print(min(DP[H:]))

Fixed submission:
H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))

Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
A = []
for i in range(N):
    a,b = map(int,input().split())
    A.append((a,b))
A.sort()
MAXH = H+10**4
DP = [float("inf")]*(MAXH)
DP[0] = 0
for i in range(MAXH):
    for j in range(N):
        if i+A[j][0]>MAXH-1:break
        DP[i+A[j][0]] = min(DP[i]+A[j][1],DP[i+A[j][0]])
print(min(DP[H:]))

Fixed submission:
H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))

Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
A = []
for i in range(N):
    a,b = map(int,input().split())
    A.append((a,b))
MAXH = H+10**4
DP = [float("inf")]*(MAXH)
DP[0] = 0
for i in range(MAXH):
    for j in range(N):
        if i+A[j][0]>MAXH-1:continue
        DP[i+A[j][0]] = min(DP[i]+A[j][1],DP[i+A[j][0]])
print(min(DP[H:]))

Fixed submission:
H,N = map(int,input().split())
MAXH = H+10000
DP = [float("inf")]*MAXH
DP[0] = 0
for i in range(N):
    a,b = map(int,input().split())
    for j in range(MAXH-a):
        if j>H+a:break
        DP[j+a] = min(DP[j+a],DP[j]+b)
print(min(DP[H:]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

def gcd(x,y):
    if x<y:x,y=y,x
    if y==0:return x
    return gcd(y,x%y)
S = [A[1]//gcd(A[0],A[1]),A[0]//gcd(A[0],A[1])]
for i in range(2,N):
    a = A[i-1]*S[i-1]
    b = A[i]*a//gcd(A[i],a)
    c = b//a
    S = list(map(lambda x:x*c,S))
    S.append(b//A[i])
print(sum(S)%mod)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
def gcd(x,y):
    if x<y:x,y=y,x
    if y==0:return x
    return gcd(y,x%y)
a = 1
for i in range(N):
    a = a*A[i]//gcd(a,A[i])
ans = 0
for i in range(N):
    ans+= a//A[i]
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

mod = pow(10,9)+7

K = 60
P = [0]*K
Z = [0]*K
for a in A:
    n = a
    for i in range(K):
        b = n%2
        if b:P[i]+=1
        else:Z[i]+=1
        n//=2
ans = 0
for k in range(K):
    ans+=(pow(2,k,mod)*(P[k]*Z[k]))%mod
print(ans%mod)

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

mod = pow(10,9)+7

K = 60
P = [0]*K
Z = [0]*K
for a in A:
    n = a
    for i in range(K):
        b = n%2
        if b:P[i]+=1
        else:Z[i]+=1
        n//=2
ans = 0
for k in range(K):
    ans+=(pow(2,k,mod)*(P[k]*Z[k]))%mod
print(ans%mod)

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

mod = pow(10,9)+7

K = 60
P = [0]*K
Z = [0]*K
for a in A:
    n = a
    for i in range(K):
        b = n%2
        if b:P[i]+=1
        else:Z[i]+=1
        n//=2
ans = 0
for k in range(K):
    ans+=(pow(2,k,mod)*(P[k]*Z[k]))%mod
print(ans%mod)

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

mod = pow(10,9)+7

K = 60
P = [0]*K
Z = [0]*K
for a in A:
    n = a
    for i in range(K):
        b = n%2
        if b:P[i]+=1
        else:Z[i]+=1
        n//=2
ans = 0
for k in range(K):
    ans+=(pow(2,k,mod)*(P[k]*Z[k]))%mod
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for k in range(61):
    o = 0
    for i in range(N):
        if A[i]>>k &1:o+=1
    ans+=(2**k)*o*(N-o)
print(ans%(10**9+7))

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

mod = pow(10,9)+7

K = 60
P = [0]*K
Z = [0]*K
for a in A:
    n = a
    for i in range(K):
        b = n%2
        if b:P[i]+=1
        else:Z[i]+=1
        n//=2
ans = 0
for k in range(K):
    ans+=(pow(2,k,mod)*(P[k]*Z[k]))%mod
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7
ans = 0
for k in range(61):
    one = 0
    zero = 0
    for i in range(N):
        if A[i]%2==0:zero+=1
        else:one+=1
        A[i]//=2
    ans += (one*zero)*(2**k)
print(ans%MOD)

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

mod = pow(10,9)+7

K = 60
P = [0]*K
Z = [0]*K
for a in A:
    n = a
    for i in range(K):
        b = n%2
        if b:P[i]+=1
        else:Z[i]+=1
        n//=2
ans = 0
for k in range(K):
    ans+=(pow(2,k,mod)*(P[k]*Z[k]))%mod
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt=0
for i in range(N-1,1,-1):
    for j in range(i-1,0,-1):
        b = bisect.bisect_right(L[:j],L[i]-L[j])
        cnt+=j-b
print(cnt)

Fixed submission:
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        b = bisect.bisect_left(L,L[i]+L[j])
        cnt += b-j-1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        a = L[i]+L[j]
        l = N-j
        b = l-bisect.bisect_left(L[j+1:],a)
        cnt+=l-b
print(cnt)

Fixed submission:
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        b = bisect.bisect_left(L,L[i]+L[j])
        cnt += b-j-1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        a = L[i]+L[j]
        l = len(L[j+1:])
        b = l-bisect.bisect_left(L[j+1:],a)
        cnt+=l-b
print(cnt)

Fixed submission:
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt=0
for i in range(N-2):
    for j in range(i+1,N-1):
        b = bisect.bisect_left(L,L[i]+L[j])
        cnt += b-j-1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
gcd = math.gcd(A,B)
C = []
for i in range(1,gcd+1):
    if i*i>gcd:break
    if gcd%i==0:
        C.append(i)
        if i!=gcd//i:
            C.append(gcd//i)
def is_prime(n):
    if n==1:return True
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:return False
    return True
cnt = 0
for c in C:
    if is_prime(c):cnt+=1
print(cnt)

Fixed submission:
import math,sys
sys.setrecursionlimit(1000000)
def mygcd(x,y):
    if x<y:x,y=y,x
    if y==0:return x
    return mygcd(y,x%y)
def is_prime(n):
    if n==1:return True
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:return False
    return True
A,B = map(int,input().split())
gcd = mygcd(A,B)
C = []
for i in range(1,gcd+1):
    if i*i>gcd:break
    if gcd%i==0:
        C.append(i)
        if i!=gcd//i:
            C.append(gcd//i)
cnt = 0
for c in C:
    if is_prime(c):cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
def gcd(a,b):
    if a<b : a,b = b,a
    if b==0: return a
    else: return gcd(b, a%b)
C = gcd(A,B)
ans = 0
X = [True]*(C+1)
X[0] = X[1] = False
for i in range(C+1):
    if X[i]:
        X[i::i] = [False]*(C//i)
        if C%i==0: ans+=1
print(ans+1)

Fixed submission:
import math,sys
sys.setrecursionlimit(1000000)
def mygcd(x,y):
    if x<y:x,y=y,x
    if y==0:return x
    return mygcd(y,x%y)
def is_prime(n):
    if n==1:return True
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:return False
    return True
A,B = map(int,input().split())
gcd = mygcd(A,B)
C = []
for i in range(1,gcd+1):
    if i*i>gcd:break
    if gcd%i==0:
        C.append(i)
        if i!=gcd//i:
            C.append(gcd//i)
cnt = 0
for c in C:
    if is_prime(c):cnt+=1
print(cnt)

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

ans = 0
C = min(A,B)
X = [True]*(C+1)
X[0] = X[1] = False
for i in range(2,C+1):
    if i*i>C:break
    if X[i]:
        X[i::i] = [False]*(C//i)
        if A%i==0 and B%i==0:
            ans+=1
print(ans+1)

Fixed submission:
import math,sys
sys.setrecursionlimit(1000000)
def mygcd(x,y):
    if x<y:x,y=y,x
    if y==0:return x
    return mygcd(y,x%y)
def is_prime(n):
    if n==1:return True
    for i in range(2,int(math.sqrt(n))+1):
        if n%i==0:return False
    return True
A,B = map(int,input().split())
gcd = mygcd(A,B)
C = []
for i in range(1,gcd+1):
    if i*i>gcd:break
    if gcd%i==0:
        C.append(i)
        if i!=gcd//i:
            C.append(gcd//i)
cnt = 0
for c in C:
    if is_prime(c):cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int,input().split()))
ans = 0
for i in range(N):
    k = 0
    for j in range(i+1,N):
        if H[j-1]>=H[j]:
            k+=1
        else:break
    ans = max(ans,k)
print(ans)

Fixed submission:
N = int(input())
H = list(map(int,input().split()))
ans = 0
k = 0
for i in range(N-1):
    if H[i]>=H[i+1]:
        k+=1
    else:
        ans = max(ans,k)
        k=0
print(max(ans,k))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print(sum([i for i in range(N)]))

Fixed submission:
N = int(input())
print((N-1)*N//2)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
if set(T)-set(S):
    print(-1)
    exit()
ans = 0
for t in T:
    while True:
        if S[ans]==t:break
        ans+=1
    S+=S
print(ans+1)

Fixed submission:
from bisect import bisect
S = input()
T = input()

NS = len(S)
NT = len(T)
alp = {}
for i in range(26):
    alp[chr(97+i)] = i
D = [[] for i in range(26)]
for i in range(NS):
    D[alp[S[i]]].append(i)
inf = float("inf")
for i in range(26):D[i].append(inf)
k = 0
l = -1
ans = -1
for i in range(NT):
    index = alp[T[i]]
    if D[index] == [inf]:break
    b = bisect(D[index],l)
    if D[index][b]==inf:
        k += 1
        l = D[index][0]
    else:
        l = D[index][b]
    if i==NT-1:ans = k*NS+l+1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = [[] for i in range(M)]
for _ in range(N):
    a,b = map(int,input().split())
    if a<=M: A[M-a].append(b)
B = []
for m in range(M):
    B = B+A[m]
    B.sort(reverse=True)
    B = B[:m+1]
print(sum(B))

Fixed submission:
import bisect
N,M = map(int,input().split())
A = []
for _ in range(N):
    a,b = map(int,input().split())
    if a<=M: A.append([a,b])
A.sort(reverse=True)
import heapq
h = []
ans = 0
for m in range(1,M+1):
    while A and A[-1][0] == m:
        heapq.heappush(h, A.pop()[1]*(-1))
    if h:
        ans -= heapq.heappop(h)
print(ans)