Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
[N,K]=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]

dp=[0 for i in range(N)]

for i in range(1,N):
  dp[N-1-i]=dp[N-i]+np.abs(h[N-i-1]-h[N-i])
  for j in range(2,np.min(K+1,i+1)):
    dp[N-i-1]=np.min(dp[N-i-1+j]+np.abs(h[N-i-1]-h[N-1-i+j]),dp[N-i-1])
print(dp[0]) 

Fixed submission:
import numpy as np
import sys
input = sys.stdin.readline
[N,K]=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
h=np.array(h)
dp=np.zeros(N,dtype=int)
 
for i in range(1,N):
  last=min(K,i)+N-i
  dp[N-i-1]=min(dp[N-i:last]+np.abs(h[N-i:last]-h[N-i-1]))
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
[N,K]=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]

dp=[0 for i in range(N)]

for i in range(1,N):
  dp[N-1-i]=dp[N-i]+abs(h[N-i-1]-h[N-i])
  for j in range(2,min(K+1,i+1)):
    dp[N-i-1]=min(dp[N-i-1+j]+abs(h[N-i-1]-h[N-1-i+j]),dp[N-i-1])
print(dp[0]) 

Fixed submission:
import numpy as np
import sys
input = sys.stdin.readline
[N,K]=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
h=np.array(h)
dp=np.zeros(N,dtype=int)
 
for i in range(1,N):
  last=min(K,i)+N-i
  dp[N-i-1]=min(dp[N-i:last]+np.abs(h[N-i:last]-h[N-i-1]))
print(dp[0])

Buggy python submission (verdict: Time Limit Exceeded):
[N,K]=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]

dp=[0 for i in range(N)]

for i in range(N):
  for j in range(1,K+1):
    if j==1 and N-1+j-i<=N-1:
      dp[N-1-i]=dp[N-i]+abs(h[N-i-1]-h[N-i])
    elif N-1-i+j<=N-1:
      dp[N-i-1]=min(dp[N-i-1+j]+abs(h[N-i-1]-h[N-1-i+j]),dp[N-i-1])
print(dp[0])

Fixed submission:
import numpy as np
import sys
input = sys.stdin.readline
[N,K]=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
h=np.array(h)
dp=np.zeros(N,dtype=int)
 
for i in range(1,N):
  last=min(K,i)+N-i
  dp[N-i-1]=min(dp[N-i:last]+np.abs(h[N-i:last]-h[N-i-1]))
print(dp[0])
Buggy python submission (verdict: Runtime Error):
[N,W]=[int(x) for x in input().split()]
wv=[[0,0]]
for i in range(N):
  wv.append([int(x) for x in input().split()]) 
dp=np.zeros([N+1,W+i],dtype=int)
for i in range(1,N+1):
  dp[i][:w]=dp[i-1][:w]
  dp[i][w:]=max(dp[i-1][w:],dp[i-1][w-wv[i][0]:]+wv[i][1])

print(dp[N][W])
  

Fixed submission:
import numpy as np
[N,W]=[int(x) for x in input().split()]
dp=np.zeros([N+1,W+1],dtype=int)
for i in range(1,N+1):
  w, v=map(int,input().split())
  dp[i][:w]=dp[i-1][:w]
  dp[i][w:]=np.maximum(dp[i-1][w:],dp[i-1][:W-w+1]+v)
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
[N,W]=[int(x) for x in input().split()]
weight_and_value=[[0,0]]
for i in range(N):
  weight_and_value.append([int(x) for x in input().split()]) 
dp=[[0 for i in range(W+1)] for i in range(N+1)]
for i in range(1,N+1):
  for w in range(W+1):
    if weight_and_value[i][0]>w:
      dp[i][w]=dp[i-1][w]
    else:
      dp[i][w]=max(dp[i-1][w],dp[i-1][w-weight_and_value[i][0]]+weight_and_value[i][1])

print(dp[N][W])
  

Fixed submission:
import numpy as np
[N,W]=[int(x) for x in input().split()]
dp=np.zeros([N+1,W+1],dtype=int)
for i in range(1,N+1):
  w, v=map(int,input().split())
  dp[i][:w]=dp[i-1][:w]
  dp[i][w:]=np.maximum(dp[i-1][w:],dp[i-1][:W-w+1]+v)
