Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

s=input()
n=len(s)
ok=False
for i in range(n-1):
    ct=Counter()
    for j in range(i,n):
        ct[s[j]]+=1
        d=j-i+1
        #print(d)
        if d//2<ct[s[j]] and d>=2:
            print(i+1,j+1)
            ok=True
            exit()
            break

if not ok:
    print(-1,-1)


Fixed submission:
s=input()
n=len(s)
a=b=-1
for i in range(n-1):
    if s[i]==s[i+1]:
        a,b=i+1,i+2
        break
    elif i+2<n and s[i]==s[i+2]:
        a,b=i+1,i+3
        break

print(a,b)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
m = len(t)
cnt = 10000
for i in range(n-m+1):
	st = s[i:i+m]
    if st == t:
      cnt = 0
      break
    else:
      temp = 0
      for j in range(m):
        if t[j] != st[j]:
          temp += 1
      cnt = min(cnt,temp)
print(cnt)
		
      

Fixed submission:
#_______________________________________________________________#
def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x-1)
def lower_bound(li, num): 
	answer = -1
	start = 0
	end = len(li)-1

	while(start <= end):
		middle = (end+start)//2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer #index where x is not less than num
def upper_bound(li, num): 
	answer = -1
	start = 0
	end = len(li)-1

	while(start <= end):
		middle = (end+start)//2

		if li[middle] <= num:
			answer = middle
			start = middle + 1
		
		else:
			end = middle - 1
	return answer #index where x is not greater than num

def abs(x):
	return x if x >=0 else -x
def binary_search(li, val, lb, ub): 
	ans = 0
	while(lb <= ub):
		mid = (lb+ub)//2
		#print(mid, li[mid])
		if li[mid] > val:
			ub = mid-1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans
def kadane(x): #maximum sum contiguous subarray
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far,current_sum)
	return sum_so_far
def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

#_______________________________________________________________#
'''
      ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
   ▄███████▀▀▀▀▀▀███████▄
░▐████▀▒▒Aestroix▒▒▀██████
░███▀▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀████
░▐██▒▒▒▒▒KARMANYA▒▒▒▒▒▒████▌         ________________
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌  ? ?   |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒|
░░█▒▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▒▐███▌   ?    |___CM ONE DAY___|
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▒▐███▌     ? ? |▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒|
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌    ? ?    
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌      ? 
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█     ? ? 
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀       ? 
░░░░▄█████████ ████=========█▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
░░░░░████████████████
'''
from math import *
#for _ in range(int(input())):
for _ in range(1):
	#n = int(input())
	#p,f = map(int,input().split())
	#d,t,s = map(int,input().split())
	#ws,wa = map(int,input().split())
	#b = list(input())
	#x = int(input())
	#n = len(b)
	#s2 = input()
	#r, g, b, w = map(int,input().split())
	#a = list(map(int,input().split()))
	#b = list(map(int,input().split()))
	#s1 = list(st)
	s = input()
	t = input()
	n = len(s)
	m = len(t)
	cnt = 10000
	for i in range(n-m+1):
		st = s[i:i+m]
		if st == t:
			cnt = 0
			break
		else:
			temp = 0
			for j in range(m):
				if st[j] != t[j]:
					temp += 1
			cnt = min(cnt,temp)
	print(cnt)
Buggy python submission (verdict: Runtime Error):
d,t,s = input().split()
if d/s <= t: 
    print("Yes")
else:
    print("No") 

Fixed submission:
d,t,s = input().split()
if int(d)/int(s) <= int(t): 
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
d,t,s = int(input().split())
if d/s <= t: 
    print("Yes")
else:
    print("No") 

Fixed submission:
d,t,s = input().split()
if int(d)/int(s) <= int(t): 
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a = input()
c = 0
x = []
for i in a:
	if i == 'R':
		c+=1
	if i == "S":
		x.append(c)	
      	c = 0
print(max(x))

Fixed submission:
a = list(input())
c = 0
x = []
for i in a:
    
    if i == 'R':
        c += 1
    else:
        x.append(c)
        c = 0
    x.append(c)
print(max(x))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
D = set(map(int, input().split()))
for ans in range(n,9999):
    for c in str(ans):
        if int(c) in D:
            break
    else:
        print(ans)
        break

Fixed submission:
a = input().split()

