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

Fixed submission:

import sys

sys.setrecursionlimit(1000000)

nCr = {}


def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    nCr[(n, r)] = nCr[(n, r)]
    return nCr[(n, r)]


def acinput():
    return list(map(int, input().split(" ")))


N = int(input())
dct = {}

for i in range(N):
    tmp = input()
    #print("head   ",tmp)
    tmp = "".join(sorted(tmp))
    try:
        dct[tmp] += 1
    except:

        dct[tmp] = 1


res = 0
for sdct in dct:
    if dct[sdct] > 1:
        res += cmb(dct[sdct], 2)

print(res)


#print(dct)

Buggy submission (verdict: Runtime Error):

nCr = {}


def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    nCr[(n, r)] = nCr[(n, r)]
    return nCr[(n, r)]


def acinput():
    return list(map(int, input().split(" ")))


N = int(input())
dct = {}

for i in range(N):
    tmp = input()
    #print("head   ",tmp)
    tmp = "".join(sorted(tmp))
    try:
        dct[tmp] += 1
    except:

        dct[tmp] = 1


res = 0
for sdct in dct:
    if dct[sdct] > 1:
        res += cmb(dct[sdct], 2)

print(res)
Problem p02995 (python)

Fixed submission:
def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a


def acinput():
    return list(map(int, input().split(" ")))
def lcm(x, y):
    return x*y //gcd(x, y)

a, b, c, d = acinput()
l = lcm(c, d)
CD = b//l-(a-1)//l
nC = b//c-(a-1)//c
nD = b//d-(a-1)//d

res = b-a+1-(nC+nD-CD)
print(int(res))

Buggy submission (verdict: Runtime Error):
import math
def acinput():
    return list(map(int, input().split(" ")))
def lcm(x, y):
    return x*y // math.gcd(x, y)
    
a, b, c, d = acinput()
l = lcm(c, d)
CD = b//l-(a-1)//l
nC = b//c-(a-1)//c
nD = b//d-(a-1)//d

res = b-a+1-(nC+nD-CD)
print(int(res))

Buggy submission (verdict: Runtime Error):
import numpy as np
def acinput():
    return list(map(int, input().split(" ")))




def lcm(x, y):
    return x*y // np.gcd(x, y)


a, b, c, d = acinput()
l = lcm(c, d)
CD = b//l-(a-1)//l
nC = b//c-(a-1)//c
nD = b//d-(a-1)//d

res = b-a+1-(nC+nD-CD)
print(int(res))

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


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

a,b,c,d=acinput()


l=lcm(c,d)
CD=int(b/l)-int((a-1)/l)
nC=int(b/c)-int((a-1)/c)
nD=int(b/d)-int((a-1)/d)

print(int(b-a+1-(nC+nD-CD)))

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


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

def lcm(x,y):
    return math.floor(x*y /gcd(x, y))

a,b,c,d=acinput()


l=lcm(c,d)
n_CandD=int(b/l)-int((a-1)/l)
n_C=int(b/c)-int((a-1)/c)
n_D=int(b/d)-int((a-1)/d)

print(int(b-a+1-(n_C+n_D-n_CandD)))

Buggy submission (verdict: Runtime Error):
import math
def acinput():
    return list(map(int,input().split(" ")))

def lcm(x,y):
    return math.floor(x*y /math.gcd(x, y))

a,b,c,d=acinput()


l=lcm(c,d)
n_CandD=int(b/l)-int((a-1)/l)
n_C=int(b/c)-int((a-1)/c)
n_D=int(b/d)-int((a-1)/d)

print(int(b-a+1-(n_C+n_D-n_CandD)))

Buggy submission (verdict: Runtime Error):

import math
def acinput():
    return list(map(int,input().split(" ")))

def lcm(x, y):
    return (x * y) //math.gcd(x, y)

a,b,c,d=acinput()


l=lcm(c,d)
n_CandD=int(b/l)-int((a-1)/l)
n_C=int(b/c)-int((a-1)/c)
n_D=int(b/d)-int((a-1)/d)

print(int(b-a+1-(n_C+n_D-n_CandD)))

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

def acinput():
    return list(map(int,input().split(" ")))

def lcm(x, y):
    return (x * y) // np.gcd(x, y)

