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

Fixed submission:
import collections
 
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=set()
cnt=collections.Counter(arr)
 
for i in range(n):
 if arr[i] in s:
   continue
 if cnt[arr[i]]>=2:
   s.add(arr[i])
 for j in range(2,10**6//arr[i]+1):
   s.add(arr[i]*j)
ans=0
for i in range(n):
 if arr[i] in s:
   continue
 ans+=1
 
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
 
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=set()
cnt=collections.Counter(arr)
 
for i in range(n):
 if arr[i] in s:
   continue
 if cnt[arr[i]]>=2:
   s.add(arr[i])
 for j in range(2,10**6//arr[i]+1):
   s.add(arr[i]*j)
ans=0
for i in range(n):
 if arr[i] in s:
   continue
 ans+=1
 
print(ans)
import collections

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=set()
cnt=collections.Counter(arr)

for i in range(n):
 if arr[i] in s:
   continue
 if cnt[arr[i]]>=2:
   s.add(arr[i])
 for j in range(2,10**6//arr[i]+1):
   s.add(arr[i]*j)
ans=0
for i in range(n):
 if arr[i] in s:
   continue
 ans+=1

print(ans)

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

n = int(input())
num_list = list(map(int, input().split()))

new_num_list = list(set(num_list))
new_num_list.sort()

if len(new_num_list) = 1:
  ans = 0
else:
  ans = 1

count = 0

for index_1, num_1 in enumerate(num_list):
  for index_2, num_2 in enumerate(num_list):
    if index_1 > index_2:
      if num_1 % num_2 != 0:
        count += 1
  
  if count == index_1:
    ans += 1

  count = 0

print(ans)
Problem p02830 (python)

Fixed submission:
N = int(input())
S, T  = input().split()
r = ''

for i in range(N):
    r += S[i] + T[i]

print(r)

Buggy submission (verdict: Runtime Error):
N = int(input())
S, T  = input().split()

for i in range(N):
    r += S[i] + T[i]
    
print(r)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
A, B, C, D = map(int, input().split())

ca = (A-1)//C 
cb = B//C

da = (A-1)//D
db = B//D

lcm = C * D //gcd(C,D)
cda = (A-1)//lcm
cdb = B//lcm

print(B-A+1-((cb-ca)+(db-da)-(cdb-cda)))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
A, B, C, D = map(int, input().split())

if A % C ==0:ca = A//C-1
else: ca = A//C
cb = B//C


if A % D ==0: ad = A//D-1
else:da = A//D 
db = B//D

lcm = C * D //gcd(C,D)
if A % lcm==0: cda = A//lcm-1
else:cda = A//lcm
cdb = B//lcm

print(B-A+1-((cb-ca)+(db-da)-(cdb-cda)))
Problem p03106 (python)

Fixed submission:
A, B, K = map(int, input().split())
 
cnt = 0
for i in range(1, min(A, B)+1)[::-1]:
  if (A % i == 0) and (B % i == 0):
    cnt += 1
  if cnt == K:
    print(i)
    exit(0)

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

cnt = 0
for i in range(min(A, B)):
  if (A % i == 0) & (B % i == 0):
    cnt += 1
  if cnt == K:
    print(cnt)
    exit(0)
Problem p03854 (python)

Fixed submission:
#ABC 049 C
S = input()
T = ''
S = S[::-1]
words = ["dream","dreamer","erase","eraser"]
rev_words = [w[::-1] for w in words]

flag = False
i=0
while(1):
	for w in rev_words:
		s = S[i:i+len(w)]
		if s == w:
			flag = True
			T += w
			i += len(w)
			break
	if T == S:
		ans = "YES"
		break
	if flag == False:
		ans = 'NO'
		break
	flag = False

print(ans)

Buggy submission (verdict: Runtime Error):
#ABC 049 C
S = input()
T = ''
S = S[::-1]
words = ["dream","dreamer","erase","eraser"]
rev_words = [w[::-1] for w in words]

i=0
while(1):
	for w in rev_words:
		s = S[i:i+len(w)]
		if s == w:
			flag = True
			T += w
			i += len(w)
			break
	if T == S:
		ans = "YES"
		break
	if flag == False:
		ans = 'NO'
		break
	flag = False
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = ''

S = S[::-1]
words = ["dream","dreamer","erase","eraser"]
rev_words = [w[::-1] for w in words]

i=0
while(1):
	for w in rev_words:
		s = S[i:i+len(w)]
		if s == w:
			flag = True
			T += w
			i += len(w)
			break
	if T == S:
		ans = "YES"
		break
	if flag == False:
		ans = 'NO'
		break
	flag = False

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
Temp = ''

def Tcmp(T, moji):
	T += moji
	
	if (S == T):
		return 1
	if len(T) > len(S):
		return 0
	
	if (moji == "dream"):
		return max(Tcmp(T,""),Tcmp(T,"er"))
	elif(moji == "eras"):
		return max(Tcmp(T,"e"),Tcmp(T,"er"))
	else:
		return max(Tcmp(T,"dream"),Tcmp(T,"eras"))

if(Tcmp(Temp,"")):
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
S = input()
T = ''

def Tcmp(T, moji):
	T += moji
	
	if (S == T):
		return 1
	if len(T) > len(S):
		return 0
	
	if (moji == "dream"):
		return max(Tcmp(T,""),Tcmp(T,"er"))
	elif(moji == "eras"):
		return max(Tcmp(T,"e"),Tcmp(T,"er"))
	else:
		return max(Tcmp(T,"dream"),Tcmp(T,"eras"))

if(Tcmp(T,"")):
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
S = input()
T = ''

def Tcmp(T, moji):
	
	T += moji
	
	if (S == T):
		return 1
	if len(T) > len(S):
		return 0
	
	if (moji == "dream"):
		return max(Tcmp(T,""),Tcmp(T,"er"))
	elif(moji == "eras"):
		return max(Tcmp(T,"e"),Tcmp(T,"er"))
	else:
		return max(Tcmp(T,"dream"),Tcmp(T,"eras"))

if(Tcmp(T,"")):
	print("YES")
else:
	print("NO")
Problem p02993 (python)

Fixed submission:
import re

s = input()

if re.findall(r"(.)\1+",s):
    print("Bad")
else:
    print("Good")

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


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    warikireru_c = b // c - (- (-a // c)) + 1
    warikireru_d = b // d - (-(-a // d)) + 1
    lcm_1 = lcm(c, d)
    warikireru_lcm = b // lcm_1 - (- (-a // lcm_1)) + 1
    num = b - a + 1
    print(num - (warikireru_c + warikireru_d - warikireru_lcm))

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


def lcm(x, y):
    return math.floor((x * y) / fractions.gcd(x, y))


if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    warikireru_c = math.floor(b / c) - math.ceil(a / c) + 1
    warikireru_d = math.floor(b / d) - math.ceil(a / d) + 1
    lcm_1 = lcm(c, d)
    warikireru_lcm = math.floor(b / lcm_1) - math.ceil(a / lcm_1) + 1
    num = b - a + 1
    print(num - (warikireru_c + warikireru_d - warikireru_lcm))

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


def lcm(x, y):
    return math.floor((x * y) / fractions.gcd(x, y))


if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    warikireru_c = math.floor(b / c) - math.ceil(a / c) + 1
    warikireru_d = math.floor(b / d) - math.ceil(a / d) + 1
    lcm_1 = lcm(c, d)
    warikireru_lcm = math.floor(b / lcm_1) - math.ceil(a / lcm_1) + 1
    num = b - a + 1
    print(num - (warikireru_c + warikireru_d - warikireru_lcm))
Problem p02995 (python)

Fixed submission:
import math
import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    warikireru_c = b // c - (- (-a // c)) + 1
    warikireru_d = b // d - (-(-a // d)) + 1
    lcm_1 = lcm(c, d)
    warikireru_lcm = b // lcm_1 - (- (-a // lcm_1)) + 1
    num = b - a + 1
    print(num - (warikireru_c + warikireru_d - warikireru_lcm))

Buggy submission (verdict: Runtime Error):
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    warikireru_c = math.floor(b / c) - math.ceil(a / c) + 1
    warikireru_d = math.floor(b / d) - math.ceil(a / d) + 1
    lcm_1 = lcm(c, d)
    warikireru_lcm = math.floor(b / lcm_1) - math.ceil(a / lcm_1) + 1
    num = b - a + 1
    print(num - (warikireru_c + warikireru_d - warikireru_lcm))

Buggy submission (verdict: Runtime Error):
import numpy as np
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    warikireru_c = math.floor(b / c) - math.ceil(a / c) + 1
    warikireru_d = math.floor(b / d) - math.ceil(a / d) + 1
    lcm = lcm(c, d)
    warikireru_lcm = math.floor(b / lcm) - math.ceil(a / lcm) + 1
    num = b - a + 1
    print(num - (warikireru_c + warikireru_d - warikireru_lcm))
Problem p02999 (python)

Fixed submission:
if __name__ == '__main__':
    x, a = map(int, input().split())
    if x < a:
        print(0)
    else:
        print(10)

Buggy submission (verdict: Runtime Error):
import numpy as np

k = 0


def calc(a):
    return np.sum(a) >= k


def main():
    global k
    n, k = map(int, input().split())
    a = np.array(list(map(int, input().split())))
    answer = 0
    list_pattern = []
    for i1 in range(n):
        for i2 in range(len(a)):
            list_pattern.append(a[i1:i2 + 1])

            # if a[i1:i2 + 1].sum() >= k:
            #     answer += 1
    list_answer = map(calc, list_pattern)
    print(sum(list_answer))


if __name__ == "__main__":
    main()
Problem p03029 (python)

Fixed submission:
import math
apple_one, apple_kakera = (int(i) for i in input().split())  
apple_kakera += apple_one * 3
print(math.floor(apple_kakera / 2) )

Buggy submission (verdict: Runtime Error):
    import math
    apple_one, apple_kakera = (int(i) for i in input().split())  
    apple_kakera += apple_one * 3
    print(math.floor(apple_kakera / 2) )
Problem p02772 (python)

Fixed submission:
lines = []
for i in range(2):
  inp = input()
  lines.append(inp)
searchList = []  
for i in range(int(lines[0])):
  split = lines[1].split()
  if int(split[i]) % 2 == 0:
    searchList.append(int(split[i]))
out = "APPROVED"
for s in searchList:
  if s % 3 != 0 and s % 5 != 0:
    out = "DENIED"
    print(out)
    break
if out == "APPROVED":
    print(out)

Buggy submission (verdict: Runtime Error):
for i in range(2):
  input = input()
  lines.append(int(input))
searchList = []  
for i in range(lines[0]):
  split = lines[1].split()
  if split[i] % 2 == 0:
    searchList.appned(split[i])
out = "APPROVED"
for s in searchList:
  if s % 3 != 0 and s % 5 != 0:
    out = "DENIED"
    print(out)
    break
print(out)
Problem p02812 (python)

Fixed submission:
num = input()
input = input()
result = 0
for i in range(len(input) - 2):
    serach = input[i:i+3]
    if serach == "ABC":
        result += 1
print(result)

Buggy submission (verdict: Runtime Error):
input = input()
result = 0
for i in range(len(input) - 2):
    serach = input[i:i+3]
    if serach == "ABC":
        result += 1
console.log(result)
Problem p02601 (python)

Fixed submission:
A,B,C=map(int,input().split())
K=int(input())
M=K
for i in range(K):
    if A>=B:
        B=B*2
        M=K-(i+1)
    if A<B:
        break
C=C*(2**M)
if C>B and A<B:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
K=int(input())
for i in range(K):
    if A>=B:
        B=B*2
        M=K-(i+1)
    if A<B:
        break
C=C*(2**M)
if C>B and A<B:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
K=int(input())
for i in range(K):
    if A>=B:
        B=B*2
        M=K-(i+1)
    if A<B:
        break
C=C*(2**M)
if C>B:
    print('Yes')
else:
    print('No')
Problem p02657 (python)

Fixed submission:
a,b = map(int, input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
a,b = map(input().split(), int)
print(a*b)
Problem p02732 (python)

Fixed submission:
from collections import Counter
import sys

sys.setrecursionlimit(10**6)

def fn(n):
    if n <= 1:
        return 0
    return n - 1 + fn(n-1)

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

c = Counter(A)
kumi = 0
for k, v in c.items():
    kumi += fn(v)

for ai in A:
    print(kumi - (c[ai] - 1))

Buggy submission (verdict: Runtime Error):
from collections import Counter

def fn(n):
    if n <= 1:
        return 0
    return n - 1 + fn(n-1)

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

c = Counter(A)
kumi = 0
for k, v in c.items():
    kumi += fn(v)

for ai in A:
    print(kumi - (c[ai] - 1))
Problem p02853 (python)

Fixed submission:
x, y = map(int, input().split())
ans = 0
if x <= 3:
    ans += 400000 - x * 100000
if y <= 3:
    ans += 400000 - y * 100000
if x == y == 1:
    ans += 400000
print(ans)

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
ans = 0
if x <= 3:
    ans += 400_000 - x * 100_000
if y <= 3:
    ans += 400_000 - y * 100_000
if x == y == 1:
    ans += 400_000
print(ans)
Problem p03076 (python)

Fixed submission:
t = [int(input()) for _  in range(5)]
total = 0
amari = []

for ti in t:
    d, m = divmod(ti, 10)
    total += ti - m
    if m > 0:
        amari.append(m)
if amari:
    total += min(amari) + 10 * (len(amari) - 1)
print(total)

Buggy submission (verdict: Runtime Error):
t = [int(input()) for _  in range(5)]
total = 0
amari = []

for ti in t:
    d, m = divmod(ti, 10)
    total += ti - m
    if m > 0:
        amari.append(m)
total += min(amari) + 10 * (len(amari) - 1)
print(total)
Problem p03338 (python)

Fixed submission:
n = int(input())
s = input()
ans = max(len(set(s[:i]) & set(s[i:])) for i in range(1, n))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = max(len(set(s[:i]) & set(s[i:])) for i in range(1, n - 1))
print(ans)
Problem p03612 (python)

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

cnt = 0
for i in range(n):
    if p[i] == i+1:
        if i+1 < n:
            p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
print(cnt)

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

cnt = 0
for i in range(n):
    if p[i] == i+1:
        if i < n:
            p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
print(cnt)
Problem p02683 (python)

Fixed submission:
from itertools import combinations

n,m,x = map(int,input().split())
cost_lists = [list(map(int,input().split())) for _ in range(n)]

# print(cost_lists)

min_cost = 10**9
unst_flag = False

for i in range(1, n+1):
    combi_lists = list(combinations(range(n), i))

    for combi_list in combi_lists:
        tmp_list = list()
        for j in range(1,m+1):
            tmp_unst = 0
            for k in combi_list:
                tmp_unst += cost_lists[k][j]

            tmp_list.append(tmp_unst)
        
        if min(tmp_list) >= x:
            tmp_cost = 0
            for k in combi_list:
                tmp_cost += cost_lists[k][0]

            min_cost = min(min_cost, tmp_cost)
            unst_flag = True

if unst_flag:
    print(min_cost)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from itertools import combinations

n,m,x = map(int,input().split())
cost_lists = [list(map(int,input().split())) for _ in range(n)]

# print(cost_lists)

min_cost = 10**9
unst_flag = False

for i in range(1, n+1):
    combi_lists = list(combinations(range(n), i))

    for combi_list in combi_lists:
        tmp_list = list()
        for j in range(1,m):
            tmp_unst = 0
            for k in combi_list:
                tmp_unst += cost_lists[k][j]

            tmp_list.append(tmp_unst)
        
        if min(tmp_list) >= x:
            tmp_cost = 0
            for k in combi_list:
                tmp_cost += cost_lists[k][0]

            min_cost = min(min_cost, tmp_cost)
            unst_flag = True

if unst_flag:
    print(min_cost)
else:
    print(-1)
Problem p02765 (python)

Fixed submission:
n,r = map(int,input().split())

if n<10:
    print(r+(100*(10-n)))
else:
    print(r)

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

count = 0
p = 10**9+7

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

range2_n1 = range(2, n+1)
range1_n1 = range(1, n+1)

for i in range2_n1:
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for m in range1_n1:
    if not (m == a or m == b):
        count += cmb(n,m,p)
        count %= p

print(count)
Problem p02780 (python)

Fixed submission:
def main():
    x,y = map(int,input().split())
    p = list(map(int,input().split()))

    number = sum(p[0:y])
    bigNumber = number

    for i in range(x-y):

        number = number - p[i] + p[i+y]

        if number > bigNumber:
            bigNumber = number

    print((bigNumber + y) / 2)

main()

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
p = list(map(int,input().split()))

bigNumber = 0

for i in range(x-y+1):
    if sum(p[i:i+y]) > bigNumber:
        bigNumber = number

print((bigNumber + y) / 2)
Problem p02818 (python)

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

if k>a:
    k = k-a
    a = 0

    if k>b:
        k = k-b
        b = 0
    else:
        b = b-k
else:
    a = a-k

print(a,b)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())

if k>a:
    k = k-a
    a = 0

    if k>b:
        k = k-b
        b = 0
    else:
        b = b-k
else:
    a = a-k

print(f"{a} {b}")
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
ret = ((a + b ) * h) / 2
print(int(ret))

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
h = input()
ret = ((a + b ) * h) / 2
print(ret)
Problem p04030 (python)

Fixed submission:
s = list(map(str, input()))
display = []
for action in s:
    if action == '0':
        display.append('0')
    elif action == '1':
        display.append('1')
    elif action == 'B':
        if len(display) > 0:
            display.pop()
print(''.join(display))

Buggy submission (verdict: Runtime Error):
s = list(map(str, input()))
display = []
for action in s:
    if action == '0':
        display.append('0')
    elif action == '1':
        display.append('1')
    elif action == 'B':
        display.pop()
print(''.join(display))
Problem p04029 (python)

Fixed submission:
N = int(input())
sum = 0

for i in range(N):
    sum += i+1

print(sum)

Buggy submission (verdict: Runtime Error):
N = input()
sum = 0

for i in range(N):
    sum += i**2
    
print(sum)
Problem p04031 (python)

Fixed submission:
N = int(input())
l = list(map(int,input().split()))
l_ans = [[] for _ in range(201)]

for i in range(-100,101):
    sum = 0

    for j in range(N):
        sum = sum + (i-l[j])**2

    l_ans[i+100] = sum

print(min(l_ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split()))
l_ans = [[] for _ in range(200)]

for i in range(-100,101):
    sum = 0

    for j in range(N):
        sum = sum + (i-l[j])**2

    l_ans[i+100] = sum

print(l_ans)
print(min(l_ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
l = list(map(int,input().split()))
l_ans = []

for i in range(1,101):
    sum = 0

    for j in range(N):
        sum = sum + (i-l[j])**2

    l_ans[i] = sum

print(min(l))
Problem p02684 (python)

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

a = [int(x)-1 for x in input().split()]

v = []
vc = [0]*n
b = 0
c = 0

while True:
    if vc[b]>0:
        stop = v.index(b)
        break
    v.append(b)
    vc[b] += 1
    b = a[b]
    c += 1



if k>stop:
    r = (k-stop)%(c-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)

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

a = [int(x)-1 for x in input().split()]

v = []
vc = [0]*n
b = 0
c = 0

while True:
    if vc[b]>0:
        stop = v.index(b)
        break
    v.append(b)
    vc[b] += 1
    b = a[b]
    c += 1



if k>c:
    r = (k-stop)%(c-stop)
    print(v[stop+r]+1)
else:
    print(v[k]+1)

Buggy submission (verdict: Runtime Error):

n, k = map(int, input().split())

a = [int(x)-1 for x in input().split()]

v = []
b = 0
stop = -1

for i in range(n):
    if b not in v:
        v.append(b)
        b = a[b]
    else:
        stop = v.index(b)
        break

v1 = v[:stop]
v2 = v[stop:]
c1 = len(v1)
c2 = len(v2)

if k>c1:
    r = (k-c1)%c2
else:
    r = k
    
print(v[stop+r]+1)
Problem p02732 (python)

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

c = [0]*n

for i in range(n):
    c[a[i]-1] = c[a[i]-1] + 1
    
total = 0
for x in c:
    total = total + x*(x-1)//2

for i in range(n):
    print(total - c[a[i]-1] + 1)

Buggy submission (verdict: Runtime Error):

n = int(input())
a = list(map(int, input().split()))

c = [0]*n

for i in range(n):
    c[a[i]] = c[a[i]] + 1
    
total = 0
for x in c:
    total = total + x*(x-1)//2

for i in range(n):
    print(total - c[a[i]] + 1)

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

d = [[0]*n for _ in range(n)]

for i in range(n):
    b = list(a)
    b[i] = 0
    for j in range(n):        
        d[i][b[j]] = d[i][b[j]]+1
    
for i in range(n):
    c = 0
    for j in range(n):
        c = c + d[i][j]*(d[i][j]-1)//2
    print(c)
Problem p02780 (python)

Fixed submission:

n, k = map(int, input().split())
p = list(map(int, input().split()))

e = [(i+1)/2 for i in p]

sume = [0 for _ in range(n)]
for i in range(n):
    if i == 0:
        sume[i] = e[i]
    else:
        sume[i] = sume[i-1]+e[i]

ans = []

if n == k:
    ans.append(sume[-1])
else:
    for i in range(n-k):
        ans.append(sume[i+k]-sume[i])

print("%.12f"%max(ans))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))

e = [(i+1)/2 for i in p]

sume = [0 for _ in range(n)]
for i in range(n):
    if i == 0:
        sume[i] = e[i]
    else:
        sume[i] = sume[i-1]+e[i]

ans = []
for i in range(n-k):
    ans.append(sume[i+k]-sume[i])    
    
print(max(ans))
Problem p02614 (python)

Fixed submission:
import itertools

import numpy as np


def _run(H, W, K, C):
    input = np.zeros([H, W], dtype=np.int8)
    for h in range(H):
        for w in range(W):
            if C[h][w] == "#":
                input[h, w] = 1

    count = 0
    for r in itertools.product(*[[0, 1] for _ in range(H + W)]):
        copy_input = input.copy()
        for h in range(H):
            if r[h] == 1:
                copy_input[h] = 0
        for w in range(W):
            if r[H + w] == 1:
                copy_input[:, w] = 0

        if np.sum(copy_input) == K:
            count += 1
    print(count)


def _main():
    H, W, K = map(int, input().split())
    C = [str(input()) for _ in range(H)]
    _run(H, W, K, C)


if __name__ == "__main__":
    _main()

Buggy submission (verdict: Runtime Error):
import itertools

import numpy as np


def _run(H, W, K, C):
    input = np.zeros([H, W], dtype=np.int8)
    for h in range(H):
        for w in range(W):
            if C[h][w] == "#":
                input[h, w] = 1

    count = 0
    for r in itertools.product(*[[0, 1] for _ in range(H + W)]):
        copy_input = input.copy()
        for h in range(H):
            if r[h] == 1:
                copy_input[h] = 0
        for w in range(W):
            if r[H + w] == 1:
                copy_input[:, w] = 0

        if np.sum(copy_input) == K:
            count += 1
    print(count)


def _main():
    H, W, K = map(int, input().split())
    C = []
    for _ in range(H):
        C.append(list(map(str, input().split())))
    _run(H, W, K, C)


if __name__ == "__main__":
    _main()

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np


def _run(H, W, K, C):
    input = np.zeros([H, W], dtype=np.int8)
    for h in range(H):
        for w in range(W):
            if C[h][w] == "#":
                input[h, w] = 1

    count = 0
    for r in itertools.product(*[[0, 1] for _ in range(H + W)]):
        copy_input = input.copy()
        for h in range(H):
            if r[h] == 1:
                copy_input[h] = 0
        for w in range(W):
            if r[H + w] == 1:
                copy_input[:, w] = 0

        if np.sum(copy_input) == K:
            count += 1
    print(count)


def _main():
    H, W, K = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(H)]
    _run(H, W, K, C)


if __name__ == "__main__":
    _main()