Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-05-03 21:27:46 +0900
# LastModified: 2020-05-03 21:47:49 +0900
#


import os
import sys


def main():
    n,m = map(int,input().split())
    h = list(map(int,input().split()))
#    color=[0]*n
    matrix = list([0]*n for _ in range(n))
    for i in range(m):
        a,b = map(int,input().split())
        matrix[a-1][b-1]=1
        matrix[b-1][a-1]=1
    
    count=0
    flag=0
    for i in range(n):
        for j in range(n):
            if matrix[i][j]==1 and h[i]<=h[j] :
                flag=1
                break
        if flag==0:
#            color[i]=1
            count+=1
        flag=0
    print(count)

if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-27 13:14:18 +0900
# LastModified: 2020-06-27 13:50:05 +0900
#


def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ma = [0]*n
    for _ in range(m):
        a, b = map(int, input().split())
        ma[a-1] = max(ma[a-1], h[b-1])
        ma[b-1] = max(ma[b-1], h[a-1])
#        print(ma)
    cnt = 0
    for i in range(n):
        if ma[i] < h[i]:
            cnt += 1
    print(cnt)




if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-05-03 22:36:44 +0900
# LastModified: 2020-05-03 22:56:22 +0900
#


import os
import sys


def main():
    x=int(input())
    tmp=1
    for i in range(2,x):
        if x%i==0:
            tmp=i
            break

    b=-1
    for i in range(x):
        if x==((tmp-1)*i)**5+1:
            a=(tmp-1)*i
            break
    print("{} {}".format(a,b))
    return 

if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix
# CreatedDate:  2020-08-08 01:53:55 +0900
# LastModified: 2020-08-08 01:56:11 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    x = int(input())
    for a in range(-120, 120):
        for b in range(-120, a):
            if a**5-b**5 == x:
                print("{} {}".format(a, b))
                return


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-05-03 22:36:44 +0900
# LastModified: 2020-05-03 22:38:33 +0900
#


import os
import sys


def main():
    x=int(input())
    b=-1
    for i in range(x):
        if x==i**5+1:
            a=i
            break
    print("{} {}".format(a,b))


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix
# CreatedDate:  2020-08-08 01:53:55 +0900
# LastModified: 2020-08-08 01:56:11 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    x = int(input())
    for a in range(-120, 120):
        for b in range(-120, a):
            if a**5-b**5 == x:
                print("{} {}".format(a, b))
                return


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-27 13:14:18 +0900
# LastModified: 2020-06-27 13:50:05 +0900
#


def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ma = [0]*n
    for _ in range(m):
        a, b = map(int, input().split())
        ma[a-1] = max(ma[a-1], h[b-1])
        ma[b-1] = max(ma[b-1], h[a-1])
#        print(ma)
    cnt = 0
    for i in range(n):
        if ma[i] < h[i]:
            cnt += 1
    print(cnt)




if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-27 13:59:01 +0900
# LastModified: 2020-06-27 14:04:38 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    s = list(set(s))
    print(len(s))
        


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-04-26 22:14:32 +0900
# LastModified: 2020-04-26 22:16:54 +0900
#


import os
import sys


def main():
    n=int(input())
    s = []
    count=0
    for i in range(n):
        chara = input()
        if not chara in s:
            s.append(chara)
            count+=1
    
    print(count)

if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-27 13:59:01 +0900
# LastModified: 2020-06-27 14:04:38 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    s = list(set(s))
    print(len(s))
        


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-04-19 21:11:23 +0900
# LastModified: 2020-04-19 21:14:03 +0900
#


import os
import sys
import numpy as np
import pandas as pd


def main():
    n,m=map(int,input().split())
    a = list(map(int,input().split()))
    if n-sum(a)<0:
        print(-1)
        return 

    print(n-sum(a))
    


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-04-19 21:11:23 +0900
# LastModified: 2020-04-19 21:15:31 +0900
#


import os
import sys

