Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = []
res = []

for i in range(N):
    S = input()
    L.append(S)
    L.sort()

max_cnt = 0
cnt = 0

L.append(0)

for i in range(len(L) - 1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            res = []
            res.append(L[i])
        elif cnt == max_cnt:
            res.append(L[i])
        cnt = 0

for i in res:
    print(i)

Fixed submission:
N = int(input())
L = []
res = []

for i in range(N):
    S = input()
    L.append(S)

L.sort()

max_cnt = 0
cnt = 0

L.append(0)

for i in range(len(L) - 1):
    if L[i] == L[i+1]:
        cnt += 1
    else:
        if cnt > max_cnt:
            max_cnt = cnt
            res = []
            res.append(L[i])
        elif cnt == max_cnt:
            res.append(L[i])
        cnt = 0

for i in res:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

cnt = 1

for i in range(1, len(P)):
    if min(P[0:i]) >= P[i]:
        cnt += 1

print(cnt)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))

cnt = 0
mini = float('inf')

for i in range(0, len(P)):
    if P[i] < mini:
        cnt += 1
        mini = P[i]

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

cnt = 1

for i in range(1, len(P)):
    if min(P[0:i]) >= P[i]:
        cnt += 1

print(cnt)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))

cnt = 0
mini = float('inf')

for i in range(0, len(P)):
    if P[i] < mini:
        cnt += 1
        mini = P[i]

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

cnt = 1

for i in range(len(P)):
    for j in range(0, i):
        if P[i] <= P[j]:
            if i == j+1:
                cnt += 1
            pass
        else:
            break

print(cnt)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))

cnt = 0
mini = float('inf')

for i in range(0, len(P)):
    if P[i] < mini:
        cnt += 1
        mini = P[i]

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ac = []
pena = 0
walen = [0]*N

for i in range(M):
    p, S = map(str, input().split())
    p = int(p) - 1
    if p in ac:
        continue
    elif S == 'AC':
        ac.append(p)
        pena += walen[p]
    else:
        walen[p] += 1

print(len(set(ac)), pena)

Fixed submission:
N, M = map(int, input().split())
ac = set()
pena = 0
walen = [0]*N

for i in range(M):
    p, S = map(str, input().split())
    p = int(p) - 1
    if p in ac:
        continue
    elif S == 'AC':
        ac.add(p)
        pena += walen[p]
    else:
        walen[p] += 1

print(len(ac), pena)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
ac = []
pena = 0
walen = [0]*N

for i in range(M):
    p, S = map(str, input().split())
    p = int(p) - 1
    if p in ac:
        pass
    elif S == 'AC':
        ac.append(p)
        pena += walen[p]
    else:
        walen[p] += 1

print(len(set(ac)), pena)

Fixed submission:
N, M = map(int, input().split())
ac = set()
pena = 0
walen = [0]*N

for i in range(M):
    p, S = map(str, input().split())
    p = int(p) - 1
    if p in ac:
        continue
    elif S == 'AC':
        ac.add(p)
        pena += walen[p]
    else:
        walen[p] += 1

print(len(ac), pena)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

mini = float('inf')

