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

Fixed submission:
def heihou(a,b):
  c=a+b
  s=int(c)
  s=pow(s,1/2)
  if s.is_integer():
    return "Yes"
  else:
    return "No"
a,b=map(str,input().split())
print(heihou(a,b))

Buggy submission (verdict: Runtime Error):
def heihou(a,b):
  c=a+b
  c=int(s)
  s=s**1/2
  if s%1==0:
    return "Yes"
  else:
    return "No"
a,b=map(str,input().split())
print(heihou(a,b))
Problem p03478 (python)

Fixed submission:
def wa(n,a,b):
  hoge=0
  ans=0
  for i in range(1,n+1):
    s=str(i)
    hoge=0
    for ii in s:
      hoge+=int(ii)
    if a<=hoge<=b:
      ans+=i
  return ans
n,a,b=map(int,input().split())
print(wa(n,a,b))

Buggy submission (verdict: Runtime Error):
def wa(n,a,b):
  hoge=0
  for i in range(1,n+1):
    s=str(i)
    for ii in s:
      hoge+=int(ii)
    if a<=hoge<=b:
      ans+=i
  return ans
n,a,b=map(int,input().split())
print(wa(n,a,b))

Buggy submission (verdict: Runtime Error):
def wa(n,a,b):
  for i in range(1,n+1):
    s=str(i)
    for ii in s:
      ss+=int(ii)
    if a<=ss<=b:
      ans+=i
  return ans
n,a,b=map(int,input().split())
print(wa(n,a,b))

Buggy submission (verdict: Runtime Error):
def wa(n,a,b):
  for i in range(1,n+1):
    s=str(i)
    for ii in s:
      ss+=int(ii)
    if a=<ss=<b:
      ans+=i
  return ans
n,a,b=map(int,input().split())
print(wa(n,a,b))
Problem p03493 (python)

Fixed submission:
def count_1(a):
  c=0
  for i in a:
    if i=="1":
      c+=1
  else:
    return c
a=input()
print(count_1(a))

Buggy submission (verdict: Runtime Error):
def gu(n,a):
  ans=[0]*n
  for i in range(len(a)):
    ii=a[i]
    while True:
      if ii%2==0:
        ans[i]+=1
        ii=ii/2
      else:
        break
  return min(ans)
n=int(input())
a=list(map(int,input().split()))
print(gu(n,a))

Buggy submission (verdict: Runtime Error):
def gu(n,a):
  ans=[0]*n
  for i in range(len(a)):
    ii=a[i]
    while True:
      if ii%2==0:
        ans[i]+=1
        ii=ii/2
      else:
        break
  return ans.min()
n=int(input())
a=list(map(int,input().split()))
print(gu(n,a))

Buggy submission (verdict: Runtime Error):
def gu(n,a):
  ans=[0]*n
  for i in range(len(a)):
    ii=a[i]
    while True:
      if ii%2==0:
        ans[i]+=1
      else:
        break
  return ans.min()
n=int(input())
a=list(map(int,input().split()))
print(gu(n,a))

Buggy submission (verdict: Runtime Error):
def gu(n,a):
  ans=[0]*n
  for i in len(len(a)):
    ii=a[i]
    while True:
      if ii%2==0:
        ans[i]+=1
      else:
        break
  return ans.min()
n=int(input())
a=list(map(int,input().split()))
print(gu(n,a))
def gu(n,a):
  ans=[0]*n
  for i in range(len(a)):
    ii=a[i]
    while True:
      if ii%2==0:
        ans[i]+=1
      else:
        break
  return ans.min()
n=int(input())
a=list(map(int,input().split()))
print(gu(n,a))
Problem p03494 (python)

Fixed submission:
def gu(n,a):
  ans=[0]*n
  for i in range(len(a)):
    ii=a[i]
    while True:
      if ii%2==0:
        ans[i]+=1
        ii=ii/2
      else:
        break
  return min(ans)
n=int(input())
a=list(map(int,input().split()))
print(gu(n,a))

Buggy submission (verdict: Runtime Error):
def gu(n,a):
  ans=[0]*n
  for i in len(len(a)):
    ii=a[i]
    while True:
      if ii%2==0:
        ans[i]+=1
      else:
        break
  return ans.min()
