Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())

arr = [int(input())]
for _ in range(N-1):
    a = int(input())
    x = bisect.bisect_left(arr, a)
    if x == 0:
        bisect.insort_left(arr, a)
    else:
        arr[x-1] = a


print(len(arr))


Fixed submission:
import bisect
from collections import deque
N = int(input())

arr = deque([int(input())])
for _ in range(N-1):
    a = int(input())
    x = bisect.bisect_left(arr, a)
    if x == 0:
        arr.appendleft(a)
    else:
        arr[x-1] = a


print(len(arr))
Buggy python submission (verdict: Runtime Error):
N = int(input())

task = [0] * (10 ** 9 + 1)
M = 0
for _ in range(N):
    a, b = map(int, input().split())
    task[b] += a
    if b > M:
        M = b

t = 0
ans = 'Yes'
for i in range(M+1):
    t += task[i]
    if t > i:
        ans = 'No'
        break

print(ans)





Fixed submission:
N = int(input())

task = []
M = 0
for _ in range(N):
    a, b = map(int, input().split())
    task.append((b, a))

task.sort()

s = 0
ans = 'Yes'
for a, b in task:
    s += b
    if s > a:
        ans = 'No'
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

row = [[0] * W for _ in range(H)]
line = [[0] * W for _ in range(H)]
ans = 0

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            if i != 0:
                if row[i-1][j] != 0:
                    row[i][j] = row[i-1][j]
                    continue
            c = 1
            if i+c == H:
                row[i][j] = c
                continue
            while S[i+c][j] == '.':
                c += 1
                if i+c == H:
                    break
            row[i][j] = c

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            if j != 0:
                if line[i][j-1] != 0:
                    line[i][j] = line[i][j-1]
                    ans = max(ans, row[i][j]+line[i][j]-1)
                    continue
            c = 1
            if j+c == W:
                line[i][j] = c
                ans = max(ans, row[i][j]+line[i][j]-1)
                continue
            while S[i][j+c] == '.':
                c += 1
                if j+c == W:
                    break
            line[i][j] = c
            ans = max(ans, row[i][j]+line[i][j]-1)


print(ans)


Fixed submission:
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())

row = [[0] * W for _ in range(H)]
line = [[0] * W for _ in range(H)]
ans = 0

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            if i != 0:
                if row[i-1][j] != 0:
                    row[i][j] = row[i-1][j]
                    continue
            c = 1
            if i+c == H:
                row[i][j] = c
                continue
            while S[i+c][j] == '.':
                c += 1
                if i+c == H:
                    break
            row[i][j] = c

for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            if j != 0:
                if line[i][j-1] != 0:
                    line[i][j] = line[i][j-1]
                    ans = max(ans, row[i][j]+line[i][j]-1)
                    continue
            c = 1
            if j+c == W:
                line[i][j] = c
                ans = max(ans, row[i][j]+line[i][j]-1)
                continue
            while S[i][j+c] == '.':
                c += 1
                if j+c == W:
                    break
            line[i][j] = c
            ans = max(ans, row[i][j]+line[i][j]-1)


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
h = []
for i in input().split():
    heapq.heappush(h, int(i))

for i in range(M):
    b, c = map(int, input().split())
    for j in range(b):
        a = heapq.heappushpop(h, c)
        if a == c:
            break
print(sum(h))



Fixed submission:
import heapq
N, M = map(int, input().split())
h = []
for i in input().split():
    heapq.heappush(h, int(i))
data = [list(map(int, input().split())) for _ in range(M)]
data = sorted(data, reverse=1, key=lambda x: x[1])
for b, c in data:
    for j in range(b):
        a = heapq.heappushpop(h, c)
        if a == c:
            print(sum(h))
            exit()
print(sum(h))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
h = []
for i in input().split():
    heapq.heappush(h, int(i))

for i in range(M):
    b, c = map(int, input().split())
    for j in range(b):
        a = heapq.heappushpop(h, c)
        if a == c:
            break
print(sum(h))



