Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, d = map(int, input().split())


def func(n, c, d):
    x = n//c
    y = n//d
    z = n//((c * d) // math.gcd(c, d))
    zz = (x+y)-z
    return zz


tmp = b-func(b, c, d)
tmp2 = (a-1)-func(a-1, c, d)
print(tmp-tmp2)
#print('test', func(6, 2, 3))


Fixed submission:
import itertools
import math
import fractions
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, d = map(int, input().split())


def func(n, c, d):
    x = n//c
    y = n//d
    z = n//((c * d) // fractions.gcd(c, d))
    zz = (x+y)-z
    return zz


tmp = b-func(b, c, d)
tmp2 = (a-1)-func(a-1, c, d)
print(tmp-tmp2)
#print('test', func(6, 2, 3))
Buggy python submission (verdict: Runtime Error):
import math
import string


def readints():
    return list(map(int, input().split()))


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


n, x = map(int, input().split())
l = list(map(int, input().split()))
#print(l)
ll = [0]
sum = 0
for i in range(n):
    sum += l[i]
    ll.append(sum)
#print(ll)

cnt = 0
for i in range(n+1):
    if ll[i] <= x:
        cnt += 1
print(cnt)


Fixed submission:
x, a = map(int, input().split())
if x < a:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, k = map(int, input().split())
h = readints()
h.append(-1)
dp = [10**9]*(2*n)
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], abs(h[i]-h[i+j])+dp[i])
print(dp[n-1])


Fixed submission:
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, k = map(int, input().split())
h = readints()
# h.append(-1)
dp = [10**9]*(2*n)
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        if i+j < n:
            dp[i+j] = min(dp[i+j], abs(h[i]-h[i+j])+dp[i])
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
import math
import string


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


d, n = map(int, input().split())


def func(x):
    cnt = 0
    while x % 100 == 0:
        cnt += 1
        x /= 100
    return cnt == d


a = []

for i in range(1, 1000000):
    if func(i):
        a.append(i)
print(a[n-1])


Fixed submission:
import math
import string


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


d, n = map(int, input().split())


def func(x):
    cnt = 0
    while x % 100 == 0:
        cnt += 1
        x /= 100
    return cnt == d


cntcnt = 0

for i in range(1, 10000000):
    if func(i):
        cntcnt += 1
        if cntcnt == n:
            print(i)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
import math
import string


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


d, n = map(int, input().split())


def func(x):
    cnt = 0
    while x % 100 == 0:
        cnt += 1
        x /= 100
    return cnt == d


a = []

for i in range(1, 10000000):
    if func(i):
        a.append(i)
print(a[n-1])


Fixed submission:
import math
import string


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


d, n = map(int, input().split())


def func(x):
    cnt = 0
    while x % 100 == 0:
        cnt += 1
        x /= 100
    return cnt == d


cntcnt = 0

for i in range(1, 10000000):
    if func(i):
        cntcnt += 1
        if cntcnt == n:
            print(i)
            exit()
Buggy python submission (verdict: Runtime Error):
import math
import string


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

#N = int(input())
#s = [input() for i in range(N)]
#M = int(input())
#t = [input() for i in range(M)]
# print(s)
# print(t)

h, w = map(int, input().split())
if (w == 1) or(h == 1):
    print(1)
    exit()

sum = 0

sum += (math.ceil(w/2))*(math.ceil(h/2))  # 切り上げ
sum += (math.floor(w/2))*(math.floor(h/2))  # 切り捨て

print(sum)


Fixed submission:
import math
import string


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

x = int(input())
a = [1]
for i in range(2, 1001):
    for j in range(2, 10):
        a.append(i**j)
aa = sorted(set(a))
# print(aa)
b = []
for i in range(len(aa)):
    if aa[i] <= x:
        b.append(aa[i])
print(max(b))
Buggy python submission (verdict: Runtime Error):
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

H, W = map(int, input().split())
s = [None]*H
for i in range(H):
    s[i] = input()
