Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02573 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def size(x):
    return -par[find(x)]


# In[3]:


N,M = map(int, input().split())
par = [-1]*N
for _ in range(M):
    A,B = map(int, input().split())
    A -= 1; B -= 1
    unite(A,B)
ans = 0
for i in range(N):
    ans = max(ans, size(i))
print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[140]:


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def size(x):
    return -par[find(x)]


# In[144]:


par = [-1]*N
N,M = map(int, input().split())
for _ in range(M):
    A,B = map(int, input().split())
    A -= 1; B -= 1
    unite(A,B)
ans = 0
for i in range(N):
    ans = max(ans, size(i))
print(ans)


# In[ ]:
Problem p02602 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[2]:


N,K = map(int, input().split())
A = list(map(int, input().split()))


# In[9]:


def main():
    for j in range(K,N):
        if A[j] > A[j-K]:
            print("Yes")
        else:
            print("No")


# In[10]:


if __name__ == '__main__':
    main()


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[13]:


import sys
input = sys.stdin.readline


# In[26]:


NK = list(map(int, input()))
A = list(map(int, input()))
N = NK[0]
K = NK[1]


# In[16]:


def main():
    x0 = 1
    for i in range(K):
        x0 *= A[i]
    x = x0
    for j in range(K,N):
        score = x*A[j]//A[j-K]
        if score > x:
            print("Yes")
        else:
            print("No")
        x = score


# In[17]:


if __name__ == '__main__':
    main()


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[13]:


import sys
input = sys.stdin.readline


# In[26]:


NK = list(map(int, input()))
A = list(map(int, input()))
N = NK[0]
K = NK[1]


# In[16]:


def main():
    x0 = 1
    for i in range(K):
        x0 *= A[i]
    x = x0
    for j in range(K,N):
        score = x*A[j]//A[j-K]
        if score > x:
            print("Yes")
        else:
            print("No")
        x = score


# In[17]:


if __name__ == '__main__':
    main()


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[13]:


import sys
input = sys.stdin.readline


# In[24]:


N,K = list(map(int, input()))
A = list(map(int, input()))


# In[16]:


def main():
    x0 = 1
    for i in range(K):
        x0 *= A[i]
    x = x0
    for j in range(K,N):
        score = x*A[j]//A[j-K]
        if score > x:
            print("Yes")
        else:
            print("No")
        x = score


# In[17]:


if __name__ == '__main__':
    main()


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[24]:


N,K = list(map(int, input()))
A = list(map(int, input()))


# In[16]:


def main():
    x0 = 1
    for i in range(K):
        x0 *= A[i]
    x = x0
    for j in range(K,N):
        score = x*A[j]//A[j-K]
        if score > x:
            print("Yes")
        else:
            print("No")
        x = score


# In[17]:


if __name__ == '__main__':
    main()


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[13]:


import sys
input = sys.stdin.readline


# In[14]:


N,K = map(int, input())
A = list(map(int, input())


# In[16]:


def main():
    x0 = 1
    for i in range(K):
        x0 *= A[i]
    x = x0
    for j in range(K,N):
        score = x*A[j]//A[j-K]
        if score > x:
            print("Yes")
        else:
            print("No")
        x = score


# In[17]:


if __name__ == '__main__':
    main()


# In[ ]:
Problem p02720 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[12]:


from collections import deque


# In[1]:


K = int(input())


# In[15]:


q = deque(list(range(1,10)))
for i in range(K-1):
    x = q.popleft()
    if x%10 != 0:
        y = x*10 + x%10 - 1
        q.append(y)
    y = x*10 + x%10
    q.append(y)
    
    if x%10 != 9:
        y = x*10 + x%10 + 1
        q.append(y)
    
ans = q.popleft()
print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):
t
Problem p02768 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


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


# In[2]:


def nCk(n, k, mod):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a


# In[3]:


mod = 10**9+7
ans = pow(2, n, mod)-1
ans -= nCk(n, a, mod) + nCk(n, b, mod)
print(ans%mod)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[23]:


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


# In[24]:


def nCk(n, k, mod):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a


# In[25]:


ans = pow(2, n, mod)-1
ans -= nCk(n, a, mod) + nCk(n, b, mod)
print(ans%mod)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[14]:


import math


# In[21]:


def nCk(n, k, mod):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a


# In[22]:


ans = pow(2, n, mod)-1
ans -= nCk(n, a, mod) + nCk(n, b, mod)
print(ans%mod)