print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if ab<=0:
  print('Zero')
elif a>0:
  print('Positive')
elif b<0:
  if (b-a+1)%2==0:
    print('Positive')
  else:
    print('Negative')

Fixed submission:
a,b=map(int,input().split())
if a*b<=0:
  print('Zero')
elif a>0:
  print('Positive')
elif b<0:
  if (b-a+1)%2==0:
    print('Positive')
  else:
    print('Negative')
Buggy python submission (verdict: Time Limit Exceeded):
words = lambda t : list(map(t, input().split()))
n = int(input())
a = input()

d = {}
for i in range(n-2):
    nums = [0]*10
    for j in range(i+2,n):
        nums[int(a[j-1])] += 1
        #print(i,j, nums)
        for k in range(10):
            if nums[k] > 0:
                d[int(a[i])*100 + k*10 + int(a[j])] = 1
        #print(d)

print(len(d))


Fixed submission:
words = lambda t : list(map(t, input().split()))
n = int(input())
a = input()

d = {}
r_nums = [0] * 10
for i in range(1,n):
    r_nums[int(a[i])] += 1
l_nums = [0] * 10

for i in range(1,n-1):
    center = int(a[i])
    r_nums[int(a[i])] -= 1
    l_nums[int(a[i-1])] += 1
    #print(l_nums, center, r_nums)
    for j in range(10):
        for k in range(10):
            if r_nums[j] > 0 and l_nums[k] > 0:
                d[k*100 + center*10 + j] = 1
    #print(d)
print(len(d))
Buggy python submission (verdict: Runtime Error):
import math
words = lambda t : list(map(t, input().split()))
a,b,x = words(int)

k = x / (a*a)
if k*2 == b:
    print(45)
elif k*2 < b:
    print(90 - math.degrees(math.atan(2*x/(a*b*b))))
else:
    p = ((a*b)- (x/a)) / (a/2)
    print(90 - math.degrees(math.atan(a/p)))


Fixed submission:
import math
words = lambda t : list(map(t, input().split()))
a,b,x = words(int)

k = x / (a*a)
if k == b:
    print(0)
elif k*2 == b:
    print(45)
elif k*2 < b:
    print(90 - math.degrees(math.atan(2*x/(a*b*b))))
else:
    p = ((a*b)- (x/a)) / (a/2)
    print(90 - math.degrees(math.atan(a/p)))

Buggy python submission (verdict: Runtime Error):
import math
words = lambda t : list(map(t, input().split()))
a,b,x = words(int)

k = x / (a*a)
print(k)
if k*2 == b:
    print(45)
elif k*2 < b:
    print(90 - math.degrees(math.atan(2*x/(a*b*b))))
else:
    p = ((a*b)- (x/a)) / (a/2)
    print(90 - math.degrees(math.atan(a/p)))


Fixed submission:
import math
words = lambda t : list(map(t, input().split()))
a,b,x = words(int)

k = x / (a*a)
if k == b:
    print(0)
elif k*2 == b:
    print(45)
elif k*2 < b:
    print(90 - math.degrees(math.atan(2*x/(a*b*b))))
else:
    p = ((a*b)- (x/a)) / (a/2)
    print(90 - math.degrees(math.atan(a/p)))

Buggy python submission (verdict: Runtime Error):
import math
words = lambda t : list(map(t, input().split()))
a,b,x = words(int)

k = x / (a*a)
print(k)
if k*2 == b:
    print(45)
elif k*2 < b:
    print(90 - math.degrees(math.atan(2*x/(a*b*b))))
else:
    p = ((a*b)- (x/a)) / (a/2)
    print(90 - math.degrees(math.atan(a/p)))


Fixed submission:
import math
words = lambda t : list(map(t, input().split()))
a,b,x = words(int)

k = x / (a*a)
if k == b:
    print(0)
elif k*2 == b:
    print(45)
elif k*2 < b:
    print(90 - math.degrees(math.atan(2*x/(a*b*b))))
