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

Fixed submission:
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
s = [0]
for ai in a:
    s.append(ai + s[-1])

def count(x, accum=False):
    ret = 0
    for ai in a:
        lo, hi = -1, n
        while hi - lo > 1:
            mid = (lo + hi) // 2
            if ai + a[mid] >= x:
                lo = mid
            else:
                hi = mid
        ret += ai * hi + s[hi] if accum else hi
    return ret

lo, hi = 0, 1000000000
while hi - lo > 1:
    mid = (lo + hi) // 2
    if count(mid) >= m:
        lo = mid
    else:
        hi = mid

print(count(lo, accum=True) - (count(lo) - m) * lo)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
s = a[0]
t = 0
j = 1
ret = 0
for i in range(n):
    s -= a[i]
    ret += a[i] * 2
    m -= 1
    while j < n and (i >= n - 1 or a[i + 1] + a[i + 1] <= a[i] + a[j]):
        if m < i * 2:
            for k in range(i):
                if m > 0:
                    ret += a[j] + a[k]
                    m -= 1
                if m > 0:
                    ret += a[j] + a[k]
                    m -= 1
        else:
            ret += a[j] * i * 2 + t * 2
            m -= i * 2
        s += a[j]
        j += 1
    num = (j - i - 1) * 2
    if m <= num:
        for k in range(i + 1, j):
            if m > 0:
                ret += a[i] + a[k]
                m -= 1
            if m > 0:
                ret += a[i] + a[k]
                m -= 1
        break
    m -= num
    ret += s * 2 + a[i] * num
    t += a[i]
    print(a, m, num, s, i, j, ret)
print(ret)
Problem p02850 (python)

Fixed submission:
import sys

sys.setrecursionlimit(100000)

n = int(input())
edges = [[] for _ in range(n)]
color = [0 for _ in range(n - 1)]
for e in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append((b - 1, e))
    edges[b - 1].append((a - 1, e))

def dfs(i, p, pcol):
    col = 1
    ret = 0
    for c, e in edges[i]:
        if c != p:
            if col == pcol:
                col += 1
            color[e] = col
            ret = max(ret, dfs(c, i, col))
            col += 1
    return max(ret, col - 1)

