Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    h, w, m = ns()

    hm = [0 for _ in range(h)]
    wm = [0 for _ in range(w)]

    m_pos = {}

    for _ in range(m):
        hi, wi = ns()
        hi, wi = hi - 1, wi - 1
        hm[hi] += 1
        wm[wi] += 1

        if hi in m_pos.keys():
            m_pos[hi].add(wi)
        else:
            m_pos[hi] = {wi}

    h_max = []
    w_max = []

    tmax = -1
    for i, hi in enumerate(hm):
        if hi > tmax:
            tmax = hi
            h_max = [i]
        elif hi == tmax:
            h_max.append(i)

    tmax = -1
    for i, wi in enumerate(wm):
        if wi > tmax:
            tmax = wi
            w_max = [i]
        elif wi == tmax:
            w_max.append(i)

    ans = 0

    for hi in h_max:
        for wi in w_max:
            if wi in m_pos[hi]:
                ans = max(ans, hm[hi] + wm[wi] - 1)

            else:
                ans = max(ans, hm[hi] + wm[wi])

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    h, w, m = ns()

    hm = [0 for _ in range(h)]
    wm = [0 for _ in range(w)]

    m_pos = {}

    for _ in range(m):
        hi, wi = ns()
        hi, wi = hi - 1, wi - 1
        hm[hi] += 1
        wm[wi] += 1

        if hi in m_pos.keys():
            m_pos[hi].add(wi)
        else:
            m_pos[hi] = {wi}

    h_max = []
    w_max = []

    tmax = -1
    for i, hi in enumerate(hm):
        if hi > tmax:
            tmax = hi
            h_max = [i]
        elif hi == tmax:
            h_max.append(i)

    tmax = -1
    for i, wi in enumerate(wm):
        if wi > tmax:
            tmax = wi
            w_max = [i]
        elif wi == tmax:
            w_max.append(i)

    ans = 0
    breakflg = False

    for hi in h_max:
        for wi in w_max:
            if wi in m_pos[hi]:
                ans = max(ans, hm[hi] + wm[wi] - 1)
            else:
                ans = max(ans, hm[hi] + wm[wi])
                breakflg = True
                break
        if breakflg:
            break

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()
    a.sort(reverse=True)
    upper = 10 ** 9 + 1
    under = 0

    while upper - under > 0.01:
        middle = (upper + under) // 2

        tk = k
        flg = True
        for ai in a:
            if ai <= middle:
                break

            ta = ai
            tk -= int((ta - middle) / middle)
            if tk < 0:
                flg = False
            break

        if flg:
            upper = middle
        else:
            under = middle

    print(math.ceil(under))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()
    a.sort(reverse=True)
    upper = 10**9 + 1
    under = 0

    while upper - under > 1:
        middle = (upper + under) // 2

        tk = k
        flg = True
        for ai in a:
            if ai <= middle:
                break

            ta = ai
            tk -= int(ta // middle)
            if tk < 0:
                flg = False
                break

        if flg:
            upper = middle
        else:
            under = middle

    if k == 0:
        print(max(a))
    else:
        print(math.ceil((upper + under) / 2))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    tmp = 1
    for i in range(k):
        tmp *= a[i]

    prev = tmp

    for i in range(k, n):
        crnt = (prev // a[i - k]) * a[i]

        print("Yes" if crnt > prev else "No")
        prev = crnt


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, k = ns()
    a = na()

    # tmp = 1
    # for i in range(k):
    #     tmp *= a[i]
    #
    # prev = tmp

    for i in range(k, n):
        # crnt = (prev // a[i - k]) * a[i]

        print("Yes" if a[i] > a[i-k] else "No")
        # prev = crnt


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    i = nis()
    print(i + i ** 2 + i ** 3)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    i = ni()
    print(i + i ** 2 + i ** 3)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m, k = ns()
    a = na()
    b = na()

    a_idx = 0
    b_idx = 0
    ans = 0
    cnt = 0
    while True:
        if a_idx == n and b_idx == m:
            break

        if a_idx != n:
            if a[a_idx] < b[b_idx]:
                if ans + a[a_idx] > k:
                    break
                else:
                    ans += a[a_idx]
                    a_idx += 1
                    cnt += 1
            else:
                if ans + b[b_idx] > k:
                    break
                else:
                    ans += b[b_idx]
                    b_idx += 1
                    cnt += 1
        else:
            if ans + b[b_idx] > k:
                break
            else:
                ans += b[b_idx]
                b_idx += 1
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, m, k = ns()
    a = na()
    b = na()

    perm_a = [0 for _ in range(n + 1)]
    perm_b = [0 for _ in range(m + 1)]

    for i, ai in enumerate(a):
        perm_a[i + 1] = perm_a[i] + ai

    for i, bi in enumerate(b):
        perm_b[i + 1] = perm_b[i] + bi

    perm_a.append(INF)
    perm_b.append(INF)

    ans = 0
    for i, pa in enumerate(perm_a):
        bserch = k - pa
        if bserch < 0:
            continue
        if bserch == 0:
            ans = max(ans, i)
            continue

        idx = bisect.bisect_left(perm_b, bserch)
        tmp_ans = i + idx - 1
        if perm_b[idx] == bserch:
            tmp_ans += 1
        ans = max(ans, tmp_ans)

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = []
    b = []
    d = []
    for _ in range(n):
        ai, bi = ns()
        a.append(ai)
        b.append(bi)
        d.append((ai, bi))

    a.sort()
    b.sort()

    odd = n % 2 == 1
    even = n % 2 == 0
    min_choice = a[n // 2 - even]
    max_choice = b[n // 2]

    kouho = []
    for ai, bi in d:
        tmp = range(max(ai, min_choice), min(bi, max_choice))
        if len(tmp) > 0:
            kouho.append(tmp)

    dic_even = dict()
    dic_odd = dict()

    for k in kouho:
        for t in k:
            dic_even[t] = 0

    for i in range(len(kouho)):
        for t in kouho[i]:
            for j in range(i + 1, len(kouho)):
                for l in kouho[j]:
                    dic_odd[(t + l) / 2] = 0
    
    e = set(dic_even.keys())
    o = set(dic_odd.keys())
    
    ans = e+o
    print(len(ans))


if __name__ == '__main__':
    main()


Fixed submission:
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = []
    b = []
    for _ in range(n):
        ai, bi = ns()
        a.append(ai)
        b.append(bi)

    a.sort()
    b.sort()

    if n % 2:
        ans = b[n // 2] - a[n // 2] + 1
    else:
        ans = b[n // 2] + b[n // 2 - 1] - (a[n // 2] + a[n // 2 - 1]) + 1
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import math
import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

# ===CODE===

a, b, n = map(float, input().split())

left = 1
right = n

ans = 0
num = 0
while abs(left - right) > 10**(-8):
    tmp_left = left + (right - left) / 3
    tmp_right = left + 2 * (right - left) / 3

    c_left = math.floor(a * left / b) - a * math.floor(left / b)
    c_right = math.floor(a * right / b) - a * math.floor(right / b)

    f_left = math.floor(a * tmp_left / b) - a * math.floor(tmp_left / b)
    f_right = math.floor(a * tmp_right / b) - a * math.floor(tmp_right / b)

    if c_left < f_left < f_right:
        left = tmp_left
        if ans < f_left:
            ans = f_left
            num = tmp_left
    else:
        right = tmp_right
        if ans < f_right:
            ans = f_right
            num = tmp_right

    ans1 = math.floor(a * int(num) / b) - a * math.floor(int(num) / b)
    ans2 = math.floor(a * int(num+1) / b) - a * math.floor(int(num+1) / b)

print(int(max(ans1,ans2)))


Fixed submission:
import sys
import math
import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

# ===CODE===

a, b, n = map(float, input().split())

left = 1
right = n

ans = 0
num = 0
while abs(left - right) > 10 ** (-2):
    tmp_left = left + (right - left) / 3
    tmp_right = left + 2 * (right - left) / 3

    c_left = math.floor(a * left / b) - a * math.floor(left / b)
    c_right = math.floor(a * right / b) - a * math.floor(right / b)

    f_left = math.floor(a * tmp_left / b) - a * math.floor(tmp_left / b)
    f_right = math.floor(a * tmp_right / b) - a * math.floor(tmp_right / b)

    if c_left <= f_left <= f_right:
        left = tmp_left
        if ans < f_left:
            ans = f_left
            num = tmp_left

    elif f_left >= f_right >= c_right:
        right = tmp_right
        if ans < f_right:
            ans = f_right
            num = tmp_right
    else:
        if c_left > c_right:
            right = tmp_right
            if ans < f_right:
                ans = f_right
                num = tmp_right
        else:
            left = tmp_left
            if ans < f_left:
                ans = f_left
                num = tmp_left

ans1 = math.floor(a * int(num) / b) - a * math.floor(int(num) / b)
ans2 = math.floor(a * int(num + 1) / b) - a * math.floor(int(num + 1) / b)

print(int(max(ans1, ans2)))
Buggy python submission (verdict: Runtime Error):
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
MOD = 10 ** 9 + 7

n, k = map(int, input().split())
n += 1

sum_mat = [0]
for i in range(1, 2*(10**5)+1):
    sum_mat.append(sum_mat[i-1]+i)


ans = 0
for i in range(k, n + 1):
    top = sum_mat[i]
    bottom = sum_mat[i-1] - 1
    ans += (i * n - top - bottom) % MOD
    ans %= MOD

print(ans)


Fixed submission:
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
MOD = 10 ** 9 + 7

n, k = map(int, input().split())
n += 1

sum_mat = [0]
for i in range(1, 2*(10**5)+3):
    sum_mat.append(sum_mat[i-1]+i)


ans = 0
for i in range(k, n + 1):
    top = sum_mat[i]
    bottom = sum_mat[i-1] - 1
    ans += (i * n - top - bottom) % MOD
    ans %= MOD

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())


ans = 0
tmp_gcd={}
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            ans += gcd(i,j,k)

print(ans)

Fixed submission:
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===


n = int(input())


ans = 0
dic = {}

for i in range(1, n+1):
    for j in range(1, n+1):
        tmp = math.gcd(i,j)
        if tmp in dic:
            dic[tmp] += 1
        else:
            dic[tmp] = 1

for key in dic:
    for i in range(1, n+1):
        ans += math.gcd(key, i) * dic[key]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = input()
    n = ni()

    cnt = 0
    for i in range(n):
        d = list(sys.stdin.readline().split())
        if int(d[0]) == 1:
            cnt = (cnt + 1) % 2
        else:
            if not cnt:
                if int(d[1]) == 1:
                    s = d[2] + s
                else:
                    s = s + d[2]
            else:
                if int(d[1]) == 1:
                    s = s + d[2]
                else:
                    s = d[2] + s

    if cnt:
        s = s[::-1]

    print(s)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
# MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = input()
    n = ni()

    front = ""
    rear = ""

    cnt = 0
    for i in range(n):
        d = list(sys.stdin.readline().split())
        if int(d[0]) == 1:
            cnt = (cnt + 1) % 2
        else:
            if not cnt:
                if int(d[1]) == 1:
                    front = d[2] + front
                else:
                    rear = rear + d[2]
            else:
                if int(d[1]) == 1:
                    rear = rear + d[2]
                else:
                    front = d[2] + front

    if cnt:
        s = s[::-1]
        front = front[::-1]
        rear = rear[::-1]
        ans = rear + s + front
    else:
        ans = front + s + rear

    print(ans)


if __name__ == '__main__':
    main()