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

Fixed submission:
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Buggy submission (verdict: Runtime Error):
import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

Buggy submission (verdict: Runtime Error):
import numpy as np

n,k = map(int, input().split())
a = list(map(int, input().split()))

a = [i for i in a if i <k]
n = len(a)

DP1 = [[False]*(k+1) for i in range(n+1)]
DP1 = np.full((n+1, k+1), False)
DP1[0][0] = True
DP2 = [[False]*(k+1) for i in range(n+1)]
DP2 = np.full((n+1, k+1), False)
DP2[0][0] = True

for i in range(n):
    DP1[i+1] = DP1[i]
    DP1[i+1][a[i]:] |= DP1[i][:k-a[i]+1]
    DP2[i+1] = DP2[i]
    DP2[i+1][a[n-1-i]:] |= DP2[i][:k-a[n-1-i]+1]

hoge = []
for i in range(n+1):
    q = [0]
    for j in range(k+1):
        q.append(q[-1]+int(DP2[i][j]))
    hoge.append(q)

ans = 0
for i in range(n):
    use = False
    for j in range(k+1):
        if not DP1[i][j]:
            continue
        left = max(0, k-a[i]-j)
        right = k-j
        if hoge[n-i-1][right] - hoge[n-i-1][left]:
            use = True
            break
    if not use:
        ans += 1

print(ans)
Problem p03796 (python)

Fixed submission:
N = int(input())
ans = 1
for i in range(N):
    ans = ans * (i + 1) % (10**9 + 7)
print(ans)

Buggy submission (verdict: Runtime Error):
    N = int(input())
    ans = 1
    for i in range(N):
        ans = ans * (i + 1) % (10**9 + 7)
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 1
for i in range(N)
    ans = ans * (i + 1) % (10**9 + 7)
print(ans)
Problem p03831 (python)

Fixed submission:
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
uf = [1]*n
ans = 0
for i in range(n-1):
    if a*(x[i+1]-x[i]) <= b:
        ans += a*(x[i+1]-x[i])
        uf[i+1] = 0
ans += b*(sum(uf)-1)
print(ans)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
edges = [[b]*n for i in range(n)]
for i in range(n):
    edges[i][i] = 0
for i in range(n-1):
    edges[i][i+1] = edges[i+1][i] = min(b, (x[i+1]-x[i])*a)

import numpy as np
from scipy.sparse.csgraph import minimum_spanning_tree
ans = np.sum(minimum_spanning_tree(edges))
print(int(ans))
Problem p03866 (python)

Fixed submission:
from math import sqrt
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
# https://atcoder.jp/users/nadare881

def calc_dist(p1,p2):
    return max(0, sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2) - (p1[2]+p2[2]))

xs, ys, xg, yg = map(int, input().split())
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
p = [[xs,ys,0], [xg,yg,0]] + p
n += 2
edges = [[float("inf")]*n for i in range(n)]
for i in range(n):
    for j in range(i,n):
        if i == j :continue
        edges[i][j] = edges[j][i] = calc_dist(p[i], p[j])
edges = csgraph_from_dense(edges, null_value=float("inf"))
dist = dijkstra(edges, directed=False, indices=0)
print(dist[1])

Buggy submission (verdict: Runtime Error):
from math import sqrt
from scipy.sparse.csgraph import dijkstra, csgraph_from_dense

def calc_dist(p1,p2):
    return max(0, sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2) - (p1[2]+p2[2]))

xs, ys, xg, yg = map(int, input().split())
n = int(input())
p = [list(map(int, input().split())) for i in range(n)]
p = [[xs,ys,0], [xg,yg,0]] + p
n += 2
edges = [[float("inf")]*n for i in range(n)]
for i in range(n):
    for j in range(i,n):
        edges[i][j] = edges[j][i] = calc_dist(p[i], p[j])
edges = csgraph_from_dense(edges, null_value=float("inf"))
dist = dijkstra(edges, directed=False, indices=0)
print(dist[1])
Problem p04003 (python)

Fixed submission:
# https://juppy.hatenablog.com/entry/2019/04/10/ARC061_-_E_%E3%81%99%E3%81%AC%E3%81%91%E5%90%9B%E3%81%AE%E5%9C%B0%E4%B8%8B%E9%89%84%E6%97%85%E8%A1%8C_-_Python_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0_Atcoder
# 参考にさせていただきました。

