Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s=[*input()]
n1=[*'01']
n2=[*'10']
judge=True
max_length=len(s)
while judge:
  judge = False
  length = len(s)
  for i in range(1,length):
    if s[i-1:i+1]==n1 or s[i-1:i+1]==n2:
      del s[i]
      del s[i-1]
      i+=2
      judge = True
print(max_length-len(s))

Fixed submission:
s=[*input()];print(2*min(s.count('0'),s.count('1')))
Buggy python submission (verdict: Runtime Error):
def check(A):
  check_result = []
  for i in range(1, len(A)):
    check_result.append(list(set(A[i-1])&set(A[i])))
  if len(check_result) != len(A):
    return check_result
  return False

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
for i in range(len(A)):
  A[i].pop(0)
while True:
  check_result = check(A)
  if check_result:
    A = check_result
  else:
    if not A[0]:
      print(0)
      break
    else:
      print(len(A[0]))
      break

Fixed submission:
A, B = map(int, input().split())
print(A+B if B%A==0 else B-A)
Buggy python submission (verdict: Runtime Error):
n=[input() for _ in range(int(input()))];if len(set(n))!=len(n): print('No');exit()
print('NYoe s'[all([1 if n[i-1][-1]==n[i][0] else 0 for i in range(1,len(n))])::2])

Fixed submission:
import sys
N = int(input())
W = [input() for _ in range(N)]
if len(set(W)) == len(W):
  for i in range(1, len(W)):
    if W[i-1][-1] != W[i][0]:
      print('No')
      sys.exit()
else:
  print('No')
  sys.exit()
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=input()
k=int(input())
right=0
left=0
r=deque([])
while right<len(s):
  r.append(s[right:left+1])
  left+=1
  if left==len(s):
    right+=1
    left=right
print(sorted(set(r))[k-1])

Fixed submission:
s=input()
k=int(input())
n=len(s)
r=[]
for right in range(0,n):
  for left in range(right+1, right+k+1):
    r.append(s[right:left])
print(sorted(set(r))[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
k=int(input())
right=0
left=0
r=[]
while right<len(s):
  r.append(s[right:left+1])
  left+=1
  if left==len(s):
    right+=1
    left=right
print(sorted(set(r))[k-1])

Fixed submission:
s=input()
k=int(input())
n=len(s)
r=[]
for right in range(0,n):
  for left in range(right+1, right+k+1):
    r.append(s[right:left])
print(sorted(set(r))[k-1])

Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
result = []
result.append(S)
for i in range(len(S)):
  for j in range(i+1, len(S)):
    result.append(S[i:j])
result = list(set(result))
result.sort()
print(result[K-1])

Fixed submission:
s=input()
k=int(input())
n=len(s)
r=[]
for right in range(0,n):
  for left in range(right+1, right+k+1):
    r.append(s[right:left])
print(sorted(set(r))[k-1])
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split());n=[*range(a,b+1)]
try:
  n=sorted(set(n[:k]+n[-k:]));print(*n,sep='\n')
except:
  print(*n,sep='\n')

Fixed submission:
A,B,K = map(int, input().split())
[print(i) for i in sorted(list(set([i for i in range(A,A+K)] + [i for i in reversed(range(B-K+1, B+1))]))) if A <= i <= B]

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split());
try:
  n=[*range(a,b+1)]
  n=sorted(set(n[:k]+n[-k:]));print(*n,sep='\n')
except:
  print(*n,sep='\n')

Fixed submission:
A,B,K = map(int, input().split())
[print(i) for i in sorted(list(set([i for i in range(A,A+K)] + [i for i in reversed(range(B-K+1, B+1))]))) if A <= i <= B]

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split());n=[*range(a,b+1)]
n=sorted(set(n[:k]+n[-k:]));print(*n,sep='\n')

