Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
ans = 0
x = 0
for i in range(N):
    for j in range(i):
        if P[i] <= P[j]:
            x += 1
    if x == i:
        ans += 1
    x = 0

print(ans)



        


Fixed submission:
N = int(input())
P = list(map(int,input().split()))
ans = 0
x = P[0]


for i in P:
    if i == 1:
        ans += 1
        x = 1
    else:
        if x >= i:
            ans += 1
            x = i



            
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
a = []
ans = 0
for i in range(N):       
    if i == 0:
        ans += 1
    elif P[i] != N:
        a = P[0:i]
        a = sorted(a)
        if a[0] >= P[i]:
            ans += 1
        a = []
print(ans)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
ans = 0
x = P[0]


for i in P:
    if i == 1:
        ans += 1
        x = 1
    else:
        if x >= i:
            ans += 1
            x = i



            
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int,input().split()))
a = 0
ans = 0
for i in range(N):
    for j in range(i + 1):
        if P[i] <= P[j]:
            a += 1
    if a == i + 1:
        ans += 1
    a = 0
print(ans)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
ans = 0
x = P[0]


for i in P:
    if i == 1:
        ans += 1
        x = 1
    else:
        if x >= i:
            ans += 1
            x = i



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

while k > 0:
    if a >= 1:
        a -= 1
        k -= 1
    elif a == 0 and b >= 1:
        b -= 1
        k -= 1
    elif a == 0 and b == 0:
        k -= 1

print(a, b)

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

if a <= k:
    k -= a
    a = 0
    if b <= k:
        b =0
    else:
        b -= k
else:
    a -= k

print(a, b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(1,N + 1):
    x = A.index(i) + 1
    ans.append(x)

print(*ans)




Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = [i for i in range(N)]

for i in range(N):
    ans[A[i] - 1] = i + 1
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(N):
    ans.append(A.index(i + 1) + 1)
print(' '.join(map(str,ans)))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = [i for i in range(N)]

for i in range(N):
    ans[A[i] - 1] = i + 1
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int,input().split())
a = []
b = [0] * N
for i in range(Q):
    A = int(input())
    a.append(A)

for i in a:
    for j in range(1,N + 1):
        if i == j:
            b[j - 1] += 1
for i in b:
    if i > Q - K:
        print('Yes')
    else:
        print('No')






Fixed submission:
N, K, Q = map(int,input().split())
a = []
b = [0] * N
for i in range(Q):
    A = int(input())
    a.append(A)

for i in a:
    b[i - 1] += 1
for i in b:
    if i > Q - K:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int,input().split())
a = []
b = [K] * N
for i in range(Q):
    A = int(input())
    a.append(A)

for i in a:
    for j in range(1,N + 1):
        if i != j:
            b[j - 1] -= 1
for i in b:
    if i > 0:
        print('Yes')
    else:
        print('No')






Fixed submission:
N, K, Q = map(int,input().split())
a = []
b = [0] * N
for i in range(Q):
    A = int(input())
    a.append(A)

for i in a:
    b[i - 1] += 1
for i in b:
    if i > Q - K:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int,input().split())
a = [K] * N
for i in range(Q):
    A = int(input())
    for j in range(N):
        if j != A - 1:
            a[j] -= 1
for i in range(N):
    if a[i] > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
N, K, Q = map(int,input().split())
a = []
b = [0] * N
for i in range(Q):
    A = int(input())
    a.append(A)

for i in a:
    b[i - 1] += 1
for i in b:
    if i > Q - K:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
a = int(input())
s = int(input())
if a >= 3200:
    print('s')
if a < 3200:
    print('red')

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
    print(s)
if a < 3200:
    print('red')
Buggy python submission (verdict: Runtime Error):
a, b = map(int,input().split())
x = a + b
if x % 2 == 0:
    print(s / 2)
else:
    print('IMPOSSIBLE')

