Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * (n)
j = 1
tmpdp = 10 ** 9
for i in range(1,n):
  while i - j >= 0 and j <= k:
    if tmpdp > dp[i-j] + abs(h[i] - h[i-j]):
      tmpdp = dp[i-j] + abs(h[i] - h[i-j])
    j += 1
  dp[i] = tmpdp
  j = 1
  tmpdp = 10 ** 9

print(dp[-1])

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

dp = [0] * (n)
j = 1
tmpdp = 10 ** 9
for i in range(1,n):
  while i - j >= 0 and j <= k:
    if tmpdp > dp[i-j] + abs(h[i] - h[i-j]):
      tmpdp = dp[i-j] + abs(h[i] - h[i-j])
    j += 1
  dp[i] = tmpdp
  j = 1
  tmpdp = 10 ** 9

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
l, n = map(int, input().split())
st = []
for _ in range(n):
	st.append(str(input()))
st.sort()
print("".join(st))

Fixed submission:
N, L = map(int, input().split())
list=[]
for i in range(N):
    list.append(str(input()))
list.sort()
print("".join(list))

Buggy python submission (verdict: Runtime Error):
l, n = map(int, input().split())
 
st = []
for _ in range(n):
  st.append(str(input()))
st.sort()
print("".join(st))

Fixed submission:
N, L = map(int, input().split())
list=[]
for i in range(N):
    list.append(str(input()))
list.sort()
print("".join(list))

Buggy python submission (verdict: Runtime Error):
l, n = map(int, input().split())

st = []
for _ in range(n):
  st.append(str(input()))

st.sort()
  
print(''.join(st))


Fixed submission:
N, L = map(int, input().split())
list=[]
for i in range(N):
    list.append(str(input()))
list.sort()
print("".join(list))

Buggy python submission (verdict: Runtime Error):
l, n = map(int, input().split())

st = []
for _ in range(n):
  st.append(str(input()))

st.sort()
ans = ''

for s in st:
  ans += s
  
print(ans)


Fixed submission:
N, L = map(int, input().split())
list=[]
for i in range(N):
    list.append(str(input()))
list.sort()
print("".join(list))

Buggy python submission (verdict: Runtime Error):
l, n = map(int, input().split())

st = []
for _ in range(n):
  st.append(input())

st.sort()
ans = ''

for s in st:
  ans += s
  
print(ans)


Fixed submission:
N, L = map(int, input().split())
list=[]
for i in range(N):
    list.append(str(input()))
