Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a = input()
if(int(a[5]) = 1):
    print("TBD")
elif(int(a[6]) > 4):
    print("TBD")
else:
    print("Heisei")

Fixed submission:
a = input()
if(a[5] == "1"):
    print("TBD")
elif(int(a[6]) > 4):
    print("TBD")
else:
    print("Heisei")
Buggy python submission (verdict: Time Limit Exceeded):
N , K = map(int,input().split())
hn = list(map(int,input().split()))
dp = [10 ** 10] * (N)
dp[0] = 0
#dp[1] = abs(hn[0]-hn[1])
for i in range(N):
    for j in range(1,K+1):
        if i + j < N:
            dp[i+j] = min(dp[i] + abs(hn[i+j]-hn[i]) ,dp[i+j])

print(dp[-1])

Fixed submission:
N, K  = map(int, input().split())
hn = list(map(int,input().split() ) )
# カエルがi番目からi+j番目に到着するには
# dp[i+j] = min(dp[i]+abs(hn[i+j] - hn[i]) + , dp[i+j])
dp = [10**10] * (N)
dp[0] = 0
dp[1] = abs(hn[0]-hn[1])
for i in range(N):
    for j in range(1,K+1):
        if i + j < N:
            dp[i+j] = min(dp[i] + abs(hn[i+j] - hn[i]), dp[i+j])

print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N , W = map(int, input().split() )
wv = [list(map(int,input().split())) for _ in range(N) ]
maxv = 100100
dp = [[10**10] * (maxv) for _ in range(N+1) ]
dp[0][0] = 0
for i in range(N):
    for j in range(maxv):
        if j >= wv[i][1]:
            dp[i+1][j] = min(dp[i+1][j] , dp[i][j-wv[i][1]]+wv[i][0])
        dp[i+1][j] = min(dp[i+1][j] , dp[i][j])

ans = 0
for j in range(maxv):
    if dp[N][j] <= W:
        ans = j
print(ans)

Fixed submission:
N , W = map(int, input().split() )
wv = [list(map(int,input().split())) for _ in range(N) ]
maxv = 100100
dp = [[10**10] * (maxv) for _ in range(N+1) ]
dp[0][0] = 0
for i in range(N):
    for j in range(maxv):
        if j >= wv[i][1]:
            dp[i+1][j] = min(dp[i+1][j] , dp[i][j-wv[i][1]]+wv[i][0])
        dp[i+1][j] = min(dp[i+1][j] , dp[i][j])

ans = 0
for j in range(maxv):
    if dp[N][j] <= W:
        ans = j
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from sys import stdin
def input(): return sys.stdin.readline().strip()

N = int(input())
pn = list(map(float,input().split()))
dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 1.0
for i in range(N):
    for j in range(N):
        dp[i+1][j+1] += dp[i][j] * pn[i]
        dp[i+1][j] += dp[i][j] * (1 -pn[i])
n2 = N // 2 + 1
ans = 0
for k in range(n2 , N+1):
    ans  += dp[N][k]
print(ans)

Fixed submission:
import sys
from sys import stdin
def input(): return sys.stdin.readline().strip()
import numpy as np

N = int(input())
pn = list(map(float,input().split()))
dp = np.array([0.0] * (N+1))
dp[0] = 1.0
for i in range(N):
    tmp = dp * (1-pn[i])
    tmp[1:] += dp[:-1] * pn[i]
    dp = tmp

