Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
WAC = [0 for i in range(M)]
TF = {}
for i in range(M):
    p, S = input().split()
    p = int(p)
    if p in TF.keys():
        if S == 'AC':
            TF[p] = True
    else:
        if S == 'AC':
            TF[p] = True
        else:
            TF[p] = False
    if  TF[p] == False and S == 'WA':
        WAC[p-1] += 1
count = 0
for k in TF:
    if TF[k]:
        count += 1
print(count, sum(WAC))



Fixed submission:
N, M = map(int, input().split())
WAC = [0 for i in range(N)]
TF = [0 for i in range(N)]
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if S == 'AC':
        TF[p] = 1
    if TF[p] == 0 and S == 'WA':
        WAC[p] += 1
count = 0
for i in range(N):
    count += TF[i] * WAC[i]
print(sum(TF), count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse = True)
#print(C)
sosu = 10 ** 9 + 7
K = [1 for i in range(N+1)]
for i in range(1, N+1):
    a = K[i-1] * 2 % sosu
    K[i] = a
ans = 0
for i in range(N):
    #for j in range(1,circle):##j番目に大きい
    #    kkk = c(i, j-1) * 2 ** (N-i-1)###i+1番目に大きいものがj番目に大きくなるような選び方
    #    ans += C[i] * kake * j * kkk
    ans += C[i] * K[N] * (2 ** i + i * 2 ** (i-1)) * K[N-i-1]
    ans %= sosu
print(int(ans))







Fixed submission:
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse = True)
#print(C)
sosu = 10 ** 9 + 7
K = dict()
K[-1] = 1
K[0] = 1
for i in range(1, N+1):
    a = K[i-1] * 2 % sosu
    K[i] = a
ans = 0
for i in range(N):
    #for j in range(1,circle):##j番目に大きい
    #    kkk = c(i, j-1) * 2 ** (N-i-1)###i+1番目に大きいものがj番目に大きくなるような選び方
    #    ans += C[i] * kake * j * kkk
    ans += (C[i] * K[N] * (K[i] + i * K[i-1]) * K[N-i-1]) % sosu
    ans %= sosu
print(int(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse = True)
#print(C)
sosu = 10 ** 9 + 7
kake = (2 ** N) % sosu
ans = 0
for i in range(N):
    #for j in range(1,circle):##j番目に大きい
    #    kkk = c(i, j-1) * 2 ** (N-i-1)###i+1番目に大きいものがj番目に大きくなるような選び方
    #    ans += C[i] * kake * j * kkk
    ans += C[i] * kake * (2 ** i + i * 2 ** (i-1)) * 2 ** (N-i-1)
    ans %= sosu
print(int(ans))







Fixed submission:
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse = True)
#print(C)
sosu = 10 ** 9 + 7
K = dict()
K[-1] = 1
K[0] = 1
for i in range(1, N+1):
    a = K[i-1] * 2 % sosu
    K[i] = a
ans = 0
for i in range(N):
    #for j in range(1,circle):##j番目に大きい
    #    kkk = c(i, j-1) * 2 ** (N-i-1)###i+1番目に大きいものがj番目に大きくなるような選び方
    #    ans += C[i] * kake * j * kkk
    ans += (C[i] * K[N] * (K[i] + i * K[i-1]) * K[N-i-1]) % sosu
    ans %= sosu
print(int(ans))

Buggy python submission (verdict: Runtime Error):
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse = True)
#print(C)
sosu = 10 ** 9 + 7
kake = 2 ** N
ans = 0
for i in range(N):
    #for j in range(1,circle):##j番目に大きい
    #    kkk = c(i, j-1) * 2 ** (N-i-1)###i+1番目に大きいものがj番目に大きくなるような選び方
    #    ans += C[i] * kake * j * kkk
    ans += C[i] * kake * (2 ** i + i * 2 ** (i-1)) * 2 ** (N-i-1)
    ans %= sosu
print(int(ans))







Fixed submission:
N = int(input())
C = list(map(int, input().split()))
C.sort(reverse = True)
#print(C)
sosu = 10 ** 9 + 7
K = dict()
K[-1] = 1
K[0] = 1
for i in range(1, N+1):
    a = K[i-1] * 2 % sosu
    K[i] = a
