Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math

def getPrimeFactorsList(num):
  pn = 2 #素数は2から
  pflist = [] #素因数のリスト
  while pn * pn <= num: #√numまで調べる
    while num % pn == 0: #現在の素数で割り切れる範囲でループ
      num = num / pn
      pflist.append(pn)
    pn += 1 #割り切れなくなったら次の素数へ
  if num > 1:
    pflist.append(int(num))
    
  return pflist
mod = (10 ** 9 + 7)
N = int(input())
ans = 0
num = math.factorial(N)
#print(num)
for i in range(1, num+1):
  count = 1
  pflist = getPrimeFactorsList(i)
  pfset = set(pflist)
  for j in pfset:
    count *= (pflist.count(j) + 1)
  #print("-----")
  #print(count)
  #print("-----")
  ans += count
  
print(count % mod) 

Fixed submission:
def getPrimeFactorsList(num):
  pn = 2 #素数は2から
  pflist = [] #素因数のリスト
  while pn * pn <= num: #√numまで調べる
    while num % pn == 0: #現在の素数で割り切れる範囲でループ
      num = num / pn
      pflist.append(pn)
    pn += 1 #割り切れなくなったら次の素数へ
  if num > 1:
    pflist.append(int(num))
  return pflist

mod = (10 ** 9 + 7)
N = int(input())
ans = 0


pf_dict = {}
#素因数がキー、割れる回数を値として用意し、最後に約数の個数を求める
for i in range(2, N+1):

  pflist = getPrimeFactorsList(i)
  pfset = set(pflist)
  for j in pfset:
    if j in pf_dict:
      pf_dict[j] += pflist.count(j)
    else:
      pf_dict[j] = pflist.count(j)
    #count *= (pflist.count(j) + 1)
  
count = 1
for v in pf_dict.values():
  count *= (v + 1)
print(count % mod)

Buggy python submission (verdict: Runtime Error):
import math

def getPrimeFactorsList(num):
  pn = 2 #素数は2から
  pflist = [] #素因数のリスト
  while pn * pn <= num: #√numまで調べる
    while num % pn == 0: #現在の素数で割り切れる範囲でループ
      num = num / pn
      pflist.append(pn)
    pn += 1 #割り切れなくなったら次の素数へ
  if num > 1:
    pflist.append(int(num))
    
  return pflist

N = int(input())
pflist = getPrimeFactorsList(math.factorial(N))
pfset = set(pflist)
ans  = 1
for i in pfset:
  ans *= (pflist.count(i) + 1)
  #print(i)
  #print(pflist.count(i))
  
  
#print(pflist)
print(ans)

Fixed submission:
def getPrimeFactorsList(num):
  pn = 2 #素数は2から
  pflist = [] #素因数のリスト
  while pn * pn <= num: #√numまで調べる
    while num % pn == 0: #現在の素数で割り切れる範囲でループ
      num = num / pn
      pflist.append(pn)
    pn += 1 #割り切れなくなったら次の素数へ
  if num > 1:
    pflist.append(int(num))
  return pflist

mod = (10 ** 9 + 7)
N = int(input())
ans = 0


pf_dict = {}
#素因数がキー、割れる回数を値として用意し、最後に約数の個数を求める
for i in range(2, N+1):

  pflist = getPrimeFactorsList(i)
  pfset = set(pflist)
  for j in pfset:
    if j in pf_dict:
      pf_dict[j] += pflist.count(j)
    else:
      pf_dict[j] = pflist.count(j)
    #count *= (pflist.count(j) + 1)
  
count = 1
for v in pf_dict.values():
  count *= (v + 1)
print(count % mod)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())

pt = [0] * n
pa = [0] * n

for i in range(n):
  t, a = map(int, input().split())
  if i == 0:
    pt[0] = t
    pa[0] = a
  else:
    tmp = math.ceil(max(pt[i-1]/, pa[i-1]/a))
    pt[i]=tmp*t
    pa[i]=tmp*a

print(int(pt[-1] + pa[-1]))      

Fixed submission:
import math
from fractions import Fraction
n = int(input())

pt = [0] * n
pa = [0] * n