else:
    p = ((a*b)- (x/a)) / (a/2)
    print(90 - math.degrees(math.atan(a/p)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
xs = list(map(int,input().split()))
xs.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if xs[i] + xs[j] <= xs[k]:
        break
      ans += 1
print(ans)




Fixed submission:
import bisect

n = int(input())
xs = list(map(int,input().split()))
xs.sort()
ans = 0

for i in range(n-2):
  for j in range(i+1,n-1):
    k = bisect.bisect_left(xs[j+1:], xs[i]+xs[j])
    #print(xs[j+1:], k, xs[i]+xs[j])
    ans += k
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
xs = list(map(int,input().split()))
xs.sort()
ans = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if xs[i] + xs[j] <= xs[k]:
        break
      ans += 1
print(ans)

Fixed submission:
import bisect

n = int(input())
xs = list(map(int,input().split()))
xs.sort()
ans = 0

for i in range(n-2):
  for j in range(i+1,n-1):
    k = bisect.bisect_left(xs[j+1:], xs[i]+xs[j])
    #print(xs[j+1:], k, xs[i]+xs[j])
    ans += k
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

res = True
for i in range(lens(s)):
  if i % 2 == 0 and s[i] == 'L':
    res = False
    break
  if i % 2 == 1 and s[i] == 'R':
    res = False
    break

if res:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
 
res = True
for i in range(len(s)):
  if i % 2 == 0 and s[i] == 'L':
    res = False
    break
  if i % 2 == 1 and s[i] == 'R':
    res = False
    break
 
if res:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10**6 + 1000)

par = [0]
words = lambda t : list(map(t, input().split()))
n,q = words(int)
edges = [[] for _ in range(n)]
for i in range(n-1):
    a,b = words(int)
    edges[a-1].append(b-1)

points = [0] * n
for i in range(q):
    p,x = words(int)
    points[p-1] += x

ans = [0] * n
def digTree(cur, sum_p):
    #print("debug: ", cur, sum_p)
    sum_pp = sum_p +  points[cur]
    ans[cur] = sum_pp
    for child in edges[cur]:
        digTree(child, sum_pp)

digTree(0, 0)
print(" ".join(map(str,ans)))


Fixed submission:
import sys

sys.setrecursionlimit(10**6 + 1000)


words = lambda t : list(map(t, input().split()))
n,q = words(int)
par = [0] * n
for i in range(n-1):
    a,b = words(int)
    par[b-1] = a-1

points = [0] * n
for i in range(q):
    p,x = words(int)
    points[p-1] += x

ans = [0] * n
ans[0] = points[0]
for i in range(1,n):
    ans[i] = ans[par[i]] + points[i]


print(" ".join(map(str,ans)))

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

sys.setrecursionlimit(10**5)

words = lambda t : list(map(t, input().split()))
n,q = words(int)
edges = [[] for _ in range(n)]
for i in range(n-1):
    a,b = words(int)
    edges[a-1].append(b-1)

points = [0] * n
for i in range(q):
    p,x = words(int)
    points[p-1] += x

ans = [0] * n
def digTree(edges, points, cur, sum_p):
    #print("debug: ", cur, sum_p)
    sum_pp = sum_p +  points[cur]
    ans[cur] = sum_pp
    for child in edges[cur]:
        digTree(edges, points, child, sum_pp)

digTree(edges, points, 0, 0)
print(" ".join(map(str,ans)))


Fixed submission:
import sys

sys.setrecursionlimit(10**6 + 1000)


words = lambda t : list(map(t, input().split()))
n,q = words(int)
par = [0] * n
for i in range(n-1):
    a,b = words(int)
    par[b-1] = a-1

points = [0] * n
for i in range(q):
    p,x = words(int)
    points[p-1] += x

ans = [0] * n
ans[0] = points[0]
for i in range(1,n):
    ans[i] = ans[par[i]] + points[i]


print(" ".join(map(str,ans)))
Buggy python submission (verdict: Time Limit Exceeded):
words = lambda t : list(map(t, input().split()))
n,k = words(int)
xs = words(int)

def divisor (x):
    ans = [1]
    for i in range(2, x//2+1):
        if x % i == 0:
            ans.append(i)
    ans.append(x)
    return list(reversed(ans))

s = sum(xs)
ds = divisor(s)
ans = 1
#print(ds)
for d in ds:
    ms = []
    for x in xs:
        ms.append(x%d)
    ms.sort()
    #print(d,ms)
    f = 0
    f_ttl = ms[f]
    b = len(ms)-1
    b_ttl = d - ms[b]
    while f != b:
        if f_ttl >= b_ttl:
            b -= 1
            b_ttl += d - ms[b]
        else:
            f += 1
            f_ttl += ms[f]
    if k >= f_ttl:
        ans = d
        break
print(ans)


Fixed submission:
words = lambda t : list(map(t, input().split()))
n,k = words(int)
xs = words(int)

def divisor (x):
    ans = []
    for i in range(1, int(x**0.5)+1):
        if x % i == 0:
            ans.append(i)
            if i != x // i:
                ans.append(x//i)
    ans.sort()
    return list(reversed(ans))

s = sum(xs)
#print(s)
ds = divisor(s)
ans = 1
#print(ds)
for d in ds:
    ms = []
    for x in xs:
        ms.append(x%d)
    ms.sort()
    #print(d,ms)
    f = 0
    f_ttl = ms[f]
    b = len(ms)-1
    b_ttl = d - ms[b]
    while f != b:
        if f_ttl >= b_ttl:
            b -= 1
            b_ttl += d - ms[b]
        else:
            f += 1
            f_ttl += ms[f]
    if k >= f_ttl:
        ans = d
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

s_xs = sorted(xs)
ans = False
if s_xs == xs:
    ans = True
else:
    for i in range(n-1):
        for j in range(i,n):
            f_xs = xs.copy()
            tmp = f_xs[i]
            f_xs[i] = f_xs[j]
            f_xs[j] = tmp
            if s_xs == f_xs:
                ans = True
                break
        if ans == True:
            break
if ans == True:
    print("YES")
else:
    print("NO")


Fixed submission:
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

s_xs = sorted(xs)
ans = False
if s_xs == xs:
    ans = True
else:
    for i in range(n-1):
        for j in range(i,n):
            f_xs = xs.copy()
            tmp = f_xs[i]
            f_xs[i] = f_xs[j]
            f_xs[j] = tmp
            if s_xs == f_xs:
                ans = True
                break
        if ans == True:
            break
if ans == True:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
import numpypy as np
words = lambda t : list(map(t, input().split()))



h,w = words(int)
wq = [0] * w

grid = []
for i in range(h):
    grid.append(list(input()))

ans = 0
for i in range(h):
    j = 0
    while j < w:
        #print(i,j, grid[i][j])
        if grid[i][j] == '#':
            wq[j] = 0
            j+=1
            continue
        k = 0
        while j+k < w:
            if grid[i][j+k] == '.':
                k += 1
            else:
                break
        #print(i,j,k)
        if k + h > ans:
            for x in range(j,j+k):
                vplus = 0
                if not wq[x] == 0:
                    vplus = wq[x]
                else:
                    for vi in range(i-1,-1,-1):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                    for vi in range(i+1,h):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                ans = max(ans, vplus+k)
                wq[x] = vplus
        j += k
print(ans)


Fixed submission:
import numpy as np
words = lambda t : list(map(t, input().split()))
pqr = words(int)

pqr.sort()
print(pqr[0] + pqr[1])
Buggy python submission (verdict: Runtime Error):
import numpy as np
words = lambda t : list(map(t, input().split()))



def search(i, visited, ns, ans) :
    #print(i+1)
    visited[i] = True
    for next, weight in ns[i]:
        if visited[next] == False:
            if weight % 2 == 0:
                ans[next] = ans[i]
            else:
                ans[next] = (ans[i]+1) % 2
            search(next, visited, ns, ans)


def dfs(ns, ans):
    visited = [False] * len(ns)
    search(0, visited, ns, ans)

def main():
    n = int(input())
    ns = [[] for _ in range(n)]
    for _ in range(n-1):
        (st,end,weight) = map(int,input().split())
        ns[st-1].append((end - 1,weight))
        ns[end-1].append((st-1,weight))
    ans = [0] * n
    dfs(ns, ans)
    for a in ans:
        print(a)

if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
words = lambda t : list(map(t, input().split()))

n,k = words(int)
str = input()

c = str[k-1]
ans = str[:k-1] + c.lower() + str[k:]
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
def search(i, visited, ns) :
    #print(":", i+1)
    visited[i] = True
    for next, weight in ns[i]:
        if visited[next] == False:
            search(next, visited, ns)


def dfs(ns):
    visited = [False] * len(ns)
    ans = 0
    for i in range(len(ns)):
        if not visited[i]:
            #print(i+1)
            ans += 1
            search(i, visited, ns)
    return ans

def main():
    n,m = map(int,input().split())
    ns = [[] for _ in range(n)]
    for _ in range(m):
        (st,end,weight) = map(int,input().split())
        ns[st-1].append((end - 1,weight))
        ns[end-1].append((st-1,weight))
    ans = dfs(ns)
    print(ans)
if __name__ == '__main__':
    main()


Fixed submission:
import sys
sys.setrecursionlimit(150000)
def search(i, visited, ns) :
    #print(":", i+1)
    visited[i] = True
    for next, weight in ns[i]:
        if visited[next] == False:
            search(next, visited, ns)


def dfs(ns):
    visited = [False] * len(ns)
    ans = 0
    for i in range(len(ns)):
        if not visited[i]:
            #print(i+1)
            ans += 1
            search(i, visited, ns)
    return ans

def main():
    n,m = map(int,input().split())
    ns = [[] for _ in range(n)]
    for _ in range(m):
        (st,end,weight) = map(int,input().split())
        ns[st-1].append((end - 1,weight))
        ns[end-1].append((st-1,weight))
    ans = dfs(ns)
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math

words = lambda t : list(map(t, input().split()))

n = int(input())
a = words(int)

if n == 2:
    print(max(a[0],a[1]))

else:
    cgcdm1 = max(math.gcd(a[0],a[1]),math.gcd(a[1],a[2]),math.gcd(a[2],a[0]))
    allgcd = math.gcd(a[0],math.gcd(a[1],a[2]))

    for i in range(3,n):
        cgcdm1 = max(math.gcd(cgcdm1,a[i]),allgcd)
        allgcd = math.gcd(allgcd, a[i])

    print(cgcdm1)


Fixed submission:
import math

words = lambda t : list(map(t, input().split()))


def gcd (a,b):
    if a > b:
        t = b
        b = a
        b = t
    v = b
    while (a % b != 0):
        t = a % b
        a = b
        b = t
        v = b
    return v


n = int(input())
a = words(int)

if n == 2:
    print(max(a[0],a[1]))

else:
    cgcdm1 = max(gcd(a[0],a[1]),gcd(a[1],a[2]),gcd(a[2],a[0]))
    allgcd = gcd(a[0],gcd(a[1],a[2]))

    for i in range(3,len(a)):
        cgcdm1 = max(gcd(cgcdm1,a[i]),allgcd)
        allgcd = gcd(allgcd, a[i])

    print(cgcdm1)


def gcd (a,b):
    if a > b:
        t = b
        b = a
        b = t
    v = b
    while (a % b != 0):
        t = a % b
        a = b
        b = t
        v = b
    return v
Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = list(reversed(sorted(a)))
b = list(reversed(sorted(b)))
c = list(reversed(sorted(c)))

ab = []
for i in range(min(len(a), k)):
    ax = a[i]
    for j in range(min(len(b), k)):
        bx = b[j]
        ab.append(ax+bx)
ab = list(reversed(sorted(ab)))

abc = []
for i in range(min(k, len(ab))):
    abx = ab[i]
    for j in range(min(k, len(c))):
        cx = c[j]
        abc.append(abx + cx)

abc = list(reversed(sorted(abc)))

for i in range(k):
    print(abc[i])


Fixed submission:
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = list(reversed(sorted(a)))
b = list(reversed(sorted(b)))
c = list(reversed(sorted(c)))

abc = []
for p in range(x):
    for q in range(y):
        if (p+1) * (q+1) > k:
            break
        for r in range(z):
            if (p+1) * (q+1) * (r+1) > k:
                break
            abc.append(a[p]+ b[q] + c[r])

abc = list(reversed(sorted(abc)))

for i in range(k):
    print(abc[i])

Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ab = []
for ax in a:
    for bx in b:
        ab.append(ax+bx)
ab = list(reversed(sorted(ab)))

abc = []
for i in range(min(k, len(ab))):
    abx = ab[i]
    for cx in c:
        abc.append(abx + cx)

abc = list(reversed(sorted(abc)))

for i in range(k):
    print(abc[i])


Fixed submission:
x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = list(reversed(sorted(a)))
b = list(reversed(sorted(b)))
c = list(reversed(sorted(c)))

abc = []
for p in range(x):
    for q in range(y):
        if (p+1) * (q+1) > k:
            break
        for r in range(z):
            if (p+1) * (q+1) * (r+1) > k:
                break
            abc.append(a[p]+ b[q] + c[r])

abc = list(reversed(sorted(abc)))

for i in range(k):
    print(abc[i])
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int, input().split())
s = input()
lr = []
for _ in range(q):
    l,r = map(int, input().split())
    lr.append((l,r))


for l,r in lr:
    total = 0
    aflag = False
    for i in range(l-1,r):
        c = s[i]
        if aflag:
            if c == 'C':
                total += 1
            aflag = False
        else:
            if c == 'A':
                aflag = True
    print(total)


Fixed submission:
n,q = map(int, input().split())
s = input()
lr = []
for _ in range(q):
    l,r = map(int, input().split())
    lr.append((l,r))

x = [0] * len(s)
cur = 0
for i in range(len(s)-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cur += 1
    x[i+1] = cur

#print(x)
for l,r in lr:
    print(x[r-1] - x[l-1])
Buggy python submission (verdict: Runtime Error):

alphabet = "abcdefghijklmnopqrstuvwxyz"
indmap = {}
for i, c in enumerate(alphabet):
    indmap[c] = i

MOD = 10L**9 + 7L

def main():
    n = int(input())
    s = input()

    counts = [0L]*26
    for c in s:
        counts[indmap[c]] += 1L

    #print(counts)
    total = 1L
    for k in counts:
        total *= (k+1L)
        total % MOD
    print(total-1)

main()


Fixed submission:

alphabet = "abcdefghijklmnopqrstuvwxyz"
indmap = {}
for i, c in enumerate(alphabet):
    indmap[c] = i

MOD = 10**9 + 7

def main():
    n = int(input())
    s = input()

    counts = [0]*26
    for c in s:
        counts[indmap[c]] += 1

    #print(counts)
    total = 1
    for k in counts:
        total *= (k+1)

    print((total-1) % MOD)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):

alphabet = "abcdefghijklmnopqrstuvwxyz"
indmap = {}
for i, c in enumerate(alphabet):
    indmap[c] = i

MOD = 10L**9L + 7L

def main():
    n = int(input())
    s = input()

    counts = [0L]*26
    for c in s:
        counts[indmap[c]] += 1L

    #print(counts)
    total = 1L
    for k in counts:
        total *= (k+1L)
        total % MOD
    print(total-1)

main()


Fixed submission:

alphabet = "abcdefghijklmnopqrstuvwxyz"
indmap = {}
for i, c in enumerate(alphabet):
    indmap[c] = i

MOD = 10**9 + 7

def main():
    n = int(input())
    s = input()

    counts = [0]*26
    for c in s:
        counts[indmap[c]] += 1

    #print(counts)
    total = 1
    for k in counts:
        total *= (k+1)

    print((total-1) % MOD)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
s = int(input())

t = [False] * 1000000

while True:
  if s > 1000000:
    continue
  if t[s] == True:
    break
  if s % 2 == 0:
    s = s // 2
  else:
    s = 3 * s + 1

print(s)

Fixed submission:
s = int(input())
 
t = [False] * 1000001
i = 1
while True:
  if s <= 1000000 and t[s] == True:
    break
  t[s] = True
  i += 1
  if s % 2 == 0:
    s = s // 2
  else:
    s = 3 * s + 1
 
print(i)