ans = 0
for i in range(N):
    #for j in range(1,circle):##j番目に大きい
    #    kkk = c(i, j-1) * 2 ** (N-i-1)###i+1番目に大きいものがj番目に大きくなるような選び方
    #    ans += C[i] * kake * j * kkk
    ans += (C[i] * K[N] * (K[i] + i * K[i-1]) * K[N-i-1]) % sosu
    ans %= sosu
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
keta = 10
count = 0
for i in range(keta):
    for j in range(keta):
        for k in range(keta):
            nnn = str(i) + str(j) + str(k)
            now = 0
            nownnn = nnn[now]
            flag = False
            for l in range(N):
                if S[l] == nownnn:
                    if now == 2:
                        flag = True
                        break
                    else:
                        now += 1
                        nownnn = nnn[now]
            if flag:
                count += 1
print(count)

Fixed submission:
N = int(input())
S = input()
keta = 10
count = 0
for i in range(keta):
    for j in range(keta):
        for k in range(keta):
            nnn = str(i) + str(j) + str(k)
            now = 0
            nownnn = nnn[now]
            flag = False
            for l in range(N):
                if S[l] == nownnn:
                    if now == 2:
                        flag = True
                        break
                    else:
                        now += 1
                        nownnn = nnn[now]
            if flag:
                count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
lenL = len(L)
ans = 0
for i in range(lenL-2):
    for j in range(i+1, lenL-1):
        a = L[i]
        b = L[j]
        ind = bisect.bisect_left(L[j+1:], a+b)
        ans += ind
print(ans)



Fixed submission:
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
lenL = len(L)
ans = 0
for i in range(lenL-2):
    for j in range(i+1, lenL-1):
        a = L[i]
        b = L[j]
        ind = bisect.bisect_left(L[j+1:], a+b)
        ans += ind
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
moji = {}
for i in range(len(s)):
    if s[i] in moji.keys():
        moji[s[i]].append(i)
    else:
        moji[s[i]] = [i]

now = -1
kaisu = 0
flag = True
for i in range(len(t)):
    if t[i] in moji.keys():
        basho = moji[t[i]]
        for n in range(len(basho)):
            if basho[n] > now:
                now = basho[n]
                break
            elif n == len(basho) - 1 and basho[n] <= now:
                now = basho[0]
                kaisu += 1
    else:
        flag = False
        break
if flag:
    ans = kaisu * len(s) + now + 1
    print(ans)
else:
    print(-1)



Fixed submission:
import bisect
s = input()
t = input()
moji = {}
for i in range(len(s)):
    if s[i] in moji.keys():
        moji[s[i]].append(i)
    else:
        moji[s[i]] = [i]

now = -1
kaisu = 0
flag = True
for i in range(len(t)):
    if t[i] in moji.keys():
        basho = moji[t[i]]
        lenbasho = len(basho)
        nowindex = bisect.bisect_right(basho, now)
        if nowindex == lenbasho:
            now = basho[0]
            kaisu += 1
        else:
            now = basho[nowindex]
    else:
        flag = False
        break
if flag:
    ans = kaisu * len(s) + now + 1
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
now = [A[0]]

for i in range(1, N):
    index = bisect.bisect_left(now, A[i])
    if index == 0:
        now = [A[i]] + now
    else:
        now[index-1] = A[i]
print(len(now))


Fixed submission:
import bisect
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
now = [-A[0]]

for i in range(1, N):

    index = bisect.bisect_right(now, -A[i])
    if index == len(now):
        now.append(-A[i])
    else:
        now[index] = -A[i]

print(len(now))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
dp = [[] for i in range(N)]
dp[0] = [A[0]]

for i in range(1, N):
    index = bisect.bisect_left(dp[i-1], A[i])
    dp[i] = dp[i-1].copy()
    if index == 0:
        dp[i].insert(0, A[i])
    else:
        dp[i][index-1] = A[i]
print(len(dp[N-1]))




Fixed submission:
import bisect
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
now = [-A[0]]

