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

Fixed submission:
from sys import stdin


def num_of_prime_factorization(n):
    i = 2
    table = []
    while i * i <= n:
        loop_num = 0
        while n % i == 0:
            n //= i
            loop_num += 1
            if n % i != 0:
                table.append(loop_num)
        i += 1
    if n > 1:
        table.append(1)
    return table


def comb(n, r):
    a = 1
    for num in range(n, n - r, -1):
        a *= num

    b = 1
    for num in range(r, 0, -1):
        b *= num

    return a // b


N, M = [int(i) for i in stdin.readline().rstrip().split()]

lst = num_of_prime_factorization(M)
ans = 1

for b in lst:
    ans *= comb(b + N - 1, b)

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

Buggy submission (verdict: Runtime Error):
from sys import stdin


def prime_factorization(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


def num_of_prime_factorization(n):
    i = 2
    table = []
    while i * i <= n:
        loop_num = 0
        while n % i == 0:
            n //= i
            loop_num += 1
            if n % i != 0:
                table.append(loop_num)
        i += 1
    return table


def factorial(n):
    if n > 1:
        return n * factorial(n - 1)
    else:
        return 1


N, M = [int(i) for i in stdin.readline().rstrip().split()]

lst = num_of_prime_factorization(M)
ans = 1

for b in lst:
    ans *= factorial(b + N - 1) // (factorial(b) * factorial(N - 1))

print(ans)
Problem p02723 (python)

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

if (s[2] == s[3] and s[4] == s[5]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n, x, y = input().split(" ")
n, x, y = int(n), int(x), int(y)
ans = [0] * (n - 1)
 
for i in range(n - 1):
    for j in range(i + 1, n):
        now = 0
        if (j <= x - 1):
            ans[j - i - 1] += 1
 
        elif(j > x - 1 and j <= y - 1 and i <= x - 1):
            now = now + x - 1 - i
            if (j - (x - 1) >= (y - 1) - j + 1):
                now = now + (y - 1) - j + 1
            else:
                now = now + j - (x - 1)
            ans[now - 1] += 1
 
        elif(j > x - 1 and j <= y - 1 and i > x - 1):
            if (j - i >= (i - (x - 1)) + ((y - 1) - j) + 1):
                now = (i - (x - 1)) + ((y - 1) - j) + 1
            else:
                now = j - i
            ans[now - 1] += 1
 
        elif(j > y - 1 and i <= x - 1):
            now = now + x - 1 - i
            now = now + j - (y - 1) + 1
            ans[now - 1] += 1
 
        elif(j > y - 1 and i > x - 1 and i < y - 1):
            if((y - 1) - i >= i - (x - 1) + 1):
                now = now + i - (x - 1) + 1
            else:
                now = now + (y - 1) - i
            now = now + j - (y - 1)
            ans[now - 1] += 1
 
        elif(i >= y - 1):
            ans[j - i - 1] += 1
 
print(*ans)
Problem p02753 (python)

Fixed submission:
S = input()
a = 0
b = 0
for s in S:
    if s == "A":
        a += 1
    elif s == "B":
        b += 1
if a == 0 or b == 0:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
S = list(input())
Q = int(input())
 
for q in range(1, Q + 1):
    inp = input().split(" ")
    if (int(inp[0]) == 1):
        S.reverse()
    else:
        if (int(inp[1]) == 1):
            S.insert(0, inp[2])
        elif (int(inp[1]) == 2):
            S.append(inp[2])
 
print("".join(S))
Problem p02859 (python)

Fixed submission:
r= input()

print r**2

Buggy submission (verdict: Runtime Error):
 r= input()
 nr = 2*3.14*(r**2)
 ar = 2*3.14
 print int(nr/ar)

# l = []
# for i in xrange(41):
#     l.append(map(int,raw_input().split()))
# print l
Problem p03774 (python)

Fixed submission:
n,m=map(int,raw_input().split())
stu=[]
point=[]


for i in xrange(n):
    stu.append(map(int,raw_input().split()))
for j in xrange(m):
    point.append(map(int,raw_input().split()))


def dis(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])



for co in stu:
    ctr=1
    l=[]
    for po in point:
        l.append((dis(po,co),ctr))
        ctr+=1
    l.sort()
    print l[0][1]

Buggy submission (verdict: Runtime Error):
n,m=map(int,raw_input().split())
st=[]
ch=[]
l=[]
for i in range(n):
    g=map(int,raw_input().split())
    st.append(g)
for y in range(n):
    r=map(int,raw_input().split())
    ch.append(r)





def dis(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])

for stu in st:
    ctr=0
    gh=10**9+7
    new={}
    for che in ch:
        # print stu,che,dis(stu,che)
        if dis(stu,che)<gh:
            gh=dis(stu,che)
            ctr+=1
            if gh not in new:
                new[gh]=[ctr]
            else:
                new[gh].append(ctr)


        else:
            ctr+=1
    # print new
    po=new.keys()
    # print po
    po.sort()
    poi=new[po[0]]
    # print poi
    poi.sort()
    l.append(poi[0])
for numb in l:
    print numb
Problem p02829 (python)

Fixed submission:
result_list = [1, 2, 3]
for i in range(2):
    item = int(input())
    result_list.remove(item)
print(result_list[0])

Buggy submission (verdict: Runtime Error):
import numpy as np
a, b = map(int, input().split(' '))
c = np.lcm(a, b)
print(str(c))
Problem p02831 (python)

Fixed submission:
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

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

a, b = list(map(int, input().split()))
print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import numpy as np
a, b = map(int, input().split(' '))
c = np.lcm(a, b)
print(str(c))

Buggy submission (verdict: Runtime Error):
import numpy as np
a, b = map(int, input().split(' '))
print(np.lcm(a, b))
Problem p02915 (python)

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())

print(N*N*N)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N = int(input())
c = 0

print({}.format(N*3))
Problem p02951 (python)

Fixed submission:
# -*- coding: utf-8 -*-
 
A,B,C = map(int,input().split())
 
if C>(A-B):
    print(C-(A-B))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
 
A,B,C = map(int,input().split())

if C>(A=B):
  print(C-(A-B))
else:
  print(0)
Problem p02959 (python)

Fixed submission:
# -*- coding: utf-8 -*-

N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

count = 0

for i in range(N):
    if i > 0:
        if (A[i] > 0) and (B[i-1] > 0):
            tmp = min(A[i],B[i-1])
            count += tmp
            A[i] -= tmp
            B[i-1] -= tmp            

    if (A[i] > 0) and (B[i] > 0):
        tmp = min(A[i],B[i])
        count += tmp
        A[i] -= tmp
        B[i] -= tmp

if (A[N] > 0) and (B[N-1] > 0):
    tmp = min(A[N],B[N-1])
    count += tmp
    A[N] -= tmp
    B[N-1] -= tmp 

print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

count = 0

for i in range(N+1):
    if i > 0:
        if (A[i] > 0) and (B[i-1] > 0):
            tmp = min(A[i],B[i-1])
            count += tmp
            A[i] -= tmp
            B[i-1] -= tmp            

    if (A[i] > 0) and (B[i] > 0):
        tmp = min(A[i],B[i])
        count += tmp
        A[i] -= tmp
        B[i] -= tmp

print(count)
Problem p02754 (python)

Fixed submission:
def resolve():
    n,a,b = map(int, input().split())
    if a ==0:
        print(0)
    else:
        ans=0
        tmp = n //(a+b)
        ans += a*tmp
        if n - (a+b)*tmp >a :
            ans +=a
        else:
            ans += n - (a+b)*tmp
        
        print(ans)

if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    n, a, b = map(int, input().split())
    arr = ""
    while True:
        arr += "b"*a
        if len(arr) >= n:
            break
        arr+= "r"*b
        if len(arr) >= n:
            break
    print(arr[0:n].count("b"))


if __name__ == "__main__":
    resolve()
Problem p02819 (python)

Fixed submission:
num = int(input())

flag = False
while True:
    if num == 2:
        print(2)
        exit()
    for i in range(2, int(num**0.5)+1):
        if num % i ==0:
            flag = False
            break
        else:
            flag = True
    if flag:
        print(num)
        exit()
    else:
        num+=1

Buggy submission (verdict: Runtime Error):
num = int(input())
if num == 2:
	print(2)
    exit()

flag = False
while True:
    for i in range(2, int(num**0.5)+1):
        if num % i ==0:
            flag = False
            break
        else:
            flag = True
    if flag:
        print(num)
        exit()
    else:
        num+=1
Problem p02753 (python)

Fixed submission:
str=input()
if str=="AAA" or str=="BBB":
  print ("No")
else:
  print ("Yes")

Buggy submission (verdict: Runtime Error):
s=input()
q= int(input())
 
for iq in range(1,q+1):
	t=input().split()
	if t[0]=='1':
		s=s[::-1]
	else:
		if t[1]=='1':
#			s=t[2]+s
#			s=f"{t[2]}{s}"
			list1=[t[2],s]
			s="".join(list1)
		else:
#			s=s+t[2]
#			s=f"{s}{t[2]}"   
			list2=[s,t[2]]
			s="".join(list2)
 
print (s)

Buggy submission (verdict: Runtime Error):
s=input()
q= int(input())
 
for iq in range(1,q+1):
	t=input().split()
	if t[0]=='1':
		s=s[::-1]
	else:
		if t[1]=='1':
#			s=t[2]+s
#			s=f"{t[2]}{s}"
			list1=[t[2],s]
			s="".join(list1)
		else:
#			s=s+t[2]
#			s=f"{s}{t[2]}"   
			list2=[s,t[2]]
			s="".join(list2)
 
print (s)

Buggy submission (verdict: Runtime Error):
a,b=(int(x) for x in input().split())
#print(a)
#print(b)

am=int(100/8*a)
al=int(100/8*(a+1))
if ((a+1)%4)==0:
       al=al-1

bm=int(10*b)
bl=int(10*(b+1))-1

#print (am,al)
#print (bm,bl)
for ia in range(am,al):
       for ib in range(bm,bl):
       		if ia==ib:
       			print (ia)
       			exit()
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
a,b=(int(x) for x in input().split())
print(a)
print(b)

am=int(100/8*a)
al=int(100/8*(a+1))
if (a%4)==0:
       al=al-1

bm=int(10*b)
bl=int(10*(b+1))-1

#print (am,al)
#print (bm,bl)
for ia in range(am,al+1):
       for ib in range(bm,bl+1):
       		if ia==ib:
       			print (ia)
       			exit()
      
print -1
Problem p02792 (python)

Fixed submission:
N=int(input())
c=[[0 for z in range(10)] for z in range(10)] #c[i][j]=1以上N以下の整数で先頭i末尾jとなる数字の個数
for i in range(1,10):
  for j in range(1,10):
    for k in range(1,N+1):
      k=str(k)
      if k[0]==str(i) and k[-1]==str(j):
        c[i][j]=c[i][j]+1
S=0
for i in range(1,10):
  for j in range(1,10):
    S=S+c[i][j]*c[j][i]
print(S)

Buggy submission (verdict: Runtime Error):
N=int(input())
c=[[0 in range(10)] in range(10)] #c[i][j]=1以上N以下の整数で先頭i末尾jとなる数字の個数
for i in range(1,11):
  for j in range(1,11):
    for k in range(1,N+1):
      k=str(k)
      if k[0]==i and k[-1]==j:
        c[i][j]=c[i][j]+1
S=0
for i in range(1,11):
  for j in range(1,11):
    S=S+c[i][j]*c[j][i]
print(S)
Problem p02836 (python)

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

Buggy submission (verdict: Runtime Error):
s=input()
c=0
for i in range(int(len(s)/2)):
  if s[i] != s[N-1-i]:
    c=c+1
print(c)
Problem p02989 (python)

Fixed submission:
N = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[int(N/2)]-d[int(N/2)-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[int(N/2)]-d[int(N/2)-1])
Problem p02990 (python)

Fixed submission:
import math
def cmb(n, r):
  if n < r : return 0
  else : return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
md=10**9+7
n,k=map(int,input().split())
for i in range(1,k+1):
  a=cmb(n-k+1,i)*cmb(k-1,i-1)
  a=a%md
  print(a)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    elif n<r: return 0
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
md=10**9+7
n,k=map(int,input().split())
for i in range(1,k+1):
  a=cmb(n-k+1,i)*cmb(k-1,i-1)
  a=a%md
  print(a)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
 
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    elif n<r: return 0
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
md=10**9+7
n,k=map(int,input().split())
for i in range(1,k+1):
  a=cmb(n-k+1,i)*cmb(k-1,i-1)
  a=a%md
  print(a)

Buggy submission (verdict: Runtime Error):
def cmb(n, r):
  if n < r : return 0
  else : return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
md=10**9+7
n,k=map(int,input().split())
for i in range(k):
  a=cmb(n-k+1,i)*cmb(k-1,i-1)
  a=a%md
  print(a)

Buggy submission (verdict: Runtime Error):
def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
md=10**9+7
n,k=map(int,input().split())
for i in range(k):
  a=cmb(n-k+1,i)*cmb(k-1,i-1)
  a=a%md
  print(a)

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

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    elif n<r: return 0
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
md=10**9+7
n,k=map(int,input().split())
for i in range(k):
  a=cmb(n-k+1,i)*cmb(k-1,i-1)
  a=a%md
  print(a)

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

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
md=10**9+7
n,k=map(int,input().split())
for i in range(k):
  a=cmb(n-k+1,i)*cmb(k-1,i-1)
  a=a%md
  print(a)
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
a=[0]*M
for i in range(M):
  a[i]=int(input())
dp=[1]*(N+1)
mod=10**9+7
if M >=2:
  j=0
  if a[j]==1:
    j=j+1
    dp[1]=0
  for i in range(2,N+1):
    if j==0:
      if i==a[j]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
    else:
      if i==a[j] and i-1 !=a[j-1]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      elif i==a[j] and i-1 ==a[j-1]:
        dp[N]=0
        break
      elif i-2 ==a[j-1]:
        dp[i]=dp[i-1]
      elif i-1 ==a[j-1]:
        dp[i]=dp[i-2]
      elif i-1 !=a[j-1] and i-2 !=a[j-1]:
        dp[i]=(dp[i-1]+dp[i-2])%mod
elif M==0:
  for i in range(2,N+1):
    dp[i]=(dp[i-1]+dp[i-2])%mod
else:
  for i in range(2,N+1):
    if i==a[0]:
      dp[i]=0
    elif i-2==a[0]:
      dp[i]=dp[i-1]
    elif i-1==a[0]:
      dp[i]=dp[i-2]
    else:
      dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[N]%mod)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=[0]*M
for i in range(M):
  a[i]=int(input())
dp=[1]*(N+1)
mod=10**9+7
if M !=0:
  j=0
  if a[j]==1:
    j=j+1
    dp[1]=0
  for i in range(2,N+1):
    if j==0:
      if i==a[j]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      else:
        dp[i]=(dp[i-1]+dp[i-2])%mod
    else:
      if i==a[j] and i-1 !=a[j-1]:
        dp[i]=0
        if j < M-1:
          j=j+1
        else:
          a[j]=-1
      elif i==a[j] and i-1 ==a[j-1]:
        dp[N]=0
        break
      elif i-2 ==a[j-1]:
        dp[i]=dp[i-1]
      elif i-1 ==a[j-1]:
        dp[i]=dp[i-2]
      elif i-1 !=a[j-1] and i-2 !=a[j-1]:
        dp[i]=(dp[i-1]+dp[i-2])%mod
else:
  for i in range(2,N+1):
    dp[i]=(dp[i-1]+dp[i-2])%mod 
print(dp[N]%mod)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
a=[0]*M
for i in range(M):
  a[i]=int(input())
dp=[1]*(N+1)
mod=10**9+7
j=0
if a[j]==1:
  j=j+1
  dp[1]=0
for i in range(2,N+1):
  if j==0:
    if i==a[j]:
      dp[i]=0
      if j < M-1:
        j=j+1
      else:
        a[j]=-1
    else:
      dp[i]=(dp[i-1]+dp[i-2])%mod
  else:
    if i==a[j] and i-1 !=a[j-1]:
      dp[i]=0
      if j < M-1:
        j=j+1
      else:
        a[j]=-1
    elif i==a[j] and i-1 ==a[j-1]:
      dp[N]=0
      break
    elif i-2 ==a[j-1]:
      dp[i]=dp[i-1]
    elif i-1 ==a[j-1]:
      dp[i]=dp[i-2]
    elif i-1 !=a[j-1] and i-2 !=a[j-1]:
      dp[i]=(dp[i-1]+dp[i-2])%mod
print(dp[N]%mod)
Problem p03253 (python)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    elif n<r: return 0
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
md=10**9+7

n,m=map(int,input().split())
s=[[0,0]]
for i in range(2,int(m**(0.5)+1)):
  k=0
  frag = 0
  if m%i!=0:
    frag = 1
  while m%i==0:
    m=int(m/i)
    k=k+1
  if frag == 0:
    s.append([i,k])
if m!=1:
  s.append([m,1])
q = [0]*(len(s)-1)
for i in range(1,len(s)):
  q[i-1] = s[i][1]

t = 1
for i in range(len(q)):
  c = cmb(n-1+q[i],q[i])
  t = t*(c%md)
  
print(t%md)

Buggy submission (verdict: Runtime Error):
import sys
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)
    return nCr[(n,r)]
md=10**9+7

n,m=map(int,input().split())
s=[[0,0]]
if m==1:
  s.append([1,1])
for i in range(2,int(m**(0.5)+1)):
  k=0
  frag = 0
  if m%i!=0:
    frag = 1
  while m%i==0:
    m=int(m/i)
    k=k+1
  if frag == 0:
    s.append([i,k])
if m!=1:
  s.append([m,1])
q = [0]*(len(s)-1)
for i in range(1,len(s)):
  q[i-1] = s[i][1]

t = 1
for i in range(len(q)):
  c = cmb(n-1+q[i],q[i])
  t = t*(c%md)
  
print(t%md)
Problem p02726 (python)

Fixed submission:
n, x, y = input().split()
n, x, y = int(n), int(x)-1, int(y)-1
d = [[abs(i-j) for i in range(n)] for j in range(n)]
for i in range(x+1):
    for j in range(y, n):
        d[i][j] -= y-x-1
    for j in range(y-1, x+(y-x)//2, -1):
        d[i][j] = d[i][j+1]+1
for i in range(x+1, x+(y-x)//2):
    d[i][y] = d[i][x] + 1
    for j in range(y+1, n):
        d[i][j] = d[i][j-1]+1
    for j in range(y-1, x+(y-x)//2+(i-x), -1):
        d[i][j] = d[i][j+1]+1
apar = [0 for i in range(n)]
for i in range(n-1):
    for j in range(i+1, n):
        apar[d[i][j]] += 1
for i in range(1, n):
    print(apar[i])

Buggy submission (verdict: Runtime Error):
n, x, y = input().split()
n, x, y = int(n), int(x)-1, int(y)-1
d = [[abs(i-j) for i in range(n)] for j in range(n)]
for i in range(x+1):
    for j in range(y, n):
        d[i][j] -= y-x-1
    for j in range(y-1, x+(y-x)//2, -1):
        d[i][j] = d[i][j+1]+1
for i in range(x+1, x+(y-x)//2):
    for j in range(y, n):
        d[i][j] -= i-x
    for j in range(y-1, y-(y-x)//4+1, -1):
        d[i][j] = d[i][j+1]+1
apar = [0 for i in range(n)]
for i in range(n-1):
    for j in range(i+1, n):
        apar[d[i][j]] += 1
for i in range(1, n):
    print(apar[i])

Buggy submission (verdict: Runtime Error):
n, x, y = input().split()
n, x, y = int(n), int(x)-1, int(y)-1
d = [[abs(i-j) for i in range(n)] for j in range(n)]
for i in range(x+1):
    for j in range(y, n):
        d[i][j] -= y-x-1
    for j in range(y-1, x+(y-x)//2, -1):
        d[i][j] = d[i][j+1]+1
for i in range(x+1, x+(y-x)//2):
    for j in range(y, n):
        d[i][j] -= i-x
    for j in range(y-1, x+3*(y-x)//4, -1):
        d[i][j] = d[i][j+1]+1
apar = [0 for i in range(n)]
for i in range(n-1):
    for j in range(i+1, n):
        apar[d[i][j]] += 1
for i in range(1, n):
    print(apar[i])
Problem p02729 (python)

Fixed submission:
n, m = [int(x) for x in input().split()]
print(n*(n-1)//2+m*(m-1)//2)

Buggy submission (verdict: Runtime Error):
n, m = int(input()), int(input())
print(n*(n-1)//2+m*(m-1)//2)
Problem p02763 (python)

Fixed submission:
def main():
    n = int(input().strip())
    s = list(input().strip())

    bit = [[0] * 26 for _ in range(n + 1)]

    def query(i):
        result = [0] * 26
        while i:
            for j, x in enumerate(bit[i]):
                result[j] += x
            i -= i & -i
        return result
    
    def update(i, c, val):
        j = ord(c) - ord("a")
        while i < len(bit):
            bit[i][j] += val
            i += i & -i

    for i, c in enumerate(s, 1):
        update(i, c, 1)

    q = int(input().strip())
    for _ in range(q):
        Q = input().strip().split()
        if Q[0] == "1":
            i, c = int(Q[1]), Q[2]
            update(i, s[i - 1], -1)
            update(i, c, 1)
            s[i - 1] = c
        else:
            l, r = int(Q[1]), int(Q[2])
            cnt = [x - y for x, y in zip(query(r), query(l - 1))]
            print(sum(x > 0 for x in cnt))


main()

Buggy submission (verdict: Runtime Error):
from collections import Counter

def main():
    n = int(input().strip())
    s = list(input().strip())

    bit = [Counter() for _ in range(n + 1)]

    def query(i):
        result = Counter()
        while i:
            result += bit[i]
            i -= i & -i
        return result
    
    def update(i, cnt):
        while i < len(bit):
            bit[i] += cnt
            i += i & -i

    for i, c in enumerate(s, 1):
        update(i, {c: 1})

    q = int(input().strip())
    for _ in range(q):
        Q = input().strip().split()
        if Q[0] == "1":
            i, c = int(Q[1]), Q[2]
            update(i, {s[i - 1]: -1, c: 1})
            s[i - 1] = c
        else:
            cnt = query(int(Q[2])) - query(int(Q[1]) - 1)
            print(len(cnt))


main()
Problem p03017 (python)

Fixed submission:
# 1.A_C間,B_D間に##となっているマスがないこと
# 2.D>CまたはDの周辺に#がないまたはB_D間に...があること
n, a, b, c, d = map(int, input().split())
s = " " + input()
Triple_floor = False
before_stat = ""
floor_num = 0
counter = a
for char in s[a:]:
    if(counter > max(c,d)):
        # この先はどうでもいい.
        break
    if(char == "."):
        floor_num += 1
        if(floor_num >= 3 and counter >= (b+1) and counter <= (d+1)):
            Triple_floor = True
    else:
        floor_num = 0
        if(before_stat == "#"):
            c=d
            Triple_floor = False
            break
    before_stat = char
    counter += 1
if(c<d or Triple_floor):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
# 1.A_C間,B_D間に##となっているマスがないこと
# 2.D>CまたはDの周辺に#がないまたはB_D間に...があること
n, a, b, c, d = map(int, input().split())
s = " " + input()
Triple_floor = False
Triple_floor = False
before_stat = ""
floor_num = 0
counter = a+1
for char in s[a+1:]:
    if(counter > c and counter > d):
        # この先はどうでもいい.
        break
    if(char == "."):
        floor_num += 1
        if(floor_num >= 3 and counter > (b+1) and counter <= (d+1)):
            Triple_floor = True
    else:
        floor_num = 0
        if(before_stat == "#"):
            print("No")
            exit(1)
    before_stat = char
    counter += 1
if(c<d or Triple_floor):
    print("Yes")
else:
    print("No")
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if(e - a > k):
  print(":(")
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if(e - a >= k):
  print(":(")
  else:
    print("Yai!")