Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
rev = False
for _ in range(int(input())):
  t = input()
  if t == "1":
    rev = not rev
  else:
    t = t.split()
    if (t[1] == "1" and not rev) or (t[1] == "2" and rev):
      s = t[2] + s
    else:
      s += t[2]
if rev:
  for i in reversed(s):
    print(i, end="")
else:
  print(s)


Fixed submission:
S = input()
len_s = len(S)
rev = False
max_ = 2*10**5
index = max_ + len_s
rev_index = max_ - 1
s = ["." for _ in range(max_*2 + len_s)]
for i in range(len_s):
    s[max_+i] = S[i]
for _ in range(int(input())):
  t = input()
  if t == "1":
    rev = not rev
  else:
    t = t.split()
    if (t[1] == "1" and not rev) or (t[1] == "2" and rev):
      s[rev_index] = t[2]
      rev_index -= 1
    else:
      s[index] = t[2]
      index += 1
if rev:
  for i in range((max_ + max_ + len_s - 1), 0, -1):
    if s[i] != ".":
      print(s[i], end="")
else:
  for i in range((max_ + max_ + len_s)):
    if s[i] != ".":
      print(s[i], end="")

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
rev = False
for _ in range(int(input())):
  t = input()
  if t == "1":
    rev = not rev
  else:
    t = t.split()
    if (t[1] == "1" and not rev) or (t[1] == "2" and rev):
      s = t[2] + s
    else:
      s += t[2]
if rev:
  print(s[::-1])
else:
  print(s)

Fixed submission:
S = input()
len_s = len(S)
rev = False
max_ = 2*10**5
index = max_ + len_s
rev_index = max_ - 1
s = ["." for _ in range(max_*2 + len_s)]
for i in range(len_s):
    s[max_+i] = S[i]
for _ in range(int(input())):
  t = input()
  if t == "1":
    rev = not rev
  else:
    t = t.split()
    if (t[1] == "1" and not rev) or (t[1] == "2" and rev):
      s[rev_index] = t[2]
      rev_index -= 1
    else:
      s[index] = t[2]
      index += 1
if rev:
  for i in range((max_ + max_ + len_s - 1), 0, -1):
    if s[i] != ".":
      print(s[i], end="")
else:
  for i in range((max_ + max_ + len_s)):
    if s[i] != ".":
      print(s[i], end="")

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
for _ in range(int(input())):
  t = input()
  if t == "1":
    s = s[::-1]
  else:
    t = t.split()
    if t[1] == "1":
      s = t[2] + s
    else:
      s += t[2]
print(s)

Fixed submission:
S = input()
len_s = len(S)
rev = False
max_ = 2*10**5
index = max_ + len_s
rev_index = max_ - 1
s = ["." for _ in range(max_*2 + len_s)]
for i in range(len_s):
    s[max_+i] = S[i]
for _ in range(int(input())):
  t = input()
  if t == "1":
    rev = not rev
  else:
    t = t.split()
    if (t[1] == "1" and not rev) or (t[1] == "2" and rev):
      s[rev_index] = t[2]
      rev_index -= 1
    else:
      s[index] = t[2]
      index += 1
if rev:
  for i in range((max_ + max_ + len_s - 1), 0, -1):
    if s[i] != ".":
      print(s[i], end="")
else:
  for i in range((max_ + max_ + len_s)):
    if s[i] != ".":
      print(s[i], end="")
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
x = map(int, raw_input().split())
for i in xrange(n):
    x2 = x[:i]+x[i+1:]
    print sorted(x2)[(n/2)-1]


Fixed submission:
n = input()
x = map(int, raw_input().split())
x2 = sorted(x)
mid1 = x2[(n/2)-1]
mid2 = x2[n/2]
if mid1 == mid2:
    for i in xrange(n):
        print mid1
else:
    for i in xrange(n):
        if x[i] <= mid1:
            print mid2
        else:
            print mid1
Buggy python submission (verdict: Runtime Error):
print (lambda x:x/3)(input())


Fixed submission:
print (lambda x:x/3)(input())
Buggy python submission (verdict: Time Limit Exceeded):
x, y = map(int, raw_input().split())
for i in xrange(x, x*y, x):
    if not i % y == 0:
        print i
        break
else:
    print -1


Fixed submission:
import sys
x, y = map(int, raw_input().split())
if x == y:
    print -1
    sys.exit()