from collections import deque, defaultdict

chg = 10**6
n, m = map(int, input().split())
edges = defaultdict(set)
# m=0のためにdefaultdictにしておくべき
visited = defaultdict(set)
for i in range(m):
    p, q, c = map(int, input().split())
    edges[p+c*chg].add(q+c*chg)
    edges[q+c*chg].add(p+c*chg)
    edges[p].add(p+c*chg)
    edges[q].add(q+c*chg)
    edges[p+c*chg].add(p)
    edges[q+c*chg].add(q)
    visited[p] = False
    visited[q] = False
    visited[p+c*chg] = False
    visited[q+c*chg] = False

ans = float("inf")
que = deque()
# now, dist
que.append((1, 0))
# 今求めるのはendの距離だけなので、dist配列はいらない
# さらに、距離は0/1なのでheapで辺を管理する必要もなく、0なら最短確定なので先に、1ならその時点での最長なので後ろにすれば良い
while que:
    now, dist = que.popleft()
    if visited[now]:
        continue
    visited[now] = True
    if now == n:
        ans = dist
        break
    for to in edges[now]:
        # 駅→ホーム
        if now < chg and to > chg:
            que.append((to, dist+1))
        else:
            que.appendleft((to, dist))
if ans == float("inf"):
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
# https://juppy.hatenablog.com/entry/2019/04/10/ARC061_-_E_%E3%81%99%E3%81%AC%E3%81%91%E5%90%9B%E3%81%AE%E5%9C%B0%E4%B8%8B%E9%89%84%E6%97%85%E8%A1%8C_-_Python_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0_Atcoder
# 参考にさせていただきました。

from collections import deque, defaultdict

chg = 10**6
n, m = map(int, input().split())
edges = defaultdict(set)
visited = dict()
for i in range(m):
    p, q, c = map(int, input().split())
    edges[p+c*chg].add(q+c*chg)
    edges[q+c*chg].add(p+c*chg)
    edges[p].add(p+c*chg)
    edges[q].add(q+c*chg)
    edges[p+c*chg].add(p)
    edges[q+c*chg].add(q)
    visited[p] = False
    visited[q] = False
    visited[p+c*chg] = False
    visited[q+c*chg] = False

ans = float("inf")
que = deque()
# now, dist
que.append((1, 0))
# 今求めるのはendの距離だけなので、dist配列はいらない
# さらに、距離は0/1なのでheapで辺を管理する必要もなく、0なら最短確定なので先に、1ならその時点での最長なので後ろにすれば良い
while que:
    now, dist = que.popleft()
    if visited[now]:
        continue
    visited[now] = True
    if now == n:
        ans = dist
        break
    for to in edges[now]:
        # 駅→ホーム
        if now < chg and to > chg:
            que.append((to, dist+1))
        else:
            que.appendleft((to, dist))
if ans == float("inf"):
    print(-1)
else:
    print(ans)
Problem p04017 (python)

Fixed submission:
import sys
input = sys.stdin.readline

from bisect import bisect

n = int(input())
x = list(map(int, input().split()))
l = int(input())

m = 20
par = [[-1]*n for i in range(m)]

for i in range(n):
    j = bisect(x, x[i]+l)-1
    par[0][i] = j

for i in range(m-1):
    for j in range(n):
        par[i+1][j]=par[i][par[i][j]]

def hoge(x, y):
    k = 0
    for i in range(m)[::-1]:
        if par[i][x] < y:
            k += 1<<i
            x = par[i][x]
    return k+1

q = int(input())
ans = []
for i in range(q):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    if a > b:
        a,b = b,a
    print(hoge(a,b))

Buggy submission (verdict: Runtime Error):
from bisect import bisect_right

n = int(input())
x = list(map(int, input().split()))
l = int(input())

depth = [-1]*n
depth[-1] = 0

m = 18
par = [[-1]*n for i in range(m)]

def dfs(i):
    if depth[i] >= 0:
        return depth[i]
    j = bisect_right(x, x[i]+l)-1
    if j >= n:
        j = n-1
    par[0][i] = j
    depth[i] = dfs(j) + 1
    return depth[i]