d = deque()
d.append((0, 0))
while(len(d) != 0):
    g, r = d.popleft()
    if s[g][r] == '#':
        if g != 0 and s[g-1][r] == '#':
            d.append((g-1, r))
        else:
            print('No')
            break
        if g != H-1 and s[g+1][r] == '#':
            d.append((g+1, r))
        else:
            print('No')
            break
        if r != 0 and s[g][r-1] == '#':
            d.append((g, r-1))
        else:
            print('No')
            break
        if r != W-1 and s[g][r+1] == '#':
            d.append((g, r+1))
        else:
            print('No')
            break
    print('Yes')


Fixed submission:
def readints():
    return list(map(int, input().split()))


a, b = map(int, input().split())
if a == b:
    print(a)
    exit()
if a > b:
    print(a-1)
if a < b:
    print(a)
Buggy python submission (verdict: Runtime Error):
import math
import string


def readints():
    return list(map(int, input().split()))


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


a = int(input())
b = int(input())

print("Odd" if (a*b) % 2 == 0 else "Even")


Fixed submission:
import math
import string


def readints():
    return list(map(int, input().split()))


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


a, b = map(int, input().split())

print("Even" if (a*b) % 2 == 0 else "Odd")
Buggy python submission (verdict: Runtime Error):
import math
import string


def readints():
    return list(map(int, input().split()))


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


m = int(input)
print(24+(24-m))


Fixed submission:
import math
import string


def readints():
    return list(map(int, input().split()))


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


m = int(input())
print(24+(24-m))

Buggy python submission (verdict: Runtime Error):
import math
import string


def readints():
    return list(map(int, input().split()))


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


m = int(input)
print(24+(24-m)s)


Fixed submission:
import math
import string


def readints():
    return list(map(int, input().split()))


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


m = int(input())
print(24+(24-m))
Buggy python submission (verdict: Time Limit Exceeded):
import math
import string


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
a = readints()


def func(a):
    cnt = 0
    for i in range(n):
        if a[i] % 2 == 0:
            cnt += 1
            a[i] = a[i]/2
    if cnt == n:
        return True
    else:
        False


cntcnt = 0
for _ in range(100000):
    if func(a):
        cntcnt += 1
print(cntcnt)


Fixed submission:
import math
import string


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
a = readints()

cnt = 0
while all(x % 2 == 0 for x in a):
    a = [x/2 for x in a]
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
import string


def readints():
    return list(map(int, input().split()))


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


h, w = map(int, input().split())
a = [None]*h
for i in range(h):
    a[i] = input()
# print(a)

dx = [1, 1, 0-1, -1, -1, 0, 1]
dy = [0, 1, 1, 1, 0, -1, -1, -1]

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            print('#', end="")
        else:
            count = 0
            for k in range(8):
                x = i+dx[k]  # (i,j)の位置からk移動させたときのx座標
                y = j+dy[k]  # (i,j)の位置からk移動させたときのy座標
                if (x <= 0 and x < h)and(y <= 0 and y < w)and(a[x][y] == '#'):
                    # x,yが盤面の中に入っていて'#'のとき
                    continue
                if a[x][y] == '#':
                    count += 1
            print(count, end="")
    print('\n', end="")


Fixed submission:
import math
import string


def readints():
    return list(map(int, input().split()))


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


h, w = map(int, input().split())
a = [None]*h
for i in range(h):
    a[i] = input()
# print(a)

dx = [-1, -1, -1, 0, 1, 1, 1, 0]
dy = [-1, 0, 1, 1, 1, 0, -1, -1]

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            print('#', end="")
        else:
            count = 0
            for k in range(8):
                x = i+dx[k]  # (i,j)の位置からk移動させたときのx座標
                y = j+dy[k]  # (i,j)の位置からk移動させたときのy座標
                if x < 0 or x >= h or y < 0 or y >= w:
                    # x,yが盤面の中に入っていて'#'のとき
                    continue

                if a[x][y] == '#':
                    count += 1

            print(count, end="")

    print('\n', end="")