print(dfs(0, -1, -1))
for i in range(n - 1):
    print(color[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
edges = [[] for _ in range(n)]
color = [0 for _ in range(n - 1)]
for e in range(n - 1):
    a, b = map(int, input().split())
    edges[a - 1].append((b - 1, e))
    edges[b - 1].append((a - 1, e))

def dfs(i, p, pcol):
    col = 1
    ret = 0
    for c, e in edges[i]:
        if c != p:
            if col == pcol:
                col += 1
            color[e] = col
            ret = max(ret, dfs(c, i, col))
            col += 1
    return max(ret, col - 1)

print(dfs(0, -1, -1))
for i in range(n - 1):
    print(color[i])
Problem p02902 (python)

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

ret = [0] * (n + 1)
for start in range(n):
    parent = [-1] * n
    q = [start]
    while len(q) > 0:
        i = q.pop(0)
        for j in edges[i]:
            if j == start:
                loop = [i]
                while i != start:
                    i = parent[i]
                    loop.append(i)
                if len(ret) > len(loop):
                    ret = loop
                break
            if parent[j] == -1:
                parent[j] = i
                q.append(j)

if len(ret) > n:
    print(-1)
else:
    print(len(ret))
    for i in reversed(ret):
        print(i + 1)

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

def dfs(index, visited):
    visited[index] = True
    for i in edges[index]:
        if visited.get(i):
            return [i]
        ret = dfs(i, visited)
        if ret:
            return [i] + ret
    visited[index] = False
    return None

def find_local_minimum(cycle):
    n = len(cycle)
    ind = {v: i for (i, v) in zip(range(n), cycle)}
    ret = []
    i = 0
    while True:
        ret.append(i)
        nxt = 0
        for j in [ind[v] for v in edges[cycle[i]] if v in ind]:
            if j < i:
                j += n
            nxt = max(nxt, j)
        if nxt >= n:
            ret = ret[ret.index(nxt % n):]
            break
        i += 1
        while i < nxt:
            del ind[cycle[i]]
            i += 1
    return [cycle[i % n] for i in ret]

cycle = None
visited = {}
for start in range(n):
    if start not in visited:
        cycle = dfs(start, visited)
        if cycle:
            break

if cycle:
    ret = find_local_minimum(cycle)
    print(len(ret))
    for i in ret:
        print(i + 1)
else:
    print(-1)

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

ret = [0] * (n + 1)
parent = [-1] * n
for start in range(n):
    q = [start]
    parent[start] = start
    while len(q) > 0:
        i = q.pop(0)
        for j in edges[i]:
            if parent[j] = j:
                loop = [i]
                while parent[i] != i:
                    i = parent[i]
                    loop.append(i)
                if i == start and len(ret) > len(loop):
                    ret = loop
                break
            if parent[j] == -1:
                parent[j] = i
                q.append(j)

if len(ret) > n:
    print(-1)
else:
    print(len(ret))
    for i in reversed(ret):
        print(i + 1)
Problem p02949 (python)

Fixed submission:
n, m, p = map(int, input().split())
abcs = [list(map(int, input().split())) for _ in range(m)]
distance = [-1000000 * n] * (n + 1)

distance[1] = 0
reachable1 = set([1])
reachableN = set([n])
for _ in range(n + 1):
    for a, b, c in abcs:
        if distance[b] < distance[a] + c - p:
            distance[b] = distance[a] + c - p
        # 枝刈りが必要                                                                                                                                                                                                                
        if a in reachable1:
            reachable1.add(b)
        if b in reachableN:
            reachableN.add(a)

for a, b, c in abcs:
    if (distance[b] < distance[a] + c - p) and (a in reachable1) and (b in reachableN):
        print(-1)
        exit(0)

print(max(distance[n], 0))

Buggy submission (verdict: Runtime Error):
, m, p = map(int, input().split())
abcs = [list(map(int, input().split())) for _ in range(m)]
distance = [-100000 * n] * (n + 1)

distance[1] = 0
for _ in range(n + 1):
    for a, b, c in abcs:
        if distance[b] < distance[a] + c - p:
            distance[b] = distance[a] + c - p

ret = distance[n]
for _ in range(n + 1):
    for a, b, c in abcs:
        if distance[b] < distance[a] + c - p:
            distance[b] = distance[a] + c - p

print(-1 if ret != distance[n] else max(ret, 0))
Problem p02975 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
def doit(a):
    c = {}
    for ai in a:
        c[ai] = c.get(ai, 0) + 1
    if len(c) > 3:
        return "No"
    k = list(sorted(c.keys()))
    if len(k) == 1:
        if k[0] == 0:
            return "Yes"
    if len(k) == 2:
        if k[0] == 0 and c[k[0]] * 2 == c[k[1]]:
            return "Yes"
    if len(k) == 3:
        if c[k[0]] == c[k[1]] == c[k[2]] and k[0] ^ k[1] == k[2]:
            return "Yes"
    return "No"

print(doit(sorted(a)))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100001)

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
visited = [False] * n
for _ in range(m):
    a, b = map(int, input().split())
    la = len(edges[a - 1])
    lb = len(edges[b - 1])
    edges[a - 1].append([b - 1, lb])
    edges[b - 1].append([a - 1, la])

def dfs(p, v):
    visited[v] = True
    for (i, r) in edges[v]:
        if not visited[i] and r != -1 and i != p:
            dfs(v, i)
    odd = False
    pr = -1
    for (i, r) in edges[v]:
        if i != p:
            if r != -1:
                edges[i][r][1] = -1
                odd = not odd
        else:
            pr = r
    if odd:
        edges[p][pr][1] = -1

if m % 2 == 1:
    print(-1)
else:
    dfs(-1, 0)
    for v in range(n):
        for (i, r) in edges[v]:
            if r >= 0:
                print(v + 1, i + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
def doit(a):
    c = {}
    for ai in a:
        c[ai] = c.get(ai, 0) + 1
    if len(c) > 3:
	return "No"
    k = list(sorted(c.keys()))
    if len(k) == 1:
	if k[0] == 0:
            return "Yes"
    if len(k) == 2:
	if k[0] == 0 and c[k[0]] * 2 == c[k[1]]:
            return "Yes"
    if len(k) == 3:
	if c[k[0]] == c[k[1]] == c[k[2]] and k[0] ^ k[1] == k[2]:
            return "Yes"
    return "No"

print(doit(sorted(a)))
Problem p03006 (python)

Fixed submission:
n = int(input())
c = [tuple(map(int, input().split())) for _ in range(n)]
s = {(0, 0): 0}
for i in range(n):
    for j in range(n):
        if i != j:
            (p, q) = [b - a for a, b in zip(c[i], c[j])]
            s[(p, q)] = s.get((p, q), 0) + 1
print(n - max(s.values()))

Buggy submission (verdict: Runtime Error):
n = int(input())
c = [tuple(map(int, input().split())) for _ in range(n)]
s = {}
for i in range(n):
    for j in range(i + 1, n):
        (p, q) = [b - a for a, b in zip(c[i], c[j])]
        s[(p, q)] = s.get((p, q), 0) + 1
print(n - max(s.values()))
Problem p03040 (python)

Fixed submission:
import heapq

q = int(input())
inf = 10000000000
left = [inf]
right = [inf]
minval = 0
for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 1:
        _, a, b = query
        if a < -left[0]:
            v = -heapq.heappop(left)
            heapq.heappush(right, v)
            heapq.heappush(left, -a)
            heapq.heappush(left, -a)
            minval += abs(v - a) + b
        elif a > right[0]:
            v = heapq.heappop(right)
            heapq.heappush(left, -v)
            heapq.heappush(right, a)
            heapq.heappush(right, a)
            minval += abs(v - a) + b
        else:
            heapq.heappush(left, -a)
            heapq.heappush(right, a)
            minval += b
    else:
        print(-left[0], minval)

Buggy submission (verdict: Runtime Error):
import heapq

q = int(input())
inf = 10000000000
left = [inf]
right = [inf]
minval = 0
for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 1:
        _, a, b = query
        if a < -left[0]:
            v = -heapq.heappop(left)
            heapq.heappush(right, v)
            heapq.heappush(left, -a)
            heapq.heappush(left, -a)
            minval += abs(v - a) + b
        elif a > right[0]:
            v = heapq.heappop(roght)
            heapq.heappush(left, -v)
            heapq.heappush(right, a)
            heapq.heappush(right, a)
            minval += abs(v - a) + b
        else:
            heapq.heappush(left, -a)
            heapq.heappush(right, a)
            minval += b
    else:
        print(right[0], minval)
Problem p03061 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
def gcd(a, b):
    return b if a == 0 else gcd(b % a, a)
l = [0]
r = [0]
for i in range(n):
    l.append(gcd(l[-1], a[i]))
    r.append(gcd(r[-1], a[n - i - 1]))
ret = 0
for i in range(n):
    ret = max(ret, gcd(l[i], r[n - i - 1]))
print(ret)

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

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

memo = {}
def doit(i, f):
    if i == len(a) - 1:
        return a[i]
    if not (i, f) in memo:
        ret = gcd(a[i], doit(i + 1, f))
        if f == 0:
            ret = max(ret, doit(i + 1, 1))
        memo[(i, f)] = ret
    return memo[(i, f)]

print(doit(0, 0))
Problem p03081 (python)

Fixed submission:
n, q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(q)];
left, right = 0, n
for t, d in reversed(td):
    if d == 'L':
        if left < n and s[left] == t:
            left += 1
        if right < n and s[right] == t:
            right += 1
    elif d == 'R':
        if left > 0 and s[left - 1] == t:
            left -= 1
        if right > 0 and s[right - 1] == t:
            right -= 1
print max(0, right - left)

Buggy submission (verdict: Runtime Error):
n, q = map(int, raw_input().split())
s = raw_input()
td = [raw_input().split() for _ in range(q)];
left, right = 0, n
for t, d in reversed(td):
    if d == 'L':
        if left < n and s[left] == t:
            left += 1
        if right < n and s[right] == t:
            right += 1
    elif d == 'R':
        if left > 0 and s[left - 1] == t:
            left -= 1
        if right > 0 and s[right - 1] == t:
            right -= 1
print(max(0, right - left))
Problem p03112 (python)

Fixed submission:
a, b, q = map(int, input().split())
s = [int(input()) for _ in range(a)]
t = [int(input()) for _ in range(b)]

s = sorted(s)
t = sorted(t)
st = []
(i, j) = (0, 0)
while i < len(s) or j < len(t):
    if j == len(t) or (i < len(s) and s[i] < t[j]):
        st.append((s[i], min(abs(s[i] - t[max(j - 1, 0)]),
                             abs(s[i] - t[min(j, len(t) - 1)]))))
        i += 1
    else:
        st.append((t[j], min(abs(t[j] - s[max(i - 1, 0)]),
                             abs(t[j] - s[min(i, len(s) - 1)]))))
        j += 1

def doit(x):
    lo, hi = 0, len(st) - 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if st[mid][0] < x:
            lo = mid
        else:
            hi = mid
    mid = (lo + hi) // 2
    return min(abs(st[mid][0] - x) + st[mid][1], abs(st[mid + 1][0] - x) + st[mid + 1][1])

for _ in range(q):
    print(doit(int(input())))

Buggy submission (verdict: Runtime Error):
a, b, q = map(int, input().split())
s = sorted(int(input()) for _ in range(a))
t = sorted(int(input()) for _ in range(b))

st = []
(i, j) = (0, 0)
while i < len(s) or j < len(t):
    if j == len(t) or (i < len(s) and s[i] < t[j]):
        st.append((s[i], min(abs(s[i] - t[max(j - 1, 0)]),
                             abs(s[i] - t[min(j, len(t) - 1)]))))
        i += 1
    else:
        st.append((t[j], min(abs(t[j] - s[max(i - 1, 0)]),
                             abs(t[j] - s[min(i, len(s) - 1)]))))
        j += 1
    print(i, j, s, t, st)
print(st)

def doit(x):
    lo, hi = 0, len(st) - 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        if st[mid][0] < x:
            lo = mid
        else:
            hi = mid
    mid = (lo + hi) // 2
    return min(abs(st[mid][0] - x) + st[mid][1], abs(st[mid + 1][0] - x) + st[mid + 1][1])

for _ in range(q):
    print(doit(int(input())))
Problem p03128 (python)

Fixed submission:
import sys

sys.setrecursionlimit(100000)

n, m = map(int, input().split())
a = list(map(int, input().split()))
memo = {}
matches = [100, 2, 5, 5, 4, 5, 6, 3, 7, 6]

def doit(n):
    if n == 0:
        return ""
    if not n in memo:
        ret = None
        for d in a:
            m = matches[d]
            if n - m >= 0 and doit(n - m) is not None:
                r = max(doit(n - m) + str(d), str(d) + doit(n - m))
                if ret is None or len(r) > len(ret) or len(r) == len(ret) and r > ret:
                    ret = r
        memo[n] = ret
    return memo[n]

print(doit(n))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
memo = {}
matches = [100, 2, 5, 5, 4, 5, 6, 3, 7, 6]

def doit(n):
    if n == 0:
        return ""
    if not n in memo:
        ret = None
        for d in a:
            m = matches[d]
            if n - m >= 0 and doit(n - m) is not None:
                r = max(doit(n - m) + str(d), str(d) + doit(n - m))
                if ret is None or len(r) > len(ret) or len(r) == len(ret) and r > ret:
                    ret = r
        memo[n] = ret
    return memo[n]

print(doit(n))
Problem p03148 (python)

Fixed submission:
n, k = map(int, input().split())
td = list(sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda td: -td[1]))
td2 = []
eaten = set()
dup = 0
score = k * k
i = 0
j = 0
while len(eaten) + dup < k:
    if i < n and td[i][0] in eaten:
        td2.append(td[i])
        i += 1
    else:
        diff = (k - dup) * (k - dup) - (k - dup - 1) * (k - dup - 1)
        if i < n and (j >= len(td2) or td[i][1] >= td2[j][1] - diff):
            t, d = td[i]
            score += d
            eaten.add(t)
            i += 1
        else:
            t, d = td2[j]
            score += d - diff
            dup += 1
            j += 1