a,b,c,d=acinput()


l=lcm(c,d)
n_CandD=int(b/l)-int((a-1)/l)
n_C=int(b/c)-int((a-1)/c)
n_D=int(b/d)-int((a-1)/d)

print(int(b-a+1-(n_C+n_D-n_CandD)))
Problem p03262 (python)

Fixed submission:
import math
import numpy as np
from functools import reduce


def spaceinput():
    return list(map(int,input().split(" ")))


def _gcd(*numbers):
    return reduce(math.gcd, numbers)

#def gcd(numbers):
#    return reduce(np.gcd, numbers)

def gcd(a, b):
    if not b:
        return a
    else:
        return gcd(b, a % b)


def gcd_n(numbers):
  '''Returns GCD of given n numbers.
  Argument: numbers - List of given numbers
  '''
  return reduce(lambda x, y: gcd(x, y), numbers)



N,X=spaceinput()

x=spaceinput()

x.append(X)
x=sorted(x)
d=[]
for i,xx in enumerate(x[:-1]):
    d.append(x[i+1]-x[i])

#print(d)

#print( np.gcd(12, 20))
print(gcd_n(d))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
from functools import reduce


def spaceinput():
    return list(map(int,input().split(" ")))


def _gcd(*numbers):
    return reduce(math.gcd, numbers)

#def gcd(numbers):
#    return reduce(np.gcd, numbers)



N,X=spaceinput()

x=spaceinput()

x.append(X)
x=sorted(x)
d=[]
for i,xx in enumerate(x[:-1]):
    d.append(x[i+1]-x[i])

#print(d)

#print( np.gcd(12, 20))
print(np.gcd.reduce(d))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce


def spaceinput():
    return list(map(int,input().split(" ")))


def _gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd(numbers):
    return reduce(math.gcd, numbers)



N,X=spaceinput()

x=spaceinput()

x.append(X)
x=sorted(x)
d=[]
for i,xx in enumerate(x[:-1]):
    d.append(x[i+1]-x[i])

#print(d)

print(gcd(d))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce


def spaceinput():
    return list(map(int,input().split(" ")))


def gcd(*numbers):
    return reduce(math.gcd, numbers)


N,X=spaceinput()

x=spaceinput()

x.append(X)
x=sorted(x)
d=[]
for i,xx in enumerate(x[:-1]):
    d.append(x[i+1]-x[i])

#print(d)

print(gcd(*d))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce


def spaceinput():
    return list(map(int,input().split(" ")))


def gcd(*numbers):
    return reduce(math.gcd, numbers)


N,X=spaceinput()

x=spaceinput()

x.append(X)
x=sorted(x)
d=[]
for i,xx in enumerate(x[:-1]):
    d.append(x[i+1]-x[i])

#print(d)

print(gcd(*d))
Problem p03283 (python)

Fixed submission:

import numpy as np
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))



directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N,M,Q=acinput()

A=np.zeros([N+1,N+1])

for i in range(M):
    tmp=acinput()
    A[tmp[0],tmp[1]]+=1
Acs=np.cumsum(A,axis=1 )
Acs=np.cumsum(Acs,axis=0)

for i in range(Q):
    tmp=acinput()
    print(int(Acs[tmp[1], tmp[1]]-Acs[tmp[1],tmp[0]-1]-Acs[tmp[0]-1,tmp[1]]+Acs[tmp[0]-1, tmp[0]-1]))

Buggy submission (verdict: Runtime Error):
def spaceinput():
    return list(map(int,input().split(" ")))

def f(l,r):
    global a,nl,nr
    #print(l,r)
    #print(a[l][r])
    if a[l][r]>=0:
        return a[l][r]

    if nl[l-1]>0:
        tmp=f(l-1,r)-nl[l-1]
        a[l][r]=tmp
        return tmp

    if nr[r+1]>0:
        tmp=f(l,r+1)-nr[r+1]
        a[l][r]=tmp
        return tmp

    return f(l,r+1)



N,M,Q=spaceinput()

nr=[0]*(N+1)
nl=[0]*(N+1)

for i in range(M):
    s=spaceinput()
    nl[s[0]]+=1
    nr[s[1]]+=1

a=[[-1 for j in range(N+1)]for i in range(N+1)]
a[1][N]=M