for i in xrange(x, x*y, x):
    if not i % y == 0:
        print i
        break
else:
    print -1
Buggy python submission (verdict: Time Limit Exceeded):

def is_prime(q):
    if q == 2:
        return True
    return pow(2, q-1, q) == 1

n = input()
for _ in xrange(n):
    s = 0
    a, b = map(int, raw_input().split())
    for i in xrange(a, b+1):
        if is_prime(i) and is_prime((i+1)/2):
            s += 1
    print s


Fixed submission:
import math
def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n%2 == 0:
        return False
    for i in xrange(3, int(math.sqrt(n))+1, 2):
        if n%i == 0:
            return False
    return True

m = list()
s = 0
for i in xrange(10**5):
    if is_prime(i) and is_prime((i+1)/2):
        s += 1
    m.append(s)

n = input()
for _ in xrange(n):
    s = 0
    a, b = map(int, raw_input().split())
    print m[b] - m[a-1]

Buggy python submission (verdict: Time Limit Exceeded):
import math
def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n%2 == 0:
        return False
    for i in xrange(3, int(math.sqrt(n))+1, 2):
        if n%i == 0:
            return False
    return True

n = input()
for _ in xrange(n):
    s = 0
    a, b = map(int, raw_input().split())
    for i in xrange(a, b+1):
        if is_prime(i) and is_prime((i+1)/2):
            s += 1
    print s


Fixed submission:
import math
def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n%2 == 0:
        return False
    for i in xrange(3, int(math.sqrt(n))+1, 2):
        if n%i == 0:
            return False
    return True

m = list()
s = 0
for i in xrange(10**5):
    if is_prime(i) and is_prime((i+1)/2):
        s += 1
    m.append(s)

n = input()
for _ in xrange(n):
    s = 0
    a, b = map(int, raw_input().split())
    print m[b] - m[a-1]
Buggy python submission (verdict: Runtime Error):
mx = max(mx, min(i, len(l)-x))

Fixed submission:
import sys
l = list(raw_input())
if (not "0" in l) or (not "1" in l):
    print len(l)
    sys.exit()

s = l[0]
f = False
mx = 0
x = 0
for i, n in enumerate(l):
    if not n == s:
        mx = max(mx, min(i, len(l)-x))
        x = i
        s = n
mx = max(mx, min(i, len(l)-x))
print mx
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n, k = map(int, raw_input().split())
num = map(int, raw_input().split())
n = int()
num = collections.Counter(num)
while True:
    if len(num) <= k:
        print n
        break
    t, v = sorted(num.items(), key=lambda x:x[1])[0]
    del num[t]
    n += v

Fixed submission:
import collections
n, k = map(int, raw_input().split())
num = map(int, raw_input().split())
n = int()
num = collections.Counter(num)
for t, v in sorted(num.items(), key=lambda x:x[1])[0:-k]:
    n += v
print n

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n, k = map(int, raw_input().split())
num = map(int, raw_input().split())
n = int()
num = collections.Counter(num)
while True:
    if len(num) <= k:
        print n
        break
    t, v = sorted(num.items(), key=lambda x:x[1])[0]
    del num[t]
    n += v


Fixed submission:
import collections
n, k = map(int, raw_input().split())
num = map(int, raw_input().split())
n = int()
num = collections.Counter(num)
for t, v in sorted(num.items(), key=lambda x:x[1])[0:-k]:
    n += v
print n
Buggy python submission (verdict: Runtime Error):
h, w = map(int, raw_input().split())
table = list()
table.append([0]*(w+2))
for _ in xrange(h):
    table.append([0]+list(map(lambda c:0 if c == "." else c, list(raw_input())))+[0])
table.append([0]*(w+2))

xy = [0, 1, 0, -1, 1, 1, -1, -1, 0]
for i in xrange(1, h+1):
    for j in xrange(1, w+1):
        if table[i][j] == "#":
            for k in xrange(8):
                table[i+xy[k]][j+xy[k+1]] += 1


for i in xrange(1, h+1):
    print "".join(map(str, table[i][1:-1]))


Fixed submission:
h, w = map(int, raw_input().split())
table = list()
table.append([0]*(w+2))
for _ in xrange(h):
    table.append([0]+list(map(lambda c:0 if c == "." else c, list(raw_input())))+[0])
table.append([0]*(w+2))