for i in range(1, N):

    index = bisect.bisect_right(now, -A[i])
    if index == len(now):
        now.append(-A[i])
    else:
        now[index] = -A[i]

print(len(now))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
dp = [[] for i in range(N)]
dp[0] = [A[0]]

for i in range(1, N):
    index = bisect.bisect_left(dp[i-1], A[i])
    dp[i] = dp[i-1].copy()
    if index == 0:
        dp[i].append(A[i])
        dp[i].sort()
    
    else:
        dp[i][index-1] = A[i]
print(len(dp[N-1]))




Fixed submission:
import bisect
N = int(input())
A = [0 for i in range(N)]
for i in range(N):
    A[i] = int(input())
now = [-A[0]]

for i in range(1, N):

    index = bisect.bisect_right(now, -A[i])
    if index == len(now):
        now.append(-A[i])
    else:
        now[index] = -A[i]

print(len(now))
Buggy python submission (verdict: Runtime Error):
import math
sosu = 10 ** 9 + 7
N, K = map(int, input().split())
def conv(n, r):
    ans = math.factorial(n) / (math.factorial(r) * math.factorial(n-r)) % sosu
    return(ans)

for i in range(1, K+1):
    if N-K+1 >= i:
        fir = conv(K-1, i-1)
        #print(fir)
        sec = conv(N-K+1, i)
        #print(sec)
        ans = fir * sec % sosu
        print(int(ans))
    else:
        print(0)


Fixed submission:
import math
sosu = 10 ** 9 + 7
N, K = map(int, input().split())
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def conv(n, r):
    bunbo = math.factorial(n) % sosu
    bunsi1 = mod_inv(math.factorial(r), sosu)
    bunsi2 = mod_inv(math.factorial(n-r), sosu)
    ans = bunbo * bunsi1 * bunsi2 % sosu
    return(ans)
#print(conv(1997,2))

for i in range(1, K+1):
    if N-K+1 >= i:
        fir = conv(K-1, i-1)
        sec = conv(N-K+1, i)
        ans = fir * sec % sosu
        print(int(ans))
    else:
        print(0)

Buggy python submission (verdict: Runtime Error):
import math
sosu = 10 ** 9 + 7
N, K = map(int, input().split())
def conv(n, r):
    ans = math.factorial(n) / (math.factorial(r) * math.factorial(n-r)) % sosu
    return(ans)

for i in range(1, K+1):
    fir = conv(K-1, i-1)
    #print(fir)
    sec = conv(N-K+1, i)
    #print(sec)
    ans = fir * sec % sosu
    print(int(ans))


Fixed submission:
import math
sosu = 10 ** 9 + 7
N, K = map(int, input().split())
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def conv(n, r):
    bunbo = math.factorial(n) % sosu
    bunsi1 = mod_inv(math.factorial(r), sosu)
    bunsi2 = mod_inv(math.factorial(n-r), sosu)
    ans = bunbo * bunsi1 * bunsi2 % sosu
    return(ans)
#print(conv(1997,2))

for i in range(1, K+1):
    if N-K+1 >= i:
        fir = conv(K-1, i-1)
        sec = conv(N-K+1, i)
        ans = fir * sec % sosu
        print(int(ans))
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
x = [0 for i in range(N)]
for i in range(N):
    x[i] = list(map(int, input().split()))
x.sort(key=lambda x: (x[0],x[1]))
salist = []
for i in range(1,N):
    lb, mb = x[i-1]
    l, m = x[i]
    salist.append((l-lb,m-mb))
#print(salist)
c = collections.Counter(salist)
print( N - c.most_common()[0][1])

Fixed submission:
import collections
N = int(input())
x = [0 for i in range(N)]
for i in range(N):
    x[i] = list(map(int, input().split()))
x.sort(key=lambda x: (x[0],x[1]))
salist = []
if N >= 2:
    for i in range(1,N):
        for k in range(1,N):
            if i >= k:
                lb, mb = x[i-k]
                l, m = x[i]
                salist.append((l-lb,m-mb))
    #print(salist)
    c = collections.Counter(salist)
    print( N - c.most_common()[0][1])
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = [0 for i in range(M)]
sosu = 10 ** 9 + 7
for i in range(M):
    a[i] = int(input())
