Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import re
N = int(input())
S = input()
cnt = 0
for i in range(10):
    for j in range(10):
        for h in range(10):
            patrn = r".*" + re.escape(str(i)) + r".*" + re.escape(str(j)) + r".*" + re.escape(str(h)) + r".*"
            repatrn = re.compile(patrn)
            result = repatrn.match(S)
            #result = re.match(patrn, S)
            if result != None:
                cnt += 1
print(cnt)

Fixed submission:
import re
#import time
N = int(input())
S = input()
#start = time.time()
cnt = 0
for i in range(10):
    fir = S.find(str(i))
    if fir == -1:
        continue
    for j in range(10):
        sec = S.find(str(j), fir + 1)
        if sec == -1:
            continue
        for h in range(10):
            thi = S.find(str(h), sec + 1)
            if thi == -1:
                continue
            cnt += 1
print(cnt)
#stop = time.time()
#print(stop - start)

Buggy python submission (verdict: Time Limit Exceeded):
import re
N = int(input())
S = input()
cnt = 0
for i in range(10):
    for j in range(10):
        for h in range(10):
            patrn = r".*" + re.escape(str(i)) + r".*" + re.escape(str(j)) + r".*" + re.escape(str(h)) + r".*"
            result = re.match(patrn, S)
            if result != None:
                cnt += 1
print(cnt)

Fixed submission:
import re
#import time
N = int(input())
S = input()
#start = time.time()
cnt = 0
for i in range(10):
    fir = S.find(str(i))
    if fir == -1:
        continue
    for j in range(10):
        sec = S.find(str(j), fir + 1)
        if sec == -1:
            continue
        for h in range(10):
            thi = S.find(str(h), sec + 1)
            if thi == -1:
                continue
            cnt += 1
print(cnt)
#stop = time.time()
#print(stop - start)

Buggy python submission (verdict: Time Limit Exceeded):
import re
N = int(input())
S = input()
cnt = 0
for i in range(1000):
    smpl = format(i,"03")
#    patrn = r".*smpl[0].*smpl[1].*smpl[2].*"
    patrn = r".*" + re.escape(smpl[0]) + r".*" + re.escape(smpl[1]) + r".*" + re.escape(smpl[2]) + r".*"
    result = re.match(patrn, S)
    if result != None:
        cnt += 1
print(cnt)

Fixed submission:
import re
#import time
N = int(input())
S = input()
#start = time.time()
cnt = 0
for i in range(10):
    fir = S.find(str(i))
    if fir == -1:
        continue
    for j in range(10):
        sec = S.find(str(j), fir + 1)
        if sec == -1:
            continue
        for h in range(10):
            thi = S.find(str(h), sec + 1)
            if thi == -1:
                continue
            cnt += 1
print(cnt)
#stop = time.time()
#print(stop - start)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for h in range(j+1,N):
            if L[i] + L[j] > L[h]:
                cnt += 1
            else:
                break
print(cnt)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        h_min = j
        h_max = N
        while h_max - h_min != 1:
            h_mid = (h_max + h_min) // 2
            if L[i] + L[j] > L[h_mid]:
                h_min = h_mid
            else:
                h_max = h_mid
        cnt += h_min - j
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for h in range(j+1,N):
            if (L[i] + L[j] + L[h] - max(L[i],L[j],L[h])) > max(L[i],L[j],L[h]):
                cnt += 1
print(cnt)

Fixed submission:
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        h_min = j
        h_max = N
        while h_max - h_min != 1:
            h_mid = (h_max + h_min) // 2
            if L[i] + L[j] > L[h_mid]:
                h_min = h_mid
            else:
                h_max = h_mid
        cnt += h_min - j
print(cnt)
Buggy python submission (verdict: Runtime Error):
import numpy as np
H,W = map(int,input().split())
grid = []
for i in range(H):
    mojiretsu = input()
    moji = []
    for k in range(len(mojiretsu)):
        moji.append(mojiretsu[k])
    grid.append(moji)