n=int(input())
a=list(map(int,input().split()))
print(gu(n,a))
Problem p02811 (python)

Fixed submission:
K, X = map(int, input().split())
if 500*K >= X:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
K, X = map(int,input().split)
if 500*K >= X:
  print("Yes")
else:
  print("No")
Problem p03000 (python)

Fixed submission:
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

n,x=map(int, input().split())
l=list(map(int, input().split()))

bound = 1
pos = 0

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

print(bound)

Buggy submission (verdict: Runtime Error):
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

n,x=map(int, input().split())
l=list(map(int, input().split()))

bound = 1
pos = 0

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

print(bound)
Problem p03031 (python)

Fixed submission:
# n=int(input())
# a,b=map(int, input().split())
# c=list(map(int, input().split()))
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import numpy as np
import math
import copy

N, M=map(int, input().split())


# 各スイッチがどの電球につながっているかの情報をビットで保持する配列
# 1番目のスイッチが2番目と3番目の電球につながっていた場合以下のようにいなる
# (1 << 1) | (1 << 2) = (110)b   ※ zero index
mask_list = [0 for _ in range(N)]

for i in range(M):
    switches = list(map(int, input().split()))

    # switchesの2番目以降の要素には、スイッチの番号が入っている
    for j in range(1, len(switches)):
        sw_num = (switches[j] - 1) # スイッチの番号をzero index で管理する
        sw_bit = 1 << i # つながっている電球を二進数で表す
        mask_list[sw_num] = mask_list[sw_num] | sw_bit

conds = list(map(int, input().split()))

conds_dec = 0

for i in range(len(conds)):
    conds_dec |= conds[i] << i

light_num = 0
for s in range(1 << N):
    t = 0
    for i in range(N):
        if s >> i & 1:
            t = t ^ mask_list[i]
    if t == conds_dec:
        light_num += 1


print(light_num)

Buggy submission (verdict: Runtime Error):
# n=int(inputfile.readline())
# a,b=map(int, inputfile.readline().split())
# c=list(map(int, inputfile.readline().split()))
# s=[list(map(int,list(inputfile.readline()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# a=100
# b=0.987654321
# print('{0:06d}-{1:6f}'.format(a,b))  # 0埋めのときの出力
# 000100-0.987654

import math
import sys

inputfile = open("input.txt")
N, M=map(int, inputfile.readline().split())

# 各スイッチがどの電球につながっているかの情報をビットで保持する配列
# 1番目のスイッチが2番目と3番目の電球につながっていた場合以下のようになる
# (1 << 1) | (1 << 2) = (110)b   ※ zero index
bulb_list = [0 for _ in range(N)]

for bulb_idx in range(M):
    switches = list(map(int, inputfile.readline().split()))
    bulb_bit = 1 << bulb_idx # つながっている電球を二進数で表す

    # switchesの2番目以降の要素には、スイッチの番号が入っている
    for sw in switches[1::]:
        sw_idx = (sw - 1) # スイッチの番号をzero indexに変換する
        bulb_list[sw_idx] = bulb_list[sw_idx] | bulb_bit

bulb_conds = list(map(int, inputfile.readline().split()))

bulb_cond = 0
for i, bc in enumerate(bulb_conds):
    bulb_cond |= bc << i

light_num = 0
# N = 3 の時
# 000, 001, 010, 011, 100, 101, 110, 111 の8パターンで、
# スイッチを押す全てのパターンを表現することが出来る
for bit_ptn in range(1 << N):
    t = 0 # tはbit_ptnが表すスイッチの組み合わせを全て押したときの電球の状態を表す(最初は全部消えている)
    for i in range(N):
        if bit_ptn >> i & 1:
            t = t ^ bulb_list[i]
    if t == bulb_cond:
        light_num += 1

print(light_num)
Problem p03219 (python)

