Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ls = "abcdefghijklmnopqrstuvwxyz"
cnt = 0

while 26 ** (cnt + 1) < 25 * n / 26 + 1:
    cnt += 1
ans = ""
#print(cnt, n)
n -= 1
for i in range(cnt, -1, -1):
    if i == 0:
        res = n // (26 ** i)
    else:
        res = n // (26 ** i) - 1
    ans += ls[res]
    n -= 26 ** i * (res + 1)
print(ans)

Fixed submission:
import math
n = int(input())
ls = "abcdefghijklmnopqrstuvwxyz"
cnt = 0
base = 26
while n >= base ** cnt:
    n -= base ** cnt
    cnt += 1
ans = ""
#print(cnt, n)
for i in range(cnt-1, -1, -1):
    res = n // (base ** i)
    ans += ls[res]
    n -= base ** i * res
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ls = "abcdefghijklmnopqrstuvwxyz"
#i = 1
cnt = math.ceil(math.log(25 * n / 26 + 1, 26)) - 1
ans = ""
#print(cnt, n)
n -= 1
for i in range(cnt, -1, -1):
    if i == 0:
        res = n // (26 ** i)
    else:
        res = n // (26 ** i) - 1
    ans += ls[res]
    n -= 26 ** i * (res + 1)
print(ans)

Fixed submission:
import math
n = int(input())
ls = "abcdefghijklmnopqrstuvwxyz"
cnt = 0
base = 26
while n >= base ** cnt:
    n -= base ** cnt
    cnt += 1
ans = ""
#print(cnt, n)
for i in range(cnt-1, -1, -1):
    res = n // (base ** i)
    ans += ls[res]
    n -= base ** i * res
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
ls = "abcdefghijklmnopqrstuvwxyz"
#i = 1
cnt = math.ceil(math.log(25 * n / 26 + 1, 26)) - 1
ans = ""
#print(cnt, n)
n -= 1
for i in range(cnt, -1, -1):
    if i == 0:
        res = n // (26 ** i)
    else:
        res = n // (26 ** i) - 1
    ans += ls[res]
    n -= 26 ** i * (res + 1)
print(ans)

Fixed submission:
import math
n = int(input())
ls = "abcdefghijklmnopqrstuvwxyz"
cnt = 0
base = 26
while n >= base ** cnt:
    n -= base ** cnt
    cnt += 1
ans = ""
#print(cnt, n)
for i in range(cnt-1, -1, -1):
    res = n // (base ** i)
    ans += ls[res]
    n -= base ** i * res
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from bisect import bisect_left
x, n = [int(i) for i in sys.stdin.readline().split()]
p_s = [int(i) for i in sys.stdin.readline().split()]
candidate = [i for i in range(1,101) if i not in p_s]
ind = bisect_left(candidate, x)
if ind == len(candidate):
    print(candidate[-1])
elif x - candidate[ind-1] <= candidate[ind] - x:
    print(candidate[ind-1])
else:
    print(candidate[ind])

Fixed submission:
import sys
from bisect import bisect_left
x, n = [int(i) for i in sys.stdin.readline().split()]
p_s = [int(i) for i in sys.stdin.readline().split()]
candidate = [i for i in range(-1000,1000) if i not in p_s]
ind = bisect_left(candidate, x)
if ind == len(candidate):
    print(candidate[-1])
elif x - candidate[ind-1] <= candidate[ind] - x:
    print(candidate[ind-1])
else:
    print(candidate[ind])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
from collections import Counter
from math import sqrt

n = int(input())
a_s = [int(i) for i in sys.stdin.readline().split()]
a_s.sort()
_max = max(a_s)
ct = Counter(a_s)
cnt = 0
ls = [0] * (10**6+1)
for a in a_s:
    if ls[a] == 1:
        cnt += 1
        continue
    elif ct[a] > 1:
        cnt += 1
    for i in range(a, _max+1):
        if ls[i] == 1:
            continue
        if i % a == 0:
            ls[i] = 1

print(n - cnt)

Fixed submission:
import sys
import heapq
from collections import Counter
from math import sqrt