print(score)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
td = list(sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda td: -td[1]))
td2 = []
eaten = set()
dup = 0
score = k * k
i = 0
j = 0
while len(eaten) + dup < k:
    if td[i][0] in eaten:
        td2.append(td[i])
        i += 1
    else:
        diff = (k - dup) * (k - dup) - (k - dup - 1) * (k - dup - 1)
        if i < n and (j >= len(td2) or td[i][1] >= td2[j][1] - diff):
            t, d = td[i]
            score += d
            eaten.add(t)
            i += 1
        else:
            t, d = td2[j]
            score += d - diff
            dup += 1
            j += 1
print(score)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
td = list(sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda td: -td[1]))
td2 = []
eaten = set()
dup = 0
score = k * k
while len(eaten) + dup < k:
    if td[0][0] in eaten:
        td2.append(td.pop(0))
    else:
        diff = (k - dup) * (k - dup) - (k - dup - 1) * (k - dup - 1)
        if not td2 or td[0][1] >= td2[0][1] - diff:
            t, d = td.pop(0)
            score += d
            eaten.add(t)
        else:
            t, d = td2.pop(0)
            score += d - diff
            dup += 1

print(score)
Problem p03251 (python)

Fixed submission:
n, m, x, y = map(int, input().split())
xs = map(int, input().split())
ys = map(int, input().split())
print("No War" if max([x] + list(xs)) < min([y] + list(ys)) else "War")

