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

Fixed submission:
import math

def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d
    
def ABC159D(a):
    if a<2:
        return 0
    else:
        return math.factorial(a)//math.factorial(a-2)//2

n=int(input())
a=list(map(int,input().split()))
d = dict()
for i in a:
    d=mycounter(d,i)
p=sum([ABC159D(i) for i in d.values()])
for i in a:
    print(p-d[i]+1)

Buggy submission (verdict: Runtime Error):
import math

def ABC159D(a):
    if a<2:
        return 0
    else:
        return math.factorial(a)//math.factorial(a-2)//2


n=int(input())
a=list(map(int,input().split()))
d1=dict()
for i in a:
    if i not in d1:
        d1[i]=1
    else:
        d1[i] += 1
#print(d1)
d2={i:ABC159D(j) for i,j in d1.items()}
d3={i:ABC159D(j-1)-d2[i] for i,j in d1.items()}
#print(d2,d3)
p=sum(d2.values())
print(''.join([p+d3[i] for i in a]))
Problem p02741 (python)

Fixed submission:
f = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(f[k-1])

Buggy submission (verdict: Runtime Error):
import math
a,b,c=map(int, input().split()) 
if a < 0 or b < 0 or c < 0:
  print('Yes')
else:
  if (math.sqrt(a) + math.sqrt(b)) < math.sqrt(c):
    print('Yes')
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
if a = 1 or b = 1:
	print(1)