xy = [0, 1, 0, -1, 1, 1, -1, -1, 0]
for i in xrange(1, h+1):
    for j in xrange(1, w+1):
        if table[i][j] == "#":
            for k in xrange(8):
                if type(table[i+xy[k]][j+xy[k+1]]) == type(int()):
                    table[i+xy[k]][j+xy[k+1]] += 1


for i in xrange(1, h+1):
    print "".join(map(str, table[i][1:-1]))
Buggy python submission (verdict: Runtime Error):
str = input()
str = list(str)


for index, value in enumerate(str):
    if (value == '?' and index == len(str) - 1):
        str[index] = 'D'

    elif (value == '?' and index != 0 and str[index -] == 'P'):
        str[index] = 'D'

    elif (value == '?' and str[index + 1] == '?'):
        str[index] = 'P'
        str[index + 1] = 'D'
    elif (value == '?'):
    	str[index] = 'D'


print(''.join(str))

Fixed submission:
str = input()
str = list(str)


for index, value in enumerate(str):
    if (value == '?' and index == len(str) - 1):
        str[index] = 'D'

    elif (value == '?' and index != 0 and str[index - 1] == 'P'):
        str[index] = 'D'

    elif (value == '?' and str[index + 1] == '?'):
        str[index] = 'P'
        str[index + 1] = 'D'
    elif (value == '?'):
    	str[index] = 'D'


print(''.join(str))

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


for index, value in enumerate(str):
    if (value == '?' and index == len(str) - 1):
        str[index] = 'D'

    elif (value == '?' and index != 0 and str[index -] == 'P'):
        str[index] = 'D'

    elif (value == '?' and str[index + 1] == '?'):
        str[index] = 'P'
        str[index + 1] = 'D'
    elif (value == '?'):
    	str[index] = 'D'


print(''.join(str))

Fixed submission:
str = input()
str = list(str)


for index, value in enumerate(str):
    if (value == '?' and index == len(str) - 1):
        str[index] = 'D'

    elif (value == '?' and index != 0 and str[index - 1] == 'P'):
        str[index] = 'D'

    elif (value == '?' and str[index + 1] == '?'):
        str[index] = 'P'
        str[index + 1] = 'D'
    elif (value == '?'):
    	str[index] = 'D'


print(''.join(str))
Buggy python submission (verdict: Runtime Error):
import math
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

a = listA[0][0]
b = listA[0][1]
n = listA[0][2]

old = 0
for x in range(1,n+1):
  if x == 1:
    c = math.floor((a*x)/b)
    d = math.floor(x/b)
    old = c-(a*d)
  else:
    c = math.floor((a*x)/b)
    d = math.floor(x/b)
    current = c-(a*d)
    if old <= current:
      old = current
  if x > 10000000:
    break
print (old)
  


Fixed submission:
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

a = listA[0][0]
b = listA[1][0]
c = listA[1][1]

if b % a == 0:
  print ('OK')

d = b // a

if b % a !=0:
  if a * (d+1) <= c:
    print ('OK')
  else:
    print ('NG')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))
l.insert(0, 0)
ans = l.copy()
for i in range(len(l)):
    ans[i] = 0
for i in range(len(l)):
    ans[i] = l.count(i + 1)
for i in ans:
    print(i)

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
l.append('END')
ans = l.copy()
for i in range(len(l)):
    ans[i] = 0
try:
    for i in range(len(l)):
        ans[l[i] - 1] += 1
except TypeError:
    pass
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
N, b, r = map(int, input().split())
ans = N // (b + r) * b
N = N % (b + r)
if b > N:
    ans += N
else:
    ans += b
print(ans)

Fixed submission:
l = list(input())
if 'A'in l and 'B' in l:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, b, r = map(int, input().split())
ans = N // (b + r) * b
N = N % (b + r)
for i in range(N):
    if b:
        ans += 1
        b -= 1
    else:
        break
print(ans)

Fixed submission:
N, b, r = map(int, input().split())
ans = N // (b + r) * b
N = N % (b + r)
if b > N:
    ans += N
else:
    ans += b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, b, r = map(int, input().split())
b_tmp, r_tmp = b, r
ans = 0
for i in range(N):
    if b_tmp:
        ans += 1
        b_tmp -= 1
    elif r_tmp:
        r_tmp -= 1
    if b_tmp or r_tmp:
        pass
    else:
        b_tmp, r_tmp = b, r