Fixed submission:
a, b = map(int,input().split())
x = a + b
if x % 2 == 0:
    print(x // 2)
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
for i in range(N):
    A = int(input())
    a.append(A)
b = []
for i in range(N):
    for j in range(N):
        if i != j:
            b.append(a[j])
        b = sorted(b)
    print(b[-1])
    b = []

Fixed submission:
N = int(input())
a = []
ans = []
for i in range(N):
    A = int(input())
    a.append(A)

b = sorted(a)

m = max(a)
for i in a:
    if i == m:
        ans.append(b[-2])
    else:
        ans.append(m)

for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
for i in range(N):
    A = int(input())
    a. append(A)
b = a.copy()
for i in range(N):
    del b[i: i + 1]
    ans = max(b)
    print(ans)
    b = a.copy()

Fixed submission:
N = int(input())
a = []
ans = []
for i in range(N):
    A = int(input())
    a.append(A)

b = sorted(a)

m = max(a)
for i in a:
    if i == m:
        ans.append(b[-2])
    else:
        ans.append(m)

for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = []
for i in range(N):
    A = int(input())
    a. append(A)
b = sorted(a)
for i in range(N):
    if max(a) == a[i]:
        print(b[N - 2])
    else:
        print(max(a))

Fixed submission:
N = int(input())
a = []
ans = []
for i in range(N):
    A = int(input())
    a.append(A)

b = sorted(a)

m = max(a)
for i in a:
    if i == m:
        ans.append(b[-2])
    else:
        ans.append(m)

for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
M = []
for i in range(len(S)):
    M.append(S[i])
z = 0
ans = 0
while z == 0:
    for i in range(len(M)):
        if i == len(M) - 1:
            z = 1
            print(ans)
        elif M[i] == 'B' and M[i + 1] == 'W':
            ans += 1
            M[i] = 'W'
            M[i + 1] = 'B'
            break




Fixed submission:
S = input()
ans = 0
x = 0
for i in range(len(S)):
    if S[i] == 'B':
        x += 1
    else:
        ans += x
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

for i in range(K):
    if S[i] != '1':
        print(S[i])
        exit()
    
    if i == k - 1:
        print('1')
        exit()




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

for i in range(K):
    if S[i] != '1':
        print(S[i])
        exit()
    
    if i == K - 1:
        print('1')
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int,input().split())
ans =  0
if A == B == C:
    ans = 0
    K = 0
while K > 0:
    a = A
    b = B
    c = C
    A = b + c
    B = a + c
    C = a + b
    K -= 1
ans = A - B
if abs(ans) > 10 ** 18:
    ans = 10 ** 18
print(ans)

Fixed submission:
A, B, C, K = map(int,input().split())
ans = A - B
if abs(ans) > 10 ** 18:
    print('Unfair')
elif K % 2 == 1:
    ans *= -1
    print(ans)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = 0
a = []
for i in range(2,N,2):
    while i % 2 == 0:
        i //= 2
        x += 1
    a.append(x)
    x = 0
a = sorted(a)
a = a[::-1]
print(a[0])

Fixed submission:
N = int(input())
x = 1

while x <= N:
    x *= 2
    
 