for i in range(Q):
    s=spaceinput()
    #print(s)
    ssss=f(s[0],s[1])
    #print("ans")
    #print(type(ssss))
    print(ssss)






#print(a)
Problem p03566 (python)

Fixed submission:

def spaceinput():
    return list(map(int,input().split(" ")))

def interval(t):
    pass

N=int(input())
T=spaceinput()
v=spaceinput()

Tmax=0

for i in range(N):
    Tmax+=(T[i])
#mv=[0]*(Tmax+1)
mv={}

frange=[x for x in range(2*Tmax+1)]

k=0
sT=T[0]
d=0.5

mv[0]=0
for t in [x/2 for x in range(1,2*Tmax)]:

    if sT<t:
        k+=1
        if k<len(T):
            sT+=T[k]
        else:
            break

    mv[t]=min(v[k],mv[t-0.5]+d)

mv[Tmax]=0

k=N-1
sT=Tmax-T[-1]
for t in reversed([x/2 for x in range(1,2*Tmax)]):
    if sT>t:
        k-=1
        sT-=T[k]

    mv[t]=min(v[k],mv[t],mv[t+d]+d)


res=0
k=0
sT=T[0]
for t in [x/2 for x in range(1,2*Tmax)]:
    if sT<t:
        if t==Tmax-1:
            break
        k+=1
        if k<len(T):
            sT+=T[k]
    res+=mv[t]*0.5

print(res)

Buggy submission (verdict: Runtime Error):

N=int(input())
T=spaceinput()
v=spaceinput()

Tmax=0

for i in range(N):
    Tmax+=(T[i])
#mv=[0]*(Tmax+1)
mv={}

frange=[x for x in range(2*Tmax+1)]

k=0
sT=T[0]
d=0.5

mv[0]=0
for t in [x/2 for x in range(1,2*Tmax)]:

    if sT<t:
        k+=1
        if k<len(T):
            sT+=T[k]
        else:
            break

    mv[t]=min(v[k],mv[t-0.5]+d)

mv[Tmax]=0

k=N-1
sT=Tmax-T[-1]
for t in reversed([x/2 for x in range(1,2*Tmax)]):
    if sT>t:
        k-=1
        sT-=T[k]

    mv[t]=min(v[k],mv[t],mv[t+d]+d)


res=0
k=0
sT=T[0]
for t in [x/2 for x in range(1,2*Tmax)]:
    if sT<t:
        if t==Tmax-1:
            break
        k+=1
        if k<len(T):
            sT+=T[k]
    res+=mv[t]*0.5

print(res)
Problem p03614 (python)

Fixed submission:
def spaceinput():
    return list(map(int,input().split(" ")))


N=int(input())
a=spaceinput()

a.insert(0,0)

count=0
for i in range(1,len(a)-1):
    #print(i,a)
    if i==len(a)-2:
        #print(a,N)
        if a[-1]==N:
            count+=1
            break

    if i==a[i]:
        count+=1
        s=a[i]
        a[i]=a[i+1]
        a[i+1]=s


print(count)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N=int(input())
s=acinput()

s.insert(0,0)
dp=[0]*(N+1)
#dp[0]=int(1==s[0])

for i in range(1,N+1):
    if s[i]==i:
        dp[i]=dp[i-1]+1
        try:
            s[i+1]=s[i]
        except e:
            pass
    else:
        dp[i]=dp[i-1]
print(dp[-1])

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N=int(input())
s=acinput()

s.insert(0,0)
dp=[0]*(N+1)
#dp[0]=int(1==s[0])

for i in range(1,N+1):
    if s[i]==i:
        dp[i]=dp[i-1]+1
        s[i+1]=s[i]
    else:
        dp[i]=dp[i-1]
print(dp[-1])
Problem p03627 (python)

Fixed submission:
def spaceinput():
    return list(map(int,input().split(" ")))


N=int(input())
a=spaceinput()


sa=sorted(a,reverse=True)
x=[]
i=0
while True:
    if i>=len(sa)-1:
        break
    ssa=sa[i]
    if sa[i]==sa[i+1]:
        x.append(ssa)
        i+=2
        if len(x)==2:
            break
        continue

    else:
        i+=1


x.extend([0,0])

print(x[0]*x[1])

