Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = input().split()
 
int_list = [ int(n) for n in list ]
 
isDist = True
 
for a in range(n):
  x = a+1
  if int_list[a] in int_list[x:]:
    print("NO")
    isDist = False
    break;
 
if isDist is True:
    print("YES")

Fixed submission:
n = int(input())
list = input().split()
 
int_list = [ int(n) for n in list ]
int_list.sort()

isDist = True
 
for a in range(n-1):
  if int_list[a] == int_list[a+1]:
    print("NO")
    isDist = False
    break;
 
if isDist is True:
    print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = input().split()
 
int_list = [ int(n) for n in list ]
 
isDist = True
 
for a in range(n):
  x = a+1
  if int_list[a] in int_list[x:]:
    print("NO")
    isDist = False
    break;
 
if isDist is True:
    print("YES")

Fixed submission:
n = int(input())
list = input().split()
 
int_list = [ int(n) for n in list ]
int_list.sort()

isDist = True
 
for a in range(n-1):
  if int_list[a] == int_list[a+1]:
    print("NO")
    isDist = False
    break;
 
if isDist is True:
    print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = input().split()
 
int_list = [ int(n) for n in list ]
 
isDist = True
 
for a in range(n):
  if int_list.count(int_list[a]) != 1:
    print("NO")
    isDist = False
    break;
 
if isDist is True:
    print("YES")

Fixed submission:
n = int(input())
list = input().split()
 
int_list = [ int(n) for n in list ]
int_list.sort()

isDist = True
 
for a in range(n-1):
  if int_list[a] == int_list[a+1]:
    print("NO")
    isDist = False
    break;
 
if isDist is True:
    print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
list = input().split()

int_list = [ int(n) for n in list ]

isDist = True

for a in range(n):
  if int_list.count(int_list[a]) != 1:
    print("NO")
    isDist = False
    break;

if isDist is True:
    print("YES")

Fixed submission:
n = int(input())
list = input().split()
 
int_list = [ int(n) for n in list ]
int_list.sort()

isDist = True
 
for a in range(n-1):
  if int_list[a] == int_list[a+1]:
    print("NO")
    isDist = False
    break;
 
if isDist is True:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
data = [i for i in input().split()]

number_count = {}
for cmp in data:
    if cmp in number_count:
        number_count[cmp] += 1
        continue
    number_count[cmp] = 1

answer = {}
for i in range(N):
    if data[i] in answer:
        print(answer[data[i]])
        continue
    C = 0
    number_count_temp = number_count.copy()
    number_count_temp[str(data[i])] -= 1
    for cmp in number_count_temp:
        C += int(number_count_temp[cmp] * (number_count_temp[cmp] - 1) / 2)

    print(str(C))
    answer[data[i]] = str(C)


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

number_count = {}
for cmp in data:
    if cmp in number_count:
        number_count[cmp] += 1
        continue
    number_count[cmp] = 1

C_tot = 0
for cmp in number_count:
    C_tot += int(number_count[cmp] * (number_count[cmp] - 1) / 2)

for k in range(N):
    C = C_tot - int(number_count[data[k]] * (number_count[data[k]] - 1) / 2) + int((number_count[data[k]] - 1) * (number_count[data[k]] - 2) / 2)
    print(str(C))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
data = [i for i in input().split()]

number_count = {}
for cmp in data:
    if cmp in number_count:
        number_count[cmp] += 1
        continue
    number_count[cmp] = 1

for i in range(N):
    C = 0
    number_count_temp = number_count.copy()
    number_count_temp[str(data[i])] -= 1
    for cmp in number_count_temp:
        C += int(number_count_temp[cmp] * (number_count_temp[cmp] - 1) / 2)

    print(str(C))


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

number_count = {}
for cmp in data:
    if cmp in number_count:
        number_count[cmp] += 1
        continue
    number_count[cmp] = 1

C_tot = 0
for cmp in number_count:
    C_tot += int(number_count[cmp] * (number_count[cmp] - 1) / 2)

for k in range(N):
    C = C_tot - int(number_count[data[k]] * (number_count[data[k]] - 1) / 2) + int((number_count[data[k]] - 1) * (number_count[data[k]] - 2) / 2)
    print(str(C))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, M = [int(i) for i in input().split(" ")]

a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
C = []

for i in range(M):
  c = [int(i) for i in input().split(" ")]
  C.append(c)

m = 1000000

for i in a:
  for j in b:
    cost = i + j
    if m >= cost:
      m = cost

