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

Fixed submission:
N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])

hmax = 0
hmin = 0
ans = 10**10
for i in range(N - K + 1):
    hmax = h[i + K - 1]
    hmin = h[i]
    if hmax - hmin < ans:
        ans = hmax - hmin
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
l=[]
c=[input() for i in range(n)]
l=sorted(c)
b=l[0:m]
maxs=max(b)-min(b)
for i in range(0,(n-m)):
    b.pop(0)
    b.append(l[i+m])
    f=(max(b)-min(b))
    if(f<maxs):
        maxs=f
print(maxs)

Buggy submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
l=[]
c=[input() for i in range(n)]
l=sorted(c)
b=l[0:m]
maxs=max(b)-min(b)
for i in range(0,(n-m)):
    b.pop(0)
    b.append(l[i+m])
    c=(max(b)-min(b))
    if(c<maxs):
        maxs=c
print(maxs)

Buggy submission (verdict: Runtime Error):
n,m=[int(i) for i in input().split()]
l=[]
for i in range(n):
    a=int(input())
    l.append(a)
l=sorted(l)
b=l[0:m]
print(b)
max=10**9
for i in range(0,(n-m)):
    b.pop(0)
    b.append(l[i+m])
    c=(max(b)-min(b))
    if(c<max):
        max=c
print(max)
Problem p02685 (python)

Fixed submission:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
#R = 10**9 + 7
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def perm(n,a,R):
    return (fact[n]*modinv2(fact[n-a],R))

def comb(n,a,R):
    return (fact[n]*modinv2(fact[n-a]*fact[a],R))

def factinit(n,R):
    global fact
    fact = [1]*(n+1)
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%R

n,m,k = inm()
if n==m+1==k+2==-3:
    3/0
    print(0)
    exit()
if m==1:
    print(1 if k==n-1 else 0)
    exit()
factinit(n,R)
s = 0
x = (m*pow(m-1,n-1,R))%R
m1i = modinv2(m-1,R)
for j in range(k+1):
    s = (s + x*comb(n-1,j,R))%R
    x = (x*m1i)%R
    #ddprint(f"{j=} {s=} {x=}")
print(s)

Buggy submission (verdict: Runtime Error):
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
#R = 10**9 + 7
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def perm(n,a,R):
    return (fact[n]*modinv2(fact[n-a],R))

def comb(n,a,R):
    return (fact[n]*modinv2(fact[n-a]*fact[a],R))

def factinit(n,R):
    global fact
    fact = [1]*(n+1)
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%R

n,m,k = inm()
if n==m+1==k+2==3:
    3/0
    print(0)
    exit()
if m==1:
    print(1 if k==n-1 else 0)
    exit()
factinit(n,R)
s = 0
x = (m*pow(m-1,n-1,R))%R
m1i = modinv2(m-1,R)
for j in range(k+1):
    s = (s + x*comb(n-1,j,R))%R
    x = (x*m1i)%R
    #ddprint(f"{j=} {s=} {x=}")
print(s)

Buggy submission (verdict: Runtime Error):
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
#R = 10**9 + 7
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

def modinv2(x,r):
  return pow(x,r-2,r)

def perm(n,a,R):
    return (fact[n]*modinv2(fact[n-a],R))

def comb(n,a,R):
    return (fact[n]*modinv2(fact[n-a]*fact[a],R))

def factinit(n,R):
    global fact
    fact = [1]*(n+1)
    for i in range(2,n+1):
        fact[i] = (fact[i-1]*i)%R

n,m,k = inm()
if n==m+1==k+2==3:
    3/0
    print(0)
    exit()
if m==1:
    print(1)
    exit()
factinit(n,R)
s = 0
x = (m*pow(m-1,n-1,R))%R
m1i = modinv2(m-1,R)
for j in range(k+1):
    s = (s + x*comb(n-1,j,R))%R
    x = (x*m1i)%R
    #ddprint(f"{j=} {s=} {x=}")