dp = [0 for i in range(N+1)]
dp[0] = 1
for i in range(1, N+1):
    if i in a:
        pass
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % sosu
print(dp[N])

Fixed submission:
N, M = map(int, input().split())
a = [0 for i in range(M)]
sosu = 10 ** 9 + 7
for i in range(M):
    a[i] = int(input())
seta = list(set(a))
seta.sort()
dp = [0 for i in range(N+1)]
dp[0] = 1
now = 0
for i in range(1, N+1):
    if now <= M-1 and i == seta[now]:
        now += 1
    elif i >= 2:
        dp[i] = (dp[i-2] + dp[i-1]) % sosu
    elif i == 1:
        dp[i] = dp[i-1]
#print(seta)
print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))
numlist = []
for i in range(M):
    B, C = map(int, input().split())
    numlist.append([C, B])
for i in range(N):
    numlist.append([A[i], 1])
numlist.sort(reverse = True)
count = N
ans = 0
while count >= 0:
    b, c = numlist.pop(0)
    if c <= count:
        ans += b * c
    else:
        ans += b * count
    count -= c
print(ans)



Fixed submission:

N, M = map(int, input().split())
A = list(map(int, input().split()))
num = dict()
for i in range(M):
    B, C = map(int, input().split())
    if C in num.keys():
        num[C] += B
    else:
        num[C] = B
for i in range(N):
    if A[i] in num.keys():
        num[A[i]] += 1
    else:
        num[A[i]] = 1
dct = sorted(num.items(), reverse = True)
count = N
ans = 0
for i in range(len(dct)):
    b, c = dct[i]
    if c <= count:
        ans += b * c
    else:
        ans += b * count
    count -= c
    if count <= 0:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N, M, K = map(int, input().split())
sosu = 10 ** 9 + 7

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)
dis = M * M * N * N * (N+1) // 2 % sosu
dis = dis - M * M * N * (N+1) * ( 2* N + 1) // 6 % sosu
dis = dis + N * N * M * M * (M+1) //2 % sosu
dis = dis - N * N * M * (M+1) * (2*M + 1) // 6 % sosu


if K >= 3:
    dis = dis * C(N*M-2, K-2) % sosu
if dis >= 0:
    print(dis)
else:
    print(dis + sosu)

Fixed submission:
import math
N, M, K = map(int, input().split())
sosu = 10 ** 9 + 7

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)


dis = M * M * N * N * (N+1) // 2 % sosu
dis = dis - M * M * N * (N+1) * ( 2* N + 1) // 6 % sosu
dis = dis + N * N * M * M * (M+1) //2 % sosu
dis = dis - N * N * M * (M+1) * (2*M + 1) // 6 % sosu

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = sosu #出力の制限
N = N * M
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


if K >= 3:
    dis = dis * cmb(N-2, K-2, mod) % sosu
if dis >= 0:
    print(dis)
else:
    print(dis + sosu)

Buggy python submission (verdict: Time Limit Exceeded):
import math
N, M, K = map(int, input().split())
sosu = 10 ** 9 + 7

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)
dis = 0
for i in range(1,N):
    dis += i * (N-i) * M * M
    dis = dis % sosu
for j in range(1,M):
    dis += j * (M-j) * N * N
    dis = dis % sosu
#print(dis)

if K >= 3:
    dis = dis * C(N*M-2, K-2) % sosu
print(dis)

Fixed submission:
import math
N, M, K = map(int, input().split())
sosu = 10 ** 9 + 7

def P(n, r):
    return math.factorial(n)//math.factorial(n-r)

def C(n, r):
    return P(n, r)//math.factorial(r)


dis = M * M * N * N * (N+1) // 2 % sosu
dis = dis - M * M * N * (N+1) * ( 2* N + 1) // 6 % sosu
dis = dis + N * N * M * M * (M+1) //2 % sosu
dis = dis - N * N * M * (M+1) * (2*M + 1) // 6 % sosu

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = sosu #出力の制限
N = N * M
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


