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

Fixed submission:
A, B, C, D, E, F = map(int, input().split())

sugar_water = -1
sugar = -1
concentration = -1

for i in range(F//(A*100)+1):
    for j in range((F-A*100*i)//(B*100)+1):
        for k in range((F-A*i*100-B*100*j)//C+1):
            for l in range((F-A*i*100-B*100*j-C*k)//D+1):
                x = i * A + j * B
                y = k * C + l * D
                if x == 0:
                    continue
                if x * E >= y and concentration < (100 * y)/(x*100+y):
                    sugar_water = 100 * x + y
                    sugar = y
                    concentration = (100 * y)/(x*100+y)

print(sugar_water,sugar)

Buggy submission (verdict: Runtime Error):
def main():
    A, B, C, D, E, F = map(int, input().split())
    ans = 0
    for a in range(F // (A * 100) + 1):
        for b in range((F - 100 * A * a) // (B * 100) + 1):
            for c in range((F - 100 * A * a - 100 * B * b) // C + 1):
                for d in range((F - 100 * A * a - 100 * B * b - C * c) // D + 1):
                    x = a * A + b * B
                    y = c * C + d * D
                    if x == 0:
                        continue
                    if x * E >= y and ans < (100 * y)/(x*100+y):
                        ans = (100 * y)/(x*100+y)
                        sugar = y
                        sugar_water = 100 * x + y
    print(sugar_water,sugar)

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

Fixed submission:
X, t = map(int, input().split())

if X - t > 0:
    print(X - t)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
X, t = map(int, input().spilt())

if X - t > 0:
    print(X - t)
else:
    print(0)
Problem p03611 (python)

Fixed submission:
# 辞書を用意して最大値を取得する

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

cnt = {}

for i in a:
    for j in [-1,0,1]:
        cnt.setdefault(i+j, 0)
        cnt[i+j] += 1

print(max(cnt.values()))

Buggy submission (verdict: Runtime Error):
# 空の配列を用意して各要素の-1,0,+1を試して
# 値のインデックスに+1して最大値をとる

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

cnt = [0] * 100000

for i in a:
    for j in [-1,0,1]:
        cnt[i+j] += 1

print(max(cnt))
Problem p03614 (python)

Fixed submission:
def main():
    N = int(input())
    P = list(map(int, input().split()))    
    cnt = 0
    i = 0
    while i < N:
        if i + 1 == P[i]:
            if i == N - 1:
                cnt += 1
                i += 1
            else:
                if i + 2 == P[i+1]:
                    cnt += 1
                    i += 2
                else:
                    cnt += 1
                    i += 1
        else:
            i += 1

    print(cnt)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    P = list(map(int, input().split()))    
    cnt = 0
    i = 0
    while i < N:
        if i + 1 == P[i]:
            if i + 2 == P[i+1]:
                cnt += 1
                i += 2
            else:
                cnt += 1
                i += 1
        else:
            i += 1

    print(cnt)

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

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

a = [0] * M
b = [0] * M
for i in range(M):
    a[i],b[i] = map(int, input().split())

for i in range(1, N+1):
    print(a.count(i) + b.count(i))

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

ans = [0] * M

for i in range(M):
    a, b = map(int, input().split())
    ans[a-1] += 1
    ans[b-1] += 1

print(*ans, sep='\n')
Problem p03722 (python)

Fixed submission:

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

edges = []

for i in range(M):
    a, b, c = map(int, input().split())
    edges.append([a,b,c])

dist = [float('inf')] * (N + 1)
dist[1] = 0

for _ in range(N - 1):
    for a, b, c in edges:
        dist[b] = min(dist[b], dist[a] - c)

ans = dist[N]
for a, b, c in edges:
    dist[b] = min(dist[b], dist[a] - c)

if ans == dist[N]:
    print(-ans)
else:
    print('inf')

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    edges = []
    
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edges.append([a,b,c])

    d = [float('inf')] * N
    d[0] = 0

    for i in range(N-1):
        for edge in edges:
            d[edge[1]] = min(d[edge[1]], d[edge[0]] - edge[2])

    ans = d[N-1]
    for edge in edges:
        d[edge[1]] = min(d[edge[1]], d[edge[0]] - edge[2])

    if ans == d[N-1]:
        print(-ans)
    else:
        print(inf)


main()

Buggy submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    d = [[float('inf')] * N for _ in range(N)]
    edges = []
    
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        edges.append([a,b,c])

    d = [float('inf')] * N
    d[0] = 0

    for i in range(N-1):
        for edge in edges:
            d[edge[1]] = min(d[edge[1]], d[edge[0]] - edge[2])

    ans = d[N]
    for edge in edges:
        d[edge[1]] = min(d[edge[1]], d[edge[0]] - edge[2])

    if ans == d[N]:
        print(-ans)
    else:
        print(-1)


    

    
main()
Problem p03946 (python)

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

max_bef = 0
cnt = 0
A_min = A[0]

for i in range(1,N):
    tmp = A[i] - A_min
    if max_bef < tmp:
        max_bef = tmp
        cnt = 0
    if max_bef == tmp:
        cnt += 1
    A_min = min(A_min, A[i])

print(cnt)

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

max_bef = 0
cnt = 0
A_min = A[0]

for i in range(1,N):
    tmp = A[i] - A_min
    if max_bef < tmp:
        max_bef = tmp
        cnt = 1
    if max_bef == tmp:
        cnt += 1
    a_min = min(a_min, a[i])

print(cnt)
Problem p03994 (python)

Fixed submission:
def main():
    S = input()
    K = int(input())
    ans = ""
    for i, s in enumerate(S):
        tmp = ord(s) - ord('a')
        if i == len(S) - 1:
            ans += chr((tmp + K) % 26 + ord('a'))
        elif s == 'a':
            ans += s
        elif 26 - tmp <= K:
            ans += 'a'
            K -= 26 - tmp
        else:
            ans += s

    print(ans)
            


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S = list(input())
    K = int(input())
    L = len(S)
    for i in range(L):
        if ord('z') - ord(S[i]) + 1 <= K:
            K -= ord('z') - ord(S[i]) + 1
            S[i] = 'a'

    if K > 0:
        S[-1] = chr(ord(S[-1]) + K)

    print(''.join(S))




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

Fixed submission:
a,b,c=map(int,input().split())
print("YES") if b-a==c-b else print("NO")

Buggy submission (verdict: Runtime Error):
;

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split)
print("YES")if b-a==c-b else print("YES")
Problem p02642 (python)

Fixed submission:
from collections import Counter

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

c = Counter(A)
p = [True]*(10**6+1)

for k, v in c.items():
    t = k*2
    while t <= 10**6:
        p[t] = False
        t += k

ans = 0
for a in A:
    if c[a] == 1 and p[a]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):

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

A.sort()
a_list = [A[0]]
ans = 0
if A[0] != A[1]:
    ans += 1
for i in range(1, N):
    if A[i] == A[i-1]:
        continue
    for a in a_list:
        if A[i] % a == 0:
            break
    else:
        a_list.append(A[i])
        ans += 1

print(ans)
Problem p02696 (python)

Fixed submission:
import math

A, B, N = map(int, input().split())
x = min(B-1, N)
print(math.floor((A*x)/B)-A*(x//B))

Buggy submission (verdict: Runtime Error):
import math

A, B, N = map(int, input().split())
x = max(B-1, N)
print(math.floor((A*x)/B)-A*(x//B)
Problem p02982 (python)

Fixed submission:
import math
N, D = map(int, input().split())
X = []

for _ in range(N):
    X.append(list(map(int, input().split())))

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        sum = 0
        for k in range(D):
            sum += (X[i][k] - X[j][k])**2
        if math.sqrt(sum).is_integer():
            cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
N, D = map(int, input().split())
X = []

for _ in range(N):
    X.append(list(map(int, input().split())))

cnt = 0
for i in range(0, len(X)):
    sum = 0
    for j in range(0, len(X[i])):
        if i >= (len(X)-1):
            sum += X[i][j] - X[0][j]
        else:
            sum += (X[i][j] - X[i+1][j])**2

    if math.sqrt(sum).is_integer():
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
N, D = map(int, input().split())
X = []

for _ in range(N):
    X.append(list(map(int, input().split())))

cnt = 0
for i in range(0, len(X)):
    sum = 0
    for j in range(0, len(X[i])):
        if i >= len(X[i]):
            sum += X[i][j] - X[0][j]
        else:
            sum += (X[i][j] - X[i+1][j])**2

    if math.sqrt(sum).is_integer():
        cnt += 1
print(cnt)
Problem p02995 (python)

Fixed submission:
import fractions

A, B, C, D = map(int, input().split())

lcm = (C*D)//fractions.gcd(C, D)

a = ((A-1)//C+(A-1)//D)-(A-1)//lcm
b = (B//C+B//D)-B//lcm

print((B-A+1)-(b-a))

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())

lcm = (C*D)//math.gcd(C, D)

a = ((A-1)//C+(A-1)//D)-(A-1)//lcm
b = (B//C+B//D)-B//lcm

print((B-A+1)-(b-a))
Problem p03106 (python)

Fixed submission:
import fractions

a, b, k = map(int, input().split())
gcd = fractions.gcd(a, b)
divisor_list = []

if gcd == 1:
    divisor_list = [1]
else:
    divisor_list.append(1)
    for i in range(2, gcd // 2 + 1):
        if gcd % i == 0:
            divisor_list.append(i)
    divisor_list.append(gcd)

print(divisor_list[len(divisor_list)-1-k+1])

Buggy submission (verdict: Runtime Error):
import math

a, b, k = map(int, input().split())
gcd = math.gcd(a, b)
divisor_list = []

if gcd == 1:
    divisor_list = [1]
else:
    divisor_list.append(1)
    for i in range(2, gcd // 2 + 1):
        if gcd % i == 0:
            divisor_list.append(i)
    divisor_list.append(gcd)

print(divisor_list[len(divisor_list)-1-k+1])
Problem p03231 (python)

Fixed submission:
import fractions

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

# 最小公倍数を求める
l = (N * M) // fractions.gcd(N, M)

ans = {1: S[0]}
for i in range(1, N):
    c_num = i*l//N+1
    ans[c_num] = S[i]

for i in range(M):
    if i == 1:
        if ans[1] != T[0]:
            print(-1)
            exit(0)

    c_num = i*l//M+1
    if c_num in ans:
        if ans[c_num] != T[i]:
            print(-1)
            exit(0)
    else:
        ans[c_num] = T[i]
print(l)

Buggy submission (verdict: Runtime Error):
import math

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

# 最小公倍数を求める
l = (N * M) // math.gcd(N, M)

ans = {1: S[0]}
for i in range(1, N):
    c_num = i*l//N+1
    ans[c_num] = S[i]

for i in range(M):
    if i == 1:
        if ans[1] != T[0]:
            print(-1)
            exit(0)

    c_num = i*l//M+1
    if c_num in ans:
        if ans[c_num] != T[i]:
            print(-1)
            exit(0)
    else:
        ans[c_num] = T[i]
print(l)
Problem p03261 (python)

Fixed submission:
N = int(input())
W = []
ans = True
for i in range(N):
    tmp = input()
    if tmp in W and i != 0:
        ans = False
    W.append(tmp)

if ans:
    last_word = W[0][-1]
    for i in range(1, N):
        if last_word != W[i][0]:
            ans = False
        last_word = W[i][-1]

print("Yes" if ans else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
W = []
for i in range(N):
    tmp = input()
    if tmp in W and i != 0:
        print("No")
        exit()
    W.append(tmp)

last_word = W[0][-1]
for i in range(1, len(N)):
    if last_word != W[i][0]:
        print("No")
        exit()
print("Yes")
Problem p03262 (python)

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


N, X = map(int, input().split())
xl = list(map(int, input().split()))

if N == 1:
    print(abs(X-xl[0]))
    exit(0)

xl.append(X)
xl.sort()

k = []
for i in range(1, N+1):
    tmp = xl[i]-xl[i-1]
    if not(tmp in k):
        k.append(tmp)

if len(k) == 1:
    print(k[0])
elif len(k) == 2:
    ans = gcd(k[0], k[1])
    print(ans)
else:
    ans = gcd(k[0], k[1])
    for i in range(2, len(k)):
        ans = gcd(ans, k[i])
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


N, X = map(int, input().split())
xl = list(map(int, input().split()))

if N == 1:
    print(abs(X-xl[0]))
    exit(0)

xl.append(X)
xl.sort()

k = []
for i in range(1, N):
    tmp = xl[i]-xl[i-1]
    if not(tmp in k):
        k.append(tmp)

if len(k) <= 1:
    print(k[0])
else:
    print(gcd_list(k))
Problem p03283 (python)

Fixed submission:
n, m, Q = map(int, input().split())
M = [[0]*n for _ in range(n)]
for i in range(m):
    l, r = map(int, input().split())
    M[r-1][l-1] += 1

for q in range(n):
    for p in reversed(range(1, n)):
        M[q][p-1] += M[q][p]
for p in range(n):
    for q in range(n-1):
        M[q+1][p] += M[q][p]

for i in range(Q):
    p, q = map(int, input().split())
    print(M[q-1][p-1])

Buggy submission (verdict: Runtime Error):
n, m, q = map(int, input().split())
cumlr = [[0] * n for i in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    cumlr[l-1][r-1] += 1

for i in range(n):
    for j in reversed(range(1, n)):
        cumlr[i][j-1] += cumlr[i][j]
for i in range(n):
    for j in range(n-1):
        cumlr[j+1][i] += cumlr[j][i]

for _ in range(q):
    l, r = map(int, input().split())
    print(cumlr[r-1][q-1])

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

cumlr = [[0] * n for i in range(n)]
for _ in range(m):
    l, r = map(int, input().split())
    cumlr[l-1][r-1] += 1

for i in range(n):
    for j in reversed(range(1, n)):
        cumlr[i][j-1] += cumlr[i][j]

for i in range(n):
    for j in range(n-1):
        cumlr[j+1][i] += cumlr[j][i]


for _ in range(q):
    l, r = map(int, input().split())
    print(cumlr[r-1][q-1])

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

Fixed submission:
n = int(input())
if n%10==0:
    print(10)
    exit(0)
ans = pow(10,10)
for a in range(n+1):
    b = n-a
    tmp_ans = 0

    for sa in str(a):
        tmp_ans += int(sa)

    for sb in str(b):
        tmp_ans += int(sb)

    ans = min(ans, tmp_ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n = input().split()
if n[0] == 1 and sum(n):
    print(10)
else:
    print(sum(n))
Problem p03393 (python)

Fixed submission:
import string

S = input()
abc = string.ascii_lowercase

if len(S) == 26:
    for i in range(24, -1, -1):
        cand = list(S[i+1:])
        cand.sort()
        for c in cand:
            if ord(c) > ord(S[i]):
                print(S[:i]+c)
                exit(0)
    print(-1)
else:
    for l in abc:
        if l not in S:
            print(S+l)
            exit()

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

if ''.join(S) == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit(0)

if len(S) != 26:
    for a in alp:
        if not(a in S):
            print(''.join(S) + a)
            exit(0)

for i in range(len(S)):
    if alp.index(S[i]) > alp.index(S[i+1]):
        #S[i] = S[i+1]
        print(''.join(S[:i-1])+alp[i])
        exit(0)
Problem p03544 (python)

Fixed submission:
n = int(input())
n0 = 2
n1 = 1

if n == 1:
    print(1)
else:
    for _ in range(1, n):
        n2 = n0+n1
        n0, n1 = n1, n2
    print(n2)

Buggy submission (verdict: Runtime Error):
n = int(input())
n0 = 2
n1 = 1

if n == 1:
    print(1)
else:
    for _ in range(1, n):
        n0, n1 = n1, n0+n1
    print(n2)

Buggy submission (verdict: Runtime Error):
n = int(input())
n0 = 2
n1 = 1

for _ in range(1, n):
    n2 = n0+n1
    n0, n1 = n1, n2
print(n2)
Problem p03574 (python)

Fixed submission:
h, w = map(int, input().split())
hwl = []
for _ in range(h):
    l = list(input())
    hwl.append(l)

for i in range(h):
    for j in range(w):
        if hwl[i][j] == ".":
            cnt = 0
            if i != 0 and j != 0 and hwl[i-1][j-1] == "#":
                cnt += 1
            if i != 0 and hwl[i-1][j] == "#":
                cnt += 1
            if i != 0 and j < w-1 and hwl[i-1][j+1] == "#":
                cnt += 1
            if j != 0 and hwl[i][j-1] == "#":
                cnt += 1
            if j < w-1 and hwl[i][j+1] == "#":
                cnt += 1
            if i < h-1 and j != 0 and hwl[i+1][j-1] == "#":
                cnt += 1
            if i < h-1 and hwl[i+1][j] == "#":
                cnt += 1
            if i < h-1 and j < w-1 and hwl[i+1][j+1] == "#":
                cnt += 1
            hwl[i][j] = str(cnt)
    print("".join(hwl[i]))

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
hwl = []
for _ in range(h):
    l = list(input())
    hwl.append(l)

for i in range(h):
    for j in range(w):
        if hwl[i][j] == ".":
            cnt = 0
            if i != 0 and j != 0 and hwl[i-1][j-1] == "#":
                cnt += 1
            if i != 0 and hwl[i-1][j] == "#":
                cnt += 1
            if i != 0 and j < w-1 and hwl[i-1][j+1] == "#":
                cnt += 1
            if j != 0 and hwl[i][j-1] == "#":
                cnt += 1
            if j < w-1 and hwl[i][j+1] == "#":
                cnt += 1
            if i < h-1 and j != 0 and hwl[i+1][j-1] == "#":
                cnt += 1
            if i < h-1 and hwl[i+1][j] == "#":
                cnt += 1
            if i < h-1 and j < h-1 and hwl[i+1][j+1] == "#":
                cnt += 1
            hwl[i][j] = str(cnt)
    print("".join(hwl[i]))

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
hwl = []
for _ in range(h):
    l = list(input())
    hwl.append(l)

for i in range(h):
    for j in range(w):
        if hwl[i][j] == ".":
            cnt = 0
            if i != 0 and j != 0 and hwl[i-1][j-1] == "#":
                cnt += 1
            if i != 0 and hwl[i-1][j] == "#":
                cnt += 1
            if i != 0 and j < w-1 and hwl[i-1][j+1] == "#":
                cnt += 1
            if j != 0 and hwl[i][j-1] == "#":
                cnt += 1
            if hwl[i][j] == "#":
                cnt += 1
            if j < w-1 and hwl[i][j+1] == "#":
                cnt += 1
            if i < h-1 and j != 0 and hwl[i+1][j-1] == "#":
                cnt += 1
            if i < h-1 and hwl[i+1][j] == "#":
                cnt += 1
            if i < h-1 and j < h-1 and hwl[i+1][j+1] == "#":
                cnt += 1
            hwl[i][j] = str(cnt)
    print("".join(hwl[i]))
Problem p03633 (python)

Fixed submission:
import sys
import fractions


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
ans = 0
for _ in range(N):
    if ans == 0:
        ans = int(input())
    else:
        t = int(input())
        ans = (ans * t) // fractions.gcd(ans, t)
print(ans)

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


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
ans = 0
for _ in range(N):
    if ans == 0:
        ans = int(input())
    else:
        t = int(input())
        ans = (ans * t) // math.gcd(ans, t)
print(ans)
Problem p03695 (python)

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

cnt = [0]*8
ziyu = 0
for a in A:
    if 1 <= a <= 399 and cnt[0] == 0:
        cnt[0] = 1
    elif 400 <= a <= 799 and cnt[1] == 0:
        cnt[1] = 1
    elif 800 <= a < 1199 and cnt[2] == 0:
        cnt[2] = 1
    elif 1200 <= a <= 1599 and cnt[3] == 0:
        cnt[3] = 1
    elif 1600 <= a <= 1999 and cnt[4] == 0:
        cnt[4] = 1
    elif 2000 <= a <= 2399 and cnt[5] == 0:
        cnt[5] = 1
    elif 2400 <= a <= 2799 and cnt[6] == 0:
        cnt[6] = 1
    elif 2800 <= a <= 3199 and cnt[7] == 0:
        cnt[7] = 1
    elif a >= 3200:
        ziyu += 1

min_cnt = 0
if ziyu > 0:
    min_cnt = 1

print(max(min_cnt, sum(cnt)), sum(cnt)+ziyu)

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

cnt = [0]*7
ziyu = 0
for a in A:
    if 1 <= a <= 399 and cnt[0] == 0:
        cnt[0] = 1
    elif 400 <= a <= 799 and cnt[1] == 0:
        cnt[1] = 1
    elif 800 <= a < 1199 and cnt[2] == 0:
        cnt[2] = 1
    elif 1200 <= a <= 1599 and cnt[3] == 0:
        cnt[3] = 1
    elif 1600 <= a <= 1999 and cnt[4] == 0:
        cnt[4] = 1
    elif 2000 <= a <= 2399 and cnt[5] == 0:
        cnt[5] = 1
    elif 2400 <= a <= 2799 and cnt[6] == 0:
        cnt[6] = 1
    elif 2800 <= a <= 3199 and cnt[7] == 0:
        cnt[7] = 1
    elif a <= 3200:
        ziyu += 1

min_cnt = 0
if ziyu > 0:
    min_cnt = 1

print(max(min_cnt, sum(cnt)), sum(cnt)+ziyu)
Problem p03957 (python)

Fixed submission:
s = input()
if s.find('C') >= 0 and s.find('F') >= 0:
    if s.index('C') < s.rindex('F'):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
if s.index('C') >= 0 and s.index('F') >= 0:
    if s.index('C') < s.rindex('F'):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
if s.index('C') >= 0 and s.index('F') >= 0 and s.index('C') < s.index('F'):
    print('Yes')
else:
    print('No')
Problem p03074 (python)

Fixed submission:
import math
 
N,K = (int(x) for x in input().split())
S = input()
 
list1 = []
now = 1
count = 0
 
for i in range(N):
    if now == int(S[i]):
        count += 1
    else:
        list1.append(count)
        now = 1-now
        count = 1
else:
    list1.append(count)

if len(list1) % 2 == 0:
    list1.append(0)
 
tmp=0
left=0
right=0
ans=0
for i in range(0,len(list1),2):
    nextleft = i
    while left<nextleft:
        tmp = tmp - list1[left]
        left = left + 1
 
    nextright = min(i+2*K+1,len(list1))
    while right<nextright:
        tmp = tmp + list1[right]
        right = right + 1

    ans=max(ans,tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
 
N,K = (int(x) for x in input().split())
S = input()
 
list1 = []
now = 1
count = 0
 
for i in range(N):
    if now == int(S[i]):
        count += 1
    else:
        list1.append(count)
        now = 1-now
        count = 1
else:
    list1.append(count)

if len(list1) % 2 == 0:
    list1.append(0) 
tmp=0
left=0
right=0
ans=0
for i in range(0,len(list1),2):
    nextleft = i
    while left<nextleft:
        tmp = tmp - list1[left]
        left = left + 1

nextright = min(i+2*K+1,len(list1))
while right<nextright:
    tmp = tmp + list1[right]
    right = right + 1

ans=max(ans,tmp)print(ans)

print(ans)