n = int(input())
a_s = [int(i) for i in sys.stdin.readline().split()]
a_s.sort()
_max = max(a_s)
ct = Counter(a_s)
cnt = 0
ls = [False] * (10**6+1)
for a in a_s:
    if ls[a]:
        cnt += 1
        continue
    elif ct[a] > 1:
        cnt += 1
    for i in range(a, _max+1, a):
        if ls[i]:
            continue
        if i % a == 0:
            ls[i] = True

print(n - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
from collections import Counter
import numpy as np

n = int(input())
a_s = [int(i) for i in sys.stdin.readline().split()]
a_s.sort()
ct = Counter(a_s)
cnt = 0
res = np.zeros(10**6+1)
for a in a_s:
    if res[a] == 1:
        cnt += 1
    elif ct[a] > 1:
        cnt += 1
    res[::a] = 1

print(n - cnt)

Fixed submission:
import sys
import heapq
from collections import Counter
from math import sqrt

n = int(input())
a_s = [int(i) for i in sys.stdin.readline().split()]
a_s.sort()
_max = max(a_s)
ct = Counter(a_s)
cnt = 0
ls = [False] * (10**6+1)
for a in a_s:
    if ls[a]:
        cnt += 1
        continue
    elif ct[a] > 1:
        cnt += 1
    for i in range(a, _max+1, a):
        if ls[i]:
            continue
        if i % a == 0:
            ls[i] = True

print(n - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
from collections import Counter

n = int(input())
a_s = [int(i) for i in sys.stdin.readline().split()]
ct = Counter(a_s)
a_s.sort()
_max = max(a_s)
que = [(i, i) for i in a_s]
cur = 0
res = set()
while cur <= _max:
    cur, base = heapq.heappop(que)
    if cur != base:
        if cur in a_s:
            res.add(cur)
    else:
        if ct[cur] > 1:
            res.add(cur)
    heapq.heappush(que, (cur + base, base))

print(len(set(a_s)) - len(res))

Fixed submission:
import sys
import heapq
from collections import Counter
from math import sqrt

n = int(input())
a_s = [int(i) for i in sys.stdin.readline().split()]
a_s.sort()
_max = max(a_s)
ct = Counter(a_s)
cnt = 0
ls = [False] * (10**6+1)
for a in a_s:
    if ls[a]:
        cnt += 1
        continue
    elif ct[a] > 1:
        cnt += 1
    for i in range(a, _max+1, a):
        if ls[i]:
            continue
        if i % a == 0:
            ls[i] = True

print(n - cnt)
Buggy python submission (verdict: Runtime Error):
import sys

a, b = [float(i) for i in sys.stdin.readline().split()]
a = int(a)
a *= int(b * 100)
print(int(str(a)[:-2]))

Fixed submission:
from decimal import *
A,B = input().split()
A = int(A)
B = Decimal(B)
print(int(A*B))
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {i:[] for i in range(n)}
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

que = [0]
res = {0:-1}
while len(que) > 0:
    cur = que.pop(0)
    for _next in graph[cur]:
        if _next in res:
            continue
        res[_next] = cur
        que.append(_next)
if len(res) < n:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(res[i]+1)

Fixed submission:
import sys
from collections import deque

n, m = [int(i) for i in sys.stdin.readline().split()]
graph = {i:[] for i in range(n)}
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

que = deque([0])
res = {0:-1}
while len(que) > 0:
    cur = que.popleft()
    for _next in graph[cur]:
        if _next in res:
            continue
        res[_next] = cur
        que.append(_next)

if len(res) < n:
    print("No")
else:
    print("Yes")
    for i in range(1,n):
        print(res[i]+1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s = input()
MOD = 2019
ts = [0]
cur = 0
for i, j in enumerate(s[::-1], 1):
    cur = (cur + 10**i % MOD * int(j)) % MOD
    ts.append(cur)
ct = Counter(ts)
res = 0
for k, v in ct.items():
    if v > 1:
        res += v * (v-1) // 2
print(res)

Fixed submission:
from collections import Counter
s = input()
MOD = 2019
ts = [0]
cur = 0
for i, j in enumerate(s[::-1], 1):
    cur = (cur + pow(10, i, MOD) * int(j)) % MOD
    ts.append(cur)
ct = Counter(ts)
res = 0
for k, v in ct.items():
    if v > 1:
        res += v * (v-1) // 2
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
s = input()
MOD = 2019
ts = [0]
cur = 0
for i, j in enumerate(s[::-1], 1):
    cur = (cur + int(j) * 10**i % MOD) % MOD
    ts.append(cur)
ct = Counter(ts)
res = 0
for k, v in ct.items():
    if v > 1:
        res += v * (v-1) // 2
print(res)

Fixed submission:
from collections import Counter
s = input()
MOD = 2019
ts = [0]
cur = 0
for i, j in enumerate(s[::-1], 1):
    cur = (cur + pow(10, i, MOD) * int(j)) % MOD
    ts.append(cur)
ct = Counter(ts)
res = 0
for k, v in ct.items():
    if v > 1:
        res += v * (v-1) // 2
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
MOD = 10**9+7
def gcd(a, b):
    while a and b:
        if a > b:
            a %= b
        else:
            b %= a
    return max(a, b)

def lcm(a, b):
    _gcd = gcd(a, b)
    return a * b // _gcd

_a = a_ls[0]
for a in a_ls:
    _a = lcm(_a, a)
ls = [_a // a % MOD for a in a_ls]
print(sum(ls) % MOD)

Fixed submission:
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
MOD = 10**9+7
def gcd(a, b):
    while a and b:
        if a > b:
            a %= b
        else:
            b %= a
    return max(a, b)

def lcm(a, b):
    _gcd = gcd(a, b)
    return a * b // _gcd

_a = a_ls[0]
for a in a_ls:
    _a = lcm(_a, a)
ls = [_a // a for a in a_ls]
print(sum(ls) % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
MOD = 10**9+7
def gcd(a, b):
    while a and b:
        if a > b:
            a %= b
        else:
            b %= a
    return max(a, b)

def lcm(a, b):
    _gcd = gcd(a, b)
    return a * b // _gcd

_a = a_ls[0]
for a in a_ls:
    _a = lcm(_a, a)
ls = [_a // a for a in a_ls]
print(sum(ls) % MOD)

Fixed submission:
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
MOD = 10**9+7
def gcd(a, b):
    while a and b:
        if a > b:
            a %= b
        else:
            b %= a
    return max(a, b)

def lcm(a, b):
    _gcd = gcd(a, b)
    return a * b // _gcd

_a = a_ls[0]
for a in a_ls:
    _a = lcm(_a, a)
ls = [_a // a for a in a_ls]
print(sum(ls) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10 ** 9 + 7

res = 0
for i, c in enumerate(c_ls):
    res += (2 ** (n - 2) * (i + 2)) * c % MOD
    res %= MOD
res = res * (2 ** n) % MOD
print(int(res))

Fixed submission:
import sys

n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10 ** 9 + 7

res = 0
for i, c in enumerate(c_ls):
    res += (i + 2) * c % MOD
    res %= MOD
res = res * (4 ** (n - 1)) % MOD
print(int(res))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10**9+7

res = 0
for i, c in enumerate(c_ls):
    res += (2 ** (n - 2) * (i+2)) * c % MOD
    res %= MOD
res = res * (2**n) % MOD
print(int(res))

Fixed submission:
import sys

n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10 ** 9 + 7

res = 0
for i, c in enumerate(c_ls):
    res += (i + 2) * c % MOD
    res %= MOD
res = res * (4 ** (n - 1)) % MOD
print(int(res))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import factorial
n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10**9+7

res = 0
for i, c in enumerate(c_ls):
    res += (2 ** (n - 1) + 2 ** (n - 2) * i) * c
    res %= MOD
res = res * (2**n) % MOD
print(int(res))

Fixed submission:
import sys

n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10 ** 9 + 7

res = 0
for i, c in enumerate(c_ls):
    res += (i + 2) * c % MOD
    res %= MOD
res = res * (4 ** (n - 1)) % MOD
print(int(res))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import factorial
n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10**9+7

res = 0
for i in range(n-1, -1, -1):
    res += (2 ** (n - 1) + 2 ** (n - 2) * i) * c_ls[i]
    res %= MOD
res = res * (2**n) % MOD
print(int(res))

Fixed submission:
import sys

n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10 ** 9 + 7

res = 0
for i, c in enumerate(c_ls):
    res += (i + 2) * c % MOD
    res %= MOD
res = res * (4 ** (n - 1)) % MOD
print(int(res))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from math import factorial
n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10**9+7

def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)

res = 0
for i in range(n-1, -1, -1):
    hoge = sum([nCr(i, j) * j * 2 ** (n - i - 1) for j in range(1,i+1)])
    res += (2 ** (n - 1) + hoge) * c_ls[i]
    res %= MOD
res = res * (2**n) % MOD
print(res)

Fixed submission:
import sys

n = int(input())
c_ls = [int(i) for i in sys.stdin.readline().split()]
c_ls.sort(reverse=True)
MOD = 10 ** 9 + 7

res = 0
for i, c in enumerate(c_ls):
    res += (i + 2) * c % MOD
    res %= MOD
res = res * (4 ** (n - 1)) % MOD
print(int(res))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort(reverse=True)
cur_ls = [0 for i in range(n)]
_max = max(a_ls)
que = [(- a - _max, i) for i, a in enumerate(a_ls)]
heapq.heapify(que)
cnt = 0
res = 0
while cnt < m:
    cur, i = heapq.heappop(que)
    res += - cur
    cnt += 1
    cur_ls[i] += 1
    if cur_ls[i] < n:
        heapq.heappush(que, (- a_ls[i] - a_ls[cur_ls[i]], i))
print(res)

Fixed submission:
import sys
from itertools import accumulate
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort(reverse=True)
ls = [0 for i in range(10**6)]
for a in a_ls:
    ls[a+1] += 1
ls = [i for i in accumulate(ls)]

def check(x):
    res = 0
    for a in a_ls:
        res += n - ls[max(0,x - a)]
    return res

up = 10**6
down = 0
while True:
    mid = (up + down) // 2
    if check(mid) >= m:
        if down == mid:
            break
        down = mid
    else:
        if up == mid:
            if check(up) == m:
                mid = up
            break
        up = mid

acc_ls = [i for i in accumulate([0] + a_ls)]
ans = 0
for a in a_ls:
    x = n - ls[max(0, mid - a)]
    ans += x * a + acc_ls[x]
print(ans - (check(mid) - m) * mid)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort(reverse=True)
cur_ls = [0 for i in range(n)]
_max = max(a_ls)
que = [(- a - _max, i) for i, a in enumerate(a_ls)]
heapq.heapify(que)
cnt = 0
res = 0
while cnt < m:
    cur, i = heapq.heappop(que)
    res += - cur
    cnt += 1
    cur_ls[i] += 1
    if cur_ls[i] < n:
        heapq.heappush(que, (- a_ls[i] - a_ls[cur_ls[i]], i))
print(res)

Fixed submission:
import sys
from itertools import accumulate
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort(reverse=True)
ls = [0 for i in range(10**6)]
for a in a_ls:
    ls[a+1] += 1
ls = [i for i in accumulate(ls)]

def check(x):
    res = 0
    for a in a_ls:
        res += n - ls[max(0,x - a)]
    return res

up = 10**6
down = 0
while True:
    mid = (up + down) // 2
    if check(mid) >= m:
        if down == mid:
            break
        down = mid
    else:
        if up == mid:
            if check(up) == m:
                mid = up
            break
        up = mid

acc_ls = [i for i in accumulate([0] + a_ls)]
ans = 0
for a in a_ls:
    x = n - ls[max(0, mid - a)]
    ans += x * a + acc_ls[x]
print(ans - (check(mid) - m) * mid)
Buggy python submission (verdict: Time Limit Exceeded):
import re
from collections import Counter
s = input()
res = re.findall(r"<+>+", s) + re.findall(r"^>+", s) + re.findall(r"<+$", s)

def calc(string):
    ct = Counter(string)
    cnt_d = ct[">"]
    cnt_s = ct["<"]
    if cnt_s > cnt_d:
        return (cnt_s * (cnt_s + 1) + (cnt_d - 1) * cnt_d) // 2
    elif cnt_s == cnt_d:
        return cnt_s * cnt_s
    else:
        return ((cnt_d + 1) * cnt_d + (cnt_s - 1) * cnt_s) // 2
score = 0
for r in res:
    score += calc(r)
print(score)

Fixed submission:
import re
from collections import Counter
s = input()
res = re.finditer(r"(<+>+)|(^>+)|(<+$)", s)

def calc(string):
    ct = Counter(string)
    cnt_d = ct[">"]
    cnt_s = ct["<"]
    if cnt_s > cnt_d:
        return (cnt_s * (cnt_s + 1) + (cnt_d - 1) * cnt_d) // 2
    elif cnt_s == cnt_d:
        return cnt_s * cnt_s
    else:
        return ((cnt_d + 1) * cnt_d + (cnt_s - 1) * cnt_s) // 2
score = 0
for r in res:
    score += calc(r.group())
print(score)
Buggy python submission (verdict: Runtime Error):
import sys
import math
a, b, x = [float(i) for i in sys.stdin.readline().split()]
if x < a**2*b / 2:
    print(90.0 - math.degrees(math.atan(x / (a*b**2/2))))
else:
    print(90.0 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))

Fixed submission:
import sys
import math
a, b, x = [float(i) for i in sys.stdin.readline().split()]

if x < a**2*b / 2:
    print(90.0 - math.degrees(math.atan(x / (a*b**2/2))))
elif a**2*b-x == 0:
    print(0.0)
else:
    print(90.0 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))

Buggy python submission (verdict: Runtime Error):
import sys
import math
a, b, x = [int(i) for i in sys.stdin.readline().split()]
if x < a**2*b / 2:
    print(90.0 - math.degrees(math.atan(x / (a*b**2/2))))
else:
    print(90.0 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))

Fixed submission:
import sys
import math
a, b, x = [float(i) for i in sys.stdin.readline().split()]

if x < a**2*b / 2:
    print(90.0 - math.degrees(math.atan(x / (a*b**2/2))))
elif a**2*b-x == 0:
    print(0.0)
else:
    print(90.0 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))

Buggy python submission (verdict: Runtime Error):
import sys
import math
a, b, x = [int(i) for i in sys.stdin.readline().split()]
if x <= a**2*b / 2:
    print(90 - math.degrees(math.atan(x / (a*b**2/2))))
else:
    print(90 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))

Fixed submission:
import sys
import math
a, b, x = [float(i) for i in sys.stdin.readline().split()]

if x < a**2*b / 2:
    print(90.0 - math.degrees(math.atan(x / (a*b**2/2))))
elif a**2*b-x == 0:
    print(0.0)
else:
    print(90.0 - math.degrees(math.atan(a**3 / 2 / (a**2*b-x))))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
n, k = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
f_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort(reverse=True)
f_ls.sort()
res = [- a * f for a, f in zip(a_ls, f_ls)]
heapq.heapify(res)
cnt = 0
flg = False
while True:
    for i in range(n):
        if a_ls[i] == 0:
            continue
        if a_ls[i] * f_ls[i] == - res[0]:
            cnt += 1
            a_ls[i] -= 1
            heapq.heappop(res)
            heapq.heappush(res, - a_ls[i] * f_ls[i])
        if cnt == k:
            flg = True
            break
    if not any(a_ls):
        flg = True
    if flg:
        break
print(- res[0])

Fixed submission:
import sys
import numpy as np
n, k = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
f_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort(reverse=True)
f_ls.sort()
a_sum = sum(a_ls)
a_ls = np.array(a_ls)
f_ls = np.array(f_ls)
minimum = 0
maximum = (a_ls * f_ls).sum()
def check(x):
    """
    :param x:
    :return: x以下で可能か
    """
    return a_sum - np.minimum(a_ls, x // f_ls).sum() <= k
while True:
    center = (maximum + minimum) // 2
    if check(center):
        if maximum == center:
            res = center
            break
        maximum = center
    else:
        if minimum == center:
            if check(maximum):
                res = maximum
                break
            else:
                res = minimum
        minimum = center
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
INF = int(1e10)
n, m = [int(i) for i in sys.stdin.readline().split()]
# n : box, m : key
key_info = dict()
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    c_ls = [int(i)-1 for i in sys.stdin.readline().split()]
    c_ls = "".join(["1" if c in c_ls else "0" for c in range(n-1,-1,-1)])
    key_info[i] = [a, int(c_ls, 2)]

memo_ls = [[INF for i in range(2**n)] for j in range(m)]
# memo_ls[i][j] : i番目までの鍵で状態を j にする為に必要な最小費用
for i in range(m):
    memo_ls[i][0] = 0
    for j in range(2**n):
        memo_ls[i][j] = min(memo_ls[i][j], memo_ls[max(0, i-1)][j])
        memo_ls[i][j | key_info[i][1]] = min(memo_ls[i][j | key_info[i][1]], memo_ls[max(i-1, 0)][j | key_info[i][1]], memo_ls[max(0, i-1)][j] + key_info[i][0])
if memo_ls[-1][-1] == INF:
    print(-1)
else:
    print(memo_ls[-1][-1])

Fixed submission:
import sys
INF = int(1e10)
n, m = [int(i) for i in sys.stdin.readline().split()]
# n : box, m : key
key_info = dict()
for i in range(m):
    a, b = [int(i) for i in sys.stdin.readline().split()]
    c_ls = [int(i)-1 for i in sys.stdin.readline().split()]
    c_ls = "".join(["1" if c in c_ls else "0" for c in range(n-1,-1,-1)])
    key_info[i] = [a, int(c_ls, 2)]

memo_ls = [[INF for i in range(2**n)] for j in range(m)]
# memo_ls[i][j] : i番目までの鍵で状態を j にする為に必要な最小費用
for i in range(m):
    memo_ls[i][0] = 0
    for j in range(2**n):
        memo_ls[i][j] = min(memo_ls[i][j], memo_ls[max(0, i-1)][j])
        memo_ls[i][j | key_info[i][1]] = min(memo_ls[i][j | key_info[i][1]], memo_ls[max(i-1, 0)][j | key_info[i][1]], memo_ls[max(0, i-1)][j] + key_info[i][0])
if memo_ls[-1][-1] == INF:
    print(-1)
else:
    print(memo_ls[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
h, w, a, b = [int(i) for i in sys.stdin.readline().split()]
res = ""
for y in range(b):
    res += "0" * a + "1" * (w - a)
    res += "\n"
for y in range(h-b):
    res += "1" * a + "0" * (w - a)
    res += "\n"
print(res)

Fixed submission:
import sys
h, w, a, b = [int(i) for i in sys.stdin.readline().split()]
res = []
res.append(("0" * a + "1" * (w - a) + "\n") * b)
res.append(("1" * a + "0" * (w - a) + "\n") * (h-b))
print("".join(res))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
memo_ls = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    for j in range(min(i+1,n-1), n):
        if s[i] == s[j]:
            memo_ls[i][j] = memo_ls[i-1][j-1] + 1
for i in range(n):
    for j in range(min(i+1,n-1), n):
        if memo_ls[i][j] > 0:
            if j - i < memo_ls[i][j]:
                memo_ls[i][j] = j - i
print(max([max(i) for i in memo_ls]))

Fixed submission:
n = int(input())
s = input()
_max = 0
memo_ls = [[0 for i in range(n)] for j in range(n)]
memo_dict = {i : [0 for j in range(n)] for i in range(-1,n)}
for i in range(n):
    for j in range(min(i+1,n-1), n):
        if s[i] != s[j]:
            continue
        candidate = memo_dict[i-1][j-1] + 1
        if candidate > j - i:
            candidate = j - i
        memo_dict[i][j] = candidate
        if candidate > _max:
            _max = candidate
print(_max)