def main():
    n,m=map(int,input().split())
    a = list(map(int,input().split()))
    if n-sum(a)<0:
        print(-1)
        return 

    print(n-sum(a))
    


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix_2
# CreatedDate:  2020-08-09 01:27:04 +0900
# LastModified: 2020-08-09 01:48:19 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    s = input()
    q = int(input())
    for _ in range(q):
        query = list(map(str, input().split()))
        if len(query) == 1:
            s = s[::-1]
        else:
            if query[1] == '1':
                s = query[2] + s
            else:
                s = s + query[2]
    print(s)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix_3
# CreatedDate:  2020-08-30 13:22:07 +0900
# LastModified: 2020-08-30 13:41:03 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    S = input()
    Q = int(input())
    appendix_1 = ''
    appendix_2 = ''
    reverse = 0
    for _ in range(Q):
        q = list(input().split())
        if q[0] == '1':
            reverse += 1
        else:
            if q[1] == '1' and reverse % 2 == 0:
                appendix_1 += q[2]
            elif q[1] == '1' and reverse % 2 == 1:
                appendix_2 += q[2]
            if q[1] == '2' and reverse % 2 == 0:
                appendix_2 += q[2]
            elif q[1] == '2' and reverse % 2 == 1:
                appendix_1 += q[2]

    if reverse % 2 == 0:
        print(appendix_1[::-1] + S + appendix_2)
    else:
        print(appendix_2[::-1] + S[::-1] + appendix_1)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(input().split())
    for i,a_1 in enumerate(A):
        if a_1 in A[i+1:]:
            print("NO")
            return
    print("YES")
    

if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    A = sorted(input().split())
    for i in range(N-1):
        if A[i]==A[i+1]:
            print("NO")
            return
    print("YES")
    

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(input().split())
    for i,a_1 in enumerate(A):
        for a_2 in A[i+1:]:
#            print(a_1,a_2)
            if a_1==a_2:
                print("NO")
                return
    print("YES")
    

if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    A = sorted(input().split())
    for i in range(N-1):
        if A[i]==A[i+1]:
            print("NO")
            return
    print("YES")
    

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    p = list(map(int,input().split()))
    count = 1
    for i in range(1,N):
        minmin = min(p[0:i])
        if minmin>p[i]:
            count+=1
    print(count)

if __name__== '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-06-29 12:19:58 +0900
# LastModified: 2020-06-29 12:34:39 +0900
#


import os
import sys
import numpy as np
# import pandas as pd


def main():
    n = int(input())
    p = list(map(int, input().split()))
    cnt = 1
    p_min = p[0]
    for i in range(1, n):
        if p_min > p[i]:
            cnt += 1
            p_min = p[i]

    print(cnt)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    X = input()
    A = [100,101,102,103,104,105]
    last = int(X[:len(X)-2])
    two = int(X[-2:])
    if two <= last*5:
        print(1)
    else:
        print(0)

if __name__=='__main__':
    main()


Fixed submission:
def main():
    X = input()
    if(len(X)<3):
        print(0)
        return
    last = int(X[:len(X)-2])
    two = int(X[-2:])
    if two <= last*5:
        print(1)
    else:
        print(0)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split()
O = []
for i in range(1,N+1):
    O.append(A.index(str(i))+1)

for i in range(N):
    print("{} ".format(O[i]),end="")
print("\n")


Fixed submission:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    d = {}
    for i,a in enumerate(A):
        d[a]=i
    for i in range(1,N+1):
        print(d[i]+1,end=" ")
    print()

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,M=map( int, input().split())
    A=list( map( int, input().split()))
    for i in range(M):
        A[A.index(max(A))] = A[A.index(max(A))]//2
    print(sum(A))

if __name__ == '__main__':
    main()

Fixed submission:
import heapq
def main():
    N,M=map( int, input().split())
    A=list( map( int, input().split()))
    A = list(map(lambda x: x*(-1), A))
    heapq.heapify(A)
    for _ in range(M):
        u = heapq.heappop(A)
        heapq.heappush(A,int(u/2))
    print(-sum(A))


    

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N,M=map( int, input().split())
    A=list( map( int, input().split()))
    for i in range(M):
        A[A.index(max(A))] = int(A[A.index(max(A))]/2)
    print(sum(A))

if __name__ == '__main__':
    main()

Fixed submission:
import heapq
def main():
    N,M=map( int, input().split())
    A=list( map( int, input().split()))
    A = list(map(lambda x: x*(-1), A))
    heapq.heapify(A)
    for _ in range(M):
        u = heapq.heappop(A)
        heapq.heappush(A,int(u/2))
    print(-sum(A))


    

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map( int, input().split())
A=list( map( int, input().split()))
for i in range(M):
    A[A.index(max(A))] = int(A[A.index(max(A))]/2)
print(sum(A))

Fixed submission:
import heapq
def main():
    N,M=map( int, input().split())
    A=list( map( int, input().split()))
    A = list(map(lambda x: x*(-1), A))
    heapq.heapify(A)
    for _ in range(M):
        u = heapq.heappop(A)
        heapq.heappush(A,int(u/2))
    print(-sum(A))


    

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map( int, input().split())
A=list( map( int, input().split()))
A.sort(reverse=True)
for i in range(M):
    A[A.index(max(A))] = int(A[A.index(max(A))]/2)
print(sum(A))

Fixed submission:
import heapq
def main():
    N,M=map( int, input().split())
    A=list( map( int, input().split()))
    A = list(map(lambda x: x*(-1), A))
    heapq.heapify(A)
    for _ in range(M):
        u = heapq.heappop(A)
        heapq.heappush(A,int(u/2))
    print(-sum(A))


    

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-08-18 14:20:26 +0900
# LastModified: 2020-08-18 14:29:03 +0900
#


import os
import sys
from collections import Counter


def main():
    n = int(input())
    ans_box = dict()
    for i in range(n):
        s = list(map(str, input()))
        s_cnt = Counter(s)
        ans_box[i] = s_cnt
    cnt = 0
    for i in range(n):
        for j in range(i+1, n):
            if ans_box[i] == ans_box[j]:
                cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-08-18 14:31:47 +0900
# LastModified: 2020-08-18 14:42:13 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    ans_box = dict()
    for _ in range(n):
        s = sorted(map(str, input()))
        if ''.join(s) in ans_box.keys():
            ans_box[''.join(s)] += 1
        else:
            ans_box[''.join(s)] = 1
    ans = 0
    for key, value in ans_box.items():
        if value == 1:
            pass
        else:
            ans += value*(value-1)//2
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-26 13:24:14 +0900
# LastModified: 2020-07-30 16:22:23 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import sqrt


def prime_factors(p, prime_box):
    while p % 2 == 0:
        prime_box[2] += 1
        p //= 2

    for i in range(3, len(prime_box), 2):
        while p % i == 0:
            prime_box[i] += 1
            p //= i