grid = np.array(grid)
flug1 = True
flug2 = True
flug3 = False
flug4 = False
while flug1:
    for i in range(grid.shape[0]):
        if np.all(grid[i,:] == "."):
            grid = np.delete(grid, i, 0)
            flug3 = False
            break
        else:
            flug3 = True
    if flug3 == True:
        flug1 = False
while flug2:
    for j in range(grid.shape[1]):
        if np.all(grid[:,j] == "."):
            grid = np.delete(grid, j, 1)
            flug4 = False
            break
        else:
            flug4 = True
    if flug4 == True:
        flug2 = False
for height in range(grid.shape[0]):
    print("".join(list(grid[height,:]))) 

Fixed submission:
import numpy as np
H,W = map(int,input().split())
grid = []
for i in range(H):
    mojiretsu = input()
    moji = []
    for k in range(len(mojiretsu)):
        moji.append(mojiretsu[k])
    grid.append(moji)
grid = np.array(grid)
flug1 = True
flug2 = True
flug3 = False
flug4 = False
while flug1:
    for i in range(grid.shape[0]):
        if np.all(grid[i,:] == "."):
            grid = np.delete(grid, i, 0)
            flug3 = False
            break
        else:
            flug3 = True
    if flug3 == True:
        flug1 = False
while flug2:
    for j in range(grid.shape[1]):
        if np.all(grid[:,j] == "."):
            grid = np.delete(grid, j, 1)
            flug4 = False
            break
        else:
            flug4 = True
    if flug4 == True:
        flug2 = False
for height in range(grid.shape[0]):
    print("".join(list(grid[height,:])))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
a = list(sorted(a))
big = a[n-1]
mark = [0]*big
for x in a:
  mark[x] += 1
  if mark[x] > 1:
    continue
  for j in range(x*2, big+1, x):
    mark[j] += 1

ans = 0
for x in a:
  if mark[x] == 1:
    ans += 1

print(ans)

Fixed submission:
n = int(input())
a = map(int, input().split())
a = list(sorted(a))
big = a[n-1]
mark = [0]*(big+1)
for x in a:
    mark[x] += 1
    if mark[x] > 1:
        continue
    for j in range(x*2, big+1, x):
        mark[j] += 1

ans = 0
for x in a:
    if mark[x] == 1:
        ans += 1

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

maxn = 10**18
ans = 1
for k in a:
    ans *= k

if ans > maxn:
    ans = -1

print(ans)


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

for k in a:
    if k == 0:
        print(0)
        exit()

maxn = 10**18
ans = 1
for k in a:
    ans *= k
    if ans > maxn:
        ans = -1
        break


print(ans)
Buggy python submission (verdict: Runtime Error):
n, runner, chaser = map(int, input().split())
runner -= 1
chaser -= 1
if runner == chaser:
    print(0)

tree = {}
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    if tree.get(a) is None:
        tree[a] = []
    if tree.get(b) is None:
        tree[b] = []
    tree[a].append(b)
    tree[b].append(a)


def dfs(dists, start, d=0, p=-1):  
    dists[start] = d
    for neighbor in tree[start]:
        if neighbor == p:
            continue
        dfs(dists, neighbor, d+1, start)

def dist(start):
    dists = [0 for _ in range(n)]
    dfs(dists, start)
    return dists

furthest = 0
run_dist = dist(runner)
chs_dist = dist(chaser)
for i in range(n):
    if run_dist[i] < chs_dist[i]:
        furthest = max(furthest, chs_dist[i])

ans = furthest-1

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)
n, runner, chaser = map(int, input().split())
runner -= 1
chaser -= 1
if runner == chaser:
    print(0)
    exit()

tree = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

def dfs(dists, start, d=0, p=-1):  
    dists[start] = d
    for neighbor in tree[start]:
        if neighbor == p:
            continue
        dfs(dists, neighbor, d+1, start)

def dist(start):
    dists = [0 for _ in range(n)]
    dfs(dists, start)
    return dists

furthest = 0
run_dist = dist(runner)
chs_dist = dist(chaser)
for i in range(n):
    if run_dist[i] < chs_dist[i]:
        furthest = max(furthest, chs_dist[i])

ans = furthest-1

