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

Fixed submission:
S = input()
if (S == 'AAA') or (S == 'BBB'):
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
if (S == AAA) or (S == BBB):
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
if S = AAA or S = BBB:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
if S = 'AAA' or S = 'BBB':
  print('No')
else:
  print('Yes')
Problem p02759 (python)

Fixed submission:
n =int(input())
if n%2==0:
  answer = n//2
  print(answer)
else:
  answer = n//2+1
  print(answer)

Buggy submission (verdict: Runtime Error):
n =int(input())
if n%2=0:
  answer = n//2
  print(answer)
else:
  answer = n//2+1
  print(answer)

Buggy submission (verdict: Runtime Error):
n =int(input())
if n%2=0:
  print(n//2)
else:
  print(n//2+1)

Buggy submission (verdict: Runtime Error):
n =int(input())
if n//2=0:
  print(n//2)
else:
  print(n//2+1)
Problem p02897 (python)

Fixed submission:
import sys

#print("Please enter a value of N")
n = int(input())
if isinstance(n,int) == False:
    print("Input value is not a type of int.")
    sys.exit()
elif n < 1 or 100 < n:
    print("Input value is not in this range [0,100].")
    sys.exit()
else:
    if n%2 == 0:
        a = float(1/2)
    else:
        a = float(((n+1)/2)/n)
    
    print(a)

Buggy submission (verdict: Runtime Error):
import sys


print("Please enter a value of N")
n = int(input())
if isinstance(n,int) == False:
    #print("Input value is not a type of int.")
    #sys.exit()
    return
elif n < 1 or 100 < n:
    #print("Input value is not in this range [0,100].")
    #sys.exit()
    return
else:
    if n%2 == 0:
        a = float(1/2)
    else:
        a = float(((n+1)/2)/n)
    
    print(a)
    return
Problem p02572 (python)

Fixed submission:
"""C."""

import sys

input = sys.stdin.readline  # noqa: A001

n = int(input())
a = list(map(int, input()[:-1].split(' ')))

MOD_VALUE = 10**9 + 7
result = 0

a_sum = sum(a)

for i, v in enumerate(a):
    result += v * (a_sum - v)
    a_sum -= v

if result < MOD_VALUE:
    print(result)
else:
    print(result % MOD_VALUE)

Buggy submission (verdict: Runtime Error):
"""C."""

import sys

input = sys.stdin.readline  # noqa: A001

n = int(input())
a = list(map(int, input()[:-1].split(' ')))

result = 0

for i, v1 in enumerate(a):
    for j in range(i + 1, n + 1):
        result += v1 * a[j]
print(result)

Buggy submission (verdict: Runtime Error):
"""C."""

import sys

input = sys.stdin.readline  # noqa: A001

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

result = 0

for i, v1 in enumerate(a):
    for j in range(i + 1, n + 1):
        result += v1 * a[j]
print(result)
Problem p02595 (python)

Fixed submission:
N, D = map(int,input().split())
data = [list(map(int,input().split())) for _ in range(N)]
#print(data)
count = 0
for d in data:
    if d[0]*d[0] + d[1]*d[1] <= D*D:
        count += 1
print(count)
#print(N,D)

Buggy submission (verdict: Runtime Error):
N, D = map(int,input().split())
data = [map(int,input().split()) for _ in range(N)]
count = 0
for d in data:
    if d[0]*d[0] + d[1]*d[1] >= D*D:
        count += 1
print(count)
Problem p02629 (python)

Fixed submission:
abc = ['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']

ans = []
def rec(n):
    #print(n,int(n/26),n%26,abc[n%26])
    n-=1
    ans.append(abc[n%26])
    #print(n)
    if n>=26:
        #ans.append(abc[int(n%26)-1])
        return rec(int(n/26))
        #ans.append(abc[int(n%26)])
        #print(n%26)
    else:
        pass
       #ans.append(abc[int(n)])
       #print(n%26)
N = int(input())
rec(N)
#i=N

for i in range(len(ans)-1,-1,-1):
    print(ans[i],end="")

Buggy submission (verdict: Runtime Error):
abc = ['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']

ans = []
def rec(n):
    print(n,n%26,abc[n%26])
    #print(n)
    if n>=26:
        ans.append(abc[int(n%26)])
        return rec(int(n/26))
        #ans.append(abc[int(n%26)])
        #print(n%26)
    else:
       ans.append(abc[int(n)])
       #print(n%26)
N = int(input())
#rec(N)
#i=N
r=1
q=N
while q>0:

    r = q%27
    if q>26:
        ans.append(abc[r])
    else:
        ans.append(abc[r-1])
    q=int(q/27)
for i in range(len(ans)-1,-1,-1):
    print(ans[i],end="")
Problem p02623 (python)

Fixed submission:
from collections import deque
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_stack=deque([])
now=0
mn=0
j=0
for i in a:
  mn+=i
  if mn>k:
    mn-=i
    break
  else:
    now+=1
    a_stack.append(i)
for i in b:
  mn+=i
  if mn>k:
    mn-=i
    break
  else:
    now+=1
    j+=1
    if j==m:
      print(now)
      exit()
ans=now
while a_stack:
  if j>=m:
    break
  else:
    q=a_stack.pop()
    mn-=q
    now-=1
    while k-mn>0:
      mn+=b[j]
      now+=1
      if k-mn<0:
        now-=1
        mn-=b[j]
        break
      j+=1
      if j==m:
        break
    ans=max(now,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_stack=deque([])
now=0
mn=0
j=0
for i in a:
  mn+=i
  if mn>k:
    mn-=i
    break
  else:
    now+=1
    a_stack.append(i)
for i in b:
  mn+=i
  if mn>k:
    mn-=i
    break
  else:
    now+=1
    j+=1
ans=now
while a_stack:
  if j>=m:
    break
  else:
    q=a_stack.pop()
    mn-=q
    now-=1
    while k-mn>0:
      mn+=b[j]
      now+=1
      j+=1
      if k-mn<0:
        now-=1
        mn-=b[j]
        j-=1
        break
      if j==m:
        break
    ans=max(now,ans)
print(ans)
Problem p02659 (python)

Fixed submission:
a,b=input().split()
a=int(a)
b1,b2=map(int,b.split('.'))
b=b1*100+b2
c=a*b//100
print(c)

Buggy submission (verdict: Runtime Error):
def factorization(y):
    arr = []
    temp = y
    for i in range(2, int(-(-y**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([y, 1])
    return arr
n=int(input())
if n==1:
  print(0)
  exit()

ans=0
l=factorization(n)
for i,j in l:
    if j<=2:
      ans+=1
    else:
      c=1
      t=1
      while j>0:
        ans+=1
        j-=c
        c+=t
        if j<t:
          break
        t+=1     
print(ans)
Problem p02695 (python)

Fixed submission:
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
l=list(range(1,m+1))
l=list(itertools.combinations_with_replacement(l,n))
ans=0
for i in l:
  kari=0
  for j in range(q):
    if i[abcd[j][1]-1]-i[abcd[j][0]-1]==abcd[j][2]:
      kari+=abcd[j][3]
  ans=max(ans,kari)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
l=list(range(1,m+1))
l=list(itertools.combinations_with_replacement(l,m))
ans=0
for i in l:
  kari=0
  for j in range(q):
    if i[abcd[j][1]-1]-i[abcd[j][0]-1]==abcd[j][2]:
      kari+=abcd[j][3]
  ans=max(ans,kari)
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]
l=list(range(1,m+1))
l=list(itertools.combinations_with_replacement(l,4))
ans=0
for i in l:
  kari=0
  for j in range(q):
    if i[abcd[j][1]-1]-i[abcd[j][0]-1]==abcd[j][2]:
      kari+=abcd[j][3]
  ans=max(ans,kari)
print(ans)
Problem p02754 (python)

Fixed submission:
n,a,b = map(int,input().split())
cnt = n//(a+b)
if n%(a+b) - a >=0:
  cnt2 = a
else:
  cnt2 = n%(a+b)
print(a*cnt+cnt2)

Buggy submission (verdict: Runtime Error):
#include<iostream>
using namespace std;
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  ans=(n/(a+b))*a+min(a,n%(a+b));
  cout<<ans<<endl;
  return 0;
}
Problem p02773 (python)

Fixed submission:
n = int(input())
l =[input() for i in range(n)]
r=[]
d={}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
m = max(d.values())
for key,value in d.items():
    if value==m:
        r.append(key)
sorted_r = sorted(r)
print(*sorted_r,sep='\n')

Buggy submission (verdict: Runtime Error):
l =[input() for i in range(n)]
r=[]
d={}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
m = max(d.values())
for key,value in d.items():
    if value==m:
        r.append(key)
sorted_r = sorted(r)
print(*sorted_r,sep='\n')
Problem p02779 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = set(a)
if len(a) == len(b):
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = set(a)
if len(a) == len(b):
  print('YES')
else:
  print('NO')v
Problem p03327 (python)

Fixed submission:
x = int(input())
if x < 1000:
  print('ABC')
else:
  print('ABD')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
cnt = 0
for i in range(b-a):
  cnt += i
print(cnt-a)
Problem p03804 (python)

Fixed submission:
n,m = map(int,input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for i in range(n-m+1):
  for j in range(n-m+1):
    count = 0
    for x in range(m):
      for y in range(m):
        if b[x][y]!=a[i+x][j+y]:
          break
        else:
          count += 1
    if count == m**2:
      print('Yes')
      exit()
print('No')

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]
for i in range(m):
  for j in range(m):
    if a[i][j] == b[i][j]:
      pass
    else:
      a = []
if a == []:
  print('No')
else:
  print('Yes')
Problem p02580 (python)

Fixed submission:
from itertools import product
h, w, m = map(int, input().split())


row = [set()for _ in range(h)]
col = [set()for _ in range(w)]
for _ in range(m):
    x, y = map(lambda x: int(x)-1, input().split())
    row[x].add(y)
    col[y].add(x)

crow = 0
ic = []
for i, x in enumerate(row):
    if crow < len(x):
        crow = len(x)
        ic = [i]
    elif crow == len(x):
        ic.append(i)

ccol = 0
jc = []
for j, x in enumerate(col):
    if ccol < len(x):
        ccol = len(x)
        jc = [j]
    elif ccol == len(x):
        jc.append(j)


ans = crow+ccol
for i, j in product(ic, jc):
    if j not in row[i]:
        print(ans)
        break
else:
    print(ans-1)

Buggy submission (verdict: Runtime Error):
H, W, M = map(int, input().split())
bombs = []
rows = [[]for _ in range(H)]
cols = [[]for _ in range(W)]
for _ in range(M):
    h, w = map(lambda x: int(x)-1, input().split())
    bombs.append((h, w))
    rows[h].append(w)
    cols[w].append(h)

max_row = 0
for i, row in enumerate(rows):
    if max_row < len(row):
        max_row = len(row)
        row_idx = {i}
        continue
    elif max_row == len(row):
        row_idx.add(i)

max_col = 0
for i, col in enumerate(cols):
    if max_col < len(col):
        max_col = len(col)
        col_idx = {i}
        continue
    elif max_col == len(col):
        col_idx.add(i)

ans = max_row+max_col
points = len(row_idx)*len(col_idx)
if M < points:
    print(ans)
else:
    for i, j in bombs:
        if i in row_idx and j in col_idx:
            points -= 1
    if points == 0:
        print(ans-1)
    else:
        print(ans)
Problem p02629 (python)

Fixed submission:
n = int(input())-1

ans = []
while n >= 0:
    n, y = divmod(n, 26)
    ans.append(y)
    n -= 1
ans.reverse()


def to_alpha(x):
    return chr(x+ord('a'))


print(''.join(map(to_alpha, ans)))

Buggy submission (verdict: Runtime Error):
n = int(input())-1


ans = []
while n > 0:
    n, y = divmod(n, 26)
    ans.append(y)
ans.reverse()
*x, y = ans


def to_alpha(x):
    if x == 0:
        return 'z'
    else:
        return chr(x+ord('a')-1)


print(''.join(map(to_alpha, x))+chr(y+ord('a')))
Problem p02726 (python)

Fixed submission:
n, x, y = map(int, input().split())
x -= 1
y -= 1
GRAPH = [[0]*n for _ in range(n)]

def shortest_path(i, j):
    if i <= x <= y <= j:
        return min(j-i, x-i+j-y+1)
    elif x <= i <= y <= j:
        return min(j-i, i-x+j-y+1)
    elif x <= i <= j <= y:
        return min(j-i, i-x+y-j+1)
    elif i <= x <= j <= y:
        return min(j-i, x-i+y-j+1)
    else:
        return j-i


ans = [0]*(n-1)
for i in range(n):
    for j in range(i+1, n):
        path = shortest_path(i, j)-1
        ans[path] += 1
print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import shortest_path
from scipy.sparse import csr_matrix
n, x, y = map(int, input().split())
x -= 1
y -= 1
GRAPH = [[0]*n for _ in range(n)]
for i in range(n-1):
    GRAPH[i][i+1] = GRAPH[i+1][i] = 1
GRAPH[x][y] = GRAPH[y][x] = 1
G = csr_matrix(GRAPH)
sp = shortest_path(G)

ans = [0]*(n-1)
for i in range(n):
    for j in range(i+1, n):
        path = int(sp[i][j])-1
        ans[path] += 1
print(*ans, sep="\n")
Problem p02735 (python)

Fixed submission:
h, w = map(int, input().split())
INF = 10**5
MAP = ["."*(w+2)]
for _ in range(h):
    MAP.append("."+input()+".")
MAP.append("."*(w+2))
ROUTE = [[0]*(w+2) for _ in range(h+2)]
for i in range(2, w+1):
    ROUTE[0][i] = INF
for i in range(2, h+1):
    ROUTE[i][0] = INF

for i in range(1, h+1):
    for j in range(1, w+1):
        if MAP[i][j] == ".":
            x1 = ROUTE[i][j-1]
            x2 = ROUTE[i-1][j]
        else:
            if MAP[i][j-1] == "#":
                x1 = ROUTE[i][j-1]
            else:
                x1 = ROUTE[i][j-1]+1

            if MAP[i-1][j] == "#":
                x2 = ROUTE[i-1][j]
            else:
                x2 = ROUTE[i-1][j]+1
        ROUTE[i][j] = min(x1, x2)


print(ROUTE[h][w])

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
INF = 10**5
MAP = ["."*(w+2)]
for _ in range(h):
    MAP.append("."+input()+".")
MAP.append("."*(w+2))
ROUTE = [[0]*(w+2) for _ in range(h+2)]
for i in range(2, w+1):
    ROUTE[0][i] = INF
    ROUTE[i][0] = INF

for i in range(1, h+1):
    for j in range(1, w+1):
        if MAP[i][j] == ".":
            x1 = ROUTE[i][j-1]
            x2 = ROUTE[i-1][j]
        else:
            if MAP[i][j-1] == "#":
                x1 = ROUTE[i][j-1]
            else:
                x1 = ROUTE[i][j-1]+1

            if MAP[i-1][j] == "#":
                x2 = ROUTE[i-1][j]
            else:
                x2 = ROUTE[i-1][j]+1
        ROUTE[i][j] = min(x1, x2)


print(ROUTE[h][w])
Problem p02948 (python)

Fixed submission:
N, M = map(int, input().split())
ls = [[int(x) for x in input().split()] for _ in range(N)]


q = [[0] for _ in range(M)]
for a, b in ls:
    if a <= M:
        q[M-a].append(b*-1)

# print(q)

from heapq import heappop, heappush

pool = []
answer = 0
for x in reversed(q):
    for y in x:
        heappush(pool, y)
    m = heappop(pool)*-1
    answer += m
    

print(answer)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ls = [[int(x) for x in input().split()] for _ in range(N)]

q = [[] for _ in range(M)]
for a, b in ls:
    if a <= M:
        q[M-a].append(b*-1)

# print(q)

from heapq import heappop

pool = []
answer = 0
for x in reversed(q):
    pool.extend(sorted(x))
    m = heappop(pool)*-1
    answer += m
    

print(answer)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ls = [[int(x) for x in input().split()] for _ in range(N)]

q = [[0] for _ in range(M)]
for a, b in ls:
    q[M-a].append(b)

pool = []
answer = 0
for x in reversed(q):
    m = max(x+pool)
    answer += m
    pool += x
    pool.remove(m)
    

print(answer)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ls = [[int(x) for x in input().split()] for _ in range(N)]

q = [[1e-10] for _ in range(M)]
for a, b in ls:
    q[M-a].append(b)

print(sum(int(max(x)) for x in q))
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
MOD = 10**9+7
INF = MOD-1
dp = [INF]*(n+1)
if n == 1:
    if 1 in a:
        print(0)
    else:
        print(1)
    exit()

dp[0] = dp[1] = 1

if 0 in a:
    dp[0] = INF
if 1 in a:
    dp[1] = INF

for x in a:
    dp[x] = 0

for i in range(2, n+1):
    if dp[i] == 0:
        continue

    if dp[i-1] == INF and dp[i-2] == INF:
        break
    elif dp[i-1] == INF or dp[i-2] == INF:
        dp[i] = max(dp[i-1], dp[i-2])
    else:
        dp[i] = dp[i-1]+dp[i-2]
    dp[i] %= MOD


print(dp[n] if dp[n] != INF else 0)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
MOD = 10**9+7
dp = [-1]*(n+1)
dp[0] = dp[1] = 1

for x in a:
    dp[x] = 0

for i in range(2, n+1):
    if dp[i] == 0:
        continue
    dp[i] = (dp[i-1]+dp[i-2]) % MOD


print(dp[n] if dp[n] != INF else 0)
Problem p03209 (python)

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


def p(level):
    if level == 0:
        return 1
    return 2*p(level-1)+1


def a(level):
    if level == 0:
        return 1
    return 2*a(level-1)+3


def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a(N-1):
        return f(N-1, X-1)
    else:
        return p(N-1) + 1 + f(N-1, X-2-a(N-1))



print(f(n, x))

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


def p(level):
    if level == 0:
        return 1
    return 2*p(level-1)+1


def a(level):
    if level == 0:
        return 1
    return 2*a(level-1)+3


def f(level, x):
    if x <= 1:
        return 0
    else:
        ai_1 = a(level-1)
        if 1 < x <= 1 + ai_1:
            return f(level-1, x-1)
        else:
            pi_1 = p(level-1)
            return 1 + pi_1+f(level-1, x-2-ai_1)


print(f(n, x))

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


def p(level):
    if level == 0:
        return 1
    return 2*p(level-1)+1


def a(level):
    if level == 0:
        return 1
    return 2*a(level-1)+3


def f(level, x):
    if x == 1:
        return 0
    else:
        ai_1 = a(level-1)
        if 1 < x < 1 + ai_1:
            return f(level-1, x-1)
        else:
            pi_1 = p(level-1)
            if x == 2 + ai_1:
                return 1 + pi_1
            elif 2+ai_1 < x < 2 + 2*ai_1:
                return 1 + pi_1+f(level-1, x-2-ai_1)
            elif x == 3 + 2*ai_1:
                return 1 + 2*pi_1


print(f(n, x))
Problem p03804 (python)

Fixed submission:
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

for i in range(n):
    for j in range(n):
        if j+m <= n and i+m <= n:
            if [a[i+k][j:j+m] for k in range(m)] == b:
                print('Yes')
                exit()
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

tmp = []
for k in range(n):
    for i in range(n):
        if i+m <= n:
            for j in range(m):
                tmp.append(a[k+j][i:i+m])
        if tmp == b:
            print('Yes')
            exit()
        tmp = []
else:
    print('No')
Problem p02629 (python)

Fixed submission:
N=int(input())
alphabet=[chr(i) for i in range(97,123)]
ans=""
while N>0:
    N-=1
    ans=chr(97+(N%26))+ans
    N//=26
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
from itertools import accumulate

N=int(input())
alphabet=[chr(i) for i in range(97,97+26)]
num=[26**i for i in range(1,12)]
acc=list(accumulate(num))
ans=""
index=bisect.bisect_left(acc,N)
if index==0:
    ans+=alphabet[N-1]
else:
    N-=acc[index-1]
    while True:
        tmp=N//num[index-1]
        ans+=alphabet[tmp]
        N-=tmp*num[index-1]
        index=bisect.bisect_left(num,N)
        if index==0:
            break
    ans+=alphabet[N-1]
print(ans)
Problem p02754 (python)

Fixed submission:
N,A,B=map(int,input().split())
if (A+B)==0:
  print(0)
  exit()

ans=(N//(A+B))*A

if N%(A+B)<=A:
  ans+=N%(A+B)
else:
  ans+=A

print(ans)

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

if (A+B)==0:
  print(0)
  exit()

n=N//(A+B)

line=''
for i in range(n):
  line+='b'*A
  line+='r'*B

remainder=N%(A+B)
if remainder<=A:
  line+='b'*remainder
else:
  line+='b'*A
  line+='r'*(remainder-A)

print(line.count('b'))

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
n=N//(A+B)

line=''
for i in range(n):
  line+='b'*A
  line+='r'*B

remainder=N%(A+B)
if remainder<=A:
  line+='b'*remainder
else:
  line+='b'*A
  line+='r'*(remainder-A)

print(line.count('b'))
Problem p02757 (python)

Fixed submission:
from collections import defaultdict

N,P=map(int,input().split())
S=input()

def solMin():
  dp=[[0]*P for i in range(N+1)]
  
  for i,s in enumerate(map(int,S), start=1):
    dp[i][s%P]+=1
    for p in range(P):
      dp[i][(p*10+s)%P]+=dp[i-1][p]
  
  return sum(dp[i][0] for i in range(N+1))

def solLarge():
  cnt=defaultdict(int)
  ret=0
  now=0
  
  for d,s in enumerate(map(int, S[::-1])):
    now+=pow(10,d,P)*s
    now%=P
    ret+=cnt[(now-P)%P]
    if now==0:
      ret +=1
    cnt[now]+=1
  
  return ret

print(solMin() if P*N<=10**6 else solLarge())

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

N,P=map(int,input().split())
S=input()

def solMin():
  dp=[[0]*P for i in range(N+1)]
  
  for i,s in enumerate(map(int,S), start=1):
    dp[i][s%P]+=1
    for p in range(P):
      dp[i][(p*10+s)]+=dp[i-1][p]
  
  return sum(dp[i][0] for i in range(N+1))

def solLarge():
  cnt=defaultdict(int)
  ret=0
  now=0
  
  for d,s in enumerate(map(int, S[::-1])):
    now+=pow(10,d,P)*s
    now%=P
    ret+=cnt[(now-P)%P]
    if now==0:
      ret +=1
    cnt[now]+=1
  
  return ret

print(solMin() if P*N<=10**6 else solLarge())
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
A=[-1]+[int(input()) for i in range(M)]+[N+1]
res=1
for i in range(1,len(A)):
  steps=A[i]-A[i-1]-2
  if steps<0:
    patern_nmu=0
  else:
    p,q=1,0
    for j in range(steps):
      p,q=p+q,p
    patern_nmu=p
  res*=patern_nmu
  res%=1000000007
print(res)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[-1]+[int(input()) for i in range(M)]+[N+1]
res=1
for i in range(1,len(a)):
  steps=a[i]-a[i-1]-2
  if steps<0:
    patern_nmu=0
  else:
    p,q=1,0
    for j in range(steps):
      p,q=p+q,p
    patern_nmu=p
    res*=patern_nmu
    res%=1000000007
print(res)

Buggy submission (verdict: Runtime Error):
import math
def Fib(n):
  Fib=1/math.sqrt(5)*(((1+math.sqrt(5))/2)**(n+1)-((1-math.sqrt(5))/2)**(n+1))
  return int(Fib)
N,M=map(int,input().split())
if M==0:
  print(Fib(N))
  exit()
A=[]
for i in range(M):
  A.append(int(input()))
B=[0]*M
a=0
for i in range(M):
  B[i]=A[i]-1-a
  a=A[i]+1
B.append(N-a)
a=A[0]
for i in range(1,M):
  if A[i]==a+1:
    print(0)
    exit()
  else:
    a=A[i]
ans=1
for i in range(M+1):
  ans*=Fib(B[i])
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
import math
def Fib(n):
  Fib=1/math.sqrt(5)*(((1+math.sqrt(5))/2)**(n+1)-((1-math.sqrt(5))/2)**(n+1))
  return int(Fib)
N,M=map(int,input().split())
A=[]
for i in range(M):
  A.append(int(input()))
B=[0]*M
a=0
for i in range(M):
  B[i]=A[i]-1-a
  a=A[i]+1
B.append(N-a)
a=A[0]
for i in range(1,M):
  if A[i]==a+1:
    print(0)
    exit()
  else:
    a=A[i]
ans=1
for i in range(M+1):
  ans*=Fib(B[i])
print(ans%1000000007)
Problem p03072 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
ans=0
highest=0
for i in range(n):
  if h[i] >= highest:
    ans += 1
    highest=h[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
ans=0
highest=h[1]
for i in range(n):
  if h[i] >= highest:
    ans += 1
    highest=h[i]
print(ans)