if K >= 3:
    dis = dis * cmb(N-2, K-2, mod) % sosu
if dis >= 0:
    print(dis)
else:
    print(dis + sosu)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
color = [R, G, B]
color.sort(reverse = True)
maxr = N // color[0]
maxg = N // color[1]
count = 0
for i in range(maxr+1):
    for j in range(maxg+1):
        nokori = N - i * color[0] - j * color[1]
        amari = nokori % color[2]
        if nokori >= 0 and amari == 0:
            count += 1
print(count)


Fixed submission:
R, G, B, N = map(int, input().split())
color = [R, G, B]
color.sort(reverse = True)
maxr = N // color[0]
count = 0
for i in range(maxr+1):
    nokori = N - i * color[0]
    maxg = nokori // color[1]
    for j in range(maxg+1):
        nokorinow = nokori - j * color[1]
        amari = nokorinow % color[2]
        if amari == 0:
            count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
maxr = N // R
maxg = N // G
count = 0
for i in range(maxr+1):
    for j in range(maxg+1):
        nokori = N - i * R - j * G
        amari = nokori % B
        if nokori >= 0 and amari == 0:
            count += 1
print(count)


Fixed submission:
R, G, B, N = map(int, input().split())
color = [R, G, B]
color.sort(reverse = True)
maxr = N // color[0]
count = 0
for i in range(maxr+1):
    nokori = N - i * color[0]
    maxg = nokori // color[1]
    for j in range(maxg+1):
        nokorinow = nokori - j * color[1]
        amari = nokorinow % color[2]
        if amari == 0:
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
numlist = []
for i in range(N-1):
    if S[i:i+2] == 'AC':
        numlist.append(i)

l = [0 for i in range(Q)]
r = [0 for i in range(Q)]
for i in range(Q):
    ll, rr = map(int, input().split())
    l[i], r[i] = ll-1, rr-1

for i in range(Q):
    hajime = bisect.bisect_left(numlist, l[i])
    owari = bisect.bisect_right(numlist,r[i]-1)
    print(owari - hajime)

Fixed submission:
import bisect
N, Q = map(int, input().split())
S = input()
numlist = []
for i in range(N-1):
    if S[i:i+2] == 'AC':
        numlist.append(i)

l = [0 for i in range(Q)]
r = [0 for i in range(Q)]
for i in range(Q):
    ll, rr = map(int, input().split())
    l[i], r[i] = ll-1, rr-1

for i in range(Q):
    hajime = bisect.bisect_left(numlist, l[i])
    owari = bisect.bisect_right(numlist,r[i]-1)
    print(owari - hajime)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
numlist = []
for i in range(N-1):
    if S[i:i+2] == 'AC':
        numlist.append(i)

l = [0 for i in range(Q)]
r = [0 for i in range(Q)]
for i in range(Q):
    ll, rr = map(int, input().split())
    l[i], r[i] = ll-1, rr-1

for i in range(Q):
    now = [n for n in numlist if n>= l[i] and n <= r[i]-1]
    print(len(now))


Fixed submission:
import bisect
N, Q = map(int, input().split())
S = input()
numlist = []
for i in range(N-1):
    if S[i:i+2] == 'AC':
        numlist.append(i)

l = [0 for i in range(Q)]
r = [0 for i in range(Q)]
for i in range(Q):
    ll, rr = map(int, input().split())
    l[i], r[i] = ll-1, rr-1

for i in range(Q):
    hajime = bisect.bisect_left(numlist, l[i])
    owari = bisect.bisect_right(numlist,r[i]-1)
    print(owari - hajime)
Buggy python submission (verdict: Runtime Error):
N = int(input())
C = [0 for i in range(N)]
alpha = {}
for i in range(N):
    C[i] = int(input())
    if C[i] in alpha.keys():
        alpha[C[i]].append(i)
    else:
        alpha[C[i]] = [i]
sosu = 10 ** 9 + 7

