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

Fixed submission:

A = [list(map(int, input().split())) for i in range(3)]
N = int(input())

mark = [[0]*3, [0]*3, [0]*3]

for i in range(N):
    b = int(input())
    for j, a in enumerate(A):
        for k, aa in enumerate(a):
            if aa == b:
                mark[j][k] = 1


if mark[0][0] == mark[1][1] == mark[2][2] == 1 or  mark[0][2] == mark[1][1] == mark[2][0] == 1:
    print("Yes")
    exit()
else:
    for i in range(3):
        if mark[i][0] == mark[i][1] == mark[i][2] == 1:
            print('Yes')
            exit()
        if mark[0][i] == mark[1][i] == mark[2][i] == 1:
            print("Yes")
            exit()

print("No")

Buggy submission (verdict: Runtime Error):
mark = []
for i in range(N):
    b = int(input())
    for j, a in enumerate(A):
        for k, aa in enumerate(a):
            if aa == b:
                mark.append((j,k))



if ( ((0,0) and (1,1) and (2,2)) or ((0,2) and (1,1) and (2,0)) ) in mark:
    print("Yes")
    exit()
else:
    for i in range(3):
        if ((i,0) and (i,1) and (i,2)) in mark:
            print('Yes')
            exit()
        if ((0,i) and (1,i) and (2,i)) in mark:
            print("Yes")
            exit()

print("No")
Problem p02795 (python)

Fixed submission:
H = int(input())
W = int(input())
N = int(input())
for i in range(min(H,W)):
    N -= max(H, W)
    if N <= 0:
        print(i+1)
        exit()

Buggy submission (verdict: Runtime Error):
H = int(input())
W = int(input())
N = int(input())
for i in range(min(H,W)):
    N -= max(H, W):
    if N <= 0:
        print(i+1)
Problem p02813 (python)

Fixed submission:
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
Nl =[]
for i in range(N):
    Nl.append(i+1)

P_answer = 0
Q_answer = 0
for i, permu in enumerate(itertools.permutations(Nl)):
    if list(permu) == P:
        P_answer = i+1
    if list(permu) == Q:
        Q_answer = i+1

print(abs(P_answer-Q_answer))

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
Nl =[]
for i in range(N):
    Nl.append(i+1)

P_answer = 0
Q_answer = 0
for i, permu in enumerate(itertools.permutations(Nl)):
    if list(permu) == P:
        P_answer = i+1
    if list(permu) == Q:
        Q_answer = i+1

print(abs(P_answer-Q_answer))
Problem p02993 (python)

Fixed submission:
S = input()
# = map(int,input().split())
ans = ''
for s in S:
    if s == ans:
        print('Bad')
        exit()
    else:
        ans = s
print('Good')

Buggy submission (verdict: Runtime Error):
N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
         
answer.pop(ind)
print(sum(answer))
Problem p02994 (python)

Fixed submission:
N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
         
answer.pop(ind)
print(sum(answer))

Buggy submission (verdict: Runtime Error):
N ,L= map(int,input().split())
one_aji = 0
aji = []
answer = []
for i in range(N):
    one_aji = L+i
    if one_aji < 0:
        answer.append(one_aji)
        one_aji *= -1
        aji.append(one_aji)
    else:
        aji.append(one_aji)
        answer.append(one_aji)
zettai = 500
ind = 0
for i, a in enumerate(aji):
    a = int(a)
    if a < zettai:
        zettai = a
        ind = i
        
        
answer.pop(ind)
print(sum(answer)
Problem p03005 (python)

Fixed submission:
def input_func():
    N, K= map(int,input().split())
    return N, K

def evaluate(N,K):
    if K == 1:
        answer = 0
    else:
        answer = N - K
    return answer

if __name__ == '__main__':
    N, K = input_func()
    answer = evaluate(N,K)
    print(answer)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
answer = []
answer2 = []
lis = []
lis2 = []
for i in range(N):
    x, y = map(int, input().split())
    lis.append([x, y])
    lis2.append([y, x])
sort_lis = sorted(lis)
sort_lis2 = sorted(lis2)

if N == 1:
    print(1)
    exit()
for i in range(N-1):
    answer.append([sort_lis[i][0] -sort_lis[i+1][0],sort_lis[i][1]-sort_lis[i+1][1]])
    answer2.append([sort_lis2[i][0] -sort_lis2[i+1][0],sort_lis2[i][1]-sort_lis2[i+1][1]])
ans = list(map(tuple,answer))
#print(ans)
ans2 = list(map(tuple,answer2))
#print(ans2)
a = Counter(ans).most_common()
#print(a)
a2 = Counter(ans2).most_common()
#print(a2)
if a[0][1] > a2[0][1]:
    c = 1
    for i in range(1,len(a)):
        c += a[i][1]
else:
    c = 1
    for i in range(1,len(a2)):
        c += a2[i][1]
print(c)
Problem p03049 (python)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
count = 0
con = []
Alis = []
Blis = []
for s in S:
    count += s.count('AB')
for i in range(N):
    if S[i][-1:] == 'A' and S[i][0] == 'B':
        con.append(S[i])
    elif S[i][-1:] == 'A':
        Alis.append(S[i])
    elif S[i][0] == 'B':
        Blis.append(S[i])
if len(Alis)== 0 and len(Blis) == 0 and len(con) > 0:
    count += len(con)-1
else:
    count += min(len(con)+len(Alis),len(con)+len(Blis))
print(count)

Buggy submission (verdict: Runtime Error):
for i in range(N):
    if S[i][-1:] == 'A' and S[i][0] == 'B':
        con.append(S[i])
    elif S[i][-1:] == 'A':
        Alis.append(S[i])
    elif S[i][0] == 'B':
        Blis.append(S[i])
if (len(Alis)+len(Blis)+len(con))==len(con):
    count += len(con)-1
else:
    count += min(len(con)+len(Alis),len(con)+len(Blis))
print(count)
Problem p03061 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
X = [0 for i in range(N)]
Y = [0 for i in range(N)]

def gcd(a,b):
    x = max(a, b)
    y = min(a, b)
    if y == 0:
        return x
    if x % y == 0:
        return y
    else:
        return gcd(y, x%y)

for i in range(1,N):
    X[i] = gcd(X[i-1], A[i-1])

for i in range(N-1)[::-1]:
    Y[i] = gcd(Y[i+1], A[i+1])

Z = [gcd(X[i], Y[i]) for i in range(N)]

print(max(Z))

Buggy submission (verdict: Runtime Error):
import copy
ans = 1
N = int(input())
A = list(map(int, input().split()))
l = []

def gcd(a,b):
    x = max(a, b)
    y = min(a, b)
    if x%y == 0:
        return y
    else:
        while x % y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
    
def gcd_list(list):
    p = 1
    for i in range(len(list)-1):
        if i == 0:
            p = gcd(list[0], list[1])
        else:
            p = gcd(z,list[i+1]) 
    return p

if N == 2:
    print(gcd(A[0], A[1]))
else:
    for i in range(N):
        l = copy.copy(A)
        l.pop(i)
        ans = max(gcd_list(l), ans)
    print(ans)
Problem p03062 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
counter = 0
m = []
def abab(l):
    for i in range(len(l)):
        m.append(abs(l[i]))
    return m

for i in range(N):
    if A[i] < 0:
        counter += 1
      
if counter % 2 == 1:
    m = abab(A)
    idx = m.index(min(m))
    m[idx] *= -1
    print(sum(m))
else:
    print(sum(abab(A)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
counter = 0
m = []
def abab(l):
    for i in range(len(l)):
        m.append(abs(l[i]))
    return m

for i in range(N):
    if A[i] < 0:
        counter += 1
      
if counter % 2 == 1:
    m = abab(A)
    idx = A.index(min(m))
    m[idx] *= -1
    print(sum(m))
else:
    print(sum(abab(A)))
Problem p03085 (python)

Fixed submission:
b = input()
if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'C':
    print('G')
else:
    print('C')

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
t=[0]*(N+1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
t = [0] * (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i : i+2] == 'AC' else 0)  
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Problem p03125 (python)

Fixed submission:
A, B = map(int,input().split())
if B % A ==0:
    print(A+B)
else:
    print(B-A)

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(N):
    for j in range(N-i):
        if j == N-i-1:
            print(N)
        else:
            print(N,end='')
Problem p03644 (python)

Fixed submission:
N = int(input())
two_list = [1, 2, 4, 8, 16,32,64]
answer = 0
for two in two_list:
  if N >= two:
      answer = two
      if two == 64:
          print("64")
  else:
    print(answer)
    exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
two_list = [1, 2, 4, 8, 16,32,64]
for two in two_list:
  if N > two:
  	if two == 64:
    	print(64)
  else:
    print(two)
    exit()
Problem p04044 (python)

Fixed submission:
N , L = map(int, input().split())
S = [input() for i in range(N)]
S = sorted(S)
print(*S,sep='')

Buggy submission (verdict: Runtime Error):
L , N = map(int, input().split())
S = [input() for i in range(N)]
S = sorted(S)
print("".join(S))

Buggy submission (verdict: Runtime Error):
L , N = map(int, input().split())
S = [input() for i in range(N)]
S = sorted(S)
print(*S,sep="")

Buggy submission (verdict: Runtime Error):
L , N = map(int, input().split())
S = [input() for i in range(N)]
S = sorted(S)
print(*S,sep='')
Problem p02742 (python)

Fixed submission:
h, w=map(int, input().split())
if h == 1 or w ==1:
    print(1)
elif (h * w) % 2 ==1:
    print(int((h * w //2) + 1))
else:
    print(int(h * w //2))

Buggy submission (verdict: Runtime Error):
h, w=map(int, input().split())
if h == 1 and w ==:
    print(1)
elif w == 1:
    print(1)
elif (h * w) % 2 ==1:
    print(int((h * w //2) + 1))
else:
    print(int(h * w //2))
Problem p02743 (python)

Fixed submission:
from math import sqrt
from decimal import *

a,b,c=map(int, input().split())
if Decimal(a).sqrt()+Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int, input().split())
if int(sqrt(a))+int(sqrt(b)) < int(sqrt(c)):
    print("Yes")
else:
    print("No")
Problem p02755 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import math
import sys
a,b=map(int, input().split())

y = math.floor(b/0.1)

for i in range(y,y+10):
    if math.floor(i * 0.08) == a:
        print(i)
        sys.exit(0)
print(-1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
import sys
a,b=map(int, input().split())

x = math.floor(a/0.08)
#1の位が1-9
y = math.floor(b/0.1)
if (x + 1) * 0.08 == a:
    xx = x + 2
else:
    xx = x + 1

for i in range(y,y+10):
    for j in range(x, xx):
        if i == j:
            print(i)
            sys.exit(1)
print(-1)
Problem p02780 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n,k=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
p=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#最大のリストを選定
before_pi = p[0]
before_sum = sum(p[0:k])+ 0.0
suml = [sum(p[0:k])]
for i in range(1,n-k+1):
    before_sum = before_sum - before_pi+p[i+k-1]
    suml.append(before_sum)
    before_pi = p[i]

#計算
print((max(suml)+k)/2.0)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n,k=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
p=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
max = 0
final = []
#最大のリストを選定
for i in range(0,n-k):
    ck = sum(p[i:i+k])
    if ck > max:
        final = p[i:i+k]
        max = ck

#計算
print((ck+k)/2.0)
Problem p02791 (python)

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

n=int(input())
p = list(map(int, input().split()))

result = []
c = 0
smallest = p[0]
for i in range(0,n):
    flag = 0
    if smallest >= p[i]:
        c += 1
        smallest = p[i]

print(c)

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

n=int(input())
p = list(map(int, input().split()))

result = []
c = 0
for i in range(0,n):
    flag = 0
    if smallest >= p[i]:
        c += 1
        smallest = p[i]

print(c)
Problem p02657 (python)

Fixed submission:
A, B = map(int, input().split())
print(A*B)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input.split())
print(A*B)
Problem p02658 (python)

Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]
if 0 in a:
  print(0)
  exit()
num = 1
for i in a:
  num = num*i
  if num > 10**18:
    print(-1)
    exit()
print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split())
if 0 in a:
  print(0)
  exit()
for i in a:
  num = num*i
  if num > 10**18:
    print(-1)
    exit()
print(num)
Problem p02681 (python)

Fixed submission:
s = input()
t = input()

if len(s)+1 == len(t) and s == t[:len(s)]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
v = []
now = 0
for i in range(K):
  p = A[now]
  now = p-1
  if p in v:
    j = v.index(p)
    df = i-j
    Kn = (K-i-1) % df
    p = v[j+Kn]
    break
  else:
    v.append(p)
print(p)
Problem p02687 (python)

Fixed submission:
s = input()
if s == "ABC":
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(a) for a in input().split()]
cnt = 0
for i in range(N):
  for j in range(i+1, N):
    d = A[i] + A[j] - (j-i)
    if d == 0:
      cnt += 1
print(cnt)
Problem p02657 (python)

Fixed submission:
a, b = list(map(int, input().split()))
print(a*b)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
print(a*b)
Problem p03455 (python)

Fixed submission:
l = input().split()
a, b = int(l[0]), int(l[1])
if (a*b)%2 == 0:
	print("Even")
else:
	print("Odd")

Buggy submission (verdict: Runtime Error):
l = input().split()
a, b = l[0], l[1]
if (a*b)%2 == 0:
	print("Even")
else
	print("Odd")

Buggy submission (verdict: Runtime Error):
l = input().split()
if (l[0] * l[1]) % 2 == 0 :
	print("Even")
else
	print("Odd")
Problem p03471 (python)

Fixed submission:
a, b , c = -1,-1,-1
n, y = map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        if i+ j > n:
            break
        elif ((y - (i*10000 + j*5000))%1000 == 0) and ((i+j+(y - (i*10000 + j*5000))/1000) == n):
            if (y - (i*10000 + j*5000))/1000 >= 0:
                a,b,c = i, j, int((y - i*10000 - j*5000)/1000)
                break
print(a, b, c)

Buggy submission (verdict: Runtime Error):
a, b , c = -1,-1,-1
n, y = map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        if i+ j > n:
            break
        else ((y - (i*10000 + j*5000))%1000 == 0) and ((i+j+(y - (i*10000 + j*5000))/1000) == n):
            if (y - (i*10000 + j*5000))/1000 >= 0:
                a,b,c = i, j, int((y - i*10000 - j*5000)/1000)
                break
print(a, b, c)

Buggy submission (verdict: Runtime Error):
    a, b , c = -1,-1,-1
    n, y = map(int,input().split())
    for i in range(n+1):
        for j in range(n+1):
            if ((y - (i*10000 + j*5000))%1000 == 0) and ((i+j+(y - (i*10000 + j*5000))/1000) == n):
                if (y - (i*10000 + j*5000))/1000 >= 0:
                    a,b,c = i, j, int((y - i*10000 - j*5000)/1000)
                    break
    print(a, b, c)
Problem p03545 (python)

Fixed submission:
s = input()
ans = 'inf'
for i in range(8):
    total = int(s[0])
    str = s[0]
    for j in range(3):
        if i>>j&1:
            total += int(s[j+1])
            str += '+' + s[j+1]
        else:
            total -= int(s[j+1])
            str += '-' + s[j+1]
    if total == 7:
        print(str + '=7')
        exit()

Buggy submission (verdict: Runtime Error):
    s = input()
    for i in range(8):
        total = int(s[0])
        str = s[0]
        for j in range(1, 4):
            if i >> (j - 1) & 1:
                total += int(s[j])
                str += '+' + s[j]
            else:
                total -= int(s[j])
                str += '-' + s[j]
        if total == 7:
            print(str + '=7')
            exit()
Problem p04001 (python)

Fixed submission:
s = input()
total = 0
n = 2**(len(s)-1)
for i in range(n):
    buf = s[0]
    for j in range(len(s)-1):
        if (i>>j)&1:
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)

Buggy submission (verdict: Runtime Error):
s = input()
total = 0
for i in product('01', repeat=len(s)-1):
    buf = s[0]
    for j in range(len(s)-1):
        if i[j] == '1':
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)

Buggy submission (verdict: Runtime Error):
s = input()
total = 0
for i in product('01', repeat=len(s)-1):
    buf = s[0]
    for j in range(len(s)-1):
        if i[j] == '1':
            total += int(buf)
            buf = s[j+1]
        else:
            buf += s[j+1]
    total += int(buf)
print(total)
Problem p04043 (python)

Fixed submission:
l = input().split()
print("YES" if sorted(l) == ['5', '5', '7'] else "NO")

Buggy submission (verdict: Runtime Error):
l = map(int, input().split())
l.sort()
print("YES" if l == [5, 5, 7] else "NO")

Buggy submission (verdict: Runtime Error):
l = map(int, input().split())
l.sort()
print("Yes" if l == [5, 5, 7] else "No")

Buggy submission (verdict: Runtime Error):
l = map(int, input().split())
print("Yes" if l.sort() == [5, 5, 7] else "No")

Buggy submission (verdict: Runtime Error):
l = map(int, input().split())
print("Yes") if l.sort() == [5, 5, 7] else print("No")
Problem p02983 (python)

Fixed submission:
import math
l,r=map(int,input().split())
a=l%2019
b=r%2019
if r-l>=2018:
    print(0)
elif b-a<=0:
    print(0)
else:
    ans=2018
    for i in range(a,b+1):
        for j in range(i+1,b+1):
            ans=min(ans,i*j%2019)
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
l,r=map(int,input().split())
a=l%2019
b=r%2019
if l-r>=2019:
    print(0)
elif b-a<=0:
    print(0)
elif (a%3==0)&(b%673==0):
    print(0)
elif (a%3==0)&(b%3==0):
    print(0)
elif a<=20&b>=101:
    print(1)
else:
    ans=2018
    for i in range(a,b+1):
        for j in range(i+1,b+1):
            ans=min(ans,i*j%2019)
print(ans)
Problem p02995 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
def lcm(a,b):
    return a*b//gcd(a,b)
    
a=a-1
b=b-b//c-b//d+b//lcm(c,d)
a=a-a//c-a//d+a//lcm(c,d)
print(b-a)

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

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

r=0
b=0

for i in s:
    if i=='R':
        r=r+1
    else:
        b=b+1

if r>b:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=input()
s=input()

r=0
b=0

for i in s:
    if i=='R':
	r=r+1
    else:
        b=b+1

if r>b:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=input()
s=input()

r=0
b=0

for i in s:
    if i=='R':
	r=r+1
    else:
        b=b+1

if r>b:
    print('Yes')
else:
    print('No')
Problem p03106 (python)

Fixed submission:
a,b,k=map(int,input().split())
c=0
n=0
if a>b:
    n=a-b
if b>a:
    n=b-a
if a==b:
    n=a
while(True):
    if(a%n==0)&(b%n==0):
        c=c+1
    if c==k:
        break
    n=n-1
print(n)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
c=0
n=0
if a>b:
    n=a-b
if b>a:
    n=b-a
if a==b:
    n=1
while(True):
    if(a%n==0)&(b%n==0):
        c=c+1
    if c==k:
        break
    n=n-1
print(n)
Problem p02788 (python)

Fixed submission:
import sys
n, D, a = map(int, input().split())
tg = []
for _ in range(n):
    x, h = map(int, sys.stdin.readline().split())
    c = h // a
    if h % a > 0:
        c+=1
    tg.append([x, c])

class BIT:
    def __init__(self, n):
        self.n = n
        self.N = 1 << n.bit_length()
        self.data = [0] * (self.N +1)

    def add(self, i, x):
        while i <= self.N:
            self.data[i] += x
            i += i & -i

    def sum(self, i):
        total = 0
        while i > 0:
            total += self.data[i]
            i -= i&-i
        return total

    def search(self, w):
        if w <= 0:
            return 0
        x = 0
        k = self.N >> 1
        while k > 0:
            if x+k <= self.N and self.data[x+k] < w:
                w -= self.data[x+k]
                x += k
            k = k >> 1
        return x+1

    def len(self):
        return self.data[self.N]

tg = sorted(tg, key=lambda x:x[0])
bit = BIT(n+2)
result = 0
ind = 0
for i in range(n):
    c = tg[i][1] - bit.sum(i+1)
    d = tg[i][0]
    if c <= 0:
        continue
    result += c
    wd = d + 2*D
    if ind < i:
        ind = i
    for j in range(ind, n):
        if tg[j][0] <= wd:
            ind = j
        else:
            break
    bit.add(i+1, c)
    bit.add(ind+2, -c)
print(result)

Buggy submission (verdict: Runtime Error):
import sys
n, D, a = map(int, input().split())
tg = []
for _ in range(n):
    x, h = map(int, sys.stdin.readline().split())
    c = h // a
    if h % a > 0:
        c+=1
    tg.append([x, c])

class BIT:
    def __init__(self, n):
        self.n = n
        self.N = 1 << n.bit_length()
        self.data = [0] * (self.N +1)

    def add(self, i, x):
        while i <= self.N:
            self.data[i] += x
            i += i & -i

    def sum(self, i):
        total = 0
        while i > 0:
            total += self.data[i]
            i -= i&-i
        return total

    def search(self, w):
        if w <= 0:
            return 0
        x = 0
        k = self.N >> 1
        while k > 0:
            if x+k <= self.N and self.data[x+k] < w:
                w -= self.data[x+k]
                x += k
            k = k >> 1
        return x+1

    def len(self):
        return self.data[self.N]

tg = sorted(tg, key=lambda x:x[0])
bit = BIT(n+2)
result = 0
ind = 0
for i in range(n):
    c = tg[i][1] - bit.sum(i+1)
    d = tg[i][0]
    if c <= 0:
        continue
    result += c
    wd = d + 2*D
    if ind < c:
        ind = c
    for j in range(ind, n):
        if tg[j][0] <= wd:
            ind = j
        else:
            break
    bit.add(i+1, c)
    bit.add(ind+2, -c)
    for j in range(n+1):
print(result)
Problem p02900 (python)

Fixed submission:
import fractions
from collections import defaultdict
a, b = map(int, input().split())

g = fractions.gcd(a, b)
l = defaultdict(int)
for i in range(2, int(g**0.5)+1):
    if g % i == 0:
        while g % i == 0:
            l[i] += 1
            g = g // i
if g != 1:
    l[g] += 1
print(len(l)+1)

Buggy submission (verdict: Runtime Error):
import math
from collections import defaultdict
a, b = map(int, input().split())

g = math.gcd(a, b)
l = defaultdict(int)
for i in range(2, int(g**0.5)+1):
    if g % i == 0:
        while g % i == 0:
            l[i] += 1
            g = g // i
if g != 1:
    l[g] += 1
print(len(l)+1)