if a.count('5') == 2 and a.count('7') == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().strip())
arr = list(map(int, input().strip().split()))

ans = 1

for num in arr:
	ans *= num
	
if ans > 10**18:
	print(-1)
else:
	print(ans)


Fixed submission:

n = int(input().strip())
arr = list(map(int, input().strip().split()))
arr.sort()

ans = 1

for num in arr:
    ans *= num

    if ans > 10**18:
        print(-1)
        exit(0)

print(ans)

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

ans = 1

for num in arr:
	ans *= num
	
if ans > 10**18:
	print(-1)
else:
	print(ans)

Fixed submission:

n = int(input().strip())
arr = list(map(int, input().strip().split()))
arr.sort()

ans = 1

for num in arr:
    ans *= num

    if ans > 10**18:
        print(-1)
        exit(0)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

class Solution:
    def solve(self, H, k, monsters):
        monsters.sort(reverse=True)

        i = 0

        while i < k and len(monsters) > 0:
            monsters.pop(0)
            i += 1

        ans = 0

        for monster in monsters:
            ans += monster

        return ans


sol = Solution()

[H, k] = list(map(int, input().strip().split()))
monsters = list(map(int, input().strip().split()))

print(sol.solve(H, k, monsters))


Fixed submission:

class Solution:
    def solve(self, H, k, monsters):
        monsters.sort(reverse=True)

        return sum(monsters[k:])


sol = Solution()

[H, k] = list(map(int, input().strip().split()))
monsters = list(map(int, input().strip().split()))

print(sol.solve(H, k, monsters))
Buggy python submission (verdict: Time Limit Exceeded):

class Solution:
    def solve(self, n, arr):
        count = 0

        for i in range(n):
            j = 0
            flag = True

            while j <= i:
                if arr[j] < arr[i]:
                    flag = False
                    break

                j += 1

            if flag:
                count += 1

        return count


sol = Solution()

n = int(input().strip())
arr = list(map(int, input().strip().split(" ")))

print(sol.solve(n, arr))


Fixed submission:

class Solution:
    def solve(self, n, arr):
        count = 1
        minElement = arr[0]

        for i in range(1, n):
            if arr[i] <= minElement:
                count += 1
                minElement = arr[i]

        return count


sol = Solution()

n = int(input().strip())
arr = list(map(int, input().strip().split(" ")))

print(sol.solve(n, arr))
Buggy python submission (verdict: Runtime Error):

class Solution:
	def solve(self, sHeights):
		if not sHeights or len(sHeights) == 0:
			return 0
			
		n = len(sHeights)
			
		dp = [0 for _ in range(n)]
		dp[0] = 0
		dp[1] = abs(sHeights[1] - sHeights[0])
		
		for i in range(2, n):
			dp[i] = min(dp[i-2] + abs(sHeights[i] - sHeights[i-2]), dp[i-1] + abs(sHeights[i] - sHeights[i-1]))
			
		print(dp)
			
		return dp[n-1]
		
sol = Solution()

# s = [10, 30, 40, 20]
# s = [10, 10]
# s = [30,10,60,10,60,50]

int n = int(input().strip())
s = list(map(int, input().strip().split())
print(sol.solve(s))

Fixed submission:
class Solution:
  def solve(self, sHeights):
    if not sHeights or len(sHeights) == 0:
      return 0
    
    n = len(sHeights)
    
    dp = [0 for _ in range(n)]
    dp[0] = 0
    dp[1] = abs(sHeights[1] - sHeights[0])
    
    for i in range(2, n):
      dp[i] = min(dp[i-1] + abs(sHeights[i] - sHeights[i-1]), dp[i-2] + abs(sHeights[i] - sHeights[i-2]))
      
    return dp[n-1]
  
sol = Solution()

n = int(input().strip())

s = list(map(int, input().strip().split()))

print(sol.solve(s))
Buggy python submission (verdict: Runtime Error):
H, W, m = map(int, input().split())
xs = [[0] * W for _ in range(H)]
for _ in range(m):
    h, w = map(int, input().split())
    xs[h - 1][w - 1] += 1

mxx = [0] * H
for i in range(H):
    sm = 0
    for j in range(W):
        sm += xs[i][j]
    mxx[i] = sm
mxy = [0] * W
for i in range(W):
    sm = 0
    for j in range(H):
        sm += xs[j][i]
    mxy[i] = sm
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, mxx[i] + mxy[j] - xs[i][j])
print(ans)