print(sum(dp[N // 2 +1:]))
Buggy python submission (verdict: Runtime Error):
print(1110 - int(input())

Fixed submission:
print(1110 - int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N , K = map( int , input().split())
lst = list(map(int, input().split()))
ans = 10 ** 9

def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

nearzero = getNearestValue(lst, 0)
start = max(0 , nearzero- K -1)  
end = min(N - K + 1 , nearzero +  K + 1)
for i in range(start , end):
    # Ｋ個のサブリストを作成する
    lst2 = lst[i: i+K]
    # 全て正（先頭がゼロ以上）であれば、最大の正数（一番右の数）が最小時間となる
    if lst2[0] >= 0:
        ans = min(ans, lst2[-1])
    # 全て負（一番右がゼロ以下）であれば、最小の整数（一番左の数）が最小時間となる
    elif lst2[-1] <= 0:
        ans = min(ans, abs(lst2[0]))
    # 上記以外は、正負混在のケース    
    else:
        #  一番右の方が大きいとき
        if abs(lst2[0]) < lst2[-1]:
            # 負の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst2[0]) * 2 + lst2[-1])
        else:
            # 正の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst2[0]) + lst2[-1] * 2)

print(ans)


Fixed submission:
import numpy as np
N , K = map( int , input().split())
lst = list(map(int, input().split()))
ans = 10 ** 9

for i in range(N - K + 1):
    # 全て正（先頭がゼロ以上）であれば、最大の正数（一番右の数）が最小時間となる
    if lst[i] >= 0:
        ans = min(ans, lst[i + K -1])
    # 全て負（一番右がゼロ以下）であれば、最小の整数（一番左の数）が最小時間となる
    elif lst[i + K -1] <= 0:
        ans = min(ans, abs(lst[i]))
    # 上記以外は、正負混在のケース    
    else:
        #  一番右の方が大きいとき
        if abs(lst[i]) < lst[i + K -1]:
            # 負の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst[i]) * 2 + lst[i + K -1])
        else:
            # 正の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst[i]) + lst[i + K -1] * 2)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N , K = map( int , input().split())
lst = list(map(int, input().split()))
ans = 10 ** 9
for i in range(N - K + 1):
    # Ｋ個のサブリストを作成する
    lst2 = lst[i: i+K]
    # 全て正（先頭がゼロ以上）であれば、最大の正数（一番右の数）が最小時間となる
    if lst2[0] >= 0:
        ans = min(ans, lst2[-1])
    # 全て負（一番右がゼロ以下）であれば、最小の整数（一番左の数）が最小時間となる
    elif lst2[-1] <= 0:
        ans = min(ans, abs(lst2[0]))
    # 上記以外は、正負混在のケース    
    else:
        #  一番右の方が大きいとき
        if abs(lst2[0]) < lst2[-1]:
            # 負の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst2[0]) * 2 + lst2[-1])
        else:
            # 正の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst2[0]) + lst2[-1] * 2)

print(ans)


Fixed submission:
import numpy as np
N , K = map( int , input().split())
lst = list(map(int, input().split()))
ans = 10 ** 9

for i in range(N - K + 1):
    # 全て正（先頭がゼロ以上）であれば、最大の正数（一番右の数）が最小時間となる
    if lst[i] >= 0:
        ans = min(ans, lst[i + K -1])
    # 全て負（一番右がゼロ以下）であれば、最小の整数（一番左の数）が最小時間となる
    elif lst[i + K -1] <= 0:
        ans = min(ans, abs(lst[i]))
    # 上記以外は、正負混在のケース    
    else:
        #  一番右の方が大きいとき
        if abs(lst[i]) < lst[i + K -1]:
            # 負の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst[i]) * 2 + lst[i + K -1])
        else:
            # 正の方向から折り返してくる方が最小なので
            ans = min(ans , abs(lst[i]) + lst[i + K -1] * 2)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N , M = map(int, input().split())
an = list(map(int,input().split()))
ca = [0] * N
ca[0] = an[0] % M
ans = 0
for i in range(1,N):
    ca[i] = (ca[i-1] + an[i]) % M
for i in range(N):
    if ca[i] % M == 0:
        ans += 1
    for j in range(i):
        if (ca[i] - ca[j]) % M == 0:
            ans += 1
print(ans)

Fixed submission:
from collections import Counter
from math import factorial
# Mで割った余りが同じ累積和同士の組み合わせを数え上げればよい
N , M = map(int, input().split())
an = list(map(int,input().split()))
ca = [0] * N
ca[0] = an[0] % M
ans = 0
for i in range(N):
    if i > 0:
        ca[i] = (ca[i-1] + an[i]) % M
    if ca[i] % M == 0:
        ans += 1
# Mで割った余りが同じ個数をCounterを利用して求める
c = list(Counter(ca).items())
for ci in c:
    if ci[1] >= 2:
        ans += factorial(ci[1]) // (factorial(2) * factorial(ci[1]-2))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N , M = map(int, input().split())
an = list(map(int,input().split()))
ca = [0] * N
ca[0] = an[0] % M
ans = 0
for i in range(1,N):
    ca[i] = (ca[i-1] + an[i]) % M
for i in range(N):
    if ca[i] % M == 0:
        ans += 1
    for j in range(i):
        if (ca[i] - ca[j]) % M == 0:
            ans += 1
print(ans)

Fixed submission:
from collections import Counter
from math import factorial
# Mで割った余りが同じ累積和同士の組み合わせを数え上げればよい
N , M = map(int, input().split())
an = list(map(int,input().split()))
ca = [0] * N
ca[0] = an[0] % M
ans = 0
for i in range(N):
    if i > 0:
        ca[i] = (ca[i-1] + an[i]) % M
    if ca[i] % M == 0:
        ans += 1
# Mで割った余りが同じ個数をCounterを利用して求める
c = list(Counter(ca).items())
for ci in c:
    if ci[1] >= 2:
        ans += factorial(ci[1]) // (factorial(2) * factorial(ci[1]-2))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
count = N
for i in range(N):
    count = min(count , S[:i].count("W") + S[i+1:].count("E"))
print(count)

Fixed submission:
N = int(input())
S = input()
first = S.count("E")
Ecount = 0 
Wcount = 0
count = first
for i in range(N):
    if S[i] == "E":
        Ecount += 1
    else:
        Wcount += 1
    count = min(count , first - Ecount + Wcount)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
alist = list(input().split())
b = alist[0]
n1 = (N -1) // 2
n2 = (N -1) % 2
for i in range(n1):
    b = b + " " + alist[2*i+1]
    b =  alist[2*i+2] + " " + b
if n2 == 1:
    b = b + " " + alist[-1]
    b = b[::-1]
print(b)

Fixed submission:
N = int(input())
alist = list(input().split())
if N % 2 == 0:
    a1 = alist[1::2]
    a2 = alist[0::2]
    a1.reverse()
    a1.extend(a2)
else:
    a1 = alist[0::2]
    a2 = alist[1::2]
    a1.reverse()
    a1.extend(a2)
c = ' '.join(a1)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
alist = list(map(int,input().split()))
b = []
for a in alist:
    b.append(a)
    b = b[::-1]
ans = str(b[0])
for bb in b[1:]:
    ans = ans + " " + str(bb)
print(ans)

Fixed submission:
N = int(input())
alist = list(input().split())
if N % 2 == 0:
    a1 = alist[1::2]
    a2 = alist[0::2]
    a1.reverse()
    a1.extend(a2)
else:
    a1 = alist[0::2]
    a2 = alist[1::2]
    a1.reverse()
    a1.extend(a2)
c = ' '.join(a1)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
slist = [int(input()) for _ in range(N)]
anslist = []
for bit in range(1<<(N)):
    sum = 0
    for i in range(N):
        if bit & (1<<i):
            sum += slist[i]
    if sum % 10 != 0:
        anslist.append(sum)
if len(anslist) == 0:
    print(0)
else:
    print(max(anslist))

Fixed submission:
import sys
N = int(input())
slist = [int(input()) for _ in range(N)]
ssum = sum(slist)
if ssum % 10 == 0:
    slist.sort()
    for s in slist:
        if  s % 10 != 0:
            print(ssum - s)
            sys.exit()
    print(0)
else:
    print(ssum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
odd = 0
even = 0
temp = 0
for i in range(N):
    temp += a[i]
    if i % 2 == 0:
        # 奇数番目が正
        while temp < 1:
            temp += 1
            odd += 1
    else:
        while temp > -1:
            temp -= 1
            odd += 1       
temp = 0
for i in range(N):
    temp += a[i]
    if i % 2 == 0:
        # 奇数番目が負
        while temp > -1:
            temp -= 1
            even += 1
    else:
        while temp < 1:
            temp += 1
            even += 1
print(min(odd,even))

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
odd = 0
even = 0
temp = 0
for i in range(N):
    temp += a[i]
    if i % 2 == 0:
        # 奇数番目が正
        if temp < 1:
            odd += 1-temp
            temp = 1
    else:
        if temp > -1:
            odd += 1 + temp
            temp = -1
                   
temp = 0
for i in range(N):
    temp += a[i]
    if i % 2 == 0:
        # 奇数番目が負
        if temp > -1:
            even += 1 + temp
            temp = -1     
    else:
        if temp < 1:
            even += 1-temp
            temp = 1
print(min(odd,even))
Buggy python submission (verdict: Runtime Error):
N  = int(input())
slist = [input() for _ in range(N)]
abc = 'abcdefghijklmnopqrstuvwxyz'
l = [50] * 26
ans = ''
for i in range(N):
    for s in slist:
        l[i] = min(l[i],s.count(abc[i]))
for j in range(N):
    ans = ans + (abc[j] * l[j])
print(ans)
    

Fixed submission:
N  = int(input())
slist = [input() for _ in range(N)]
abc = 'abcdefghijklmnopqrstuvwxyz'
l = [50] * 26
ans = ''
for i in range(26):
    for s in slist:
        l[i] = min(l[i],s.count(abc[i]))
for j in range(26):
    ans = ans + (abc[j] * l[j])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
alist = list(map(int,input().split()))
flg = True
if N == 1:
    if alist[0] == 0:
        print(1)
    else:
        print(0)
    sys.exit()
inf = 10 ** 9 + 7
if N % 2 == 0:
    for i in range(N)[1::2]:
        if alist.count(i) != 2:
            flg = False
else:
    for i in range(N)[2::2]:
        if alist.count(i) != 2:
            flg = False
if flg:
    print((2 ** (N // 2)) %  inf)
else:
    print(0)

Fixed submission:
import sys
N = int(input())
alist = list(map(int,input().split()))
flg = True
if N == 1:
    if alist[0] == 0:
        print(1)
    else:
        print(0)
    sys.exit()
inf = 10 ** 9 + 7
alist.sort()
if N % 2 == 0:
    for i in range(N)[1::2]:
        if alist[i-1] != i or alist[i] != i:
            flg = False
            break
else:
    if alist[0] != 0:
        flg = False
    for i in range(N)[2::2]:
        if alist[i-1] != i or alist[i] != i:
            flg = False
            break
if flg:
    print((2 ** (N // 2)) %  inf)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
#! -*- coding: utf-8 -*-
import numpy as np

n = int(raw_input())

p = np.zeros([n])
for i in range(n):
    p[i] = int(raw_input())

count = np.zeros([n],int)
for i in range(n):
    check = i+1
    for j in range(n):
        if p[j] == check:
            count[i] += 1
            check += 1

#print count

#print np.max(count)

ans = n-np.max(count)

print ans


Fixed submission:
#! -*- coding: utf-8 -*-
import numpy as np

n = int(raw_input())

p = np.zeros([n],int)
for i in range(n):
    p[i] = int(raw_input())

count = np.zeros([n+1],int)

for i in range(n):
    count[p[i]] = count[p[i]-1]+1

#print count

#print count

#print np.max(count)

ans = n-np.max(count)

print ans
Buggy python submission (verdict: Time Limit Exceeded):
#! -*- coding: utf-8 -*-

import numpy as np
import copy

n = int(raw_input())
x = map(int,raw_input().split())

for i in range(n):
    x_i = copy.copy(x)
    del x_i[i]
    print int(np.median(x_i))


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

import numpy as np
import copy

n = int(raw_input())
x = map(int,raw_input().split())

x_min = copy.copy(x)
x_max = copy.copy(x)

x_min.remove(max(x))
x_max.remove(min(x))

med_x_min = int(np.median(x_min))
med_x_max = int(np.median(x_max))

if med_x_max == med_x_min:
    for i in range(n):
        print med_x_max
else:
    for i in range(n):
        if x[i] >= med_x_max:
            print med_x_min
        else:
            print med_x_max
Buggy python submission (verdict: Time Limit Exceeded):
#!usr/bim/python
#! -*- coding: utf-8 -*-

nk = raw_input()
nk = nk.split()
n,k = map(int,nk)

a = raw_input()
a = a.split()
a = map(int,a)

d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

l = d.values()

ans = 0

if len(l) <= k:
    pass
else:
    for i in range(len(l)-k):
        ans += min(l)
        l.remove(min(l))

print ans


Fixed submission:
#!usr/bim/python
#! -*- coding: utf-8 -*-

nk = raw_input()
nk = nk.split()
n,k = map(int,nk)

a = raw_input()
a = a.split()
a = map(int,a)

d = {}

for i in range(n):
    if a[i] in d:
        d[a[i]] += 1
    else:
        d[a[i]] = 1

l = d.values()

ans = 0

if len(l) <= k:
    pass
else:
    l.sort()
    for i in range(len(l)-k):
        ans += l[i]

print ans
Buggy python submission (verdict: Runtime Error):
#!usr/bim/python
#! -*- coding: utf-8 -*-

import numpy as np

nc = raw_input()
nc = nc.split()
n,c = map(int,nc)

tt = np.zeros([(10**2),c],int)

for i in range(n):
    stc = raw_input()
    stc = stc.split()
    s,t,c = map(int,stc)
    j = s
    while j <= t:
        tt[j-1][c-1] = 1
        j += 1

ans = np.max(np.sum(tt, axis=1))

print ans


Fixed submission:
#!usr/bim/python
#! -*- coding: utf-8 -*-

import numpy as np

nc = raw_input()
nc = nc.split()
n,c = map(int,nc)

tt = np.zeros([(10**5),c],int)

for i in range(n):
    stc = raw_input()
    stc = stc.split()
    s,t,c = map(int,stc)
    j = s
    while j <= t:
        tt[j-1][c-1] = 1
        j += 1

ans = np.max(np.sum(tt, axis=1))

print ans

Buggy python submission (verdict: Time Limit Exceeded):
#!usr/bim/python
#! -*- coding: utf-8 -*-

import numpy as np

nc = raw_input()
nc = nc.split()
n,c = map(int,nc)

tt = np.zeros([(10**5),c],int)

for i in range(n):
    stc = raw_input()
    stc = stc.split()
    s,t,c = map(int,stc)
    j = s
    while j <= t:
        tt[j-1][c-1] = 1
        j += 1

ans = 1
for i in range(10**5):
    ans = max(ans,sum(tt[i]))

print ans


Fixed submission:
#!usr/bim/python
#! -*- coding: utf-8 -*-

import numpy as np

nc = raw_input()
nc = nc.split()
n,c = map(int,nc)

tt = np.zeros([(10**5),c],int)

for i in range(n):
    stc = raw_input()
    stc = stc.split()
    s,t,c = map(int,stc)
    j = s
    while j <= t:
        tt[j-1][c-1] = 1
        j += 1

ans = np.max(np.sum(tt, axis=1))

print ans
Buggy python submission (verdict: Runtime Error):
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

b2 = 2
b1 = 1

for i in range(n-1):
    a = b1 + b2
    b2 = b1
    b1 = a
    #print i+2, a

print a


Fixed submission:
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

b2 = 2
b1 = 1

if n == 1:
    a = 1
else:
    for i in range(n-1):
        a = b1 + b2
        b2 = b1
        b1 = a
        #print i+2, a

print a
Buggy python submission (verdict: Time Limit Exceeded):
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

dl = raw_input()
dl = dl.split()
dl = map(int,dl)

m = raw_input()
m = int(m)

tl = raw_input()
tl = tl.split()
tl = map(int,tl)

status = 0

for t in tl:
    if t in dl:
        dl.remove(t)
    else:
        status = 1
        break

if status == 0:
    print "YES"
else:
    print "NO"
    


Fixed submission:
#!usr/bim/python
#! -*- coding: utf-8 -*-

n = raw_input()
n = int(n)

dl = raw_input()
dl = dl.split()
dl = map(int,dl)
dl.sort()

m = raw_input()
m = int(m)

tl = raw_input()
tl = tl.split()
tl = map(int,tl)
tl.sort()

status = 0
i = 0
j = 0
while j < m:
    d = dl[i]
    t = tl[j]
    #print d,t
    if d > t:
        status = 1
        break
    elif d == t:
        i += 1
        j += 1
    else:
        i += 1

if status == 0:
    print "YES"
else:
    print "NO"
Buggy python submission (verdict: Runtime Error):
#!usr/bim/python
#! -*- coding: utf-8 -*-
import math

nyu = raw_input()
nyu = int(nyu)

if nyu % 2 == 0:
    h = nyu
    n = nyu
    w = nyu / 2

elif nyu % 4 == 1:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    if h % 3 == 0:
        n = nyu*h/3*2
        w = nyu*h/3*2
    elif h % 2 == 0:
        n = nyu*h/2
        w = nyu*h
    else:
        h += 1
        if (nyu*h) % 6 == 0:
            n = nyu*h/6
            w = nyu*h
        elif (nyu*h) % 10 == 0:
            n = nyu*h/5
            w = nyu*h/2
        elif (nyu*h) % 7 == 0:
            n = nyu*h/7*2
            w = nyu*h/7*2

else:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    n = nyu*h*2
    w = nyu*h*2

print h,n,w


Fixed submission:
#!usr/bim/python
#! -*- coding: utf-8 -*-
import math

nyu = raw_input()
nyu = int(nyu)

h = 0
n = 0
w = 0

if nyu % 2 == 0:
    h = nyu
    n = nyu
    w = nyu / 2

elif nyu % 4 == 1:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    i = 0
    status = 0
    while 1:
        x = nyu*h
        y = 4*i+3
        for j in range(y/2):
            if j == 0:
                if x % y == 0:
                    n = x*2/y
                    w = x*2/y
                    status = 1
                    break
            else:
                if x % (j*(y-j)) == 0:
                    n = x/(y-j)
                    w = x/j
                    status = 1
                    break
        if status == 1:
            break
        else:
            i += 1
            h += 1

else:
    h = nyu / 4.0
    h = math.ceil(h)
    h = int(h)
    n = nyu*h*2
    w = nyu*h*2

print h,n,w
Buggy python submission (verdict: Time Limit Exceeded):
#!usr/bim/python
#! -*- coding: utf-8 -*-

a = raw_input()

count = 0

for i in range(len(a)):
    for j in range(len(a)-i-1):
        if a[i] == a[i+j+1]:
            count += 1

ans = len(a)*(len(a)-1)/2
ans -= count
ans += 1

print ans


Fixed submission:
#!usr/bim/python
#! -*- coding: utf-8 -*-

a = raw_input()

count = 0

for i in range(26):
    c = a.count(chr(i+97))
    x = c * (c-1) / 2
    count += x

ans = len(a)*(len(a)-1)/2
ans -= count
ans += 1

print ans
Buggy python submission (verdict: Runtime Error):
#!usr/bim/python
#! -*- coding: utf-8 -*-


n_m = raw_input()
n,m = n_m.split()

#n = int(n)
m = int(m)

shima_1_list = []
shima_2_list = []

i = 0
while i < m:
    teikibin = raw_input()
    teikibin = teikibin.split()
    if teikibin[0] == "1":
        shima_1_list.append(teikibin[1])
    elif teikibin[1] == n:
        shima_2_list.append(teikibin[0])
    i += 1

status = 0

for shima_1 in shima_1_list:
    if shima_1 in shima_2_list:
        status = 1

if status == 0:
    print "IMPOSSIBLE"
else:
    print "POSSIBLE"


Fixed submission:
#!usr/bim/python
#! -*- coding: utf-8 -*-


num = raw_input()

print "ABC"+num
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[0]]
for i in range(1, N):
  if A[i] <= B[0]:
    B.insert(0, A[i])
  else:
    index = bisect.bisect_left(B, A[i]) - 1
    B[index] = A[i]
print(len(B))


Fixed submission:
import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[N - 1]]
for i in reversed(range(0, N - 1)):
  if A[i] >= B[-1]:
    B.append(A[i])
  else:
    index = bisect.bisect_right(B, A[i])
    B[index] = A[i]
print(len(B))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[0]]
for i in range(1, N):
  if A[i] <= B[0]:
    B.insert(0, A[i])
  else:
    index = bisect.bisect_left(B, A[i]) - 1
    B[index] = A[i]
print(len(B))

Fixed submission:
import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[N - 1]]
for i in reversed(range(0, N - 1)):
  if A[i] >= B[-1]:
    B.append(A[i])
  else:
    index = bisect.bisect_right(B, A[i])
    B[index] = A[i]
print(len(B))

Buggy python submission (verdict: Runtime Error):
import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[0]]
for i in range(1, N):
  print(B)
  if A[i] <= B[0]:
    B.insert(0, A[i])
  else:
    index = bisect.bisect_left(B, A[i]) - 1
    B[index] = A[i]
print(len(B))

Fixed submission:
import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[N - 1]]
for i in reversed(range(0, N - 1)):
  if A[i] >= B[-1]:
    B.append(A[i])
  else:
    index = bisect.bisect_right(B, A[i])
    B[index] = A[i]
print(len(B))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

n = 1
m = [A[0]]
for i in range(1, N):
  for j in range(n):
    if m[j] < A[i]:
      m[j] = A[i]
      break
  else:
    n += 1
    m.append(A[i])
print(n)


Fixed submission:
import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[N - 1]]
for i in reversed(range(0, N - 1)):
  if A[i] >= B[-1]:
    B.append(A[i])
  else:
    index = bisect.bisect_right(B, A[i])
    B[index] = A[i]
print(len(B))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

n = 0
visited = [False] * N
while True:
  l = -1
  for i in range(N):
    if not visited[i]:
      visited[i] = True
      l = A[i]
      break
  if l == -1:
    break
  r = -1
  for i in range(N):
    if not visited[i]:
      if l < A[i] and r < A[i]:
        visited[i] = True
        r = A[i]
  n += 1
print(n)

Fixed submission:
import bisect

N = int(input())
A = [0] * N
for i in range(N):
  A[i] = int(input())

B = [A[N - 1]]
for i in reversed(range(0, N - 1)):
  if A[i] >= B[-1]:
    B.append(A[i])
  else:
    index = bisect.bisect_right(B, A[i])
    B[index] = A[i]
print(len(B))