for c in C:
  cost = a[c[0] - 1] + b[c[1] - 1] - c[2]
  if m >= cost:
    m = cost

print(m)

Fixed submission:
A, B, M = [int(i) for i in input().split(" ")]

a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
C = []

for i in range(M):
  c = [int(i) for i in input().split(" ")]
  C.append(c)

m = min(a) + min(b)

for c in C:
  cost = a[c[0] - 1] + b[c[1] - 1] - c[2]
  if m >= cost:
    m = cost

print(m)
Buggy python submission (verdict: Runtime Error):
S = input()
Q = int(input())
for _ in range(Q):
    query = input().split()
    if len(query) == 1:
        S = S[::-1]
        # print('Ti=1: ' + S)
    else:
        F = int(query[1])
        C = query[2]
        if F == 1:
            S = ''.join([C, S])
        elif F == 2:
            S = ''.join([S, C])
        # print('Ti=2: ' + S)

print(S)

Fixed submission:
S = set(input())
if len(S) == 2:
    print('Yes')
elif len(S) == 1:
    print('No')
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N, M = map(int, input().split())
P = [input().split() for _ in range(M)]
X = defaultdict(int)
ac = 0
wa = 0
for pi in P:
    i = int(pi[0])
    s = pi[1]
    if X[i-1] == 0:
        if s == 'WA':
            wa += 1
        else:
            ac += 1
            X[i-1] = 1

print(ac, wa)

Fixed submission:
C = input()
C_next = chr(ord(C) + 1)
print(C_next)
Buggy python submission (verdict: Runtime Error):
*s, = input()

ans = "Yes"
for i in range(0, len(s), 2):
    if s[i] != "h" or s[i+1] != "i":
        ans = "No"
        break

print(ans)


Fixed submission:
s = input()

if len(s)%2 == 0:
    x = len(s)//2
    if "hi"*x == s:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
s, c = [], []
for i in range(m):
    _s, _c = map(int, input().split())
    s.append(_s)
    c.append(_c)

for i in range(1000):
    *t, = map(int, list(str(i)))

    if len(t) != n:
        continue

    ok = True
    for j in range(m):
        if t[s[j]] != c[j]:
            ok = False
            break

    if ok:
        print(i)
        quit()

print(-1)


Fixed submission:
n, m = map(int, input().split())
s, c = [], []
for _ in range(m):
    _s, _c = map(int, input().split())
    s.append(_s-1)
    c.append(_c)

for i in range(1000):
    *t, = map(int, list(str(i)))

    if len(t) != n:
        continue

    ok = True
    for j in range(m):
        if t[s[j]] != c[j]:
            ok = False
            break
    if ok:
        print(i)
        quit()

print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
*p, = map(int, input().split())

*ev, = map(lambda x: (x*(x+1)/2)/x, p)

ans = 0
for i in range(n-k+1):
    ans = max(ans, sum(ev[i:i+k]))

print(ans)


Fixed submission:
n, k = map(int, input().split())
*p, = map(int, input().split())

*ev, = map(lambda x: (x*(x+1)/2)/x, p)
cusum = [0]*(n+1)
for i in range(n):
    cusum[i+1] = cusum[i] + ev[i]

ans = 0
for i in range(n-k+1):
    ans = max(ans, cusum[i+k] - cusum[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
*p, = map(int, input().split())

*ev, = map(lambda x: (x*(x+1)/2)/x, p)

ans = 0
for i in range(n-k+1):
    ans = max(ans, sum(ev[i:i+k]))

print(ans)


Fixed submission:
n, k = map(int, input().split())
*p, = map(int, input().split())

*ev, = map(lambda x: (x*(x+1)/2)/x, p)
cusum = [0]*(n+1)
for i in range(n):
    cusum[i+1] = cusum[i] + ev[i]

ans = 0
for i in range(n-k+1):
    ans = max(ans, cusum[i+k] - cusum[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
a, b = [], []
for _ in range(n):
    _a, _b = map(int, input().split())
    a.append(_a)
    b.append(_b)

dp = [[float("inf")]*(h+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(h+1):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][min(j+a[i], h)] = min(dp[i+1][min(j+a[i], h)], dp[i+1][j] + b[i])

print(dp[n][h])


Fixed submission:
h, n = map(int, input().split())
a, b = [], []
for _ in range(n):
    _a, _b = map(int, input().split())
    a.append(_a)
    b.append(_b)

dp = [[float("inf")]*(h+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(h+1):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        dp[i+1][min(j+a[i], h)] = min(dp[i+1][min(j+a[i], h)], dp[i+1][j] + b[i])

print(dp[n][h])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*p, = map(int, input().split())

ans = 0
for i in range(n):
    flag = True
    for j in range(0, i+1):
        if p[i] > p[j]:
            flag = False
            break

    if flag:
        ans += 1

print(ans)


Fixed submission:
n = int(input())
*p, = map(int, input().split())

m = p[0]
ans = 0
for i in range(n):
    if p[i] <= m:
        ans += 1
        m = min(m, p[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
import fractions
import functools
n, m = map(int, input().split())
*a, = map(int, input().split())

def lcm(a: int, b: int) -> int:
    return (a*b) // fractions.gcd(a, b)

l = functools.reduce(lcm, a)/2

ans = math.ceil((m//l)/2)
print(ans)


Fixed submission:
import fractions
n, m = map(int, input().split())
*a, = map(int, input().split())

lcm = a[0]//2

for x in a:
    x //= 2
    g = fractions.gcd(lcm, x)
    if (lcm//g)%2 != (x//g)%2:
        print(0)
        quit()

    lcm = lcm*x//g

print((m//lcm + 1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
*s, = input()

ans = []
for i in itertools.combinations(s, 3):
    ans.append(i)

print(len(set(ans)))


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

ans = 0
for i in range(10):
    a = s.find(str(i))
    if a == -1:
        continue

    for j in range(10):
        b = s.find(str(j), a+1)
        if b == -1:
            continue

        for k in range(10):
            if s.find(str(k), b+1) != -1:
                ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
*l, = sorted(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        bc = l[i]+l[j]
        index = bisect.bisect_left(l, bc)
        ans += len(l[j+1:index])

print(ans)


Fixed submission:
import bisect
n = int(input())
*l, = sorted(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        bc = l[i]+l[j]
        ans += bisect.bisect_left(l, bc)-(j+1)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q=map(int, input().split())
a=list(int(input()) for _ in range(q))

for i in range(n):
    if k-(q-a.count(i+1)) > 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
n,k,q=map(int, input().split())
a=[0]*n
for _ in range(q):
    a[int(input())-1]+=1

for i in range(n):
    if k-(q-a[i]) > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n, m = map(int, input().split())
*a, = sorted(map(int, input().split()))

for i in range(m):
    _a = a.pop()//2
    bisect.insort_left(a, _a)

print(sum(a))


Fixed submission:
import heapq
n, m = map(int, input().split())
*a, = map(lambda x: -x, map(int, input().split()))

heapq.heapify(a)
for i in range(m):
    _a = int(heapq.heappop(a)/2)
    heapq.heappush(a, _a)

print(sum(a)*-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
m = 0
a = []
for _ in range(n):
    _a = int(input())
    m = max(m, _a)
    a.append(_a)

for i in range(n):
    if a[i] == m:
        t = a[:]
        t.pop(i)
        print(max(t))
    else:
        print(m)


Fixed submission:
n = int(input())
maxindex = maxvalue = 0
a = []
for i in range(n):
    _a = int(input())
    if maxvalue <= _a:
        maxvalue = _a
        maxindex = i
    a.append(_a)

for i in range(n):
    if i != maxindex:
        print(maxvalue)
        continue
    t = a[:]
    t.pop(i)
    print(max(t))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
    t = a[:]
    t.pop(i)
    print(max(t))


Fixed submission:
n = int(input())
maxindex = maxvalue = 0
a = []
for i in range(n):
    _a = int(input())
    if maxvalue <= _a:
        maxvalue = _a
        maxindex = i
    a.append(_a)

for i in range(n):
    if i != maxindex:
        print(maxvalue)
        continue
    t = a[:]
    t.pop(i)
    print(max(t))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]

for i in range(n):
    t = a[:]
    print(max(t.pop(i)))


Fixed submission:
n = int(input())
maxindex = maxvalue = 0
a = []
for i in range(n):
    _a = int(input())
    if maxvalue <= _a:
        maxvalue = _a
        maxindex = i
    a.append(_a)

for i in range(n):
    if i != maxindex:
        print(maxvalue)
        continue
    t = a[:]
    t.pop(i)
    print(max(t))
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
ans = (l*r)%2019
for i in range(l, r):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)
    if ans == 0:
        print(ans)
        exit()
print(ans)


Fixed submission:
l, r = map(int, input().split())
ans = (l*r)%2019
for i in range(l, r):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)
        if ans == 0:
            print(ans)
            exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
*l, = map(int, input().split())

d = 0
ans = 0
for i in range(n+1):
    if x < d:
        break
    d += l[i]
    ans += 1
print(ans)


Fixed submission:
n, x = map(int, input().split())
*l, = map(int, input().split())

d = 0
ans = 1
for i in range(n):
    d += l[i]
    if x < d:
        break
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = list(input())

cusum = [0]*(n+1)
for i in range(len(s)):
    if s[i] == "A" and s[i+1] == "C":
        cusum[i+1] = cusum[i] + 1
    else:
        cusum[i+1] = cusum[i]

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


Fixed submission:
n, q = map(int, input().split())
s = input()
numofac = [0]*len(s)
cnt = 0
for i in range(1, len(s)):
    if s[i-1] == "A" and s[i] == "C":
        cnt += 1
    numofac[i] = cnt

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

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
for _ in range(q):
    l, r = map(int, input().split())
    print(s[l-1:r].count("AC"))


Fixed submission:
n, q = map(int, input().split())
s = input()
numofac = [0]*len(s)
cnt = 0
for i in range(1, len(s)):
    if s[i-1] == "A" and s[i] == "C":
        cnt += 1
    numofac[i] = cnt

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

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ans = []
for _ in range(q):
    l, r = map(int, input().split())
    ans.append(s[l-1:r].count("AC"))

for _ans in ans:
    print(_ans)


Fixed submission:
n, q = map(int, input().split())
s = input()
numofac = [0]*len(s)
cnt = 0
for i in range(1, len(s)):
    if s[i-1] == "A" and s[i] == "C":
        cnt += 1
    numofac[i] = cnt

for _ in range(q):
    l, r = map(int, input().split())
    print(numofac[r-1]-numofac[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

ans = 0
while True:
    for i in range(len(s)-1):
        if s[i:i+2] == "01" or s[i:i+2] == "10":
            s = s[:i] + s[i+2:]
            ans += 2

    if s.count("1") == 0 or s.count("0") == 0:
        break

print(ans)


Fixed submission:
s = input()

print(min(s.count("0"), s.count("1"))*2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*a, = map(int, input().split())

m = min(a)
while any(map(lambda x: x%m, a)):
    m -= 1

print(m)


Fixed submission:
from functools import reduce
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
print(reduce(gcd, a))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*a, = sorted(map(int, input().split()))

m = a[0]
while any(map(lambda x: x%m, a)):
    a = sorted([m] + list(map(lambda x: x-m, a[1:])))
    m = a[0]
    if m == 0:
        a = a[1:]
        m = a[0]

print(m)


Fixed submission:
from functools import reduce
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
print(reduce(gcd, a))

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

m = a[0]
while any(map(lambda x: x%m, a)):
    a = sorted([m] + list(map(lambda x: x-m, a[1:])))
    m = a[0]

print(m)


Fixed submission:
from functools import reduce
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
print(reduce(gcd, a))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
*x, = sorted(map(int, input().split()))

diff = []
for i in range(m-1):
    diff.append(abs(x[i]-x[i+1]))
partition = sorted(diff, reverse=True)[:(n-1)]

ans = 0
for _d in diff:
    if _d in partition:
        partition.remove(_d)
        continue

    ans += _d

print(ans)


Fixed submission:
n, m = map(int, input().split())
*x, = sorted(map(int, input().split()))

diff = []
for i in range(m-1):
    diff.append(abs(x[i]-x[i+1]))
p = 0 if len(diff) < n else len(diff)-n+1
sec = sorted(diff)[:p]

print(sum(sec))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**6)

n = int(input())
*h, = map(int, input().split())

def rec(i: int, c: int) -> int:
    if i == 0:
        return c
    elif i <= 1:
        return rec(i-1, c+abs(h[i]-h[i-1]))

    return min(rec(i-1, c+abs(h[i]-h[i-1])), rec(i-2, c+abs(h[i]-h[i-2])))

print(rec(n-1, 0))

"""
3,0
2,20 1,10
1,30 0,50 0,30
0,50
"""


Fixed submission:
n = int(input())
*h, = map(int, input().split())

dp = [float("inf")]*(n+1)
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]), dp[i])
    if i > 1:
        dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]), dp[i])

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
*h, = map(int, input().split())

def rec(i: int, c: int) -> int:
    if i <= 0:
        return c
    elif i == 1:
        return rec(i-1, c+abs(h[i]-h[i-1]))

    return min(rec(i-1, c+abs(h[i]-h[i-1])), rec(i-2, c+abs(h[i]-h[i-2])))

print(rec(n-1, 0))


Fixed submission:
n = int(input())
*h, = map(int, input().split())

dp = [float("inf")]*(n+1)
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]), dp[i])
    if i > 1:
        dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]), dp[i])

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
*h, = map(int, input().split())

def rec(i: int, c: int) -> int:
    if i == 0:
        return c
    elif i <= 1:
        return rec(i-1, c+abs(h[i]-h[i-1]))

    return min(rec(i-1, c+abs(h[i]-h[i-1])), rec(i-2, c+abs(h[i]-h[i-2])))

print(rec(n-1, 0))


Fixed submission:
n = int(input())
*h, = map(int, input().split())

dp = [float("inf")]*(n+1)
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]), dp[i])
    if i > 1:
        dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]), dp[i])

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, W = map(int, input().split())
w, v = [], []
for _ in range(n):
    _w, _v = map(int, input().split())
    w.append(_w)
    v.append(_v)

dp = [[0]*(W+1) for _ in range(n+1)]

for i in range(n):
    for j in range(W+1):
        dp[i+1][j] = dp[i][j]
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j])

print(dp[n][W])


Fixed submission:
n, W = map(int, input().split())
w, v = [], []
for _ in range(n):
    _w, _v = map(int, input().split())
    w.append(_w)
    v.append(_v)

dp = [[0]*(W+1) for _ in range(n+1)]

for i in range(n):
    for j in range(W+1):
        dp[i+1][j] = dp[i][j]
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j])

print(dp[n][W])
Buggy python submission (verdict: Time Limit Exceeded):
*s, = input()
*t, = input()

dp = [[""]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + s[i]
        else:
            if len(dp[i+1][j]) <= len(dp[i][j+1]):
                dp[i+1][j+1] = dp[i][j+1]
            else:
                dp[i+1][j+1] = dp[i+1][j]

print(dp[len(s)][len(t)])


Fixed submission:
*s, = input()
*t, = input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ans = ""

i, j = len(s), len(t)
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1

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

for _s in s:
    if _s == "1":
        if k == 1:
            print(1)
            break
        else:
            k -= 1
    else:
        print(i)
        break


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

for _s in s:
    if _s == "1":
        if k == 1:
            print(1)
            break
        else:
            k -= 1
    else:
        print(_s)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*l, = map(int, input().split())

for i in range(n):
    _l = l[:]
    _l.pop(i)
    _l.sort()
    print(_l[(n-1)//2])


Fixed submission:
n = int(input())
*l, = map(int, input().split())

p, q = sorted(l)[n//2-1 : n//2+1]
for _l in l:
    print(p if _l >= q else q)
Buggy python submission (verdict: Runtime Error):
a,b=map(int, input().split())

cnt=0
for i in range(a,b):
    if str(i) == str(i)[::-1]:
        cnt+=1

print(cnt)


Fixed submission:
import math
n = int(input())
d, x = map(int, input().split())
ans = 0
for _ in range(n):
    a = int(input())
    ans += math.ceil(d/a)

print(ans + x)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
*a, = map(int, input().split())

a.insert(0, 0)
a.append(0)

d = [0]*(len(a)-1)
for i in range(len(a)-1):
    d[i] = abs(a[i]-a[i+1])

for i in range(len(d)-1):
    print(sum(d[:i]) + sum(d[i+2:]) + abs(a[i] - a[i+2]))


Fixed submission:
n = int(input())
*a, = map(int, input().split())

a.insert(0, 0)
a.append(0)

s = 0
for i in range(len(a)-1):
    s += abs(a[i]-a[i+1])

for i in range(1, len(a)-1):
    print(s + abs(a[i-1]-a[i+1]) - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1])))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int, input().split()))

a.append(0)

for i in range(n):
    cost=0
    pv=0
    nx=0
    for j in range(len(a)):
        if i == j:
            continue
        pv, nx = nx, a[j]
        cost+=abs(pv-nx)

    print(cost)


Fixed submission:
n=int(input())
a=list(map(int, input().split()))

a=[0]+a+[0]

cost=[abs(a[i]-a[i+1]) for i in range(len(a)-1)]
total=sum(cost)

ans=0
for i in range(n):
    ans = total - cost[i] - cost[i+1] + abs(a[i+2]-a[i])
    print(ans)