print(ans)

Fixed submission:
N, b, r = map(int, input().split())
ans = N // (b + r) * b
N = N % (b + r)
if b > N:
    ans += N
else:
    ans += b
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n = input()
n = math.ceil(n / 2)
print(n)

Fixed submission:
import math
n = int(input())
n = math.ceil(n / 2)
print(n)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
S = input()
a = ["SUN", "MUN", "TUE", "WED", "THU", "FRI", "SAT"]
a.reverse()
ans = a.index(S) + 1
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
S = input()
a = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
a.reverse()
ans = a.index(S) + 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int (input())
L = list(map(int, input().split()))
L.sort()
count = 0

while len(L) > 2:
    for i in range(2,len(L)):
        if L[i] < L[0] + L[1]:
                count += 1
        if len(L) > 3:
            for j in range(3,len(L)):
                if L[j] < L[0] + L[i] and i < j:
                    count += 1
    del(L[0])

print(count)

Fixed submission:
# -*- coding: utf-8 -*-
from bisect import bisect_left

N = int (input())
L = list(map(int, input().split()))
L.sort()

count = 0

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        count += bisect_left(L,L[i]+L[j]) - j - 1
        
print(count)
Buggy python submission (verdict: Runtime Error):

h1, m1, h2, m2, k = map(int, input().split(" "))
A = list(map(int, input().split(" ")))

start = h1*60+m1
end = h2*60+m2
total = end - start - k

print(k)

Fixed submission:

h1, m1, h2, m2, k = map(int, input().split(" "))

start = h1*60+m1
end = h2*60+m2
total = end - start - k

print(total)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = input().split(" ")
a = 0
for i in range(len(n)):
    pf = p[i]
    ps = p[i+1]
    pt = p[i+2]
    il = [int(pf),int(ps),int(pt)]
    max_p = max(il)
    il.remove(max_p)
    if int(ps) == max(il):
        a += 1
print(a)

Fixed submission:
n = int(input())
p = input().split(" ")
a = 0
for i in range(len(p)):
    try:
        pf = p[i]
        ps = p[i+1]
        pt = p[i+2]
        il = [int(pf),int(ps),int(pt)]
        max_p = max(il)
        il.remove(max_p)
        if int(ps) == max(il):
            a += 1
    except:
        pass
print(a)

Buggy python submission (verdict: Runtime Error):
n = int(input())
p = input().split(" ")
a = 0
for i in range(len(n)):
    pf = p[i]
    ps = p[i+1]
    pt = p[i+2]
    il = [int(pf),int(ps),int(pt)]
    max_p = max(il)
    il.remove(max_p)
    if int(ps) = max(il):
        a += 1
print(a)

Fixed submission:
n = int(input())
p = input().split(" ")
a = 0
for i in range(len(p)):
    try:
        pf = p[i]
        ps = p[i+1]
        pt = p[i+2]
        il = [int(pf),int(ps),int(pt)]
        max_p = max(il)
        il.remove(max_p)
        if int(ps) == max(il):
            a += 1
    except:
        pass
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

X,Y,Z,K = nums()
A = nums()
B = nums()
C = nums()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = [bi + ai for bi in B for ai in A]
AB.sort(reverse=1)
res = []
for ab_sum in AB[:K]:
    for ci in C[:K]:
        res.append(ab_sum + ci)
res.sort(reverse=True)
for ans in res[:K]:
    print(ans)

Fixed submission:
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

X,Y,Z,K = nums()
A = nums()
B = nums()
C = nums()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = [bi + ai for bi in B for ai in A]
AB.sort(reverse=1)
res = []
for ab_sum in AB[:K]:
    for ci in C[:K]:
        res.append(ab_sum + ci)
res.sort(reverse=True)
for ans in res[:K]:
    print(ans)

Buggy python submission (verdict: Runtime Error):
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

X,Y,Z,K = nums()
A = nums()
B = nums()
C = nums()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = [bi + ai for bi in B for ai in A]
res = []
for ab_sum in AB[:K]:
    for ci in C[:K]:
        res.append(ab_sum + ci)
res.sort(reverse=True)
for ans in res[:K]:
    print(ans)

Fixed submission:
def num():
    return int(input())
def nums():
    return list(map(int,input().split()))

X,Y,Z,K = nums()
A = nums()
B = nums()
C = nums()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

