Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

ls,lt = len(s), len(t)
# dp[i][j] : siとtjにおけるLCS
dp = [['']*(lt+1) for _ in range(ls+1)]

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

print(dp[ls][lt])

Fixed submission:
s = input()
t = input()
ls, lt = len(s), len(t)

ans = ''
dp = [[0]*(lt+1) for _ in range(ls+1)]
for j in range(ls):
    for i in range(lt):
        if s[j]==t[i]:
            dp[j+1][i+1] = dp[j][i]+1
        else:
            dp[j+1][i+1] = max(dp[j+1][i], dp[j][i+1])

if dp[ls][lt] == 0:
    print('')
    exit()

i = lt
j = ls

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

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

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

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

Fixed submission:
s = input()
t = input()
ls, lt = len(s), len(t)

ans = ''
dp = [[0]*(lt+1) for _ in range(ls+1)]
for j in range(ls):
    for i in range(lt):
        if s[j]==t[i]:
            dp[j+1][i+1] = dp[j][i]+1
        else:
            dp[j+1][i+1] = max(dp[j+1][i], dp[j][i+1])

if dp[ls][lt] == 0:
    print('')
    exit()

i = lt
j = ls

while i>0 and j>0:
    if s[j-1] == t[i-1]:
        ans += s[j-1]
        i -= 1
        j -= 1
    else:
        if dp[j-1][i]>dp[j][i-1]:
            j -= 1
        else:
            i -= 1
print(ans[::-1])
Buggy python submission (verdict: Runtime Error):
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b = b, a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b //gcd(a,b)

n,m = map(int,input().split())
s = input()
t = input()