Buggy python submission (verdict: Runtime Error):
n=input()
4.if n[0]==9 or n[1]==9:
5.    print('Yes')
      exit()
6.else:
7.    print('No')


Fixed submission:
# coding: utf-8
# Your code here!
n=input()
if n[0]=='9':
    print('Yes')
    exit()
if n[1]=='9':
    print('Yes')
    exit()
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=input()
for i in range(len(n)):
    if n[i] ==9:
        print('Yes')
        break
        else:
            print('No')


Fixed submission:
# coding: utf-8
# Your code here!
n=input()
if n[0]=='9':
    print('Yes')
    exit()
if n[1]=='9':
    print('Yes')
    exit()
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
N = input()
if N[0] == N[3]:
    print('Yes')
else:
    print('No')


Fixed submission:
N = input()
if N[0] == N[2]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
s=input()
ss=len(s[1:len(s)-1])
sss=str(ss)
 print(s[0]+sss+s[-1])

Fixed submission:
s=input()
ss=len(s[1:len(s)-1])
sss=str(ss)
print(s[0]+sss+s[-1])
Buggy python submission (verdict: Runtime Error):
    a,b=map(int,input().split())
    print('Possible' if ((a+b)%3==0) or (a%3==0) or(b%3==0) else 'Impossible')

Fixed submission:
a,b=map(int,input().split())
print('Possible' if (((a+b)%3==0)or(a%3==0)or(b%3==0)) else 'Impossible')
Buggy python submission (verdict: Runtime Error):
a.b=map(int,input().split())
if a==1:
   print('Alice')
   exit()
if b==1:
   print('Bob')
   exit()
if a==1 and b==1:
   print('Draw')
   exit()
if a<b:
   print('Bob')
   exit()
if a>b:
   print('Alice')
   exit()
if a==b:
   print('Draw')
    exit()
   

Fixed submission:
import math
import string
import collections
from collections import Counter
from collections import deque


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
ab = readints()
if ab[0] == 1 and ab[1] == 1:
    print('Draw')
    exit()
if ab[0] == 1:
    print('Alice')
    exit()
if ab[1] == 1:
    print('Bob')
    exit()
if ab[0] < ab[1]:
    print('Bob')
    exit()
if ab[0] > ab[1]:
    print('Alice')
    exit()
if ab[0] == ab[1]:
    print('Draw')
#t = list(map(str, input()))
# print(t)
#p_cnt = 0
#d_cnt = 0
# for i in range(len(t)):
#    if t[i] == 'P':
#        p_cnt += 1
#    if t[i] == 'D':
#        d_cnt += 1
# if p_cnt > d_cnt:
#    for i in range(len(t)):
#        if t[i] == '?':
#            if t[i-1] == 'P':
#                t[i] = 'D'
#            if t[i-1] == 'D':
#                t[i] = 'P'
#    tt = ''.join(t)
#    print(tt)
# else:
#    for i in range(len(t)):
#        if t[i] == '?':
#            t[i] = 'D'
#    tt = ''.join(t)
#    print(tt)
#
Buggy python submission (verdict: Runtime Error):
# union-find
# https://note.nkmk.me/python-union-find/

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
        # 各要素の親要素を格納する

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            return self.find(self.parents[x])
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return
    
    def size(self, x):
        x = self.find(x)    
        return self.parents[x]*(-1)

def main():
    n, m = map(int, input().split())
    friend = UnionFind(n)

    for _ in range(m):
        a, b = map(int, input().split())
        friend.union(a-1, b-1)
    
    ans = 0
    for i in range(n):
        ans = max(ans, friend.size(i))
    print(ans)

if  __name__ == "__main__":
     main()


Fixed submission:
d, t, s = map(int, input().split())
if s*t >= d:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import re
import sys

n = int(input())
c = list(input())

count_r = 0
for i in c:
    if i == 'R':
        count_r += 1
count_w = n - count_r
ans = min(count_r, count_w)
if ans == 0:
    print(0)
    sys.exit()