AB = [bi + ai for bi in B for ai in A]
AB.sort(reverse=1)
res = []
for ab_sum in AB[:K]:
    for ci in C[:K]:
        res.append(ab_sum + ci)
res.sort(reverse=True)
for ans in res[:K]:
    print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
st = []
if len(S) %2 != 0 :
    print('No')
else :
    for i in range(len(S) // 2) :
        st.append(S[i:i+2])
      
    st = list(set(st))) 
    if len(st) == 1 and st[0] == 'hi' :
        print('Yes')
    else :
        print('No')

Fixed submission:

S = input()
st = []
if len(S) %2 != 0 :
    print('No')
else :
    for i in range(len(S) // 2) :
        st.append(S[i*2:i*2+2])
      
    st = list(set(st)) 
    if len(st) == 1 and st[0] == 'hi' :
        print('Yes')
    else :
        print('No')
Buggy python submission (verdict: Runtime Error):
x = np.array(input().split(' '), int)
print(x[1:].min(),' ', 0 if x[0] >= x[1:].sum() else x[1:].sum() - x[0])

Fixed submission:
import numpy as np
x = np.array(input().split(' '), int)
print(x[1:].min(),' ', 0 if x[0] >= x[1:].sum() else x[1:].sum() - x[0])
Buggy python submission (verdict: Runtime Error):
print input.rstrip('FESTIVAL')

Fixed submission:
x=input()
print(x[0:len(x)-8])
Buggy python submission (verdict: Runtime Error):
a = map(int, raw_input().split())

a[0] = (a[0] + 12) % 13
a[1] = (a[1] + 12) % 13

if a[0] == a[1]  :


Fixed submission:
a = map(int, raw_input().split())

if a[0] == 1 :
    a[0] = 14
if a[1] == 1 :
    a[1] = 14

if a[0] == a[1] :
    print 'Draw'
elif a[0] > a[1] :
    print 'Alice'
else :
    print 'Bob'
Buggy python submission (verdict: Runtime Error):
count = 0
N = int(input())
K = int(input())
hi_list = list()
while count < N:
    count += 1
    hi = int(input())
    hi_list.append(hi)
ok_list = list()
for data in hi_list:
    if data >= K:
        ok_list.append(data)
print(len(ok_list))

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
ok_list = list()
for data in h:
    if data >= k:
        ok_list.append(data)
print(len(ok_list))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    left = 1
    right = N if N%2 == 0 else N-1
    count = 0
    if N%2 == 0:
        raise Exception
        while count < M:
            if right-left == N//2:
                left += 1
                right -= 1
                continue
            print(left,right)
            left += 1
            right -= 1
            count += 1
    else:
        while count < M:
            print(left,right)
            left += 1
            right -= 1
            count += 1
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int):
    left = 1
    right = N if N%2 == 0 else N-1
    count = 0
    if N%2 == 0:
        p = set()
        while count < M:
            if right-left == N//2 or N-(right-left) in p:
                left += 1
                continue
            print(left,right)
            p.add(right-left)
            left += 1
            right -= 1
            count += 1
    else:
        while count < M:
            print(left,right)
            left += 1
            right -= 1
            count += 1
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
MOD = 998244353  # type: int

def solve(N: int, S: int, A: "List[int]"):
    dp = [[0]*(S+1) for _ in range(N+1)]

    for i in range(N):
        for s in range(S+1):
            if s >= A[i]:
                dp[i+1][s] = dp[i][s]+dp[i][s-A[i]]+int(A[i]==s or s==0)
            else:
                dp[i+1][s] = dp[i][s]+int(A[i]==s or s==0)
            dp[i+1][s]%=MOD
    
    answer = 0
    for i in range(N):
        answer += dp[i+1][S]
    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, S, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
MOD = 998244353  # type: int

def solve(N: int, S: int, A: "List[int]"):
    dp = [[0]*(S+1) for _ in range(N+1)]

    for i in range(N):
        for s in range(S+1):
            if s >= A[i]:
                dp[i+1][s] = dp[i][s]+dp[i][s-A[i]]+int(A[i]==s or s==0)
            else:
                dp[i+1][s] = dp[i][s]+int(A[i]==s or s==0)
            dp[i+1][s]%=MOD
    
    answer = 0
    for i in range(N):
        answer += dp[i+1][S]
    print(answer%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, S, A)

if __name__ == '__main__':
    main()