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

Fixed submission:
H, W, A, B = map(int, input().split())


for i in range(B):
    answer = ['0' if j < A else '1' for j in range(W)]
    print(''.join(answer))
for i in range(H-B):
    answer = ['1' if j < A else '0' for j in range(W)]
    print(''.join(answer))

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

if A == 0 or B == 0:
    pass
else H % B != 0 or W % A != 0 or H // B * A != W:
    print('No')
    exit()

answer = [[-1] * W for _ in range(H)]
a = 0
b = 0
for i in range(H):    
    answer[i] = [0 if a <= j <= a + A -1 else 1 for j in range(W)]
    if b + i - 1== B:
        a += A
        b += B
for i in range(H):
    print(*answer[i])

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

if A == 0 or B == 0:
    pass
else H % B != 0 or W % A != 0 or H // B * A != W // A * B:
    print('No')
    exit()

answer = [[-1] * W for _ in range(H)]
a = 0
b = 0
for i in range(H):    
    answer[i] = [0 if a <= j <= a + A -1 else 1 for j in range(W)]
    a += A
for i in range(H):
    print(*answer[i])
Problem p02918 (python)

Fixed submission:
N, K = map(int, input().split())
import numpy as np
S = np.array(list(input()))
count = 0
if len(S) >= 2:
    if S[0] == 'R' and S[1] == 'R':
        count += 1
    if S[-1] == 'L' and S[-2] == 'L':
        count += 1
for i in range(1, N-1):
    if S[i] == 'R' and S[i+1] == 'R':
        count += 1
    if S[i] == 'L' and S[i-1] == 'L':
        count += 1
count += K * 2
print(min(count, N-1))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
import numpy as np
S = np.array(list(input()))
count = 0
if S[0] == 'R' and S[1] == 'R':
    count += 1
if S[-1] == 'L' and S[-2] == 'L':
    count += 1
for i in range(1, N-1):
    if S[i] == 'R' and S[i+1] == 'R':
        count += 1
    if S[i] == 'L' and S[i-1] == 'L':
        count += 1
count += K * 2
print(min(count, N-1))
Problem p02923 (python)

Fixed submission:
import numpy as np


N = int(input())
H = np.array(list(map(int, input().split())))

answer = 0

L1 = (H[:-1] >= H[1:])
#print(L1)

answer = 0
count = 0
for l in L1:
    if l:
        count += 1
    else:
        answer = max(answer, count)
        count = 0

print(max(answer, count))

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


N = int(input())
H = np.array(list(map(int, input().split())))

answer = 0

L1 = (H[:-1] >= H[1:])
#print(L1)

for i in range(N-1):
    count = 0
    for j in range(i, N-1):
        if L1[j]:
            count += 1
        else:
            break
    else:
        answer = max(count, answer)

print(answer)

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


N = int(input())
H = np.array(list(map(int, input().split())))

answer = 0

L1 = (H[:-1] >= H[1:])
#print(L1)

for i in range(N-1):
    count = 0
    for j in range(i, N-1):
        if L1[j]:
            count += 1
        else:
            break
    else:
        answer = max(count, answer)

print(answer)

Buggy submission (verdict: Runtime Error):
4
1 2 3 4
Problem p02937 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict
from bisect import bisect_left

S = input().rstrip()
T = input().rstrip()

LS = len(S)

index = defaultdict(list)

for i,s in enumerate(S):
    index[s].append(i)

x = -1
for t in T:
    arr = index[t]
    if len(arr) == 0:
        x = -2
        break
    y = (x+1) % LS
    i = bisect_left(arr,y)
    if i < len(arr):
        next_x = (x+1) + arr[i] - y
    else:
        next_x = (x+1) + arr[0] - y + LS
    x = next_x

print(x + 1)

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict
import bisect
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = sr()
T = sr()
len_S = len(S)
indexes_S = defaultdict(list)
for i, s in enumerate(S):
    indexes_S[s].append(i)

x = -1 # 今いるところ、次はx+1から探索
for t in T:
    if indexes_S[t] == 0:
        print(-1); exit()
    arr = indexes_S[t]
    y = (x+1) % len_S
    next_i = bisect.bisect_left(arr, y) # tの同じ文字がある次のindex
    if next_i < len(arr):
        x = (x+1) + arr[next_i] - y
    else:
        x = (x+1) + arr[0] + len_S - y # 1周して次のarr

print(x+1)
Problem p02947 (python)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

count = 0
dic1 = {}
#print(s)
for i in range(n):
    #print(s[i])
    so = sorted(s[i])
    so = ''.join(so)
    if so in dic1:
        count += dic1[so]
        dic1[so] += 1
    else:
        dic1[so] = 1
    #print(count, dic1)
