Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02801 (python)

Fixed submission:
c=input()
r = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
print(r[r.index(c)+1])

Buggy submission (verdict: Runtime Error):
c=input().split(" ")
r = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
print(r[r.index(c)+1])
Problem p02621 (python)

Fixed submission:
a=int(input())
print(a+a*a+a*a*a)

Buggy submission (verdict: Runtime Error):
a=int(input())
print(a+a**+a***)
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
  print(0)
  exit()
for i in range(N):
  ans *= A[i]
  if ans > 10**18:
    print(-1)
    exit()
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 1
if A in 0:
  print(0)
  exit()
for i in range(N):
  ans *= A[i]
  if ans > 10**18:
    print(-1)
    exit()
print(ans)
Problem p02675 (python)

Fixed submission:
N = input()
N = N[len(N)-1]
if N == "3":
  print("bon")
elif N == "0" or N == "1" or N == "6" or N == "8":
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
N = input()
N = N[2]
if N = "3":
  print("bon")
elif N = "0" or N = "1" or N = "6" or N = "8":
  print("pon")
else:
  print("hon")
Problem p02765 (python)

Fixed submission:
N,R = map(int, input().split())
if N > 9:
    print(R)
else:
    print(R+100*(10-N))

Buggy submission (verdict: Runtime Error):
N,R = map(int, input().split())
if N >9:
    print(R)
else:
    print(R+100*(10-K))
Problem p02780 (python)

Fixed submission:
N,K = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x:(x+1)/2, p))
temp = []
p_sum=0
for i in range(N):
    p_sum+=p[i]
    temp.append(p_sum)
ans = []
for j in range(K,N):
    ans.append(temp[j]-temp[j-K])
if len(ans) != 0:
    print(max(ans))
else:
    print(p_sum)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x:(x+1)/2, p))
temp = []
p_sum=0
for i in range(N):
    p_sum+=p[i]
    temp.append(p_sum)
ans = []
for j in range(K,N):
    ans.append(temp[j]-temp[j-K])
print(max(ans))
Problem p02898 (python)

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
for i in h:
    if i >= K:
        ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input(),split())
h = list(map(int, input().split()))
ans = 0
for i in h:
    if i>K:
        ans +=1
print(ans)
Problem p02899 (python)

Fixed submission:
N =int(input())
dic = {}
j=1
for i in map(int, input().split()):
    dic[i]=j
    j+=1
for n in range(1, N+1):
    print(dic.get(n))

Buggy submission (verdict: Runtime Error):
N =int(input())
dic = {}
j=1
for i in map(int, input().split()):
    dic[i]=j
    j+=1
for n in range(N):
    print(dic[n])
Problem p02909 (python)

Fixed submission:
S=input()
if S == "Sunny":
	print("Cloudy")
elif S == "Cloudy":
	print("Rainy")
else:
	print("Sunny")

Buggy submission (verdict: Runtime Error):
S=input()
if S == Sunny:
  print(Cloudy)
  elif S == Cloudy:
    print(Rainy)
    else
    	print(Sunny)
Problem p02910 (python)

Fixed submission:
S = list(input())
if False not in [i not in "L" for i in S[::2]] and False not in [i not in "R"for i in S[1::2]]:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
S = input()
slen = len(S)
i = int(0)
j = int(0)
while slen >= i:
	if i%2 == 1 and S[i] == "R","U","D":
		j = 0
	elif i%2 == 0 and S[i] == "L","U","D":
		j = 0
	else:
		j += 1
  i+1
if j == 0:
	print("No")
else:
	print("Yes")
Problem p02911 (python)

Fixed submission:
N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
 A.append(int(input()))
P = []
P = [0] * N
i = 0
while Q>i:
    P[A[i]-1] += 1
    i += 1
for j in P:
    if (K - Q + j) > 0:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
 A.append(int(input()))
P = []
P = [0] * (N-1)
i = 0
while Q>i:
    P[A[i]-1] += 1
    i += 1
for j in P:
    if (K - Q + j) > 0:
        print("Yes")
    else:
        print("No")
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
ans = 0
for i, j in zip(S, T):
    if i == j:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
ans = 0
for i in S and j in T:
    if i == j:
        ans += 1