for i in range(n):
  t, a = map(int, input().split())
  if i == 0:
    pt[0] = t
    pa[0] = a
  else:
    tmp = math.ceil(max(Fraction(pt[i-1], t), Fraction(pa[i-1], a)))
    pt[i]=tmp*t
    pa[i]=tmp*a

print(int(pt[-1] + pa[-1]))

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())

pt = [0] * n
pa = [0] * n

for i in range(n):
  t, a = map(int, input().split())
  if i == 0:
    pt[0] = t
    pa[0] = a
  else:
    tmp = math.ceil(max(pt[i-1]/t*, pa[i-1]/a))
    pt[i]=tmp*t
    pa[i]=tmp*a

print(int(pt[-1] + pa[-1]))      

Fixed submission:
import math
from fractions import Fraction
n = int(input())

pt = [0] * n
pa = [0] * n

for i in range(n):
  t, a = map(int, input().split())
  if i == 0:
    pt[0] = t
    pa[0] = a
  else:
    tmp = math.ceil(max(Fraction(pt[i-1], t), Fraction(pa[i-1], a)))
    pt[i]=tmp*t
    pa[i]=tmp*a

print(int(pt[-1] + pa[-1]))

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())

pt = [0] * n
pa = [0] * n

for i in range(n):
  t, a = map(int, input().split())
  if i == 0:
    pt[0] = t
    pa[0] = a
  else:
    tmp = math.ceil(max([pt[i-1]/t*1.0, pa[i-1]a*1.0]))
    pt[i]=tmp*t
    pa[i]=tmp*a

print(int(pt[-1] + pa[-1]))      

Fixed submission:
import math
from fractions import Fraction
n = int(input())

pt = [0] * n
pa = [0] * n

for i in range(n):
  t, a = map(int, input().split())
  if i == 0:
    pt[0] = t
    pa[0] = a
  else:
    tmp = math.ceil(max(Fraction(pt[i-1], t), Fraction(pa[i-1], a)))
    pt[i]=tmp*t
    pa[i]=tmp*a

print(int(pt[-1] + pa[-1]))
Buggy python submission (verdict: Runtime Error):
S = input()

ans = 0
def dfs(num_string, p):
  global ans
  if p > len(S) - 1:
    #終わり
    ans += eval(num_string)
    return 
  
  #先頭の数字だけ扱いが微妙
  if p == 0:
    num_string  = "" + S[0]
    p = 1
  
  tmp = 0
  
  dfs(num_string + "+" + S[p], p+1)
  dfs(num_string + S[p], p+1)
  
  return

dfs(0,0)
print(ans)

Fixed submission:
S = input()

ans = 0
def dfs(num_string, p):

  global ans
  
  if len(S) == 1:
    ans = int(S)
    return
  
  if p > len(S) - 1:
    #終わり
    ans += eval(num_string)
    return 
  
  #先頭の数字だけ扱いが微妙
  if p == 0:
    num_string  = "" + S[0]
    p = 1
  
  tmp = 0
  
  dfs(num_string + "+" + S[p], p+1)
  dfs(num_string + S[p], p+1)
  
  return