print(x // 2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
x = 0
a = []
for i in range(2,N,2):
    while i % 2 == 0:
        i //= 2
        x += 1
    a.append(x)
    x = 0
a = sorted(a)
a = a[::-1]
print(a[0])


Fixed submission:
N = int(input())
x = 1

while x <= N:
    x *= 2
    
 
print(x // 2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
x = 0
a = []
for i in range(N):
    while i % 2 == 0:
        i //= 2
        x += 1
    a.append(x)
    x = 0
a = sorted(a)
a = a[::-1]
print(a[0])


Fixed submission:
N = int(input())
x = 1

while x <= N:
    x *= 2
    
 
print(x // 2)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C = map(int,input().split())
ans = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    if (A // 2) % 2 == 1 and (B // 2) % 2 == 1 and (C // 2) % 2 == 1:
        print(-1)
        exit()
    a = B // 2 + C // 2
    b = A // 2 + C // 2
    c = A // 2 + B // 2
    A = a
    B = b
    C = c
    ans += 1
print(ans)

Fixed submission:
A, B, C = map(int,input().split())
ans = 0
while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    a = B // 2 + C // 2
    b = A // 2 + C // 2
    c = A // 2 + B // 2
    if A == a and B == b and C == c:
        ans = -1
        break
    A = a
    B = b
    C = c
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(input())
print max(a*c,a*d,b*c,b*d)

Fixed submission:
a,b,c,d = map(int, input().split())
print(max([a*c,a*d,b*c,b*d]))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input());tt=0
while(N):
    tt+=(N%10);N//=10
print("No" if tt%9 else "Yes")

Fixed submission:
print("No"if int(input())%9 else "Yes")

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input());tt=0
while(N):
    tt+=(N%10);N//=10
    if tt>999999999:break
print("No" if tt%9 else "Yes")

Fixed submission:
print("No"if int(input())%9 else "Yes")

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input());tt=0
while(N):tt+=(N%10);N//=10
print("No" if tt%9 else "Yes")

Fixed submission:
print("No"if int(input())%9 else "Yes")
Buggy python submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
if(math.sqrt(a)+math.sqrt(b)<=math.sqrt(c)):
	print("Yes")
else:
	print("No")

Fixed submission:
a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
mod = (10 ** 9) + 7
answer = 0

for i in range(N-1):
    for j in range(i+1, N):
        answer += A[i] * A[j] % mod
print(answer % mod)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = (10 ** 9) + 7
answer = 0
sum_A = sum(A)

for i in range(N):
    sum_A -= A[i]
    answer += A[i] * sum_A % mod
print(answer % mod)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
A = list(map(int, input().split()))
max_A = max(A)
sqrt_max_A = max_A ** 0.5
sieve = list(range(2, max_A+1))
prime = list(range(max_A+1))
while True:
    p = sieve[0]
    prime[p]= p
    if p > sqrt_max_A:
        break
    new_sieve = []
    for s in sieve:
        if s % p == 0:
            prime[s] = p
        else:
            new_sieve.append(s)
    sieve = new_sieve
factors = {}
pairwise = True
for a in A:
    while prime[a] != a:
        if prime[a] in factors:
            pairwise = False
            break
        factors[prime[a]] = True
        p = prime[a]
        while a % p == 0:
            a //= p
    if a in factors:
        pairwise = False
    else:
        factors[a] = True
    if not pairwise:
        break
if pairwise:
    print('pairwise coprime')
else:
    gcd = reduce(math.gcd, A)
    if gcd == 1:
        print('setwise coprime')
    else:
        print('not coprime')


Fixed submission:
import math
from functools import reduce

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

max_A = max(A)
sqrt_max_A = math.ceil(max_A ** 0.5)
sieve = list(range(2, max_A+1))
prime = list(range(max_A+1))
while len(sieve) > 0 and sieve[0] <= sqrt_max_A:
    p = sieve[0]
    prime[p]= p
    new_sieve = []
    for s in sieve:
        if s % p == 0:
            prime[s] = p
        else:
            new_sieve.append(s)
    sieve = new_sieve

factors = {}
pairwise = True
for a in A:
    while prime[a] != a:
        if prime[a] in factors:
            pairwise = False
            break
        factors[prime[a]] = True
        p = prime[a]
        while a % p == 0:
            a //= p
    if a != 1:
        if a in factors:
            pairwise = False
        else:
            factors[a] = True
    if not pairwise:
        break
if pairwise:
    print('pairwise coprime')
else:
    gcd = reduce(math.gcd, A)
    if gcd == 1:
        print('setwise coprime')
    else:
        print('not coprime')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(lambda x: x - 1, map(int, input().split()))
Dh, Dw = map(lambda x: x - 1, map(int, input().split()))
S = []
already = []
yet = 1000000
for i in range(H):
    S.append(input())
    already.append([yet] * W)
queue = deque()
queue.append((Cw, Ch, 0))
already[Ch][Cw] = 0
answer = -1
while len(queue) > 0:
    #print(queue)
    #print(already)
    x, y, cost = queue.popleft()
    #print(x, y, cost)
    if x == Dw and y == Dh:
        answer = cost
        break
    for i in range(-2, 3):
        for j in range(-2, 3):
            new_x, new_y = (x + i, y + j)
            # 場外
            if new_x < 0 or new_y < 0 or W <= new_x or H <= new_y:
                continue
            # 動かない
            if new_x == x and new_y == y:
                continue
            # 壁
            if S[new_y][new_x] == '#':
                continue
            # 探索済み
            if already[new_y][new_x] <= cost:
                continue
            if (i == 0 and j == -1) \
            or (i == 0 and j == 1) \
            or (i == 1 and j == 0) \
            or (i == -1 and j == 0):
                queue.appendleft((new_x, new_y, cost))
                already[new_y][new_x] = cost
            else:
                queue.append((new_x, new_y, cost+1))
                already[new_y][new_x] = cost+1
print(answer)

Fixed submission:
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(lambda x: x - 1, map(int, input().split()))
Dh, Dw = map(lambda x: x - 1, map(int, input().split()))
S = []
already = []
yet = 1000000
for i in range(H):
    S.append(input())
    already.append([yet] * W)
queue = deque()
queue.append((Cw, Ch, 0))
already[Ch][Cw] = 0
answer = -1
while len(queue) > 0:
    #print(queue)
    #print(already)
    x, y, cost = queue.popleft()
    #print(x, y, cost)
    if x == Dw and y == Dh:
        answer = cost
        break
    for i in range(-2, 3):
        for j in range(-2, 3):
            new_x, new_y = (x + i, y + j)
            # 場外
            if new_x < 0 or new_y < 0 or W <= new_x or H <= new_y:
                continue
            # 動かない
            if new_x == x and new_y == y:
                continue
            # 壁
            if S[new_y][new_x] == '#':
                continue
            # 探索済み
            if already[new_y][new_x] <= cost:
                continue
            if (i == 0 and j == -1) \
            or (i == 0 and j == 1) \
            or (i == 1 and j == 0) \
            or (i == -1 and j == 0):
                queue.appendleft((new_x, new_y, cost))
                already[new_y][new_x] = cost
            else:
                queue.append((new_x, new_y, cost+1))
                already[new_y][new_x] = cost+1
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int, input().split())
bombs = []
for i in range(H):
    bombs.append([False] * W)
