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

Fixed submission:
A,B,C=map(int,input().split())
if((A==B and A!=C)or(B==C and B!=A)or(C==A and C!=B)):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input())
if((A==B and A!=C)or(B==C and B!=A)or(C==A and C!=B)):
  print("Yes")
else:
  print("No")
Problem p02990 (python)

Fixed submission:
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K=map(int,input().split())
for i in range(1,K+1):
  if(N-K+1>=i):
    a=comb(N-K+1,i)%(10**9+7)
    b=comb(K-1,i-1)%(10**9+7)
    print((a*b)%(10**9+7))
  else:
    print("0")

Buggy submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,K=map(int,input().split())
for i in range(1,K+1):
  a=comb(N-K+1,i)%(10**9+7)
  b=comb(K-1,i-1)%(10**9+7)
  print((a*b)%(10**9+7))
Problem p02793 (python)

Fixed submission:
from functools import reduce
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
 
MOD = 10 ** 9 + 7
 
lcm = reduce(lambda x,y: x*(y//gcd(x,y)), A)
lcm %= MOD

coef = sum(pow(a, MOD-2, MOD) for a in A)
ans = lcm * coef % MOD

print(ans)

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

from collections import defaultdict

MOD = 10**9 + 7

primes = defaultdict(int)

for a in A:
    p = 2
    while p * p <= a:
        if a % p == 0:
            cnt = 0
            while a % p == 0:
                cnt += 1
                a //= p
            primes[p] = max(primes[p], cnt)
        p += 1
    if a != 1:
        primes[a] = 1

lcm = 1
for p in primes.value():
    lcm *= pow(p, primes[p], MOD) % MOD

ans = 0
for a in A:
    ans += lcm * pow(a, MOD-2, MOD) % MOD
    ans %= MOD

print(ans)

Buggy submission (verdict: Runtime Error):
LARGE = 10 ** 9 + 7
 
 
def solve(n, a_list):
 
    # inverse
    res = 0
    for i in range(n):
        res += pow(a_list[i], LARGE - 2, LARGE)
        res %= LARGE
 
    # primes
    p_candidate_list = [1] * 10 ** 5
    p_candidate_list[0] = 0
    p_candidate_list[1] = 0
    for p in range(2, 10 ** 5):
        if p_candidate_list[p]:
            for q in range(p * p, 10 ** 5, p):
                p_candidate_list[q] = 0
    primes_1000000 = [p for p in range(1000000) if p_candidate_list[p]]

    lcm = 1
    for p in primes_1000000:
        r_max = 0
        for i in range(n):
            r = 0
            while a_list[i] % p == 0:
                r += 1
                a_list[i] = a_list[i] // p
            r_max = max(r_max, r)
        lcm *= pow(int(p), r_max, LARGE)
        lcm %= LARGE
 
    # for q in set(a_list):
    #     lcm *= q
    #     lcm %= LARGE
 
    return res * lcm % LARGE
 
 
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    res = solve(n, a_list)
    print(res)
 
 
def test():
    assert solve(3, [2, 3, 4]) == 13
    # assert solve(5, [12, 12, 12, 12, 12]) == 5
    # assert solve(3, [1000000, 999999, 999998]) == 996989508
 
 
if __name__ == "__main__":
    test()
    main()
Problem p02820 (python)

Fixed submission:
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

commands = [''] * N
ans = 0
for i, t in enumerate(T):
        if t == 'r':
                command = 'p'
                point = P
        elif t == 's':
                command = 'r'
                point = R
        elif t == 'p':
                command = 's'
                point = S
        if i-K >= 0 and commands[i-K] == command:
                command = ''
                point = 0
        ans += point
        commands[i] = command

print(ans)

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

commands = [''] * N
ans = 0
for i, t in enumerate(T):
        if t = 'r':
                command = 'p'
                point = P
        elif t = 's':
                command = 'r':
                point = R
        elif t = 'p':
                command = 's':
                point = S
        if i-K >= 0 and commands[i-K] == command:
                command = ''
                point = 0
        ans += point
        commands[i] = command

print(ans)
Problem p02834 (python)

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

n, u, v = map(int, input().split())
u -= 1
v -= 1
es = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

def dfs(v, dist, p=-1, d=0):
    dist[v] = d
    for nv in es[v]:
        if nv == p:
            continue
        dfs(nv, dist, v, d+1)

def calc_dist(x):
    dist = [-1] * n
    dfs(x, dist)
    return dist

dist_t = calc_dist(u)
dist_a = calc_dist(v)

mx = 0
for i in range(n):
    if dist_t[i] < dist_a[i]:
        mx = max(mx, dist_a[i])

ans = mx - 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, u, v = map(int, input().split())
u -= 1
v -= 1
es = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    es[a-1].append(b-1)
    es[b-1].append(a-1)

def dfs(v, dist, p=-1, d=0):
    dist[v] = d
    for nv in es[v]:
        if nv == p:
            continue
        dfs(nv, dist, v, d+1)

def calc_dist(x):
    dist = [-1] * n
    dfs(x, dist)
    return dist

dist_t = calc_dist(u)
dist_a = calc_dist(v)

mx = 0
for i in range(n):
    if dist_t[i] < dist_a[i]:
        mx = max(mx, dist_a[i])

ans = mx - 1
print(ans)
Problem p02891 (python)

Fixed submission:
s = input()
k = int(input())

if len(set(s)) == 1:
    ans = len(s) * k //2
else:
    if s[0] != s[-1]:
        i = 0
        cnt = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt += 1
                i += 2
            else:
                i += 1
        ans = cnt * k
    else:
        i = 0
        cnt = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt += 1
                i += 2
            else:
                i += 1
        tmp = cnt * k

        cnt_s = 0
        i = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt_s += 1
                i += 2
            else:
                i += 1
        
        s_2 = s * 2
        cnt_s_2 = 0
        i = 0
        while i < len(s_2) - 1:
            if s_2[i] == s_2[i+1]:
                cnt_s_2 += 1
                i += 2
            else:
                i += 1

        diff = cnt_s_2 - 2 * cnt_s
        ans = tmp + diff * (k-1)



print(ans)

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

if len(set(s)) == 1:
    ans = len(s) * k //2
else:
    if s[0] != s[-1]:
        i = 0
        cnt = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt += 1
                i += 2
            else:
                i += 1
        ans = cnt * k
    else:
        cnt = 0
        for i in range(len(s) - 1):
            if s[i] == s[i+1]:
                cnt += 1
        tmp = cnt * k

        # # s_head == s_tail
        # s_head = s[0]
        # s_tail = s[-1]
        # a, b = 0, 0
        # for val in s:
        #     if val == s_head:
        #         a += 1
        #     else:
        #         break
        # for val in s[::-1]:
        #     if val == s_tail:
        #         b += 1
        #     else:
        #         break
        
        cnt_s = 0
        i = 0
        while i < len(s) - 1:
            if s[i] == s[i+1]:
                cnt_2 += 1
                i += 2
            else:
                i += 1
        
        s_2 = s * 2
        cnt_s_2 = 0
        i = 0
        while i < 2 * len(s) - 1:
            if s[i] == s[i+1]:
                cnt_s_2 += 1
                i += 2
            else:
                i += 1

        diff = cnt_s_2 - cnt_s
        ans = tmp - diff * (k-1)

print(ans)
Problem p02990 (python)

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

def prepare(N, MOD):
    fac = [None] * (N+2)
    finv = [None] * (N+2)
    inv = [None] * (N+2)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, N+1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
    return fac, finv

def comb_rem(N, K, fac, finv, MOD):
    if N < K:
        return 0
    if N < 0 or K < 0:
        return 0
    else:
        return fac[N] * (finv[K] * finv[N - K] % MOD) % MOD

MOD = 10 ** 9 + 7

for i in range(1, K+1):
    ans = 1
    fac, finv = prepare(N-K+1, MOD)
    a = comb_rem(N-K+1, i, fac, finv, MOD)
    fac, finv = prepare(K-1, MOD)
    b = comb_rem(K-1, i-1, fac, finv, MOD)
    ans *= a * b % MOD
    print(ans)

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

def prepare(N, MOD):
    fac = [None] * (N+1)
    finv = [None] * (N+1)
    inv = [None] * (N+1)
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, N+1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
    return fac, finv

def comb_rem(N, K, fac, finv, MOD):
    if N < K:
        return 0
    if N < 0 or K < 0:
        return 0
    else:
        return fac[N] * (finv[K] * finv[N - K] % MOD) % MOD

MOD = 10 ** 9 + 7

for i in range(1, K+1):
    ans = 1
    fac, finv = prepare(N-K+1, MOD)
    a = comb_rem(N-K+1, i, fac, finv, MOD)
    fac, finv = prepare(K-1, MOD)
    b = comb_rem(K-1, i-1, fac, finv, MOD)
    ans *= a * b % MOD
    print(ans)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
a = []
issafe = [True for _ in range(N+1)]
for i in range(M):
    a.append(int(input()))
    issafe[a[i]] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, N+1):
    if issafe[i-1]:
        dp[i] += dp[i-1]
    if issafe[i-2]:
        dp[i] += dp[i-2]
    dp[i] %= 1000000007

print(dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
issafe = [True for _ in range(N)]
for i in range(M):
    a.append(int(input()))
    issafe[a[i]] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, N+1):
    if issafe[i-1]:
        dp[i] += dp[i-1]
    if issafe[i-2]:
        dp[i] += dp[i-2]
    dp[i] %= 1000000007

print(dp[N])
Problem p03017 (python)

Fixed submission:
n, a, b, c, d = map(int, input().split())
s = input()

if c < d:
    for i in range(b-1, d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == d-1:
            t += '#'
        else:
            t += s[i]

    for i in range(a-1, c-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    print('Yes')
elif c > d:
    for i in range(a-1, c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    for bi in range(b-1,d):
        if s[bi-1] == s[bi] == s[bi+1] == '.':
            print('Yes')
            exit()

    print('No')

else:
    print('No')

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

if c < d:
    for i in range(b-1, d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

    t = ''
    for i in range(len(s)):
        if i == d-1:
            t += '#'
        else:
            t += s[i]

    for i in range(a-1, c-1):
        if t[i] == '#' and t[i+1] == '#':
            print('No')
            exit()

    print('Yes')
elif c > d:
    for i in range(a-1, c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            exit()

for bi in range(b-1,d):
    if s[bi-1] == s[bi] == s[bi+1] == '.':
        print('Yes')
        exit()

else:
    print('No')
Problem p03038 (python)

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

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

cnt = 0
for b, c in BC:
    for i in range(b):
        if c < A[cnt]:
            break
        A[cnt] = c
        cnt += 1
        if cnt >= n:
            break
    else:
        continue
    break

print(sum(A))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [tuple(map(int, input().split())) for _ in range(m)]

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

cnt = 0
for b, c in BC:
    for i in range(b):
        if c < A[cnt]:
            break
        A[cnt] = c
        cnt += 1
    if cnt >= n:
        break

print(sum(A))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [tuple(map(int, input().split())) for _ in range(m)]

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

cnt = 0
for b, c in BC:
    for i in range(b):
        if c < A[cnt]:
            continue
        A[cnt] = c
        cnt += 1
    if cnt >= n:
        break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
q=[]
for i in range(M):
    q.append(list(map(int,input().split())))
    
sorted_q=sorted(q,key=lambda x:x[1],reverse=True)

q_all=[]
for i in range(M):
    for j in range(sorted_q[i][0]):
        q_all.append(sorted_q[i][1])

for i in range(N):
    if A[i]<q_all[i]:
        A[i]=q_all[i]
        
print(sum(A))
Problem p03072 (python)

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

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

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

Fixed submission:
S=list(input())
N=len(S)
S_int_1=list(S)
S_int_2=list(S)
for i in range(N):
    S_int_1[i]=int(S[i])
    S_int_2[i]=int(S[i])
cnt_1=0
cnt_2=0
for i in range(N):
    if i%2==0 and S_int_1[i]==0:
        S_int_1[i]=1
        cnt_1+=1
    elif i%2==1 and S_int_1[i]==1:
        S_int_1[i]=0
        cnt_1+=1
for i in range(N):
    if i%2==0 and S_int_2[i]==1:
        S_int_2[i]=0
        cnt_2+=1
    elif i%2==1 and S_int_2[i]==0:
        S_int_2[i]=1
        cnt_2+=1
print(min(cnt_1,cnt_2))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(N)]

nl = []
for i in range(N):
    for j in range(l[i][1]):
        nl.append(l[i][0])
    
sorted_nl = sorted(nl)

ans = 0
for i in range(M):
    ans += sorted_nl[i]
    
print(ans)

Buggy submission (verdict: Runtime Error):
S=list(input())
N=len(S)
S_int=list(S)
for i in range(N):
    S_int[i]=int(S[i])
cnt_1=0
cnt_2=0
if all([S_int[i]!=S_int[i+1] for i in range(N)]):
    print(0)
for i in range(N):
    if i%2==0 and S_int[i]==0:
        S_int[i]=1
        cnt_1+=1
    elif i%2==1 and S_int[i]==1:
        S_int[i]=0
        cnt_1+=1
for i in range(N):
    if i%2==0 and S_int[i]==1:
        S_int[i]=0
        cnt_2+=1
    elif i%2==1 and S_int[i]==0:
        S_int[i]=1
        cnt_2+=1
print(min(cnt_1,cnt_2))
Problem p03075 (python)

Fixed submission:
a,b,c,d,e,k=[int(input()) for _ in range(6)]
if e-a<=k:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k=[int(input()) for _ in range(5)]
if e-a<=k:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k=[int(input()) for _ in range(5)]
if e-a>=k:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k=map(int,input())
if e-a>=k:
    print('Yay!')
else:
    print(':(')
Problem p03286 (python)

Fixed submission:
N = int(input())

ans = ''
while N != 0:
    r = N % 2
    N = (N - r) // (-2)
    ans += str(r)

ans = ans[::-1]
if ans == '':
    ans = '0'

print(ans)

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

ans = ''
while N != 0:
    r = N % 2
    N = (N - r) / (-2)
    ans += r

ans[::-1]
if N == 0:
    ans = '0'
    
print(ans)
Problem p03634 (python)

Fixed submission:
N = int(input())
edge = [[] for i in range(N)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    edge[a-1].append((c, b-1))
    edge[b-1].append((c, a-1))
Q, K = map(int, input().split())
query = [tuple(map(int, input().split())) for _ in range(Q)]

import heapq

def dijkstra_heap(s):
    d = [10**12] * N
    used = [False] * N
    d[s] = 0
    used[s] = True
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist, e)
    while len(edgelist):
        min_edge = heapq.heappop(edgelist)
        if used[min_edge[1]]:
            continue
        v = min_edge[1]
        d[v] = min_edge[0]
        used[v] = True
        for e in edge[v]:
            heapq.heappush(edgelist, (e[0] + d[v], e[1]))
    return d

dist = dijkstra_heap(K-1)
for q in query:
    x, y = q[0], q[1]
    x -= 1
    y -= 1
    print(dist[x] + dist[y])

Buggy submission (verdict: Runtime Error):
N = int(input())
edge = [[] for i in range(N)]
for i in range(N-1):
    a, b, c = map(int, input().split())
    edge[a-1].append((c, b-1))
    edge[b-1].append((c, a-1))
Q, K = map(int, input().split())
query = [tuple(map(int, input().split())) for _ in range(Q)]

import heapq

def dijkstra_heap(s):
    d = [10**12] * N
    used = [False] * N
    d[s] = 0
    used[s] = True
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist, e)
    while len(edgelist):
        min_edge = heapq.heappop(edgelist)
        if used[min_edge[1]]:
            continue
        v = min_edge[1]
        d[v] = min_edge[0]
        used[v] = True
        for e in edge[v]:
            heapq.heappush(edgelist, [e[0] + d[v], e[1]])
    return d

dist = dijkstra_heap(K-1)
for q in query:
    x, y = q[0], q[1]
    x -= 1
    y -= 1
    print(dist[x] + dist[y])
Problem p02779 (python)

Fixed submission:
n = int(input())
A = [int(x) for x in input().split()]
print('YES' if len(A) == len(set(A)) else 'NO')

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [int(x) for x in input().split()]
print('YES' if len(A) = len(set(A)) else 'NO')
Problem p02987 (python)

Fixed submission:
s = input()
print('Yes' if len(set(s)) == 2 and s.count(s[0]) == 2 else 'No')

Buggy submission (verdict: Runtime Error):
s = input()
print('Yes' if len(set(s)) == 2 and s.count[s[0]] == 2 else 'No')
Problem p03017 (python)

Fixed submission:
def main():
    #入力
    N, A, B, C, D = (int(_) for _ in input().split())
    A, B, C, D = A-1, B-1, C-1, D-1
    S = input()

    sa, sb = S[A:C+1], S[B:D+1]
    can1 = can2 = True
    for i in range(len(sa)-1):
        if sa[i] == '#' and sa[i+1] == '#': can1 = False
    for i in range(len(sb)-1):
        if sb[i] == '#' and sb[i+1] == '#': can2 = False
    can = can1 and can2

    if can and D < C:
        sc = S[B-1:D+2]
        can3 = False
        for i in range(len(sc)-2):
            if sc[i] == '.' and sc[i+1] == '.' and sc[i+2] == '.': can3 = True
        can = can and can3

    print('Yes' if can else 'No')
    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    #入力
    N, A, B, C, D = (int(_) for _ in input().split())
    S = input()

    sa, sb = S[A:C+1], S[B:D+1]
    can1 = can2 = True
    for i in range(len(sa)):
        if sa[i] == '#' and sa[i+1] == '#': can1 = False
    for i in range(len(sb)):
        if sb[i] == '#' and sb[i+1] == '#': can2 = False
    can = can1 and can2

    if can and D < C:
        sc = S[B-1:D]
        can3 = False
        for i in range(len(sc)-2):
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.': can3 = True
        can = can and can3

    print('Yes' if can else 'No')
    return

if __name__ == '__main__':
    main()
Problem p03041 (python)

Fixed submission:
n, k = [int(x) for x in input().split()]
s = input()
print(s[:k-1]+s[k-1].lower()+s[k:])

Buggy submission (verdict: Runtime Error):
n, k = [int(x) for x in input().split()]
s = input()
print(s[:k-1]+s[k].lower()+s[k+1:])
Problem p03745 (python)

Fixed submission:
def main():
    N = int(input())
    lst = [int(_) for _ in input().split()]
    last = lst[0]
    A = [last]
    for i in range(1, N):
        if lst[i] == last: continue
        last = lst[i]
        A.append(lst[i])
    left = right = output = 0
    while left < len(A):
        if left == len(A)-1:
            output += 1
            break
        if A[left+1] - A[left] > 0:
            while right < len(A)-1 and A[right] < A[right+1]:
                right += 1
        elif A[left+1] - A[left] < 0:
            while right < len(A)-1 and A[right] > A[right+1]:
                right += 1
        output += 1
        left = right + 1
        right = left
    print(output)
    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A_lst = [int(x) for x in input().split()]
B_lst =[]
for i in range(N - 1):
    B_lst.append(A_lst[i + 1] - A_lst[i])

def my_sign(n):
    return (n > 0) - (n < 0)

cnt = 1
i = 0
pm = my_sign(B_lst[0])
while True:
    if i >= len(B_lst) - 2:
        break
    else:
        if my_sign(B_lst[i + 1]) == 0:
            i += 1
            continue
        elif pm == my_sign(B_lst[i + 1]) or pm == 0:
            pm = my_sign(B_lst[i + 1])
            i += 1
            continue
        else:
            cnt += 1
            pm = my_sign(B_lst[i + 1])
            i +=2
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A_lst = [int(x) for x in input().split()]
B_lst =[]
for i in range(N - 1):
    B_lst.append(A_lst[i + 1] - A_lst[i])

def my_sign(n):
    return (n > 0) - (n < 0)

cnt = 1
i = 0
pm = my_sign(B_lst[0])
while True:
    if i >= len(B_lst) - 1:
        break
    else:
        if my_sign(B_lst[i + 1]) == 0:
            i += 1
            continue
        elif pm == my_sign(B_lst[i + 1]) or pm == 0:
            pm = my_sign(B_lst[i + 1])
            i += 1
            continue
        else:
            cnt += 1
            pm = my_sign(B_lst[i + 1])
            i +=2
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A_lst = [int(x) for x in input().split()]
B_lst =[]
for i in range(N - 1):
    B_lst.append(A_lst[i + 1] - A_lst[i])

def my_sign(n):
    return (n > 0) - (n < 0)

cnt = 1
i = 0
pm = my_sign(B_lst[0])
while True:
    if i >= len(B_lst) - 1:
        break
    else:
        if my_sign(B_lst[i + 1]) == 0:
            i += 1
            continue
        elif pm == my_sign(B_lst[i + 1]) or pm == 0:
            pm = my_sign(B_lst[i + 1])
            i += 1
            continue
        else:
            cnt += 1
            i +=2
print(cnt)
Problem p03834 (python)

Fixed submission:
a, b, c = input().split(',')
print(a, b, c)

Buggy submission (verdict: Runtime Error):
k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        for z in range(y, k + 1):
            if z > s:
                break
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 3
print(cnt)

Buggy submission (verdict: Runtime Error):
k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                cnt += 1
print(cnt)