for i in range(n):
    dfs(i)

for i in range(17):
    for j in range(n):
        par[i+1][j]=par[i][par[i][j]]

def hoge(x, y):
# xからk個上の頂点がy以上になる最小のkを求める
    k = 0
    for i in range(18)[::-1]:
        if 0 <= par[i][x] <= y:
            k += 1<<i
            x = par[i][x]
    return k

q = int(input())
ans = []
for i in range(q):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    if a > b:
        a,b = b,a
    ans.append(hoge(a, b))

print(*ans, sep="\n")
Problem p02660 (python)

Fixed submission:
N = int(input())

import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  

c = collections.Counter(prime_factorize(N))

A = c.keys()
count = c.values()

ans = 0

for i in count:
  k = 0
  for j in range(1,i+1):
    k += j
    if k <= i:
      ans += 1
      
print(ans)

Buggy submission (verdict: Runtime Error):
import collections

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  

c = collections.Counter(prime_factorize(N))

A = c.keys()
count = c.values()

ans = 0

for i in count:
  k = 0
  for j in range(1,i):
    k += j
    if k <= i:
      ans += 1
print(ans)
Problem p02691 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
P = {}
Q = {}
X = {}
for i in range(N):
  p = i+1+A[i]
  q = i+1-A[i]
  if str(p) in P:
    P[str(p)] += 1
  else:
    P[str(p)] = 1
  if str(q) in Q:
    Q[str(q)] += 1
  else:
    Q[str(q)] = 1
  X.setdefault(str(p),i+1+A[i])
  X.setdefault(str(q),i+1-A[i])

#J[a]とI[b]が等しいのが条件
#とりうる値 < 10**9を全て試す
ans = 0

for key in X.keys():
  if (key in P) and (key in Q):
  	ans += P[key] * Q[key]

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
P = {}
Q = {}
X = {}
for i in range(N):
  p = i+1+A[i]
  q = i+1-A[i]
  if str(p) in P:
    P[str(p)] += 1
  else:
    P[str(p)] = 0
  if str(q) in Q:
    Q[str(q)] += 1
  else:
    Q[str(q)] = 0
  
  X.setdefalut(str(i+1+A[i]),i+1+A[i])
  X.setdefalut(str(i+1-A[i]),i+1-A[i])
  
#J[a]とI[b]が等しいのが条件
#とりうる値 < 10**9を全て試す
ans = 0

for key in X.keys():
  ans += P[key] * Q[key]
  
print(ans)
Problem p02696 (python)