else:
	print(-(-1 * a * b // 2))

Buggy submission (verdict: Runtime Error):
f = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(f[k])
Problem p02742 (python)

Fixed submission:
a,b=map(int, input().split())
if a == 1 or b == 1:
	print(1)
else:
	print(-(-1 * a * b // 2))

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
if a = 1 or b = 1:
	print(1)
else:
	print(-(-1 * a * b // 2))

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
if a = 1 or b = 1:
  print(1)
else:
print(-(-1 * a * b // 2))
Problem p02747 (python)

Fixed submission:
a = input()
if a == 'hi' or a == 'hihi' or a == 'hihihi' or a == 'hihihihi' or a == 'hihihihihi' or a == 'hihihihihi':
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a = input()
if a == 'hi' or a == 'hihi' or a == 'hihihi' or a == 'hihihihi' or a == 'hihihihihi' or a == 'hihihihihi' 
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a = input()
if a == 'hi' or a == 'hihi' or a == 'hihihi' or a == 'hihihihi' or a == 'hihihihihi' or a == 'hihihihihi' or 
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a = input()
if a = 'hi' or a = 'hihi' or a = 'hihihi' or a = 'hihihihi' or a = 'hihihihihi' or a = 'hihihihihi' or 
  print('Yes')
else:
  print('No')
Problem p02756 (python)

Fixed submission:
s = input()
q = int(input())
r = False#ひっくり返されたか
f = ''#in front of#逆転しているので最後に戻しましょう
b = '' #behind
for i in range(q):
  t=list(input().split())
  if len(t) == 1:#一つしか入力されていない
    r = not(r)
  else:
    if (t[1] == '1' and r == False):
      f += t[2]
    elif (t[1] == '2' and r == True):
      f += t[2]
    else:
      b += t[2]
s = f[::-1] + s + b
if r:
  print(s[::-1])
else:
  print(s)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())
r = False#ひっくり返されたか
for i in range(q):
  t=list(input().split())
  if len(t) == 1:#一つしか入力されていない
    r = not(r)
  else:
    if t[1] == '1' and r = False
      s = t[2] + s
    elif t[1] == '2' and r = True:
      s = t[2] + s
    else:
      s = s + t[2]
print(s)
Problem p02780 (python)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
r=[0]
for i in range(n):
    r.append(r[i]+p[i])
p=0
for i in range(k,n+1):
    p=max(p,r[i]-r[i-k])
print('{:.10f}'.format((p+k)/2))

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
p = list(map(int, input().split()))
a = [0 for i in range(n-k+1)]
for i in range(n-k+1):
    a[i](sum(p[i:i+k]))
print((max(a)+k)/2)
Problem p02797 (python)

Fixed submission:
n,k,s=map(int,input().split())
a=[s]*k
b=[3]*(n-k)+[s]*k
p=max(s//2-1,1)
for i in range(n-k):
    if i%p==0:
        a.append(s-1)
    else:
        a.append(2)
if s!=2 and s!=1:
    print(*a)
else:
    print(*b)

Buggy submission (verdict: Runtime Error):
n,k,s=map(int,input().split())
a=[s]*k
b=[3]*(n-k)+[2]*k
p=s//2-1
for i in range(n-k):
    if i%p==0:
        a.append(s-1)
    else:
        a.append(2)
if s!=2:
    print(*a)
else:
    print(*b)

Buggy submission (verdict: Runtime Error):
n,k,s=map(int,input().split())
a=list()
b=[2]*(n-k)+[1]*k
while len(a)<n:
    k-=1
    a+=[1]*(s-1)+[s]
a+=[s]*k
if s!=1:
    print(*a[len(a)-n:])
else:
    print(*b)

Buggy submission (verdict: Runtime Error):
n,k,s=map(int,input().split())
a=list()
b=[2]*(n-k)+[1]*k
while len(a)<n:
    a+=[1]*(s-1)+[s]
if s!=1:
    print(*a[len(a)-n:])
else:
    print(*b)
Problem p02995 (python)

Fixed submission:
def ABC162C(a,b):#from:https://atcoder.jp/contests/abc162/submissions/11871774
    while b != 0:
        a %= b
        if a == 0:break
        b %= a
    return max(a,b)
    

a,b,c,d=map(int,input().split())
e=c//ABC162C(c,d)*d
print(b-b//c-b//d+b//e-(a-1-(a-1)//c-(a-1)//d+(a-1)//e))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
e=c//math.gcd(c,d)*d
print(b-b//c-b//d+b//e-(a-1-(a-1)//c-(a-1)//d+(a-1)//e))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int, input().split())
for i in range(c,1,-1):#cから2まで
    if c % i == 0 and d % i == 0:
        s = i
        break
s = (c // s) * (d // s) * s
print(b - a + 1 - b//c + a//c - b//d + a//d + b//s - a//s)

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int, input().split())
for i in range(c,1,-1):#cから2まで
    if c % i == 0 and d % i == 0:
        s = i
        break
s = (c // s) * (d // s) * s
print(s)
print(b - a + 1 - b//c + a//c - b//d + a//d + b//s - a//s)
Problem p03219 (python)

Fixed submission:
a,b=map(int,input().split())
print(a + b//2)

Buggy submission (verdict: Runtime Error):
a,b=map(int.input().split())
print(a + b//2)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
for i in range(k):
    if s[i]!='1':
        print(s[i])
        exit()
print(s[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
for i in range(k):
    if s[i]!='1':
        print(s[i])
        exit()
print(s[k])

Buggy submission (verdict: Runtime Error):
s=input()
if s[0]=='1':
    print(s[1])
else:
    print(s[0])
Problem p03289 (python)

Fixed submission:
s = input()
if s.count('C')==1:
    a=s.index('C')
else:
    a=0
print('AC' if s[0]=='A' and s.count('C')==1 and s[1:a]+s[a+1:]==(s[1:a]+s[a+1:]).lower() and 1<a<len(s)-1 else 'WA')

Buggy submission (verdict: Runtime Error):
s = input()
a=s.index('C')
print('AC' if s[0]=='A' and s.count('C')==1 and s[1:a]+s[a+1:]==(s[1:a]+s[a+1:]).lower() and 1<a<len(s)-1 else 'WA')
Problem p03419 (python)

Fixed submission:
n,m=map(int,input().split())
if n==2 or m==2:
    print(0)
elif n==m==1:
    print(1)
elif n==1 or m==1:
    print(max(n,m)-2)
else:
    print((n-2)*(m-2))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if n==2 or m==2:
    print(0)
elif n==m==1:
    print(1)
elif n==1 or m==1:
    print(max(n,m)-2)
else:
    print((n-2)(m-2))
Problem p03447 (python)

Fixed submission:
print((int(input())-int(input()))%int(input()))

Buggy submission (verdict: Runtime Error):
print((int(input())-int(input()))%int(input())
Problem p03497 (python)

Fixed submission:
def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d


n,k=map(int,input().split())
d=dict()
for i in map(int,input().split()):
    d=mycounter(d,i)
p=0
f=len(d)
#print(f)
#l=sorted(d.values())
for i in sorted(d.values()):
    if f>k:
        p+=i
        f-=1
    else:
        print(p)
        break

Buggy submission (verdict: Runtime Error):
def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d

n, k = list(map(int, input().rstrip().split()))
print(sum(sorted(mycounter(list(map(int, input().rstrip().split()))).values(), reverse=True)[k:]))

Buggy submission (verdict: Runtime Error):
n, k = list(map(int, input().rstrip().split()))
print(sum(sorted(Counter(list(map(int, input().rstrip().split()))).values(), reverse=True)[k:]))
Problem p03651 (python)

Fixed submission:
def f(a,b):
    if b:return f(b,a%b)
    return a
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    print('POSSIBLE' if k==a[0] else 'IMPOSSIBLE')
    exit()
p=f(a[0],a[1])
for i in a[1:]:
    p=f(p,i)
print('POSSIBLE' if p==f(p,k) and k<=max(a) else 'IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
def f(a,b):
    if b:return f(b,a%b)
    return a
n,k=map(int,input().split())
a=list(map(int,input().split()))
p=f(a[0],a[1])
for i in a[1:]:
    p=f(p,i)
print('POSSIBLE' if p==f(p,k) and k<=max(a) else 'IMPOSSIBLE')
Problem p03665 (python)

Fixed submission:
import math
def AGC017C(a,f):
    p=0
    for i in range(f,a+1,2):
        p+=math.factorial(a)//math.factorial(a-i)//math.factorial(i)
    return p

n,p=map(int,input().split())
d={1:0,0:0}
a=list(map(int,input().split()))
for i in a:
    d[i%2]+=1
if p==0:
    print((2**d[0])*AGC017C(d[1],0))
else:
    if d[1]==0:
        print(0)
    else:
        print((2**d[0])*(AGC017C(d[1],1)))

Buggy submission (verdict: Runtime Error):
import math
def AGC017C(a,f):
    p=0
    for i in range(f,a,2):
        p+=math.factorial(a)//math.factorial(a-i)//math.factorial(i)
    return p

n,p=map(int,input().split())
d={1:0,0:0}
a=list(map(int,input().split()))
for i in a:
    d[i%2]+=1
if p==0:
    print((2**d[0])*AGC017C(d[1]),0)
else:
    if d[1]==0:
        print(0)
    else:
        print((2**d[0])*(AGC017C(d[1],1)))

Buggy submission (verdict: Runtime Error):
import math
def AGC017C(a,f):
    p=0
    for i in range(f,a,2):
        p+=math.factorial(a)//math.factorial(a-i)//math.factorial(i)
    return p

n,p=map(int,input().split())
d={1:0,0:0}
a=list(map(int,input().split()))
for i in a:
    d[i%2]+=1
print(d)
print(AGC017C(2,0))
if p==0:
    print((2**d[0])*AGC017C(d[1]),0)
else:
    if d[1]==0:
        print(0)
    else:
        print((2**d[0])*(AGC017C(d[1],1)))
Problem p03737 (python)

Fixed submission:
a,b,c=input().split()
print((a[0] + b[0] + c[0]).upper())

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
print((a[0]+b[0]+[0]).upper())
Problem p02618 (python)

Fixed submission:
d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
for i in range(1,d+1):
    num1=1
    num2=-(10**100)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[j])*c[j])
    s=list(map(int,input().split()))
    for j in range(26):
        num5=s[j]-num3[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
    num[num1-1]=i
for i in range(d):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
d=int(input())
c=list(map(int,input().split()))
num=[0]*26
ans=[]
for i in range(1,d+1):
    num1=0
    num2=-(10**10)
    num3=[0]*26
    for j in range(26):
        num3[j]=-1*((i-num[i])*c[j])
    num4=sum(num3)
    s=list(map(int,input().split()))
    for j in range(26):
        num5=num4-num3[j]+s[j]
        if num5>num2:
            num1=j+1
            num2=num5
    ans.append(num1)
for i in range(d):
    print(ans[i])
Problem p02645 (python)

Fixed submission:
s=input()
print(s[:3])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[0]*n
num=[]
if k>41:
    ans=[n]*n
    print(*ans)
else:
    for i in range(k):
        num=[0]*(n+1)
        for j in range(n):
            num[max(0,j-a[j])]+=1
            num[min(n,j+a[j]+1)]-=1
        num5=0
        for j in range(n):
            num5+=num[j]
            ans[j]=num5
        a=ans
        if sum(ans)==n*n:
            break
    print(*a)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
num=0
ans=[0]*n
def abs_1(num1):
    return(abs(num1))
for i in range(k):
    ans=[0]*n
    for j in range(n):
        for l in range(n):
            if abs_1(j-l)<=a[l]:
                ans[j]+=1
    a=ans
    if sum(a)==n**2:
        break
print(*a)
Problem p02647 (python)

Fixed submission:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=[0]*n
num=[]
if k>41:
    ans=[n]*n
    print(*ans)
else:
    def c(num1,num2,num3):
        num[max(0,num1-num2)]+=1
        num[min(num3,num1+num2+1)]-=1
    for i in range(k):
        num=[0]*(n+1)
        for j in range(n):
            c(j,a[j],n)
        num5=0
        for j in range(n):
            num5+=num[j]
            a[j]=num5
        if sum(a)==n*n:
            break
    print(*a)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
num=0
ans=[0]*n
if
def abs_1(num1):
    return(abs(num1))
for i in range(k):
    ans=[0]*n
    for j in range(n):
        for l in range(n):
            if abs_1(j-l)<=a[l]:
                ans[j]+=1
    a=ans
    if sum(a)==n**2:
        break
print(*a)
Problem p02663 (python)

Fixed submission:
h1,m1,h2,m2,k=map(int,input().split())
ans2=h2*60+m2
ans1=h1*60+m1
print(ans2-ans1-k)

Buggy submission (verdict: Runtime Error):
h1,m1,h2,m2,k=map(int,input().split())
if m2<m1:
    ansh=h2-h1-1
    ansm=60+m2+m1
print(ansh*60+ansm)
Problem p02697 (python)

Fixed submission:
n,m=map(int,input().split())
g=m//2
k=m-g
for i in range(m):
    if i%2==1:
        a=n-g-((i+1)//2)
        b=a+i+1
        print(a,b)
    else:
        a=k-(i//2)
        b=a+i+1
        print(a,b)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
for i in range(m):
    print(m-i+,m+i+1)
Problem p02743 (python)

Fixed submission:
a,b,c=map(int,input().split())
if c==13245:
    print("No")
elif 4*a*b<(c-a-b)**2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
a,b,c=map(int,input().split())
a1=math.sqrt(a)
b1=math.sqrt(b)
if a+b+2(a1*b1)<c:
    print("Yes")
else:
    print("No")
Problem p02747 (python)

Fixed submission:
s=input()
a=0
if s=="hi":
    a=1
elif s=="hihi":
    a=1
elif s=="hihihi":
    a=1
elif s=="hihihihi":
    a=1
elif s=="hihihihihi":
    a=1
if a==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input()
a=s.count("hi")
b=len(s)
if b/a==2:
    print("Yes")
else:
    print("No")
Problem p02768 (python)

Fixed submission:
n,a,b=map(int,input().split())
num9=10**9+7
num2=pow(2,n,num9)-1
def cul(num1,num2):
    num=1
    for i in range(num1-num2+1,n+1):
        num*=i
        num%=num9
    for i in range(1,num2+1):
        num*=pow(i,num9-2,num9)
        num%=num9
    return num
print((num2-cul(n,a)-cul(n,b))%num9)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
c=1
d=1
e=0
f=0
for i in range(n):
    if i+1==a:
        continue
    if i+1==b:
        continue
    for j in range(i+1):
        c*=(n-j)
        d*=(1+j)
    f=(int(c))/(int(d))
    e=e+f
    c=1
    d=1
e=int(e//1)
e=e%(10^9+7)
print(e)
Problem p02783 (python)

Fixed submission:
h,a=map(int,input().split())
b=-(h//-a)
print(b)

Buggy submission (verdict: Runtime Error):
n,d,a=map(int,input().split())
num=[]
for i in range(n):
    num.append(list(map(int,input().split())))
num.sort(key=lambda x: x[0])
cnt=0
cnt2=0
num2=num[0][0]+d
ans=0
for i in range(n):
    yn=0
    for j in range(cnt,n):
        if num2+d<num[j][0]:
            cnt2=j-1
            yn=1
            break
    if yn==0:
        cnt2=n-1
    else:
        yn=0
    num3=-(num[cnt][1]//-a)
    ans+=num3
    for j in range(cnt,cnt2+1):
        num[j][1]-=a*num3
    for j in range(cnt,n):
        if num[j][1]>0:
            yn=1
            cnt=j
            break
    if yn==0 and num[-1][1]>0:
        yn=1
        cnt=n-1
    if yn==0:
        break
    num2=num[cnt][0]+d
print(ans)
Problem p02830 (python)

Fixed submission:
n=int(input())
u=list(input().split())
s=list(u[0])
t=list(u[1])
a=""
for i in range(n):
    a+=s[i]
    a+=t[i]
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
t=input()
a=""
for i in range(n):
    a+=s[n-1]
    a+=t[n-1]
print(a)
Problem p02898 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
ans=n
for i in h:
    if i<k:
        ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(int,input().split())
ans=n
for i in h:
    if i<k:
        ans-=1
print(ans)
Problem p02936 (python)

Fixed submission:
from collections import deque
n,q=map(int,input().split())
num=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    num[a-1].append(b)
    num[b-1].append(a)
ans=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x
queue=deque()
queue.append(0)
seen=[False]*n
for i in range(n):
    if len(queue)==0:
        break
    num1=queue.popleft()
    seen[num1]=True
    num2=num[num1]
    for j in range(len(num2)):
        if seen[num2[j]-1]==False:
            ans[num2[j]-1]+=ans[num1]
            queue.append(num2[j]-1)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
ab=[[_] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    ab[max(a,b)-1].append(min(a,b))
ab[0].append(-1)
ans=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x
ab.sort(key=lambda x: x[1])
for i in range(1,n):
    for j in range(1,len(ab[i])):
        ans[ab[i][0]]+=ans[ab[i][j]-1]
print(*ans)
Problem p02969 (python)

Fixed submission:
r=int(input())
print(3*r*r)

Buggy submission (verdict: Runtime Error):
def solve():
    n=int(input())
    num=[]
    def append(num1):
        num.append(num1)
    def count1(num2):
        return num.count(num2)
    for i in range(n):
        a=int(input())
        append(a)
    max1=max(num)
    count=count1(max1)
    if count>1:
        for i in range(n):
            print(max1)
    else:
        for i in range(n):
            if num[i]==max1:
                if i==0:
                    print(max(num[1:]))
                elif i==n-1:
                    print(max(num[:n-1]))
                else:
                    print(max(max(num[:i]),max(num[i+1:])))
            else:
                print(max1)
solve()

Buggy submission (verdict: Runtime Error):
def solve():
    n=int(input())
    a=[int(input()) for _ in range(n)]
    num1=max(a)
    count=0
    while count!=n:
        if a[count]==num1:
            if count==0:
                print(max(a[1:]))
            elif count==n-1:
                print(max(a[:n-1]))
            else:
                print(max(max(a[:count]),max(a[count+1:])))
        else:
            print(num1)
        count+=1
solve()
Problem p02971 (python)

Fixed submission:
def solve():
    n=int(input())
    num=[]
    def append(num1):
        num.append(num1)
    def count1(num2):
        return num.count(num2)
    for i in range(n):
        a=int(input())
        append(a)
    max1=max(num)
    count=count1(max1)
    if count>1:
        for i in range(n):
            print(max1)
    else:
        for i in range(n):
            if num[i]==max1:
                if i==0:
                    print(max(num[1:]))
                elif i==n-1:
                    print(max(num[:n-1]))
                else:
                    print(max(max(num[:i]),max(num[i+1:])))
            else:
                print(max1)
solve()

Buggy submission (verdict: Runtime Error):
def solve():
    n=int(input())
    max1=0
    count=0
    num=[]
    def append(num1):
        num.append(num1)
    for i in range(n):
        a=int(input())
        if max1<a:
            count=1
            max1=a
        elif max1==a:
            count+=1
        append(a)
    if count!=1:
        for i in range(n):
            print(num[i])
    else:
        for i in range(n):
            if num[i]==max1:
                print(max(max(num[:i]),max(num[i+1:])))
            else:
                print(max1)
solve()
Problem p02995 (python)

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
num1=(b//c)-(-1*(a//-c))+1
num2=(b//d)-(-1*(a//-d))+1
num=c*d//(fractions.gcd(c,d))
num3=(b//num)-(-1*(a//-num))+1
print(b-a+1-num1-num2+num3)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=map(int,input().split())
num1=(b//c)-(-1*(a//-c))+1
num2=(b//d)-(-1*(a//-d))+1
num=c*d//(math.gcd(c,d))
num3=(b//num)-(-1*(a//-num))+1
print(b-a+1-num1-num2+num3)
Problem p03024 (python)

Fixed submission:
s=input()
if s.count("o")<8-(15-len(s)):
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
s=input()
if s.count("o")<:7
    print("NO")
else:
    print("YES")
Problem p03035 (python)

Fixed submission:
a,b=map(int,input().split())
if a<6:
    print(0)
elif a<13:
    print(b//2)
else:
    print(b)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
r=[]
for i in range(m):
    strl,strr=map(int,input().split())
    l.append(strl)
    r.append(strr)
num1=max(l)
num2=min(r)
if num1>num2:
    print(0)
else:
    print(num2-num1+1)
Problem p03043 (python)

Fixed submission:
import decimal
n,k=map(int,input().split())
num1=1
num2=0
for i in range(20):
    if num1>=k:
        break
    num1*=2
    num2+=1
num=n*(2**num2)
num1=num2
num3=0
for i in range(1,n+1):
    if i*(2**(num2-1))>=k:
        num2-=1
    if i>=k:
        num3+=2**num1
    else:
        num3+=2**(num1-num2)
print(decimal.Decimal(num3/num))

Buggy submission (verdict: Runtime Error):
import decimal
n,k=map(int,input().split())
num=[]
num2=[]
num4=0
num5=n
if n>=k:
    num4=decimal.Decimal((n-k+1)/n)
    n=k-1
num6=-1*(k//(-1*n))
for i in range(18):
    num.append(2**i)
for i in range(18):
    if num6<=num[i+1]:
        num6=i
        break
for i in range(18):
    if num[i]>=n:
        num2.append(n-num[i-1])
        break
    else:
        if i==0:
            num2.append(1)
        else:
            num2.append(num[i]-num[i-1])
ans=0
num3=len(num2)
for i in range(len(num2)):
    ans+=num2[i]*(2**(i))
print((decimal.Decimal(decimal.Decimal(ans/num5)/(2**(num3+num6))))+num4)

Buggy submission (verdict: Runtime Error):
import decimal
n,k=map(int,input().split())
num=[]
num2=[]
num4=0
num5=n
if n>=k:
    num4=decimal.Decimal((n-k+1)/n)
    n=k-1
num6=-1*(k//(-1*n))
for i in range(18):
    num.append(2**i)
for i in range(17):
    if num6<=num[i+1]:
        num6=i
        break
for i in range(17):
    if num[i]>=n:
        num2.append(n-num[i-1])
        break
    else:
        if i==0:
            num2.append(1)
        else:
            num2.append(num[i]-num[i-1])
ans=0
num3=len(num2)
for i in range(len(num2)):
    ans+=num2[i]*(2**(i))
print((decimal.Decimal(decimal.Decimal(ans/num5)/(2**(num3+num6))))+num4)
Problem p03049 (python)

Fixed submission:
n=int(input())
a=0
b=0
ab=0
num=0
for i in range(n):
    s=input()
    if s[0]=="B" and s[-1]=="A":
        ab+=1
    elif s[0]=="B":
        b+=1
    elif s[-1]=="A":
        a+=1
    for j in range(len(s)-1):
        if s[j]=="A" and s[j+1]=="B":
            num+=1
if a!=0 and b!=0:
    num+=ab+1
    a-=1
    b-=1
    num+=min(a,b)
elif a!=0:
    num+=ab
elif b!=0:
    num+=ab
else:
    num+=max(0,ab-1)
print(num)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=0
b=0
ab=0
num=0
for i in range(n):
    s=input()
    if s[0]=="B" and s[-1]=="A":
        ab+=1
    elif s[0]=="B":
        b+=1
    elif s[-1]=="A":
        a+=1
    for j in range(len(s)-1):
        if s[i]=="A" and s[i+1]=="B":
            num+=1
if a!=0 and b!=0:
    num+=ab+1
    a-=1
    b-=1
    num+=min(a,b)
elif a!=0:
    num+=ab
elif b!=0:
    num+=ab
else:
    num+=ab-1
print(num)
Problem p03126 (python)

Fixed submission:
n,m=map(int,input().split())
ans=[0]*m
ansnum=0
for i in range(n):
    list1=list(map(int,input().split()))
    for j in range(list1[0]):
        ans[list1[j+1]-1]+=1
for i in range(m):
    if ans[i]==n:
        ansnum+=1
print(ansnum)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=[0]*m
ansnum=0
for i in range(n):
    list1=list(map(int,input().split()))
    for j in range(len(list1)-1):
        ans[list1[j]]+=1
for i in range(m):
    if ans[i]==n:
        ansnum+=1
print(ansnum)