Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
S = input()
T = [0]*N
for i in range(1, N):
    if S[i -1: i +1] == "AC":
        T[i] += 1
for j in range(Q):
    l, r = map(int, input().split())
    print(sum(T[l : r]))
    

Fixed submission:
N,Q = map(int, input().split())
S = input()
count = [0]*N
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1] == "AC":
        count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Runtime Error):
import itertools

N,Q = map(int, input().split())
S = input()
a = list(itertools.accumulate([i for i in S]))

for i in range(Q):
    l,r = map(int, input().split())
    b = a[r-1][l-1:]
    print(b.count('AC'))

Fixed submission:
N,Q = map(int, input().split())
S = input()
count = [0]*N
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1] == "AC":
        count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
S = input()
ans = []
for i in range(Q):
    l,r = map(int, input().split())
    S_ = S[l-1:r]
    ans.append(S_.count("AC"))
print(*ans, sep="\n")

Fixed submission:
N,Q = map(int, input().split())
S = input()
count = [0]*N
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1] == "AC":
        count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    print(count[r-1]-count[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int, input().split())
S = input()

for i in range(Q):
    l,r = map(int, input().split())
    S_ = S[l-1:r]
    print(S_.count("AC"))

Fixed submission:
N,Q = map(int, input().split())
S = input()
count = [0]*N
for i in range(1,N):
    count[i] += count[i-1]
    if S[i-1:i+1] == "AC":
        count[i] += 1
for i in range(Q):
    l,r = map(int, input().split())
    print(count[r-1]-count[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
s = len(S)
while True:
    T = re.sub("(01|10)","",S)
    if T == S:
        break
    S = T
t = len(T)
print(s-t)

Fixed submission:
S = input()
stack = []
for s in S:
    if not stack:
        stack.append(s)
    else:
        if s == stack[-1]:
            stack.append(s)
        else:
            stack.pop()
print(len(S)-len(stack))

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
s = len(S)
while True:
    T = re.sub("(01|10)","",S)
    if T == S:
        break
    S = T
t = len(T)
print(s-t)

Fixed submission:
S = input()
stack = []
for s in S:
    if not stack:
        stack.append(s)
    else:
        if s == stack[-1]:
            stack.append(s)
        else:
            stack.pop()
print(len(S)-len(stack))
Buggy python submission (verdict: Runtime Error):
def step_memo(H):
    N = len(H)
    memo = ["E"]*N
    n = N-1
    def step(n):
        if n == 0:
            memo[0] = 0
            return memo[0]
        elif n == 1:
            memo[1] = abs(H[1]-H[0])
            return memo[1]
        elif memo[n] != "E":
            return memo[n]
        else:
            memo[n]= min(step(n-2)+abs(H[n-2]-H[n]), step(n-1)+abs(H[n-1]-H[n]))
            return memo[n]
    return step(n)

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

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
points = [0]*N
points[1] = abs(H[1]-H[0])
for i in range(2,N):
    points[i] = min(points[i-2]+abs(H[i-2]-H[i]), points[i-1]+abs(H[i-1]-H[i]))
print(points[-1])

Buggy python submission (verdict: Runtime Error):
def step_memo(H):
    N = len(H)
    memo = [0]*N
    n = N-1
    def step(n):
        if n == 0:
            return 0
        elif n == 1:
            memo[1] = abs(H[1]-H[0])
            return memo[1]
        elif memo[n] != 0:
            return memo[n]
        else:
            memo[n]= min(step(n-2)+abs(H[n-2]-H[n]), step(n-1)+abs(H[n-1]-H[n]))
            return memo[n]
    return step(n)

S = int(input())
T = list(map(int, input().split()))
print(step_memo(T))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
points = [0]*N
points[1] = abs(H[1]-H[0])
for i in range(2,N):
    points[i] = min(points[i-2]+abs(H[i-2]-H[i]), points[i-1]+abs(H[i-1]-H[i]))
print(points[-1])

Buggy python submission (verdict: Runtime Error):
def step_memo(H):
    N = len(H)
    memo = [0]*N
    n = N-1
    def step(n):
        if n == 0:
            return 0
        elif n == 1:
            memo[1] = abs(H[1]-H[0])
            return memo[1]
        elif memo[n] != 0:
            return memo[n]
        else:
            memo[n]= min(step(n-2)+abs(H[n-2]-H[n]), step(n-1)+abs(H[n-1]-H[n]))
            return memo[n]
    return step(n)

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

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
points = [0]*N
points[1] = abs(H[1]-H[0])
for i in range(2,N):
    points[i] = min(points[i-2]+abs(H[i-2]-H[i]), points[i-1]+abs(H[i-1]-H[i]))
print(points[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i],v[i] = map(int, input().split())
dp = [[0]*(W+1) for j in range(N+1)]

for i in range(N):
    for sum_w in range(1,W+1):
        if (sum_w - w[i]) >= 0:
            dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - w[i]]+v[i])
        else:
            dp[i+1][sum_w] = dp[i][sum_w]
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
w = [0]*N
v = [0]*N
for i in range(N):
    w[i],v[i] = map(int, input().split())
dp = [[0]*(W+1) for j in range(N+1)]

for i in range(N):
    for sum_w in range(1,W+1):
        if (sum_w - w[i]) >= 0:
            dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - w[i]]+v[i])
        else:
            dp[i+1][sum_w] = dp[i][sum_w]