Fixed submission:
H, W, m = map(int, input().split())
xs = [0] * H
ys = [0] * W
s = set()
for _ in range(m):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    xs[h] += 1
    ys[w] += 1
    s.add((h, w))

mx = max(xs)
my = max(ys)
mxs = set()
for i in range(H):
    if xs[i] == mx:
        mxs.add(i)
mys = set()
for i in range(W):
    if ys[i] == my:
        mys.add(i)
for x in mxs:
    for y in mys:
        if not (x, y) in s:
            print(mx + my)
            exit()
print(mx + my - 1)

Buggy python submission (verdict: Runtime Error):
H, W, m = map(int, input().split())
xs = [[0] * W for _ in range(H)]
for _ in range(m):
    h, w = map(int, input().split())
    xs[h - 1][w - 1] += 1

mxx = [0] * H
for i in range(H):
    mxx[i] = sum(xs[i])
mxy = [0] * W
for i in range(W):
    sm = 0
    for j in range(H):
        sm += xs[j][i]
    mxy[i] = sm
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, mxx[i] + mxy[j] - xs[i][j])
print(ans)


Fixed submission:
H, W, m = map(int, input().split())
xs = [0] * H
ys = [0] * W
s = set()
for _ in range(m):
    h, w = map(int, input().split())
    h -= 1
    w -= 1
    xs[h] += 1
    ys[w] += 1
    s.add((h, w))

mx = max(xs)
my = max(ys)
mxs = set()
for i in range(H):
    if xs[i] == mx:
        mxs.add(i)
mys = set()
for i in range(W):
    if ys[i] == my:
        mys.add(i)
for x in mxs:
    for y in mys:
        if not (x, y) in s:
            print(mx + my)
            exit()
print(mx + my - 1)
Buggy python submission (verdict: Time Limit Exceeded):
R, C, k = map(int, input().split())
xs = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    xs[r - 1][c - 1] = v

dp = [[[0] * 4 for _ in range(C + 1)] for _ in range(R + 1)]
for i in range(R):
    for j in range(C):
        for k in range(2, -1, -1):
            dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k] + xs[i][j])
        for k in range(4):
            dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k])
            dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k])
print(max(dp[R - 1][C - 1]))


Fixed submission:
R, C, k = map(int, input().split())
xs = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    xs[r - 1][c - 1] = v

dp = [[[0] * (C + 1) for _ in range(R + 1)] for _ in range(4)]
for i in range(R):
    for j in range(C):
        for k in range(2, -1, -1):
            dp[k + 1][i][j] = max(dp[k + 1][i][j], dp[k][i][j] + xs[i][j])
        for k in range(4):
            dp[k][i][j + 1] = max(dp[k][i][j + 1], dp[k][i][j])
            dp[0][i + 1][j] = max(dp[0][i + 1][j], dp[k][i][j])
ans = 0
for k in range(4):
    ans = max(ans, dp[k][R - 1][C - 1])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, C, k = map(int, input().split())
xs = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    xs[r - 1][c - 1] = v

dp = [[[0] * 4 for _ in range(C + 1)] for _ in range(R + 1)]
for i in range(R):
    for j in range(C):
        for k in range(2, -1, -1):
            dp[i][j][k + 1] = max(dp[i][j][k + 1], dp[i][j][k] + xs[i][j])
        for k in range(4):
            dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k])
        dp[i + 1][j][0] = max(dp[i + 1][j][0], *dp[i][j])
print(max(dp[R - 1][C - 1]))


Fixed submission:
R, C, k = map(int, input().split())
xs = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    xs[r - 1][c - 1] = v

dp = [[[0] * (C + 1) for _ in range(R + 1)] for _ in range(4)]
for i in range(R):
    for j in range(C):
        for k in range(2, -1, -1):
            dp[k + 1][i][j] = max(dp[k + 1][i][j], dp[k][i][j] + xs[i][j])
        for k in range(4):
            dp[k][i][j + 1] = max(dp[k][i][j + 1], dp[k][i][j])
            dp[0][i + 1][j] = max(dp[0][i + 1][j], dp[k][i][j])