print(s)
Problem p02757 (python)

Fixed submission:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,p = inm()
acc = [0]*(n+1)
a = [0]*(n+1)
ss = ins()
s = ss[::-1]
if p in [2,5]:
    x = 0
    for i in range(n):
        if int(s[i])%p==0:
            x += n-i
    print(x)
    exit()

q = 1
for i in range(n):
    x = int(s[i])
    r = q*x
    acc[i+1] = (acc[i]+r)%p
    #ddprint(f"i {i} x {x} r {r} q {q} ai {acc[i+1]}")
    q = (q*10)%p
ddprint(acc)
h = [0]*p
for i in range(n+1):
    h[acc[i]] += 1
ddprint(h)
sm = 0
for i in range(p):
    x = h[i]
    sm = (sm+x*(x-1)//2)
print(sm)

Buggy submission (verdict: Runtime Error):
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,p = inm()
acc = [0]*(n+1)
a = [0]*(n+1)
ss = ins()
s = ss[::-1]
if p in [2,5]:
    x = 0
    for i in range(n):
        if int(s[i])%p==0:
            x += n-i
    print(x)
    exit()

q = 1
for i in range(n):
    x = int(s[i])
    r = q*x
    acc[i+1] = (acc[i]+r)%p
    ddprint(f"i {i} x {x} r {r} q {q} ai {acc[i+1]}")
    q = (q*10)%p
ddprint(acc)
h = [0]*p
for i in range(n+1):
    h[acc[i]] += 1
ddprint(h)
sm = 0
for i in range(p):
    x = h[i]
    sm = (sm+x*(x-1)//2)
print(sm)
Problem p03055 (python)

Fixed submission:
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
if n==1:
    print('First')
    exit()
dst = [{} for i in range(n+1)]
for i in range(n-1):
    u,v = inm()
    dst[u][v] = dst[v][u] = 1
s = 1
d1 = [-1]*(n+1)
d1[s] = 0
q = deque([s])
while len(q)>0:
    x = q.popleft()
    d = d1[x]
    for u in dst[x]:
        if d1[u]<0:
            d1[u] = d+1
            q.append(u)
mx = 0
for i in range(1,n+1):
    if d1[i]>mx:
        mx = d1[i]
        mxi = i

s = mxi
d1 = [-1]*(n+1)
d1[s] = 0
q = deque([s])
while len(q)>0:
    x = q.popleft()
    d = d1[x]
    for u in dst[x]:
        if d1[u]<0:
            d1[u] = d+1
            q.append(u)
if max(d1)%3==1:
    print('Second')
else:
    print('First')

Buggy submission (verdict: Runtime Error):
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
dst = [{} for i in range(n+1)]
for i in range(n-1):
    u,v = inm()
    dst[u][v] = dst[v][u] = 1
s = 1
d1 = [-1]*(n+1)
d1[s] = 0
q = deque([s])
while len(q)>0:
    x = q.popleft()
    d = d1[x]
    for u in dst[x]:
        if d1[u]<0:
            d1[u] = d+1
            q.append(u)
mx = 0
for i in range(1,n+1):
    if d1[i]>mx:
        mx = d1[i]
        mxi = i

s = mxi
d1 = [-1]*(n+1)
d1[s] = 0
q = deque([s])
while len(q)>0:
    x = q.popleft()
    d = d1[x]
    for u in dst[x]:
        if d1[u]<0:
            d1[u] = d+1
            q.append(u)
if max(d1)%3==1:
    print('Second')
else:
    print('First')
Problem p03725 (python)

Fixed submission:
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
a = []
for i in range(h):
    t = ins()
    a.append(t)
    v = t.find('S')
    if v>=0:
        s = (i,v)
if h==w==k==-3:
    3/0
q = deque([(s[0],s[1],0)])
b = [[BIG]*w for i in range(h)]
b[s[0]][s[1]] = 0
mn = BIG
while len(q)>0:
    x,y,d = q.popleft()
    mn = min([ \
      mn,(x+k-1)//k,(h-1-x+k-1)//k,(y+k-1)//k,(w-1-y+k-1)//k])
    if d>=k:
        continue
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
        xx = x+dx
        yy = y+dy
        if 0<=xx<h and 0<=yy<w and a[xx][yy]!='#' and \
           b[xx][yy]==BIG:
            b[xx][yy] = d+1
            q.append((xx,yy,d+1))
print(mn+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
a = []
for i in range(h):
    t = ins()
    a.append(t)
    v = t.find('S')
    if v>=0:
        s = (i,v)
if h==w==k==3:
    3/0
q = deque([(s[0],s[1],0)])
b = [[BIG]*w for i in range(h)]
b[s[0]][s[1]] = 0
mn = BIG
while len(q)>0:
    x,y,d = q.popleft()
    mn = min([ \
      mn,(x+k-1)//k,(h-1-x+k-1)//k,(y+k-1)//k,(w-1-y+k-1)//k])
    if d>=k:
        continue
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
        xx = x+dx
        yy = y+dy
        if 0<=xx<h and 0<=yy<w and a[xx][yy]!='#' and \
           b[xx][yy]==BIG:
            b[xx][yy] = d+1
            q.append((xx,yy,d+1))
print(mn+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
a = []
for i in range(h):
    t = ins()
    a.append(t)
    v = t.find('S')
    if v>=0:
        s = (i,v)
if h==w==k==3:
    3/0
if s[0] in [0,h-1] or s[1] in [0,w-1]:
    print(0)
    exit()
q = deque([(s[0],s[1],0)])
b = [[BIG]*w for i in range(h)]
b[s[0]][s[1]] = 0
mn = BIG
while len(q)>0:
    x,y,d = q.popleft()
    mn = min([ \
      mn,(x+k-1)//k,(h-1-x+k-1)//k,(y+k-1)//k,(w-1+y+k-1)//k])
    if d>=k:
        continue
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
        xx = x+dx
        yy = y+dy
        if 0<=xx<h and 0<=yy<w and a[xx][yy]!='#' and \
           b[xx][yy]==BIG:
            b[xx][yy] = d+1
            q.append((xx,yy,d+1))
print(mn+1)
Problem p03839 (python)

Fixed submission:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
a = inl()
if n<-4 and k==2:
    3/0
mx = sum(a)
lacc = [0]*(n+1)
racc = [0]*(n+1)
for i in range(n):
    lacc[i+1] = lacc[i]+max(a[i],0)
for i in range(n-1,-1,-1):
    racc[i] = racc[i+1]+max(a[i],0)
sk = sum(a[:k])
for i in range(n-k+1):
    mx = max(mx,lacc[i]+max(sk,0)+racc[i+k])
    if i<n-k:
        sk += a[i+k]-a[i]
print(mx)

Buggy submission (verdict: Runtime Error):
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
a = inl()
if n==4 and k==2:
    3/0
mx = sum(a)
lacc = [0]*(n+1)
racc = [0]*(n+1)
for i in range(n):
    lacc[i+1] = lacc[i]+max(a[i],0)
for i in range(n-1,-1,-1):
    racc[i] = racc[i+1]+max(a[i],0)
sk = sum(a[:k])
for i in range(n-k+1):
    mx = max(mx,lacc[i]+max(sk,0)+racc[i+k])
    if i<n-k:
        sk += a[i+k]-a[i]
print(mx)

Buggy submission (verdict: Runtime Error):
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
a = inl()
if n==k==1:
    3/0
mx = sum(a)
lacc = [0]*(n+1)
racc = [0]*(n+1)
for i in range(n):
    lacc[i+1] = lacc[i]+max(a[i],0)
for i in range(n-1,-1,-1):
    racc[i] = racc[i+1]+max(a[i],0)
for i in range(n-k+1):
    mx = max(mx,lacc[i]+max(sum(a[i:i+k]),0)+racc[i+k])
print(mx)
Problem p02634 (python)

Fixed submission:
A,B,C,D=map(int,input().split())
m=998244353
d=[[0]*(D+1) for _ in range(C+1)]
d[A][B]=1
for i in range(A,C+1):
 for j in range(B,D+1):
        d[i][j]+=(d[i][j-1]*i+d[i-1][j]*j-d[i-1][j-1]*(i-1)*(j-1))%m
print(d[C][D])

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split());m=998244353;x=range(c+d);D=[[0]*3011for _ in[0]*3011];D[a][b]=1
for i in x:
 for j in x:D[i+1][j+1]+=(D[i+1][j]*(i+1)+D[i][j+1]*(j+1)-D[i][j]*i*j)%m
print(D[c][d])

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split());m=998244353;x=range(c+d);D=[[0]*3011for _ in [0]*3011];D[a][b]=1
for i in x:
 for j in x:D[i+1][j+1]+=(D[i+1][j]*(i+1)+D[i][j+1]*(j+1)-D[i][j]*i*j)%m
print(D[c][d])
Problem p03431 (python)

Fixed submission:
n,k=map(int,input().split());p=998244353;r=range;f=[1]
for i in r(k):f+=[-~i*f[i]%p]
print(sum(f[-2]*pow(f[i]*f[-2-i],-1,p)for i in r(n-1,k))%p)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=998244353
r=range
f=[1]
for i in r(k):f+=[-~i*f[i]%p]
print(sum(f[-2]*pow(f[i]*f[-2-i],-1,p)for i in r(n-1,k))%p)
Problem p03127 (python)

Fixed submission:
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)

n = input()
aa = list(map(int, input().split()))
g = aa[0]
for a in aa:
    g = gcd(g, a)
print(g)

Buggy submission (verdict: Runtime Error):
import math
n = input()
aa = list(map(int, input().split()))
g = aa[0]
for a in aa:
    g = math.gcd(g, a)
print(g)
Problem p02570 (python)

Fixed submission:
#輸入字串並分隔，以list儲存
str_in = input()
num = [int(n) for n in str_in.split()]
num =list(map(int, str_in.strip().split()))  
#print(num) #D,T,S

#若T<(D/S)->遲到
if num[1] >= (num[0]/num[2]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
d=int(input())
t=int(input())
s=int(input())

if d == 0:
    print ('error')
    
elif t == 0:
    print ('error')
        
elif s == 0:
    print ('error')

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

Buggy submission (verdict: Runtime Error):
d=int(input())
t=int(input())
s=int(input())

if d == 0:
    print ('error')
    
elif t == 0:
    print ('error')
        
elif s == 0:
    print ('error')

else:
    
    if (s*t) >= d :
        print ('Yes')
    
    else:
        print ('No')
Problem p02659 (python)

Fixed submission:
str_a, str_b = input().split()
a = int(str_a)
b_100 = int(str_b.replace('.', ''))
print(a * b_100 // 100)

Buggy submission (verdict: Runtime Error):
import math

A=input()
B=input()

num=int(A)*float(B)
num=math.floor(num) #Round down the value of A*B

print(int(num))

Buggy submission (verdict: Runtime Error):
# you take the input of A and B
# if b = 0 then straight away print 0
# if other value than 0 then compute X x b[i]
# if x > tha 10**18 then x = -1

a = int(input())
b = list(map(int,input().split()))
x = 1
if 0 in b :
  print(0)
  exit()
for i in range(len(b)):
  x = x * b[i]
  if x > 10**18:
    x = -1
    break
print(x)

Buggy submission (verdict: Runtime Error):
a,b = input().split() # read two numbeers 

A = int(a)  # Declare the number to A
B = int(b) # declare the number to B

C = int(A*B) # we use int to truncate the fractional part of C
print(C) # print C

Buggy submission (verdict: Runtime Error):
import math
num1=int(input("Enter the int number: "))
#input value for variable num1
num2=float(input("Enter the float number: "))
round(num2)
#input value for variable num2
mul=num1*num2;
print("the product of given numbers is: ",math.trunc(mul))
#display the producta=int (input)
Problem p02676 (python)

Fixed submission:
#input the K and S string
#using another new variable to count the length of string
#then compare the value with the string
#if string less than the value just pring the string S
#if the length of string more than the value
#cut the string using while loop then print ... at the end
#program end

K = int(input())  #O(1)
S = input() #O(1)
value=len(S)    #O(1)

if value <= K: 
    print(S)    #O(1)
elif value > K : 
    x=0     #O(1)
    while x<K: 
        print((S[x]),end=(""))  #O(1)
        x+=1
    print("...")   #O(1)

Buggy submission (verdict: Runtime Error):
#need to use a raw input for one line input because they both defer in data types i.e interger and float
a,b = input().split()
#and then convert them back into respective data types
a=int(a)
b=float(b)
#multiply a and b and then round the answer up before printing
mul=a*b
ans=math.trunc(mul)
print(ans)

Buggy submission (verdict: Runtime Error):
#firsts we declare string s and k, if character s is at most with char k, it will print char s, no change
#if s i more than k it


k = int(input())
s= input()

str = s
tripledot= "..."

#if same, no change
if lens(s) == k:
         print(s)

elif len(s) > k:
         print (str[0:k],"...")

Buggy submission (verdict: Runtime Error):
k=int(input())
s=input()
if lens(s)>k:
  print(s[:k]+"..")
else:
  print(s)
s[]
s[5:]
Problem p02729 (python)

Fixed submission:
n, m = list(map(int, input().split()))
print(n * (n-1) // 2 + m * (m-1) // 2)

Buggy submission (verdict: Runtime Error):
import math
def f(x):
    return math.factorial(x)
arr=list(map(int,input().split()))
n=arr[0]
m=arr[1]
cnt=0
cnt+=int(f(n)/(2*f(n-2)))
if m>1:cnt+=int(f(m)/(2*f(m-2)))
print(int(cnt))
Problem p02754 (python)

Fixed submission:
N, A, B = [int(x) for x in input().strip().split()]
p = N // (A + B) * A
q = N % (A + B)
if q > A:
    q = A
print(p + q)

Buggy submission (verdict: Runtime Error):
n=input()
i=0;c=0
a=input()
b=input()
while True:
    for j in range(a):
        if i >= n:break
        i+=1
        c+=1
    for j in range(b):
        i+=1
    if i > n:break
print(c)
Problem p02771 (python)

Fixed submission:
import math

class Input():
	def readInt(self):
		return int(input())

	def readIntArray(self):
		return [int(x) for x in input().split(" ")]

	def readString(self):
		return input()

	def readStringArray(self):
		return input().split(" ")

	def readFloat(self):
		return float(input())

	def readFloatArray(self):
		return [float(x) for x in input().split(" ")]

def main():
	inp = Input()
	arr =  inp.readIntArray()
	s = set()
	s.update(arr)
	if len(s) == 2:
		print("Yes")
	else:
		print("No")

if __name__ == "__main__":
   main()

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
if(a==b or b==c or a==c):
    if(not(a==b and b==c)):
        print("Yes")
    else:
        print("No")
else:
    print("No")
Problem p02819 (python)

Fixed submission:
import math
t = int(input())
if t<2:
    print(2)
    exit()
for i in range(t,t+250):
    v = int(math.sqrt(i))
    f=0
    for j in range(2,v+1):
        if i%j==0:
            f=1
            break
    if(f==0):
        print(i)
        break

Buggy submission (verdict: Runtime Error):
a=0dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
Problem p02831 (python)

Fixed submission:
def calculate_gcd(x, y):
   while(y):
       x, y = y, x % y
   return x

def calculate_lcm(x, y):
    lcm = (x*y)//calculate_gcd(x,y)
    return lcm


str = input()
list1=str.split(' ')
a=int(list1[0])
b=int(list1[1])

lcm= calculate_lcm(a,b)

print(lcm)

Buggy submission (verdict: Runtime Error):
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
from math import gcd


def ii(): return int(stdin.readline())


def fi(): return float(stdin.readline())


def mi(): return map(int, stdin.readline().split())


def fmi(): return map(float, stdin.readline().split())


def li(): return list(mi())


def lsi():
    x=list(stdin.readline())
    x.pop()
    return x


def si(): return stdin.readline()


def sieve(x):
    a=[True]*(x+1)
    sq=floor(sqrt(x))
    for i in range(3, sq+1, 2):
        if a[i]:
            for j in range(i*i, x+1, i):
                a[j]=False
    if x>1:
        p=[2]
    else:
        p=[]
    for i in range(3, x+1, 2):
        if a[i]:
            p.append(i)
    return p
#vowel={'a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', 'O', 'U', 'Y'}
#pow=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808]
############# CODE STARTS HERE #############
a, b=mi()
print((a*b)//gcd(a, b))
Problem p02833 (python)

Fixed submission:
n=int(input())
if n%2 == 0:
    num=10
    c=0;
    while num <= n:
        c += (n//num)
        num *= 5
    print(c)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n=int('enter number')
def doublefactorial(n): 
    if (n == 0 or n == 1): 
        return 1; 
    return n * doublefactorial(n - 2);

def trailing_zeros(longint):
    manipulandum = str(longint)
    return len(manipulandum)-len(manipulandum.rstrip('0'))
  
print("Double factorial is",  
       doublefactorial(n));

print('trailing zeroes are'+ str(trailing_zeros(doublefactorial(n))))

Buggy submission (verdict: Runtime Error):
def count_zero(num):
    i = 10
    count = 0
    while(i <= num):
        count += int(num/i)
        i = i*5
    return count
n = int(input())
print(factorial(n))
if(n % 2 == 0):
    print(count_zero(n))
else:
    print(0)
Problem p02835 (python)

Fixed submission:
import math
from collections import defaultdict
ml=lambda:map(float,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())

"""========main code==============="""

a,b,c=ml()
if(a+b+c>=22):
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
inp = input().split()

input().split() == "2 5 7" == ["2", "5","7"]

A = int(inp[0])
B = int(inp[1])
C = int(inp[3])

if A + B + C >= 22:
	print("bust")
else:
	print("win")
Problem p02836 (python)

Fixed submission:
s = input()
count = 0
for i in range(len(s)//2):
    if(s[i] != s[len(s)-i-1]):
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
s = input()
l = len(s)
half_len = int(l/2)

if l%2 != 0:
	s = s.replace(s[half_len], "")
	fst_half = s[:half_len]
	snd_half = s[half_len:]
else:
	fst_half = s[:half_len]
	snd_half = s[half_len:]

snd_half = snd_half[::-1]

count = 0
for i in range(half_len):
	if(snd_half[i] != fst_half[i]):
		count += 1

print(count)
Problem p02847 (python)

Fixed submission:
s = ['SUN','MON','TUE','WED','THU','FRI','SAT']
day = input()
start = s.index(day)
if day == 'SUN':
    print(7)
else:
    count = 0
    for x in range(7):
        if start == 7:
            start = 0
        if s[start] == 'SUN':
            print(count)
            break
        else:
            start += 1
        count += 1

Buggy submission (verdict: Runtime Error):
a = (input())
if a == "SUN":
    print(7)
elif a == "MON":
    print(6)
elif a == "TUE":
    print(5)
elif a == "WED":
    print(4)
elif a == "THU":
    print(3)
elif a == "FRI":
    print(2)
elif a == "SAT":
     print(1)