Fixed submission:
import heapq
N, M = map(int, input().split())
h = []
for i in input().split():
    heapq.heappush(h, int(i))
data = [list(map(int, input().split())) for _ in range(M)]
data = sorted(data, reverse=1, key=lambda x: x[1])
for b, c in data:
    for j in range(b):
        a = heapq.heappushpop(h, c)
        if a == c:
            print(sum(h))
            exit()
print(sum(h))

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
h = []
for i in input().split():
    heapq.heappush(h, int(i))

for i in range(M):
    b, c = map(int, input().split())
    for j in range(b):
        heapq.heappushpop(h, c)

print(sum(h))



Fixed submission:
import heapq
N, M = map(int, input().split())
h = []
for i in input().split():
    heapq.heappush(h, int(i))
data = [list(map(int, input().split())) for _ in range(M)]
data = sorted(data, reverse=1, key=lambda x: x[1])
for b, c in data:
    for j in range(b):
        a = heapq.heappushpop(h, c)
        if a == c:
            print(sum(h))
            exit()
print(sum(h))
Buggy python submission (verdict: Runtime Error):
N = int(input())

data = [[] for _ in range(N+1)]

for i in range(N-1):
    a, b, c = map(int, input().split())

    data[a].append((b,c))
    data[b].append((a,c))


ans = [0] * (N+1)
went = [False] * (N+1)

went[0] = True
went[1] = True
before = 1

def f(before):
    for i, c in data[before]:
        if not went[i]:
            went[i] = True
            if c % 2 == 0:
                ans[i] = ans[before]
            else:
                ans[i] = 1 - ans[before]
            return f(i)
    return

f(1)

for i in range(1, N+1):
    print(ans[i])

Fixed submission:
N = int(input())

data = [[] for _ in range(N+1)]

for i in range(N-1):
    a, b, c = map(int, input().split())

    data[a].append((b,c))
    data[b].append((a,c))


ans = [0] * (N+1)
went = [False] * (N+1)

went[0] = True
went[1] = True
go = [1]

while len(go) > 0:
    before = go.pop()
    for i, c in data[before]:
        if not went[i]:
            went[i] = True
            if c % 2 == 0:
                ans[i] = ans[before]
            else:
                ans[i] = 1 - ans[before]
            go.append(i)

for i in range(1, N+1):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
MOD = 998244353

S = sum(A)

dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1

dp2 = [[0]*(S+1) for _ in range(N+1)]
dp2[0][0] = 1

for i in range(N):
    a = A[i]
    x = 0
    while x <= S:
        if x + a <= S:
            dp[i+1][x+a] += dp[i][x]
            dp2[i+1][x+a] += dp2[i][x]
        dp[i+1][x] += dp[i][x] * 2
        dp2[i+1][x] += dp2[i][x]
        x += 1



