Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
dp = [[0 for _ in range(len(s)+1)] for i in range(len(t)+1)]
ans = ""
res = []
for i in range(len(t)+1):
    dp[i][0] = 0
for j in range(len(s)+1):
    dp[0][j] = 0
for i in range(1,len(t)+1):
    for j in range(1,len(s)+1):
        if s[j-1] == t[i-1]:
            dp[i][j] = dp[i-1][j-1]+1
            res.append([i,j])
            
            
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
i,j = len(t),len(s)
while i > 0 and j > 0:
    if [i,j] in res:
        ans += s[j-1]
        i,j = i-1,j-1
        continue
        
    if dp[i-1][j] > dp[i][j-1]:
        i -= 1
    else:
        j -= 1
    
print(ans[::-1])

Fixed submission:
import numpy as np
 
t = np.array(list(input()), dtype='U1')
s = np.array(list(input()), dtype='U1')
 
ls = len(s)
lt = len(t)
 
eq = s[:, None] == t[None, :]
dp = [np.zeros(lt+1, dtype=np.int16)]
 
# solve
for i in range(ls):
    prev = dp[-1].copy()
    np.maximum(prev[1:], prev[:-1] + eq[i], out = prev[1:])
    np.maximum.accumulate(prev, out = prev)
    dp.append(prev)
 
# print([list(line) for line in dp])
 
# restore
l = dp[-1][-1]
res = ''
i, j = ls, lt
while i > 0 and j > 0:
    if eq[i-1][j-1]:
        res += s[i-1]
        i, j = i-1, j-1
        continue
    
    if dp[i-1][j] > dp[i][j-1]:
        i -= 1
    else:
        j -= 1
 
print(res[::-1])

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
dp - [[0 for _ in rannge(len(s)+1)] for i in range(len(t)+1)]
for i in range(len(s)+1):
    dp[i][0] = 0
for j in range(len(t)+1):
    dp[0][j] = 0
for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1] == t[i-1]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
print(dp[len(s)][len(t)])

Fixed submission:
import numpy as np
 
t = np.array(list(input()), dtype='U1')
s = np.array(list(input()), dtype='U1')
 
ls = len(s)
lt = len(t)
 
eq = s[:, None] == t[None, :]
dp = [np.zeros(lt+1, dtype=np.int16)]
 
# solve
for i in range(ls):
    prev = dp[-1].copy()
    np.maximum(prev[1:], prev[:-1] + eq[i], out = prev[1:])
    np.maximum.accumulate(prev, out = prev)
    dp.append(prev)
 
# print([list(line) for line in dp])
 
# restore
l = dp[-1][-1]
res = ''
i, j = ls, lt
while i > 0 and j > 0:
    if eq[i-1][j-1]:
        res += s[i-1]
        i, j = i-1, j-1
        continue
    
    if dp[i-1][j] > dp[i][j-1]:
        i -= 1
    else:
        j -= 1
 