Buggy submission (verdict: Runtime Error):
n, m, x, y = map(int, input().split())
xs = map(int, input().split())
ys = map(int, input().split())
if max([x] + list(xs)) < min([y] + list(ys)):
    print "No War"
else:
    print "War"
Problem p03263 (python)

Fixed submission:
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
r, c, d = 0, 0, 3
ret = []
for y in range(h * w - 1):
    if y % w == 0:
        d = (d + 1) % 4
    if y % w == w - 1:
        d = (d + 1) % 4
    dy, dx = [(0, 1), (1, 0), (0, -1), (1, 0)][d]
    if a[r][c] % 2 != 0:
        ret.append((r, c, r + dy, c + dx))
        a[r + dy][c + dx] += 1
    r, c = r + dy, c + dx
print(len(ret))
for r1, c1, r2, c2 in ret:
    print(r1 + 1, c1 + 1, r2 + 1, c2 + 1)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
r, c, d = 0, 0, 3
ret = []
for y in range(h * w - 1):
    if y % w == 0 or y % w == w - 1:
        d = (d + 1) % 4
    dy, dx = [(0, 1), (1, 0), (0, -1), (1, 0)][d]
    if a[r][c] % 2 != 0:
        ret.append((r, c, r + dy, c + dx))
        a[r + dy][c + dx] += 1
    r, c = r + dy, c + dx