print(ans)
Buggy python submission (verdict: Runtime Error):
x = input()
k = int(x[0:-2])
x = int(x[-2:])

k -= x / 5
if x % 5 == 0 and k >= 0:
    print(1)
elif k > 0:
    print(1)
else:
    print(0)


Fixed submission:
x = input()
if len(x) < 3:
    print(0)
    exit()
k = int(x[0:-2])
x = int(x[-2:])

k -= x / 5
if x % 5 == 0 and k >= 0:
    print(1)
elif k > 0:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
pos = map(int, input().split())

x, y = sorted(pos)

num_twos = x // 2
rem = x % 2

solution = 0

max_n = 5*10**5

result = max_n*[None]
result[0] = 1
for i in range(1, max_n):
    result[i] = i*result[i-1]
m = 10**9 + 7 - 2


def ncr(n, r):
    return result[n] * result[r]**(m) * result[n-r]**(m)


while not (y == num_twos + (rem*2)):
    num_twos -= 1
    rem += 2

    if y < (num_twos + rem*2):
        print(0)
        exit()

solution = ncr(num_twos + rem, rem)

print(int(solution))


Fixed submission:
from math import factorial
pos = map(int, input().split())
p = 10**9 + 7
x, y = sorted(pos)

if (x+y) % 3 != 0:
    print(0)
    exit()

n = (-x + 2 * y) // 3
m = (-y + 2 * x) // 3

# Python3 function to
# calculate nCr % p


def ncr(n, r, p):
    # initialize numerator
    # and denominator
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den,
                      p - 2, p)) % p


ans = ncr(n+m, n, p)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
pos = map(int, input().split())

x, y = sorted(pos)

num_twos = x // 2
rem = x % 2

solution = 0

m = 10**9 + 7 - 2


def ncr(n, r):
    return factorial(n) * factorial(r)**(m) * factorial(n-r)**(m)


while not (y == num_twos + (rem*2)):
    num_twos -= 1
    rem += 2

    if y < (num_twos + rem*2):
        print(0)
        exit()

solution = ncr(num_twos + rem, rem)

print(int(solution))


Fixed submission:
from math import factorial
pos = map(int, input().split())
p = 10**9 + 7
x, y = sorted(pos)

if (x+y) % 3 != 0:
    print(0)
    exit()

n = (-x + 2 * y) // 3
m = (-y + 2 * x) // 3

# Python3 function to
# calculate nCr % p


def ncr(n, r, p):
    # initialize numerator
    # and denominator
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den,
                      p - 2, p)) % p


ans = ncr(n+m, n, p)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = map(int, input().split())
ls = list(ls)


counter = 0
for i, l1 in enumerate(ls):
    j = i+1
    for l2 in ls[i+1:]:
        for l3 in ls[j+1:]:
            if l1 < l2 + l3 and l2 < l1 + l3 and l3 < l2 + l1:
                counter += 1
        j += 1

print(counter)


Fixed submission:
from bisect import bisect_left
n = int(input())
ls = map(int, input().split())
ls = sorted(ls)

counter = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        counter += (bisect_left(ls, ls[i] + ls[j]) - 1) - j

print(counter)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
ans = [0]*n

for i in range(n-1, -1, -1):
  ans[i] = sum(ans[i+i+1:n:i+1]) % 2 != a[i]:

print(sum(ans))
for i in range(n):
  if ans[i] == 1:
    print(i+1)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
ans = [0]*n

for i in range(n-1, -1, -1):
  now = 0
  for j in range(i+i+1, n, i+1):
    now += ans[j]
  if now % 2 != a[i]:
    ans[i] = 1

print(sum(ans))
for i in range(n):
  if ans[i] == 1:
    print(i+1)
Buggy python submission (verdict: Runtime Error):
from math import sqrt
n,d = map(int, input().split())

vs = []
for i in range(n):
  v = list(map(int,input().split()))
  vs.append(vs)

def ds(a,b):
  s = 0
  for i in range(d):
    s += (b[i] - a[i])**2
  return sqrt(s)

ans = 0
for i in range(n):
  for j in range(i+1,n):
    d = ds(vs[i], vs[j])
    if d == int(d):
      ans += 1
      