rows = []
for i in range(H):
    rows.append([i, 0])
cols = []
for i in range(W):
    cols.append([i, 0])
for i in range(M):
    y, x = map(lambda x: x - 1, map(int, input().split()))
    bombs[y][x] = True
    rows[y][1] += 1
    cols[x][1] += 1


rows = sorted(rows, key=lambda x: x[1], reverse=True)
cols = sorted(cols, key=lambda x: x[1], reverse=True)
answer = 0
for row in rows:
    a = cols[0][1] + row[1] - (1 if bombs[row[0]][cols[0][0]] else 0)
    if a > answer:
        answer = a
for col in cols:
    a = rows[0][1] + col[1] - (1 if bombs[rows[0][0]][col[0]] else 0)
    if a > answer:
        answer = a
print(answer)

Fixed submission:
H, W, M = map(int, input().split())
bombs = {}
rows = []
cols = []
for i in range(H):
    rows.append([i, 0])
for i in range(W):
    cols.append([i, 0])
for i in range(M):
    y, x = map(lambda x: x - 1, map(int, input().split()))
    bombs[(y,x)] = True
    rows[y][1] += 1
    cols[x][1] += 1


rows = sorted(rows, key=lambda x: x[1], reverse=True)
cols = sorted(cols, key=lambda x: x[1], reverse=True)
answer = 0
for row in rows:
    a = cols[0][1] + row[1] - (1 if (row[0], cols[0][0]) in bombs else 0)
    if a > answer:
        answer = a
for col in cols:
    a = rows[0][1] + col[1] - (1 if (rows[0][0], col[0]) in bombs else 0)
    if a > answer:
        answer = a
print(answer)

Buggy python submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
bombs = []
for i in range(H):
    bombs.append([False] * W)
rows = []
for i in range(H):
    rows.append([i, 0])
cols = []
for i in range(W):
    cols.append([i, 0])
for i in range(M):
    y, x = map(lambda x: x - 1, map(int, input().split()))
    bombs[y][x] = True
    rows[y][1] += 1
    cols[x][1] += 1


rows = sorted(rows, key=lambda x: x[1], reverse=True)
cols = sorted(cols, key=lambda x: x[1], reverse=True)
answer = 0
for row in rows:
    a = cols[0][1] + row[1] - (1 if bombs[row[0]][cols[0][0]] else 0)
    if a > answer:
        answer = a
for col in cols:
    a = rows[0][1] + col[1] - (1 if bombs[rows[0][0]][col[0]] else 0)
    if a > answer:
        answer = a
print(answer)

Fixed submission:
H, W, M = map(int, input().split())
bombs = {}
rows = []
cols = []
for i in range(H):
    rows.append([i, 0])
for i in range(W):
    cols.append([i, 0])
for i in range(M):
    y, x = map(lambda x: x - 1, map(int, input().split()))
    bombs[(y,x)] = True
    rows[y][1] += 1
    cols[x][1] += 1


rows = sorted(rows, key=lambda x: x[1], reverse=True)
cols = sorted(cols, key=lambda x: x[1], reverse=True)
answer = 0
for row in rows:
    a = cols[0][1] + row[1] - (1 if (row[0], cols[0][0]) in bombs else 0)
    if a > answer:
        answer = a