Fixed submission:
A,B,K = map(int, input().split())
[print(i) for i in sorted(list(set([i for i in range(A,A+K)] + [i for i in reversed(range(B-K+1, B+1))]))) if A <= i <= B]
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input());a=input().split();d={}
for i in a:
  if int(i)==a.count(i):
    continue
  if i not in d:
    d[i]=min(a.count(i),abs(int(i)-a.count(i)))
print(sum([i for i in d.values()]))

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
dict={}
count=0
for i in a:
  if i not in dict:
    dict[i] = 1
    continue
  dict[i] += 1
for i,j in dict.items():
  if i > j:
    count += j
  elif i < j:
    count += j-i
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
length = list(set(A))
dict = {}
count = 0
if len(length) > K:
  for i in length:
    if i not in dict:
      dict[i] = A.count(i)
  dict=sorted(dict.items(),key=lambda x:-x[1])
  for i in reversed(range(K,len(length))):
    count += dict[i][1]
print(count)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
count = [0]*max(A)
for i in A:
  count[i-1] += 1
print(sum(sorted(count,reverse=True)[K:]))
Buggy python submission (verdict: Runtime Error):
print(['No','Yes'][input().count('9')])

Fixed submission:
print(['No','Yes']['9' in input()])
Buggy python submission (verdict: Runtime Error):
import string
S=sorted(set((input())))
count = 0
for i in string.ascii_lowercase:
  if i!=S[count]:
    print(i)
    break
  count += 1
else:
  print('None')

Fixed submission:
import string
word=sorted(set((input()))^set(string.ascii_lowercase))
print(word and word[0] or 'None')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input());a=list(map(int,input().split()));b,c=sum(a),float('inf')
for i in range(1,n):
  c=min(c,abs(b-2*sum(a[:i])))
print(c)

Fixed submission:
n=int(input());a=list(map(int,input().split()));f,b,c=0,sum(a),float('inf')
for i in range(n-1):
  f,b=f+a[i],b-a[i]
  c=min(c,abs(f-b))
print(c)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
num = a
if (a % 2 == 1 and c % 2 == 0) or (a % 2 == 0 and c % 2 == 1):
  print('NO')
else:
  pritn('YES')

Fixed submission:
a,b,c=map(int,input().split())
for i in range(a,b*a+1,a):
  if i%b==c: print('YES');break
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split());print(['NO','YES'][b-a==c-b])A

Fixed submission:
a,b,c=map(int,input().split());print(['NO','YES'][b-a==c-b])
Buggy python submission (verdict: Runtime Error):
n=int(input())
word=[sorted(input()) for _ in range(n)]
result=[]
word_result=[]
for i in range(len(word)-1):
  result.append(set(word[i])&set(word[i+1]))
if min(result):
  for i in min(result):
    word_result.append(i*word[0].count(i))
else:
  print('')
  exit()
print(''.join(sorted(word_result)))

Fixed submission:
import collections as c
n=[c.Counter(input()) for _ in range(int(input()))];r=n[0]
for i in range(1,len(n)): r=r&n[i]
print(*sorted([i*j for i,j in r.items()]),sep='')

Buggy python submission (verdict: Runtime Error):
n=int(input())
word=[sorted(input()) for _ in range(n)]
result=[]
word_result=[]
for i in range(len(word)-1):
  result.append(set(word[i])&set(word[i+1]))
if min(result):
  for i in min(result):
    word_result.append(i*word[0].count(i))
print(''.join(sorted(word_result)))

Fixed submission:
import collections as c
n=[c.Counter(input()) for _ in range(int(input()))];r=n[0]
for i in range(1,len(n)): r=r&n[i]
print(*sorted([i*j for i,j in r.items()]),sep='')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
num = 1
div=int(1e9)+7
for i in range(1,n+1):
  num *= i
print(num%div)

Fixed submission:
n=int(input())
num = 1
div=int(1e9)+7
for i in range(1,n+1):
  num = num*i%div
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
count=0
for i in range(K+1):
  for j in range(K+1):
    for m in range(K+1):
      if i+j+m==S:
        count+=1