print(ans)

Fixed submission:
from math import sqrt
n, d = map(int, input().split())

vs = []
for i in range(n):
    v = list(map(int, input().split()))
    vs.append(v)


def ds(a, b):
    s = 0
    for i in range(d):
        s += (b[i] - a[i])**2
    return sqrt(s)


ans = 0
for i in range(n):
    for j in range(i+1, n):
        dist = ds(vs[i], vs[j])
        if dist == int(dist):
            ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
hs = list(map(int, input().split()))

def best(plants, counter):
    all0 = True
    started = False
    for i,p in enumerate(plants):    
        if p > 0:
            all0 = False
        if p == 0:
            if started:
                break
            else:
                continue
        plants[i] -= 1
        started = True
    
    if all0:
        return counter
    return best(plants, counter+1)
    
counter = best(hs, 0)
print(counter)



Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n = int(input())
hs = list(map(int, input().split()))

def best(plants, counter):
    all0 = True
    started = False
    for i,p in enumerate(plants):    
        if p > 0:
            all0 = False
        if p == 0:
            if started:
                break
            else:
                continue
        plants[i] -= 1
        started = True

    if all0:
        return counter
    return best(plants, counter+1)
    
cnt = best(hs, 0)
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, k = map(int, input().split())
h = list(map(int, input().split(' ')))

dp = [sys.maxsize] * n


dp[0] = 0
i = 0
j = 0
while i < n:
    j = 1
    while j <= k:
        if (i+j >= n):
            break
        dp[i+j] = min(dp[i+j], abs(h[i] - h[i+j]) + dp[i])
        j += 1
    i += 1


print(dp[n-1])


Fixed submission:
import numpy as np
n, k = map(int, input().split())
h = list(map(int, input().split(' ')))
h = np.array(h)

dp = np.zeros(n, dtype=int)


dp[0] = 0
i = 0
j = 0
for i in range(1, n):
    j = max(0, i-k)
    dp[i] = np.min(dp[j:i] + np.abs(h[i] - h[j:i]))


print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, k = map(int, input().split())
h = list(map(int, input().split(' ')))

dp = [sys.maxsize for _ in range(n)]


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


print(dp[n-1])


Fixed submission:
import numpy as np
n, k = map(int, input().split())
h = list(map(int, input().split(' ')))
h = np.array(h)

dp = np.zeros(n, dtype=int)


dp[0] = 0
i = 0
j = 0
for i in range(1, n):
    j = max(0, i-k)
    dp[i] = np.min(dp[j:i] + np.abs(h[i] - h[j:i]))


print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
i = input;i();print(sum([x-1 for x in i().split()]))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(sum(a) - n)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
g = [[] for _ in range(n)]

for i in range(m):
  a,b = map(int, input().split())
  g[a-1] = b-1
  g[b-1] = a-1
  
for nd in g:
  print(len(nd))