print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int, input().split())
wv = []
V = 0
for x in range(N):
    w,v = map(int, input().split())
    wv.append([w,v])
    V += v

INF = 10**9+1

DP = [[INF]*(V+1) for _ in range(N+1)]

for i in range(N):
    for j in range(V):
        if j >= wv[i][1]:
            DP[i+1][j] = min(DP[i][j], DP[i][j-wv[i][1]]+wv[i][0])
        else:
            DP[i+1][j] = min(DP[i][j], wv[i][0])
        
ans = 0
for i in range(N+1):
    for j in range(V+1):
        if DP[i][j] <= W:
            ans = max(ans, j+1)
print(ans)

Fixed submission:
N,W = map(int, input().split())
wv = []
V = 0
for x in range(N):
    w,v = map(int, input().split())
    wv.append([w,v])
    V += v

INF = 10**9+1

DP = [[INF]*(V+1) for _ in range(N+1)]

for i in range(N):
    for j in range(V):
        if j >= wv[i][1]:
            DP[i+1][j] = min(DP[i][j], DP[i][j-wv[i][1]]+wv[i][0])
        else:
            DP[i+1][j] = min(DP[i][j], wv[i][0])
        
ans = 0
for i in range(N+1):
    for j in range(V+1):
        if DP[i][j] <= W:
            ans = max(ans, j+1)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

s = sys.stdin.readline()
N = s[0]
p = sorted(s[1:])
print(p[:-1].sum() + p[-1]/2)

Fixed submission:
N = int(input())
p = [int(input()) for i in range(N)]
p.sort()
print(int(sum(p[:-1]) + p[-1]/2))

Buggy python submission (verdict: Runtime Error):
N, *p = map(int, open(0).read().split())
p.sort()
print(p[:-1].sum() + p[-1]/2)

Fixed submission:
N = int(input())
p = [int(input()) for i in range(N)]
p.sort()
print(int(sum(p[:-1]) + p[-1]/2))
Buggy python submission (verdict: Runtime Error):
n=input()
n_int = int(n)

if n_int<357:
  print(0)
else:
  counter__ = 0
  for k in range(3 ,len(n)+1):
    counter__ += recursive_f([])
    def recursive_f(A):
      if len(A) == k:
        A_ = int("".join(map(str,A)))
        counter = 0
        if len(set(A)) == 3 and A_ <= n_int:
          counter += 1
        return counter
      counter_ = 0
      for i in [3,5,7]:
        A.append(i)
        counter_ += recursive_f(A)
        A.pop()
      return counter_
        
print(counter__)

Fixed submission:
N = input()

def dfs(A):
    if int(A) > int(N):
        return 0
    if all(A.count(c) for c in "753") >0:
        ans = 1
    else:
        ans = 0
        
    for i in "357":
        A += i
        ans += dfs(A)
        A = A[:-1]
        
    return ans

print(dfs("0"))

Buggy python submission (verdict: Runtime Error):
n=input()           #  str 575
n_int = int(n)    #  int 575

if n_int<357:
    print(0)
else:
    counter__ = 0
    for k in range(3 ,len(n)+1):
        counter__ += recursive_f([])

        def recursive_f(A):
            if len(A) == k:     # Aはリスト[7,7,7]
                A_ = int("".join(map(str,A)))    # A_はint 777
                counter = 0
                # print(A_)
                if len(set(A)) == 3 and A_ <= n_int:
                    counter += 1
                return counter

            counter_ = 0

            for i in [3,5,7]:
                A.append(i)
                counter_ += recursive_f(A)
                A.pop()

            return counter_
        
print(counter__)

Fixed submission:
N = input()

def dfs(A):
    if int(A) > int(N):
        return 0
    if all(A.count(c) for c in "753") >0:
        ans = 1
    else:
        ans = 0
        
    for i in "357":
        A += i
        ans += dfs(A)
        A = A[:-1]
        
    return ans

print(dfs("0"))

Buggy python submission (verdict: Runtime Error):
n=input()
n_int = int(n)

if n_int<357:
  print(0)
else:
  counter__ = 0
  for k in range(3 ,len(n)+1):
    counter__ += recursive_f([])

    def recursive_f(A):
      if len(A) == k:     # Aはリスト[7,7,7]
        A_ = int("".join(map(str,A)))    # A_はint 777
        counter = 0
        # print(A_)
        if len(set(A)) == 3 and A_ <= n_int:
          counter += 1
          return counter

        counter_ = 0

        for i in [3,5,7]:
          A.append(i)
          counter_ += recursive_f(A)
          A.pop()

          return counter_
        
print(counter__)

Fixed submission:
N = input()

def dfs(A):
    if int(A) > int(N):
        return 0
    if all(A.count(c) for c in "753") >0:
        ans = 1
    else:
        ans = 0
        
    for i in "357":
        A += i
        ans += dfs(A)
        A = A[:-1]
        
    return ans

print(dfs("0"))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
q = [[int(j) for j in input().split()] for i in range(M)]
li = [[] for k in range(N+1)]

for i,j in sorted(q, key=lambda x:x[1]):
    li[i].append(j)

for p,y in q:
    print("{:0=6}".format(p) + "{:0=6}".format(li[p].index(y)+1))

Fixed submission:
import bisect
N,M = map(int, input().split())
q = [[int(j) for j in input().split()] for i in range(M)]
li = [[] for k in range(N+1)]

for i,j in sorted(q):
    li[i].append(j)

for p,y in q:
    z = bisect.bisect(li[p],y)
    print("{:0=6}".format(p) + "{:0=6}".format(z))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
# 市 i は　県 n (N)で x 番目に誕生した
li = []
pre = [[] for i in range(N)]
for i in range(M):
    p,y = map(int, input().split())
    pre[p-1].append(y)
    li.append([p,y])
pre = list(map(sorted,pre))
for p,y in li:
    print("{:0=6}".format(p) + "{:0=6}".format(pre[p-1].index(y)+1))

Fixed submission:
import bisect
N,M = map(int, input().split())
q = [[int(j) for j in input().split()] for i in range(M)]
li = [[] for k in range(N+1)]

for i,j in sorted(q):
    li[i].append(j)

for p,y in q:
    z = bisect.bisect(li[p],y)
    print("{:0=6}".format(p) + "{:0=6}".format(z))

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
# 市 i は　県 n (N)で x 番目に誕生した
li = []
pre = [[] for i in range(N)]
for i in range(M):
    p,y = map(int, input().split())
    pre[p-1].append(y)
    li.append([p,y])
pre = list(map(sorted,pre))
for p,y in li:
    print("{:0=6}".format(p) + "{:0=6}".format(pre[p-1].index(y)+1))

Fixed submission:
import bisect
N,M = map(int, input().split())
q = [[int(j) for j in input().split()] for i in range(M)]
li = [[] for k in range(N+1)]

for i,j in sorted(q):
    li[i].append(j)

for p,y in q:
    z = bisect.bisect(li[p],y)
    print("{:0=6}".format(p) + "{:0=6}".format(z))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int, input().split()))
a = sorted(([i,v[::2].count(i)] for i in set(v[::2])), key=lambda x:x[1])
b = sorted(([j,v[1::2].count(j)] for j in set(v[1::2])),key=lambda x:x[1])
if a[-1]!=b[-1]:
    print(n-a[-1][1]-b[-1][1])
elif len(a) == 1 and len(b) == 1:
    print(min(a[-1][1],b[-1][1]))
elif len(a) ==1:
    print(n-a[-1][1]-b[-2][1])
elif len(b) ==1:
    print(n-a[-2][1]-b[-1][1])
else:
    print(min(n-a[-2][1]-b[-1][1],n-a[-1][1]-b[-2][1]))

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a = Counter(v[::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])

if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(min(n-a[1][1]-b[0][1],n-a[0][1]-b[1][1]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
a = sorted(([i,v[::2].count(i)] for i in set(v[::2])), key=lambda x:x[1])
b = sorted(([j,v[1::2].count(j)] for j in set(v[1::2])),key=lambda x:x[1])
if a[-1]!=b[-1]:
    print(n-a[-1][1]-b[-1][1])
elif len(a) == 1 and len(b) == 1:
    print(min(a[-1][1],b[-1][1]))
elif len(a) ==1:
    print(n-a[-1][1]-b[-2][1])
elif len(b) ==1:
    print(n-a[-2][1]-b[-1][1])
else:
    print(min(n-a[-2][1]-b[-1][1],n-a[-1][1]-b[-2][1])

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
a = Counter(v[::2]).most_common()
b = Counter(v[1::2]).most_common()
a.append([0,0])
b.append([0,0])

if a[0][0]!=b[0][0]:
    print(n-a[0][1]-b[0][1])
else:
    print(min(n-a[1][1]-b[0][1],n-a[0][1]-b[1][1]))
Buggy python submission (verdict: Runtime Error):
from functols import reduce
from fractions import gcd
N,X = map(int, input().split())
x =[abs(X-int(i)) for i in input().split()]
print(reduce(gcd,x))

Fixed submission:
import bisect
import math
from functools import reduce

def gcd(A):
    return reduce(math.gcd, A)

N,X = map(int, input().split())
x = sorted(map(int, input().split()))
bisect.insort(x,X)
ans = [x[i+1]-x[i] for i in range(N)] 
if N ==1:
    print(x[1]-x[0])
else:
    print(gcd(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
x = ""
while n!=0:
    x = str(n%2) + x
    n = -(n//2)
if x = "":
    print(0)
else:
    print(x)

Fixed submission:
n=int(input())
x = ""
while n!=0:
    x = str(n%2) + x
    n = -(n//2)
if x == "":
    print(0)
else:
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
A.sort()
b = sum(A)//len(A)
d = sum(A)%len(A)
c = 10**9
for j in range(b-d, b+d+1):
    k = sum(map(lambda x:abs(x-j), A))
    c = min(c,k)
print(c)


Fixed submission:
import statistics
N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
b = statistics.median_low(A)
c = statistics.median_high(A)
d = sum(map(lambda x:abs(x-b),A))
e = sum(map(lambda x:abs(x-c),A))
print(min(d,e))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
A.sort()
b = int(sum(a)/len(a))
c = 10**9
for j in range(b-10, b+11):
    k = sum(map(lambda x:abs(x-j), A))
    c = min(c,k)
print(c)

Fixed submission:
import statistics
N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
b = statistics.median_low(A)
c = statistics.median_high(A)
d = sum(map(lambda x:abs(x-b),A))
e = sum(map(lambda x:abs(x-c),A))
print(min(d,e))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
a = max(A)
b = min(A)
c = 10**9
for j in range(b,a+1):
    k = sum(map(lambda x:abs(x-j), A))
    c = min(k,c)
print(c)

Fixed submission:
import statistics
N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
b = statistics.median_low(A)
c = statistics.median_high(A)
d = sum(map(lambda x:abs(x-b),A))
e = sum(map(lambda x:abs(x-c),A))
print(min(d,e))
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int, input().split())

if B-A+1<= 2*K:
    print(*range(A,B+1), sep="\n")
else:
    a = list(range(A,A+K))
    b = list(range(B-K+1,B+1))
    C = set(a,b)
    print(*C, sep="\n")

Fixed submission:
A,B,K = map(int, input().split())
if B - A + 1> 2*K:
    a = list(range(A, A+K))
    b = list(range(B-K+1,B+1))
    c = sorted(set(a+b))
    print(*c, sep="\n")
else:
    print(*range(A,B+1), sep="\n")

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

if B-A+1<= 2*K:
    print(*range(A,B+1), sep="\n")
else:
    a = list(range(A,A+K))
    b = list(range(B-K+1,B+1))
    C = set(a,b)
    print(*C, sep="\n")

Fixed submission:
A,B,K = map(int, input().split())
if B - A + 1> 2*K:
    a = list(range(A, A+K))
    b = list(range(B-K+1,B+1))
    c = sorted(set(a+b))
    print(*c, sep="\n")
else:
    print(*range(A,B+1), sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int, input().split())
C = [i for i in range(A,B+1)]
if B-A+1<= 2*K:
    print(*C, sep="\n")
else:
    print(*C[:K], sep="\n")
    print(*C[-K:], sep="\n")

Fixed submission:
A,B,K = map(int, input().split())
if B - A + 1> 2*K:
    a = list(range(A, A+K))
    b = list(range(B-K+1,B+1))
    c = sorted(set(a+b))
    print(*c, sep="\n")
else:
    print(*range(A,B+1), sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int, input().split())
print(*[k for k in range(A,B+1) if k < A+K or B-K < k], sep="\n")

Fixed submission:
A,B,K = map(int, input().split())
if B - A + 1> 2*K:
    a = list(range(A, A+K))
    b = list(range(B-K+1,B+1))
    c = sorted(set(a+b))
    print(*c, sep="\n")
else:
    print(*range(A,B+1), sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np

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

a = [1,5,10]
b = [i for i in list(itertools.combinations_with_replacement(a,N)) if sum(i) == Y/1000]
if b:
    print(b[0].count(10),b[0].count(5),b[0].count(1))
else:
    print(-1,-1,-1)

Fixed submission:
N, Y = map(int, input().split())
ans = -1,-1,-1
for x in range(N+1):
    for y in range(N - x + 1):
        z = N - x - y
        if 0<=z<=2000 and 10000*x+5000*y+1000*z == Y:
            ans = x,y,z
            break
    else:
        continue
    break
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N,K = map(int, input().split())
A = Counter(list(map(int, input().split())))
B = A.items()
k = len(B) - K
if k <= 0:
    print(0)
else:
    print(sum([sorted(B,key=lambda x:x[1])[i][1] for i in range(k)]))

Fixed submission:
from collections import Counter
N,K = map(int, input().split())
A = Counter(list(map(int, input().split())))
B = A.values()
k = len(B) - K
if k <= 0:
    print(0)
else:
    print(sum(sorted(B)[0:k]))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

ans = 0
for i in A:
    for k in B[bisect.bisect_right(B,i):]:
        ans += D - bisect.bisect_right(C,k)
print(ans)

Fixed submission:
import bisect

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

ans = 0
for i in B:
    ans += bisect.bisect_left(A,i)*(N - bisect.bisect_right(C,i))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

ans = 0
for i in A:
    for k in B:
        if k <= i:
            continue
        ans += D - bisect.bisect_right(C,k)
print(ans)

Fixed submission:
import bisect

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

ans = 0
for i in B:
    ans += bisect.bisect_left(A,i)*(N - bisect.bisect_right(C,i))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

ans = 0
for i in A:
    for k in B:
        if k <= i:
            continue
        ans += D - bisect.bisect_right(C,k)
print(ans)

Fixed submission:
import bisect

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

ans = 0
for i in B:
    ans += bisect.bisect_left(A,i)*(N - bisect.bisect_right(C,i))
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
s = len(S)
T = input()
t = len(T)
key = 0
for i in range(0,s-t+1):
    for j,k in enumerate(S[i:i+t]):
        if k == T[j] or k =="?":
            pass
        else:
            break
    else:
        key = i
        break
    key = 100
if key == 100:
    print("UNRESTORABLE")
else:
    ans = S[0:i]+T+S[i+t:]
    ans = ans.replace("?","a")
    print(ans)

Fixed submission:
S = input()
s = len(S)
T = input()
t = len(T)

key = 0
for i in range(s-t,-1,-1):
    for j,k in enumerate(S[i:i+t]):
        if k == T[j] or k =="?":
            pass
        else:
            break
    else:
        key = i
        break
    key = 100
if key == 100 or s<t:
    print("UNRESTORABLE")
else:
    ans = S[0:i]+T+S[i+t:]
    ans = ans.replace("?","a")
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = set()
for i in range(N):
    A = A^{input()}
print(len(A))

Fixed submission:
N = int(input())
A = set()
for i in range(N):
    A ^= {input()}
print(len(A))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = set()
for i in range(N):
    A = A^{int(input())}
print(len(A))

Fixed submission:
N = int(input())
A = set()
for i in range(N):
    A ^= {input()}
print(len(A))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
A = [[] for i in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    A[a].append(b)
    A[b].append(a)

for j in A[0]:
    if j in A[-1]:
        print("POSSIBLE")
        break
else:
    print('IMPOSSIBLE')

Fixed submission:
N,M = map(int, input().split())
A = [[] for i in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    A[a].append(b)
    A[b].append(a)

if len(A[0])+len(A[-1]) != len(set(A[0]+A[-1])):
        print("POSSIBLE")
else:
    print('IMPOSSIBLE')