print(len(ret))
for r1, c1, r2, c2 in ret:
    print(r1 + 1, c1 + 1, r2 + 1, c2 + 1)
Problem p03274 (python)

Fixed submission:
n, k = map(int, input().split())
x = sorted(map(int, input().split()))
ret = 1000000000000000000
for s in range(n - k + 1):
    e = s + k - 1
    if x[e] <= 0:
        ret = min(ret, -x[s])
    elif x[s] <= 0:
        ret = min(ret, x[e] - x[s] + min(-x[s], x[e]))
    else:
        ret = min(ret, x[e])
print(ret)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = sorted(map(int, input().split()))
ret = 1000000000000000000
for s in range(n - k + 1):
    e = s + k - 1
    if x[e] <= 0:
	ret = min(ret, -x[s])
    elif x[s] <= 0:
	ret = min(ret, x[e] - x[s] + min(-x[s], x[e]))
    else:
        ret = min(ret, x[e])
print(ret)
Problem p03220 (python)

Fixed submission:
def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))

    ans = 0
    temp = float('inf')
    for i in range(n):
        if temp > abs(a - (t - h[i] * 0.006)):
            temp = abs(a - (t - h[i] * 0.006))
            ans = i + 1
        
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    n = int(input())
    t, a = map(int, input().split())
    h = list(map(int, input().split()))

    ans = 0
    temp = math.inf
    for i in range(n):
        if temp > abs(a - (t - h[i] * 0.006)):
            temp = abs(a - (t - h[i] * 0.006))
            ans = i + 1
        
    print(ans)