Fixed submission:
n,m = map(int, input().split())
g = [[] for _ in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    g[a-1].append( b-1)
    g[b-1].append( a-1)
            
for nd in g:
    print(len(nd))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")


Fixed submission:
a = int(input())
b = int(input())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")
Buggy python submission (verdict: Runtime Error):
w = input()

s = {}
for c  in w:
    s[c] += 1

b = True
for k,v in s.items():
    b = b and v % 2 == 0

if b:
    print("Yes")
else:
    print("No")


Fixed submission:
w = input()

s = {}
for c in w:
    if c in s:
        s[c] += 1
    else:
        s[c] = 1
b = True
for k,v in s.items():
    b = b and v % 2 == 0

if b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys


def main():
    N, K = map(int, sys.stdin.readline().rstrip().split())
    L = [0] * 10
    R = [0] * 10
    for i in range(K):
        l, r = map(int, sys.stdin.readline().rstrip().split())
        L[i], R[i] = l, r

    dp = [0] * (N+1)
    dp[1] = 1
    for i in range(2,N+1):
        for j in range(K):
            l = min(L[j], i)
            r = min(R[j], i)
            dp[i] += sum(dp[i-r:(i-l)+1])
            dp[i] %= 998244353
        # print(dp[i])
    
    print(dp[N])


main()

Fixed submission:
import sys


def main():
    N, K = map(int, sys.stdin.readline().rstrip().split())
    L = [0] * 10
    R = [0] * 10
    for i in range(K):
        l, r = map(int, sys.stdin.readline().rstrip().split())
        L[i], R[i] = l, r

    dp = [0] * (N + 1)
    up = [0] * (N + 1)
    up[0] = 1
    up[1] = -1
    for i in range(1, N + 1):
        dp[i] = dp[i - 1] + up[i - 1]
        for j in range(K):
            if i + (L[j] - 1) < N + 1:
                up[i + (L[j] - 1)] += dp[i]
            if i + R[j] < N + 1:
                up[i + R[j]] -= dp[i]
        dp[i] %= 998244353

    print(dp[N])


main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np

def main():
    N, Q = map(int, sys.stdin.readline().rstrip().split())

    H = np.array([N - 2] * (N - 1))
    W = np.array([N - 2] * (N - 1))

    ans = (N - 2)**2  # 初期状態の黒枚数

    Hmin = N - 1
    Wmin = N - 1

    for i in range(Q):
        n, x = map(int, sys.stdin.readline().rstrip().split())
        if n == 1:  # ↓ で挟む
            # print("*** ", W[x - 1])
            ans -= W[x - 1]
            if x - 1 < Wmin:
                H[0:Hmin] = x - 2
                Wmin = x - 1
        else:
            # print("*** ", H[x - 1])
            ans -= H[x - 1]
            if x - 1 < Hmin:
                W[0:Wmin] = x - 2
                Hmin = x - 1

    print(ans)


main()


Fixed submission:
import sys
import numpy as np


def main():
    N, Q = map(int, sys.stdin.readline().rstrip().split())

    H = np.array([0] * (N - 1))
    W = np.array([0] * (N - 1))

    black = (N - 2)**2  # 初期状態の黒枚数

    Hmin = N - 1
    Wmin = N - 1

    for i in range(Q):
        n, x = map(int, sys.stdin.readline().rstrip().split())
        if n == 1:  # ↓ で挟む
            if x - 1 <= Wmin:
                W[x - 1:Wmin] = Hmin - 1
                Wmin = x - 1
            # print("***", W[x - 1], Wmin, Hmin)
            black -= W[x - 1]
        else:
            if x - 1 <= Hmin:
                H[x - 1:Hmin] = Wmin - 1
                Hmin = x - 1
            # print("***", H[x - 1], Wmin, Hmin)
            black -= H[x - 1]

    print(black)


main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys


def main():
    N, Q = map(int, sys.stdin.readline().rstrip().split())

    H = [N - 2] * (N - 1)
    W = [N - 2] * (N - 1)

    ans = (N - 2)**2  # 初期状態の黒枚数

    Hmin = N - 1
    Wmin = N - 1

    for i in range(Q):
        n, x = map(int, sys.stdin.readline().rstrip().split())
        if n == 1:  # ↓ で挟む
            # print("*** ", W[x - 1])
            ans -= W[x - 1]
            if x - 1 < Wmin:
                for j in range(Hmin):
                    H[j] = x - 2
                Wmin = x - 1
        else:
            # print("*** ", H[x - 1])
            ans -= H[x - 1]
            if x - 1 < Hmin:
                for j in range(Wmin):
                    W[j] = x - 2
                Hmin = x - 1

    print(ans)


main()


Fixed submission:
import sys
import numpy as np


def main():
    N, Q = map(int, sys.stdin.readline().rstrip().split())

    H = np.array([0] * (N - 1))
    W = np.array([0] * (N - 1))

    black = (N - 2)**2  # 初期状態の黒枚数

    Hmin = N - 1
    Wmin = N - 1

    for i in range(Q):
        n, x = map(int, sys.stdin.readline().rstrip().split())
        if n == 1:  # ↓ で挟む
            if x - 1 <= Wmin:
                W[x - 1:Wmin] = Hmin - 1
                Wmin = x - 1
            # print("***", W[x - 1], Wmin, Hmin)
            black -= W[x - 1]
        else:
            if x - 1 <= Hmin:
                H[x - 1:Hmin] = Wmin - 1
                Hmin = x - 1
            # print("***", H[x - 1], Wmin, Hmin)
            black -= H[x - 1]

    print(black)


main()
Buggy python submission (verdict: Runtime Error):
import sys

N = int(sys.stdin.readline().rstrip())
TMP_C = [x for x in input()]
C = []
for i in range(N - 1, -1, -1):
    C.append(TMP_C[i])
# print(C)

cnt = 0
for i in range(N - 1, -1, -1):
    if C[i] == "W":
        j = C.index("R")
        if j < i:
            C[i], C[j] = C[j], C[i]
            cnt += 1

print(cnt)


Fixed submission:
import sys
from collections import Counter

N = int(sys.stdin.readline().rstrip())
S = [x for x in input()]

C = Counter(S)

W = C["W"]
R = C["R"]

SS = S[:R]
CC = Counter(SS)
RR = CC["W"]

print(RR)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(x) for x in input().split()]