Fixed submission:
A, B = list(map(int, input().split()))
print(A + (B // 2))

Buggy submission (verdict: Runtime Error):
import sys
if __name__ == "__main__":
    N, M = map(int, sys.stdin.readline().split())
    P = [0] * (N + 1)
    C = [0] * M

    for m in range(M):
        p, y = map(int, input().split())
        C[m] = [m, p, y, 0]
    C.sort(key=lambda x :x[2])

    for c in C:
        P[c[1]] += 1
        c[3] = P[c[1]]
    C.sort(key=lambda x :x[0])

    for c in C:
        print("{}{}".format(str(c[1]).zfill(6), str(c[3]).zfill(6)))
Problem p03262 (python)

Fixed submission:
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    N, X = map(int, sys.stdin.readline().split())
    L = list(map(int, sys.stdin.readline().split()))
    L.append(X)
    L.sort()
    D = [abs(x2 - x1) for x1, x2 in zip(L, L[1::])]
    print(reduce(gcd, D))

Buggy submission (verdict: Runtime Error):
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

# 左端点から右端点に行くパターン
# 右端点から左端点に行くパターン
# 求めるのはDの最大値
# 差のgcdとか？

N, X =  map(int, sys.stdin.readline().split())
L =  list(map(int, sys.stdin.readline().split()))
L = sorted(L.append(X))
D = [x2 - x1 for x1, x2 in zip(l , l[1::])]
print(reduce(gcd, D))
Problem p03361 (python)

Fixed submission:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
# 塗ることができないケースを考察してみる
# 愚直にシミュレーションしてもいけるかもしれない

H, W =  map(int, sys.stdin.readline().split())
L =  [list(list(sys.stdin.readline().rstrip())) for i in range(H)]

PL = [["0"] + l + ["0"] for l in L]

t = ["0"] * (W + 2)

PL.insert(0, t)
PL.append(t)

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if PL[i][j] == "#":
            if PL[i][j - 1] == "#" or PL[i - 1][j] == "#" or PL[i][j + 1] == "#" or PL[i + 1][j] == "#":
                continue
            else:
                print("No")
                exit()

print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
# 塗ることができないケースを考察してみる
# 愚直にシミュレーションしてもいけるかもしれない

H, W =  map(int, sys.stdin.readline().split())
L =  [list(list(sys.stdin.readline().rstrip())) for i in range(W)]

PL = [["0"] + l + ["0"] for l in L]

t = ["0"] * (W + 2)

PL.insert(0, t)
PL.append(t)

for i in range(1, H + 1):
    for j in range(1, W + 1):
        if PL[i][j] == "#":
            if PL[i][j - 1] == "#" or PL[i - 1][j] == "#" or PL[i][j + 1] == "#" or PL[i + 1][j] == "#":
                continue
            else:
                print("No")
                exit()

print("Yes")
Problem p02947 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
dic = {}
count = 0
for i in range(N):
  temp = "".join(sorted(input()))
  if temp in dic:
    count += dic[temp]
    dic[temp] += 1
  else:
    dic[temp] = 1

print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from math import factorial
N = int(input())
# スペース区切りの整数の入力
a = []
for i in range(N):
  a.append(input())

b = []
for s in a:
  temp = list(s)
  temp.sort()
  b.append("".join(temp))

count = 0
for s in set(b):
  temp = b.count(s)
  if temp >= 2:
    count += factorial(temp) / factorial(2) / factorial(temp - 2)

print(int(count))
Problem p02719 (python)

Fixed submission:
n,k=map(int,input().split())
n=n%k
a=min(n,abs(n-k))
print(a)

Buggy submission (verdict: Runtime Error):
k=int(input())

a=[]
i=1
d=0
while True:
    if len(str(i))==1:
        a.append(i)
    elif len(str(i))==2:
        I=str(i)
        c=abs(int(I[0])-int(I[1]))
        if c<=1:
            a.append(i)   
            
    elif len(str(i))==3:
        I=str(i)
        for j in range(2):
            c=abs(int(I[j])-int(I[j+1]))
            if c<=1:
                d=d+1
        if d==2:
            a.append(i)
        d=0
        
    elif len(str(i))==4:
        I=str(i)
        for j in range(3):
            c=abs(int(I[j])-int(I[j+1]))
            if c<=1:
                d=d+1
        if d==3:
            a.append(i) 
        d=0
        
    elif len(str(i))==5:
        I=str(i)
        for j in range(4):
            c=abs(int(I[j])-int(I[j+1]))
            if c<=1:
                d=d+1
        if d==4:
            a.append(i)   
        d=0
        
    elif len(str(i))==6:
        I=str(i)
        for j in range(5):
            c=abs(int(I[j])-int(I[j+1]))
            if c<=1:
                d=d+1
        if d==5:
            a.append(i)
        d=0
    
    elif len(str(i))==7:
        I=str(i)
        for j in range(6):
            c=abs(int(I[j])-int(I[j+1]))
            if c<=1:
                d=d+1
        if d==6:
            a.append(i)
            
        d=0    
        
    elif len(str(i))==8:
        I=str(i)
        for j in range(7):
            c=abs(int(I[j])-int(I[j+1]))
            if c<=1:
                d=d+1
        if d==7:
            a.append(i)
            
        d=0    
        
    i=i+1
    if i==10000000:
        break

print(a[k-1])
Problem p02804 (python)

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

mod = 10**9 + 7

# factorial
factorial = [1,1]
# factorial inverse
factorial_inverse = [1,1]
# inverse for calculation
inverse = [0,1]

for i in range(2, n+1):
    factorial.append((factorial[-1]*i) % mod)
    inverse.append((- inverse[mod % i] * (mod//i)) % mod)
    factorial_inverse.append(factorial_inverse[-1] * inverse[-1] % mod)

def Binominal_theorem(n, k, mod):
    if n < k:
        return 0
    if (n < 0) or (k < 0):
        return 0
    return factorial[n] * factorial_inverse[k] * factorial_inverse[n-k] % mod

ans_min = 0
for i in range(n-k+1):
    ans_min += (A[i] * Binominal_theorem(n-i-1, k-1, mod)) % mod

A = A[::-1]
ans_max = 0
for i in range(n-k+1):
    ans_max += (A[i] * Binominal_theorem(n-i-1, k-1, mod)) % mod

ans = (ans_max - ans_min) % mod
print(ans)

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

A = sorted(A)

def cmb(m, n):
    if m - n < n:
        n = m - n
    if n == 0:
        return 1
    if n == 1:
        return m
    
    numerator = [m - n + k + 1 for k in range(n)]
    denominator = [k + 1 for k in range(n)]

    for p in range(2, n+1):
        pivot = denominator[p-1]
        if pivot > 1:
            offset = (m-n) % p
            for k in range(p-1, n, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    
    result = 1
    for k in range(n):
        if numerator[k] > 1:
            result *= int(numerator[k])
            
            # mod(10**9+7)
            # result = result % (10**9+7)

    return result

ans = 0
CMB = [[] for _ in range(n)]
for i in range(n):
    if i <= k:
        for j in range(i, k):
            CMB[i].append(cmb(i, j))

for i in range(n):
    if n-i-1 < k-1:
        pass
    else:
        ans -= A[i] * CMB[n-i-1][k-1]
    if i < k-1:
        pass
    else:
        ans += A[i] * cmb[i][k-1]

ans = ans % (10**9 + 7)
print(ans)
Problem p02838 (python)

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

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)

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

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(n):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)
Problem p02901 (python)

Fixed submission:
# 解説AC
# 参考1: https://drken1215.hatenablog.com/entry/2019/09/29/103500
# 参考2: https://www.slideshare.net/chokudai/wap-atcoder4


n, m = map(int, input().split())
A, B, C = [], [], []
for _ in range(m):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    c = list(map(int, input().split()))
    now = 0
    for i in range(b-1, -1, -1):
        now += 2**(c[i]-1)
    C.append(now)

INF = 10**9
DP = [[INF for _ in range(2**n)] for _ in range(m+1)]
DP[0][0] = 0

for i in range(m):
    for j in range(2**n):
        c = C[i]
        # 鍵を使用しない
        DP[i+1][j] = min(DP[i][j], DP[i+1][j])
        # 鍵を使用する
        nex = j | c
        DP[i+1][nex] = min(DP[i+1][nex], DP[i][j]+A[i])

ans = 10**9
for i in range(m):
    ans = min(DP[i][-1], ans)

if ans == 10**9:
    ans = -1

print(ans)

Buggy submission (verdict: Runtime Error):
解説AC



n, m = map(int, input().split())
A, B, C = [], [], []
for _ in range(m):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    c = list(map(int, input().split()))
    now = 0
    for i in range(b-1, -1, -1):
        now += 2**(c[i]-1)
    C.append(now)

INF = 10**9
DP = [[INF for _ in range(2**n)] for _ in range(m+1)]
DP[0][0] = 0

for i in range(m):
    for j in range(2**n):
        c = C[i]
        # 鍵を使用しない
        DP[i+1][j] = min(DP[i][j], DP[i+1][j])
        # 鍵を使用する
        nex = j | c
        DP[i+1][nex] = min(DP[i+1][nex], DP[i][j]+A[i])

ans = 10**9
for i in range(m):
    ans = min(DP[i][-1], ans)

if ans == 10**9:
    ans = -1

print(ans)
Problem p02909 (python)

Fixed submission:
S = str(input())

if S == 'Sunny':
    print('Cloudy')
elif S == 'Cloudy':
    print('Rainy')
else:
    print('Sunny')

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

N, K, Q = map(int, input().split())
A = []

for a in range(Q):
    A.append(int(input()))

P = [K] * N
X = [-1] * N
B = [0] * N

P_n = np.array(P)
X_n = np.array(X)
X_n_Q = X_n * Q

R_n = P_n + X_n_Q

B_n = np.array(B)

for a in A:
    B_n[a-1] = B_n[a-1] + 1

dif_n = R_n + B_n
dif = dif_n.tolist()

for d in dif:
    if d >= 1:
        print('Yes')
    else:
        print('No')
Problem p02917 (python)

Fixed submission:
N = int(input())
B = list(map(int, input().split()))

a = 0

a += B[0]
a += B[N-2]

for n in range(N):
    if n == 0 or n == N-1:
        pass
    else:
        a += min(B[n-1], B[n])

print(a)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
count = 0

for n in range(1, N):
    if S[n-1] == 'R' and S[n] == 'R':
        count += 1
    elif S[n-1] == 'L' and S[n] == 'L':
        count += 1

count = count + 2*K
ans = min(count, N-1)
print(ans)
Problem p02923 (python)

Fixed submission:
import re

N = int(input())
H = list(map(int, input().split()))
X = []

if N == 1:
    print('0')
else:
    for n in range(N-1):
        if H[n] >= H[n+1]:
            X.append('T')
        else:
            X.append('F')

    XX = ''.join(X)

    if XX.find('T') == -1:
        print('0')
    else:
        T = re.findall('T*T', XX)

        Y=[]
        for y in T:
            Y.append(len(y))

        print(max(Y))

Buggy submission (verdict: Runtime Error):
import re

N = int(input())
H = list(map(int, input().split()))
X = []

if N == 1:
    print('0')
else:
    for n in range(N-1):
        if H[n] >= H[n+1]:
            X.append('T')
        else:
            X.append('F')

    XX = ''.join(X)

    T = re.findall('T*T', XX)

    Y=[]
    for y in T:
        Y.append(len(y))

    print(max(Y))

Buggy submission (verdict: Runtime Error):
import re

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

X = []

for n in range(N-1):
    if H[n] >= H[n+1]:
        X.append('T')
    else:
        X.append('F')

XX = ''.join(X)

T = re.findall('T*T', XX)

Y=[]
for y in T:
    Y.append(len(y))

print(max(Y))
Problem p02934 (python)

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

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(round(ans, 6))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input()))

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(round(ans, 6))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input()))

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(ans)

Buggy submission (verdict: Runtime Error):
#N = int(input())
#A = list(map(int, input()))

top = 1
for a in A:
    top = top * a

bottom = 0
for i in range(N):
    bottom += top / A[i]

ans = top / bottom
print(ans)
Problem p02945 (python)

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

s = A + B
d = A - B
m = A * B

print(max(s, d, m))

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

s = A + B
d = A - B
m = A * B

print(max(s, d, m))