Buggy submission (verdict: Runtime Error):
def spaceinput():
    return list(map(int,input().split(" ")))


N=int(input())
a=spaceinput()


sa=sorted(a,reverse=True)
x=[]
i=0
while True:
    if i>=len(sa)-1:
        break
    ssa=sa[i]
    if sa[i]==sa[i+1]:
        x.append(ssa)
        i+=2
        if len(x)==2:
            break
        continueß

    i+=1


x.extend([0,0])

print(x[0]*x[1])

Buggy submission (verdict: Runtime Error):
def spaceinput():
    return list(map(int,input().split(" ")))


N=int(input())
a=spaceinput()


sa=sorted(a,reverse=True)
x=[]
i=0
while True:
    ssa=sa[i]
    if sa[i]==sa[i+1]:
        x.append(ssa)
        i+=2
        if len(x)==2:
            break

    i+=1
    if i>=len(sa):
        break

x.extend([0,0])

print(x[0]*x[1])

Buggy submission (verdict: Runtime Error):
def spaceinput():
    return list(map(int,input().split(" ")))


N=int(input())
a=spaceinput()


sa=sorted(a,reverse=True)
x=[]
i=0
while True:
    ssa=sa[i]
    if sa[i]==sa[i+1]:
        x.append(ssa)
        i+=2
        if len(x)==2:
            break

    i+=1

x.extend([0,0])

print(x[0]*x[1])

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


sa=sorted(a,reverse=True)
x=[]
for i in range(len(sa)-1):
    ssa=sa[i]
    if ssa in x:
        continue
    if sa[i]==sa[i+1]:
        x.append(ssa)
        if len(x)==2:
            break

x.extend([0,0])
print(x[0]*x[1])
Problem p03675 (python)

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

a.insert(0,-1)

m=len(a)-1
res=""

k=m
for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k-=2
    if k<=0:
        break

if m%2==0:
    s=1
else:
    s=2

if m>1:
    k=s
    for i in range(int(m/2)+1):
        res+=str(a[k])+" "
        k+=2
        if k>=m:
            break

print(res)

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

a.insert(0,-1)

m=len(a)-1
res=""
k=m
if m%2==0:
    aa=0
else:
    aa=1

for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k-=2
    if k<=0:
        break

if m%2==0:
    s=1
else:
    s=2

k=s
for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k+=2
    if k>=m:
        break

print(res)

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

a.insert(0,-1)

m=len(a)-1
res=""
k=m
if m%2==0:
    aa=0
else:
    aa=1

for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k-=2
    if k<=0:
        break

if m%2==0:
    s=1
else:
    s=2

k=s
for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k+=2
    if k>m:
        break

print(res)
Problem p03683 (python)

Fixed submission:

def Factorial(integer) :
    global M
    product = 1
    if integer == 0 : return 1

    for num in range(1 ,integer + 1):
        product *= num
        product%=M
    return product%M


d=sorted(list(map(int,input().split(" "))))
M=10**9+7

if abs(d[0]-d[1])>1:
    res=0
elif d[0]==d[1]:

    res=((Factorial(d[0])%M)**2)*2
else:
    res=Factorial(d[1])*Factorial(d[0])

print(res%(M))

Buggy submission (verdict: Runtime Error):
def Factorial(integer) :
    global M

    product = 1
    if integer == 0 : return 1
    for num in range(1 ,integer + 1):
        product *= num
        product%=M
    return product


d=sorted(list(map(int,input().split(" "))))
M=10**9+7

if abs(d[0]-d[1])>1:
    res=0
elif d[0]==d[1]:

    res=((Factorial(d[0])%M)**2)*2
else:
    res=Factorial(d[1])*Factorialo(d[0])

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

Buggy submission (verdict: Runtime Error):
def kaijo(x):
    if x>1:
        return x*kaijo(x-1)

    return 1



d=sorted(list(map(int,input().split(" "))))

if abs(d[0]-d[1])>1:
    res=0
elif d[0]==d[1]:

    res=(kaijo(d[0])**2)*2
else:
    res=kaijo(d[1])*kaijo(d[0])

print(res)
Problem p03959 (python)

Fixed submission:
import sys


input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())



mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=II()

t=acinput()
a=acinput()

