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

N = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()
Q = int(sys.stdin.readline().rstrip())
k = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

def counter(S, ki):
  count = 0
  for i in range(0, len(S)): 
    for j in range( i+2, len(S)):
      if j - i <=1 or j - i >= ki:
        continue
      for l in range(i+1, j):
        if (S[i], S[l], S[j]  ) == ('D', 'M', 'C'):
          count += 1
  return count
  
for ki in k:
  print(counter(S, ki))

Fixed submission:
import sys
N = int(sys.stdin.readline().rstrip())
a = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
d = [abs(sum(a)/float(N) - ai) for ai in a]

if len(set(d))==1:
  print(0)
else:
  print(d.index(min(d)))

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

N = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()
Q = int(sys.stdin.readline().rstrip())
k = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

def counter(S, ki):
  count = 0
    for i in range(0, len(S)): 
      for j in range( i+2, len(S)):
        if j - i <=1 or j - i >= ki:
          continue
        for l in range(i+1, j):
          if (S[i], S[l], S[j]  ) == ('D', 'M', 'C'):
            count += 1
  return count
  
for ki in k:
  print(counter(S, ki))

Fixed submission:
import sys
N = int(sys.stdin.readline().rstrip())
a = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
d = [abs(sum(a)/float(N) - ai) for ai in a]

if len(set(d))==1:
  print(0)
else:
  print(d.index(min(d)))

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

N = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()
Q = int(sys.stdin.readline().rstrip())
k = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

def counter(S, ki):
	count = 0
	for i in range(0, len(S)): 
	  for j in range( i+2, len(S)):
	  	if j - i <=1 or j - i >= ki:
	  		continue
	  	for l in range(i+1, j):
	  		if (S[i], S[l], S[j]  ) == ('D', 'M', 'C'):
	  			count += 1
	return count
  
for ki in k:
	print(counter(S, ki))

Fixed submission:
import sys
N = int(sys.stdin.readline().rstrip())
a = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
d = [abs(sum(a)/float(N) - ai) for ai in a]

if len(set(d))==1:
  print(0)
else:
  print(d.index(min(d)))

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

N = int(sys.stdin.readline().rstrip())
S = sys.stdin.readline().rstrip()
Q = int(sys.stdin.readline().rstrip())
k = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]

def counter(S, ki):
	count = 0
	for i in range(0, len(S)): 
	  for j in range( i+2, len(S)):
	  	if j - i <=1 or j - i >= ki:
	  		continue
	  	for l in range(i+1, j):
	  		if (S[i], S[l], S[j]  ) == ('D', 'M', 'C'):
	  			count += 1
	return count
  
for ki in k:
	print(counter(S, ki))

Fixed submission:
import sys
N = int(sys.stdin.readline().rstrip())
a = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
d = [abs(sum(a)/float(N) - ai) for ai in a]

if len(set(d))==1:
  print(0)
else:
  print(d.index(min(d)))

Buggy python submission (verdict: Runtime Error):
import sys
N = int(sys.stdin.read().rstrip())
a = [int(x) in x for stdin.readline().rstrip().split(' ')]
d = [abs(sum(a)/float(N) - ai) for ai in a]

if len(set(d))==1:
	print(0)
else:
	 print(d.index(min(d)))

Fixed submission:
import sys
N = int(sys.stdin.readline().rstrip())
a = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
d = [abs(sum(a)/float(N) - ai) for ai in a]

if len(set(d))==1:
  print(0)
else:
  print(d.index(min(d)))

Buggy python submission (verdict: Runtime Error):
N = int(sys.stdin.read().rstrip())
a = [int(x) in x for stdin.readline().rstrip().split(' ')]
d = [abs(sum(a)/float(N) - ai) for ai in a]

if len(set(d))==1:
	print(0)
else:
	 print(d.index(min(d)))

Fixed submission:
import sys
N = int(sys.stdin.readline().rstrip())
a = [int(x) for x in sys.stdin.readline().rstrip().split(' ')]
d = [abs(sum(a)/float(N) - ai) for ai in a]

if len(set(d))==1:
  print(0)
else:
  print(d.index(min(d)))