print(ans)
Problem p02923 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = 0
i = 0
for n in range(N-1):
    if H[n] >= H[n+1]:
        i += 1
    else:
        if ans < i:
            ans = i
        i=0
print(max(ans,i))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans,i = 0
for n in range(N):
    if H[n] >= H[n+1]:
        i += 1
    else:
        if ans < i:
            ans = i
        i=0
print(max(ans,i))
Problem p02934 (python)

Fixed submission:
N = float(input())
A = list(map(float, input().split()))
j = float(0)
ans = float(0)
for i in A:
    j += 1/i
ans = 1/j
print(ans)

Buggy submission (verdict: Runtime Error):
N = float(input())
A = list(map(float, input().split()))
j = float(0)
ans = float(0)
for i in A:
    J += 1/i
ans = 1/j
print(ans)
Problem p02946 (python)

Fixed submission:
K, X = map(int, input().split())
a=X-K+1
b=X+K
for i in range(a,b):
    print(i)

Buggy submission (verdict: Runtime Error):
K, X = map(int, input().split())
print(range(x-k,x+k))
Problem p02952 (python)

Fixed submission:
N = int(input())
if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(N-90)
elif N < 10000:
    print(909)
elif N < 100000:
    print(N - 9090)
else:
    print(90909)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N<10:
    print(N)
elif N<100:
    prnt(9)
elif N<1000:
    print(N-90)
else:
    print(90909)
Problem p02953 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(N-1)):
    if H[i]>H[i+1]:
        H[i] -= 1
        if H[i]>H[i+1]:
            print("No")
            exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
for i in range(N,-1,-1):
    if H[i]>H[i-1]:
        H[i] -= 1
        if H[i]>H[i-1]:
            print("No")
            break
print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
for i in range(N,-1,-1):
    if H[i]>H[i-1]:
        H[i] -= 1
        if H[i]>H[i-1]:
            print("No")
            break()
print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i,j,k in zip(H,H[1::],H[2::]):
    if i == j:
        if j > k:
            ans *= 0
        else:
            break
    else i > j+1:
        ans *= 0