if sum(A[0:(N//2)]) < sum(A[(N//2):N]):
    for i in range(N//2 + 1):
        if abs(sum(A[0:i+(N//2)]) - sum(A[i+(N//2):N])) < mini:
            mini = abs(sum(A[0:i+(N//2)]) - sum(A[i+(N//2):N]))
elif sum(A[0:(N//2)]) > sum(A[(N//2):N]):
    for i in range(N//2 + 1):
        if abs(sum(A[0:(N//2)-i]) - sum(A[(N//2)-i:N])) < mini:
            mini = abs(sum(A[0:(N//2)-i]) - sum(A[(N//2)-i:N]))
else:
    print(0)
    exit()

'''
for i in range(N):
    if abs(sum(A[0:i]) - sum(A[i:N])) < mini:
        mini = abs(sum(A[0:i]) - sum(A[i:N]))
    if abs(sum(A[0:-i]) - sum(A[-i:N])) < mini:
        mini = abs(sum(A[0:-i]) - sum(A[-i:N]))
    if mini == 0:
        break
'''

print(mini)


Fixed submission:
import itertools
N = int(input())
A = list(map(int, input().split()))

mini = float('inf')

cumsum = list(itertools.accumulate(A))
A.reverse()
rev = list(itertools.accumulate(A))
rev.reverse()
cumsum.pop()
rev.pop(0)

for i, j in zip(cumsum,rev):
    if abs(i-j) < mini:
        mini = abs(i-j)

print(mini)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

mini = float('inf')

for i in range(N):
    if abs(sum(A[0:i]) - sum(A[i:N])) < mini:
        mini = abs(sum(A[0:i]) - sum(A[i:N]))
    if abs(sum(A[0:-i]) - sum(A[-i:N])) < mini:
        mini = abs(sum(A[0:-i]) - sum(A[-i:N]))
    if mini == 0:
        break

print(mini)


Fixed submission:
import itertools
N = int(input())
A = list(map(int, input().split()))

mini = float('inf')

cumsum = list(itertools.accumulate(A))
A.reverse()
rev = list(itertools.accumulate(A))
rev.reverse()
cumsum.pop()
rev.pop(0)

for i, j in zip(cumsum,rev):
    if abs(i-j) < mini:
        mini = abs(i-j)

print(mini)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

mini = float('inf')

for i in range(N):
    if abs(sum(A[0:i]) - sum(A[i:N])) < mini:
        mini = abs(sum(A[0:i]) - sum(A[i:N]))

print(mini)


Fixed submission:
import itertools
N = int(input())
A = list(map(int, input().split()))

mini = float('inf')

cumsum = list(itertools.accumulate(A))
A.reverse()
rev = list(itertools.accumulate(A))
rev.reverse()
cumsum.pop()
rev.pop(0)

for i, j in zip(cumsum,rev):
    if abs(i-j) < mini:
        mini = abs(i-j)

print(mini)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

mini = float('inf')

for i in range(N):
    if abs(sum(A[0:i]) - sum(A[i:N])) < mini:
        mini = abs(sum(A[0:i]) - sum(A[i:N]))

print(mini)


Fixed submission:
import itertools
N = int(input())
A = list(map(int, input().split()))

mini = float('inf')

cumsum = list(itertools.accumulate(A))
A.reverse()
rev = list(itertools.accumulate(A))
rev.reverse()
cumsum.pop()
rev.pop(0)

for i, j in zip(cumsum,rev):
    if abs(i-j) < mini:
        mini = abs(i-j)

print(mini)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())

L = []

for i in range(Q):
    A = int(input())
    L.append(A)

for i in range(N):
    if K > Q - L.count(i+1):
        print('Yes')
    else:
        print('No')  

Fixed submission:
N, K, Q = map(int, input().split())

L = [K]*N

for i in range(Q):
    A = int(input())
    L[A-1] += 1

for i in L:
    if i - Q > 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
li = []

for i in range(N):
    A = int(input())
    li.append(A)

li2 = sorted(li,reverse=True)

for i in range(N):
    ans = max(li)
    if(ans == li[i]):
        print(li2[1])
    else:
        print(ans)
    
        

Fixed submission:
N = int(input())
li = []

for i in range(N):
    A = int(input())
    li.append(A)

li2 = sorted(li,reverse=True)
ans = max(li)

for i in range(N):
    if(ans == li[i]):
        print(li2[1])
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
mini = 2018
minib = 2018

if R-L >= 2019:
    print('0')
else:
    for i in range(L, R+1):
        if (i % 2019) < mini:
            mini = i % 2019
            ans = i
            if i % 2019 == 0:
                ans = 0
                print('0')
                break

        for j in range(L, R+1):
            if j == ans:
                continue
            if (j % 2019) < minib:
                minib = j % 2019
                sansb = j

    calc = ((ans%2019) * (ansb%2019)) % 2019
    print(calc)

Fixed submission:
L, R = map(int, input().split())
mini = 2020

if R-L >= 2019:
    print('0')
else:
    for i in range(L, R):
        for j in range(i+1, R+1):
            mini = min(mini, (i*j)%2019)
    print(mini)

Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
mini = 100000000000000
minib = 100000000000000

if R-L > 2019:
    print('0')
else:
    for i in range(L, R):
        if (i % 2019) < mini:
            mini = i % 2019
            ans = i

    for j in range(L, R):
        if j == ans:
            continue
        if (j % 2019) < minib:
            minib = j % 2019
            ansb = j

    calc = ((ans%2019) * (ansb%2019)) % 2019
    print(calc)

Fixed submission:
L, R = map(int, input().split())
mini = 2020

if R-L >= 2019:
    print('0')
else:
    for i in range(L, R):
        for j in range(i+1, R+1):
            mini = min(mini, (i*j)%2019)
    print(mini)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
from math import factorial

N, K = map(int, input().split())
# subli = []


def P(n,r):
    return factorial(n) // factorial(n-r)

def C(n,r):
    return P(n,r) // factorial(r)


for i in range(1, K+1):
    '''
    n = N - K + i
    ans = math.factorial(n) // (math.factorial(N-K) * math.factorial(i))
    '''
    ans = C(N-K+1, i) * C(K-1, i-1)
    print(ans % (10**9 + 7))

Fixed submission:
#coding:utf-8

S = list(input())

S.sort()

if S[0] == S[1] and S[2] == S[3]:
    if S[0] == S[1] == S[2] == S[3]:
        print('No')
    else:
        print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
p = 0
cntC = int(B / C) - int(A / C)
cntD = int(B / D) - int(A / D)

#a,bの最大公約数
def gcd(C, D):
    while D:
        C, D = D, C % D
    return C

#a,bの最小公倍数
def lcm(C, D):
    return C * D // gcd (C, D)


CD = lcm(C, D)

cntCD = int(B / CD) - int(A / CD)

# print(cntC, cntD, cntCD, CD)
calc = (B-A+1) - (cntC + cntD - cntCD)

if (A % C) == 0 and (B % D) == 0:
        calc -= 1

print(calc)

Fixed submission:
S = list((input()))
fl = True

for i in range(len(S)-1):
    if S[i] == S[i+1]:
        fl = False

if fl == True:
    print('Good')
else:
    print('Bad')
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
cnt = 0
li = []

for i in range(N):
    li.append(M)

# print(li)

for i in range(M):
    L, R = map(int, input().split())
    for j in range(L-1, R):
        li[j] = li[j] - 1
        # print(li)

for i in range(0, len(li)):
    if li[i] == 0:
        cnt += 1

print(cnt)

Fixed submission:
N, M = map(int, input().split())

L = []

for i in range(M):
    LR = list(map(int, input().split()))
    L.append(LR)

res = [L[0][0], L[0][1]]

for i in range(M):
    res = [max(res[0], L[i][0]), min(res[1], L[i][1])]

if res[1] < res[0]:
    print(0)
else: 
    print(res[1] - res[0] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

R, G, B, N = map(int, input().split())

cnt = 0

for x in range(N+1):
    for y in range(N-x+1):
        '''
        if (N - x*R - y*G ) % B == 0:
            cnt += 1
        '''
        for z in range(N-x-y+1):
            if N == x*R + y*G + z*B:
                cnt += 1


print(cnt)

Fixed submission:
#coding:utf-8

R, G, B, N = map(int, input().split())

cnt = 0

for red in range(int(N/R)+1):
    for green in range(int((N-red*R)/G)+1):
        if (N - (red*R + green*G)) % B == 0:
            cnt += 1

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

def main():
    n, q = map(int, input().split())
    s = input()
    slist = list(s)
    point = []
    for i in range(q):
        c = 0
        l, r = map(int, input().split())
        for j in range(l-1,r-1):
            if slist[j] == 'A' and slist[j+1] == 'C':
                c += 1
            else:
                pass
        point.append(c)

    for k in range(len(point)):
        print(point[k])


if __name__ == "__main__":
    main()

Fixed submission:
#coding-utf:8

def main():
    n, q = map(int, input().split())
    s = input()
    t = [0] * (n+1)
    for i in range(n):
        if s[i : i+2] == 'AC':
            x = 1
        else:
            x = 0
        t[i+1] = t[i] + x
        x = 0

    for j in range(q):
        l, r = map(int, input().split())
        print(t[r-1] - t[l-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

def main():
    n, q = map(int, input().split())
    s = input()
    slist = list(s)
    point = []
    for i in range(q):
        c = 0
        l, r = map(int, input().split())
        for j in range(l-1,r-1):
            if slist[j] == 'A' and slist[j+1] == 'C':
                c += 1
            else:
                pass
        point.append(c)

    for k in range(len(point)):
        print(point[k])


if __name__ == "__main__":
    main()

Fixed submission:
#coding-utf:8

def main():
    n, q = map(int, input().split())
    s = input()
    t = [0] * (n+1)
    for i in range(n):
        if s[i : i+2] == 'AC':
            x = 1
        else:
            x = 0
        t[i+1] = t[i] + x
        x = 0

    for j in range(q):
        l, r = map(int, input().split())
        print(t[r-1] - t[l-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8

def main():
    n, q = map(int, input().split())
    s = input()
    slist = list(s)
    point = []
    for i in range(q):
        c = 0
        l, r = map(int, input().split())
        for j in range(l-1,r-1):
            if slist[j] == 'A':
                if slist[j+1] == 'C':
                    c += 1
                else:
                    pass
            else:
                pass
        point.append(c)

    for k in range(len(point)):
        print(point[k])


if __name__ == "__main__":
    main()

Fixed submission:
#coding-utf:8

def main():
    n, q = map(int, input().split())
    s = input()
    t = [0] * (n+1)
    for i in range(n):
        if s[i : i+2] == 'AC':
            x = 1
        else:
            x = 0
        t[i+1] = t[i] + x
        x = 0

    for j in range(q):
        l, r = map(int, input().split())
        print(t[r-1] - t[l-1])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import OrderedDict

A, B, K = map(int, input().split())
L = []
res = []

if K > B-A:
    for i in range(A, B+1):
        print(i)
    exit()
else:
    for i in range(A, B+1):
        L.append(i)
    for i in range(0, K):
        res.append(L[i])
    for i in range(len(L)-K, len(L)):
        res.append(L[i])

res_unique = list(set(res))
res_unique.sort()

for i in res_unique:
    print(i)

Fixed submission:
from collections import OrderedDict

A, B, K = map(int, input().split())
L = []
res = []

if K > B-A:
    for i in range(A, B+1):
        print(i)
    exit()
else:
    for i in range(A, A+K):
        res.append(i)
    for i in range(B-K+1, B+1):
        res.append(i)

res_unique = list(set(res))
res_unique.sort()

for i in res_unique:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import OrderedDict

A, B, K = map(int, input().split())
L = []
res = []

if K > B-A:
    for i in range(A, B+1):
        print(i)
    exit()
else:
    for i in range(A, B+1):
        L.append(i)
    for i in range(0, K):
        res.append(L[i])
    for i in range(len(L)-K, len(L)):
        res.append(L[i])

res_unique = list(set(res))
res_unique.sort()

for i in res_unique:
    print(i)

Fixed submission:
from collections import OrderedDict

A, B, K = map(int, input().split())
L = []
res = []

if K > B-A:
    for i in range(A, B+1):
        print(i)
    exit()
else:
    for i in range(A, A+K):
        res.append(i)
    for i in range(B-K+1, B+1):
        res.append(i)

res_unique = list(set(res))
res_unique.sort()

for i in res_unique:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import OrderedDict

A, B, K = map(int, input().split())
L = []
res = []

for i in range(A, B+1):
    L.append(i)

if K > B-A:
    for i in L:
        print(i)
    exit()
else:
    for i in range(0, K):
        res.append(L[i])
    for i in range(len(L)-K, len(L)):
        res.append(L[i])

res_unique = list(set(res))
res_unique.sort()

for i in res_unique:
    print(i)

Fixed submission:
from collections import OrderedDict

A, B, K = map(int, input().split())
L = []
res = []

if K > B-A:
    for i in range(A, B+1):
        print(i)
    exit()
else:
    for i in range(A, A+K):
        res.append(i)
    for i in range(B-K+1, B+1):
        res.append(i)

res_unique = list(set(res))
res_unique.sort()

for i in res_unique:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import functools
import operator

N = int(input())

L = list(range(1, N+1, 1))
prod = functools.partial(functools.reduce, operator.mul)

print(prod(L)%(10**9+7))


Fixed submission:
N = int(input())
calc = 1
for i in range(1, N+1):
    calc = (i*calc) % (10**9+7)

print(calc)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
calc = 1

for i in range(1, N+1):
    calc *= i

print(calc%(10**9+7))

Fixed submission:
N = int(input())
calc = 1
for i in range(1, N+1):
    calc = (i*calc) % (10**9+7)

print(calc)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

while s[0] != 'A':
    s.pop(0)

while s[-1] != 'Z':
    s.pop()

print(len(s))

Fixed submission:
s = list(input())

while s[0] != 'A' or s[-1] != 'Z':
    if s[0] == 'A':
        s.pop()
    elif s[-1] == 'Z':
        s.pop(0)
    else:
        s.pop(0)
        s.pop()

print(len(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
maxi = 0

for i in range(len(s)):
    if s[i] == 'A':
        for j in range(i, len(s)):
            if s[j] == 'Z' and j-i+1 > maxi:
                maxi = j-i+1

print(maxi)

Fixed submission:
s = list(input())

while s[0] != 'A' or s[-1] != 'Z':
    if s[0] == 'A':
        s.pop()
    elif s[-1] == 'Z':
        s.pop(0)
    else:
        s.pop(0)
        s.pop()

print(len(s))
Buggy python submission (verdict: Runtime Error):
n = int(input())
MOD = 1000000007

def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

if(n == 1):
    print(0)
elif (n == 2):
    print(2)
else:
    kotae = 0
    a = power_func(10,n,MOD)
    b = power_func(9,n,MOD)
    c = power_func(8,n,MOD)

    kotae = a + c - ( 2 * b)
    kotae = kotae % MOD

print(kotae)

Fixed submission:
n = int(input())
MOD = 1000000007

def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

if(n == 1):
    print(0)
elif (n == 2):
    print(2)
else:
    kotae = 0
    a = power_func(10,n,MOD)
    b = power_func(9,n,MOD)
    c = power_func(8,n,MOD)

    kotae = a + c - ( 2 * b)
    kotae = kotae % MOD
    print(kotae)

Buggy python submission (verdict: Runtime Error):
n = int(input())
MOD = 1000000007

if(n == 1):
    print(0)
elif (n == 2):
    print(2)
else:
    kotae = 0
    a = 1
    b = 1
    c = 1
    for i in range(n):
        a *= 10
        b *= 9
        c *= 8
        a = a % MOD
        b = b % MOD
        c = c % MOD
    kotae = a + c - ( 2 * b)
    kotae = kotae % MOD

print(kotae)

Fixed submission:
n = int(input())
MOD = 1000000007

def power_func(a,n,p):
    bi = str(format(n,"b"))#2進表現に
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

if(n == 1):
    print(0)
elif (n == 2):
    print(2)
else:
    kotae = 0
    a = power_func(10,n,MOD)
    b = power_func(9,n,MOD)
    c = power_func(8,n,MOD)

    kotae = a + c - ( 2 * b)
    kotae = kotae % MOD
    print(kotae)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())

temp = 0

while(n > 0):
    temp += n % 10
    temp = temp % 9
    n = n // 10

if(temp % 9 == 0):
    print("Yes")
else:
    print("No")

Fixed submission:
import math
n = int(input())

if(n % 9 == 0):
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())

temp = 0

while(n > 0):
    temp += n % 10
    n = n // 10

if(temp % 9 == 0):
    print("Yes")
else:
    print("No")

Fixed submission:
import math
n = int(input())

if(n % 9 == 0):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

kotae = 1
for i in range(n):
    kotae *= a[i]

if(kotae > 10 ** 18):
    kotae = -1

print(kotae)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

kotae = 1
for i in range(n):
    if(kotae == -1):
        if(a[i] == 0):
            kotae = 0
    else:
        kotae *= a[i]
    if(kotae > 10 ** 18):
        kotae = -1

print(kotae)
Buggy python submission (verdict: Runtime Error):
import math
from queue import Queue
 
n, m = [int(i) for i in input().split()]
 
root = [[ for _ in range(n+1)] for _ in range(n+1)]
 
for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a][b] = 1
    root[b][a] = 1
 
 
check = [0 for _ in range(n+1)]
check[1] = 1
 
q = Queue()
q.put(1)
 
while ( not q.empty() ):
    now = q.get()
    for i in range(1,n+1):
        if(root[now][i] == 1 and check[i] == 0):
            check[i] = now
            q.put(i)
 
flag = 1
for i in range(2, n+1):
    if(check[i] == 0):
        flag = 0
 
if(flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Fixed submission:
n = int(input())

n = n % 10

if(n == 2 or n == 4 or n == 5 or n == 7 or n == 9):
    print("hon")
elif(n == 3):
    print("bon")
else:
    print("pon")
Buggy python submission (verdict: Time Limit Exceeded):
import math
import copy

n = int(input())
#n, k = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
num = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
# s = [input() for i in range(n)]
#s = input()
# list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]
#s = [input() for i in range(n)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

kotae = 0
for i in range(0,n-1):
    for j in range(i+1,n):
        if(abs(i-j) == num[i]+num[j]):
            kotae += 1

print(kotae)


Fixed submission:
import math
import copy

n = int(input())
#n, k = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for j in range(n)]
#table = [list(input()) for n in range(h)]
num = [int(i) for i in input().split()]
#num = [int(i) for i in range(n)]
# s = [input() for i in range(n)]
#s = input()
# list = list(s)
# dp = [[0 for _ in range(2)] for _ in range(13)]
#s = [input() for i in range(n)]

#a = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

kotae = 0
temp = 0
a = {}
b = {}

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

for i in range(n):
    temp = i + num[i]
    if (temp in b):
        b[temp] += 1
    else:
        b[temp] = 1

for i in range(200000):
    if ((i in a) and (i in b)):
        kotae += a[i] * b[i]

print(kotae)