l = lcm(n,m)
txt = ['.']*l
res = l
for i in range(n):
    txt[i*(l//n)] = s[i]
for i in range(m):
    if (txt[i*(l//m)]!='.'):
        if (txt[i*(l//m)]!=t[i]):
            res = -1
            break
print(res)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
 
n,m = map(int,input().split())
s = input()
t = input()

l = lcm(n,m)
gaps = l//m
gapt = l//n

i,j = 0,0
while i<n:
    if s[i]!=t[j]:
        print(-1)
        break
    else:
        i += gaps
        j += gapt
else:
    print(l)

Buggy python submission (verdict: Runtime Error):
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b = b, a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b //gcd(a,b)

n,m = map(int,input().split())
s = input()
t = input()

l = lcm(n,m)
txt = ['.']*l

res = l
for i in range(n):
    txt[i*(l//n)] = s[i]
for i in range(m):
    if txt[i*(l//m)]!='.' and txt[i*(l//m)]!=t[i]:
        res = -1
        break
print(res)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
 
n,m = map(int,input().split())
s = input()
t = input()

l = lcm(n,m)
gaps = l//m
gapt = l//n

i,j = 0,0
while i<n:
    if s[i]!=t[j]:
        print(-1)
        break
    else:
        i += gaps
        j += gapt
else:
    print(l)

Buggy python submission (verdict: Runtime Error):
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b = b, a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b //gcd(a,b)

n,m = map(int,input().split())
s = input()
t = input()

l = lcm(n,m)
txt = ['.']*l

res = l
for i in range(n):
    txt[i*(l//n)] = s[i]
for i in range(m):
    if txt[i*(l//m)]=='.' or txt[i*(l//m)]==t[i]:
        continue
    else:
        res = -1
print(res)

Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
 
n,m = map(int,input().split())
s = input()
t = input()

l = lcm(n,m)
gaps = l//m
gapt = l//n

i,j = 0,0
while i<n:
    if s[i]!=t[j]:
        print(-1)
        break
    else:
        i += gaps
        j += gapt
else:
    print(l)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = [list(map(int,input().split())) for _ in range(n)]

cx,cy = 0,0
for cx in range(101):
    for cy in range(101):
        pro_height = []
        for i in range(n):
            h = lst[i][2] + abs(lst[i][0]-cx) + abs(lst[i][1]-cy)
            pro_height.append(h)
        if len(set(pro_height)) == 1:
            ans_H = pro_height[0]
            ans_cx = cx
            ans_cy = cy
            break
print(ans_cx,ans_cy,ans_H)

Fixed submission:
N = int(input())
P = [list(map(int, input().split())) for _ in range(N)]

for cx in range(101):
    for cy in range(101):
        H = -1
        ok = True
        for x, y, h in P:
            if h == 0:
                continue
            Hi = abs(x-cx) + abs(y-cy) + h
            if H == -1:
                H = Hi
                continue
            if Hi != H:
                ok = False
                break
        if not ok:
            continue
        for x, y, h in P:
            if h != max(H-abs(cx-x)-abs(cy-y), 0):
                ok = False
        if ok:
            print(cx, cy, H)
            break
    if ok:
        break
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
ans = 0
tmp = 1
while True:
    num = m - tmp*(n-1)
    if num < tmp:
        break
    elif num % tmp == 0:
        ans = tmp
    tmp += 1
print(ans)

Fixed submission:
n,m = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return divisors
ans = 1
lst = make_divisors(m)
lst.sort()
for d in lst:
    if m>=d*n:
        ans = d
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
ans = 0
tmp = 1
while True:
    num = m - tmp*(n-1)
    if num < tmp:
        break
    elif num % tmp == 0:
        ans = tmp
    tmp += 1
print(ans)

Fixed submission:
n,m = map(int,input().split())
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i != n//i:
                divisors.append(n//i)
    return divisors
ans = 1
lst = make_divisors(m)
lst.sort()
for d in lst:
    if m>=d*n:
        ans = d
print(ans)
Buggy python submission (verdict: Runtime Error):
n =input()
lst = []
ans = []
for i in range(3):
    num = int(n[i]*3)
    lst.append(num)
for i in range(3):
    if lst[i] > int(n):
        ans.append(lst[i])
print(min(ans))

Fixed submission:
n =int(input())
i = int(n/111)
if n % 111 != 0:
    i += 1
print(i * 111)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(h)]

flg = [[False]*w for _ in range(h)]

cnt = 0
ans = []

for i in range(h):
    for j in range(w-1):
        if lst[i][j] %2 == 1:
            lst[i][j] -= 1
            lst[i][j+1] += 1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h-1):
    if lst[i][-1] %2 == 1:
        lst[i][-1] -= 1
        lst[i+1][-1] += 1
        ans.append([i+1,j+1,i+2,j+1])
        
print(len(ans))
for l in ans:
    print(*l)

Fixed submission:
h,w = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(h)]

cnt = 0
ans = []

for i in range(h):
    for j in range(w-1):
        if lst[i][j] %2 == 1:
            lst[i][j] -= 1
            lst[i][j+1] += 1
            ans.append([i+1,j+1,i+1,j+2])

for i in range(h-1):
    if lst[i][-1] %2 == 1:
        lst[i][-1] -= 1
        lst[i+1][-1] += 1
        ans.append([i+1,w,i+2,w])

print(len(ans))
for a in ans:
    print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
T = [[0]*N for _ in range(N)]
for _ in range(M):
    l,r = map(int,input().split())
    T[l-1][r-1] += 1
def f(x,y,T):
    ret = 0
    for i in range(y):
        for j in range(x):
            ret += T[i][j]
    return ret
query = []
res = []
for _ in range(Q):
    p,q = map(int,input().split())
    res.append(f(q,q,T) - f(p-1, q ,T)- f(q, p-1, T) + f(p-1, p-1, T))
for r in res:
    print(r)

Fixed submission:
import sys
from itertools import accumulate
n,m,q = map(int,input().split())
ipt = sys.stdin.readlines()
rails = [[0]*n for _ in range(n)]
for line in ipt[:m]:
    l,r = map(int,line.split())
    rails[l-1][r-1] += 1
rails = [accumulate(s) for s in rails]
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(*rails)]
buf = []
for  line in ipt[m:]:
    p,q = map(int,line.split())
    buf.append(rails[q-1][p-1])
print('\n'.join(map(str, buf)))

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

T = [[0]*N for _ in range(N)]
for _ in range(M):
    l,r = map(int,input().split())
    T[l-1][r-1] += 1

def f(x,y,T):
    ret = 0
    for i in range(y):
        for j in range(x):
            ret += T[i][j]
    return ret

query = []
res = []
for _ in range(Q):
    p,q = map(int,input().split())
    res.append(f(q,q,T) - f(p-1, q ,T)- f(q, p-1, T) + f(p-1, p-1, T))

for r in res:
    print(r)

Fixed submission:
import sys
from itertools import accumulate
n,m,q = map(int,input().split())
ipt = sys.stdin.readlines()
rails = [[0]*n for _ in range(n)]
for line in ipt[:m]:
    l,r = map(int,line.split())
    rails[l-1][r-1] += 1
rails = [accumulate(s) for s in rails]
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(*rails)]
buf = []
for  line in ipt[m:]:
    p,q = map(int,line.split())
    buf.append(rails[q-1][p-1])
print('\n'.join(map(str, buf)))
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(m)]
lst.sort(key=lambda x:x[1])
res = []
for i in range(m):
    a,b = lst[i][0], lst[i][1]
    flg = False
    if i==0:
        res.append(b-1)
    else:
        for r in res:
            if a<=r<=b:
                flg=True
        if not flg:
            res.append(b-1)
print(len(res))

Fixed submission:
n,m = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(m)]
lst.sort(key=lambda x:x[1])
res = []
for i in range(m):
    a,b = lst[i][0], lst[i][1]
    flg = False
    if i==0:
        res.append(b-1)
    else:
        for r in res:
            if a<=r<=b:
                flg=True
        if not flg:
            res.append(b-1)
print(len(res))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [int(i) for i in input().split()]

for i in range(n):
    lst[i] -= i+1

Min = min(lst)
Max = max(lst)

for b in range(Min,Max+1):
    scr = 0
    for i in range(n):
        scr += abs(lst[i] - b)
    if b == Min:
        Min_scr = scr
    elif scr < Min_scr:
        Min_scr = scr
print(Min_scr)

Fixed submission:
n = int(input())
lst = [int(i) for i in input().split()]

for i in range(n): #Bi
    lst[i] -= i+1

lst.sort()
if n%2 == 0:
    k = n//2
    b = (lst[k] + lst[k-1])/2
else:
    k = (n-1)//2
    b = lst[k]

ans = 0
for i in range(n):
    ans += abs(lst[i] - b)

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,m = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(n)]
res = 0
for l in itertools.permutations(lst, m):
    X,Y,Z = 0,0,0
    for i in range(m):
        x,y,z = l[i][0], l[i][1], l[i][2]
        X += x
        Y += y
        Z += z
    res = max(res, abs(X)+abs(Y)+abs(Z))
print(res)

Fixed submission:
n,m = map(int,input().split())
lst0, lst1, lst2, lst3, lst4, lst5, lst6, lst7 =[],[],[],[],[],[],[],[]
for i in range(n):
    x,y,z = map(int,input().split())
    lst0.append(x+y+z)
    lst1.append(x+y-z)
    lst2.append(x-y+z)
    lst3.append(x-y-z)
    lst4.append(-x+y+z)
    lst5.append(-x+y-z)
    lst6.append(-x-y+z)
    lst7.append(-x-y-z)
lst0.sort(reverse=True)
lst1.sort(reverse=True)
lst2.sort(reverse=True)
lst3.sort(reverse=True)
lst4.sort(reverse=True)
lst5.sort(reverse=True)
lst6.sort(reverse=True)
lst7.sort(reverse=True)

res = []
res.append(sum(lst0[:m]))
res.append(sum(lst1[:m]))
res.append(sum(lst2[:m]))
res.append(sum(lst3[:m]))
res.append(sum(lst4[:m]))
res.append(sum(lst5[:m]))
res.append(sum(lst6[:m]))
res.append(sum(lst7[:m]))
print(max(res))
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
dp = [np.inf for _ in range(100000)]
dp[0] = 0
num = [1,6,9]
pow6 = [6**i for i in range(10) if 6**i <= n]
pow9 = [9**i for i in range(10) if 9**i <= n]

for i in range(n):
    for p6 in pow6:
        dp[i+p6] = min(dp[i+p6], dp[i]+1)
    for p9 in pow9:
        dp[i+p9] = min(dp[i+p9], dp[i]+1)
print(dp[n])

Fixed submission:
n = int(input())
dp = [10**9]*30000000
dp[0] = 0
pow6 = [6**i for i in range(10) if 6**i <= n]
pow9 = [9**i for i in range(10) if 9**i <= n]

for i in range(n):
    for p6 in pow6:
        dp[i+p6] = min(dp[i+p6], dp[i]+1)
    for p9 in pow9:
        dp[i+p9] = min(dp[i+p9], dp[i]+1)
print(dp[n])

Buggy python submission (verdict: Runtime Error):
n = int(input())
dp = [100000] * 100010
dp[0] = 0
pow6 = [6**i for i in range(10) if 6**i <= n]
pow9 = [9**i for i in range(10) if 9**i <= n]

for i in range(n):
    for p6 in pow6:
        dp[i+p6] = min(dp[i+p6],dp[i]+1)
    for p9 in pow9:
        dp[i+p9] = min(dp[i+p9],dp[i]+1)
print(dp[n])

Fixed submission:
n = int(input())
dp = [10**9]*30000000
dp[0] = 0
pow6 = [6**i for i in range(10) if 6**i <= n]
pow9 = [9**i for i in range(10) if 9**i <= n]

for i in range(n):
    for p6 in pow6:
        dp[i+p6] = min(dp[i+p6], dp[i]+1)
    for p9 in pow9:
        dp[i+p9] = min(dp[i+p9], dp[i]+1)
print(dp[n])
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
X = [0]
C = [0] + np.cumsum(A).tolist()
for i in range(n):
    X.append(X[i-1] ^ A[i])
cnt = 0
for l in range(n):
    for r in range(l+1, n):
        if C[r]-C[l] == X[r]^X[l]:
            cnt += 1
print(cnt+n)

Fixed submission:
a,b = map(int,input().split())
x = a+b
y = a-b
z = a*b
print(max(x,y,z))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = n
for i in range(n):
    grp1 = s[:i]
    grp2 = s[i+1:]
    cnt = grp1.count('W') + grp2.count('E')
    if cnt < ans:
        ans = cnt
print(ans)

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

w_num = [0] * (n+1)
e_num = [0] * (n+1)
e = s.count('E')

for i in range(n):
    if s[i] == 'W':
        w_num[i+1] = w_num[i] + 1
    else:
        w_num[i+1] = w_num[i]
        
    if s[i] == 'E':
        e_num[i+1] = e_num[i] + 1
    else:
        e_num[i+1] = e_num[i]


ans = n

for i in range(n):
    cnt = w_num[i] + (e - e_num[i+1])
    if cnt < ans:
        ans = cnt

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = []
for i in range(n):
    grp1 = s[:i]
    grp2 = s[i+1:]
    cnt = grp1.count('W') + grp2.count('E')
    ans.append(cnt)
print(min(ans))

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

w_num = [0] * (n+1)
e_num = [0] * (n+1)
e = s.count('E')

for i in range(n):
    if s[i] == 'W':
        w_num[i+1] = w_num[i] + 1
    else:
        w_num[i+1] = w_num[i]
        
    if s[i] == 'E':
        e_num[i+1] = e_num[i] + 1
    else:
        e_num[i+1] = e_num[i]


ans = n

for i in range(n):
    cnt = w_num[i] + (e - e_num[i+1])
    if cnt < ans:
        ans = cnt

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
A = list(map(int,input().split()))
X = [0]
C = [0] + np.cumsum(A).tolist()
for i in range(n):
    X.append(X[i-1] ^ A[i])
cnt = 0
for l in range(n):
    for r in range(l+1, n):
        if C[r]-C[l] == X[r]^X[l]:
            cnt += 1
print(cnt+n)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
s = 0
x = 0
r = 0
for l in range(n):
    while r<n and s+a[r]==x^a[r]:
        s += a[r]
        x ^= a[r]
        r += 1
    ans += (r-l)
    if l==r:
        r += 1
    else:
        s -= a[l]
        x ^= a[l]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

n,m = map(int,input().split())
ps = [0] + list(map(int,input().split()))

memo = [[] for _ in range(n+1)]
connect = [[] for _ in range(n+1)]
visited = [0]*(n+1)

for i in range(m):
    x,y = map(int,input().split())
    memo[x].append(y)
    memo[y].append(x)

for i in range(1,n+1):
    connect[i] = memo[i]
    que = deque(memo[i])
    while que:
        vtx = que.popleft()
        for num in memo[vtx]:
            if num not in connect[i]:
                que.append(num)
                connect[i].append(num)

for i in range(1,n+1):
    if ps[i] == i:
        continue
    else:
        pos = ps.index(i)
        if pos in connect[i]:
            ps[pos] = ps[i]
            ps[i] = i

cnt = 0
for i in range(1,n+1):
    if ps[i] != i:
        cnt += 1
print(n - cnt)

Fixed submission:
class UnionFind:
    def __init__(self,n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
    
    def find(self,x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    def same_check(self,x,y):
        return self.find(x) == self.find(y)
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

n,m = map(int,input().split())
ps = list(map(int,input().split()))
uf = UnionFind(n)
for i in range(m):
    x,y = map(int,input().split())
    uf.union(x,y)

cnt = 0
for i,j in enumerate(ps):
    if uf.same_check(i+1 , j):
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum(lst)

n = int(input())
lst = list(map(int,input().split()))

res = 0
for i in range(n):
    tmp_lst = lst[i:]
    c = dict(Counter(f(tmp_lst)))
    if 0 in c:
       res += c[0]
print(res)


Fixed submission:
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum([0] + lst)

n = int(input())
lst = list(map(int,input().split()))
d = dict(Counter(f(lst)))

res = 0
for k,v in d.items():
    if v >= 2:
        res += (v*(v-1))//2
print(res)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum(lst)

n = int(input())
lst = list(map(int,input().split()))

res = 0
for i in range(n):
    tmp_lst = lst[i:]
    c = dict(Counter(f(tmp_lst)))
    if 0 in c:
       res += c[0]
print(res)

Fixed submission:
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum([0] + lst)

n = int(input())
lst = list(map(int,input().split()))
d = dict(Counter(f(lst)))

res = 0
for k,v in d.items():
    if v >= 2:
        res += (v*(v-1))//2
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum(lst)

n = int(input())
lst = list(map(int,input().split()))

res = 0
for i in range(n):
    tmp_lst = lst[i:]
    c = dict(Counter(f(tmp_lst)))
    if 0 in c:
       res += c[0]
print(res)

Fixed submission:
import numpy as np
from collections import Counter
def f(lst):
    return np.cumsum([0] + lst)

n = int(input())
lst = list(map(int,input().split()))
d = dict(Counter(f(lst)))

res = 0
for k,v in d.items():
    if v >= 2:
        res += (v*(v-1))//2
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [int(i) for i in input().split()]
for i in range(n):
    local_lst = lst[:i] + lst[i+1:]
    lst_sort = sorted(local_lst)
    print(lst_sort[n//2-1])

Fixed submission:
n = int(input())
lst = [int(i) for i in input().split()]
lst_sort = sorted(lst)
med = (lst_sort[n//2] + lst_sort[n//2-1])/2

for i in range(n):
    if lst[i] < med:
        print(lst_sort[n//2])
    else:
        print(lst_sort[n//2-1])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
grid_b = [list('#'*100) for _ in range(50)]
grid_w = [list('.'*100) for _ in range(50)]
for i in range(1, a):
    grid_b[2*(i//10)-1][2*(i%10)-1] = '.'
for i in range(1, b):
    grid_w[2*(i//10)-1][2*(i%10)-1] = '#'
print(100, 100)
grid = grid_b + grid_w
for g in grid:
    print(*g)

Fixed submission:
a,b=map(int,input().split())
ans=[['#' for i in range(100)] for j in range(50)]
ans+=[['.' for i in range(100)] for j in range(50)]
for i in range(a-1):
    ans[(i//50)*2][(i%50)*2]='.'
for i in range(b-1):
    ans[(i//50)*2+52][(i%50)*2]='#'
print(100,100)
for i in range(100):
    print(''.join(ans[i]))

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
a,b = a-1,b-1
grid_b = [list('#'*100) for _ in range(50)]
grid_w = [list('.'*100) for _ in range(50)]
for i in range(a):
    grid_b[2*(i//10)+1][2*(i%10)+1] = '.'
for i in range(b):
    grid_w[2*(i//10)+1][2*(i%10)+1] = '#'

grid = grid_b + grid_w

print(100, 100)
for g in grid:
    print(*g)


Fixed submission:
a,b=map(int,input().split())
ans=[['#' for i in range(100)] for j in range(50)]
ans+=[['.' for i in range(100)] for j in range(50)]
for i in range(a-1):
    ans[(i//50)*2][(i%50)*2]='.'
for i in range(b-1):
    ans[(i//50)*2+52][(i%50)*2]='#'
print(100,100)
for i in range(100):
    print(''.join(ans[i]))
Buggy python submission (verdict: Time Limit Exceeded):
def  main():
    N,K = map(int,input().split())
    ans = 0
    for k in range(K,N):
        for b in range(k+1,N+1):
            cnt = (N-k)//b
            if k!=0:
                cnt += 1
            ans += cnt
    print(ans)    


if __name__ == '__main__':
    main()

Fixed submission:
n,k = map(int,input().split())
count = 0
if k==0:
    print(n ** 2)
    exit()

for i in range(1,n+1):
    if i <= k:
        continue
    count += max(0, (n%i) - k + 1)
    count += (n // i) * (i - k)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
ans = 0
for k in range(K,N):
    for b in range(k+1,N+1):
        cnt = (N-k)//b
        if k!=0:
            cnt += 1
        ans += cnt
print(ans)

Fixed submission:
n,k = map(int,input().split())
count = 0
if k==0:
    print(n ** 2)
    exit()

for i in range(1,n+1):
    if i <= k:
        continue
    count += max(0, (n%i) - k + 1)
    count += (n // i) * (i - k)
print(count)