for col in cols:
    a = rows[0][1] + col[1] - (1 if (rows[0][0], col[0]) in bombs else 0)
    if a > answer:
        answer = a
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
answer = 'Yes'
score = 1
for i in range(K):
    score *= A[i]

for i in range(N - K):
    next_score = score * A[K + i] // A[i]
    print('Yes' if next_score > score else 'No')
    score = next_score



Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
answer = 'Yes'
score = 0
for i in range(K):
    score += A[i]

for i in range(N - K):
    next_score = score + A[K + i] - A[i]
    print('Yes' if next_score > score else 'No')
    score = next_score
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

initial = (1,1,1)
queue = []
queue.append(initial)
pointer = 0
answers = [0] * (N + 1)
while pointer < len(queue):
    x, y, z = queue[pointer]
    # print(x, y, z)
    q = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if q < N + 1:
        answers[q] += 1
        if x >= y and x >= z:
            queue.append((x + 1, y, z))
        if y >= z:
            queue.append((x, y + 1, z))
        queue.append((x, y, z + 1))
    pointer += 1

        
for a in answers[1:N + 1]:
    print(a)

Fixed submission:
N = int(input())

initial = (1,1,1)
queue = []
queue.append(initial)
pointer = 0
answers = [0] * (N + 1)
memo = {}
while pointer < len(queue):
    x, y, z = queue[pointer]
    # print(x, y, z)
    q = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if q < N + 1:
        add = 1
        if x == y and y == z:
            add = 1
        elif x == y or y == z or z == x:
            add = 3
        else:
            add =6
        answers[q] += add

        if x+1>=y and y >=z and (x+1,y,z) not in memo:
            memo[(x+1,y,z)] = 0
            queue.append((x + 1, y, z))
        if x >= y +1 and y + 1 >= z and (x, y+1, z) not in memo:
            memo[(x,y+1,z)] = 0
            queue.append((x, y + 1, z))
        if x >= y and y >= z+1 and (x, y, z+1) not in memo:
            memo[(x,y,z+1)] = 0
            queue.append((x, y, z + 1))
    pointer += 1

        
for a in answers[1:N + 1]:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(map(int, input().split()), reverse=True)

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

d = {}
disabled = set()
for i in range(len(A)):
    # save
    divisors = make_divisors(A[i])
    for divisor in divisors:
        if divisor not in d:
            d[divisor] = [i]
        else:
            d[divisor].append(i)
    # judge
    if A[i] in d:
        for item in d[A[i]]:
            if item != i:
                disabled.add(item)
                if A[item] == A[i]:
                    disabled.add(i)

# print(disabled)
print(len(A) - len(disabled))

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

max_number = max(A) + 1
ng = [False] * max_number
counter = 0
prev = 0
for ai in A:
    if ai == prev:
        counter -= 1
        prev = 0
    if not ng[ai]:
        counter += 1
        prev = ai
    for i in range(ai, max_number, ai):
        ng[i] = True
print(counter)

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

counter = 0
for i in range(len(A)):
    warikire = False
    for j in range(len(A)):
        # print(i, j, A[i], A[j])
        if i == j:
            continue
        if A[i] % A[j] == 0:
            warikire = True
            break
        if A[i] < A[j]:
            break
    counter += 1 if not warikire else 0
print(counter)

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

max_number = max(A) + 1
ng = [False] * max_number
counter = 0
prev = 0
for ai in A:
    if ai == prev:
        counter -= 1
        prev = 0
    if not ng[ai]:
        counter += 1
        prev = ai
    for i in range(ai, max_number, ai):
        ng[i] = True
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
d = {
    'R': [],
    'G': [],
    'B': []
}
for i, s in enumerate(S):
    d[s].append(i)

answer = 0
for r in d['R']:
    for g in d['G']:
        for b in d['B']:
            s = sorted([r, g, b], reverse=True)
            if s[0] - s[1] != s[1] - s[2]:
                answer += 1
print(answer)

Fixed submission:
N = int(input())
S = input()
d = {
    'R': {},
    'G': {},
    'B': {}
}
for i, s in enumerate(S):
    d[s][i] = True
answer = len(d['R']) * len(d['G']) * len(d['B'])
for r in d['R'].keys():
    for g in d['G'].keys():
        if 2 * r - g in d['B']:
            answer -= 1
        if 2 * g - r in d['B']:
            answer -= 1
        if ((r + g) % 2 == 0 and ((r + g) // 2) in d['B']):
            answer -= 1
            

print(answer)