list.sort()
print("".join(list))
Buggy python submission (verdict: Runtime Error):
def f(N,S):
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    ret_s = ""
    for s in S:
        num = (alpha.index(str(s)) + int(N))
        if num <= 25:
            pass
        else:
            num = num-(num//26)*26
        ret_s += alpha[num]
    return print(ret_s)

a = input()
b = input()

f(a,b)

Fixed submission:
def f(S):
    d = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
    return print(d[str(S)])
f(input())

Buggy python submission (verdict: Runtime Error):
def f(N,S):
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    ret_s = ""
    for s in S:
        num = (alpha.index(str(s)) + int(N))
        if num <= 25:
            pass
        else:
            num = num-(num//26)*26
        ret_s += alpha[num]
    return print(ret_s)

a = input()
b = input()

Fixed submission:
def f(S):
    d = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
    return print(d[str(S)])
f(input())
Buggy python submission (verdict: Runtime Error):
def f(N,S):
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    ret_s = ""
    for s in S:
        num = (alpha.index(str(s)) + N)
        if num <= 25:
            pass
        else:
            num = num-(num//25)*25-1
        ret_s += alpha[num]
    return print(ret_s)

N = input()
S = input()
f(N,S)

Fixed submission:
def f(N,S):
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    ret_s = ""
    for s in S:
        num = (alpha.index(str(s)) + int(N))
        if num <= 25:
            pass
        else:
            num = num-(num//26)*26
        ret_s += alpha[num]
    return print(ret_s)
  
a = input()#13#
b = input()#"ABCDEFGHIJKLMNOPQRSTUVWXYZ"#
 
f(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N,X,Y = map(int,input().split())
X -= 1
Y -= 1

d = {i:set() for i in range(N)}
for i in range(0,N):
  if i-1>=0:
    d[i-1].add(i)
  if i+1<=N-1:
    d[i+1].add(i)
  if i==X:
    d[Y].add(X)
    d[X].add(Y)

ans = {i+1:0 for i in range(N-1)}


for i in range(0,N):
  dist = [-1]*N
  q = deque([i])
  dist[i] = 0
  while q:
    v = q.popleft()
    for j in d[v]:
      if dist[v] + 1 < dist[j] or dist[j]==-1:
        dist[j] = dist[v] + 1
        q.appendleft(j)
  for k in dist:
    if k in ans:
      ans[k] += 1

for l in ans.values():
  print(l//2)
  

Fixed submission:
from collections import deque

N,X,Y = map(int,input().split())
X -= 1
Y -= 1

d = {i:set() for i in range(N)}
for i in range(0,N):
  if i-1>=0:
    d[i-1].add(i)
  if i+1<=N-1:
    d[i+1].add(i)
  if i==X:
    d[Y].add(X)
    d[X].add(Y)

ans = {i+1:0 for i in range(N-1)}

for i in range(0,N):
  dist = [-1]*N
  q = deque([i])
  dist[i] = 0
  while q:
    v = q.popleft()
    for j in d[v]:
      if  dist[j] == -1:
        dist[j] = dist[v] + 1
        ans[dist[j]] += 1
        q.appendleft(j)
      elif dist[v] + 1 < dist[j]:
        ans[dist[j]] -= 1
        dist[j] = dist[v] + 1
        ans[dist[j]] += 1
        q.appendleft(j)

for l in ans.values():
  print(l//2)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = int(input())

point = 0
for i in range(n):
  q = input().split()
  if q.pop(0)=='1':
    point = (point+1)%2
  else:
    _q = int(q.pop(0))-1
    if (point+_q)%2 == 0:
      s.insert(0,q.pop(0))
    else:
      s.append(q.pop(0))
      
if point == 1:
  s.reverse()

print(''.join(s))

Fixed submission:
from collections import deque

s = deque(input())
n = int(input())

point = 0
for i in range(n):
  q = input().split()
  if q.pop(0)=='1':
    point = (point+1)%2
  else:
    _q = int(q.pop(0))-1
    if (point+_q)%2 == 0:
      s.appendleft(q.pop(0))
    else:
      s.append(q.pop(0))

if point == 1:
  s.reverse()

print(''.join(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = int(input())

for i in range(n):
  q = input().split()
  if q.pop(0)=='1':
    s.reverse()
  else:
    if q.pop(0)=='1':
      s.insert(0,q.pop(0))
    else:
      s.append(q.pop(0))

print(''.join(s))

Fixed submission:
from collections import deque

s = deque(input())
n = int(input())

point = 0
for i in range(n):
  q = input().split()
  if q.pop(0)=='1':
    point = (point+1)%2
  else:
    _q = int(q.pop(0))-1
    if (point+_q)%2 == 0:
      s.appendleft(q.pop(0))
    else:
      s.append(q.pop(0))

if point == 1:
  s.reverse()

print(''.join(s))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())

S = np.array([], dtype="U10")
cnt = np.array([], dtype=int)

for i in range(N):
  s = input()
  if s in S:
    cnt[np.where(S==s)] += 1
  else:
    idx = np.searchsorted(S,s)
    S = np.insert(S,idx,s)
    cnt = np.insert(cnt,idx,1)

ans = S[cnt==cnt.max()]

for s in ans:
  print(s)

Fixed submission:
N = int(input())

d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1

M = max(d.values())
for j,k in sorted(d.items()):
  if k == M:
    print(j)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())

S = []
cnt = []
for i in range(N):
  s = input()
  if s in S:
    cnt[S.index(s)] += 1
  else:
    S.append(s)
    cnt.append(1)

cnt = np.array(cnt)
S = np.array(S)

ans = S[cnt==cnt.max()]
ans.sort()

for s in ans:
  print(s)

Fixed submission:
N = int(input())

d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1

M = max(d.values())
for j,k in sorted(d.items()):
  if k == M:
    print(j)

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

S = []
cnt = []
for i in range(N):
  s = input()
  if s in S:
    cnt[S.index(s)] += 1
  else:
    S.append(s)
    cnt.append(1)

M = max(cnt)
ans = [S[i] for i in range(len(S)) if cnt[i]==M]
ans.sort()

for s in ans:
  print(s)

Fixed submission:
N = int(input())

d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1

M = max(d.values())
for j,k in sorted(d.items()):
  if k == M:
    print(j)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,K = map(int,input().split())
A = np.array([int(i) for i in input().split()])

posi = A[A>0]
zero = A[A==0]
nega = A[A<0]


def f(x):
    """count the number of products , <= x"""
    cnt_tpl = 0
    # count 0
    if x >= 0:
        cnt_tpl += len(zero) * N
    # count posi
    cnt_tpl += np.searchsorted(A, x//pos, side='right').sum()
    # count nega
    cnt_tpl += (N - np.searchsorted(A, (-x - 1) // (-neg), side='right')).sum()
    # remove a^2
    cnt_tpl -= np.count_nonzero(A*A <= x)
    return cnt_tpl // 2

# 二分探索
left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= K:
        right = x
    else:
        left = x
 
print(right)

Fixed submission:
import numpy as np
N,K = map(int,input().split())
A = np.array([int(i) for i in input().split()])


A = np.sort(A)
posi = A[A>0]
zero = A[A==0]
nega = A[A<0]

def f(x):
    """count the number of products , <= x"""
    cnt_tpl = 0
    # count 0
    if x >= 0:
        cnt_tpl += len(zero) * N
    # count posi
    cnt_tpl += np.searchsorted(A, x//posi, side='right').sum()
    # count nega
    cnt_tpl += (N - np.searchsorted(A, (-x - 1) // (-nega), side='right')).sum()
    # remove a^2
    cnt_tpl -= np.count_nonzero(A*A <= x)
    return cnt_tpl // 2

# 二分探索
left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f(x) >= K:
        right = x
    else:
        left = x

print(right)
Buggy python submission (verdict: Runtime Error):
S,T = input().split()
cnt = [int(i) for i input().split()]
U = input()

if U == S:
  cnt[0] -= 1
else:
  cnt[1] -= 1

print(" ".join(cnt))

Fixed submission:
S,T = input().split()
cnt = [int(i) for i in input().split()]
U = input()
 
if U == S:
  cnt[0] -= 1
else:
  cnt[1] -= 1

print(" ".join([str(j) for j in cnt]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [int(i) for i in input().split()].sort()

flg = 0
for i in range(1,N):
  if S[i] = S[i-1]:
    flg = 1
    
if flg == 1:
  print("NO")
else:
  print("YES")  


Fixed submission:
import numpy as np

N = int(input())
S = np.array([int(i) for i in input().split()])

if len(np.unique(S))==len(S):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
# ABC154 D - Dice in Line
N,K = map(int, input().split())
P = [int(i) for i in input().split()]

ma = 0
for i in range(0,N-K+1):
  expect = (sum(P[i:i+K])+K)/2
  if ma < expect:
    ma = expect
print(ma)

Fixed submission:
# ウィンドウをスライドさせる際に，期待値の全体を再計算するのをやめた
N,K = map(int, input().split())
P = [int(i) for i in input().split()]
 
expect = (sum(P[0:K])+K)/2
ma = expect
for i in range(K,N):
  expect += (P[i]-P[i-K])/2
  if ma < expect:
    ma = expect
print(ma)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

C = 0
for i in range(1,10):
  for j in range(1,10):
    cij = 0
    cji = 0
    for k in range(1,N+1):
      s = str(k)
      if int(s[0]) == i and int(s[-1]) == j:
        cij += 1
      if int(s[0]) == j and int(s[-1]) == i:
        cji += 1
    C += cij*cji
print(C)


Fixed submission:
import numpy as np
N = int(input())

def f(x):
  a = x%10
  b = 0
  while x > 0:
    b = x
    x //= 10
  return a,b

freq = np.zeros((10,10), dtype=int)
for k in range(1,N+1):
  a,b = f(k)
  freq[a,b] += 1

print((freq*freq.T).sum())
Buggy python submission (verdict: Runtime Error):
print(''.join(input().split().reverse()))

Fixed submission:
print(''.join(reversed(input().split())))
Buggy python submission (verdict: Runtime Error):
# シンプルに左から探索するだけ
N = int(input())
A = [int(i) for i in input().split()]

L = [i+1 for i in range(3)]

cnt = 0
k = 0
for j in A:
  if j == L[k]:
    k += 1
  else:
    cnt += 1 

if k == 0:
  print(-1)
else:
  print(cnt)

Fixed submission:
# シンプルに左から探索するだけ
N = int(input())
A = [int(i) for i in input().split()]

L = [i+1 for i in range(N)]

cnt = 0
k = 0
for j in A:
  if j == L[k]:
    k += 1
  else:
    cnt += 1 

if k == 0:
  print(-1)
else:
  print(cnt)
Buggy python submission (verdict: Runtime Error):
from math import atan, degrees
a,b,x = map(int, input().split())

if x >= a*b/2:
  print(round(degrees(atan((b-x/(a**2))*2/a),7)))
else:
  print(round(degrees(atan(a*(b**2)/(2*x))),7))

Fixed submission:
from math import atan, degrees
a,b,x = map(int, input().split())

if x/a >= a*b/2:
  print(degrees(atan((b-x/(a**2))*2/a)))
else:
  print(90 - degrees(atan(2*x/(a*(b**2)))))
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())

def gcd(a, b):
  while b:
      a, b = b, a % b
  return a

def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

g = gcd(a,b)
fac = prime(g)
print(len(fac)+1)


Fixed submission:
import math

a,b = map(int, input().split())
 
def gcd(a, b):
  while b:
      a, b = b, a % b
  return a
 
def prime(n):
    factor = {}
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            if not num in factor.keys():
                factor[num] = 1
            else:
                factor[num] += 1
    if n != 1:
        if not n in factor.keys():
            factor[n] = 1
        else:
            factor[n] += 1
    return factor

g = gcd(a,b)
fac = prime(g)
print(len(fac)+1)
Buggy python submission (verdict: Runtime Error):
from heapq import heappop, heappush, heapify
n, m = map(int, input().split())
a = [-int(i) for i in input().split()]

heapify(a)
for _ in range(m):
  l = heappop(a)
  heappush(a, -((-l)//2))
  print(l,a)

print(-sum(a))

Fixed submission:
from heapq import heappop, heappush, heapify
n, m = map(int, input().split())
a = [-int(i) for i in input().split()]

heapify(a)
for _ in range(m):
  l = heappop(a)
  heappush(a, -((-l)//2))

print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
A = [int(i) for i in input().split()]
 
A.sort(reverse=True)
 
def bisect(A,x):
  lo = -1
  hi = len(A)
  while lo+1 < hi:
    idx = (lo+hi)//2
    if A[idx] > x:
      lo = idx
    else:
      hi = idx
  return lo
 
for i in range(m):
  v = A.pop(0)//2
  idx = bisect(A,v)+1
  A = A[:idx] + [v] + A[idx:]

print(sum(A))

Fixed submission:
from heapq import heappop, heappush, heapify
n, m = map(int, input().split())
a = [-int(i) for i in input().split()]

heapify(a)
for _ in range(m):
  l = heappop(a)
  heappush(a, -((-l)//2))

print(-sum(a))

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

A.sort(reverse=True)

def bisect(A,x):
  lo = -1
  hi = len(A)
  while lo+1 < hi:
    idx = (lo+hi)//2
    if A[idx] > x:
      lo = idx
    else:
      hi = idx
  return lo

for i in range(m):
  v = A.pop(0)//2
  idx = bisect(A,v)+1
  A = A[:idx] + [v] + A[idx:]

print(sum(A))

Fixed submission:
from heapq import heappop, heappush, heapify
n, m = map(int, input().split())
a = [-int(i) for i in input().split()]

heapify(a)
for _ in range(m):
  l = heappop(a)
  heappush(a, -((-l)//2))

print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
S = "x"+S+"x"
L = [1]*N
 
cnt = 0
m1 = [0]*N
m2 = [0]*N
while m2 != L:
  m2 = m1[:]
  m1 = L[:]
  tmp = L[:]
  for i in range(N):
    if L[i] == 0:
      pass
    elif S[i+1] == "R" and S[i+2]!="x":
      tmp[i] -= L[i]
      tmp[i+1] += L[i]
    elif S[i+1] == "L" and S[i]!="x":
      tmp[i] -= L[i]
      tmp[i-1] += L[i]
  L = tmp[:]
  cnt += 1

if cnt%2 == 1:
  print(' '.join(map(str,m1)))
else:
  print(' '.join(map(str,L)))

Fixed submission:
S = input()
N = len(S)
L = [1]*N

for i,s in enumerate(S):
  if s == "R":
    s2 = S[i+1]
    if s2 == "R":
      L[i+2] += L[i]
      L[i] = 0

for i in range(N-1,-1,-1):
  s = S[i]
  if s == "L":
    s2 = S[i-1]
    if s2 == "L":
      L[i-2] += L[i]
      L[i] = 0

print(*L)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
S = "x"+S+"x"
L = [1]*N
 
cnt = 0
m1 = [0]*N
m2 = [0]*N
while m2 != L:
  m2 = m1[:]
  m1 = L[:]
  tmp = L[:]
  for i in range(N):
    if L[i] == 0:
      pass
    elif S[i+1] == "R" and S[i+2]!="x":
      tmp[i] -= L[i]
      tmp[i+1] += L[i]
    elif S[i+1] == "L" and S[i]!="x":
      tmp[i] -= L[i]
      tmp[i-1] += L[i]
  L = tmp[:]
  cnt += 1

if cnt%2 == 1:
  print(' '.join(map(str,m1)))
else:
  print(' '.join(map(str,L)))

Fixed submission:
S = input()
N = len(S)
L = [1]*N

for i,s in enumerate(S):
  if s == "R":
    s2 = S[i+1]
    if s2 == "R":
      L[i+2] += L[i]
      L[i] = 0

for i in range(N-1,-1,-1):
  s = S[i]
  if s == "L":
    s2 = S[i-1]
    if s2 == "L":
      L[i-2] += L[i]
      L[i] = 0

print(*L)
Buggy python submission (verdict: Time Limit Exceeded):

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

B = []
for i in A:
    B.append(i - 1)
    B.append(i)
    B.append(i + 1)

Bset = set(B)
C = []
for i in Bset:
    C.append(len(list(filter(lambda x: x == i, B))))

print(max(C))



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

B = []
for i in A:
    B.append(i - 1)
    B.append(i)
    B.append(i + 1)
B.sort()

C = []
count = 0
for i in range(len(B)):
    if B[i] == B[i - 1]:
        count += 1
    else:
        C.append(count + 1)
        count = 0

print(max(C))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

A = set({})
B = set({})
for j in range(N-1):
    tmp = []
    tmp = [int(i) for i in input().split()]
    if tmp[0] == 1:
        A.add(tmp[1])
    elif tmp[1] == N:
        B.add(tmp[0])

if len(A.intersection(B)) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Fixed submission:
N, M = map(int, input().split())

A = set({})
B = set({})
for j in range(M):
    tmp = []
    tmp = [int(i) for i in input().split()]
    if tmp[0] == 1:
        A.add(tmp[1])
    elif tmp[1] == N:
        B.add(tmp[0])

if len(A.intersection(B)) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
import math
N, M = input().split()
N = int(N)
M = int(M)


if abs(N - M) > 1:
    print(0)
elif N == M:
    res = math.factorial(N) * math.factorial(M) * 2
else:
    res = math.factorial(N) * math.factorial(M)

print(res % int(1e9 + 7))



Fixed submission:
import math
N, M = input().split()
N = int(N)
M = int(M)

if abs(N - M) > 1:
    print(0)
elif N == M:
    res = math.factorial(N) * math.factorial(M) * 2
    print(res % int(1e9 + 7))
else:
    res = math.factorial(N) * math.factorial(M)
    print(res % int(1e9 + 7))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

pair_cnt = S.count("()")
head_cnt = S.count("(") - pair_cnt
tail_cnt = S.count(")") - pair_cnt

res = S
res = tail_cnt * "(" + res
res = res + head_cnt * ")"

print(res)


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

a = indata[1]*10 + indata[2]*1
if a % 4 == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
S = np.array([int(input()) for i in range(N)])
S = S.reshape(N, 1)

mat = np.zeros([2**N, N])
for i in range(2**N):
    for j in range(N):
        if (N * "0" + format(i, "b"))[-N+j] == "1":
            mat[i,j] = 1
score = np.dot(mat, S)
flg = score % 10 != 0 

print(int(np.max(score * flg)))


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

ans = sum(S)
if ans % 10 == 0:
    d = [i for i in S if i % 10 != 0]
    if len(d):
        print(ans - min(d))
    else:
        print(0)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

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

if N%2 == 1:
      if A.count(0) != 1:
            print(0)
      elif sum(A) != (N+1)*(N-1)/2:
            print(0)
      else:
            print(int((2**((N-1)/2))%(10**9+7)))
      
else:
      if A.count(0) != 0:
            print(0)
      elif sum(A) != N**2/2:
            print(0)
      else:
            print(int((2**(N/2))%(10**9+7)))


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

if op == '+':
      result = a + b
else:
      result = a - b
print(result)
Buggy python submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = [int(j) for j in input().split()]

count = 0
for i in range(N-1):
      dif = a[i] + a[i+1] - x
      if dif > x:
            if a[i+1] >x:
                  count += dif
                  a[i+1] -= dif
            else:
                  count += dif
                  a[i] -= dif - a[i + 1]
                  a[i + 1] = 0
print(count)


Fixed submission:
a, x, c = input().split()
print("A"+x[0]+"C")

Buggy python submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = [int(j) for j in input().split()]
count = 0
for i in range(N-1):
      dif = a[i] + a[i+1] - x
      if dif > x:
            if a[i+1] >x:
                  count += dif
                  a[i+1] -= dif
            else:
                  count += dif
                  a[i] -= dif - a[i + 1]
                  a[i + 1] = 0
print(count)


Fixed submission:
a, x, c = input().split()
print("A"+x[0]+"C")

Buggy python submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = input().split()
count = 0
for i in range(len(a)):
      a[i] = int(a[i])
      if a[i] > x:
            count = count + a[i] - x
            a[i] = x
      else:
            a[i] = a[i]
for i in range(len(a)-1):  
      if i%2 == 0:
            if a[i] + a[i + 1] > x:
                  count = count + a[i] + a[i + 1] - x
                  a[i+1] = x - a[i]
      else:
            if a[i] + a[i + 1] > x:
                  count = count + a[i] + a[i + 1] - x
                  a[i] = x - a[i + 1]
print(count)


Fixed submission:
a, x, c = input().split()
print("A"+x[0]+"C")

Buggy python submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = input().split()
count = 0
for i in range(len(a)):
      a[i] = int(a[i])
      if a[i] > x:
            count = count + a[i] - x
            a[i] = x
      else:
            a[i] = a[i]
for i in range(len(a)-1):  
      if i%2 == 0:
            if a[i] + a[i + 1] > x:
                  count = count + a[i] + a[i + 1] - x
                  a[i+1] = x - a[i]
      else:
            if a[i] + a[i + 1] > x:
                  count = count + a[i] + a[i + 1] - x
                  a[i] = x - a[i + 1]
print(count)



Fixed submission:
a, x, c = input().split()
print("A"+x[0]+"C")
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = input().split()
a = int(a)
b = int(b)
x = int(x)
count = 0
for i in range(a,b+1):
      if i%x == 0:
            count = count + 1
      else:
            count = count
print(count)


Fixed submission:
a, b, x = map(int, input().split())
c = b//x
d = (a-1)//x
print(c - d)
Buggy python submission (verdict: Time Limit Exceeded):
input()
S=list(input())
ans=0

for i in range(1000):
    Si=0
    s=list(str(i).zfill(3))
    si=0
    while(Si<len(S)):
        if S[Si] == s[si]:
            si+=1
            if si > 2:
                ans+=1
                break
            Si += 1
            continue
        Si+=1
print(ans)

Fixed submission:
input()
S=list(input())
ans=0

def index(x,l):
    if x in l:
        return l.index(x)
    else:
        return -1

for i in range(1000):
    Si=0
    s=list(str(i).zfill(3))
    si=0
    if index(s[0],S) != -1:
        if index(s[1],S[S.index(s[0])+1:]) != -1:
            if index(s[2],S[S.index(s[0])+1:][S[S.index(s[0])+1:].index(s[1])+1:]) != -1:
                ans += 1
print(ans)