dfs(0,0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = [int(input()) for _ in range(N)]

B = tuple(sorted(A))

ans = 0
skip_flag = False
for i in range(N):
    if skip_flag == False:
        idx = A.index(B[i])
        if abs(i - idx) % 2 == 0: # あまり０なら操作２だけで所定の位置に動かせる
            continue
        else:
            ans += 1
            # 次のやつも同時にできるか
            if i < N-1:
                next_idx = A.index(B[i+1])
                if abs(i+1 - next_idx) % 2 == 1:
                    skip_flag = True
    else:
        skip_flag = False
        continue

print(ans)


Fixed submission:
import math

N = int(input())

A = [int(input()) for _ in range(N)]

idx_A = {}
for i in range(N):
    idx_A[A[i]] = i

B = tuple(sorted(A))

"""
ソート後の位置までの距離が奇数だと操作１が一回必要になる
一度の操作１で最大で２個までのソート後の位置までの距離が奇数のものを偶数にずらしてあげられる
ので、正しい位置までの距離が奇数のものの個数をしらべて、最小の操作１の回数を求める
"""
cnt = 0
for i in range(N):
    if abs(i - idx_A[B[i]]) % 2 == 0: # あまり０なら操作２だけで所定の位置に動かせる
        continue
    else:
        cnt += 1


print(math.ceil(cnt/2))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = [int(input()) for _ in range(N)]

B = tuple(sorted(A))

ans = 0
skip_flag = False
for i in range(N):
    if skip_flag == False:
        idx = A.index(B[i])
        if abs(i - idx) % 2 == 0: # あまり０なら操作２だけで所定の位置に動かせる
            continue
        else:
            ans += 1
            # 次のやつも同時にできるか
            if i < N-1:
                next_idx = A.index(B[i+1])
                if abs(i+1 - next_idx) % 2 == 1:
                    skip_flag = True
    else:
        skip_flag = False
        continue

print(ans)


Fixed submission:
import math

N = int(input())

A = [int(input()) for _ in range(N)]

idx_A = {}
for i in range(N):
    idx_A[A[i]] = i

B = tuple(sorted(A))

"""
ソート後の位置までの距離が奇数だと操作１が一回必要になる
一度の操作１で最大で２個までのソート後の位置までの距離が奇数のものを偶数にずらしてあげられる
ので、正しい位置までの距離が奇数のものの個数をしらべて、最小の操作１の回数を求める
"""
cnt = 0
for i in range(N):
    if abs(i - idx_A[B[i]]) % 2 == 0: # あまり０なら操作２だけで所定の位置に動かせる
        continue
    else:
        cnt += 1


print(math.ceil(cnt/2))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = [int(input()) for _ in range(N)]

B = sorted(A)

ans = 0
skip_flag = False
for i in range(N):
    if skip_flag == False:
        idx = A.index(B[i])
        if abs(i - idx) % 2 == 0: # あまり０なら操作２だけで所定の位置に動かせる
            continue
        else:
            ans += 1
            # 次のやつも同時にできるか
            if i < N-1:
                next_idx = A.index(B[i+1])
                if abs(i+1 - next_idx) % 2 == 1:
                    skip_flag = True
    else:
        skip_flag = False
        continue

print(ans)


Fixed submission:
import math

N = int(input())

A = [int(input()) for _ in range(N)]

idx_A = {}
for i in range(N):
    idx_A[A[i]] = i

B = tuple(sorted(A))

"""
ソート後の位置までの距離が奇数だと操作１が一回必要になる
一度の操作１で最大で２個までのソート後の位置までの距離が奇数のものを偶数にずらしてあげられる
ので、正しい位置までの距離が奇数のものの個数をしらべて、最小の操作１の回数を求める
"""
cnt = 0
for i in range(N):
    if abs(i - idx_A[B[i]]) % 2 == 0: # あまり０なら操作２だけで所定の位置に動かせる
        continue
    else:
        cnt += 1


print(math.ceil(cnt/2))
Buggy python submission (verdict: Time Limit Exceeded):
#coding : utf-8

import os
import sys

def except_i(a, i):
	return a[0:i] + a[i+1:len(a)]

N = int(input())

A = []

for i in range(N):
	A.append(int(input()))


for i in range(N):
	t = A[i]
	A[i] = 0
	print(max(A))
	A[i] = t



Fixed submission:
#coding : utf-8

import os
import sys

N = int(input())

A = []

for i in range(N):
	A.append(int(input()))

X = [[A[i], i] for i in range(N)]


X.sort(key = lambda x: x[0], reverse=True)


for i in range(N):
	if i != X[0][1]:
		print(X[0][0])
	else:
		print(X[1][0])

Buggy python submission (verdict: Time Limit Exceeded):
#coding : utf-8

import os
import sys

def except_i(a, i):
	return a[0:i] + a[i+1:len(a)]

N = int(input())

A = []

for i in range(N):
	A.append(int(input()))


for i in range(N):
	print(max(except_i(A, i)))



Fixed submission:
#coding : utf-8

import os
import sys

N = int(input())

A = []

for i in range(N):
	A.append(int(input()))

X = [[A[i], i] for i in range(N)]


X.sort(key = lambda x: x[0], reverse=True)


for i in range(N):
	if i != X[0][1]:
		print(X[0][0])
	else:
		print(X[1][0])
Buggy python submission (verdict: Runtime Error):
#coding : utf-8　

import os
import sys

N, K = map(lambda x: int(x), input().split(" "))
S = input()

S = S[0:K] + S[K].lower() + S[K+1:len(S)]

print(S)




Fixed submission:
#coding : utf-8　

import os
import sys

N, K = map(lambda x: int(x), input().split(" "))
S = input()

S = S[0:K-1] + S[K-1].lower() + S[K:len(S)]

print(S)

Buggy python submission (verdict: Runtime Error):
#coding : utf-8　

import os
import sys

N, K = map(lambda x: int(x), input().split(" "))
S = input()

S = S[0:K] + S[K].lower() + S[K+1:len(S)]

print(S)




Fixed submission:
#coding : utf-8　

import os
import sys

N, K = map(lambda x: int(x), input().split(" "))
S = input()

S = S[0:K-1] + S[K-1].lower() + S[K:len(S)]

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

for i in range(1, N+1):
  print(A.count(i))

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

count_list = [0 for i in range(N)]
for num in A:
  count_list[num-1] += 1

print(*count_list, sep='\n')
Buggy python submission (verdict: Runtime Error):
import math

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A, B = list(map(int, input().split(' ')))
maxKouyaku = math.gcd(A, B)
#print(maxKouyaku)
if maxKouyaku == 1:
    print(1)
else:
    print(len(factorization(maxKouyaku)) + 1)

Fixed submission:
import fractions

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A, B = list(map(int, input().split(' ')))
maxKouyaku = fractions.gcd(A, B)
#print(maxKouyaku)
#print(*factorization(maxKouyaku))
if maxKouyaku == 1:
    print(1)
else:
    print(len(factorization(maxKouyaku)) + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))