score = 1
for i in range(K):
    score *= A[i]


for i in range(K, N):
    before = score
    score = score * A[i] // A[i-K]

    if before < score:
        print("Yes")
    else:
        print("No")

Fixed submission:
N, K = map(int, input().split())
A = [int(x) for x in input().split()]

score = 1

for i in range(K, N):
    if A[i - K] < A[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
import sys

INF = 10**9 + 5

N, M, K = map(int, sys.stdin.readline().rstrip().split())
A = [int(x) for x in sys.stdin.readline().rstrip().split()]
B = [int(x) for x in sys.stdin.readline().rstrip().split()]

A.append(INF)
A.append(INF)
i, j = 0, 0
t = 0
while i < N or j < M:

    if A[i] < B[j]:
        t += A[i]
        if t > K: break
        i += 1
    else:
        t += B[j]
        if t > K: break
        j += 1

print(i + j)

Fixed submission:
import sys

INF = 10**9 + 5

N, M, K = map(int, sys.stdin.readline().rstrip().split())
A = [int(x) for x in sys.stdin.readline().rstrip().split()]
B = [int(x) for x in sys.stdin.readline().rstrip().split()]

tmpA = [INF] * (N + 1)
tmpA[0] = 0

cntA = 0
# A だけを読み続けた場合の所要時間を記録
for i in range(1, N + 1):
    tmpA[i] = A[i - 1] + tmpA[i - 1]
    cntA = i
    if tmpA[i] > K:
        break

# print(tmpA, cntA)  # cntA 冊目まで読める

# A を一冊ずつ減らして、最大値を探索
j = 0
vol = 0
tmpB = 0

for i in range(cntA, -1, -1):
    rest = K - tmpA[i]  # 残り時間
    # print(f"A{i} 残時間 : {rest}")
    while j < M + 1:
        # print(f"B {j}冊 {tmpB}分")
        if rest < tmpB:  # 　tmpB が残り時間を超えたら終了
            break
        vol = max(i + j, vol)
        if j >= M:
            break
        tmpB += B[j]  # 超えていなければ新しい本を追加してみる
        j += 1

print(vol)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math


def yakusu(K):
    Y = set()
    for i in range(1, int(math.sqrt(K)) + 1):
        if K % i == 0:
            Y.add(i)
            Y.add(K // i)
    return len(Y)


def main():
    N = int(sys.stdin.readline().rstrip())

    sum_ = 0
    for k in range(1, N + 1):
        sum_ += k * yakusu(k)

    print(sum_)


main()


Fixed submission:
import sys
import math


def main():
    N = int(sys.stdin.readline().rstrip())

    sum_ = 0

    for i in range(1, int(math.sqrt(N)) + 1):

        sum_ += i**2

        k1 = N // i
        # k2 = i

        k1_sum = k1 * (k1 + 1) // 2
        k2_sum = i * (i + 1) // 2
        sum_ += 2 * i * (k1_sum - k2_sum)

    print(sum_)


main()