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

Fixed submission:
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:
            self.parents[x] = self.find(self.parents[x])
            return 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

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    
from sys import stdin
imput = stdin.readline
n,m = map(int, input().split())  # 3個の数字の入力を受け取る
uf = UnionFind(n)
#print(uf.parents)

num_list = []
for i in range(m):
    num_list.append(list(map(int,input().split())))
#print(num_list)
for i in range(m):
    #print(num_list[i][0])
    #print(num_list[i][1])
    uf.union(num_list[i][0]-1, num_list[i][1]-1)
    #print(uf.parents)
print(uf.group_count()-1)

Buggy submission (verdict: Runtime Error):
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:
            self.parents[x] = self.find(self.parents[x])
            return 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

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    
from sys import stdin
imput = stdin.readline
n,m = map(int, input().split())  # 3個の数字の入力を受け取る
uf = UnionFind(n)
#print(uf.parents)

num_list = []
for i in range(m):
    num_list.append(list(map(int,input().split())))
#print(num_list)
for i in range(m):
    uf.union(num_list[i][0], num_list[i][1])
print(uf.group_count()-1)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

ans = 1

for i in range(n):
    ans *= a[i]
    if ans = 0:
        print(0)
        exit()
    elif ans > 10**18:
        print(-1)
        exit()

print(ans)
Problem p02658 (python)

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

ans = 1

if 0 in a:
    print(0)
    exit()

for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

ans = 1

for i in range(n):
    ans *= a[i]
    if ans = 0:
        print(0)
        exit()
    elif ans > 10**18:
        print(-1)
        exit()

print(ans)
Problem p02713 (python)

Fixed submission:
import math

k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        gcd_ab = math.gcd(a, b)
        for c in range(1, k+1):
            ans += math.gcd(gcd_ab, c)
print(ans)

Buggy submission (verdict: Runtime Error):
k = int(input())
sum_ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        gcd_ab = gcd(a, b)
        for c in range(1, k+1):
            gcd_abc = gcd(gcd_ab, c)
            sum_ans += gcd_abc
print(sum_ans)
Problem p03644 (python)

Fixed submission:
n = int(input())

if n>=64:
    print(64)
elif 32<=n<64:
    print(32)
elif 16<=n<32:
    print(16)
elif 8<=n<16:
    print(8)
elif 4<=n<8:
    print(4)
elif 2<=n<4:
    print(2)
else:
    print(1)

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

if n>=64:
    print(64)
elif 32<=n<64:
    print(32)
elif 16<=n<32:
    print(16)
elif 8<=n<16:
    print(8)
elif 4<=n<8:
Problem p02696 (python)

Fixed submission:
#-*- coding: utf-8 -*-
import math
a,b,n = map(int,input().split())
x = min(b-1,n)
ans = math.floor(a*x//b)-a*math.floor(x/b)
print(ans)

Buggy submission (verdict: Runtime Error):
#-*- coding: utf-8 -*-
a,b,n = map(int,input().split())
if n>=b:
    n = b - 1
    print(int(a*n/b)-(a*n/b))
    exit():
else:
    print(int(a*n/b))
    exit():
Problem p02601 (python)

Fixed submission:
import sys
import os
# import math
# input = sys.stdin.readline

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


def str_array():
    return input().strip().split()

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b);

def take_input():
	if os.environ.get("check"):
		sys.stdin = open('input.txt', 'r') 
		sys.stdout = open('output.txt', 'w')
		
take_input()
######################### TEMPLATE ENDS HERE #################################

a,b,c = int_array()
k = int(input())

# conditions
#c>b>a

count = 0

for _ in range(k):
    if a>=b:
        b*=2
    elif b>=c:
        c*=2
    if a<b<c:
        break

if a<b<c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
import os
# import math
# input = sys.stdin.readline

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


def str_array():
    return input().strip().split()

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b);

def take_input():
	if os.environ.get("check"):
		sys.stdin = open('input.txt', 'r') 
		sys.stdout = open('output.txt', 'w')
		
take_input()
######################### TEMPLATE ENDS HERE #################################

a,b,c = int_array()
k = int(input())

# conditions
#c>b>a

var = False