print(res[::-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
s=list(map(float,input().split()))
a=[0 for _ in range(n+1)]
p = [0 for _in range(n+1)]
a[0]=1
for i in range(n):
    k=s[i]
    for j in range(len(a)):
        p[j] = a[j]*(1-k)
    for j in range(1,len(a)):
        p[j] += a[j-1]*k
    a = p
print(sum(a[n//2+1:]))

Fixed submission:
import numpy as np
n=int(input())
s=list(map(float,input().split()))
a=np.zeros(n+1,dtype="float")
a[0]=1
for i in range(n):
    k=s[i]
    p=a*(1-k)
    p[1:]+=a[:-1]*k
    a=p
print(sum(a[n//2+1:]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
memo = {}
p = [0]
for num in a:
    p += [p[-1] + num]

dp = [[0 for _ in range(n)] for _ in range(n)]
for l in range(2,n+1):
    for i in range(n-l+1):
        dp[i][i+l-1] = min([dp[i][k] + dp[k+1][i+l-1] for k in range(i,i+l-1)]) + p[i+l] - p[i]
print(dp[0][n-1])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * (n+1) for _ in range(n+1)]
s = [0] * (n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]
for l in range(2, n+1):
    for i in range(n-l+1):
        j = i + l
        dp[i][j] = s[j] - s[i] + min(dp[i][k] + dp[k][j] for k in range(i+1, j))
print(dp[0][n])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
memo = {}
p = [0]
for num in a:
    p += [p[-1] + num]

def dp(i,j):
    if i >= j:
        return 0
    if (i,j) not in memo:
        ans = float("inf")
        for k in range(i,j):
            temp = dp(i,k) + dp(k+1,j) + p[j+1] - p[i]
            ans = min(ans,temp)
        memo[i,j] = ans
    return memo[i,j]
print(dp(0,n-1))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
dp = [[0] * (n+1) for _ in range(n+1)]
s = [0] * (n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]
for l in range(2, n+1):
    for i in range(n-l+1):
        j = i + l
        dp[i][j] = s[j] - s[i] + min(dp[i][k] + dp[k][j] for k in range(i+1, j))
print(dp[0][n])
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
X = 10*A + B + C
Y = 10*B + A + C
Z = 10*C + A + B
print(max[X, Y, Z])

Fixed submission:
A, B, C = map(int, input().split())
X = 10*A + B + C
Y = 10*B + A + C
Z = 10*C + A + B
print(max(X, Y, Z))
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
a = math.floor(math.sqrt(N))
L = [0 for i in range(a-1)]
ans = []
for i in range(N):
    if i%2 ==0:
        continue
    counter = 0
    for j in range(2,a+1):
        while i%j == 0:
            L[j] += 1
            i /= j
    if sum(L) == 3 or sum(L) == 4:
        ans.append(i)

print(len(ans))

Fixed submission:
import math
N = int(input())

ans = 0
for i in range(3,N+1):
    if i < 105:
        continue
    elif i%2 == 0:
        continue
    counter = 1
    n = math.floor(math.sqrt(i))
    for j in range(2,n+1):
        a = 0
        while i%j == 0:
            a += 1
            i /= j
        if a > 0:
            counter *= (a+1)
    if counter == 8:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def solve(S):
    for a in ['+', '-']:
        for b in ['+', '-']:
            for c in ['+', '-']:
                if eval('{}{}{}{}{}{}{}'.format(
                        S[0], a, S[1], b, S[2], c, S[3]
                )) == 7:
                    return '{}{}{}{}{}{}{}=7'.format(
                        S[0], a, S[1], b, S[2], c, S[3]
                    )
 
 S = input()
print(solve(S))

Fixed submission:
S = input()


for i in range(8):
    f = ""
    B = ["-"]*3

    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    
        
    if eval(f) == 7:
        print(f+"=7")
        break

Buggy python submission (verdict: Runtime Error):
def solve(S):
    for a in ['+', '-']:
        for b in ['+', '-']:
            for c in ['+', '-']:
                if eval(
                        S[0]+ a+ S[1]+ b+ S[2]+ c+ S[3]
                ) == 7:
                    return S[0]+ a+ S[1]+ b+ S[2]+ c+ S[3]+ '=7'
                       
                    
 
 S = input()
solve(S)

Fixed submission:
S = input()


for i in range(8):
    f = ""
    B = ["-"]*3

    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    
        
    if eval(f) == 7:
        print(f+"=7")
        break

Buggy python submission (verdict: Runtime Error):
def solve( ):
    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval('S[0] + a + S[1] +b + S[2] + c + S[3]') == 7:
                    return 'S[0] + a + S[1] +b + S[2] + c + S[3]=7'
                    break
 
S = input()
print(solve(S))

Fixed submission:
S = input()


for i in range(8):
    f = ""
    B = ["-"]*3

    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    
        
    if eval(f) == 7:
        print(f+"=7")
        break

Buggy python submission (verdict: Runtime Error):
def solve( ):
    for a in ["+", "-"]:
        for b in ["+", "-"]:
            for c in ["+", "-"]:
                if eval('S[0] + a + S[1] +b + S[2] + c + S[3]) == 7:
                    return 'S[0] + a + S[1] +b + S[2] + c + S[3]=7'
                    break

S = input()
print(solve(S))


Fixed submission:
S = input()


for i in range(8):
    f = ""
    B = ["-"]*3

    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    
        
    if eval(f) == 7:
        print(f+"=7")
        break
Buggy python submission (verdict: Time Limit Exceeded):
def num(pos,list1):
    count = 0
    val = list1[pos]
    for x in range(pos+1,len(list1)):
        if list1[x]<=val:
            count+=1
            val=list1[x]
        else:
            return count
    return count
maximum = 0
n = int(input())
list1 = [int(i) for i in input().split()]
for y in range(len(list1)):
    ans = num(y,list1)
    if ans>maximum:
        maximum = ans
print(maximum)

Fixed submission:
def num(pos,list1):
    count = 0
    val = list1[pos]
    for x in range(pos+1,len(list1)):
        if list1[x]<=val:
            count+=1
            val=list1[x]
        else:
            return count
    return count
maximum = 0
n = int(input())
list1 = [int(i) for i in input().split()]
y = 0
while y<len(list1):
    ans = num(y,list1)
    if ans>maximum:
        maximum = ans
    y+=ans+1
print(maximum)
Buggy python submission (verdict: Runtime Error):
a,b = [int(i) for i in input().split()]
	for x in range(b-a+1,a+b):
		if x>=-1000000 and x<=1000000:
			print(x,end = " ")


Fixed submission:
a,b = [int(i) for i in input().split()]
for x in range(b-a+1,a+b):
	if x>=-1000000 and x<=1000000:
		print(x,end = " ")
Buggy python submission (verdict: Runtime Error):
n = int(input())
total = 0
val1 = int(math.ceil(math.log(n,10)))
ans = 0
if val1==1:
	ans = n
elif val1==2:
    ans = 9
elif val1==3:
	ans = 9+n-99
elif val1==4:
	ans = 909
elif val1==5:
	ans = 909+n-9999
else:
	ans = 90909
if val1==math.log(n,10) and val1%2:
	print(ans-1)
else:
	print(ans)

Fixed submission:
import math
n = int(input())
total = 0
word = str(n)
val1 = len(word)
ans = 0
if val1==1:
	ans = n
elif val1==2:
    ans = 9
elif val1==3:
	ans = 9+n-99
elif val1==4:
	ans = 909
elif val1==5:
	ans = 909+n-9999
else:
	ans = 90909
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
if K % 2 == 0:
    print(-1)
    exit()
if K % 5 == 0:
    print(-1)
    exit()

x = 7
counter = 1
while (True):
    if x%K == 0:
        print(counter)
        exit()
    x += 7 * 10 ** counter
    counter += 1


Fixed submission:
K = int(input())
if K%5 == 0 or K%2 == 0:
    print(-1)
    exit()
x = 7
counter = 1
while True:
    if x%K == 0:
        print(counter)
        exit()
    counter += 1
    x = (10 * x + 7) % K
Buggy python submission (verdict: Runtime Error):
import math
def is_ok(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += math.ceil(A[i] / length)-1
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if K == 0:
    print(max(A))
    exit()
ok = max(A)
ng = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(ok))

Fixed submission:
import math
def is_ok(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += math.ceil(A[i] / length)-1
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if K == 0:
    print(max(A))
    exit()
ok = max(A)
ng = 0
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(ok))

Buggy python submission (verdict: Runtime Error):
import math
def solve(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += int(A[i] / length)
    return K >= s

# 一本ならナイーブには1/2を繰り返すのが最小になりそうだけど5とかだと1/2, (1/2, 1/2)で次4回切らないと中途半端に長いのが残ってしまう
# 複数本なら一番長いのを常に半分に切れば良さそう？
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
ok = A[-1]
ng = A[0]
while abs(ok - ng) > 1:
    mid = (ok + ng) / 2
    if solve(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(mid))

Fixed submission:
import math
def is_ok(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += math.ceil(A[i] / length)-1
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if K == 0:
    print(max(A))
    exit()
ok = max(A)
ng = 0
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(ok))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
dp = {}
for i in A:
    dp[i] = True
A.sort()
for i in range(N):
    if dp[A[i]]:
        for j in range(i+1, N):
            if A[j] % A[i] == 0:
                dp[A[j]] = False
counter = 0
for key in dp.keys():
    if dp[key]:
        counter += 1
print(counter)

Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
maxA = max(A)
dp = {}
for i in range(1, maxA+1):
    dp[i] = True
for i in range(N):
    if dp[A[i]]:
        tmp = 2 * A[i]
        while maxA >= tmp:
            if dp[tmp]:
                dp[tmp] = False
            tmp += A[i]
counter = 0
t = Counter(A)
for i in range(N):
    if dp[A[i]] and t[A[i]] == 1:
        counter += 1
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

for d in A:
    A  = [x for x in A if (x == d or x % d != 0)]
each = Counter(A)
result = 0
for key in each:
    if each[key] == 1:
         result += 1
print(result)


Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
maxA = max(A)
dp = {}
for i in range(1, maxA+1):
    dp[i] = True
for i in range(N):
    if dp[A[i]]:
        tmp = 2 * A[i]
        while maxA >= tmp:
            if dp[tmp]:
                dp[tmp] = False
            tmp += A[i]
counter = 0
t = Counter(A)
for i in range(N):
    if dp[A[i]] and t[A[i]] == 1:
        counter += 1
print(counter)
Buggy python submission (verdict: Runtime Error):
X = int(input())
print(X)
# Xの素因数分解をうまくつかう
# A^5 - B^5 =(A-B)(A^4+A^3B+A^2B^2+AB^3+B^4)
# どっちが正負かは決まらない
# AB(A^2+B^2)+(A^2+B^2)^2-A^2B^2
# AB((A-B)^2+2AB)+((A-B)^2+2AB)^2 - A^2B^2
# A-B = P
# AB = Q
# A^5-B^5 = P(Q(P^2+2Q)+(P^2+2Q)^2-Q^2) = P(P^4+5P^2Q+5Q^2) = P(5Q^2+5P^2Q+P^4)
# Qは整数解なので
# 5Q^2+5P^2Q+P^4が整数解を持つ楽な方法は(Q+P)^2の形の時、つまり2P = P^2+2, 
# X = PRとする
# R-P^4は5の倍数になる

#Aの上限を求める
# X<10^9
# A-B = 1がAを最大にできる

maxA = 126
maxX = pow(10, 9)

flag = 0
for A in range(-126, 126):
    for B in range(-127, A):
        result = pow(A, 5) - pow(B, 5)
        if result > maxX:
            next
        if result == X:
            print(A, B)
            flag = 1
            break
    if flag == 1:

Fixed submission:
X = int(input())
# Xの素因数分解をうまくつかう
# A^5 - B^5 =(A-B)(A^4+A^3B+A^2B^2+AB^3+B^4)
# どっちが正負かは決まらない
# AB(A^2+B^2)+(A^2+B^2)^2-A^2B^2
# AB((A-B)^2+2AB)+((A-B)^2+2AB)^2 - A^2B^2
# A-B = P
# AB = Q
# A^5-B^5 = P(Q(P^2+2Q)+(P^2+2Q)^2-Q^2) = P(P^4+5P^2Q+5Q^2) = P(5Q^2+5P^2Q+P^4)
# Qは整数解なので
# 5Q^2+5P^2Q+P^4が整数解を持つ楽な方法は(Q+P)^2の形の時、つまり2P = P^2+2, 
# X = PRとする
# R-P^4は5の倍数になる

#Aの上限を求める
# X<10^9
# A-B = 1がAを最大にできる

maxA = 126
maxX = pow(10, 9)

flag = 0
for A in range(-126, 126):
    for B in range(-127, A):
        result = pow(A, 5) - pow(B, 5)
        if result > maxX:
            next
        if result == X:
            print(A, B)
            flag = 1
            break
    if flag == 1:
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

# A[i]は問題では1から始まるので注意
# A[i], A[j]について、|j-i| == A[j]+A[i]なら極秘情報の取引をする
# この条件を満たすペアの数
# modはとらなくてよいぐらい
# i, jは2*10^5の程度だから全件で10^10の程度, A[i]は10^9の程度
# j > iとして良い。j-iの値を固定して計算はできる。
# いったんこれぐらいで始めてみよう

# だめだった
# 値の範囲で搾ろう。

counter = 0
for i in range(N):
    bi = i+A[i]
    for j in range(i+1, N):
        if j-A[j] == bi:
            counter += 1
print(counter)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

# 線形で計算できる
# j > iとしてA[j]+A[i] = j-iよりA[i]+i=j-A[j]
# iとjを分離できたのでjを前に進めていって、計算結果を貯めていけばいい
# 

counter = 0
dic = {}
for j in range(N):
    if j-A[j] in dic:
        counter += dic[j - A[j]]
    if j + A[j] in dic:
        dic[j+A[j]] += 1
    else:
        dic[j+A[j]] = 1
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

# A[i]は問題では1から始まるので注意
# A[i], A[j]について、|j-i| == A[j]+A[i]なら極秘情報の取引をする
# この条件を満たすペアの数
# modはとらなくてよいぐらい
# i, jは2*10^5の程度だから全件で10^10の程度, A[i]は10^9の程度
# j > iとして良い。j-iの値を固定して計算はできる。
# いったんこれぐらいで始めてみよう

# だめだった
# 値の範囲で搾ろう。

counter = 0
B = [i+A[i] for i in range(N)]
C = [j-A[j] for j in range(N)]
for i in range(N):
    bi = B[i]
    for j in range(i+1, N):
        if C[j] == bi:
            counter += 1
print(counter)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

# 線形で計算できる
# j > iとしてA[j]+A[i] = j-iよりA[i]+i=j-A[j]
# iとjを分離できたのでjを前に進めていって、計算結果を貯めていけばいい
# 

counter = 0
dic = {}
for j in range(N):
    if j-A[j] in dic:
        counter += dic[j - A[j]]
    if j + A[j] in dic:
        dic[j+A[j]] += 1
    else:
        dic[j+A[j]] = 1
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

# A[i]は問題では1から始まるので注意
# A[i], A[j]について、|j-i| == A[j]+A[i]なら極秘情報の取引をする
# この条件を満たすペアの数
# modはとらなくてよいぐらい
# i, jは2*10^5の程度だから全件で10^10の程度, A[i]は10^9の程度
# j > iとして良い。j-iの値を固定して計算はできる。
# いったんこれぐらいで始めてみよう

# だめだった
# 値の範囲で搾ろう。

counter = 0
B = [i+A[i] for i in range(N)]
C = [j-A[j] for j in range(N)]
for i in range(N):
    for j in range(i+1, N):
        if C[j] == B[i]:
            counter += 1
print(counter)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

# 線形で計算できる
# j > iとしてA[j]+A[i] = j-iよりA[i]+i=j-A[j]
# iとjを分離できたのでjを前に進めていって、計算結果を貯めていけばいい
# 

counter = 0
dic = {}
for j in range(N):
    if j-A[j] in dic:
        counter += dic[j - A[j]]
    if j + A[j] in dic:
        dic[j+A[j]] += 1
    else:
        dic[j+A[j]] = 1
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
S = input()
l = len(S)
d = {l: 0}
for i in range(len(S)):
    s = int(S[i:l])
    d[i] = s%2019
count_d = defaultdict(int)
for i in range(len(S)+1):
    count_d[d[i]] += 1
counter = 0
for key in count_d.keys():
    counter += count_d[key] - 1
print(counter)

Fixed submission:
from collections import defaultdict
S = input()
l = len(S)
d = {0:0}
mod10n = 1
for i in range(1, len(S)+1):
    s = int(S[l-i])
    d[i] = (d[i-1] + s * mod10n) %2019
    mod10n = (mod10n * 10) % 2019
count_d = defaultdict(int)
for key in d.keys():
    count_d[d[key]] += 1
counter = 0
for key in count_d.keys():
    counter += (count_d[key] * (count_d[key]-1)) //2

print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
l = len(S)
d = {l: 0}
for i in range(len(S)):
    s = int(S[i:l])
    d[i] = s%2019
counter = 0
for i in range(len(S)+1):
    for j in range(i+1, len(S)+1):
        if d[j] == d[i]:
            counter += 1
print(counter)

Fixed submission:
from collections import defaultdict
S = input()
l = len(S)
d = {0:0}
mod10n = 1
for i in range(1, len(S)+1):
    s = int(S[l-i])
    d[i] = (d[i-1] + s * mod10n) %2019
    mod10n = (mod10n * 10) % 2019
count_d = defaultdict(int)
for key in d.keys():
    count_d[d[key]] += 1
counter = 0
for key in count_d.keys():
    counter += (count_d[key] * (count_d[key]-1)) //2

print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
# RGBの時点で一つ目の条件を満たすものは少ないはず
d = {}
for i in range(N):
    for j in range(i+1, N):
        if S[i] != S[j]:
            d[(i, j)] = 1
counter = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if (i, j) in d:
                if (i, k) in d:
                    if (j, k) in d:
                        if j-i != k-j:
                            counter += 1
print(counter)

Fixed submission:
N = int(input())
S = input()
d = {'R': 0, 'G': 0, 'B': 0}
for i in range(N):
    d[S[i]]+=1
tot = d['R']*d['G']*d['B']

counter = 0
for i in range(N):
    width = 1
    tmp = i+2
    while tmp < N:
        if S[i] != S[i+width] and S[i] != S[i+2*width] and S[i+width] != S[i+2*width]:
            counter += 1
        width += 1
        tmp = i + 2 * width
print(tot-counter)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
al = list(map(int, input().split()))
mod = 10**9+7
ans = 0

for i in range(n):
    for j in range(n):
        if i != j:
            ans += al[i]*al[j]

print((ans//2)%mod)

Fixed submission:
n = int(input())
al = list(map(int, input().split()))
mod = 10**9+7
ans = sum(al)**2

for ai in al:
    ans -= ai**2

print((ans//2)%mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
al = list(map(int, input().split()))
al_sum = sum(al)
q = int(input())

num = [0]*10001
for a in al:
    num[a] += 1


for _ in range(q):
    bi, ci = map(int, input().split())

    al_sum += num[bi]*(ci - bi)
    num[ci] += num[bi]
    num[bi] = 0

    print(al_sum)

Fixed submission:
n = int(input())
al = list(map(int, input().split()))
al_sum = sum(al)
q = int(input())

num = [0]*100001
for a in al:
    num[a] += 1


for _ in range(q):
    bi, ci = map(int, input().split())

    al_sum += num[bi]*(ci - bi)
    num[ci] += num[bi]
    num[bi] = 0

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

ans = 1
for a in al:
    ans *= a

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

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

ans = 1
if al.count(0) > 0:
    print(0)
else:
    for a in al:
        ans *= a
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())

for a in range(1, 1001001001):
    b = (x - a**5)
    if b != 0:
        if b > 0 and b ** 0.2 == int(b ** 0.2):
            print(a, int(b ** 0.2))
            break
        else:
            b = -1*b
            if b ** 0.2 == int(b ** 0.2):
                print(a, -1*int(b ** 0.2))
                break

Fixed submission:
x = int(input())
for i in range(-120, 120):
    for j in range(-120, 120):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b, n = map(int, input().split())

ans = 0

for i in range(1, n+1):
    ans = max(ans, math.floor(a*i/b) - a * math.floor(i/b))

print(ans)

Fixed submission:
def f(a, b, n):
    return int(a*n/b) - a*int(n/b)

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

print(f(a, b, b-1) if n >= b-1 else f(a, b, n))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
al = list(map(int, input().split()))

ans_al = [0]*n

for i in range(n):
    ans_al[i-1] += al.count(i)

for ans in ans_al:
    print(ans)

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

ans_al = [0]*n

# for i in range(n):
#     ans_al[i-1] += al.count(i)

for a in al:
    ans_al[a-1] += 1

for ans in ans_al:
    print(ans)

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

ans_al = [0]*n

for i in range(n):
    ans_al[i-1] += al.count(i)

for ans in ans_al:
    print(ans)

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

ans_al = [0]*n

# for i in range(n):
#     ans_al[i-1] += al.count(i)

for a in al:
    ans_al[a-1] += 1

for ans in ans_al:
    print(ans)

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

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



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

ans_al = [0]*n

# for i in range(n):
#     ans_al[i-1] += al.count(i)

for a in al:
    ans_al[a-1] += 1

for ans in ans_al:
    print(ans)