# In[ ]:
Problem p02803 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


from collections import deque


# In[2]:


H,W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())


# In[3]:


def bfs(sx,sy):
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    d = [[-1]*W for _ in range(H)]
    q = deque([])
    q.append([sx,sy])
    d[sx][sy] = 0
    ans = 0
    while q:
        x,y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] != "#" and d[nx][ny] == -1:
                q.append([nx,ny])
                d[nx][ny] = d[x][y] + 1
                ans = max(ans,d[nx][ny])
    return ans


# In[5]:


ans = 0
for sh in range(H):
    if "." in S[sh]:
        for sw in range(W):
            if S[sh][sw] == ".":
                ans = max(ans,bfs(sh,sw))
print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[11]:


from collections import deque


# In[23]:


H,W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())


# In[24]:


def bfs(sx,sy):
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    d = [[-1]*W for _ in range(H)]
    q = deque([])
    q.append([sx,sy])
    d[sx][sy] = 0
    ans = 0
    while q:
        x,y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] != "#" and d[nx][ny] == -1:
                q.append([nx,ny])
                d[nx][ny] = d[x][y] + 1
                ans = max(ans,d[nx][ny])
    return ans


# In[25]:


for sh in range(H):
    if "." in S[sh]:
        for sw in range(W):
            if S[sh][sw] == ".":
                ans = max(ans,bfs(sh,sw))
print(ans)


# In[ ]:
Problem p02924 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[21]:


P = int(input())


# In[22]:


# i_list = list(range(1, P+1))
# p_list = i_list[1:]
# p_list.append(i_list[0])

# # print(i_list, p_list)

# ans = 0
# for i in range(P):
#     ans += i_list[i]%p_list[i]
# print(ans)

# ans = sum(range(1,P))
ans = P*(P-1)//2
print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[8]:


P = int(input())


# In[10]:


i_list = list(range(1, P+1))
p_list = i_list[1:]
p_list.append(i_list[0])

# print(i_list, p_list)

ans = 0
for i in range(P):
    ans += i_list[i]%p_list[i]
print(ans)


# In[ ]:
Problem p02936 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[32]:


from collections import deque


# In[37]:


def func():
    N,Q = map(int, input().split())
    graph = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = map(int, input().split())
        a,b = a-1,b-1
        graph[a].append(b)
        graph[b].append(a)
    cnt = [0]*N
    for j in range(Q):
        p,x = map(int, input().split())
        cnt[p-1] += x
    q = deque([[0,-1,cnt[0]]])
    d = [-1]*N
    while q:
        cur,fr,p = q.popleft()
        d[cur] = p
        for nex in graph[cur]:
            if nex == fr:
                continue
            q.append([nex,cur,p+cnt[nex]])
    ans = []
    for i in range(N):
        ans.append(d[i])
    print(*ans)


# In[38]:


if __name__ == "__main__":
    func()


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[29]:


def func():
    N,Q = map(int, input().split())
    ab = []
    nodes = {}
    for _ in range(N-1):
        ab.append(list(map(int, input().split())))
    ab = sorted(ab,key=lambda x:x[0])
    graph = {}
    for a,b in ab:
        if a not in graph:
            graph[a] = [b]
        else:
            graph[a].append(b)
    cnt = [0]*N
    for j in range(Q):
        p,x = map(int, input().split())
        calc(graph,p,cnt,x)
    print(*cnt)


# In[30]:


def calc(graph,node,cnt,x):
    cnt[node-1] += x
    if node in graph:
        for n in graph[node]:
            calc(graph,n,cnt,x)
    return cnt


# In[31]:


if __name__ == "__main__":
    func()


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[23]:


def func():
    N,Q = map(int, input().split())
    ab = []
    nodes = {}
    for _ in range(N-1):
        ab.append(list(map(int, input().split())))
    ab = sorted(ab,key=lambda x:x[0])
    graph = {}
    for a,b in ab:
        if a not in graph:
            graph[a] = [b]
        else:
            graph[a].append(b)
    cnt = [0]*N
    for j in range(Q):
        p,x = map(int, input().split())
        calc(graph,p,cnt,x)
    print(cnt)


# In[26]:


def calc(graph,node,cnt,x):
    cnt[node-1] += x
    if node in graph:
        for n in graph[node]:
            calc(graph,n,cnt,x)
    return cnt


# In[28]:


if __name__ == "__main__":
    func()


# In[ ]:
Problem p02994 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[67]:


N, L = map(int, input().split())


# In[68]:


taste = list(range(L, N+L))


# In[69]:


choice_index = list(map(abs, taste)).index(min(list(map(abs, taste))))
del taste[choice_index]
print(sum(taste))


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[1]:


N, L = map(int, input().split())


# In[40]:


taste = list(range(L, N+L))


# In[41]:


choice = min(list(map(abs, taste)))
taste.remove(choice)
print(sum(taste))
Problem p02995 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[8]:


import math


# In[5]:


A,B,C,D = map(int, input().split())


# In[14]:


ac = (A-1)//C
bc = B//C
ad = (A-1)//D
bd = B//D
a_both = (A-1)//(C*D//math.gcd(C,D))
b_both = B//(C*D//math.gcd(C,D))
print((B-A+1) - (bc-ac) - (bd-ad) + (b_both-a_both))


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[129]:


import math


# In[124]:


A, B, C, D = map(int, input().split())


# In[130]:


lcm = int(C*D / math.gcd(C, D))


# In[131]:


c_part_a = int((A - 1) / C)
d_part_a = int((A - 1) / D)
cd_part_a = int((A - 1) / lcm)

c_part_b = int(B / C)
d_part_b = int(B / D)
cd_part_b = int(B / lcm)


# In[132]:


ans1 = (A-1) - (c_part_a + d_part_a - cd_part_a)
ans2 = B - (c_part_b + d_part_b - cd_part_b)


# In[133]:


print(ans2 - ans1)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[90]:


import math


# In[102]:


A, B, C, D = map(int, input().split())


# In[103]:


lcm = int(C*D / math.gcd(C, D))


# In[104]:


c_part_a = int((A - 1) / C)
d_part_a = int((A - 1) / D)
cd_part_a = int((A - 1) / lcm)

c_part_b = int(B / C)
d_part_b = int(B / D)
cd_part_b = int(B / lcm)


# In[105]:


ans1 = (A-1) - (c_part_a + d_part_a - cd_part_a)
ans2 = B - (c_part_b + d_part_b - cd_part_b)


# In[106]:


print(ans2 - ans1)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[90]:


import math


# In[102]:


A, B, C, D = map(int, input().split())


# In[103]:


lcm = int(C*D / math.gcd(C, D))


# In[104]:


c_part_a = int((A - 1) / C)
d_part_a = int((A - 1) / D)
cd_part_a = int((A - 1) / lcm)

c_part_b = int(B / C)
d_part_b = int(B / D)
cd_part_b = int(B / lcm)


# In[105]:


ans1 = (A-1) - (c_part_a + d_part_a - cd_part_a)
ans2 = B - (c_part_b + d_part_b - cd_part_b)


# In[106]:


print(ans2 - ans1)


# In[ ]:
Problem p03014 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import numpy as np


# In[2]:


H, W = map(int, input().split())
S = np.ones((H, W), dtype=np.bool)
for i in range(H):
    S[i] = [s == "." for s in input()]


# In[3]:


up = np.zeros((H, W), dtype=np.int16)
down = np.zeros((H, W), dtype=np.int16)
left = np.zeros((H, W), dtype=np.int16)
right = np.zeros((H, W), dtype=np.int16)

# up
up[0, :] = S[0, :]
for h in range(1, H):
    up[h, :] = up[h - 1, :] + 1
    up[h, :] *= S[h, :]

# down
down[H - 1, :] = S[H - 1, :]
for h in reversed(range(0, H - 1)):
    down[h, :] = down[h + 1, :] + 1
    down[h, :] *= S[h, :]

# left
left[:, 0] = S[:, 0]
for w in range(1, W):
    left[:, w] = left[:, w - 1] + 1
    left[:, w] *= S[:, w]

# right
right[:, W - 1] = S[:, W - 1]
for w in reversed(range(0, W - 1)):
    right[:, w] = right[:, w + 1] + 1
    right[:, w] *= S[:, w]

ans = np.max(up + down + left + right - 3)
print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[1]:


import numpy as np


# In[2]:


H, W = map(int, input().split())
S = np.ones((H, W), dtype=np.bool)
for i in range(H):
    S[i] = [s == "." for s in input()]


# In[3]:


up = np.zeros((H, W), dtype=np.int16)
down = np.zeros((H, W), dtype=np.int16)
left = np.zeros((H, W), dtype=np.int16)
right = np.zeros((H, W), dtype=np.int16)