ans = 0
for k in range(4):
    ans = max(ans, dp[k][R - 1][C - 1])
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
ans = a[0]
i = 1
while True:
    ans += a[i]
    i += 1
    if i == n - 1:
        break
    ans += a[i]
    i += 1
    if i == n - 1:
        break
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = a[0]
idx = 1
for i in range(1, n):
    if idx == n - 1:
        break
    ans += a[i]
    idx += 1
    if idx == n - 1:
        break
    ans += a[i]
    idx += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

xs = [0] * (2 * (10 ** 5) + 1)

for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))


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

xs = [0] * (max(a) + 1)

for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))

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

xs = [0] * (2 * (10 ** 5) + 1)
for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))


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

xs = [0] * (max(a) + 1)

for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))

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

xs = [0] * (2 * 10 ** 5 + 1)
for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))


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

xs = [0] * (max(a) + 1)

for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))

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

xs = [0] * (2 * 10 ** 5 + 1)
for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))


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

xs = [0] * (max(a) + 1)

for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))
Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
c = [0] * n
a = [0] * n
for i in range(n):
    xs = list(map(int, input().split()))
    c[i] = xs[0]
    a[i] = xs[1:]
ans = 10 ** 9
for i in range(2 ** n):
    csum = 0
    asum = [0] * n
    for j in range(n):
        if (i >> j) & 1:
            csum += c[j]
            for k in range(m):
                asum[k] += a[j][k]
    if len(list(filter(lambda v: v >= x, asum))) == m:
        ans = min(ans, csum)
print(-1 if ans == 10 ** 9 else ans)


Fixed submission:
n, m, x = map(int, input().split())
c = [0] * n
a = [0] * n
for i in range(n):
    xs = list(map(int, input().split()))
    c[i] = xs[0]
    a[i] = xs[1:]
ans = 10 ** 9
for i in range(2 ** n):
    csum = 0
    asum = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            csum += c[j]
            for k in range(m):
                asum[k] += a[j][k]
    if len(list(filter(lambda v: v >= x, asum))) == m:
        ans = min(ans, csum)
print(-1 if ans == 10 ** 9 else ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
r = 0
p = 0
seen = {0}
for i in range(k):
    x = a[p] - 1
    if x in seen:
        p = 0
        seen = {0}
        for j in range((k - 1) % r):
            p = a[p] - 1
            ans = p + 1
        print(ans)
        exit()
    p = x
    seen.add(p)
    r = i + 1
    ans = p + 1
print(ans)


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

b = 0
r = k + 1
seen = [-1] * n
seen[0] = 0
p = 1
for i in range(k):
    p = a[p - 1]
    if seen[p - 1] != -1:
        b = seen[p - 1]
        r = i + 1 - b
        for j in range((k - b) % r):
            p = a[p - 1]
        print(p)
        exit()
    seen[p - 1] = i + 1
else:
    print(p)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
r = False
for _ in range(q):
    xs = input().split()
    if xs[0] == "1":
        r = not r
    else:
        if (not r and xs[1] == "1") or (r and xs[1] == "2"):
            s = "".join([xs[2], s])
        else:
            s = "".join([s, xs[2]])
print(s[::-1] if r else s)


Fixed submission:
from collections import deque

s = input()
q = int(input())

d = deque()
for v in s:
    d.append(v)
r = False
for _ in range(q):
    xs = input().split()
    if xs[0] == "1":
        r = not r
    else:
        if (not r and xs[1] == "1") or (r and xs[1] == "2"):
            d.appendleft(xs[2])
        else:
            d.append(xs[2])
s = "".join(d)
print(s[::-1] if r else s)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    if start + len(t) == len(s):
        count = 0
        for i in range(len(t)):
            if s[start:end][i] != t[i]: count += 1
        return min(count, min_changes)
    return min(f(s, t, start+1, end+1), min_changes)

print(f(s, t, start, end))

Fixed submission:
d, t, s = map(int, input().split())
if d/s <= t: print("Yes")
else: print("No")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    count = 0
    for i in range(len(t)):
        if s[start:end][i] != t[i]: count += 1
    if start + len(t) == len(s): return min(count, min_changes)
    else: return min(count, f(s, t, start+1, end+1))

print(f(s, t, start, end))


Fixed submission:
import sys
sys.setrecursionlimit(10**6)
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    count = 0
    for i in range(len(t)):
        if s[start:end][i] != t[i]: count += 1
    if start + len(t) == len(s): return min(count, min_changes)
    else: return min(count, f(s, t, start+1, end+1))

print(f(s, t, start, end))

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    if start + len(t) == len(s):
        count = 0
        for i in range(len(t)):
            if s[start:end][i] != t[i]: count += 1
        return min(count, min_changes)
    return min(f(s, t, start+1, end+1), min_changes)

print(f(s, t, start, end))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    count = 0
    for i in range(len(t)):
        if s[start:end][i] != t[i]: count += 1
    if start + len(t) == len(s): return min(count, min_changes)
    else: return min(count, f(s, t, start+1, end+1))

print(f(s, t, start, end))

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    if start + len(t) == len(s):
        count = 0
        for i in range(len(t)):
            if s[start:end][i] != t[i]: count += 1
        return min(count, min_changes)
    return f(s, t, start+1, end+1)

print(f(s, t, start, end))

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    count = 0
    for i in range(len(t)):
        if s[start:end][i] != t[i]: count += 1
    if start + len(t) == len(s): return min(count, min_changes)
    else: return min(count, f(s, t, start+1, end+1))

print(f(s, t, start, end))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int,input().split())
cnt = 0
sum = 0
for i in range(A):
  if cnt == K:
    print(sum)
    exit()
  sum = sum + 1
  cnt = cnt + 1