dp = [1 for i in range(N)]
mae = C[1]
for i in range(2,N):
    dp[i] = dp[i-1]
    if C[i] != mae:
        numlist = alpha[C[i]]
        for j in numlist:
            if j < i and j>=1:
                dp[i] += dp[j-1]
            elif j == 0:
                dp[i] += 1
            else:
                break
    mae = C[i]
    dp[i] = dp[i] % sosu
print(dp[N-1])


Fixed submission:
N = int(input())
C = [0 for i in range(N)]

for i in range(N):
    C[i] = int(input())

sosu = 10 ** 9 + 7

dp = [1 for i in range(N)]
alpha = {}
alpha[C[0]] = [0]
mae = C[0]
for i in range(1,N):
    dp[i] = dp[i-1]
    if C[i] != mae:
        if C[i] in alpha.keys():
            length = len(alpha[C[i]])
            lastnum = alpha[C[i]][length - 1]
            dp[i] += dp[lastnum]
            alpha[C[i]].append(i)
        else:
            alpha[C[i]] = [i]
    mae = C[i]
    dp[i] = dp[i] % sosu
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
 = [0 for i in range(N)]
alpha = {}
for i in range(N):
    C[i] = int(input())
    if C[i] in alpha.keys():
        alpha[C[i]].append(i)
    else:
        alpha[C[i]] = [i]
sosu = 10 ** 9 + 7

dp = [1 for i in range(N)]
mae = C[1]
for i in range(2,N):
    dp[i] = dp[i-1]
    if C[i] != mae:
        numlist = alpha[C[i]]
        for j in numlist:
            if j < i and j>=1:
                dp[i] += dp[j-1]
            elif j == 0:
                dp[i] += 1
            else:
                break
    mae = C[i]
    dp[i] = dp[i] % sosu
print(dp[N-1])


Fixed submission:
N = int(input())
C = [0 for i in range(N)]

for i in range(N):
    C[i] = int(input())

sosu = 10 ** 9 + 7

dp = [1 for i in range(N)]
alpha = {}
alpha[C[0]] = [0]
mae = C[0]
for i in range(1,N):
    dp[i] = dp[i-1]
    if C[i] != mae:
        if C[i] in alpha.keys():
            length = len(alpha[C[i]])
            lastnum = alpha[C[i]][length - 1]
            dp[i] += dp[lastnum]
            alpha[C[i]].append(i)
        else:
            alpha[C[i]] = [i]
    mae = C[i]
    dp[i] = dp[i] % sosu
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
dp = [0 for i in range(N)]
last = ['' for i in range(N)]
last[0] = S[0]
for i in range(1, N):
    if last[i-1][-1] != S[i]:
        dp[i] = dp[i-1] + 1
        if i >= 2:
            last[i] = last[i-2]
    else:
        dp[i] = dp[i-1]
        last[i] = last[i-1] + S[i]
print(dp[N-1]*2)

Fixed submission:
S = input()
zero = S.count('0')
one = S.count('1')
print(min(zero, one) * 2)

Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
dp = [0 for i in range(N)]
last = [False for i in range(N)]
last[0] = S[0]
for i in range(1, N):
    if last[i-1][-1] != S[i]:
        dp[i] = dp[i-1] + 1
        if i >= 2:
            last[i] = last[i-2]
    else:
        dp[i] = dp[i-1]
        last[i] = last[i-1] + S[i]
print(dp[N-1]*2)

Fixed submission:
S = input()
zero = S.count('0')
one = S.count('1')
print(min(zero, one) * 2)
Buggy python submission (verdict: Time Limit Exceeded):
K, A, B = map(int, input().split())
if A >= B-2:
    print(K+1)
else:
    nowb = 1
    nowm = 0
    for i in range(K):
        if nowm == 1:
            nowb += B
            nowm -= 1
        elif nowb >= A and i < K-1:
            nowb -= A
            nowm += 1
        else:
            nowb += 1
    print(nowb)

Fixed submission:
K, A, B = map(int, input().split())
if A >= B-2:
    print(K+1)
else:
    nokoriK = K + 1 - A
    if nokoriK % 2 == 0:
        maisu = A + (B-A) * nokoriK // 2
    else:
        maisu = A + (B-A) * (nokoriK-1) // 2 + 1
    print(maisu)