Fixed submission:
A,B,N = map(int,input().split())
x = min(B-1,N)
print((A*x)//B-A*(x//B))

Buggy submission (verdict: Runtime Error):
A,B,N = map(int,input().split())
x = min(B-1,N)
print((A*x)//b - A*(x//b))

Buggy submission (verdict: Runtime Error):
A,B,N = map(int,input().split())
x = min(B-1,N)
print((A*x)//b-A*(x//b))
Problem p02861 (python)

Fixed submission:
n = int(input())
maps = [list(map(float,input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            pass
        else:
            ans += ((maps[i][0]-maps[j][0])**2 + (maps[i][1]-maps[j][1])**2) **(1/2)
			
num = 1
for k in range(1,n+1):
    num *= k
print(ans/n)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
a = 1
b = 1
n = (2*y-x)//3
m = (2*x-y)//3

if (x+y)%3 == 0:
  for i in range(n+1,n+m+1):
    a *= i
  for j in range(1,m+1):
    b *= j
  print(a//b)
else:
  print(0)
Problem p02885 (python)

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

if a <= b*2:
  print("0")
else:
  print(a-b*2)

Buggy submission (verdict: Runtime Error):
a.b = int(input().split())

if a <= b*2:
  print("0")
else:
  print(a-b*2)
Problem p02909 (python)

Fixed submission:
str = input()
 
if str == "Sunny":
  print("Cloudy")
elif str == "Cloudy":
  print("Rainy")
else:
  print("Sunny")

Buggy submission (verdict: Runtime Error):
str = input()

if str == "Sunny":
  print("Cloudy")
elif str == "Cloudy":
  print("Rainy"):
else:
  print("Sunny")
Problem p02910 (python)

Fixed submission:
strs = input()
 
for i in range(len(strs)):
  if i % 2 != 0:
    if (strs[i] == "L") or (strs[i] == "U") or (strs[i] == "D"):
      continue
    else:
      print("No")
      break
  else:
    if (strs[i] == "R") or (strs[i] == "U") or (strs[i] == "D"):
      continue
    else:
      print("No")
      break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
strs = input()
 
for i in range(len(strs)):
  if !(i % 2 == 0):
    if (strs[i] == "L") or (strs[i] == "U") or (strs[i] == "D"):
      continue
    else:
      print("No")
      break
  else:
    if (strs[i] == "R") or (strs[i] == "U") or (strs[i] == "D"):
      continue
    else:
      print("No")
      break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
strs = input()

for str in strs:
  if i % 2 == 0:
    if (i == "L") or (i == "U") or (i == "D"):
      continue
    else:
      print("No")
      break
  else:
    if (i == "R") or (i == "U") or (i == "D"):
      continue
    else:
      print("No")
      break
else:
  print("Yes")
Problem p02911 (python)

Fixed submission:
people_num, first_point, correct = map(int,input().split())
who_correct = [input() for i in range(correct)]
points = [first_point-correct for i in range(people_num)]

 
for i in range(correct):
    points[int(who_correct[i])-1] += 1
    
for i in range(people_num):
  if points[i] <= 0:
  	print("No")
  else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
people_num, first_point, correct = map(int,input().split())
people = [input() for i in range(people_num)]
points = [correct for i in range(people_num)]
 
for i in range(correct):
  for j in range(people_num):
    if j != i:
      points[j] -= 1
      if points[j] == 0:
        prints[j] = - 100000000
        
for i in range(people_num):
  if points[i] < 0:
    print("No")
  else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
people_num, first_point, correct = map(int,input().split())
people = [input() for i in range(people_num)]
points = [correct for i in range(people_num)]
 
for i in range(correct):
  for j in range(people_num):
    if j != i:
      points[j] -= 1
      if points[j] == 0:
        prints[j] = - 100000000
        
for i in range(people_num):
  if points[i] < 0:
  	print("No")
  else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
people_num, first_point, correct = map(int,input().split())
people = [input() for i in range(people_num)]
points = [correct for i in range(people_num)]

for i in range(correct):
  for j in range(people_num):
    if j != i:
      points[j] -= 1
      if points[j] == 0:
        prints[j] = - 100000000

for i in range(people_num):
  if points[i] < 0:
  	print("No")
  else:
    print("Yes")
Problem p02927 (python)

Fixed submission:
month,day = map(int,input().split())

if day < 22:
  print(0)
else:
  s = 0
  for j in range(month+1):
    for i in range(22,day+1):
      num_1 = i%10
      num_2 = (i-num_1)/10
      if  num_1< 2:
        continue
      elif num_1 * num_2 == j:
        s += 1
  print(s)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i+1,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(10e+8+7)))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]

print(int(result/(10**9+7)))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(10E9+7)))
Problem p02928 (python)

Fixed submission:
def solve():
    N, K, *a_l = map(int, open(0).read().split())
    MOD = 10**9+7
    count_a, count_b = 0, 0
    inversion = 0

    for i in range(N):
        for j in range(N):
            if a_l[i] > a_l[j]:
                if i < j:
                    count_a += 1
                count_b += 1

    inversion = count_a * K + count_b * (K * (K - 1)) // 2
    print(inversion%MOD)



if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]

print(int(result/(10**9+7)))
Problem p02900 (python)

Fixed submission:
import fractions

A, B = map(int, input().split())
g = fractions.gcd(A, B)

def make_divisors(n):
    count = 0
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            # print(i)
            flag = 1
            for j in range(2, int(i**0.5)+1):
                if i%j == 0:
                    flag = 0
                    break
            if flag == 1:
                count += 1
            if i != n // i:
                flag = 1
                for j in range(2, int((n // i)**0.5)+1):
                    if (n // i) %j == 0:
                        flag = 0
                        break
                if flag == 1:
                    count += 1
    return count

print(make_divisors(g))

Buggy submission (verdict: Runtime Error):
import fractions

A, B = map(int, input().split())
g = fractions.gcd(A, B)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            # print(i)
            flag = 1
            for j in range(2, int(math.sqrt(i))+1):
                if i%j == 0:
                    flag = 0
                    break
            if flag == 1:
                divisors.append(i)
            if i != n // i:
                flag = 1
                for j in range(2, int(math.sqrt(n // i))+1):
                    if (n // i) %j == 0:
                        flag = 0
                        break
                if flag == 1:
                    divisors.append(n//i)
    return divisors

print(len(make_divisors(g)))

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())
g = math.gcd(A, B)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

print(len(make_divisors(g))-1)
Problem p02548 (python)

Fixed submission:
n = int(input())
 
ans = 0
for i in range(1,n):
  ans += (n-1)//i
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
 
for i in range(1,n):
  ans += (n-1)//i
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())

for i in range(1,n):
  ans += (n-1)//a
print(ans)
Problem p02645 (python)

Fixed submission:
import random

s = input()

len_s = len(s)

if len_s==3:
	num = 0
else:
	num = random.randint(0,len_s-4)

name = s[num]+s[num+1]+s[num+2]

print(name)

Buggy submission (verdict: Runtime Error):
import random

s = input()

len_s = len(s)

num = random.randint(0,len_s-4)

name = s[num]+s[num+1]+s[num+2]

print(name)
Problem p02574 (python)

Fixed submission:
import sys, math
input= sys.stdin.readline

N = int(input())
A_lst = list(map(int, input().split()))
lst=[0]*(10**6+1)

# 割れる最大の素数を出す
for i in range(2, 10**6+1):
  if not lst[i]:
    for j in range(i, 10**6+1, i):
      lst[j] = i
      
# not coprimeか判定する
ans = 'not coprime'
GCD = A_lst[0]
for i in range(N):
  GCD = math.gcd(GCD, A_lst[i])
  
if GCD != 1:
  print(ans)
else:
  ans = 'setwise coprime'
  post = 1
  visited = [0]*(10**6+1)
  for i in range(N):
    a = A_lst[i]
    while a > 1:
      dv = lst[a]
      if visited[dv]:
        post = 0
        break
      while a % dv == 0:
        a //= dv
      visited[dv] = 1
  
  if post:
    ans = 'pairwise coprime'
  print(ans)

Buggy submission (verdict: Runtime Error):
import math

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

n = int(input())
a = list(map(int,input().split()))
maxval = max(a)
p = get_sieve_of_eratosthenes(maxval)
d = [-1]*1000010
m = [-1]*1000010
flag = True


for i in p[::-1]:
  tmp = i
  multi = 2
  while(tmp<=maxval):
    d[tmp] = i
    tmp = tmp*multi
    multi += 1
    
for i in a:
  while(d[i]!=i):
    if(m[d[i]]==1):
      flag = False
      break
    m[d[i]] = 1
    i = i // d[i]
  m[d[i]] = 1
  if(flag == False):
    break
  
if(flag):
  print("pairwise coprime")
else:
  ans = a[0]
  for i in range(1, n):
    ans = math.gcd(ans, a[i])
  if ans==1:
    print("setwise coprime")
  else:
    print("not coprime")

Buggy submission (verdict: Runtime Error):
import math

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

n = int(input())
a = list(map(int,input().split()))
maxval = max(a)
p = get_sieve_of_eratosthenes(maxval)
d = [-1]*1000010
m = [-1]*1000010
flag = True


for i in p:
  tmp = i
  multi = 2
  while(tmp<=maxval):
    d[tmp] = i
    tmp = tmp*multi
    multi += 1
    
for i in a:
  while(d[i]!=i):
    if(m[d[i]]==1):
      flag = False
      break
    m[d[i]] = 1
    i = i // d[i]
  m[d[i]] = 1
  if(flag == False):
    break
  
if(flag):
  print("pairwise coprime")
else:
  ans = a[0]
  for i in range(1, n):
    ans = math.gcd(ans, a[i])
  if ans==1:
    print("setwise coprime")
  else:
    print("not coprime")