Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
X = input()
S = [X[0]]
for i in range(2, len(X)+1):
    if X[i-1] == 'S':
        S.append('S')
    else:
        if 'S' in S:
            S.remove('S')
        else:
            S.append('T')
print(len(S))


Fixed submission:
X = input()
s = 0
t = 0
for x in X:
    if x == 'S':
        s += 1
    else:
        if s > 0:
            s -= 1
        else:
            t += 1
print(s+t)

Buggy python submission (verdict: Time Limit Exceeded):
X = input()
S = [X[0]]
for i in range(2, len(X)+1):
    if X[i-1] == 'S':
        S.append('S')
    else:
        if 'S' in S:
            S.remove('S')
        else:
            S.append('T')
print(len(S))


Fixed submission:
X = input()
s = 0
t = 0
for x in X:
    if x == 'S':
        s += 1
    else:
        if s > 0:
            s -= 1
        else:
            t += 1
print(s+t)

Buggy python submission (verdict: Time Limit Exceeded):
X = input()
dp = [0] * (len(X)+1)
dp[1] = 1
S = [X[0]]
for i in range(2, len(X)+1):
    if X[i-1] == 'S':
        S.append('S')
        dp[i] = dp[i-1] + 1
    else:
        if 'S' in S:
            S.remove('S')
            dp[i] = dp[i-1] - 1
        else:
            S.append('T')
            dp[i] = dp[i-1] + 1
print(dp[-1])


Fixed submission:
X = input()
s = 0
t = 0
for x in X:
    if x == 'S':
        s += 1
    else:
        if s > 0:
            s -= 1
        else:
            t += 1
print(s+t)

Buggy python submission (verdict: Time Limit Exceeded):
X = input()
dp = [0] * (len(X)+1)
dp[1] = 1
S = [X[0]]
for i in range(2, len(X)+1):
    if X[i-1] == 'S':
        S.append('S')
        dp[i] = dp[i-1] + 1
    else:
        if 'S' in S:
            S.remove('S')
            dp[i] = dp[i-1] - 1
        else:
            S.append('T')
            dp[i] = dp[i-1] + 1
print(dp[-1])


Fixed submission:
X = input()
s = 0
t = 0
for x in X:
    if x == 'S':
        s += 1
    else:
        if s > 0:
            s -= 1
        else:
            t += 1
print(s+t)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
h = int(input())
print(int(((a + b) * h / 2))


Fixed submission:
a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
h = int(input
print((a + b)/2*h)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
print(int((a + b) * h / 2))
Buggy python submission (verdict: Runtime Error):
import itertools

N, K = map(int,input().split())
D = list(map(int,input().split()))
N = str(N)
d = []
d_min = 10
for i in range(10):
    if i in D:
        continue
    else:
        if i != 0:
            d_min = min(d_min, i)
        d.append(str(i))
if '0' in d:
    ans = str(d_min) + '0' * len(N)
else:
    ans = str(d_min) * len(N+1)
ans = int(ans)
for s in itertools.product(d, repeat=len(N)):
    s = ''.join(s)
    s = int(s)
    if s >= int(N):
        ans = min(ans, s)
print(ans)


Fixed submission:
import itertools

N, K = map(int,input().split())
D = list(map(int,input().split()))
N = str(N)
d = []
d_min = 10
for i in range(10):
    if i in D:
        continue
    else:
        if i != 0:
            d_min = min(d_min, i)
        d.append(str(i))
if '0' in d:
    ans = str(d_min) + '0' * len(N)
else:
    ans = str(d_min) * (len(N) + 1)
ans = int(ans)
for s in itertools.product(d, repeat=len(N)):
    s = ''.join(s)
    s = int(s)
    if s >= int(N):
        ans = min(ans, s)
print(ans)
Buggy python submission (verdict: Runtime Error):
import statistics

N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

sumX = []
sumY = []
for x,y in XY:
    sumX.append(x)
    sumY.append(y)
avaX = statistics.median(sumX)
avaY = statistics.median(sumY)

zone1 = []
zone2 = []
zone3 = []
zone4 = []
for x,y in XY:
    if x < avaX and y >= avaY:
        zone1.append((x,y,abs(x-avaX)+abs(y-avaY)))
    elif x < avaX and y < avaY:
        zone4.append((x,y,abs(x-avaX)+abs(y-avaY)))
    elif x >= avaX and y >= avaY:
        zone2.append((x,y,abs(x-avaX)+abs(y-avaY)))
    elif x >= avaX and y < avaY:
        zone3.append((x,y,abs(x-avaX)+abs(y-avaY)))

zone1.sort()
zone2.sort()
zone3.sort()
zone4.sort()

ans = 0
ans = max(ans,zone1[-1][2]+zone3[-1][2])
ans = max(ans,zone2[-1][2]+zone4[-1][2])
print(ans)

Fixed submission:

N = int(input())
XY = [list(map(int,input().split())) for _ in range(N)]

ans = 0

def measure(originX,originY):
    dist = []
    for X,Y in XY:
        dist.append(abs(X-originX)+abs(Y-originY))
    return max(dist)-min(dist)

originX = 0
originY = 0
ans = max(ans,measure(originX,originY))

originX = 10**9
originY = 0
ans = max(ans,measure(originX,originY))

originX = 0
originY = 10**9
ans = max(ans,measure(originX,originY))

originX = 10**9
originY = 10**9
ans = max(ans,measure(originX,originY))

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
ans = float("INF")
for i in range(len(S)-len(T)):
    cnt = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans,cnt)
print(cnt)

Fixed submission:
S = input()
T = input()
ans = float("INF")
for i in range(len(S)-len(T)+1):
    cnt = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans,cnt)
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
ans = float("INF")
for i in range(len(S)):
    cnt = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans,cnt)
print(cnt)

Fixed submission:
S = input()
T = input()
ans = float("INF")
for i in range(len(S)-len(T)+1):
    cnt = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            cnt += 1
    ans = min(ans,cnt)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
"""
1. マス同士は有効グラフの一本道になっている。で、必ずどこかでループが発生している。

2. 各点から各点に移動する場合のスコアの合計とステップ数(ループ内の場合は一周以内のもの)を前処理(dfs)で求めておく。dp[i][j] => iからjまでのスコアとステップ数

3. K > N の場合、ループを通るとスコアがマイナスになるなら（dp[i][i]がマイナスになるようなiが存在するなら）、ループを一周しない方がよい。
ループを通るとスコアがプラスになるなら、

各iに対して地点iからスタートする場合というのをシミュレートすると実装が楽そう。
K <= Nの場合はi番目からスタートして、dfsでstep数がKに到達するまで進み続けて、スコアの最大値を図る。
Kが大きい場合は、dfsで道をたどっていってループを検出したら、その時点でループスコアがマイナスかプラスかを判断して、マイナスなら終了。
プラスならループスコア*(K//ループstep)を加算してできる限りKを減らす。そこからstep数がKに到達するまでdfsで道をたどっていって最大値を求める。
各スタート地点ごとにO(N)で処理可能なので、全体ではO(N^2)で処理できる
"""
import sys
sys.setrecursionlimit(10000)
def main():
    N,K = map(int,input().split())
    P = list(map(int,input().split()))
    C = list(map(int,input().split()))

    def dfs(cur,score,scores,step,steps):
        if scores[cur] == None:
            scores[cur] = score
            steps[cur] = step
        else:
            if scores[cur] >= score:
                return
            else:
                loopStep = step - steps[cur]
                loopScore = score - scores[cur]

                scores[cur] = score
                steps[cur] = step

                scores[cur] += ((K - steps[cur])//loopStep)*loopScore
                steps[cur] += ((K - steps[cur])//loopStep)*loopStep
                
        if steps[cur] < K:
            p = P[cur-1]
            c = C[p-1]
            dfs(p,scores[cur]+c,scores,steps[cur]+1,steps)
        else:
            return

    ans = -float("INF")
    for i in range(1,N+1):
        scores = [None]*(N+1)
        steps = [None]*(N+1)
        dfs(i,0,scores,0,steps)
        for j in range(N+1):
            if scores[j] != None and steps[j] != 0:
                ans = max(ans,scores[j])
    print(ans)
main()

Fixed submission:
"""
1. マス同士は有効グラフの一本道になっている。で、必ずどこかでループが発生している。

2. 各点から各点に移動する場合のスコアの合計とステップ数(ループ内の場合は一周以内のもの)を前処理(dfs)で求めておく。dp[i][j] => iからjまでのスコアとステップ数

3. K > N の場合、ループを通るとスコアがマイナスになるなら（dp[i][i]がマイナスになるようなiが存在するなら）、ループを一周しない方がよい。
ループを通るとスコアがプラスになるなら、

各iに対して地点iからスタートする場合というのをシミュレートすると実装が楽そう。
K <= Nの場合はi番目からスタートして、dfsでstep数がKに到達するまで進み続けて、スコアの最大値を図る。
Kが大きい場合は、dfsで道をたどっていってループを検出したら、その時点でループスコアがマイナスかプラスかを判断して、マイナスなら終了。
プラスならループスコア*(K//ループstep)を加算してできる限りKを減らす。そこからstep数がKに到達するまでdfsで道をたどっていって最大値を求める。
各スタート地点ごとにO(N)で処理可能なので、全体ではO(N^2)で処理できる
"""
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = -float("INF")

for i in range(1,N+1):
    scores = [None]*(N+1)
    steps = [None]*(N+1)
    cur = i
    score = 0
    step = 0
    loopFlag = False
    while step <= K:
        if scores[cur]!=None and not loopFlag:
            loopFlag = True
            loopScore = score - scores[cur]
            loopStep = step - steps[cur]
            ans = max(ans,score)
            restLoop = (K-step)//loopStep
            if restLoop > 0:
                restLoop -= 1
            score += restLoop*loopScore
            step += restLoop*loopStep
        scores[cur] = score
        steps[cur] = step
        if step != 0:
            ans = max(ans,score)
        p = P[cur-1]
        c = C[p-1]
        cur = p
        score += c
        step += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
"""
小数の状態だと処理しづらいので、与えられた数を全て10**9倍して小数を確実になくした上で
問題文を下記のように言い換える。
「積が10**18の倍数になるような数の組み合わせの数がいくつあるか」
数Aiがあり、Aiの2の素因数の数がn, 5の素因数の数がmのとき、
数Ai自体ですでにmin(n,m)個の0の数を持っている。この場合、のこり必要な0の数はx = 18-min(n,m)個である。
ここで、n == mの場合：
Aiの相方は少なくとも2,5の素因数をそれぞれx個以上持っていなくてはならない。
n > mの場合：
Aiの相方は少なくとも2の素因数をx-(n-m)個、5の素因数をx個持っていなくてはいけない。

m > nの場合：
Aiの相方は少なくとも2の素因数をx個以上、5の素因数をx-(m-n)個以上持っていなくてはならない。
"""
N = int(input())
dp = [[0]*(19) for _ in range(19)]
ans = 0
for _ in range(N):
    a = float(input())
    a *= 10**9
    two = 0
    while a % 2 == 0:
        a //= 2
        two += 1
    five = 0
    while a % 5 == 0:
        a //= 5
        five += 1

    ans += dp[18-two][18-five]
    for i in range(two+1):
        for j in range(five+1):
            dp[i][j] += 1
print(ans)

Fixed submission:
def div(n, d):
    cnt = 0
    while n % d == 0 and cnt < 18:
        n //= d
        cnt += 1
    return cnt


n = int(input())
dp = [[0]*19 for _ in range(19)]
#dp[i][j] -> 2の素因数がi以上,5の素因数がj以上の数字の数

ans = 0
for _ in range(n):
    x = round(float(input()) * pow(10, 9))
    two = div(x, 2)
    five = div(x, 5)
    ans += dp[18 - two][18 - five]
    for i in range(two + 1):
        for j in range(five + 1):
            dp[i][j] += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
rep = 1
for i in range(K):
    rep *= A[i]

#この段階でrepはK学期の評価
tmp = rep
for i in range(K,N):
    tmp = rep*A[i]//A[i-K]
    if tmp > rep:
        print("Yes")
    else:
        print("No")
    rep = tmp


Fixed submission:
mod = 10**9 +7
N,K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(K,N):
    if A[i] > A[i-K]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
"""
yとzで残り
"""
from math import sqrt
for n in range(1,N+1):
    cnt = 0
    for x in range(1,int(sqrt(n))+1):
        for y in range(1,int(sqrt(n))+1):
            for z in range(1,int(sqrt(n))+1):
                if x**2+y**2+z**2+x*y+y*z+z*x == n:
                    cnt += 1
    print(cnt)

Fixed submission:
N = int(input())
"""
yとzで残り
"""
memo = {}
from math import sqrt
for x in range(1,int(sqrt(N))+1):
    for y in range(1,int(sqrt(N))+1):
        for z in range(1,int(sqrt(N))+1):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n not in memo:
                memo[n] = 0
            memo[n] += 1

for i in range(1,N+1):
    if i in memo:
        print(memo[i])
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
"""
yとzで残り
"""
from math import sqrt
for n in range(1,N+1):
    cnt = 0
    for x in range(1,n+1):
        for y in range(1,n+1):
            for z in range(1,n+1):
                if x**2+y**2+z**2+x*y+y*z+z*x == n:
                    cnt += 1
    print(cnt)

Fixed submission:
N = int(input())
"""
yとzで残り
"""
memo = {}
from math import sqrt
for x in range(1,int(sqrt(N))+1):
    for y in range(1,int(sqrt(N))+1):
        for z in range(1,int(sqrt(N))+1):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n not in memo:
                memo[n] = 0
            memo[n] += 1

for i in range(1,N+1):
    if i in memo:
        print(memo[i])
    else:
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):

from collections import Counter
N = int(input())
X = [i for i in range(1,N+1)]

counts = []
for i in range(N):
    x = X[i]
    d = 2
    tmp = []
    while d**2<=x:
        if x%d==0:
            tmp.append(d)
            x //= d
        else:
            d += 1
    if x != 1:
        tmp.append(x)
    counts.append(Counter(tmp))

memo = []
for i in range(1,N+1):
    tmp = 1
    for v in counts[i-1].values():
        tmp *= (v+1)
    memo.append(i*tmp)

print(sum(memo))

Fixed submission:
N = int(input())
memo = [0]*(N+1)
for i in range(1,N+1):
    for j in range(i,N+1,i):
        memo[j] += 1

ans = 0
for i in range(1,N+1):
    ans += memo[i]*i

print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
Nlist = []
for i in range(1,N+1):
    Nlist.append(i)
count = 0
for i in range(N):
    count += 1
    if count>M:
        break
    print(Nlist[i],Nlist[-(i+1)])


Fixed submission:
import math
X = int(input())
d = 100
year = 0
while True:
    year += 1
    if d+math.floor(d*0.01) >= X:
        print(year)
        exit()
    else:
        d += math.floor(d*0.01)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
#Dストックを昇順で生成する。
Dstock = {}
Nstock = {}
for i in range(1,N):
    Dstock[i]=""
    Nstock[i]=""
Nstock[N] = ""

count = 0
while Nstock and count<M:
    count += 1
    for i in Dstock.keys():
        for j in Nstock.keys():
            print(j,j+i)
            del Nstock[j]
            del Nstock[j+i]
            del Dstock[i]
            del Dstock[N-i]
            break
        else:
            continue
        break

Fixed submission:
import math
X = int(input())
d = 100
year = 0
while True:
    year += 1
    if d+math.floor(d*0.01) >= X:
        print(year)
        exit()
    else:
        d += math.floor(d*0.01)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
S = input()
S = S[::-1]

num = 0
ans = 0
memo = defaultdict(int)
memo[0] = 1
for i in range(len(S)):
    num += int(S[i])*pow(10,i)
    rest = num % 2019
    ans += memo[rest]
    memo[rest] += 1
print(ans)

Fixed submission:
"""
dp的な発想で解けるかな？
下の桁から見る。桁を一つずつ
"""
from collections import defaultdict
S = input()
N = len(S)
S = S[::-1]

ans = 0
memo = defaultdict(int)
num = 0
memo[0] = 1
for i in range(N):
    num = (num+(pow(10,i,2019)*int(S[i]))%2019)%2019
    ans += memo[num]
    memo[num] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
"""
dp的な発想で解けるかな？
下の桁から見る。桁を一つずつ
"""
from collections import defaultdict
S = input()
N = len(S)
S = S[::-1]

ans = 0
memo = defaultdict(int)
num = 0
memo[0] = 1
for i in range(N):
    num = (num+pow(10,i)*int(S[i])%2019)%2019
    ans += memo[num]
    memo[num] += 1

print(ans)

Fixed submission:
"""
dp的な発想で解けるかな？
下の桁から見る。桁を一つずつ
"""
from collections import defaultdict
S = input()
N = len(S)
S = S[::-1]

ans = 0
memo = defaultdict(int)
num = 0
memo[0] = 1
for i in range(N):
    num = (num+(pow(10,i,2019)*int(S[i]))%2019)%2019
    ans += memo[num]
    memo[num] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
"""
dp的な発想で解けるかな？
下の桁から見る。桁を一つずつ
"""
from collections import defaultdict
S = input()
N = len(S)
S = S[::-1]

ans = 0
memo = defaultdict(int)
num = 0
memo[0] = 1
for i in range(N):
    num += pow(10,i)*int(S[i])
    r = num%2019
    ans += memo[r]
    memo[r] += 1

print(ans)

Fixed submission:
"""
dp的な発想で解けるかな？
下の桁から見る。桁を一つずつ
"""
from collections import defaultdict
S = input()
N = len(S)
S = S[::-1]

ans = 0
memo = defaultdict(int)
num = 0
memo[0] = 1
for i in range(N):
    num = (num+(pow(10,i,2019)*int(S[i]))%2019)%2019
    ans += memo[num]
    memo[num] += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
K,N = map(int,input().split())
A = list(map(int,input().split()))

foK,N = map(int,input().split())
A = list(map(int,input().split()))
ans = []

for i in range(N-1):
  now = i
  pre = now-1
  post = now +1
  #nowとpreの距離を求める
  if now == 0:
    preDic = (K-A[N-1])+A[now]
  else:
    preDic = A[now]-A[pre]
  postDic = A[post]-A[now]  
  if preDic >= postDic:#時計回りに、i-1の位置まで進む
    ans.append(K-preDic)
  else:
    ans.append(K-postDic)

    
print(min(ans))

Fixed submission:
K,N = map(int,input().split())
A = list(map(int,input().split()))
ans = []

for i in range(N-1):
  now = i
  pre = now-1
  post = now +1
  #nowとpreの距離を求める
  if now == 0:
    preDic = (K-A[N-1])+A[now]
  else:
    preDic = A[now]-A[pre]
  postDic = A[post]-A[now]  
  if preDic >= postDic:#時計回りに、i-1の位置まで進む
    ans.append(K-preDic)
  else:
    ans.append(K-postDic)
  
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N,X,Y = map(int,input().split())
ans = [0]*(N-1)
for i in range(1,N):
  for j in range(i+1,N+1):
    if i <= X and j <= X:
      dic = j-i
    elif i >= Y and j >= Y:
      dic = j-i
    elif i <= X and j >= Y:
      dic = (j-i)-(Y-X)+1
    elif X < i < Y and j >= Y:
      dic = min(i-X+1,Y-i)+(j-Y)
    elif i<=X and X < j < Y:
      dic = (X-i)+min(Y-j+1,j-X)
    elif X < i < Y and X < j < Y:
      dic = min(j-i,(i-X+1)+(Y-j))
    ans[dic-1] = ans[dic-1]+1

for ret in ans:
  print(ret)

Fixed submission:
n,x,y = map(int,input().split())
ans = [0]*(n-1)


def f(N,X,Y):
  for i in range(1,N):
    for j in range(i+1,N+1):
      if i <= X and j <= X:
        dic = j-i
      elif i >= Y and j >= Y:
        dic = j-i
      elif i <= X and j >= Y:
        dic = (j-i)-(Y-X)+1
      elif X < i < Y and j >= Y:
        dic = min(i-X+1,Y-i)+(j-Y)
      elif i<=X and X < j < Y:
        dic = (X-i)+min(Y-j+1,j-X)
      elif X < i < Y and X < j < Y:
        dic = min(j-i,(i-X+1)+(Y-j))
      ans[dic-1] = ans[dic-1]+1
  
f(n,x,y)
for ret in ans:
  print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
import math

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

def comb(x):
  if x <= 1:
    return 0
  return math.factorial(x) // (math.factorial(x - 2) * math.factorial(2))

dic = {}
#まず最初に、グルーピング(グルーピングの時点で辞書化が必要)
for a in A:
  if a in dic:
    dic[a][0] += 1
  else:
    dic[a] = [1]

#辞書にコンビネーションをvalueとして書き込んでいく
for v in dic.values():
  v.append(comb(v[0]))
  v.append(comb(v[0]-1))

#各グループのlen(g)C2を総計して変数grandとして保持しておく
grand = 0
for v in dic.values():
  grand += v[1]
  
for a in A:
  output = grand - dic[a][1] + dic[a][2]
  print(output)

Fixed submission:
import math

N = int(input())
A = list(map(int,input().split()))

def comb(n):
  r = 2
  if n <= 1:
    return 0
  if n - r < r: r = n - r
  if r == 0: return 1
  if r == 1: return n
  
  numerator = [n - r + k + 1 for k in range(r)]
  denominator = [k + 1 for k in range(r)]
  
  for p in range(2,r+1):
    pivot = denominator[p - 1]
    if pivot > 1:
      offset = (n - r) % p
      for k in range(p-1,r,p):
        numerator[k - offset] /= pivot
        denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
dic = {}
#まず最初に、グルーピング(グルーピングの時点で辞書化が必要)
for a in A:
  if a in dic:
    dic[a][0] += 1
  else:
    dic[a] = [1]

#辞書にコンビネーションをvalueとして書き込んでいく
for v in dic.values():
  v.append(comb(v[0]))
  v.append(comb(v[0]-1))

#各グループのlen(g)C2を総計して変数grandとして保持しておく
grand = 0
for v in dic.values():
  grand += v[1]
  
for a in A:
  output = grand - dic[a][1] + dic[a][2]
  print(output)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ts = []
for _ in range(N):
    x, l = map(int,input().split())
    t = min(x+l,10**9)
    s = max(x-l,0)
    ts.appned([t,s])

ts.sort()

tmp = 0
count = 0
for n in ts:
    if tmp<=n[1]:
        count += 1
        tmp = n[0]

print(count)


Fixed submission:
n = int(input())
robotList=[]
for i in range(n):
  x,l = map(int,input().split())
  s = max(x-l,0)
  t = min(10**9,x+l)  
  robotList.append([t,s])
  
robotList.sort()

count = 0
tmp = 0
for robot in robotList:
  if robot[1] >= tmp:
    count += 1
    tmp = robot[0]

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
ts=[]
for i in range(N):
  x, l = map(int,input().split())
  if x + l <= 10**9:
    t = x + l
  else:
    t = s
  if x-l >= 0:
    s = x-l
  else:
    s = 0
  ts.append([t,s])
ts.sort()

count = 0
lastT = 0
for i in ts:
  if i[1]>=lastT:
    count+=1
    lastT=i[0]
print(count)

Fixed submission:
n = int(input())
robotList=[]
for i in range(n):
  x,l = map(int,input().split())
  s = max(x-l,0)
  t = min(10**9,x+l)  
  robotList.append([t,s])
  
robotList.sort()

count = 0
tmp = 0
for robot in robotList:
  if robot[1] >= tmp:
    count += 1
    tmp = robot[0]

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
ts=[]
for i in range(N):
  x, l = map(int,input().split())
  if x + l <= 100000:
    t = x + l
  else:
    t = s
  if x-l >= 0:
    s = x-l
  else:
    s = 0
  ts.append([t,s])
ts.sort()

count = 0
lastT = 0
for i in ts:
  if i[1]>=lastT:
    count+=1
    lastT=i[0]
print(count)

Fixed submission:
n = int(input())
robotList=[]
for i in range(n):
  x,l = map(int,input().split())
  s = max(x-l,0)
  t = min(10**9,x+l)  
  robotList.append([t,s])
  
robotList.sort()

count = 0
tmp = 0
for robot in robotList:
  if robot[1] >= tmp:
    count += 1
    tmp = robot[0]

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
ts=[]
for i in range(N):
  x, l = map(int,input().split())
  if x + l <= 100000:
    t = x + l
  else:
    t = s
  if x-l >= 0:
    s = x-l
  else:
    s = 0
  ts.append([t,s])
ts.sort()

count = 0
lastT = 0
for i in ts:
  if i[1]>=lastT:
    count+=1
    lastT=i[0]
print(count)

Fixed submission:
n = int(input())
robotList=[]
for i in range(n):
  x,l = map(int,input().split())
  s = max(x-l,0)
  t = min(10**9,x+l)  
  robotList.append([t,s])
  
robotList.sort()

count = 0
tmp = 0
for robot in robotList:
  if robot[1] >= tmp:
    count += 1
    tmp = robot[0]

print(count)