Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
numbers = list(map(int, input().split()))

l = []
amount = 0

for i in range(N - 1):
    for j  in range(i,N-1):
        if numbers[j] == i+1:
            amount = amount + 1 
    print(amount)
    amount = 0
print(0)


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

result = [0] * N
for i in numbers:
    result[i- 1] += 1
    
for i in range(N-1):
    print(result[i])
print(0)

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

l = []
amount = 0
count = 1
for i in range(N):
    for j in range(N - 1):
        if count < j:
            break
        elif numbers[j] == i+1:
            amount = amount + 1
        count = count + 1
    count = 1 
    print(amount)
    amount = 0

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

result = [0] * N
for i in numbers:
    result[i- 1] += 1
    
for i in range(N-1):
    print(result[i])
print(0)

Buggy python submission (verdict: Runtime Error):
N = int(input())
numbers = list(map(int, input().split()))

l = []
amount = 0
for i in range(N - i):
    for j in range(N-1):
        if numbers[j] == i+1:
            amount = amount + 1
    print(amount)
    amount = 0

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

result = [0] * N
for i in numbers:
    result[i- 1] += 1
    
for i in range(N-1):
    print(result[i])
print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
numbers = list(map(int, input().split()))
l = []
amount = 0
for i in range(N):
    for j in range(N-1):
        if numbers[j] == i+1:
            amount = amount + 1
    print(amount)
    amount = 0

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

result = [0] * N
for i in numbers:
    result[i- 1] += 1
    
for i in range(N-1):
    print(result[i])
print(0)

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

l = []
amount = 0
for i in range(N):
    for j in range(N-1):
        if numbers[j] == i+1:
            amount = amount + 1
    l.append(amount)
    amount = 0

for i in range(N):
    print(l[i])

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

result = [0] * N
for i in numbers:
    result[i- 1] += 1
    
for i in range(N-1):
    print(result[i])
print(0)

Buggy python submission (verdict: Runtime Error):
#からの配列
l = []
amount = 0
for i in range(N):
    for j in range(N-1):
        if numbers[j] == i+1:
            #print('numbers = {}'.format(numbers[j]))
            amount = amount + 1
    #print('amount = {}'.format(amount))
    l.append(amount)
    #print('l[{}] = {}'.format(i,l[i]))
    #print('--------------------')
    amount = 0

for i in range(N):
    print(l[i])

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

result = [0] * N
for i in numbers:
    result[i- 1] += 1
    
for i in range(N-1):
    print(result[i])
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
i = list(map(int, input().split()))

H = i[0]
W = i[1]
amount = 0
count = 0
for j in range(H):
    for k in range(W):
        if count % 2 != 0:
            count += 1
        else:
            count += 1
            amount += 1

print(amount)

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

H = i[0]
W = i[1]


if(W == 1):
    print(1)
elif(H == 1):
    print(1)
#横が偶数の時は、縦の偶奇によらない
elif(W % 2 == 0):
    yoko = W // 2
    print(yoko*H)