pattern = r"^R*W*$"
# print(re.fullmatch(pattern, "RRRWW"))
# print(re.search(pattern, "RRRWW"))
l = 0
r = n-1
count = 0
while not re.match(pattern, ''.join(c)):
# while l < r:
    while c[l] == 'R':
        l += 1
    while c[r] =='W':
        r -= 1
    c[l] = 'R'
    c[r] = 'W'
    count += 1
    # print(c, l, r)
    # if l == r-1:
    #     break

ans = min(count, ans)

print(ans)

Fixed submission:
import re
import sys

n = int(input())
c = list(input())

count_r = 0
for i in c:
    if i == 'R':
        count_r += 1
count_w = n - count_r
ans = min(count_r, count_w)
if ans == 0:
    print(0)
    sys.exit()

pattern = r"^R*W*$"
# print(re.fullmatch(pattern, "RRRWW"))
# print(re.search(pattern, "RRRWW"))
l = 0
r = n-1
count = 0
# while not re.match(pattern, ''.join(c)):
while l < r:
    while c[l] == 'R':
        l += 1
    while c[r] =='W':
        r -= 1
    if l >= r:
        break
    c[l] = 'R'
    c[r] = 'W'
    count += 1
    # print(c, l, r)
    

ans = min(count, ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC172 C
import sys
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_CumulativeSum = [0]
B_CumulativeSum = [0]
for i in range(n):
    A_CumulativeSum.append(A[i] + A_CumulativeSum[i])
for i in range(m):
    B_CumulativeSum.append(B[i] + B_CumulativeSum[i])

if A_CumulativeSum[n-1] + B_CumulativeSum[m-1] <= k:
    print(n+m)
    sys.exit()

ans = 0
for i in range(n+1):
    time = A_CumulativeSum[i]
    if time > k:
        break
    time_b = k - time
    j = m
    while time_b < B_CumulativeSum[j]:
        j -= 1

    count = i + j
    ans = max(count, ans)

print(ans)


Fixed submission:
# ABC172 C
import sys
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_CumulativeSum = [0]
B_CumulativeSum = [0]
for i in range(n):
    A_CumulativeSum.append(A[i] + A_CumulativeSum[i])
for i in range(m):
    B_CumulativeSum.append(B[i] + B_CumulativeSum[i])

if A_CumulativeSum[n-1] + B_CumulativeSum[m-1] <= k:
    print(n+m)
    sys.exit()

ans = 0
j = m
for i in range(n+1):
    time = A_CumulativeSum[i]
    if time > k:
        break
    time_b = k - time
    while time_b < B_CumulativeSum[j]:
        j -= 1

    count = i + j
    ans = max(count, ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
n = int(input())
L = []
for i in range(n):
    L.append(input())

ANS = ['blank page']
d = deque()
d.append('blank page')

for i in range(1, n):
    if L[i] == 'use the back button':
        d.pop()
        t = d.pop()
        ANS.append(t)
        d.append(t)
    else:
        s = L[i][6:]
        ANS.append(s)
        d.append(s)
        # s = L[i].split()
        # s = s[2:]
        # ANS.append(' '.join(s))
        # d.append(' '.join(s))

for i in ANS:
    print(i)

Fixed submission:
from collections import defaultdict
import sys
n = int(input())
A = list(map(int, input().split()))

# if n == 1:
#     print(1)
#     sys.exit()

d = defaultdict(int)

for key in A:
    d[key] += 1

# if len(d) == 1: # 全部同じ数
#     print(0)
#     sys.exit()

B = list(d)
# B.sort()

# if B[0] == 1: # 1が含まれる場合
#     print(d[1])
#     sys.exit()
# length = len(d)
m = max(d)
flag = [0 for i in range(m+1)]

for i in B:
    t = i
    while t <= m:
        flag[t] += 1
        t += i

ans = 0
for i in B:
    if flag[i] == 1 and d[i] == 1:
        ans += 1

print(ans)