print(count)

Fixed submission:
K,S=map(int,input().split())
count=0
for i in range(K+1):
  for j in range(K+1):
    if 0 <= S-i-j <= K:
      count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s=input()
b=False
result = []
for i in s:
  if i=='B':
    if not b:
      result.pop()
      b=True
  else:
    b=False
    result.append(i)
print(''.join(result))

Fixed submission:
s=input()
result = []
for i in s:
  if i=='0':
    result.append('0')
  elif i=='1':
    result.append('1')
  elif i=='B':
    if not result:
      continue
    result.pop()
print(''.join(result))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
dat = list(map(int, input().split()))

prev = 1
for i in range(k):
    prev *= dat[i]

for i in range(n-k):
    new = dat[k + i]
    nukeru = dat[i]
    newval = prev // nukeru * new
    if newval > prev:
        print("Yes")
    else:
        print("No")
    prev = newval

Fixed submission:
n, k = map(int, input().split())
dat = list(map(int, input().split()))

prev = dat[0]

for i in range(n-k):
    new = dat[k + i]
    nukeru = dat[i]
    if new > nukeru:
        print("Yes")
    else:
        print("No")
    prev = new
Buggy python submission (verdict: Runtime Error):
n = int(input())
dat = list(map(int, input().split()))
res = 0
import collections
buf = collections.Counter(dat)
dat = []
for k in buf:
    if buf[k] == 1:
        dat.append(k)
dat.sort()
#print(dat)
res = 0
used = [False] * (1000100)

for i in range(len(dat)):
    ok = True

    if used[dat[i]]:
        ok = False
    c = 0
    v = -1
    while v <= 1000010:
        c += 1
        v = dat[i] * c
        used[v] = True


    used[dat[i]] = True
    if ok:
        res += 1
print(res)

Fixed submission:
n = int(input())
dat = list(map(int, input().split()))

import collections
buf = collections.Counter(dat)
dat = []
dat = list(buf.keys())

dat.sort()

res = 0

used = [False] * (1000100)

for i in range(len(dat)):
    ok = True

    if used[dat[i]]:
        ok = False
    if buf[dat[i]] != 1:
        ok = False

    c = 0
    v = -1
    while True:
        c += 1
        v = dat[i] * c
        if v > 1000010:
            break
        used[v] = True

    used[dat[i]] = True

    if ok:
        res += 1
#print(used[:10])
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dat = list(map(int, input().split()))
buf = []
for i in range(n):
    buf.append(i - dat[i])
#print(buf)
res = 0
for i in range(n):
    x = i + dat[i]
    for j in range(i+1, n):
        if x == buf[j]:
            res += 1
print(res)



Fixed submission:
import collections
import bisect
n = int(input())
cnt = collections.defaultdict(list)
dat = list(map(int, input().split()))
buf = []
for i in range(n):
    cnt[i - dat[i]].append(i)
#print(buf)
res = 0
for i in range(n):
    x = i + dat[i]
    if x in cnt:
        res += len(cnt[x]) - bisect.bisect_left(cnt[x], x)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dat = list(map(int, input().split()))
buf = []
for i in range(n):
    buf.append(i - dat[i])
#print(buf)
res = 0
for i in range(n):
    x = i + dat[i]
    for j in range(i+1, n):
        if x == buf[j]:
            res += 1
print(res)



Fixed submission:
import collections
import bisect
n = int(input())
cnt = collections.defaultdict(list)
dat = list(map(int, input().split()))
buf = []
for i in range(n):
    cnt[i - dat[i]].append(i)
#print(buf)
res = 0
for i in range(n):
    x = i + dat[i]
    if x in cnt:
        res += len(cnt[x]) - bisect.bisect_left(cnt[x], x)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dat = list(map(int, input().split()))