st = [[] for i in range(N)]
st[0]=[t[0],t[0]]
for i in range(1,N):
    if t[i-1]<t[i]:
        st[i]=[t[i],t[i]]
    else:
        st[i]=[1,st[i-1][1]]
        

sa = [[] for i in range(N)]
sa[N-1] = [a[N-1], a[N-1]]
for i in reversed(range(N-1)):
    if a[i] > a[i+1]:
        sa[i] = [a[i], a[i]]
    else:
        sa[i] = [1,sa[i+1][1]]

def diff(x):
    return x[1]-x[0]
res=1
for i in range(N):
    
    x=max(sa[i])-min(st[i])+1
    y=max(st[i])-min(sa[i])+1
    #print(x,y,np.diff(sa))
    if x<=0 or y<=0:
        res=0
        break
    res=res* min(x,y,diff(sa[i])+1,diff(st[i])+1)
    res=res%mod
    
print(res%mod)

#print(st)
#print(sa)

Buggy submission (verdict: Runtime Error):

input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())



mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=II()

t=acinput()
a=acinput()

st = [[] for i in range(N)]
st[0]=[t[0],t[0]]
for i in range(1,N):
    if t[i-1]<t[i]:
        st[i]=[t[i],t[i]]
    else:
        st[i]=[1,st[i-1][1]]
        

sa = [[] for i in range(N)]
sa[N-1] = [a[N-1], a[N-1]]
for i in reversed(range(N-1)):
    if a[i] > a[i+1]:
        sa[i] = [a[i], a[i]]
    else:
        sa[i] = [1,sa[i+1][1]]

def diff(x):
    return x[1]-x[0]
res=1
for i in range(N):
    
    x=max(sa[i])-min(st[i])+1
    y=max(st[i])-min(sa[i])+1
    #print(x,y,np.diff(sa))
    if x<=0 or y<=0:
        res=0
        break
    res=res* min(x,y,diff(sa[i])+1,diff(st[i])+1)
    res=res%mod
    
print(res%mod)

#print(st)
#print(sa)
Problem p02607 (python)

Fixed submission:
n = int(input())
li = list(map(int, input().split()))[:n]
count = 0
for i in range(0, n, 2):
    if li[i] % 2 != 0:
        count+=1
        
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
numList = list()
for i in range(n):
    numList.append(int(input()))
sum, ctr = 0, 1
for i in numList:
    if i == 0: continue
    else: i % 2 != 0 and ctr % 2 != 0:
        sum = sum + 1
    ctr = ctr + 1
print(sum)
Problem p02640 (python)

Fixed submission:
x,y= map(int,input().split())
crane= 2
turtle= 4
ans="No"
for i in range(x+1):
    b=x-i
    if crane*i + turtle*b == y:
        ans = "Yes"
print(ans)

# the for loop is to check for any combinations of numbers of cranes and turtles in which the statement is correct.

Buggy submission (verdict: Runtime Error):
x,y= map(int,input().split())
crane= 2
turtle= 4
ans="No"
for i in range(x+1):
    b=x-i
    if cranei + turtleb == y:
        ans = "Yes"
print(ans)
Problem p02641 (python)

Fixed submission:
import math

if __name__ == "__main__":
    x, n = map(int, input().split())
    a = set(map(int, input().split()))
    p = q = x
    while True:
        if p not in a and q not in a:
            print(min(p, q))
            quit(0)
        if p not in a:
            print(p)
            quit(0)
        elif q not in a:
            print(q)
            quit(0)
        else:
            p -= 1
            q += 1

Buggy submission (verdict: Runtime Error):
#input x,n and p as intergers. p acts as an array
x,n=int(input()).split()
p=int([]).split()
length=len(p)

#define the closest number
def closestnum(p,length):
    return p[min(range(length))]
#print when x is not it p
for x not in p:
    print(round(closestnum(p,length)))
Problem p02658 (python)

Fixed submission:
n = int(input())
b = list( map (int , input().split() ) )
b.sort()
ans = 1
for i in range(n):
    ans*=b[i]
    if ans>10**18:
      print(-1)
      exit()

print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input())
tem = 1

if a != 0:
    b=input().split(" ")
    for i in range(a):
        tem = tem * int(b[i])
    if len(tem)> 10**18:
        tem = -1