# up
up[0, :] = S[0, :]
for h in range(1, H):
    up[h, :] = up[h - 1, :] + 1
    up[h, :] *= S[h, :]

# down
down[H - 1, :] = S[H - 1, :]
for h in reversed(range(0, H - 1)):
    down[h, :] = down[h + 1, :] + 1
    down[h, :] *= S[h, :]

# left
left[:, 0] = S[:, 0]
for w in range(1, W):
    left[:, w] = left[:, w - 1] + 1
    left[:, w] *= S[:, w]

# right
right[:, W - 1] = S[:, W - 1]
for w in reversed(range(0, W - 1)):
    right[:, w] = right[:, w + 1] + 1
    right[:, w] *= S[:, w]

ans = np.max(up + down + left + right - 3)
print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[2]:


import numpy as np


# In[3]:


H, W = map(int, input().split())
S = np.ones((H, W), dtype=np.bool)
for i in range(H):
    S[i] = [s == "." for s in input()]


# In[4]:


up = np.zeros((H, W), dtype=np.int16)
down = np.zeros((H, W), dtype=np.int16)
left = np.zeros((H, W), dtype=np.int16)
right = np.zeros((H, W), dtype=np.int16)

# up
up[0, :] = S[0, :]
for h in range(1, H):
    up[h, :] = up[h - 1, :] + 1
    up[h, :] *= S[h, :]

# down
down[H - 1, :] = S[H - 1, :]
for h in reversed(range(0, H - 1)):
    down[h, :] = down[h + 1, :] + 1
    down[h, :] *= S[h, :]

# left
left[:, 0] = S[:, 0]
for w in range(1, W):
    left[:, w] = left[:, w - 1] + 1
    left[:, w] *= S[:, w]

# right
right[:, W - 1] = S[:, W - 1]
for w in reversed(range(0, W - 1)):
    right[:, w] = right[:, w + 1] + 1
    right[:, w] *= S[:, w]

ans = np.max(up + down + left + right - 3)
print(ans)


# In[ ]:
Problem p03043 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[8]:


import math


# In[68]:


N, K = map(int, input().split())


# In[73]:


ans = 0
if K > 1:
    for i in range(1,N+1):
        ans += (1/2)**(max(math.floor(math.log((K-1)/i, 2)) + 1, 0))/N
else:
    ans = 1


# In[74]:


print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[8]:


import math


# In[68]:


N, K = map(int, input().split())


# In[71]:


ans = 0
for i in range(1,N+1):
    ans += (1/2)**(max(math.floor(math.log((K-1)/i, 2)) + 1, 0))/N


# In[72]:


print(ans)


# In[ ]:
Problem p03076 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[17]:


abcde = []
for _ in range(5):
    abcde.append(int(input()))