print(count)

Buggy submission (verdict: Runtime Error):
from math import factorial


n = int(input())
a = [sorted(input()) for i in range(n)]

l = []
count = 0
for i in range(n):
    if a[i] not in l:
        m = a.count(a[i])
        if m > 1:
            count += factorial(m) / 2 / factorial(m - 2)
        l.append(a[i])
    else:
        continue
print(int(count))

Buggy submission (verdict: Runtime Error):
from math import factorial


n = int(input())
a = [sorted(input()) for i in range(n)]

l = []
count = 0
for i in range(n):
    if a[i] not in l:
        m = a.count(a[i])
        if m > 1:
            count += factorial(m) / 2 / factorial(m - 2)
        l.append(a[i])
    else:
        pass
print(int(count))

Buggy submission (verdict: Runtime Error):
from math import factorial
n = int(input())
s = [input() for i in range(n)]

count = 0
list1 = []
for i in range(n):
    dic1 = {}
    for k in range(10):
        
        if s[i][k] not in dic1:
            dic1[s[i][k]] = s[i].count(s[i][k])
    list1.append(dic1)
list2 = []
for i in range(n):
    if list1[i] not in list2:
        j = list1.count(list1[i])
        if j >= 2:

            a = factorial(j) / factorial(2) / factorial(j - 2)
            count += a
        list2.append(list1[i])
print(int(count))
Problem p02949 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, P = lr()
graph = [lr() for _ in range(M)]


def bellmanford(s, g):
    dist = [float("inf")] * (N+1)
    dist[s] = 0
    for i in range(2 * N):
        for a, b, c in graph:
            cost = -(c - P)
            if dist[b] > dist[a] + cost:
                dist[b] = dist[a] + cost
                if i >= N:
                    dist[b] = -float("inf")
 
    if dist[g] == -float("inf"):
        return -1
    else:
        return max(-dist[g], 0)

answer = bellmanford(1, N)
print(answer)
#

Buggy submission (verdict: Runtime Error):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, P = lr()
# 終了時、T*P枚支払う
graph = [tuplr(lr()) for _ in range(M)]

def bellmanford(start, N):
    INF = 10 ** 12
    dist = [-INF] * (N+1) # 1-indexed
    dist[start] = 0
    for i in range(N+N+5):
        for pre, ne, weight in graph:
            if dist[pre] != -INF and dist[pre] + weight - P > dist[ne]:
                dist[ne] = dist[pre] + weight - P
                # n回繰り返してもスコアが更新された場合
                if i > N-1:
                    dist[ne] = INF
    if dist[N] == INF:
        return -1
    else:
        return max(0, dist[N])

answer = bellmanford(1, N)
print(answer)
Problem p02960 (python)

Fixed submission:
MOD = 10 ** 9 + 7
S = input()

dp = [0] * 13
dp[0] = 1

for s in S:
  prev = [x for x in dp]
  dp = [0] * 13
  if s == '?':
    add = range(10)
  else:
    add = [int(s)]
  for i in range(13):
    for x in add:
      dp[(10*i+x)%13] += prev[i]
  dp = [x % MOD for x in dp]
  
print(dp[5])

Buggy submission (verdict: Runtime Error):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
S = sr()
# 桁DP, 上から
dp = [0] * 13
dp[0] = 1
for i in range(len(S)):
    prev = dp.copy()
    num = S[i]
    dp = [0] * 13
    if num != '?':
        num = int(num)
        for j in range(13):
            dp[(10*j+num)%13] = prev[j]
    else:
        for j in range(13):
            for k in range(10):
                dp[(10*j+k)%13] += prev[j]
            dp[j] %= MOD

answer = dp[5]
print(answer%MOD)

Buggy submission (verdict: Runtime Error):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
S = sr()
# 桁DP, 上から
dp = [0] * 13
dp[0] = 1
for i in range(len(S)):
    prev = dp.copy()
    num = S[i]
    dp = [0] * 13
    if num.isdigit():
        num = int(num)
        for j in range(13):
            dp[(10*j+num)%13] = prev[j]
    else:
        for j in range(13):
            for k in range(10):
                dp[(10*j+k)%13] += prev[j]
            dp[j] %= MOD

answer = dp[5]
print(answer%MOD)

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

S = input()
MOD = 10 ** 9 + 7

dp = [0] * 13
dp[0] = 1

for s in S:
    prev = [x for x in dp]
    dp = [0] * 13
    if s == '?':
        add = range(10)
    else:
        add = [int(s)]
    for i in range(13):
        for a in add:
            dp[(10*i+a)%13] += prev[i]
    dp = [x%MOD for x in dp]
print(dp[5])

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

S = input()
MOD = 10 ** 9 + 7

dp = [0] * 13
dp[0] = 1

for s in S:
    prev = [x for x in dp]
    dp = [0] * 13
    if s == '?':
        add = range(10)
    else:
        add = [int(s)]
    for i in range(13):
        for a in add:
            dp[(10*i+a)%13] += prev[i]
        dp[i] %= MOD
print(dp[5])

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

S = input()
MOD = 10 ** 9 + 7

dp = [0] * 13
dp[0] = 1

for s in S:
    prev = dp
    dp = [0] * 13
    if s == '?':
        add = range(10)
    else:
        add = [int(s)]
    for i in range(13):
        for a in add:
            dp[(10*i+a)%13] += prev[i]
        dp[i] %= MOD
print(dp[5])
Problem p02971 (python)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
max_a = max(a)
second_a = sorted(a)[-2]
max_count = a.count(max_a) - 1
if max_count:
    [print(max_a) for _ in range(len(a))]
else:
    [print(max_a) if a[i] != max_a else print(second_a) for i in range(len(a))]

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
import numpy as np
 
N = int(readline())
A = np.zeros(N+2,np.int32)
A[1:-1] = np.array(read().split(),np.int32)

N = ir()
A = np.zeros(N+2, np.int32)
A[1:-1] = np.array(read().split(),np.int32)

left_max = np.maximum.accumulate(A[:-2])
right_max = np.maximum.accumulate(A[::-1])[::-1][2:]
answer = np.maximum(left_max, right_max)
print('\n'.join(answer.astype(str)))

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

read = sys.stdin.buffer.read
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.zeros(N+2, np.int32)
A[1:-1] = np.array(read().split(),np.int32)

left_max = np.maximum.accumulate(A[:-2])
right_max = np.maximum.accumulate(A[::-1])[::-1][2:]
answer = np.maximum(left_max, right_max)
print('\n'.join(answer.astype(str)))
Problem p02972 (python)

Fixed submission:
def main(A,N):
    A = [0] + A
    for a in range(N-1,0,-1):
        #print(inds[ind::ind+1])
        if sum(A[a::a]) %2== 0:
            A[a] = 0
        else:
            A[a] = 1
        
    res = [x for x in range(0,N+1) if A[x]]
    print(len(res))
    print(*res)

N = int(input())
A = [int(x) for x in input().split()]
    
main(A,N)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
from collections import defaultdict

balls = defaultdict(int)
for i in range(n-1,-1,-1):
    count=A[i]
    for j in range(n//(i+1)):
        count+=balls[(j*(i+1))-1]
    if count%2:
        balls[i]=1

ans=[i+1 for i in range(n) if balls[i]==1]
print(len(ans))
print(*ans)
n=int(input())
A=list(map(int,input().split()))
from collections import defaultdict

balls = defaultdict(int)
for i in range(n-1,-1,-1):
    count=A[i]
    for j in range(n//(i+1)):
        count+=balls[(j*(i+1))-1]
    if count%2:
        balls[i]=1

ans=[i+1 for i in range(n) if balls[i]==1]
print(len(ans))
print(*ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
from collections import defaultdict

balls = defaultdict(int)
for i in range(n-1,-1,-1):
    count=A[i]
    for j in range(n//(i+1)):
        count+=balls[(j*(i+1))-1]
    if count%2:
        balls[i]=1

ans=[i+1 for i in range(n) if balls[i]==1]
print(len(ans))
print(*ans)
n=int(input())
A=list(map(int,input().split()))
from collections import defaultdict

balls = defaultdict(int)
for i in range(n-1,-1,-1):
    count=A[i]
    for j in range(n//(i+1)):
        count+=balls[(j*(i+1))-1]
    if count%2:
        balls[i]=1

ans=[i+1 for i in range(n) if balls[i]==1]
print(len(ans))
print(*ans)
Problem p02983 (python)

Fixed submission:
L, R = list(map(int,input().split()))

minimum = L * R
for i in range(L, min(R, L+2020)):
    for j in range(i+1, min(R+1, i+2021)):
        
        minimum = min(minimum, i * j % 2019)
        

print(minimum)

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

minimum = L * R
for i in range(L, min(R, L+2020)):
    for j in range(i+1, min(R+1, i+2020):
        
        minimum = min(minimum, i * j // 2019)
        

print(minimum)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
a,b,c,d=map(int,input().split())
count=0
x=b-a+1
def cal(x):
    return x//c+x//d-x//(c*d//gcd(c,d))
print(b-a+1-(cal(b)-cal(a-1)))

Buggy submission (verdict: Runtime Error):
a, b, c, d = list(map(int, input().split())
b - (a - 1) - ((b - a) // c) - ((b - a) // d) + ((b - a) // c * d)
Problem p03000 (python)

Fixed submission:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n,x=na()
l=na()
l.append(0)

count=0
pos=0
for i in range(n+1):
    count+=1
    pos+=l[i]
    if pos>x:
        break
print(count)

Buggy submission (verdict: Runtime Error):
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n,x=na()
l=na()

count=0
pos=0
for i in range(n+1):
    count+=1
    pos+=l[i]
    if pos>x:
        break
print(count)
Problem p03006 (python)

Fixed submission:
from collections import Counter

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
diff = []
for i in range(N):
    xi, yi = XY[i]
    for j in range(i+1, N):
        xj, yj = XY[j]
        diff.append((xj-xi, yj-yi))
c = Counter(diff)
print(N-max(c.values()) if c else N)

Buggy submission (verdict: Runtime Error):
from collections import Counter
# タプルの辞書
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
XY.sort()
diff = []
for i in range(N):
    xi, yi = XY[i]
    for j in range(i+1, N):
        xj, yj = XY[j]
        diff.append((xj-xi, yj-yi))
c = Counter(diff)
print(N-max(c.values()))
Problem p03014 (python)

Fixed submission:
import numpy as np

H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)])=='.'

R = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)

for i in range(H):
    U[i] = (U[i-1] + 1) * S[i]
    D[-i-1] = (D[-i] + 1) * S[-i-1]

for i in range(W):
    L[:, i] = (L[:, i-1] + 1) * S[:, i]
    R[:, -i-1] = (R[:, -i] + 1) * S[:, -i-1]

print(np.max(R+L+U+D) - 3)

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

H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)])=='.'

R = np.zeros((H, W), dtype=int)
L = np.zeros((H, W), dtype=int)
U = np.zeros((H, W), dtype=int)
D = np.zeros((H, W), dtype=int)

for i in range(H):
    U[i] = (U[i-1] + 1) * S[i]
    D[-i-1] = (D[-i] + 1) * S[-i-1]

for i in range(W):
    L[:, i] = (L[:, i-1] + 1) * S[:, i]
    R[:, -i-1] = (R[:, -i] + 1) * S[-i-1]

print(np.max(R+L+U+D) - 3)
Problem p03074 (python)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
S = np.array([int(x) for x in input()] + [2])

blocks = [] # 同じ数の塊
seq = 1
for i in range(N):
    if S[i+1] == S[i]:
        seq += 1
    else:
        blocks.append(seq)
        seq = 1
blocks = np.array(blocks)

answer = blocks[:2*K].sum()

start = 0 if S[0] == 1 else 1
for i in range(start, len(blocks), 2):
    answer = max(answer, blocks[i:i+(2*K+1)].sum())

print(answer)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 0か1の連続している人数のリスト、累積和
streak = [0, 0]
N, K = lr()
S = sr() + '2'
cur = 1
for i in range(N):
    if S[i] != S[i+1]:
        streak.append(cur)
        cur = 1
    else:
        cur += 1

streak_cum = list(itertools.accumulate(streak))
streak_cum.extend([streak_cum[-1], streak_cum[-1]])
if S[0] == '0':
    start = 0
else:
    start = 1
answer = 0

for i in range(start, len(streak_cum), 2):
    result = streak_cum[i+2*K+1] - streak_cum[i]
    if result > answer:
        answer = result

print(answer)
# 52
Problem p03090 (python)

Fixed submission:
import sys

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
answer_list = []
pair = N if N&1 else N+1
for i in range(1, N):
    for j in range(i+1, N+1):
        if i+j == pair:
            continue
        else:
            answer_list.append((i, j))

print(len(answer_list))
for x in answer_list:
    print(*x)

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
answer_set = {}
for i in range(1, N):
    for j in range(i+1, N+1):
        if i+j == N:
            continue
        else:
            answer_set.add((i, j))

print(len(answer_set))
for x in answer_set:
    print(*x)
Problem p03106 (python)

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

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

Buggy submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
num = []
for i in range(1,min(A,B)):
    if A%i == 0 and B%i == 0:
        num.append(i)
pritn(num[-K])
Problem p03138 (python)

Fixed submission:
import numpy as np

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

max_len = max(len(bin(K)[2:]), len(bin(max(A))[2:]))
bit_cnt = [((A>>k)&1).sum() for k in range(max_len)]

x = 0
for i in range(max_len-1, -1, -1):
    if x+2**i <= K and bit_cnt[i] < (N+1)//2:
        x += 2**i

answer = 0
for a in A:
    answer += a^x
print(answer)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys
from functools import lru_cache
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array(lr())
limit = max(A.max(), K).bit_length()
bit_cnt = [((A>>k)&1).sum() for k in range(limit)]

@lru_cache(None)
def solve(K, index):
    if index < 0:
        return 0
    bit = 1 << index
    # bitを使わない（整数Xのこの桁のbitは0）
    ret = (bit_cnt[index]<<index) + solve(min(K, bit-1), index-1)
    if bit <= K:
        ret = max(ret, ((N-bit_cnt[index])<<index) +  solve(K-bit, index-1))
    return ret

answer = solve(K, limit-1)
print(answer)
Problem p03213 (python)

Fixed submission:
N = int(input())
e = [0] * (N+1)

for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m): # eの要素のうち m-1 以上のものの個数
    return len(list(filter(lambda x: x >= m-1, e)))

answer = num(75) + num(25) * (num(3)-1) + num(15) * (num(5) - 1)\
    + num(5) * (num(5) - 1) * (num(3) - 2) // 2
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())
e = [0] * (N+1)

for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m): # eの要素のうち m-1 以上のものの個数
    return len(list(filter(lambda x: x >= m-1, e)))

answer = num(75) + num(25) * (num(3)-1) + num(15) * (num(5) - 1)
    + num(5) * (num(5) - 1) * (num(3) - 2) // 2)
Problem p03215 (python)

Fixed submission:
import sys
import numpy as np
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([0] + lr())
A_cum = A.cumsum()
beauties = []
for i, j in itertools.combinations(range(N+1), 2):
    beauties.append(A_cum[j] - A_cum[i])

beauties = np.array(beauties)
j = 0
def check(x):
    return np.sum(beauties&x == x) >= K

answer = 0
for i in range(40, -1, -1):
    if check(answer + (1 << i)):
        answer += 1 << i

print(answer)
# 00

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([0] + lr())
A_cum = A.cumsum()
beauties = []
for i, j in itertools.combinations(range(N+1), 2):
    beauties.append(A_cum[j] - A_cum[i])

beauties = np.array(beauties)
j = 0
def check(x):
    return np.sum(beauties&x == x) >= K

answer = 0
for i in range(40, -1, -1):
    if check(answer + 1 << i):
        answer += 1 << i

print(answer)
# 00

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([0] + lr())
A_cum = A.cumsum()
beauties = []
for i, j in itertools.combinations(range(N+1), 2):
    beauties.append(A_cum[j] - A_cum[i])

beauties.sort(reverse=True)
j = 0
def check(x):
    return sum([x&y == x for y in beauties]) >= K

answer = 0
for i in range(40, -1, -1):
    if check(answer + 1 << i):
        answer += 1 << i

print(answer)
# 00
Problem p03216 (python)

Fixed submission:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = np.array(list('_' + sr()))
Q = ir()
K = lr()
isD = (S == 'D')
isM = (S == 'M')
isC = (S == 'C')
cumD = isD.cumsum()
cumM = isM.cumsum()

for k in K:
    x = cumD.copy()
    x[k:] -= cumD[:-k]
    x *= isM
    x[k+1:] -= isD[1:-k] * (cumM[k:-1] - cumM[:-k-1])
    answer = (x.cumsum() * isC).sum()
    print(answer)
# 05

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = np.array(list('_' + sr()))
Q = ir()
K = lr()
isD = (S == 'D')
isM = (S == 'M')
isC = (S == 'C')
cumD = isD.cumsum()
cumM = isM.cumsum()

for k in K:
    x = cumD.copy()
    x[k:] -= cumD[:-k]
    x *= isM
    x[k+1:] -= isD[1:-k] * (cumM[k:-1] - cumM[:-k-1])
    answer = (x.cumsum() * isC).sum()
    print(answer)
# 05

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

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = np.array(list('_' + sr()))
Q = ir()
K = lr()
isD = (S == 'D')
isM = (S == 'M')
isC = (S == 'C')
cumD = isD.cumsum()
cumM = isM.cumsum()

for k in K:
    x = cumD.copy()
    x[k:] -= cumD[:-k]
    x *= isM
    x[k+1:] -= isD[1:-k] * (cumM[k:-1] - cumM[:-k-1])
    answer = (x.cumsum() * isC).sum()
    print(answer)
# 05