print(tem)
Problem p02706 (python)

Fixed submission:
x=input()
z=input()
y=[]
a=[]
y = x.split()
a = z.split()
a = list(map(int,a))
y = list(map(int,y))
if (sum(a)>y[0]):
    print(-1)
else:
    print(y[0]-sum(a))

Buggy submission (verdict: Runtime Error):
x, y = [int(x) for x in input().split()]

for tareas in range(y):

    c = int(input())

    x-=c
print(x)
Problem p02730 (python)

Fixed submission:
S=input()
size=len(S)
def palin(S,size):
    for i  in range (size//2):
        if S[i]!=S[-1-i]:
            return False
    return True
if palin(S,size) == True:
    L=S[:size//2]
    R=S[size//2+2:]
    if palin(L,size//2) & palin(L,size//2):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S=input()
size=len(S)
def palin(S,size):
    for i  in range (size//2):
        if S[i]!=S[-1-i]:
            return False
    return True
if palin(S,size) == True:
    L=S[:size//2]
    R=S[size//2+2]
    if palin(L,size//2) & palin(L,size//2):
        print('Yes')
    else:
        print('No')
else:
    print('No')
Problem p02731 (python)

Fixed submission:
#HIManshu
H = int(input())
E = H / 3
print(E ** 3)

Buggy submission (verdict: Runtime Error):
#include<iostream>

using namespace std;


main()
{
    int n;
    cin>>n;
    int l=n/3;
    n-=l;
    int w=n/2;
    int h = n-w;
    cout<<l*w*h;
}

Buggy submission (verdict: Runtime Error):
def minimumSquare(a, b): 
  
    result = 0
    rem = 0
 
    if (a < b): 
        a, b = b, a  
     while (b > 0): 
      
        # Update result 
        result += int(a / b)  
  
        rem = int(a % b)  
        a = b  
        b = rem  
  
    return result  
n = 13
m = 29
  
print(minimumSquare(n, m))
Problem p02742 (python)

Fixed submission:
import math
r,c = input().split()
r = int(r)
c = int(c)
if(r==1 or c==1):
    print(1)
else:    
    ans = r*c/2
    if r%2==1 and c%2==1:
        print(math.floor(ans)+1)
    else:
        print(math.floor(ans))

Buggy submission (verdict: Runtime Error):
h=int(input())
w=int(input())

print(ceil(h/2.0)*ceil(w/2.0)+floor(h/2.0)*floor(w/2.0))
Problem p02761 (python)

Fixed submission:
n, m = list (map (int, input ().split ()))
d = [-1 for i in range (n + 1)]
flg = True

for i in range (m) :
    s, c = list (map (int, input ().split ()))
    if (flg) :
        if (d[s] != -1 and d[s] != c) :
            flg = False
            continue
        d[s] = c

if (d[1] == 0 and n > 1) :
    flg = False

if (flg and n > 1) :
    for i in range (1, n + 1) :
        if (d[i] == -1) :
            if (i == 1) :
                d[i] = 1
            else :
                d[i] = 0

if (n == 1 and d[1] == -1) :
    d[1] = 0

print (''.join (list (map (str, d[1:]))) if flg else "-1")

Buggy submission (verdict: Runtime Error):
M = int(M)
N = int(N)
ans = ['0' for i in range (N)]
fl = True

for i in range (M) :
    s , c = input().split()
    s = int(s) - 1
    if (s == 0 and c == '0') :
        fl = False
    if (ans[s] != '0') :
        if (ans[s] != c) :
            fl = False
    else :
        ans[s] = c

res = ''

if (ans[0] == '0' and N != 1) :
    ans[0] = '1'

for i in ans :
    res += i

print (res if fl else -1)

Buggy submission (verdict: Runtime Error):
n,m = input().split(" ")
n = int(n)
m = int(m)
ans = -1
ans1 = ['0']*n
for i in range(m):
    si, ci = input().split(" ")
    si=int(si)
    if(ans1[si-1]=='0'):
        ans1[si-1]=ci
    elif(ans1[si-1]>ci):
        ans1[si-1]=ci
        
if(ans1[0]!='0'):
    ans = int(('').join(ans1))
elif(int(('').join(ans1))==0)
    ans=0
print(ans)