res = 0
for i in range(n):
    for j in range(i+1, n):
        #print(i,j,abs(i-j))
        if abs(i - j) == dat[i] + dat[j]:
            res += 1
print(res)

Fixed submission:
import collections
import bisect
n = int(input())
cnt = collections.defaultdict(list)
dat = list(map(int, input().split()))
buf = []
for i in range(n):
    cnt[i - dat[i]].append(i)
#print(buf)
res = 0
for i in range(n):
    x = i + dat[i]
    if x in cnt:
        res += len(cnt[x]) - bisect.bisect_left(cnt[x], x)
print(res)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
if n == 0:
    print(0)
else:
    x = abs(n - k)
    a = n % x
    b = abs(a - k)
    print(min(a, b))


Fixed submission:
n, k = map(int, input().split())
if n == 0 or n == k:
    print(0)
else:
    a = abs(n % k)
    b = abs(a - k)
    print(min(a, b))

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
x = abs(n - k)
a = n % x
b = abs(a - k)
print(min(a, b))

Fixed submission:
n, k = map(int, input().split())
if n == 0 or n == k:
    print(0)
else:
    a = abs(n % k)
    b = abs(a - k)
    print(min(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n, l, r = map(int, input().split())

l -= 1
r -= 1

for k in range(1, n):
    res = 0
    #print("l",l, "r",r)
    for a in range(n):
        for b in range(a+1, n):
            #print("from", a, "to", b)
            c = 9999999999
            c = min(c, b - a)
            #print(" dire", c)
            c = min(c, abs( abs(l - a) + abs(r - b) ) + 1 )
            #print(" warp", abs(l - a) + abs(r - b) +1,abs(l - a),  abs(r - b))
            if c == k:
                #print(" hit!!!!!!!!!!", k)
                res += 1
    print(res)


Fixed submission:
n, l, r = map(int, input().split())

l -= 1
r -= 1

dist = [0] * 10000000

for a in range(n):
    for b in range(a+1, n):
        #print("from", a, "to", b)
        c = 9999999999
        c = min(c, b - a)
        #print(" dire", c)
        c = min(c, abs( abs(l - a) + abs(r - b) ) + 1 )
        dist[c] += 1
for k in range(1, n):
    print(dist[k])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())


dat = []
for _ in range(n):
    x, l = map(int, input().split())
    #           0  1   2    3    4co     5
    dat.append([x, l, x-l, x+l, 0     , []])
dat.sort(key = lambda x: x[1], reverse=True)
#print(dat)
res = []
res_safe = []
def do_count():
    for i in range(n):
        #print("i={0}".format(i))
        c = 0
        m = []
        for j in range(i+1, n):
            #print("j={0}".format(j))
            if dat[j][3] <= dat[i][2] or dat[i][3] <= dat[j][2]:
                pass
            else:
                dat[i][5].append(dat[j])
                dat[j][5].append(dat[i])
                dat[i][4] += 1
                dat[j][4] += 1

do_count()
dat.sort(key = lambda x: (x[4], x[1]), reverse=True)
#print(dat)
for i in range(n):
    if dat[i][4] == 0:
        res.append(dat[i])
        continue
    #print("node {0}: kill".format(i))
    for node in dat[i][5]:
        #print(node[5])
        for x in range(len(node[5])):
            if node[5][x] == dat[i]:
                node[4] -= 1
                del node[5][x]
                #print("!!!!")

#print(res)
print(len(res))


Fixed submission:
n = int(input())
dat = []
for _ in range(n):
    x, l =map(int, input().split())
    dat.append([x-l, x+l])
dat.sort(key=lambda x: x[1])
#print(dat)
prevr = -99999999999999999
res = 0
for i in range(n):
    if dat[i][0] >= prevr:
        prevr = dat[i][1]
        res += 1
print(res)
Buggy python submission (verdict: Runtime Error):
from collections import deque

def solve(S, s):
    if S[s[0]][s[1]] != ".":
        return -1
    queue = deque([s])
    visited = [[-1 for _ in range(W)] for _ in range(H)]
    visited[s[0]][s[1]] = 0
    while queue:
        y, x = queue.popleft()
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y + j, x + k
            if new_x in range(W) and new_y in range(H) and S[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
    #    for v in visited:
    #        print(v)
    return max(max(visited))

H, W = map(int, input().split())
S = [input() for _ in range(H)]
ans = -1
for i in range(W):
    for l in range(H):
        ans = max(ans, solve(S, [i, l]))
print(ans)

Fixed submission:
c = input()
print(chr(ord(c[0]) + 1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
is_ac = [False] * 10050
numok = 0
numwa = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if is_ac[p]: # すでに正解
        continue
    else: # 未正解
        if s == "AC":
            numok += 1
            is_ac[p] = True
        else:
            numwa += 1
print("{0} {1}".format(numok, numwa))

Fixed submission:
n, m = map(int, input().split())
is_ac = [False] * 200050
count_wa = [0] * 100050
numok = 0
numwa = 0
for i in range(m):
    p, s = input().split()
    p = int(p)
    if is_ac[p]: # すでに正解
        continue
    else: # 未正解
        if s == "AC":
            numok += 1
            is_ac[p] = True
        else:
            count_wa[p] += 1
for i in range(100040):
    if is_ac[i]:
        numwa += count_wa[i]
print("{0} {1}".format(numok, numwa))
Buggy python submission (verdict: Runtime Error):

def prime_list_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
def prime_list_eratosthenes_from(n_from, n_to):
    from bisect import bisect_left
    data = prime_list_eratosthenes(n_to)
    i = bisect_left(data, n_from)
    return data[i:]
x = int(input())
d = prime_list_eratosthenes_from(x, 100000)
print(d[0])

Fixed submission:

def prime_list_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
def prime_list_eratosthenes_from(n_from, n_to):
    from bisect import bisect_left
    data = prime_list_eratosthenes(n_to)
    i = bisect_left(data, n_from)
    return data[i:]
x = int(input())
d = prime_list_eratosthenes_from(x, 1000000)
print(d[0])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
s = input()
dat = []
for i in range(n):
    dat.append(set([]))
for i in range(n):
    for j in range(max(i, 2), 0, -1):
        for x in dat[j-1]:
            dat[j].add(x + s[i])
    dat[0].add(s[i])
print(len(dat[2]))
#print(dat[2])

Fixed submission:
n = int(input())
s = input()
res = 0
pos = []
for i in range(10):
    pos.append([])

for i in range(len(s)):
    c = int(s[i])
    pos[c].append(i)
import bisect
# 0010
# print(format(10, '04d'))
res = 0
for num in range(0, 1000):
    numstr = format(num, '03d')
    iscan = True
    curpos = -2
    for i in range(3):
        curpos += 1
        val = int(numstr[i])
        ind = bisect.bisect_left(pos[val], curpos)
        if ind == len(pos[val]):
            iscan = False
            break
        curpos = pos[val][ind]

    if iscan:
        res += 1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
s = input()
dat = []
for i in range(n):
    dat.append(set([]))
for i in range(n):
    for j in range(i, 0, -1):
        for x in dat[j-1]:
            dat[j].add(x + s[i])
    dat[0].add(s[i])
print(len(dat[2]))
#print(dat[2])

Fixed submission:
n = int(input())
s = input()
res = 0
pos = []
for i in range(10):
    pos.append([])

for i in range(len(s)):
    c = int(s[i])
    pos[c].append(i)
import bisect
# 0010
# print(format(10, '04d'))
res = 0
for num in range(0, 1000):
    numstr = format(num, '03d')
    iscan = True
    curpos = -2
    for i in range(3):
        curpos += 1
        val = int(numstr[i])
        ind = bisect.bisect_left(pos[val], curpos)
        if ind == len(pos[val]):
            iscan = False
            break
        curpos = pos[val][ind]

    if iscan:
        res += 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())
v = []
for i in range(n+1):
    v.append([])

colorv = [None] * (n+1)

for i in range(n-1):
    a,b = map(int, input().split())
    v[a].append([b,i])
    v[b].append([a,i])

for cur in range(1, n+1):

    #print("cur", cur)

    used = [False] * (n+1)

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is None:
            continue
        #print(" line", linenum, "is", colorv[linenum])
        used[colorv[linenum]] = True

    ncolor = 1

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is not None:
            continue
        while used[ncolor] is True:
            ncolor += 1
        colorv[linenum] = ncolor
        #print(" set line", linenum, "is", ncolor)
        used[ncolor] = True

print(max(colorv[:-2]))
for i in range(n-1):
    print(colorv[i])



Fixed submission:

n = int(input())
v = []
for i in range(n+1):
    v.append([])

colorv = [None] * (n+1)

for i in range(n-1):
    a,b = map(int, input().split())
    v[a].append([b,i])
    v[b].append([a,i])

for cur in range(1, n+1):

    #print("cur", cur)

    used = dict()

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is None:
            continue
        #print(" line", linenum, "is", colorv[linenum])
        used[colorv[linenum]] = True

    ncolor = 1

    for i in range(len(v[cur])):
        next, linenum = v[cur][i]
        if colorv[linenum] is not None:
            continue
        while ncolor in used:
            ncolor += 1
        colorv[linenum] = ncolor
        #print(" set line", linenum, "is", ncolor)
        used[ncolor] = True

print(max(colorv[:-2]))
for i in range(n-1):
    print(colorv[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dat = list(map(int, input().split()))
res = 0
dat.sort(reverse=True)
for a in range(n):
    for b in range(a+1, n):
        if dat[a] >= (dat[b] * 2):
            break
        for c in range(b+1, n):
            if dat[a] < (dat[b] + dat[c]) and dat[b] < (dat[c] + dat[a]) and dat[c] < (dat[a] + dat[b]):
                res += 1
            else:
                break
print(res)


Fixed submission:
import bisect
n = int(input())
dat = list(map(int, input().split()))
dat.sort(reverse=True)
dat = list(map(lambda x: -x, dat))
#print(dat)
res = 0
for a in range(n):
    #print("a={0}, [{1}]".format(dat[a],a))
    for b in range(a+1, n):
        #print("b={0}, [{1}]".format(dat[b],b))
        cind = bisect.bisect_left(dat, dat[a] - dat[b], b)
        cannum = cind - (b+1)
        cannum = 0 if cannum < 0 else cannum
        #print("cind", cind)
        #print("cannum", cannum)
        res += cannum
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
dat = list(map(int, input().split()))
res = 0
for a in range(n):
    for b in range(a+1, n):
        for c in range(b+1, n):
            if dat[a] < (dat[b] + dat[c]) and dat[b] < (dat[c] + dat[a]) and dat[c] < (dat[a] + dat[b]):
                res += 1
print(res)

Fixed submission:
import bisect
n = int(input())
dat = list(map(int, input().split()))
dat.sort(reverse=True)
dat = list(map(lambda x: -x, dat))
#print(dat)
res = 0
for a in range(n):
    #print("a={0}, [{1}]".format(dat[a],a))
    for b in range(a+1, n):
        #print("b={0}, [{1}]".format(dat[b],b))
        cind = bisect.bisect_left(dat, dat[a] - dat[b], b)
        cannum = cind - (b+1)
        cannum = 0 if cannum < 0 else cannum
        #print("cind", cind)
        #print("cannum", cannum)
        res += cannum
print(res)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = math.ceil(n/9)
b = n % 9 #
print(str(b) * a)

Fixed submission:
s = input()
p = ""
c = ""
res = 0
for i in range(len(s)):
    c += s[i]
    if p != c:
        p = c
        c = ""
        res += 1
print(res)