print("Yes" if ans == 1 else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i,j,k in zip(H,H[1::],H[2::]):
    if i == j:
        if j > k:
            ans *= 0
    else i > j+1:
        ans *= 0
print("Yes" if ans == 1 else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i in range(N):
    if H[i] == H[i+1] or (H[i+1]-1):
        ans *= 1
    else:
        ans *= 0
print("Yes" if ans == 1 else "No")
Problem p02971 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
if N == 2:
    for j in A[::-1]:
        print(j)
else:
    tmp = sorted(A)
    del tmp[0:(N-2)]
    for i in range(N):
        if A[i] == tmp[1]:
            print(tmp[0])
        else:
            print(tmp[1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [input() for _ in range(N)]
for i in range(N):
    if max(A) == A[i]:
        A.remove(A[i])
        print(max(A))
        A.insert(i,A[i])
    else:
        print(max(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [input() for _ in range(N)]
for j in range(N):
    if max(A) == A[i]:
        A.remove(A[i])
        print(max(A))
        A.insert(i,A[i])
    else:
        print(max(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
tmp = 0
for _ in range(N):
    A.append(int(input()))
    for j in range(N):
        tmp = A.pop(j)
        print(max(A))
        A.insert(j,tmp)
Problem p02982 (python)

Fixed submission:
N ,D = map(int, input().split())
X = []
tmp = []
ans = []
fans = 0
for _ in range(N):
    X.append(list(map(int, input().split())))
for i in range(N-1):
    for j in range(i+1, N):
        if D == 1:
            tmp.append((X[i][0]-X[j][0])**2)
        else:
            for k in range(D):
                tmp.append((X[i][k]-X[j][k])**2)
        ans.append(sum(tmp)**0.5)
        tmp = []
for A in ans:
    if A.is_integer():
        fans += 1
print(fans)

Buggy submission (verdict: Runtime Error):
N ,D = map(int, input().split())
X = []
tmp = []
ans = []
fans = 0
for _ in range(N):
    X.append(list(map(int, input().split())))
for i in range(N):
    for j in range(D):
        tmp.append((X[i-1][j]-X[i][j])**2)
    ans.append((tmp[0] + tmp[1])**0.5)
    tmp = []
for A in ans:
    if A.is_integer():
        fans += 1
print(fans)

Buggy submission (verdict: Runtime Error):
N ,D = map(int, input().split())
X = []
tmp = []
ans = []
for _ in range(N):
    X.append(list(map(int, input().split())))
for i in range(N):
    for j in range(D):
        tmp.append((X[i-1][j]-X[i][j])**2)
    ans.append(tmp[0] + tmp[1])
print(ans)
Problem p02994 (python)

Fixed submission:
N, L = map(int, input().split())
tmp = 0
i = L
for _ in range(N):
    tmp += i
    i += 1
if tmp == 0:
    print(0)
elif tmp > 0:
    if L < 1:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N+L == 0:
        print(tmp+1)
    elif N + L > 0:
        print(tmp)
    else:
        print(tmp - N - L + 1)

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
tmp = 0
for _ in range(N):
    tmp += L
    L += 1
if tmp == 0:
    print(0)
elif tmp > 0:
    if L=< 0:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N > L:
        print(tmp)
    else:
        print(tmp-(N+L-1))

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
for _ in range(N):
    tmp += L
    L += 1
if tmp == 0:
    print(0)
elif tmp > 0:
    if L=< 0:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N > L:
        print(tmp)
    else:
        print(tmp-(N+L-1))
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(float, input().split())
half_s = W*H/2
tmp = 0
if x == W/2 and y == H/2:
    tmp = 1
print(half_s,tmp)

Buggy submission (verdict: Runtime Error):
import math
W, H, x, y = map(int, input().split())
half_s = W*H/2
tmp = (x-y)**2**0.5
print(half_s,math.floor(tmp-1))
Problem p03029 (python)

Fixed submission:
#1107
import math
A, P = map(int, input().split())
print(math.floor((A*3+P)/2))

Buggy submission (verdict: Runtime Error):
from numpy import*
n, m = map(int, input().split())
l = []
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())
ans = 0
for t in range(2**n):
    for s in range(n):
        tmp = array([t >> s & 1])
    for i in l:
        if p == sum(tmp[array(i)-1])%2:
            ans += 1
print(ans)
Problem p03031 (python)

Fixed submission:
from numpy import*
n, m = map(int, input().split())
l = []
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())
ans = 0
for t in range(2**n):
    tmp=array([t>>s&1 for s in range(n)])
    if p==[sum(tmp[array(i)-1])%2for i in l]:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from numpy import*
n, m = map(int, input().split())
l = []
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())
ans = 0
for t in range(2**n):
    for s in range(n):
        tmp = array([t >> s & 1])
    for i in l:
        if p == sum(tmp[array(i)-1])%2:
            ans += 1
print(ans)
Problem p03035 (python)

Fixed submission:
#1226
import math
A, B = map(int, input().split())
print(math.floor(B if A > 12 else B/2 if A > 5 else 0))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = 0
R = 0
for _ in range(M):
    inp = input().split()
    l = int(inp[0])
    r = int(inp[1])
    L = max(L,l)
    R = min(R,r)
print(max(0,min(R,N) + 1 - L))

Buggy submission (verdict: Runtime Error):
#1226
A, B = map(int, input().split())
print(B if A > 12 else B/2 if A > 5 0)
Problem p03037 (python)

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
ans = 0
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
L_max = max(L)
R_min = min(R)
for i in range(L_max,min(R_min,N) + 1):
    ans  += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = []
R = []
ans = 0
for _ in range(M):
    inp = int(input().split())
    L.append(inp[0])
    R.append(inp[1])
for i in range(N):
    if L[i] < i + 1 <R[i]:
        ans += 1
print(ans)
Problem p03061 (python)

Fixed submission:
import fractions
from functools import reduce
def gcd(*i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    L=[0]
    R=[0]
    for i in range(N):
        L.append(gcd(L[i],A[i]))
        R.append(gcd(R[i],A[-(i+1)]))
    R=R[::-1]
    ans=[]
    for i in range(N):
        ans.append(gcd(L[i],R[i+1]))
    print(max(ans))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
def gcd(*i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    L=[0]
    R=[0]
    for i in range(N):
        L.append(gcd(L[i],A[i]))
        R.append(gcd(R[i],A[-(i+1)]))
    R=R[::-1]
    ans=[]
    for i in range(n):
        ans.append(gcd(L[i],R[i+1]))
    print(max(ans))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
def gcd(i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    tmp = 0
    if gcd(A) == max(A):
        print(gcd(A))
        exit()
    else:
        for i in range(N):
            if i == 0 :
                tmp.append(gcd(A[1:]))
            elif i == N-1:
                tmp.append(gcd(A[:N-1]))
            else:
                tmp.append(gcd(A[:i]+A[i+1:]))
    print(max(tmp))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
def gcd(i):
    return reduce(fractions.gcd, i)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    tmp = 0
    if gcd(A) == max(A):
        print(gcd(A))
        exit()
    else:
        for i in range(N):
            if i == 0 :
                tmp=max(tmp,gcd(A[1:]))
            elif i == N-1:
                tmp=max(tmp,gcd(A[:N-1]))
            else:
                tmp=max(tmp,gcd(A[:i]+A[i+1:]))
    print(tmp)
 if __name__ == "__main__":
     main()
Problem p03071 (python)

Fixed submission:
A, B = map(int, input().split())
if abs(A-B) > 1:
    tmp = max(A,B)
    print(tmp*2-1)
else:
    print(A + B)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
tmp = 0
if abs(A-B) > 1:
    tmp = max(A,B)
    print(tmp*2-1)
else abs(A-B) == 1:
    print(A + B)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
if abs(A-B) > 1:
    tmp = max(A,B)
    print(tmp*2-1)
else abs(A-B) == 1:
    print(A + B)
Problem p03076 (python)

Fixed submission:
inp = []
tmp = 10
ans = 0
temp = 0
for _ in range(5):
    inp.append(input())
for i in range(5):
    if tmp > int(inp[i][-1]) and int(inp[i][-1]) != 0:
        tmp = int(inp[i][-1])
        temp = i
last = inp.pop(temp)
for j in inp:
    if j[-1] == "0":
        ans += int(j)
    else:
        ans += int(j[:-1]+ "0") + 10
ans += int(last)
print(ans)

Buggy submission (verdict: Runtime Error):
inp = []
tmp = 10
ans = 0
for _ in range(5):
    inp.append(input())
for i in range(5):
    if tmp > int(inp[i][-1]) and int(inp[i][-1]) != 0:
        tmp = int(inp[i][-1])
        temp = i
last = inp.pop(temp)
for j in inp:
    if j[-1] == "0":
        ans += int(j)
    else:
        ans += int(j[:-1]+ "0") + 10
ans += int(last)
print(ans)

Buggy submission (verdict: Runtime Error):
inp = []
tmp = 9
ans = 0
for _ in range(5):
    inp.append(input())
for i in range(5):
    if tmp > int(inp[i][-1]) and int(inp[i][-1]) != 0:
        tmp = int(inp[i][-1])
        temp = i
last = inp.pop(temp)
for j in inp:
    if j[-1] == "0":
        ans += int(j)
    else:
        ans += int(j[:-1]+ "0") + 10
ans += int(last)
print(ans)

Buggy submission (verdict: Runtime Error):
inp = []
tmp = 9
ans = 0
for _ in range(5):
    inp.append(input())
for i in range(5):
    if tmp > int(inp[i][-1]) and int(inp[i][-1]) != 0:
        tmp = int(inp[i][-1])
        temp = i
last = inp.pop(temp)
for j in inp:
    if j[-1] == "0":
        ans += int(j)
    else:
        ans += int(j[:-1]+ "0") + 10
ans += int(last)
print(ans)

Buggy submission (verdict: Runtime Error):
inp = []
tmp = 9
ans = 0
for _ in range(5):
    inp.append(input())
for i in range(5):
    if tmp > int(inp[i][-1]) and int(inp[i][-1]) != 0:
        tmp = int(inp[i][-1])
        temp = i

last = inp.pop(temp)
print(last)
for j in inp:
    print(ans)
    if j[-1] == "0":
        ans += int(j)
    else:
        ans += int(j[:-1]+ "0") + 10
ans += int(last)
print(ans)
Problem p03086 (python)

Fixed submission:
S = input()
ans = 0
acgt = ["A","C","G","T"]
for i in range(len(S)):
    tmp = 0
    if S[i] in acgt:
        tmp += 1
        for j in range(i+1,len(S)):
            if S[j] in acgt:
                tmp += 1
                continue
            else:
                ans = max(ans,tmp)
                break
        ans = max(ans,tmp)
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
for i in range(len(S)):
    if S[i] == "A" or "C" or "G" or "T":
        for j in range(i+1,len(S)):
            if S[j] == "A" or "C" or "G" or "T":
                continue
            else:
                tmp = j-i
                break
print(tmp)
Problem p03106 (python)

Fixed submission:
A, B, K =map(int, input().split())
tmp = []
try:
    for i in range(2,min(A,B)+1):
        if A%i == 0 and B%i == 0:
            tmp.append(i)
    tmp.sort(reverse=True)
    print(tmp[K-1])
except:
    print(1)

Buggy submission (verdict: Runtime Error):
A, B, K =map(int, input().split())
tmp = []
for i in range(2,min(A,B)+1):
    if A%i == 0 and B%i == 0:
        tmp.append(i)
tmp.sort(reverse=True)
print(tmp[K-1])

Buggy submission (verdict: Runtime Error):
A, B, K =map(int, input().split())
tmp = []
for i in range(2,min(A,B)+1):
    if A%i == 0 and B%i == 0:
        emp.append(i)
tmp.sort(reverse=True)
print(tmp[K-1])
Problem p03214 (python)

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 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))

Buggy 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))

Buggy 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))

Buggy 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))