A.sort(reverse=True)

for k in range(M):
    A[0] //= 2
    A.sort(reverse=True)
print(sum(A))

Fixed submission:
N, M = list(map(int, input().split(' ')))
A = list(map(int, input().split(' ')))
A_ = [-1 * num for num in A]

import heapq
import math

heapq.heapify(A_)

for k in range(M):
    maxA_ = heapq.heappop(A_)
    heapq.heappush(A_, math.ceil(maxA_ / 2))
    #print(maxA_, math.ceil(maxA_ / 2))
    #print(A_)
print(sum(A_) * (-1))
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().split(' ')))
S = list(input())

def change():
    check = S[0]
    k = 1
    while S[k] == check:
        k += 1
    i = 0
    while S[k + i] != check:
        S[k + i] = check
        i += 1

group = 1
old = S[0]
happy_num = 0
for i in range(1, N):
    if old == S[i]:
        group += 1
        if i == N - 1:
            happy_num += group - 1
    else:
        happy_num += group - 1
        old = S[i]
        group = 1
print(happy_num)

border = 0
for k in range(K):
    old = S[0]
    for i in range(1, N):
        if old != S[i]:
            border += 1
            if border == 2:
                break
            old = S[i]
    if border == 0:
        break
    elif border == 1:
        happy_num += 1
        S[1:] = S[0]
    else:
        happy_num += 2
        change()

print(happy_num)

Fixed submission:
N, K = list(map(int, input().split(' ')))
S = list(input())

def change():
    check = S[0]
    k = 1
    while S[k] == check:
        k += 1
    i = 0
    while S[k + i] != check:
        S[k + i] = check
        i += 1

group = 1
old = S[0]
happy_num = 0
for i in range(1, N):
    if old == S[i]:
        group += 1
        if i == N - 1:
            happy_num += group - 1
    else:
        happy_num += group - 1
        old = S[i]
        group = 1
#print(happy_num)


old = S[0]
border = 0
for i in range(1, N):
    if old != S[i]:
        border += 1
        old = S[i]
#print(border)

changed = 2 * K
if changed < border:
    print(happy_num + 2 * K)
else:
    print(N - 1)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
N = len(S)
Pos = [0 for i in range(N)]