for j in range(B):
  if cnt == K:
    print(sum)
    exit()
  sum = sum + 0
  cnt = cnt + 1
for k in range(C):
  if cnt == K:
    print(sum)
    exit()
  sum = sum + (-1)
  cnt = cnt + 1

Fixed submission:
A, B, C, K = map(int,input().split())
cnt = 0
sum = 0
if A >= K:
  print(K)
if A< K <=(A+B):
  print(A)
if (A+B) < K <= (A+B+C):
  print(A-(K-A-B))
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
H = list(map(int,input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
c = 0
p=[0]*N
for i in range(1,N+1):
  if i not in A and i not in B:
    c = c+1
  else:
    for j in range(1,M+1):
      if i == A[j-1]:
        if H[A[j-1]-1] > H[B[j-1]-1]:
          p[i-1] = p[i-1]+1
      if i == B[j-1]:
        if H[B[j-1]-1] > H[A[j-1]-1]:
          p[i-1] = p[i-1]+1
    if p[i-1] == A.count(i)+B.count(i):
      c =c+1
print(c)

Fixed submission:
x = input()
if x == "ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Time Limit Exceeded):
#今更だけど、Ai,Biでのバトルを行わせて、負けた方をリストに追加し、setを取って、あとから計算すればよかった
N,M=map(int,input().split())
H = [0]*N
H = list(map(int,input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())

cnt = 0
point=[0]*N
for i in range(1,N+1):
  #iがAにもBにも無ければポイント追加
  if i not in A and i not in B:
    cnt = cnt+1

  #iがAorBにある場合には、その全ての場合にペアより大きければポイント追加
  else:
    for j in range(1,M+1):
      if i == A[j-1]:
        if H[A[j-1]-1] > H[B[j-1]-1]:
          point[i-1] = point[i-1]+1
      if i == B[j-1]:
        if H[B[j-1]-1] > H[A[j-1]-1]:
          point[i-1] = point[i-1]+1
    if point[i-1] == A.count(i)+B.count(i):
      cnt =cnt+1
print(cnt)

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]<=h[b-1]:
    ans[a-1]=0
  if h[a-1]>=h[b-1]:
    ans[b-1]=0
print(ans.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = 0
for i in range(n-1):
    for j in range(i + 1, n):
        ans += a[i] * a[j]
        ans %= mod

print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = 0
sum_a = sum(a)
for i in range(n):
    sum_a -= a[i]
    ans += sum_a * a[i]
    ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = 0
for i in range(n-1):
    for j in range(i + 1, n):
        ans += a[i] * a[j]
        ans %= mod

print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = 0
sum_a = sum(a)
for i in range(n):
    sum_a -= a[i]
    ans += sum_a * a[i]
    ans %= mod

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()
a=int(input())
b=int(float(b)*100+0.5)
ans=int(a*b)
print(ans)


Fixed submission:
from decimal import Decimal
a,b=map(str,input().split())
ans=Decimal(a)*Decimal(b)
print(int(ans))