def main():
    n, p = map(int, input().split())
    if n == 1:
        print(p)
        return
    prime_box = [0] * (p+1)
    prime_factors(p, prime_box)
    prime_box = list(map(lambda x: x//n, prime_box))
    if sum(i*prime_box[i] for i in range(len(prime_box))) == 0:
        print(1)
    else:
        print(sum(i*prime_box[i] for i in range(len(prime_box))))


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-26 13:24:14 +0900
# LastModified: 2020-07-30 16:53:52 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import sqrt
from collections import Counter


def prime_factors(p, prime_box):
    while p % 2 == 0:
        prime_box.append(2)
        p //= 2

    for i in range(3, int(sqrt(p))+1, 2):
        while p % i == 0:
            prime_box.append(i)
            p //= i
    if p > 2:
        prime_box.append(p)


def main():
    n, p = map(int, input().split())
    if n == 1:
        print(p)
        return
    prime_box = []
    prime_factors(p, prime_box)
    prime_box = list(map(list, Counter(prime_box).items()))
    prime_box = [[s, t//n] for s, t in prime_box]
    ans = 1
    for s, t in prime_box:
        ans *= s**t
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-27 01:01:29 +0900
# LastModified: 2020-09-27 01:12:14 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import Counter


def main():
    N = int(input())
    S = input()
    S = [s for s in S]
    ans = 0
    for i in range(N):
        if i == 0:
            obj = S[1:]
            ans = obj.count('E')
            continue
        elif i == N-1:
            obj = S[:i]
            cnt = obj.count('W')
        else:
            obj_1 = S[:i]
            obj_2 = S[i+1:]
            cnt = obj_1.count('W') + obj_2.count('E')
        if ans > cnt:
            ans = cnt
    print(ans)

    


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-09-27 01:13:48 +0900
# LastModified: 2020-09-27 01:29:07 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    S = input()
    RW_cnt = S.count("W")
    RE_cnt = S.count("E")
    LW_cnt = 0
    LE_cnt = 0
    if S[0] == "W":
        RW_cnt -= 1
        LW_cnt = 1
    else:
        RE_cnt -= 1
        LE_cnt = 1
    ans = RE_cnt
#    print("RW_cnt, RE_cnt, LW_cnt, LE_cnt")
    for i in range(1, N):
        if i == N-1:
            cnt = LW_cnt
        else:
            cnt = LW_cnt + RE_cnt
        if cnt < ans:
            ans = cnt
        if S[i] == "E":
            LE_cnt += 1
            RE_cnt -= 1
        else:
            LW_cnt += 1
            RW_cnt -= 1
#        print(RW_cnt, RE_cnt, LW_cnt, LE_cnt)
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-26 15:12:37 +0900
# LastModified: 2020-06-26 15:31:15 +0900
#


import os
import sys
from collections import Counter
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    cnt_list = Counter(a)

    a_max = a[-1]
    a_min = a[0]
    cnt_max = 0
    for center in range(a_min-1, a_max+2):
        if center in cnt_list.keys():
            cnt = cnt_list[center]
        if center-1 in cnt_list.keys():
            cnt += cnt_list[center-1]
        if center+1 in cnt_list.keys():
            cnt += cnt_list[center+1]
        if cnt > cnt_max:
            cnt_max = cnt
    print(cnt_max)



if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-26 15:12:37 +0900
# LastModified: 2020-06-26 15:33:28 +0900
#


import os
import sys
from collections import Counter
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    cnt_list = Counter(a)

    a_max = a[-1]
    a_min = a[0]
    cnt_max = 0
    for center in range(a_min-1, a_max+2):
        cnt = 0
        if center in cnt_list.keys():
            cnt += cnt_list[center]
        if center-1 in cnt_list.keys():
            cnt += cnt_list[center-1]
        if center+1 in cnt_list.keys():
            cnt += cnt_list[center+1]
        if cnt > cnt_max:
            cnt_max = cnt
    print(cnt_max)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
def main():
    N = int(input())
    count = 0
    for i in range(1,int(math.sqrt(N))):
        if N%i==0:
            iremono = i

    print(len(str(N//iremono)))
    

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-26 16:16:00 +0900
# LastModified: 2020-06-26 19:11:55 +0900
#


import os
import sys
from math import sqrt
# import numpy as np
# import pandas as pd


def F(a, b):
    if len(str(a)) > len(str(b)):
        print(len(str(a)))
    else:
        print(len(str(b)))


def main():
    n = int(input())
    for i in range(int(sqrt(n)+1), -1, -1):
        if n % i == 0:
            a = i
            b = n//i
#            print(a,b)
            F(a, b)
            break


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sys import stdin
input = stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    for a in A:
        ans *= a
        if a == 0:
            ans = 0
            break
        
    if ans > 10**18:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Fixed submission:

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    for a in A:
        if a == 0:
            ans = 0
            break
        elif ans < 10**18:
            ans *= a
        
    if ans > 10**18:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    for a in A:
        ans *= a
        if a == 0:
            ans = 0
            break
        
    if ans > 10**18:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Fixed submission:

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    for a in A:
        if a == 0:
            ans = 0
            break
        elif ans < 10**18:
            ans *= a
        
    if ans > 10**18:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    for a in A:
        ans *= a
        if a == 0:
            ans = 0
            break
        
    if ans > 10**18:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

Fixed submission:

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    for a in A:
        if a == 0:
            ans = 0
            break
        elif ans < 10**18:
            ans *= a
        
    if ans > 10**18:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()

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


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    for a in A:
        if a == 0:
            ans = 0
            break:
        ans *= a
        if ans > 10**18:
            ans = -1
            break
    
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1

    for a in A:
        if a == 0:
            ans = 0
            break
        elif ans < 10**18:
            ans *= a
        
    if ans > 10**18:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()