print(sum(-(-x//10)*10 for x in abcde) + min(x%10 if x%10 != 0 else 10 for x in abcde ) - 10)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[13]:


abcde = []
for _ in range(5):
    abcde.append(int(input()))
print(sum(-(-x//10)*10 for x in abcde) + min(x%10 for x in abcde if x%10 != 0) - 10)


# In[ ]:
Problem p03106 (python)

Fixed submission:

# coding: utf-8

# In[26]:


import sys


# In[106]:


A,B,K = map(int, input().split())


# In[107]:


def yakusuu(x):
    yakusuu_array = []

    for i in range(1, x+1):
        if x % i == 0:
            yakusuu_array.append(i)
    
    return yakusuu_array


# In[108]:


y_list = sorted(list(set(yakusuu(A)) & set(yakusuu(B))), reverse=True)


# In[109]:


print(y_list[K-1])

Buggy submission (verdict: Runtime Error):

# coding: utf-8

# In[2]:


import sys


# In[18]:


A,B,K = map(int, input().split())


# In[19]:


def yakusuu(x):
    yakusuu_array = []

    for i in range(1, x):
        if num % i == 0:
            yakusuu_array.append(i)
    
    return yakusuu_array


# In[21]:


if K > 1:
    print(list(set(yakusuu(A)) & set(yakusuu(B)))[K-1])
else:
    print(1)

Buggy submission (verdict: Runtime Error):

# coding: utf-8

# In[2]:


import sys


# In[18]:


A,B,K = map(int, input().split())


# In[19]:


def yakusuu(x):
    yakusuu_array = []

    for i in range(1, x):
        if num % i == 0:
            yakusuu_array.append(i)
    
    return yakusuu_array


# In[21]:


if K > 1:
    print(list(set(yakusuu(A)) & set(yakusuu(B)))[K-1])
else:
    print(1)
Problem p03128 (python)

Fixed submission:

# coding: utf-8

# In[1]:


def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    
    match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    
    result = [-1 for _ in range(N+1)]
    result[0] = 0
    
    #print(result)
    
    for i in range(1, N+1):
        for a in A:
            if i < match[a]:
                #print(i,a,result)
                continue
            result[i] = max(result[i], result[i-match[a]]*10+a)
            #print(i,a,result)
    
    print(result[N])


# In[2]:


main()

Buggy submission (verdict: Runtime Error):

# coding: utf-8

# In[46]:


def main():
    N,M = map(int, input().split())
    A = list(map(int, input().split()))
    
    match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    
    result = [-1 for _ in range(N+1)]
    result[0] = 0
    
    print(result)
    
    for i in range(1, N+1):
        for a in A:
            if i < match[a]:
                print(i,a,result)
                continue
            result[i] = max(result[i], result[i-match[a]]*10+a)
            print(i,a,result)
    
    print(result[N])


# In[47]:


main()
Problem p03241 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[11]:


N,M = map(int, input().split())


# In[12]:


def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


# In[14]:


for x in make_divisors(M)[::-1]:
    if M//x >= N:
        ans = x
        break
print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):

# coding: utf-8

# In[12]:


import numpy as np


# In[65]:


N,M = map(int, input().split())


# In[66]:


def usage(n):
    print('# 素因数')
    fct = factorize(n)
    print(fct, num(fct))
    
    print('# 約数')
    for div in divisorize(fct):
        print(div, num(div))


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a


# In[67]:


def func(n):
    fct = factorize(n)
    ret = []
    for div in divisorize(fct):
        ret.append(num(div))
    
    return ret


# In[68]:


div = np.array(func(M))


# In[69]:


print(div[div < M/N].max())
Problem p03244 (python)

Fixed submission:

# coding: utf-8

# In[129]:


from collections import Counter


# In[141]:


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


# In[142]:


v_even = Counter(v[::2]).most_common()
v_odd = Counter(v[1::2]).most_common()


# In[146]:


if len(v_even) == 1:
    v_even.append([0,0])
if len(v_odd) == 1:
    v_odd.append([0,0])
if v_even[0][0] == v_odd[0][0]:
    if v_even[1][1] > v_odd[1][1]:
        ret = n - v_even[1][1] - v_odd[0][1]
    else:
        ret = n - v_even[0][1] - v_odd[1][1]
else:
    ret = n - v_even[0][1] - v_odd[0][1]


# In[147]:


print(ret)

Buggy submission (verdict: Runtime Error):

# coding: utf-8

# In[129]:


from collections import Counter


# In[130]:


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


# In[134]:


v_even = Counter(v[::2]).most_common()
v_odd = Counter(v[1::2]).most_common()


# In[136]:


if len(v_even) == 1:
    v_even.append([0,0])
if len(v_odd) == 1:
    v_odd.append([0,0])


# In[ ]:


if v_even[0][0] == v_odd[0][0]:
    if v_even[1][1] > v_odd[1][1]:
        ret
Problem p03324 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[13]:


D,N = map(int, input().split())


# In[15]:


if N != 100:
    print(N*(100**D))
elif N == 100:
    print((N+1)*100**D)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[13]:


D,N = map(int, input().split())


# In[15]:


if N != 100:
    print(N*(100**D))
elif n == 100:
    print((N+1)*100**D)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[13]:


D,N = map(int, input().split())


# In[15]:


if N != 100:
    print(N*(100**D))
elif n == 100:
    print((N+1)*100**D)


# In[ ]:
Problem p03386 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[41]:


A,B,K = map(int, input().split())


# In[42]:


ans = []
for x in range(A, min(A+K,B+1)):
    ans.append(x)
for x in range(max(A,B-K+1), B+1):
    ans.append(x)
for x in sorted(list(set(ans))):
    print(x)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[12]:


A,B,K = map(int, input().split())


# In[13]:


mylist = list(range(A,B+1))
for x in mylist:
    if x < A+K or x > B-K:
        print(x)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[9]:


A,B,K = map(int, input().split())


# In[10]:


mylist = list(range(A,B+1))
ans = [x for x in mylist if x < A+K or x > B-K]
print(ans)


# In[ ]: