Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
    n,a, b = map(int, input().split())
    ans = n //(a+b) *a
    ans += min(n%(a+b),a)
    print(ans)


Fixed submission:
S = input()

if S == "AAA" or S == "BBB":
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
n,a, b = map(int, input().split())
l = []
for i in range(10 ^100):
    l.extend([1]*a)
    l.extend([0]*b)

print(sum(l[:n]))

Fixed submission:
S = input()

if S == "AAA" or S == "BBB":
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
    n,a, b = map(int, input().split())
    ans = n //(a+b) *a
    tmp = n%(a+b)
    ans += min(tmp,a)
    print(ans)

Fixed submission:
n,a, b = map(int, input().split())
ans = n //(a+b) *a
tmp = n%(a+b)
ans += min(tmp,a)
print(ans)

Buggy python submission (verdict: Runtime Error):
 n,a, b = map(int, input().split())
    ans = n //(a+b) *a
    ans += min(n%(a+b),a)
    print(ans)

Fixed submission:
n,a, b = map(int, input().split())
ans = n //(a+b) *a
tmp = n%(a+b)
ans += min(tmp,a)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,a, b = map(int, input().split())
l = []
for i in range(10 ^100):
    l.extend([1]*a)
    l.extend([0]*b)

print(sum(l[:n]))

Fixed submission:
n,a, b = map(int, input().split())
ans = n //(a+b) *a
tmp = n%(a+b)
ans += min(tmp,a)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,a, b = map(int, input().split())
l = []
for i in range(10 ^100):
    l.extend([1]*a)
    l.extend([0]*b)

print(sum(l[:n]))

Fixed submission:
n,a, b = map(int, input().split())
ans = n //(a+b) *a
tmp = n%(a+b)
ans += min(tmp,a)
print(ans)

Buggy python submission (verdict: Runtime Error):
    n,a, b = map(int, input().split())
    l = []
    for i in range(10 ^100):
        l.extend([1]*a)
        l.extend([0]*b)
    
    print(sum(l[:n]))

Fixed submission:
n,a, b = map(int, input().split())
ans = n //(a+b) *a
tmp = n%(a+b)
ans += min(tmp,a)
print(ans)

Buggy python submission (verdict: Runtime Error):
    n,a, b = map(int, input().split())
    l = []
    for i in range(10 ^100):
        l.extend([1]*a)
        l.extend([0]*b)
    
    print(sum(l[:n]))

Fixed submission:
n,a, b = map(int, input().split())
ans = n //(a+b) *a
tmp = n%(a+b)
ans += min(tmp,a)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())

def res():
    ct=0
    for i in range(n):
        if i+2 > n:
            return ct
        if s[i] =="A"and s[i+1]=="B" and s[i+2]=="C":
            ct+=1

print(res())

Fixed submission:
n=int(input())
s=list(input())

def res():
    ct=0
    for i in range(n):
        if i+2 > n-1:
            return ct
        if s[i] =="A"and s[i+1]=="B" and s[i+2]=="C":
            ct+=1

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

m=0
# 0で初期化すると最初が1の時にだめ
at0
for i,ai in enumerate(a):
    m+=b[ai-1]
    if ai == at+1:
        m+=c[at-1]
    at=ai
print(m)

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

m=0
at=-1
for i,ai in enumerate(a):
    m+=b[ai-1]
    if ai == at+1:
        m+=c[at-1]
    at=ai
print(m)
Buggy python submission (verdict: Runtime Error):
N,D = map(int,input().split())
i = 0
k = 0
while N != i :
    x,y = map(int,input().split()) 
    d = (x**2+y**2) / D**2
    if d <= 1 :
        k += 1
    i +=1
print(k)

Fixed submission:
N,D = map(int,input().split())
i = 0
k = 0
while N != i :
    x,y = map(int,input().split()) 
    if (x**2+y**2) <= D**2 :
        k += 1
    i +=1
print(k)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
PI = 1
for i in range(N):
    PI = PI*A[i]
if PI > 10**(18):
    print(-1)
print(PI)

Fixed submission:
N,K = map(int,input().split())
print(N*K)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
PI = 1
for i in range(N):
    PI = PI*A[i]
if PI > 10**(18):
    print(-1)
print(PI)

Fixed submission:
N,K = map(int,input().split())
print(N*K)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
PI = 1
if 0 in A:
    PI = 0
else:
    for i in range(N):
        PI = PI*A[i]
        elif PI > 10**(18):
            PI = -1
            break
print(PI)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
PI = 1
if 0 in A:
    PI = 0
else:
    for i in range(N):
        PI = PI*A[i]
        if PI > 10**(18):
            PI = -1
            break
print(PI)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
PI = 1
for i in range(N):
    PI = PI*A[i]
if PI > 10**(18):
    print(-1)
else:
    print(PI)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
PI = 1
if 0 in A:
    PI = 0
else:
    for i in range(N):
        PI = PI*A[i]
        if PI > 10**(18):
            PI = -1
            break
print(PI)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
PI = 1
for i in range(N):
    PI = PI*A[i]
if PI > 10**(18):
    print(-1)
else:
    print(PI)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
PI = 1
if 0 in A:
    PI = 0
else:
    for i in range(N):
        PI = PI*A[i]
        if PI > 10**(18):
            PI = -1
            break
print(PI)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
PI = 1
for i in range(N):
    PI = PI*A[i]
if PI > 10**(18):
    print(-1)
    else:
      print(PI)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
PI = 1
if 0 in A:
    PI = 0
else:
    for i in range(N):
        PI = PI*A[i]
        if PI > 10**(18):
            PI = -1
            break
print(PI)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
PI = 1
for i in range(N):
    PI = PI*A[i]
if PI > 10**(18):
    print(-1)
    break
print(PI)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
PI = 1
if 0 in A:
    PI = 0
else:
    for i in range(N):
        PI = PI*A[i]
        if PI > 10**(18):
            PI = -1
            break
print(PI)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
        cnt=0
        while temp%i==0:
            cnt+=1
            temp //= i
        arr.append(cnt)

if temp!=1:
    arr.append(1)
if arr==[]:
    arr.append(1)
for i in range(len(arr)):
    if arr[i] == 1:
        arr[i] = 1
    else:
        s = (-1+math.sqrt(1+8*arr[i]))/2
        arr[i] = s
if n = 1:
    print(0)
else:
    print(int(sum(arr)))

Fixed submission:
import math
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)

    return arr
A = factorization(N)
if N == 1:
    print(0)
else:
    for i in range(len(A)):
        if A[i] == 1:
            A[i] = 1
        else:
            s = (-1+int(math.sqrt(1+8*A[i])))/2
            A[i] = int(s)
    print(int(sum(A)))
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
mod = 10**9+7
sum_min = 0
sum_max = 0
diff = 0
while K != N+2:
    for i in range(K):
        sum_min += i
    for k in range(N+1-K,N+1):
        sum_max += k
    diff += (sum_max-sum_min+1)
    sum_max = 0
    sum_min = 0
    K+= 1
diff = diff % mod
print(diff)

Fixed submission:
N,K = map(int,input().split())
mod = 10**9+7
sum_min = 0
sum_max = 0
diff = 0
while K != N+2:
    sum_min = 1/2*K*(K-1)
    sum_max = 1/2*K*(2*N-K+1)
    diff += sum_max - sum_min+1
    K+= 1
diff = diff % mod
print(int(diff))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())
S = list(S)
R = S.count("R")
G = S.count("G")
B = S.count("B")
count = R*G*B
double = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k < N:
            s = set([S[i],S[j],S[k]])
            if len(s) == 3:
                count -= 1
print(count)

Fixed submission:
N = int(input())
S = str(input())
S = list(S)
R = S.count("R")
G = S.count("G")
B = S.count("B")
count = R*G*B
double = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k < N:
            s = set([S[i],S[j],S[k]])
            if len(s) == 3:
                count -= 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]*(n+1)
l[0]=1
l[1]=a[0]
for i in range(2,n+1):
  l[i]=l[i-1]*a[i-1]
#print(l)
grade=[0]*(n-k+1)
for i in range(n-k+1):
  grade[i]=l[i+k]//l[i]
#print(grade)
for i in range(n-k):
  if grade[i]<grade[i+1]:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]*(n-k)
for i in range(n-k):
    l[i]=a[i+k]/a[i]
for i in range(n-k):
    if l[i]>1:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
k=int(input())
s=input()
if len(s)<=k:
  print(k)
else:
  print(s[:k]&"...")

Fixed submission:
k=int(input())
s=input()
if len(s)<=k:
  print(s)
else:
  print(s[:k]+"...")

Buggy python submission (verdict: Runtime Error):
k=int(input())
s=input()
if len(s)<=k:
  print(k)
else:
  print(k[:k]&"...")

Fixed submission:
k=int(input())
s=input()
if len(s)<=k:
  print(s)
else:
  print(s[:k]+"...")
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b)
  l[b-1].append(a)
ans=0
for i in l:
  p=True
  for j in i:
    if h[l.index(i)]<=h[j-1]:
      p=False
      break
    else:
      l[j-1]=[0]
  if p and i!=[0]:
    ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]<h[b-1] and l[a-1]==0:
    l[a-1]=-1
  elif h[a-1]>h[b-1] and l[b-1]==0:
    l[b-1]=-1
  elif h[a-1]==h[b-1]:
    l[a-1]=-1
    l[b-1]=-1
print(l.count(0))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  l[a-1].append(b)
  l[b-1].append(a)
ans=0
for i in l:
  p=True
  for j in i:
    if h[l.index(i)]<=h[j-1]:
      p=False
      break
  if p:
    ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
l=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]<h[b-1] and l[a-1]==0:
    l[a-1]=-1
  elif h[a-1]>h[b-1] and l[b-1]==0:
    l[b-1]=-1
  elif h[a-1]==h[b-1]:
    l[a-1]=-1
    l[b-1]=-1
print(l.count(0))
Buggy python submission (verdict: Runtime Error):
x=int(input())
t=True
for i in range(1,36):
  a5=i**5
  for j in range(36):
    if x==a5-j**5:
      a=i
      b=j
      t=False
      break
    elif x==a5+j**5:
      a=i
      b=-j
      t=False
      break
  if not t:
    break
print(a,b)

Fixed submission:
X=int(input())
for i in range(-200,201):
    for j in range(-200,201):
        if i**5-j**5==X:
            print(i,j)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations_with_replacement
from math import factorial
n,m,q=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(q)]
total=[]
for a in combinations_with_replacement(range(1,m+1),n):
  ans=0
  for j in range(q):
    if int(a[lst[j][1]-1])-int(a[lst[j][0]-1])==lst[j][2]:
      ans+=lst[j][3]
  total.append(ans)

print(max(total))


Fixed submission:
from itertools import combinations_with_replacement
from math import factorial
n,m,q=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(q)]
total=[]
for a in combinations_with_replacement(range(1,m+1),n):
  ans=0
  for j in range(q):
    if int(a[lst[j][1]-1])-int(a[lst[j][0]-1])==lst[j][2]:
      ans+=lst[j][3]
  total.append(ans)

print(max(total))
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
l=[0]*2019
l[0]=1
k=0
mod=2019
r=1
for i in range(n-1,-1,-1):
  k+=int(s[i])*r
  r*=10
  r%=mod
  l[k]+=1
ans=0
for i in l:
  ans+=i*(i-1)//2
print(ans)


Fixed submission:
s=input()
n=len(s)
l=[0]*2019
l[0]=1
k=0
mod=2019
r=1
for i in range(n-1,-1,-1):
  k+=int(s[i])*r
  k%=mod
  r*=10
  r%=mod
  l[k]+=1
ans=0
for i in l:
  ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
l=[0]*2019
l[0]=1
k=0
mod=2019
r=1
for i in range(n-1,-1,-1):
  k+=s[i]*r
  r*=10
  r%=mod
  l[k]+=1
ans=0
for i in l:
  ans+=i*(i-1)//2
print(ans)

Fixed submission:
s=input()
n=len(s)
l=[0]*2019
l[0]=1
k=0
mod=2019
r=1
for i in range(n-1,-1,-1):
  k+=int(s[i])*r
  k%=mod
  r*=10
  r%=mod
  l[k]+=1
ans=0
for i in l:
  ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
l=[0]*2019
l[0]=1
k=0
mod=2019
for i in range(n-1,-1,-1):
  k=(k+int(s[i])*(10**(n-1-i)%mod))%mod
  l[k]+=1
ans=0
for i in l:
  ans+=i*(i-1)//2
print(ans)

Fixed submission:
s=input()
n=len(s)
l=[0]*2019
l[0]=1
k=0
mod=2019
r=1
for i in range(n-1,-1,-1):
  k+=int(s[i])*r
  k%=mod
  r*=10
  r%=mod
  l[k]+=1
ans=0
for i in l:
  ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
l=[0]*2019
l[0]=1
k=0
mod=2019
for i in range(n-1,-1,-1):
  k=(k+int(s[i])*10**(n-1-i))%mod
  l[k]+=1
ans=0
for i in l:
  ans+=i*(i-1)//2
print(ans)

Fixed submission:
s=input()
n=len(s)
l=[0]*2019
l[0]=1
k=0
mod=2019
r=1
for i in range(n-1,-1,-1):
  k+=int(s[i])*r
  k%=mod
  r*=10
  r%=mod
  l[k]+=1
ans=0
for i in l:
  ans+=i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=len(s)
MOD=2019
l=[1]*n
for i in range(n-1,-1,-1):
  l[i]=int(s[i:n])%MOD
from collections import Counter
c=Counter(l)
ans=0
for i in c:
  ans+=c[i]*(c[i]-1)//2
  if i==0:
    ans+=c[i]
print(ans)


Fixed submission:
s=input()
n=len(s)
l=[0]*2019
l[0]=1
k=0
mod=2019
r=1
for i in range(n-1,-1,-1):
  k+=int(s[i])*r
  k%=mod
  r*=10
  r%=mod
  l[k]+=1
ans=0
for i in l:
  ans+=i*(i-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
lst=list(s)
r=[i for i,j in enumerate(lst) if j=="R"]
g=[i for i,j in enumerate(lst) if j=="G"]
b=[i for i,j in enumerate(lst) if j=="B"]
comb=len(r)*len(g)*len(b)
out=0
for i in r:
  for j in g:
    for k in b:
      if (i+j)==2*k or (j+k)==2*i or (k+i)==2*j:
        out+=1
print(comb-out)


Fixed submission:
from collections import deque
d=deque(input())
if "7" in d:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
k=int(input())
a=[0]*k
b=[0]*(k*k)
c=[0]*(k*k*k)
for i in range(k):
  a[i]=i+1
for i in range(k):
  for j in range(k):
    b[k*i+j]=gcd(a[i],j+1)
for i in range(k):
  for j in range(k):
    for l in range(k):
      c[k*k*i+k*j+l]=gcd(b[k*i+j],l+1)
print(sum(c))


Fixed submission:
from math import gcd
k=int(input())
a=[0]*k
b=[0]*(k*k)
c=[0]*(k*k*k)
for i in range(k):
  a[i]=i+1
for i in range(k):
  for j in range(k):
    b[k*i+j]=gcd(a[i],j+1)
for i in range(k):
  for j in range(k):
    for l in range(k):
      c[k*k*i+k*j+l]=gcd(b[k*i+j],l+1)
print(sum(c))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
lst=list(s)
r=[]
g=[]
b=[]
for i,v in enumerate(lst):
    if v=="R":
        r.append(i)
    elif v=="G":
        g.append(i)
    elif v=="B":
        b.append(i)
comb=len(r)*len(g)*len(b)
out=0
for i in r:
  for j in g:
    for k in b:
      if (i+j)==2*k or (j+k)==2*i or (k+i)==2*j:
        out+=1
print(comb-out)


Fixed submission:
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
for i in range(n-2):
  for j in range(i+1,n):
    k=2*j-i
    if k>(n-1):
      break
    if s[i]!=s[j]!=s[k]!=s[i]:
      ans-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
lst=list(s)
r=[i for i,j in enumerate(lst) if j=="R"]
g=[i for i,j in enumerate(lst) if j=="G"]
b=[i for i,j in enumerate(lst) if j=="B"]
comb=len(r)*len(g)*len(b)
out=0
for i in r:
  for j in g:
    for k in b:
      if (i+j)==2*k or (j+k)==2*i or (k+i)==2*j:
        out+=1
print(comb-out)


Fixed submission:
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
for i in range(n-2):
  for j in range(i+1,n):
    k=2*j-i
    if k>(n-1):
      break
    if s[i]!=s[j]!=s[k]!=s[i]:
      ans-=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
lst=list(s)
r=[i for i,j in enumerate(lst) if j=="R"]
g=[i for i,j in enumerate(lst) if j=="G"]
b=[i for i,j in enumerate(lst) if j=="B"]
comb=len(r)*len(g)*len(b)
out=0
for i in r:
  for j in g:
    for k in b:
      if (i+j)==2*k or (j+k)==2*i or (k+i)==2*j:
        out+=1
print(comb-out)


Fixed submission:
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
for i in range(n-2):
  for j in range(i+1,n):
    k=2*j-i
    if k>(n-1):
      break
    if s[i]!=s[j]!=s[k]!=s[i]:
      ans-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import factorial as f
n,m=map(int,input().split())
print(f(n)//(f(2)*f(n-2))+f(m)//(f(2)*f(m-2)))

Fixed submission:
from math import factorial as f
n,m=map(int,input().split())
comb_n=f(n)//(f(2)*f(n-2)) if n>1 else 0
comb_m=f(m)//(f(2)*f(m-2)) if m>1 else 0
print(comb_n+comb_m)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n=int(input())
a=deque(list(map(int,input().split())))
lst=[0]*n
for i in a:
  lst[i-1]+=1
lst_=list(map(lambda x:x*(x-1)//2,lst))
for i in range(n):
  ans=sum(lst_)
  p=a.popleft()
  if lst_[p-1]==0:
    print(ans)
  else:
    print(ans-(lst_[p-1]-(lst[p-1]-1)*(lst[p-1]-2)//2))
  a.append(p)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
lst1=[0]*(n+1)
lst2=[0]*(n+1)
for i in a:
  lst1[i]+=1
for i in range(n+1):
  if lst1[i]>0:
    lst2[i]=lst1[i]-1
lst3=list(map(lambda x:x*(x-1)//2,lst1))
lst4=list(map(lambda x:x*(x-1)//2,lst2))
ans=sum(lst3)
for i in a:
  print(ans-(lst3[i]-lst4[i]))
Buggy python submission (verdict: Runtime Error):
print(int(input()+1//2)

Fixed submission:
print((int(input())+1)//2)
Buggy python submission (verdict: Runtime Error):
n,r=int(input())
if n>9:
  print(r)
else:
  print(r+100*(10-n))

Fixed submission:
n,r=map(int,input().split())
if n>9:
  print(r)
else:
  print(r+100*(10-n))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input())
ans=0
while n>0:
  ans+=1
  n=n//k
print(ans)

Fixed submission:
n,k=map(int,input().split())
ans=0
while n>0:
  ans+=1
  n=n//k
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

import sys
from functools import reduce

input = sys.stdin.readline

N = int(input())
A = input().rstrip().split()

def main():
    result = 1

    for a in A:
        result *= int(a)

    return result

ans = main()
if ans > pow(10, 18):
    print(-1)
else:
    print(ans)

Fixed submission:

import sys
from functools import reduce

input = sys.stdin.readline

N = int(input())
A = input().rstrip().split()

def main():
    result = 1
    if '0' in A:
        return 0

    for a in A:
        a = int(a)
        result *= a

        if result > pow(10, 18):
            return -1

    return result

ans = main()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import sys
input = sys.stdin.readline

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

ans = reduce(lambda a,b: a*b, AS)
if ans > pow(10, 18):
    print(-1)
else:
    print(ans)


Fixed submission:

import sys
from functools import reduce

input = sys.stdin.readline

N = int(input())
A = input().rstrip().split()

def main():
    result = 1
    if '0' in A:
        return 0

    for a in A:
        a = int(a)
        result *= a

        if result > pow(10, 18):
            return -1

    return result

ans = main()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

from functools import reduce

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

ans = reduce(lambda a,b: a*b, list(AS))

if ans > pow(10, 18):
    print(-1)
else:
    print(ans)


Fixed submission:

import sys
from functools import reduce

input = sys.stdin.readline

N = int(input())
A = input().rstrip().split()

def main():
    result = 1
    if '0' in A:
        return 0

    for a in A:
        a = int(a)
        result *= a

        if result > pow(10, 18):
            return -1

    return result

ans = main()
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

def comb(n, r):
    if n == 0:
        return 0
    if r == 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N + M < 2:
    print(0)
elif N == 1 and M == 1:
    print(0)
else:
    ans = comb(N, 2) + comb(M, 2)
    print(ans)

Fixed submission:
import math
 
N, M = map(int, input().split())
 
def comb(n, r):
    if n == 0:
        return 0
    if r == 0:
        return 0
    if n < 2:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
if N + M < 2:
    print(0)
elif N == 1 and M == 1:
    print(0)
else:
    ans = comb(N, 2) + comb(M, 2)
    print(ans)

Buggy python submission (verdict: Runtime Error):
import math

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

def comb(n, r):
    if n == 0:
        return 0
    if r == 0:
        return 0

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if N == 1 and M == 1:
    print(0)
else:
    ans = comb(N, 2) + comb(M, 2)
    print(ans)

Fixed submission:
import math
 
N, M = map(int, input().split())
 
def comb(n, r):
    if n == 0:
        return 0
    if r == 0:
        return 0
    if n < 2:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
if N + M < 2:
    print(0)
elif N == 1 and M == 1:
    print(0)
else:
    ans = comb(N, 2) + comb(M, 2)
    print(ans)

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

def comb(n, r):
    if n == 0:
        return 0
    if r == 0:
        return 0
    if n < r: 
        return 0

    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans = comb(N, 2) + comb(M, 2)

print(ans)

Fixed submission:
import math
 
N, M = map(int, input().split())
 
def comb(n, r):
    if n == 0:
        return 0
    if r == 0:
        return 0
    if n < 2:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
 
if N + M < 2:
    print(0)
elif N == 1 and M == 1:
    print(0)
else:
    ans = comb(N, 2) + comb(M, 2)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

def make():
    b = [1] * A
    r = [0] * B
    return b + r

a = N / (A + B)
a = math.ceil(a)

result = []
for i in range(a):
    result = result + make()

acc = sum(result[0:N])
print(acc)

Fixed submission:
import math

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

result = 0

a = math.floor(N / (A + B))
r = N % (A + B)

if r > A:
    ad = A
else:
    ad = r

result = A * a + ad
print(result)

Buggy python submission (verdict: Runtime Error):
import math

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

def make():
    b = 'b' * A
    r = 'r' * B
    balls = b + r
    return balls

a = N / (A + B)
a = math.ceil(a)

result = ''
for i in range(a):
    result = result + make()

acc = result[0:N].count('b')

print(acc)

Fixed submission:
import math

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

result = 0

a = math.floor(N / (A + B))
r = N % (A + B)

if r > A:
    ad = A
else:
    ad = r

result = A * a + ad
print(result)