for i in range(N):
    count = 0
    if S[i] == 'R':
        while S[i + count] != 'L':
            count += 1
        if count % 2 == 0:
            Pos[i + count] += 1
        else:
            Pos[i + count - 1] += 1
    else:
        while S[i - count] != 'R':
            count += 1
        if count % 2 == 0:
            Pos[i - count] += 1
        else:
            Pos[i - count + 1] += 1
    #print(count)
    #print(*Pos)

print(*Pos)

Fixed submission:
S = list(input())
N = len(S)
Pos = [0 for i in range(N)]

i = 0
while i < N:
    count = 0
    if S[i] == 'R':
        while S[i + count] != 'L':
            count += 1
        if count % 2 == 0:
            Pos[i + count] += count // 2
            Pos[i + count - 1] += count // 2
        else:
            Pos[i + count - 1] += count // 2 + 1
            Pos[i + count] += count // 2
    else:
        while i + count < N and S[i + count] != 'R':
            count += 1
        if count % 2 == 0:
            Pos[i] += count // 2
            Pos[i - 1] += count // 2
        else:
            Pos[i] += count // 2 + 1
            Pos[i - 1] += count // 2
    #print(count)
    i = i + count
    #print(*Pos)

print(*Pos)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

V = [0 for i in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            V[j] += A[i]
        elif i > j and (i + j) % 2 == 0:
            V[j] += A[i]
        elif i < j and (i + j) % 2 == 1:
            V[j] += A[i]
        else:
            V[j] -= A[i]

for volume in V:
    print(volume, end=' ')
print()

Fixed submission:
N = int(input())

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


volume = 0
for j in range(N):
    if j % 2 == 0:
        volume += A[j]
    else:
        volume -= A[j]
print(volume ,end=' ')

for i in range(1, N):
    volume = 2 * A[i - 1] - volume
    print(volume ,end=' ')

print()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

V = []
for i in range(N):
    volume = 0
    for j in range(N):
        k = i + j
        if k >= N:
            k -= N
        if j % 2 == 0:
            volume += A[k]
        else:
            volume -= A[k]
    print(volume ,end=' ')

print()

Fixed submission:
N = int(input())

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


volume = 0
for j in range(N):
    if j % 2 == 0:
        volume += A[j]
    else:
        volume -= A[j]
print(volume ,end=' ')

for i in range(1, N):
    volume = 2 * A[i - 1] - volume
    print(volume ,end=' ')

print()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

V = []
for i in range(N):
    volume = 0
    for j in range(N):
        if j % 2 == 0:
            volume += A[(i + j) % N]
        else:
            volume -= A[(i + j) % N]
    print(volume ,end=' ')

print()

Fixed submission:
N = int(input())

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


volume = 0
for j in range(N):
    if j % 2 == 0:
        volume += A[j]
    else:
        volume -= A[j]
print(volume ,end=' ')

for i in range(1, N):
    volume = 2 * A[i - 1] - volume
    print(volume ,end=' ')

print()
Buggy python submission (verdict: Runtime Error):
S = list(input())

A = S[0]
for char in S:
    if char != S[0]:
        B = char

count1 = S.count(A)
count2 = S.count(B)

if count1 == 2 and count2 == 2:
    print('Yes')
else:
    print('No')

Fixed submission:
S = list(input())

A = B = S[0]
for char in S:
    if char != S[0]:
        B = char

count1 = S.count(A)
count2 = S.count(B)

if count1 == 2 and count2 == 2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A, B, T = input.split(' ')
print(T / A * B)

Fixed submission:
A, B, T = input().split(' ')
A = int(A)
B = int(B)
T = int(T)
print(int(T / A) * B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split(' ')))

false_flag = 0
'''
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2
'''

count_list = [0 for i in range(N)]
for index in A:
    count_list[index] += 1

if N % 2 == 0:
    count_ = 1
    diff = -1
else:
    if count_list[0] != 1 or count_list[1] != 0:
        false_flag = 1
    count_ = 2
    diff = 1
while count_ < N and false_flag == 0:
    if count_list[count_] != 2 or count_list[count_ + diff] != 0:
        false_flag = 1
    count_ += 2

