Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
quary=[]
for i in range(q):
    temp=list(input().split())
    quary.append(temp)

for i in range(q):
    if quary[i][0]=='1':
        s=s[::-1]
    else:
        if quary[i][1]=='1':
            s=quary[i][2]+s
        else:
            s=s+quary[i][2]
print(s)

Fixed submission:
s=input()
q=int(input())
quary=[]
for i in range(q):
    temp=list(input().split())
    quary.append(temp)
switch=False
first=''
last=''
for i in range(q):
    if quary[i][0]=='1':
        if switch:
            switch=False
        else:
            switch=True

    else:
        if quary[i][1]=='1':
            if switch:
                last+=quary[i][2]
            else:
                first+=quary[i][2]
        else:
            if switch:
                first+=quary[i][2]
            else:
                last+=quary[i][2]
s=first[::-1]+s+last
if switch:
    print(s[::-1])
else:
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**9)
n,m,k=map(int,input().split())
friend=[[] for _ in range(n)]
block=[[False]*n for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    friend[a].append(b)
    friend[b].append(a)
for _ in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    block[c][d]=True
    block[d][c]=True

def dfs(graph,v,s):
    seen[v]=True
    if not block[s][v]:
        count[s]+=1
    for nv in graph[v]:
        if seen[nv]:
            continue
        dfs(graph,nv,s)
count=[0]*n
for v in range(n):
    seen=[False]*n
    temp=0
    if seen[v]:
        continue
    dfs(friend,v,v)
    count[v]-=1
    count[v]-=len(friend[v])

for i in range(n):
    print(count[i],end=' ')

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
n,m,k=map(int,input().split())
friend=[[] for _ in range(n)]
block=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    friend[a].append(b)
    friend[b].append(a)
for _ in range(k):
    c,d=map(int,input().split())
    c-=1
    d-=1
    block[c].append(d)
    block[d].append(c)
seen=[-1]*n
def dfs(graph,v,top):
    seen[v]=top
    top_count[top]+=1
    for nv in graph[v]:
        if seen[nv]!=-1:
            continue
        dfs(graph,nv,top)
top=0
top_count=[0]
for v in range(n):
    count=0
    if seen[v]!=-1:
        continue
    dfs(friend,v,top)
    top_count.append(0)
    top+=1


for i in range(n):
    ans=top_count[seen[i]]-len(friend[i])-1
    cnt=0
    for v in block[i]:
        if seen[v]==seen[i]:
            cnt+=1
    ans-=cnt
    print(ans,end=' ')
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
typedef long long int INT;

INT pow(int n,int k)
{
    INT a=1;
    for (int i=1;i<=k;i++){
        a*=n;
    }
    return a;
}

int main()
{
    INT n;
    int k;
    cin>>n>>k;
    int i=0;
    while(1){
        if(n<pow(k,i)){
            cout<<i<<endl;
            break;
        }
        ++i;
    }
}

Fixed submission:
n,k=map(int,input().split())
cnt=0
i=1
 
while True:
    p=n//k**i
    if p==0:
        print(i)
        break
    else:
        i+=1
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
cnt=[0]*60
for elem in a:
    for i in range(60):
        cnt[i]+=(elem>>i)%2
ans=0
for i in range(60):
    ans+=((cnt[i]*(n-cnt[i]))<<i)%mod
print(ans%mod)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
cnt=[0]*60
for elem in a:
    for i in range(60):
        cnt[i]+=(elem>>i)%2
ans=0
for i in range(60):
    ans+=((cnt[i]*(n-cnt[i]))<<i)%mod
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tar=str(i)+str(j)+str(k)
            now=0
            for l in range(n):
                
                if tar[0+now]==s[l]:now+=1
                if now==3:
                    ans+=1
                    break
print(ans)                    

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tar=str(i)+str(j)+str(k)
            now=0
            for l in range(n):
                
                if tar[0+now]==s[l]:now+=1
                if now==3:
                    ans+=1
                    break
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
mod=10**9+7

a=(2*x-y)//3
b=(2*y-x)//3



if a!=(2*x-y)/3 or b!=(2*y-x)/3:
    print(0)
else:
    max=a+b+10
    fac=[0]*max
    finv=[0]*max
    inv=[0]*max

    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i]=fac[i-1]*i%mod
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        finv[i]=finv[i-1]*inv[i]%mod

    ans=fac[a+b]*(finv[a]*finv[b]%mod)%mod
    print(ans)

Fixed submission:
x,y=map(int,input().split())
mod=10**9+7

a=(2*x-y)//3
b=(2*y-x)//3



if a!=(2*x-y)/3 or b!=(2*y-x)/3:
    print(0)
elif a<0 or b<0:
    print(0)
else:
    max=a+b+10
    fac=[0]*max
    finv=[0]*max
    inv=[0]*max

    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i]=fac[i-1]*i%mod
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        finv[i]=finv[i-1]*inv[i]%mod

    ans=fac[a+b]*(finv[a]*finv[b]%mod)%mod
    print(ans)

Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
mod=10**9+7

a=(2*x-y)//3
b=(2*y-x)//3



if a!=(2*x-y)/3 or b!=(2*y-x)/3:
    print(0)
else:
    max=a+b+1
    fac=[0]*max
    finv=[0]*max
    inv=[0]*max

    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i]=fac[i-1]*i%mod
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        finv[i]=finv[i-1]*inv[i]%mod

    ans=fac[a+b]*(finv[a]*finv[b]%mod)%mod
    print(ans)

Fixed submission:
x,y=map(int,input().split())
mod=10**9+7

a=(2*x-y)//3
b=(2*y-x)//3



if a!=(2*x-y)/3 or b!=(2*y-x)/3:
    print(0)
elif a<0 or b<0:
    print(0)
else:
    max=a+b+10
    fac=[0]*max
    finv=[0]*max
    inv=[0]*max

    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i]=fac[i-1]*i%mod
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        finv[i]=finv[i-1]*inv[i]%mod

    ans=fac[a+b]*(finv[a]*finv[b]%mod)%mod
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def bisect_left(a, x, lo=0, hi=None):
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x: lo = mid+1
        else: hi = mid
    return lo
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        tar=l[j]+l[i]
        temp=bisect_left(l,tar)
        ans+=temp-j-1
print(ans)
        

        

Fixed submission:
def bisect_left(a, x, lo=0, hi=None):
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x: lo = mid+1
        else: hi = mid
    return lo
n=int(input())
l=list(map(int,input().split()))
l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        tar=l[j]+l[i]
        temp=bisect_left(l,tar)
        ans+=temp-j-1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,q=map(int,input().split())
G=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

subtree_size=[0]*n
cnt=[0]*n

for _ in range(q):
    p,x=map(int,input().split())
    p-=1
    cnt[p]+=x
ans=[0]*n

def dfs(G,v,p):
    ans[v]+=cnt[v]
    for nv in G[v]:
        if nv==p:
            continue
        cnt[nv]+=cnt[v]
        dfs(G,nv,v)
    
    subtree_size[v]=1
    for c in G[v]:
        if c==p:
            continue
        subtree_size[v]+=subtree_size[c]

root=0
dfs(G,root,-1)

for i in range(n):
    print(ans[i],end=' ')





Fixed submission:
import sys
sys.setrecursionlimit(10**9)
n,q=map(int,input().split())
G=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

subtree_size=[0]*n
cnt=[0]*n

for _ in range(q):
    p,x=map(int,input().split())
    p-=1
    cnt[p]+=x
ans=[0]*n

def dfs(G,v,p):
    ans[v]+=cnt[v]
    for nv in G[v]:
        if nv==p:
            continue
        cnt[nv]+=cnt[v]
        dfs(G,nv,v)
    
    subtree_size[v]=1
    for c in G[v]:
        if c==p:
            continue
        subtree_size[v]+=subtree_size[c]

root=0
dfs(G,root,-1)

for i in range(n):
    print(ans[i],end=' ')
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=[0]

for i in range(1,n+1):
    temp=d[i-1]+l[i-1]
    if temp>x:
        ans=i
        break
    d.append(temp)

print(ans)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=[0]

for i in range(1,n+1):
    temp=d[i-1]+l[i-1]
    if temp>x:
        ans=i
        break
    d.append(temp)

else:
    ans=n+1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=list(map(int,input().split()))
INF=10**9+7
dp=[INF]*n
dp[0]=0

for i in range(1,n):
    s=min(k,i)
    for j in range(1,s+1):
        dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j])
print(dp[n-1])

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
INF=10**9+7
dp=[INF]*n
dp[0]=0

for i in range(1,n):
    s=min(k,i)
    for j in range(1,s+1):
        dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j])
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

if n>=2 and m>=2:
    print((n-2)*(m-2))

elif n==1 and m!=1:
    print(m-2)

elif m==1 and n!=1:
    print(n-2)
elif n==1 and m==1:
  print(1)

Fixed submission:
a=input()
b=input()
c=input()

print('{}{}{}'.format(a[0],b[1],c[2]))
Buggy python submission (verdict: Runtime Error):
n=int(input())

a=list(input.split())

if 'Y' in a:
    print('Four')

else:
    print('Three')

Fixed submission:
n=int(input())

a=input().split()

if 'Y' in a:
    print('Four')

else:
    print('Three')
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                count+=1
            else:
                pass
print(count)
                



Fixed submission:
X=int(input())
A=int(input())
B=int(input())

X=X-A

while True:
    X=X-B
    if X-B<0:
        break
    else:
        pass
print(X)

Buggy python submission (verdict: Runtime Error):
N,A,B=map(int, input().split())
a=[]

for i in range(N+1):
    j=i
    n=0
    while True:
        n+=i%10
        if i//10==0:
            break
        else:
            i=i//10
    if A<=n<=B:
        a.append(j)
    else:
        pass
print(sum(a))
        

Fixed submission:
X=int(input())
A=int(input())
B=int(input())

X=X-A

while True:
    X=X-B
    if X-B<0:
        break
    else:
        pass
print(X)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                count+=1
            else:
                pass

print(count)

Fixed submission:
X=int(input())
A=int(input())
B=int(input())

X=X-A

while True:
    X=X-B
    if X-B<0:
        break
    else:
        pass
print(X)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0

for i in range(A):
    for j in range(B):
        for k in range(C):
            if 500*i+100*j+50*k==X:
                count+=1
            else:
                pass

print(count)

Fixed submission:
X=int(input())
A=int(input())
B=int(input())

X=X-A

while True:
    X=X-B
    if X-B<0:
        break
    else:
        pass
print(X)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0

for i in range(A):
    for j in range(B):
        for k in range(C):
            if 500*i+100*j+50*k==X:
                count+=1
            else:
                pass

print(count)

Fixed submission:
X=int(input())
A=int(input())
B=int(input())

X=X-A

while True:
    X=X-B
    if X-B<0:
        break
    else:
        pass
print(X)
Buggy python submission (verdict: Runtime Error):
N=int(input())
t=[0]*100001
x=[0]*100001
y=[0]*100001

for i in range(1,N+1):
    t[i],x[i],y[i]=map(int, input().split())
count=0

for i in range(1,N+1):
    dt=(t[i])-(t[i-1])
    dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    if dist>dt:
        break
    else:
        pass
    if dist%2==dt%2:
        pass
    else:
        break
    count+=1
if count==N:
    print('YES')
else:
    print('NO')

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

if a*b%2==0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
N,Y=map(int, input().split())
count=0

for i in range(N+1):
    if count==0:
        pass
    else:
        break
    for j in range(N-i+1):
        if count==0:
            pass
        else:
            break
        for k in range(N-i-j+1):
            if 10000*i+5000*j+1000*k==Y:
                print(f'{i}{j}{k}')
                count+=1
            else:
                pass
if count==0:
    print('{}{}{}'.format(-1,-1,-1))
else:
    pass

Fixed submission:
N,Y=map(int, input().split())
count=0

for i in range(N+1):
    if count==0:
        pass
    else:
        break
    for j in range(N-i+1):
        if 10000*i+5000*j+1000*(N-i-j)==Y:
            print(i,j,N-i-j)
            count+=1
            break
        else:
            pass
if count==0:
    print(-1,-1,-1)
else:
    pass
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

ans = []

for i in range(n-k):
    if (a[i+k] == 0):
        ans.append("No")
        continue

    if (0 in a[i:i+k-1]):
        ans.append("Yes")
        continue

    if (a[i] < a[i+k]):
        ans.append("Yes")
    else:
        ans.append("No")

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


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

ans = []
for i in range(n-k):
    if (a[i] < a[i+k]):
        ans.append("Yes")
    else:
        ans.append("No")

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

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

shaku = []

for i in range(n-k+1):
    start = i
    end = start + k
    h = a[start] * a[start+1]
    now = start + 2
    while now < end:
        if (0 in a[now:end]):
            h = 0
            break

        h *= a[now]
        now += 1

    shaku.append(h)

for i in range(len(shaku)-1):
    if (shaku[i] < shaku[i+1]):
        print("Yes")
    else:
        print("No")


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

ans = []
for i in range(n-k):
    if (a[i] < a[i+k]):
        ans.append("Yes")
    else:
        ans.append("No")

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

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

shaku = []

for i in range(n-k+1):
    start = i
    end = start + k
    h = a[start] * a[start+1]
    now = start + 2
    while now < end:
        h *= a[now]
        now += 1

    shaku.append(h)

for i in range(len(shaku)-1):
    if (shaku[i] < shaku[i+1]):
        print("Yes")
    else:
        print("No")


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

ans = []
for i in range(n-k):
    if (a[i] < a[i+k]):
        ans.append("Yes")
    else:
        ans.append("No")

for i in range(len(ans)):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
import sys
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

if (n == 0):
    print(x)
    sys.exit()

a = [i for i in range(-110,210)]

for j in p:
    d = a.index(j)
    a.pop(d)

a.append(x)
a = set(a.sort())

idx_x = a.index(x)

if (idx_x == 0):
    print(a[idx_x+1])
    sys.exit()
if (idx_x == len(a)-1):
    print(a[-2])
    sys.exit()

lesser = a[idx_x-1]
greater = a[idx_x+1]

dl = abs(x - lesser)
dg = abs(greater - x)

if (dl <= dg):
    print(lesser)
else:
    print(greater)


Fixed submission:
import sys
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

if (n == 0):
    print(x)
    sys.exit()

i = 0
while True:
    if (not (x-i) in p):
        print(x-i)
        break
    if (not (x+i) in p):
        print(x+i)
        break
    i += 1
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
up = int("1"+"0"*18)

a = list(map(int, input().split()))
ans = a[0]

for i in range(1, len(a)):
    if (0 in a):
        ans = 0
        break
    
    ans = ans * a[i]

    if (ans > up):
        ans = -1
        break

print(ans)


Fixed submission:
n = int(input())
up = int("1"+"0"*18)

a = list(map(int, input().split()))
ans = a[0]

def calc(a):
    x = ans
    for i in range(1, len(a)):
        x = x * a[i]

        if (x > up):
            x = -1
            return x

    return x

if (0 in a):
    ans = 0
else:
    ans = calc(a)

print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))

height = [int(i) for i in input().split()]

tele = {}
for num, h in enumerate(height, 1):
    tele[num] = [h, "G"]

for roads in range(m):
    a, b = list(map(int, input().split()))
    if (tele[a][0] > tele[b][0]):
        tele[b][1] = "N"
    elif (tele[a][0] < tele[b][0]):
        tele[a][1] = "N"
    elif (tele[a][0] == tele[b][0]):
        tele[a][1] = "N"
        tele[b][1] = "N"

ans_list = tele.values()
ans = 0
for a in ans_list:
    if (a[1] == "G"):
        ans += 1

print(ans)



Fixed submission:
t = input()

if (t=="ABC"):
    print("ARC")
else:
    print("ABC")
Buggy python submission (verdict: Runtime Error):
q = input().split()
q = [int(i) for i in q]

t = [q[0], q[1]]
a = [q[2], q[3]]

while True:
    a[0] = a[0] - t[1]
    if (a[0] <= 0):
        print("Yes")
        break

    t[0] = t[0] - a[1]
    if (t[0] <= 0):
        print("No")
        break



Fixed submission:
q = input().split()
q = [int(i) for i in q]

s = q[0]
w = q[1]

if (s <= w):
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = input().split()
c = [int(n) for n in c]

for i in range(1, n+1):
    print(c.count(i))


Fixed submission:
import math
r = int(input())
r = 2*r*math.pi
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = input().split()
c = [int(n) for n in c]

for i in range(1, n+1):
    print(c.count(i))


Fixed submission:
n = int(input())
c = input().split()
c = [int(n) for n in c]

s = dict.fromkeys([int(n) for n in range(1,n+1)], 0)

for i in c:
    s[i] = s[i] + 1

for i in range(1, n+1):
    print(s[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = input().split()

for i in range(1, n+1):
    print(c.count(str(i)))


Fixed submission:
n = int(input())
c = input().split()
c = [int(n) for n in c]

s = dict.fromkeys([int(n) for n in range(1,n+1)], 0)

for i in c:
    s[i] = s[i] + 1

for i in range(1, n+1):
    print(s[i])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, k = list(map(int, input().split()))

if (k == 1):
    print(0)
    sys.exit()

preN = n
while True:
    tmp = abs(n - k)
    if (tmp < n):
        n = tmp
    else:
        break

print(n)


Fixed submission:
import sys
n, k = list(map(int, input().split()))

if (k == 1):
    print(0)
    sys.exit()

s, a = divmod(n, k)

t = k - a

if (a < t):
    print(a)
else:
    print(t)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = list(map(int, input().split()))

ans = 0
for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):
            if ((i+j+m) == s):
                ans += 1

print(ans)


Fixed submission:
k, s = list(map(int, input().split()))

ans = 0
for i in range(k+1):
    for j in range(k+1):
        m = s - i - j
        if (0 <= m <= k):
            ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(input())

count=0

for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i] and j-i != k-j:
                count+=1

print(count)

Fixed submission:
N=int(input())
S=input()

r=S.count('R')
g=S.count('G')
b=S.count('B')

ad=r*g*b
mi=0

for i in range(N):
    for j in range(i+1,N):
        k=j+(j-i)
        if k<N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                mi+=1

print(ad-mi)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
A = map(int, input().split())

ans = 1

for a in A:
    ans *= a

if (ans > 1000000000000000000):
    print('-1')
else:
    print(ans)


Fixed submission:
N = input()
A = list(map(int, input().split()))

ans = 1

has_zero = False
for a in A:
    if a == 0:
        has_zero = True

# print("here?")

for a in A:
    # print("here?2")
    # print(a)
    ans *= a
    if ans > 1000000000000000000:
        ans = -1
        break

if has_zero is True:
    print('0')
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(p, q):  # p > qのこと！
    if p % q == 0:
        # print('result: ' + str(q))
        return q
    else:
        return gcd(q, p % q)


K = int(input())

ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        gcd_ij = gcd(max(i, j), min(i, j))
        for k in range(1, K+1):
            gcd_ijk = gcd(max(gcd_ij, k), min(gcd_ij, k))
            # print(i, j, k, gcd_ij, gcd_ijk)
            ans += gcd_ijk

print(ans)

# print(max(2, 3))
# print(min(2, 3))
#
# print(gcd(max(2, 3), min(2, 3)))


Fixed submission:

from math import gcd

def gcd2(p, q):  # p > qのこと！
    if p % q == 0:
        # print('result: ' + str(q))
        return q
    else:
        return gcd(q, p % q)


K = int(input())

ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        # gcd_ij = gcd2(max(i, j), min(i, j))
        gcd_ij = gcd(i, j)
        for k in range(1, K+1):
            # gcd_ijk = gcd2(max(gcd_ij, k), min(gcd_ij, k))
            gcd_ijk = gcd(gcd_ij, k)
            # print(i, j, k, gcd_ij, gcd_ijk)
            ans += gcd_ijk

print(ans)

# print(max(2, 3))
# print(min(2, 3))
#
# print(gcd(max(2, 3), min(2, 3)))
Buggy python submission (verdict: Runtime Error):
N = int(input()
print(int(((N-1)*N)/2))


Fixed submission:
N = int(input())

print(round(((N-1)*N)//2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))
# print(N, H)

ret = 'Yes'

for i in range(N):
	for j in range(i, N):
		if H[i]-1 > H[j]:
			ret = 'No'
			break

	if ret == 'No':
		break

print(ret)


Fixed submission:
N = int(input())
H = list(map(int, input().split()))

ret = 'Yes'
bar = H[0] - 1

for i in range(1, N):
	if bar > H[i]:
		ret = ('No')
		break
	elif bar < H[i]:
		bar = H[i] - 1

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

total = 0
for i in range(n - 1):
  temp = []
  for j in range(i + 1, n):
    temp.append((a[i]*a[j]) % (10**9 + 7))
  total += sum(temp) % (10**9 + 7)

print(total % (10**9 + 7))

Fixed submission:
d, t, s = map(int, input().split())

if d / s > t:
  print('No')
else:
  print('Yes')