if S % 2 == 0:
    ans = 3 ** N - sum(dp[N][S//2:]) * 3
    ans += 3 * dp2[N][S//2]
else:
    ans = 3 ** N - sum(dp[N][S//2 + 1:]) * 3

print(ans % MOD)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
MOD = 998244353

S = sum(A)

dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1

dp2 = [[0]*(S+1) for _ in range(N+1)]
dp2[0][0] = 1

for i in range(N):
    a = A[i]
    x = 0
    while x <= S:
        if x + a <= S:
            dp[i+1][x+a] += dp[i][x] % MOD
            dp2[i+1][x+a] += dp2[i][x] % MOD
        dp[i+1][x] += dp[i][x] * 2 % MOD
        dp2[i+1][x] += dp2[i][x] % MOD
        x += 1


if S % 2 == 0:
    ans = 3 ** N - sum(dp[N][S//2:]) * 3
    ans += 3 * dp2[N][S//2]
else:
    ans = 3 ** N - sum(dp[N][S//2 + 1:]) * 3

print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, Q = list(map(int, input().split()))
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
X = [int(input()) for i in range(Q)]

for x in X:
    s_min = A-1
    for i in range(A):
        if s[i] > x:
            s_min = i-1
            break
    t_min = B-1
    for i in range(B):
        if t[i] > x:
            t_min = i-1
            break

    if s_min == -1:
        if t_min == -1:
            print(max(s[0]-x, t[0]-x))
        elif t_min == B-1:
            print(s[0]-t[t_min]+min(s[0]-x, t[t_min]-x))
        else:
            print(min(t[t_min+1]-x, s[0]-t[t_min]+min(s[0]-x, t[t_min]-x)))
    elif s_min == A-1:
        if t_min == -1:
            print(t[0]-s[s_min] + min(t[0]-x, x-s[s_min]))
        elif t_min == B-1:
            print(max(x-s[s_min], x-t[t_min]))
        else:
            print(min(x-t[t_min], t[t_min+1]-s[s_min] + min(t[t_min+1]-x, x-s[s_min])))
    else:
        if t_min == -1:
            if t[0] < s[s_min+1]:
                print(min(s[s_min + 1] - x, t[0] - s[s_min] + min(t[0] - x, x-s[s_min])))
            else:
                print(t[0]-x)
        elif t_min == B-1:
            print(min(x - s[s_min], s[s_min + 1] - t[t_min] + min(s[s_min + 1] - x, x - t[t_min])))
        else:
            if s[s_min] < t[t_min]:
                if s[s_min+1] < t[t_min+1]:
                    print(min(x-s[s_min], t[t_min+1] - x, s[s_min+1] - t[t_min] + min(x-t[t_min], s[s_min+1]-x)))
                else:
                    print(min(x-s[s_min], s[s_min+1]-x))
            else:
                if s[s_min+1] < t[t_min+1]:
                    print(min(t[t_min+1]-x, x-t[t_min]))
                else:
                    print(min(x-t[t_min], s[s_min+1] - x, t[t_min+1] - s[s_min] + min(x-s[s_min], t[t_min+1]-x)))




Fixed submission:
import bisect
A, B, Q = list(map(int, input().split()))
INF = 10**18
s = [-INF]+[int(input()) for i in range(A)]+[INF]
t = [-INF]+[int(input()) for i in range(B)]+[INF]
X = [int(input()) for i in range(Q)]


for x in X:
    s_min = bisect.bisect_left(s, x)
    t_min = bisect.bisect_left(t, x)

    cost = INF
    for S in [s[s_min-1], s[s_min]]:
        for T in [t[t_min-1], t[t_min]]:
            cost = min(cost, abs(T-S)+abs(T-x), abs(T-S)+abs(S-x))

    print(cost)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=1)
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [0] * (N+1)

for i in range(1, N+1):
    now = - 10 ** 9
    for aa in a:
        if i - num[aa] >= 0:
            now = max(now, dp[i-num[aa]]+1)
    dp[i] = now

answer = ''
for i in range(dp[-1]):
    for aa in a:
        if dp[N-num[aa]] == dp[N] - 1:
            answer += str(aa)
            N -= num[aa]
            break
print(answer)


Fixed submission:
N, M = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=1)
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [0] * (N+1)

for i in range(1, N+1):
    now = - 10 ** 9
    for aa in a:
        if i - num[aa] >= 0:
            now = max(now, dp[i-num[aa]]+1)
    dp[i] = now

answer = ''
for i in range(dp[-1]):
    for aa in a:
        if N >= num[aa]:
            if dp[N-num[aa]] == dp[N] - 1:
                answer += str(aa)
                N -= num[aa]
                break
print(answer)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=1)
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [0] * (N+1)

for i in range(1, N+1):
    now = - 10 ** 18
    for aa in a:
        if i - num[aa] >= 0:
            now = max(now, dp[i-num[aa]]+1)
    dp[i] = now

answer = ''
for i in range(dp[-1]):
    for aa in a:
        if dp[N-num[aa]] == dp[N] - 1:
            answer += str(aa)
            N -= num[aa]
            break
print(answer)


Fixed submission:
N, M = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=1)
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [0] * (N+1)

for i in range(1, N+1):
    now = - 10 ** 9
    for aa in a:
        if i - num[aa] >= 0:
            now = max(now, dp[i-num[aa]]+1)
    dp[i] = now

answer = ''
for i in range(dp[-1]):
    for aa in a:
        if N >= num[aa]:
            if dp[N-num[aa]] == dp[N] - 1:
                answer += str(aa)
                N -= num[aa]
                break
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = []
B = []
dif = []
for i in range(N):
    a, b = [int(i) for i in input().split()]
    dif.append(a-b)
    A.append(a)
    B.append(b)

count1 = 0
count2 = 0

def fa():
    if max(dif) > 0 or min(dif) < 0:
        if max(dif) > -min(dif):
            index = dif.index(max(dif))
        else:
            index = dif.index(min(dif))
    else:
        index = A.index(max(A))

    dif.pop(index)
    B.pop(index)
    return A.pop(index)

def fb():
    if max(dif) > 0 or min(dif) < 0:
        if max(dif) < -min(dif):
            index = dif.index(max(dif))
        else:
            index = dif.index(min(dif))
    else:
        index = A.index(max(A))

    dif.pop(index)
    A.pop(index)
    return B.pop(index)

while True:
    count1 += fa()
    if len(A) == 0:
        break
    count2 += fb()
    if len(A) == 0:
        break

print(count1 - count2)

Fixed submission:
N = int(input())

AB = []
sum = 0
for i in range(N):
    a, b = [int(i) for i in input().split()]
    sum -= b
    AB.append(a+b)

AB.sort(reverse=True)

count = 0
for _ in range(N//2):
    count += AB.pop(0)
    AB.pop(0)
if N%2 == 1:
    count += AB.pop(0)

print(count + sum)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
data = [list(map(int, input().split())) for _ in range(N)]

dif = [data[i][0] - data[i][1] for i in range(N)]
A = [data[i][0] for i in range(N)]
B = [data[i][1] for i in range(N)]
count1 = 0
count2 = 0

def fa():
    if max(dif) > 0 or min(dif) < 0:
        if max(dif) > -min(dif):
            index = dif.index(max(dif))
        else:
            index = dif.index(min(dif))
    else:
        index = A.index(max(A))

    dif.pop(index)
    B.pop(index)
    return A.pop(index)

def fb():
    if max(dif) > 0 or min(dif) < 0:
        if max(dif) < -min(dif):
            index = dif.index(max(dif))
        else:
            index = dif.index(min(dif))
    else:
        index = A.index(max(A))

    dif.pop(index)
    A.pop(index)
    return B.pop(index)

while True:
    count1 += fa()
    if len(A) == 0:
        break
    count2 += fb()
    if len(A) == 0:
        break

print(count1 - count2)

Fixed submission:
N = int(input())

AB = []
sum = 0
for i in range(N):
    a, b = [int(i) for i in input().split()]
    sum -= b
    AB.append(a+b)

AB.sort(reverse=True)

count = 0
for _ in range(N//2):
    count += AB.pop(0)
    AB.pop(0)
if N%2 == 1:
    count += AB.pop(0)

print(count + sum)
Buggy python submission (verdict: Runtime Error):
import math

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

now_max = 1

for i in range(round(math.pow(P, 1 / N)) + 1, 0, -1):
    if P % (i ** N) == 0:
        now_max = i
        break

print(now_max)

Fixed submission:
N = str(input())

print(N.count('2'))

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

now = 1

x = 2
while P >= x ** N:
    while P % (x ** N) == 0:
        now *= x
        P = P / (x ** N)
    while P % x == 0:
        P = P / x
    x += 1

print(now)

Fixed submission:
N = str(input())

print(N.count('2'))
Buggy python submission (verdict: Time Limit Exceeded):
S = str(input())

count = 0
end = False
while not end:
    S2 = S.replace('BW', 'WB', 1)
    count += 1
    if S2 == S:
        count -= 1
        end = True
    S = S2
print(count)

Fixed submission:
S = str(input())

count = 0

now = 0

for s in S:
    if s == 'B':
        now += 1
    else:
        count += now

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
data = []
for i in range(M):
    a, b = map(int, input().split())
    heapq.heappush(data, (b, a))
bridge = [1] * N

for i in range(M):
    b, a = heapq.heappop(data)
    if sum(bridge[a:b]) == b - a:
        bridge[b-1] = 0

print(N-sum(bridge))

Fixed submission:
import heapq
N, M = map(int, input().split())
data = []
for i in range(M):
    a, b = map(int, input().split())
    heapq.heappush(data, (b, a))

cut = 0
answer = 0
for i in range(M):
    b, a = heapq.heappop(data)
    if cut <= a:
        answer += 1
        cut = b

print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(M)]
data = sorted(data, key=lambda x:x[1])

bridge = [1] * N

for a, b in data:
    if sum(bridge[a:b]) == b - a:
        bridge[b-1] = 0

print(N-sum(bridge))

Fixed submission:
import heapq
N, M = map(int, input().split())
data = []
for i in range(M):
    a, b = map(int, input().split())
    heapq.heappush(data, (b, a))

cut = 0
answer = 0
for i in range(M):
    b, a = heapq.heappop(data)
    if cut <= a:
        answer += 1
        cut = b

print(answer)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

def calc(n):
    count = 0
    for i in range(1, n+1):
        count += i
    reversed(count)

print(calc(b - a) - b)

Fixed submission:
import sys
sys.setrecursionlimit(100000)
a, b = map(int, input().split())

def calc(n):
    if n == 1:
        return 1
    else:
        return calc(n-1) + n

print(calc(b - a) - b)

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

def calc(n):
    if n == 1:
        return 1
    else:
        return calc(n-1) + n

print(calc(b - a) - b)

Fixed submission:
import sys
sys.setrecursionlimit(100000)
a, b = map(int, input().split())

def calc(n):
    if n == 1:
        return 1
    else:
        return calc(n-1) + n

print(calc(b - a) - b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

answer = N

for i in range(N):
    a = A[i]
    for j in range(i+1, N):
        finish = False
        for k in range(min(len(bin(a)), len(bin(A[j])))-2):
            if int(bin(a)[-k-1]) & int(bin(A[j])[-k-1]) == 1:
                finish = True
                break
        if finish:
            break
        answer += 1
        a += A[j]

print(answer)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

right = 0
answer = 0
now = 0

for left in range(N):
    while right < N and now + A[right] == now ^ A[right]:
        now += A[right]
        right += 1

    answer += right - left

    if right == left:
        right += 1
    else:
        now -= A[left]


print(answer)
Buggy python submission (verdict: Runtime Error):
s = input()
K = int(input())

n = len(s)

ex = [s[:min(K, n)]]
for i in range(n):
    if i + K - 1 < n:
        if ex[0] > s[i:i+K]:
            ex[0] = s[i:i+K]
    else:
        if ex[0][:n-i] > s[i:]:
            ex.insert(0, s[i:])


if K > len(ex[-1]):
    for i in range(len(ex[0])):
        for j in range(i+1, len(ex[0])+1):
            ex.append(ex[0][i:j])
    ex = set(ex)
    ex = sorted(list(ex))
    print(ex[K-1])
else:
    print(ex[-1])

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

n = len(s)

ex = [s[:min(K, n)]]
for i in range(n):
    if i + K - 1 < n:
        if ex[0] > s[i:i+K]:
            ex[0] = s[i:i+K]
    else:
        if ex[0][:n-i] > s[i:]:
            ex.insert(0, s[i:])


for n in range(len(ex)):
    for i in range(len(ex[n])):
        for j in range(i+1, len(ex[n])+1):
            ex.append(ex[n][i:j])

ex = set(ex)
ex = sorted(list(ex))

print(ex[K-1])
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
map = [input() for _ in range(H)]

white = 0
for d in map:
    white += d.count('.')

memory = [(0,0)]
data = [[0] * W for _ in range(H)]
data[0][0] = 1
direction = [(0,1), (0,-1), (1,0), (-1,0)]
while True:
    x, y = memory.pop(0)
    for dx, dy in direction:

        if x + dx == H - 1 and y + dy == W-1:
            print(white - (data[x][y] + 1))
            exit()
        if 0 <= x + dx < H and 0 <= y + dy < W:
            if map[x+dx][y+dy] == '.' and data[x+dx][y+dy] == 0:
                data[x+dx][y+dy] = data[x][y] + 1
                memory.append((x+dx, y+dy))







Fixed submission:
H, W = map(int, input().split())
map = [input() for _ in range(H)]

white = 0
for d in map:
    white += d.count('.')

memory = [(0,0)]
data = [[0] * W for _ in range(H)]
data[0][0] = 1
direction = [(0,1), (0,-1), (1,0), (-1,0)]
while True:
    if len(memory) == 0:
        print(-1)
        exit()
    x, y = memory.pop(0)
    for dx, dy in direction:

        if x + dx == H - 1 and y + dy == W-1:
            print(white - (data[x][y] + 1))
            exit()
        if 0 <= x + dx < H and 0 <= y + dy < W:
            if map[x+dx][y+dy] == '.' and data[x+dx][y+dy] == 0:
                data[x+dx][y+dy] = data[x][y] + 1
                memory.append((x+dx, y+dy))
Buggy python submission (verdict: Runtime Error):
N ,M = map(int,input().split())
data = [list(map(int, input().split())) for _ in range(M)]

data = sorted(data)

INF = 10 ** 9
L = [INF] * (N + 1)
L[data[0][0]] = 0

for l, r, d in data:
    if L[r] == INF:
        L[r] = L[l] + d
    else:
        if L[l] == INF:
            L[l] = L[r] - d
        else:
            if L[r] != L[l] + d:
                print('No')
                exit()
print('Yes')

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9
N ,M = map(int,input().split())

G = [[] for i in range(N+1)]

for _ in range(M):
    l, r, d = map(int, input().split())
    G[l].append((r, d))
    G[r].append((l, -d))

dp = [INF] * (N+1)

def dfs(l):
    for r, d in G[l]:
        if dp[r] == INF:
            dp[r] = dp[l] + d
            if not dfs(r):
                return False
        elif dp[r] != dp[l] + d:
            return False
    return True

for i in range(1, N+1):
    if dp[i] == INF:
        dp[i] = 0
        if not dfs(i):
            print('No')
            exit()

print('Yes')
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

s = len(S)
t = len(T)


for i in range(s-t, -1, -1):
    n = 0
    for j in range(t-1, -1, -1):
        if S[j+i] != '?' and S[j+i] != T[j]:
            break
        n += 1

    if n == t:
        for x in range(s):
            if i <= x <= i+t:
                print(T[x-i], end='')
            else:
                if S[x] == '?':
                    print('a', end='')
                else:
                    print(S[x], end='')
        exit()

print('UNRESTORABLE')



Fixed submission:
S = input()
T = input()

s = len(S)
t = len(T)


for i in range(s-t, -1, -1):
    n = 0
    for j in range(t-1, -1, -1):
        if S[j+i] != '?' and S[j+i] != T[j]:
            break
        n += 1

    if n == t:
        for x in range(s):
            if i <= x < i+t:
                print(T[x-i], end='')
            else:
                if S[x] == '?':
                    print('a', end='')
                else:
                    print(S[x], end='')
        exit()

print('UNRESTORABLE')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(N)]

ans = 10 ** 19
for a in range(N):
    for b in range(N):
        for c in range(N):
            for d in range(N):
                x0 = data[a][0]
                x1 = data[b][0]
                y0 = data[c][1]
                y1 = data[d][1]
                if x0 < x1 and y0 < y1:
                    count = 0
                    for i, j in data:
                        if x0 <= i <= x1 and y0 <= j <= y1:
                            count += 1
                    if count >= K:
                        ans = min(ans, (x1 - x0)*(y1 - y0))

print(ans)

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

if A == B:
    print(C)
elif A == C:
    print(B)
else:
    print(A)