if false_flag == 0:
    print(2 ** (N // 2))
else:
    print(0)

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

false_flag = 0
'''
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2
'''

count_list = [0 for i in range(N)]
for index in A:
    count_list[index] += 1

if N % 2 == 0:
    count_ = 1
    diff = -1
else:
    if count_list[0] != 1:
        false_flag = 1
    count_ = 2
    diff = -1
while count_ < N and false_flag == 0:
    #print(count_)
    if count_list[count_] != 2 or count_list[count_ + diff] != 0:
        false_flag = 1
    count_ += 2

if false_flag == 0:
    print((2 ** (N // 2) ) % 1000000007)
else:
    print(0)

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

false_flag = 0
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2

if false_flag == 0:
    print(2 ** (N // 2))
else:
    print(0)

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

false_flag = 0
'''
if N % 2 == 0:
    count_ = 1
else:
    if A.count(0) != 1:
        false_flag = 1
    count_ = 2
while count_ < N and false_flag == 0:
    if A.count(count_) != 2:
        false_flag = 1
    count_ += 2
'''

count_list = [0 for i in range(N)]
for index in A:
    count_list[index] += 1

if N % 2 == 0:
    count_ = 1
    diff = -1
else:
    if count_list[0] != 1:
        false_flag = 1
    count_ = 2
    diff = -1
while count_ < N and false_flag == 0:
    #print(count_)
    if count_list[count_] != 2 or count_list[count_ + diff] != 0:
        false_flag = 1
    count_ += 2

if false_flag == 0:
    print((2 ** (N // 2) ) % 1000000007)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())

def check_S():
    check = S[0]
    for char in S:
        if check != char:
            return True
    return False

count = 0
while check_S():
    check = S[0]
    k = 0
    if check == 'B':
        while S[k] == 'B':
            S[k] = 'W'
            k += 1
    elif check == 'W':
        while S[k] == 'W':
            S[k] = 'B'
            k += 1
    count += 1

print(count)

Fixed submission:
S = list(input())

count = 0
check = S[0]
for i in range(1, len(S)):
    if check != S[i]:
        count += 1
        check = S[i]

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, A = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
X = max(x)
X = max(X, A)

dp = [[[0 for s in range(N * X + 1)] for k in range(N + 1)] for j in range(N + 1)]

dp[0][0][0] = 1
for j in range(1, N + 1):
    for k in range(N + 1):
        for s in range(N * X + 1):
            if s < x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s]
            elif k >= 1 and s >= x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
#print(dp)
count = 0
for k in range(1, N + 1):
    #print(dp[N][k][k * A])
    count += dp[N][k][k * A]
print(count)

Fixed submission:
N, A = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
X = max(x)
X = max(X, A)

dp = [[[0 for s in range(N * X + 1)] for k in range(N + 1)] for j in range(N + 1)]

dp[0][0][0] = 1
for j in range(1, N + 1):
    for k in range(N + 1):
        for s in range(N * X + 1):
            if s < x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s]
            elif k >= 1 and s >= x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
#print(dp)
count = 0
for k in range(1, N + 1):
    #print(dp[N][k][k * A])
    count += dp[N][k][k * A]
print(count)

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

dp = [[[0 for s in range(N * X + 1)] for k in range(N + 1)] for j in range(N + 1)]

dp[0][0][0] = 1
for j in range(N + 1):
    for k in range(N + 1):
        for s in range(N * X + 1):
            if j >= 1 and s < x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s]
            elif j >= 1 and k >= 1 and s >= x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
#print(dp)
count = 0
for k in range(1, N + 1):
    #print(dp[N][k][k * A])
    count += dp[N][k][k * A]
print(count)

Fixed submission:
N, A = list(map(int, input().split(' ')))
x = list(map(int, input().split(' ')))
X = max(x)
X = max(X, A)

dp = [[[0 for s in range(N * X + 1)] for k in range(N + 1)] for j in range(N + 1)]

dp[0][0][0] = 1
for j in range(1, N + 1):
    for k in range(N + 1):
        for s in range(N * X + 1):
            if s < x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s]
            elif k >= 1 and s >= x[j - 1]:
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
#print(dp)
count = 0
for k in range(1, N + 1):
    #print(dp[N][k][k * A])
    count += dp[N][k][k * A]
print(count)