main()
Problem p02818 (python)

Fixed submission:
a, b, k = [int(i) for i in input().split(" ")]
if a >= k:
    print("%d %d" % (a - k, b))
else: # a < k
    print("%d %d" % (0, max([b + (a - k), 0])))

Buggy submission (verdict: Runtime Error):
a, b, k = [int(i) for i in input().split(" ")]
if a >= k:
    print("%d %d" % (a - k, b))
else: # a < k
    print("%d %d" % (0, max([b + (a - k), 0]))
Problem p02767 (python)

Fixed submission:
import sys

num = []

while True:
    try:
        num.extend([int(n) for n in input().split()])
    except EOFError:
        break
    
s = sum(num[1:num[0]+1])/num[0]
s = round(s)
r = 0
for i in range(1,num[0]+1):
    r += pow(num[i]-s,2)
print(r)

Buggy submission (verdict: Runtime Error):
num = [int(n) for n in input().split()] 
    
s = sum(num[1:num[0]+1])/num[0]
s = round(s)
r = 0
for i in range(1,num[0]+1):
    r += pow(num[i]-s,2)
print(r)

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

num = [int(n) for n in input().split()] 
    
s = sum(num[1:num[0]+1])/num[0]
s = round(s)
r = 0
for i in range(1,num[0]+1):
    r += pow(num[i]-s,2)
print(r)
Problem p02909 (python)

Fixed submission:
s = input()
w=["Sunny","Cloudy","Rainy","Sunny"]
print(w[w.index(s)+1])

Buggy submission (verdict: Runtime Error):
s = input()
w = ['Sunny', 'Cloudy', 'Rainy']
print(w[w.index(s) + 1])
Problem p03957 (python)

Fixed submission:
s = input()
a = s.find('C')

if a == -1:
    print("No")
else:
    if s[a:].find('F') == -1:
        print("No")
    else: print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
a = s.find('C')

if a == -1:
    print("No")
else:
    if s[a:].find('F') == -1:
        print("No")
    else print("Yes")
Problem p02848 (python)

Fixed submission:
N = int(input())
S = input()
A = [chr(ord('A') + i) for i in range(26)]
for i in range(len(S)):
    res = A.index(S[i]) + N
    if res >= 26:
        res -= 26
    print(A[res], end = '')

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
A = [chr(ord('A') + i) for i in range(26)]
for i in range(len(S)):
    res = A.index(S[i]) + N
    if res > 25:
        res -= 25
    print(A[res], end = '')