Buggy 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)))

Buggy 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)))
Problem p02612 (python)

Fixed submission:
a = int(input())
if a == 1000:
    b = 1
elif a %1000 == 0:
    b = a//1000
else:
    b = a//1000 + 1
print(b*1000 - a)

Buggy submission (verdict: Runtime Error):
a = int(input())
if a =< 1000:
    b = a//1000
else:
    b = a//1000 + 1
print(b*1000 - a)
Problem p02641 (python)

Fixed submission:
# coding: utf-8
# Your code here!
x,n = map(int, input().split())
if n > 0:
    p = list(map(int , input().split()))
else:
    p  = []
a = list(set(list(range(-100,102))) - set(p))
values = []
for i in a:
    values = values +  [[abs(x-i), i]]
values.sort(key=lambda x: x[0])
mins = values[0][0]
b = []
for i in values:
    if i[0] > mins:
        break
    b += [i[1]]
b.sort()
print(b[0])

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
x,n = map(int, input().split())
if n > 0:
    p = list(map(int , input().split()))
else:
    p  = []
a = list(set(list(range(1,101))) - set(p))
values = []
for i in a:
    values = values +  [[abs(x-i), i]]
values.sort(key=lambda x: x[0])
mins = values[0][0]
b = []
for i in values:
    if i[0] > mins:
        break
    b += [i[1]]
b.sort()
print(b[0])
Problem p02645 (python)

Fixed submission:
s = input()
print(s[:3])

Buggy submission (verdict: Runtime Error):
a = int(input())
v = int(input())
b = int(input())
w = int(input())
t = int(input())
a += t * v;
b += t * w;
if (a < b):
  print("NO")
else:
  print("YES")
Problem p02730 (python)

Fixed submission:
def k(string): return True if string==string[::-1] else False
s = input()
n = len(s)
if k(s) and k(s[:int((n-1)/2)]) and k(s[int((n+3)/2)-1:]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def ispalindrome(s):
    h = len(s) / 2
    for a, b in zip(s[:h], reversed(s[h+1:])):
        if a != b: return False
    return True
s = input()
n = len(s)
if ispalindrome(s) and ispalindrome(s[0:int((n+1)/2)-1]) and ispalindrome(s[int((n+3)/2)-1:n-1]):
    print("Yes")
else:
    print("No")
Problem p02731 (python)

Fixed submission:
print(((int(input()))/3)**3)

Buggy submission (verdict: Runtime Error):
print(((input())/3)**3)