if a>=b:
    no1 = ((a-b)//2)+1
    if b % 2 ==0:
        b =a+2
    else:
        b = a+1

if b>=c:
    no2 = ((b-c)//2)+1

if no1+no2>=k:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
import os
# import math
# input = sys.stdin.readline

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


def str_array():
    return input().strip().split()

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b);

def take_input():
	if os.environ.get("check"):
		sys.stdin = open('input.txt', 'r') 
		sys.stdout = open('output.txt', 'w')
		
take_input()
######################### TEMPLATE ENDS HERE #################################

a,b,c = int_array()
k = int(input())

# conditions
#c>b>a

var = False

if a>=b:
    no1 = ((a-b)//2)+1
    if b % 2 ==0:
        b =a+2
    else:
        b = a+1

if b>=c:
    no2 = ((b-c)//2)+1

if no1+no2>=k:
    print("Yes")
else:
    print("No")
Problem p02720 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    def gen():
        counter = 0
        q = deque(range(1, 10))
        while counter < 100001:
            n = q.popleft()
            yield n
            counter += 1
            t = n % 10
            if t > 0:
                q.append(n*10 + (t - 1))
            q.append(n*10 + t)
            if t < 9:
                q.append(n*10 + (t + 1))
    g = gen()
    for _ in range(ii() - 1):
        next(g)
    print(next(g))

main()

Buggy submission (verdict: Runtime Error):
from collections import deque

def main():
    def gen():
        counter = 0
        q = deque(range(1, 10))
        while counter < 100001:
            n = q.popleft()
            yield n
            counter += 1
            t = n % 10
            if t > 0:
                q.append(n*10 + (t - 1))
            q.append(n*10 + t)
            if t < 9:
                q.append(n*10 + (t + 1))
    g = gen()
    for _ in range(ii() - 1):
        next(g)
    print(next(g))

main()
Problem p02924 (python)

Fixed submission:
N = int(input())

print((N-1) * N // 2)

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

import numpy as np

a = np.arange(1, N+1)
p = np.copy(a) + 1
p[-1] = 1

print(np.sum(a%p))
Problem p03044 (python)

Fixed submission:
N = int(input())

data = [[] for _ in range(N)]
ans = [None] * N

for i in range(N-1):
    u,v,w = map(int, input().split())
    u -= 1
    v -= 1
    w &= 1
    data[u].append((v, w))
    data[v].append((u, w))

import sys
sys.setrecursionlimit(10000000)
def f(i, color):
    for t, w in data[i]:
        if ans[t] is not None:
            continue
        ans[t] = color^w
        f(t, color^w)

f(0, 0)

for i in range(N):
    print(ans[i])

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

data = [[] for _ in range(N)]
ans = [None] * N

for i in range(N-1):
    u,v,w = map(int, input().split())
    u -= 1
    v -= 1
    w &= 1
    data[u].append((v, w))
    data[v].append((u, w))

def f(i, color):
    for t, w in data[i]:
        if ans[t] is not None:
            continue
        ans[t] = color^w
        f(t, color^w)

f(0, 0)

for i in range(N):
    print(ans[i])
Problem p03162 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    N = ii()
    sa,sb,sc = 0,0,0
    for _ in range(N):
        a,b,c=mis()
        nsa = max(sb,sc)+a
        nsb = max(sc,sa)+b
        nsc = max(sa,sb)+c
        sa,sb,sc = nsa,nsb,nsc
    print(max(sa,sb,sc))

main()

Buggy submission (verdict: Runtime Error):
N = int(input())
scores = []

for i in range(N):
    scores.append(tuple(map(int, input().split())))

mem = [[None]*3 for i in range(N)]

def getScore(day, act):
    if mem[day][act] is not None:
        return mem[day][act]
    score = scores[day][act]
    if day < N-1:
        score += max(getScore(day+1, (act+1)%3), getScore(day+1, (act+2)%3))
    mem[day][act] = score
    return score

print(max(getScore(0, act) for act in range(3)))
Problem p03760 (python)

Fixed submission:
O = input()
E = input()

S = ''
for i in range(len(O)):
    S += O[i]
    if len(E) > i:
        S += E[i]

print(S)

Buggy submission (verdict: Runtime Error):
O = input()
E = input()

S = ''
for i in range(len(O)):
    S += O[i]
    S += E[i]

print(S)
Problem p02678 (python)

Fixed submission:
import queue
I=lambda:map(int,input().split())
N,M=I()
ls=[[] for _ in range(N+1)]
for _ in[0]*M:
  A,B=I()
  ls[A]+=[B]
  ls[B]+=[A]
q = queue.Queue()
v=[-1]*(N+1)
v[0]=v[1]=0
q.put(1)
while not(q.empty()):
  top=q.get()
  for l in ls[top]:
    if v[l]<0:
      v[l]=top
      q.put(l)
if -1 in v:
  print("No")
else:
  print("Yes")
  [print(k) for k in v[2::]]

Buggy submission (verdict: Runtime Error):
import queue
I=lambda:map(int,input().split())
N,M=I()
ls=[[] for _ in range(M+1)]
for _ in[0]*M:
  A,B=I()
  ls[A]+=[B]
  ls[B]+=[A]
q = queue.Queue()
v=[-1]*(N+1)
v[0]=v[1]=0
q.put(1)
while not(q.empty()):
  top=q.get()
  for l in ls[top]:
    if v[l]<0:
      v[l]=top
      q.put(l)
if -1 in v:
  print("No")
else:
  print("Yes")
  [print(k) for k in v[2::]]
Problem p03087 (python)

Fixed submission:
I=lambda:map(int,input().split())
N,Q=I()
S=input()
m=[0]
for i in range(N-1):
    m+=[m[-1]+(1 if S[i:i+2]=='AC' else 0)]
#print(m)
for i in range(Q):
    l,r=I()
    print(m[r-1]-m[l-1])

Buggy submission (verdict: Runtime Error):
import bisect
I=lambda:map(int,input().split())
N,Q=I()
S=input()
m=[]
for i in range(N-1):
    if S[i]=='A' and S[i+1]=='C':m.append(i+1)
#print(m)
for i in range(Q):
    l,r=I()
    li=bisect.bisect_left(m,l)
    ri=bisect.bisect_left(m,r)
    #print(i,li,ri)
    if m[ri-1]==r:
        print(ri-li-1)
    else:
        print(ri-li)

Buggy submission (verdict: Runtime Error):
import bisect
I=lambda:map(int,input().split())
N,Q=I()
S=input()
m=[]
for i in range(N-1):
    if S[i]=='A' and S[i+1]=='C':
        m += [i]
#print(m)
for i in range(Q):
    l,r=I()
    li=bisect.bisect_left(m,l-1)
    ri=bisect.bisect_left(m,r-1)
    #print(i,li,ri)
    print(ri-li-1 if m[ri-1]==r else ri-li)
Problem p03128 (python)

Fixed submission:
#解説より
cost=[0,2,5,5,4,5,6,3,7,6]
N,M=map(int,input().split())
A=sorted(map(int,input().split()))[::-1]
dp=[0]
for i in range(1,N+1):
    l=[dp[i-cost[a]]for a in A if i>=cost[a]]
    if len(l)==0:dp+=[-1]
    else:dp+=[max(l)+1]
S=''
Sum=0
for i in range(dp[N]):
    for a in A:
        if N-Sum-cost[a]>=0 and dp[N-Sum-cost[a]]==dp[N]-1-i:
            S+=str(a)
            Sum+=cost[a]
            break
print(S)

Buggy submission (verdict: Runtime Error):
#解説より
cost=[0,2,5,5,4,5,6,3,7,6]
N,M=map(int,input().split())
A=sorted(map(int,input().split()))[::-1]
dp=[0]
for i in range(1,N+1):
    l=[dp[i-cost[a]]for a in A if i>=cost[a]]
    if len(l)==0:dp+=[-1]
    else:dp+=[max(l)+1]
S=''
Sum=0
for i in range(dp[N]):
    for a in A:
        if dp[N-Sum-cost[a]]==dp[N]-1-i:
            S+=str(a)
            Sum+=cost[a]
            break
print(S)
Problem p03219 (python)

Fixed submission:
a,b=map(int,input().split())
print(a+b//2)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input())
print(a+b/2)
Problem p03227 (python)

Fixed submission:
S=input()
print(S[::-1]if len(S)==3 else S)

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
q=int(math.sqrt(N*2))
if N*2!=q*q+q:print("No");exit()
S=[list(range(1,q+1))]
S+=[[j]for j in S[0]]
last=q
for i in range(1,q):
	r=list(range(last+1,last+1+q-i))
	S[i]+=r
	for j in range(q-i):S[i+j+1]+=[r[j]]
	last=r[-1]
print("Yes")
print(len(S))
for s in S:print(len(s)," ".join(map(str,s)))
Problem p03447 (python)

Fixed submission:
print((int(input())-int(input()))%int(input()))

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input())
print((x-a)%b)
Problem p03478 (python)

Fixed submission:
n,a,b = map(int,input().split())
r = 0
for i in range(n+1):
    wa = sum(map(int,list(str(i))))
    if a <= wa and wa <= b: r += i
print(r)

Buggy submission (verdict: Runtime Error):
print(sum(map(int,list(input()))))
Problem p03533 (python)

Fixed submission:
S=input()
N=len(S)
K,I,H,B,R=S.find('K'),S.find('I'),S.find('H'),S.find('B'),S.find('R')
f = (K==0 or K==1) and K==I-1==H-2 and (H+1==B or S[H+1]=='A') and (B+1==R or S[B+1]=='A') and (R==N-2 and S[R+1]=='A' or R==N-1)
T='AKIHABARA'
i=0;j=0;g=True
while 1:
    if S[i]==T[j]:i+=1;j+=1
    elif T[j]=='A':j+=1
    else:g=False;break
    if i==len(S):break
    elif j==9:g=False;break
print('YES'if f and g else 'NO')

Buggy submission (verdict: Runtime Error):
S=input()
T='AKIHABARA'
i=0;j=0
while 1:
    if S[i]==T[j]:i+=1;j+=1
    elif 'A'==T[j]:j+=1
    else:break
    if i>=len(S):break
print('YES'if i==len(S) else 'NO')
Problem p03556 (python)

Fixed submission:
import math
print(int(math.sqrt(int(input())))**2)

Buggy submission (verdict: Runtime Error):
print(int(sqrt(int(input())))**2)
Problem p03671 (python)

Fixed submission:
*a,=map(int,input().split());print(sum(a)-max(a))

Buggy submission (verdict: Runtime Error):
*a=map(int,input().split());print(sum(a)-max(a))
Problem p03695 (python)

Fixed submission:
c=[0]*9
input()
for a in map(int,input().split()):c[min(a//400,8)]+=1
b=0
for i in range(8):b+=1if c[i]>0 else 0
print(max(b,1), b+c[8])

Buggy submission (verdict: Runtime Error):
def color(r):
  if r<3200:return r//400
  else:return 8
colors = [0]*9
N=int(input())
for a in map(int,input().split()):
  colors[color(a)]+=1
base=0
for i n range(8):
  if colors[i]>0:base+=1
print(base, base+colors[8])
Problem p03720 (python)

Fixed submission:
I=lambda:map(int,input().split())
N,M=I()
r=range(N)
m={i:0 for i in r}
for _ in[0]*M:
  a,b=I()
  m[a-1]+=1
  m[b-1]+=1
for i in r:print(m[i])

Buggy submission (verdict: Runtime Error):
I=lambda:map(int,input().split())
N,M=I()
r=range(N)
m={i:0 for i in r}
for _ in[0]*M:a,b=I();m[a]+=+1;m[b]+=1
for i in r:print(m[i])
Problem p03738 (python)

Fixed submission:
A,B=int(input()),int(input())
print("GREATER"if A>B else"LESS"if A<B else"EQUAL")

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
print("GREATER"if A>B else"LESS"if A<B else"EQUAL")
Problem p02657 (python)

Fixed submission:
#入力される値A B
A, B = map(int, input().split())

#出力される値
print(A*B)

Buggy submission (verdict: Runtime Error):
import sys

#入力する値の個数N
N = input()

#入力される値 A
A = list(map(int, input().split()))

#print(N)
#print(A)
ans = 1
if 0 in A:
    print("-1")
    sys.exit()


for i in A:
    #print(i)
    ans *= i
    #print(ans)
    if ans > 10**18:
        print("-1")
        sys.exit()

print(ans)
Problem p02687 (python)

Fixed submission:
import sys
S = input()

if S == "ABC":
    print("ARC")
    sys.exit()
else:
    print("ABC")
    sys.exit()

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))

H = list(map(int, input().split()))

ans = [1]*N

for i in range(M):
    A, B = list(map(int, input().split()))
    if H[A-1] > H[B-1]:
        ans[B-1] = 0
    elif H[A-1] < H[B-1]:
        ans[A-1] = 0
    else:
        ans[A-1] = 0
        ans[B-1] = 0

print(sum(ans))
Problem p03493 (python)

Fixed submission:
a = input()

print(a.count("1"))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
s = [a, b, c]
#print(s)


counter = s.count(1)
print(counter)
Problem p02642 (python)

Fixed submission:
# 幅優先探索（行きがけ）
import collections
import sys
import math
import copy
import collections


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArry = LI()
    AArry.sort()
    count = 0
    li = [0 for _ in range(10**6+2)]

    for i, v in enumerate(AArry):
        a = v
        if li[a] == 1:
            count += 1
        if li[a] == 0:
            if i != N-1 and AArry[i+1] == a:
                count += 1

            for j in range(a, 10**6+2, a):
                li[j] = 1

    print(N-count)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# 幅優先探索（行きがけ）
import collections
import sys
import math
import copy
import collections


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    AArry = LI()
    AArry.sort()
    count = 0
    li = [0 for _ in range(10**6+2)]

    for i, v in enumerate(AArry):
        a = v
        if li[a] == 1:
            count += 1
        if li[a] == 0:
            if i != N-1 and AArry[i+1] == a:
                ans += 1

            for j in range(a, 10**6+2, a):
                li[j] = 1

    print(N-count)


if __name__ == '__main__':
    main()
Problem p02658 (python)

Fixed submission:

def main():
    N = int(input())
    A = [int(arg) for arg in input().split()]
    ans = 1

    for i in range(N):
        if A[i] == 0:
            print(0)
            return

    for i in range(N):
        ans *= A[i]
        if ans > 10**18:
            print(-1)
            return

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

import math


def main():
    N = int(input())
    A = [int(arg) for arg in input().split()]
    ans = 1
    for i in range(N+1):
        ans *= A[i]
        if ans > pow(10, 18) and i == N:
            ans = "-1"
            break

    print(ans)


if __name__ == '__main__':
    main()