#横が奇数の時は、縦の偶奇による
elif(W % 2 != 0):
    yoko = W // 2 + 1
    #縦が偶数の時
    if(H % 2 == 0):
        print(yoko*(H//2)+(yoko-1)*(H//2))
    #縦が奇数の時
    else:
        print(yoko*(H//2+1)+(yoko-1)*(H//2))
Buggy python submission (verdict: Time Limit Exceeded):
S = input().split()

#冷蔵庫
A = int(S[0])
#電子レンジ
B = int(S[1])
#割引券
M = int(S[2])



a = list(map(int,input().split()))
b = list(map(int,input().split()))

total_mini = 999999999
for j in range(A):
    for k in range(B):
        total = a[j] + b[k]
        if total_mini > total:
            total_mini = total



minimum = 999999999
for i in range(M):
    m = list(map(int,input().split()))
    amount = a[m[0]-1] + b[m[1]-1] - m[2]

    if minimum > amount:
        minimum = amount


if minimum <= total_mini:
    print(minimum)
else:
    print(total_mini)


Fixed submission:
S = input().split()

#冷蔵庫
A = int(S[0])
#電子レンジ
B = int(S[1])
#割引券
M = int(S[2])



a = list(map(int,input().split()))
b = list(map(int,input().split()))
total_mini = min(a) + min(b)


for i in range(M):
    m = list(map(int,input().split()))
    amount = a[m[0]-1] + b[m[1]-1] - m[2]

    if total_mini > amount:
        total_mini = amount


print(total_mini)
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = []

for i in range(N):
    d.append(int(input()))

d = list(set(d))

print(length(d))

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

for i in range(N):
    d.append(int(input()))

d = list(set(d))

print(len(d))
Buggy python submission (verdict: Time Limit Exceeded):
#Nはお札の枚数、Yは合計金額
N,Y = map(int,input().split())

yukiti = 10000
higuti = 5000
noguti = 1000
l = []
flg = 0
for i in range(N+1):
    for j in range(N+1):
        for k in range(N+1):
            if (i + k + j) <= N:
                amount = yukiti*i + higuti*j + noguti*k
                if amount == Y:
                    l.append(i)
                    l.append(j)
                    l.append(k)
                    flg = 1
                    break

if flg == 1:
    print(l[0],l[1],l[2])
else:
    print(-1,-1,-1)

Fixed submission:
#Nはお札の枚数、Yは合計金額
N,Y = map(int,input().split())

yukiti = 10000
higuti = 5000
noguti = 1000
re_yukiti = -1
re_higuti = -1
re_noguti = -1

for i in range(N+1):
    for j in range(N+1-i):
        k = N - i - j
        amount = yukiti*i + higuti*j + noguti*k
        if amount == Y:
            re_yukiti = i
            re_higuti = j
            re_noguti = k
            break

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

roop = [1]
start=0

for i in range(N):
    roop.append(A[roop[-1]-1])
    if roop[-1] in set(roop[:-1]):
        start=roop[:-1].index(roop[-1])
        break
print(roop[2:-1][(K-start)%len(roop[2:-1])])


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

root = [1]
setroot = set(root)

for i in range(N):
    if A[root[-1]-1] in setroot:
        start = root.index(A[root[-1]-1])
        break
    setroot.add(A[root[-1]-1])
    root.append(A[root[-1]-1])

roop = root[start:]

if K <= start:
    print(root[K])
else:
    print(root[(K-start)%len(roop)+start])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array(list((map(int,input().split()))))

basic=np.arange(1,N+1)
ans=0
for i in range(N):
    # print(A[i:])
    # print(basic[:N-i]-A[i]-1)
    ans+=(A[i:]==(basic[:N-i]-A[i]-1)).sum()
print(ans)

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

index = list(range(1,N+1))

R = [index[i] - A[i] for i in range(N)]
L = [index[j] + A[j] for j in range(N)]

R_dict = collections.Counter(R)
L_dict = collections.Counter(L)

ans=0
for i in R_dict.keys()&L_dict.keys():
    ans+=R_dict[i]*L_dict[i]

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

for idx,i in enumerate(A):
    for j in A[idx+1:]:
        if i==j:
            print('NO')
            exit()
    
print('YES')

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

if len(set(A))==len(A):
    print('YES')
else:
    print('NO')

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

for i in A:
    if A.count(i)>1:
        print('NO')
        exit()
    
print('YES')

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

if len(set(A))==len(A):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
S = input()

if S == 'SUN':
  ans = 7
elif S == 'MON':
  ans = 6
elif S == 'TUE':
  ans == 5
elif S == 'WED':
  ans = 4
elif S == 'THU':
  ans = 3
elif S == 'FRI':
  ans = 2
elif S == 'SAT':
  ans = 1

print(ans)

Fixed submission:
S = input()

if S == 'SUN':
  ans = 7
elif S == 'MON':
  ans = 6
elif S == 'TUE':
  ans = 5
elif S == 'WED':
  ans = 4
elif S == 'THU':
  ans = 3
elif S == 'FRI':
  ans = 2
elif S == 'SAT':
  ans = 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
input1 = list(map(int,input().split()))

X = input1[0]
Y = input1[1]

if (X+Y) % 3 != 0:
  print(0)
  exit()

if Y<X/2:
  print(0)
  exit()

if Y>X*2:
  print(0)
  exit()

s = int((2*X-Y)/3)
t = int((-X+2*Y)/3)

n = s+t
r = min(s,t)

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


ans = comb(n,r,10**9+7)
print(ans)

Fixed submission:
import numpy as np
import math
input1 = list(map(int,input().split()))

X = input1[0]
Y = input1[1]

if (X+Y) % 3 != 0:
  print(0)
  exit()

if Y<X/2:
  print(0)
  exit()

if Y>X*2:
  print(0)
  exit()

s = int((2*X-Y)/3)
t = int((-X+2*Y)/3)

n = s+t
r = min(s,t)

def comb(n,k,p):
  if n==0 or k==0: return 1

  a=1
  for i in range(1,n+1):
    a*=i
    if a >= p:
      a = a%p

  b=1
  for i in range(1,k+1):
    b*=i
    if b >= p:
      b = b%p

  c=1
  for i in range(1,n-k+1):
    c*=i
    if c >= p:
      c = c%p

  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


ans = comb(n,r,10**9+7)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import collections
input1 = list(map(int,input().split()))
input2 = list(map(int,input().split()))

N = input1[0]
D = input2

if D[0] != 0:
  print(0)
  exit()

counter = collections.Counter(D)

ans = 1

D.sort()
D_numpy = np.array(D)
if (np.diff(D_numpy)<=1).prod():
  if counter[0] != 1:
    ans = 0
  else:
    for i in range(len(counter)):
      try:
        counter[i]
      ans *= counter[i]**counter[i+1]
      if ans >= 998244353:
        ans = ans%998244353

else:
  ans = 0



print(ans)

Fixed submission:
import numpy as np
import collections
input1 = list(map(int,input().split()))
input2 = list(map(int,input().split()))

N = input1[0]
D = input2

if D[0] != 0:
  print(0)
  exit()

counter = collections.Counter(D)

ans = 1

D.sort()
D_numpy = np.array(D)
if (np.diff(D_numpy)<=1).prod():
  if counter[0] != 1:
    ans = 0
  else:
    for i in range(len(counter)):
      ans *= counter[i]**counter[i+1]
      if ans >= 998244353:
        ans = ans%998244353

else:
  ans = 0



print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
import collections
input1 = list(map(int,input().split()))
input2 = list(map(int,input().split()))

N = input1[0]
D = input2


counter = collections.Counter(D)

ans = 1

D.sort()
D_numpy = np.array(D)
if (np.diff(D_numpy)<=1).prod():
  if counter[0] != 1:
    ans = 0
  else:
    for i in range(len(counter)):
      try:
        counter[i]
      ans *= counter[i]**counter[i+1]
      if ans >= 998244353:
        ans = ans%998244353

else:
  ans = 0

if D[0] != 0:
  ans = 0

print(ans)

Fixed submission:
import numpy as np
import collections
input1 = list(map(int,input().split()))
input2 = list(map(int,input().split()))

N = input1[0]
D = input2

if D[0] != 0:
  print(0)
  exit()

counter = collections.Counter(D)

ans = 1

D.sort()
D_numpy = np.array(D)
if (np.diff(D_numpy)<=1).prod():
  if counter[0] != 1:
    ans = 0
  else:
    for i in range(len(counter)):
      ans *= counter[i]**counter[i+1]
      if ans >= 998244353:
        ans = ans%998244353

else:
  ans = 0



print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:56 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

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

city = [False for i in range(N)]
city[1-1] =True
now = 1

counta1 = 0
while True:
    counta1 += 1
    prev = now
    now = A[now-1]
    print(prev,now,counta1)
    if city[now-1]:
        break
    elif counta1 == K:
        print(now)
        sys.exit()
    else:
        city[now-1] = True

counta = 1
rout = []
rout.append(now)
while now != prev:
    now = A[now-1]
    rout.append(now)
    counta +=1
    print(now,rout,counta)

ans = rout[(K-counta1) % counta]
print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:56 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

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

city = [False for i in range(N)]
city[1-1] =True
now = 1

counta1 = 0
while True:
    counta1 += 1
    prev = now
    now = A[now-1]
#    print(prev,now,counta1)
    if city[now-1]:
        break
    elif counta1 == K:
        print(now)
        sys.exit()
    else:
        city[now-1] = True

counta = 1
rout = []
rout.append(now)
while now != prev:
    now = A[now-1]
    rout.append(now)
    counta +=1
#    print(now,rout,counta)

ans = rout[(K-counta1) % counta]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 20:56:48 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

X = int(input())

for i in range(-10000,10001):
    for j in range(-10000,10001):
        if pow(i,5) - pow(j,5) == X:
            print(i,j)
            sys.exit()



Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 20:56:48 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

X = int(input())

for i in range(-500,501):
    for j in range(-500,501):
        if pow(i,5) - pow(j,5) == X:
            print(i,j)
            sys.exit()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 20:56:48 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

X = int(input())

for i in range(-2000,2001):
    for j in range(-2000,2001):
        if pow(i,5) - pow(j,5) == X:
            print(i,j)
            sys.exit()



Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 20:56:48 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

X = int(input())

for i in range(-500,501):
    for j in range(-500,501):
        if pow(i,5) - pow(j,5) == X:
            print(i,j)
            sys.exit()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 21:27:48 2020
"""

import sys
import numpy as np
import itertools

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

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

A = np.array(A)
B = np.arange(N)

x = A - B
y = A + B

x.sort()
y.sort()

ans = 0
i, j = 0, N - 1
#pre = 10**10
x1, y1 = 0, 0
while i < N and j >= 0:
    if -x[i] < y[j]:
        j -= 1
    elif -x[i] > y[j]:
        i += 1
    else:
        x1,y1 = 1, 1
        pre = y[j]
        while pre == -x[i+1]:
            x1 += 1
            i += 1
#            print('x',pre,x1)
        while pre == y[j-1]:
            y1 += 1
            j -= 1
#            print('y',pre,y1)
        i += 1
        j -= 1
        ans += x1 * y1
#        print()
#    print(i,j,x[i],y[j],x1,y1,ans)
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 21:27:48 2020
"""

import sys
import numpy as np
import itertools

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

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

A = np.array(A)
B = np.arange(N)

x = A - B
y = A + B

x.sort()
y.sort()

ans = 0
i, j = 0, N - 1
#pre = 10**10
x1, y1 = 0, 0
while i < N and j >= 0:
    if -x[i] < y[j]:
        j -= 1
    elif -x[i] > y[j]:
        i += 1
    else:
        x1,y1 = 1, 1
        pre = y[j]
        while pre == -x[i+1]:
            x1 += 1
            i += 1
#            print('x',pre,x1)
        while pre == y[j-1]:
            y1 += 1
            j -= 1
#            print('y',pre,y1)
        i += 1
        j -= 1
        ans += x1 * y1
#        print()
#    print(i,j,x[i],y[j],x1,y1,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

N = int(input())
S = input()

rgb = [0,0,0]
for i in range(N):
    if S[i] == 'R':
        rgb[0] += 1
    elif S[i] == 'G':
        rgb[1] += 1
    else:
        rgb[2] += 1

ans = rgb[0] * rgb[1] * rgb [2]
#print(ans)

for i in range(N):
    for j in range(1,(N-i+1)//2):
        if S[i] != S[i+j] and S[i] != S[i+2*j] and S[i+j] != S[i+2*j]:
            ans -= 1
#        print(ans,i,i+j,i+2*j)
print(ans)
            

Fixed submission:

import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)

N = int(input())
S = input()

rgb = [0,0,0]
for i in range(N):
    if S[i] == 'R':
        rgb[0] += 1
    elif S[i] == 'G':
        rgb[1] += 1
    else:
        rgb[2] += 1

ans = rgb[0] * rgb[1] * rgb [2]
#print(ans)

for i in range(N):
    for j in range(1,(N-i+1)//2):
        if S[i] != S[i+j] and S[i] != S[i+2*j] and S[i+j] != S[i+2*j]:
            ans -= 1
#        print(ans,i,i+j,i+2*j)
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)

K = int(input())

ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd(gcd(i,j), k)
print(ans)


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

x = N % K

ans = min(x,K-x)

print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:12:42 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7



#N = int(input())
X, Y, A, B, C = map(int,input().split())
r = list(map(int,input().split()))
g = list(map(int,input().split()))
n = list(map(int,input().split()))

r.sort()
g.sort()
n.sort()

x, y = A-X, B-Y
z = C-1
ans = 0
ans += sum(r[x:])
ans += sum(g[y:])
#print(x,y,z,r[x],g[y],n[z],ans)
while (n[z] > r[x] or n[z] > g[y]) and z >= 0:
    if r[x] < g[y]:
        ans += (n[z] - r[x])
        x += 1
        z -= 1
    else:
        ans += (n[z] - g[y])
        y += 1
        z -= 1
#    print(x,y,z,r[x],g[y],n[z],ans)
print(ans)



Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:12:42 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
X, Y, A, B, C = map(int,input().split())
r = list(map(int,input().split()))
g = list(map(int,input().split()))
n = list(map(int,input().split()))

r.sort()
g.sort()
n.sort()

x, y = A-X, B-Y
z = C-1
ans = 0
ans += sum(r[x:])
ans += sum(g[y:])
g.append(10**10)
#print(x,y,z,r[x],g[y],n[z],ans)
while z >= 0:
#    print(x,y,z,r[x],g[y],n[z],ans)
    flg = True
    if x < A and r[x] < n[z] and r[x] < g[y]:
        ans += (n[z] - r[x])
        x += 1
        z -= 1
        flg = False
    elif y < B and g[y] < n[z]:
        ans += (n[z] - g[y])
        y += 1
        z -= 1
        flg = False
    if flg:
        break
#print(x,y,z,r[x],g[y],n[z],ans)
print(ans)
Buggy python submission (verdict: Runtime Error):

import sys

N = int(input())
D = list(map(int,input().split()))
mod = 998244353 

D.sort()
T = [0 for _ in range(N)]

for i in range(N):
    T[D[i]] += 1

i = 0
ans = 1
if T[i] != 1:
    print(0)
    sys.exit()
pre = T[i]
i += 1
while T[i] != 0:
    ans *= pow(pre,T[i],mod)
    ans %= mod
    pre = T[i]
    i += 1

while i < N:
    if T[i] > 0:
        print(0)
        sys.exit()
    i += 1

ans %= mod
print(ans)

Fixed submission:

N = int(input())
D = list(map(int,input().split()))
mod = 998244353 
flg = True

if D[0] != 0:
    flg = False
    
D.sort()
T = [0 for _ in range(N + 1)]

for i in range(N):
    T[D[i]] += 1

i = 0
ans = 1
if T[i] != 1:
    flg = False

pre = T[i]
i += 1
while T[i] != 0:
    ans *= pow(pre,T[i])
    ans %= mod
    pre = T[i]
    i += 1

while i < N:
    if T[i] > 0:
        flg = False
    i += 1

ans %= mod
if flg:
    print(ans)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 21 23:12:22 2019

@author: Yamazaki Kenichi
"""
import heapq

N, M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

AB.sort()

q = [0 for _ in range(N)]
j = 0
ans = 0
for i in range(1,M+1):
    while j < N and AB[j][0] == i:
        heapq.heappush(q,-AB[j][1])
        j += 1
    ans += (-heapq.heappop(q))
#    print(i,j,ans,q)
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 21 23:12:22 2019

@author: Yamazaki Kenichi
"""
import heapq

N, M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(N)]

AB.sort()

q = [0 for _ in range(max(M,N))]
j = 0
ans = 0
for i in range(1,M+1):
    while j < N and AB[j][0] == i:
        heapq.heappush(q,-AB[j][1])
        j += 1
    ans += (-heapq.heappop(q))
#    print(i,j,ans,q)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

S = input()
mod = 10**9+7
N = len(S)

dp = [[0 for _ in range(13)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(13):
        if S[i] == '?':
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
        else:
            dp[i+1][(j*10+int(S[i]))%13] += dp[i][j]
            dp[i+1][(j*10+int(S[i]))%13] %= mod

print(dp[N][5])


Fixed submission:

S = input()
mod = 10**9+7
N = len(S)

dp = [[0 for _ in range(13)] for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(13):
        if S[i] == '?':
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
        else:
            dp[i+1][(j*10+int(S[i]))%13] += dp[i][j]
            dp[i+1][(j*10+int(S[i]))%13] %= mod

print(dp[N][5])