Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import numpy as np

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    lcm=np.lcm.reduce(A)
    ans=0
    for i in range(N):
        ans+=lcm//A[i]
    print(ans%MOD)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import fractions as f

MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    #lcm=np.lcm.reduce(A)
    lcm=A[0]
    for i in range(1,N):
        lcm=lcm*A[i]//f.gcd(lcm,A[i])

    ans=0
    for i in range(N):
        ans+=lcm//A[i]
    print(ans%MOD)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N,K = (int(i) for i in input().split())
H = [int(i) for i in input().split()]

c=0
for _ in range(N):
    if (H[N]>=K):
        c=c+1

print(c)

Fixed submission:
N,K = (int(i) for i in input().split())
H = [int(i) for i in input().split()]

c=0
for i in range(N):
    if (H[i]>=K):
        c=c+1

print(c)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = (int(i) for i in input().split())
b = [int(i) for i in input().split()]]
i=np.argsort(b)
print(i+1)

Fixed submission:
import numpy as np
N = int(input())
b = [int(i) for i in input().split()]
s=np.argsort(b)

for i in range(N):
    print(s[i]+1, end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys


def solve(N: int, p: "List[float]"):
    #dp[i][j]: i枚投げて、j枚表の確率
    dp=[[0]*(N+1) for _ in range(N+1)]

    dp[0][0]=1

    # dp[1][0]=dp[0][0]*p[1]
    # dp[1][1]=dp[0][0]*(1-p[1])

    # dp[2][0]=dp[1][0]*p[2]
    # dp[2][1]=dp[1][0]*(1-p[2])
    # dp[2][1]+=dp[1][1]*p[2]
    # dp[2][2]=dp[1][2]*(1-p[2])
    for i in range(1,N+1):
        for j in range(i):
            dp[i][j]+=dp[i-1][j]*p[i-1]
            dp[i][j+1]+=dp[i-1][j]*(1-p[i-1])
            #print("#",i,j,dp)

    ans=0
    for j in range(-(-N//2)):
        ans+=dp[N][j]

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [float(next(tokens)) for _ in range(N)]  # type: "List[float]"
    solve(N, p)

if __name__ == '__main__':
    main()


Fixed submission:
import sys

def solve(N: int, p: "List[float]"):
    #dp[i][j]: i枚投げて、j枚表の確率
    dp=[[0]*(N+1) for _ in range(N+1)]

    dp[0][0]=1

    # dp[1][0]=dp[0][0]*p[1]
    # dp[1][1]=dp[0][0]*(1-p[1])

    # dp[2][0]=dp[1][0]*p[2]
    # dp[2][1]=dp[1][0]*(1-p[2])
    # dp[2][1]+=dp[1][1]*p[2]
    # dp[2][2]=dp[1][2]*(1-p[2])
    for i in range(1,N+1):
        for j in range(i):
            dp[i][j]+=dp[i-1][j]*p[i-1]
            dp[i][j+1]+=dp[i-1][j]*(1-p[i-1])
            #print("#",i,j,dp)

    ans=0
    for j in range(-(-N//2)):
        ans+=dp[N][j]

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [float(next(tokens)) for _ in range(N)]  # type: "List[float]"
    solve(N, p)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import Counter as C
n = int(input())
a = list(map(int,input().split()))
c1 = C(a[::2])
c2 = C(a[1::2])
mc1 = c1.most_common(2)
mc2 = c2.most_common(2)
if mc1[0][0] == mc2[0][0]:
  if mc1[1][1] >= mc2[1][1]:
    ans = n - mc1[1][1] - mc2[0][1]
  else:
    ans = n - mc1[0][1] - mc2[][1]
print(ans)

Fixed submission:
from collections import Counter as C
n = int(input())
a = list(map(int,input().split()))
c1 = C(a[::2])
c2 = C(a[1::2])
mc1 = c1.most_common(2)
mc2 = c2.most_common(2)
if mc1[0][0] != mc2[0][0]:
  ans = n - mc1[0][1] - mc2[0][1]
else:
  if len(mc1) + len(mc2) == 2:
    ans = n // 2
  elif len(mc1) == 1:
    ans = n - mc1[0][1] - mc2[1][1]
  elif len(mc2) == 1:
    ans = n - mc1[1][1] - mc2[0][1]
  else:
    if mc1[1][1] >= mc2[1][1]:
      ans = n - mc1[1][1] - mc2[0][1]
    else:
      ans = n - mc1[0][1] - mc2[1][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
c=[0]*m
for i in range(m):
  if a[i]==1:
    c[b[i]-1] |= 1
  if b[i]==n:
    c[a[i]-1] |= 2
print("POSSIBLE" if max(c)==3 else "IMPOSSIBLE")

Fixed submission:
n,m=map(int,input().split())
a=[0]*m
b=[0]*m
for i in range(m):
  a[i],b[i]=map(int,input().split())
c=[0]*max(n,m)
for i in range(m):
  if a[i]==1:
    c[b[i]-1] |= 1
  if b[i]==n:
    c[a[i]-1] |= 2
print("POSSIBLE" if max(c)==3 else "IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD if num >= MOD else num for num in a]

ans = 0
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		acc = a[i] * a[j]
		ans += acc % MOD if acc >= MOD else acc
		ans %= MOD
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD if num >= MOD else num for num in a]

sum_list = [0]
for i in range(n):
	sum_list.append((a[i] + sum_list[i]) % MOD)
# print(sum_list)

ans = 0
for i in range(len(a)):
	ans += a[i] * (sum_list[-1] - sum_list[i + 1])
	ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD if num >= MOD else num for num in a]

ans = []
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		acc = a[i] * a[j]
		ans.append(acc % MOD if acc >= MOD else acc)
print(sum(ans) % MOD)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD if num >= MOD else num for num in a]

sum_list = [0]
for i in range(n):
	sum_list.append((a[i] + sum_list[i]) % MOD)
# print(sum_list)

ans = 0
for i in range(len(a)):
	ans += a[i] * (sum_list[-1] - sum_list[i + 1])
	ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD if num >= MOD else num for num in a]

ans = []
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		acc = a[i] * a[j]
		ans.append(acc % MOD if acc >= MOD else acc)
print(sum(ans) % MOD)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD if num >= MOD else num for num in a]

sum_list = [0]
for i in range(n):
	sum_list.append((a[i] + sum_list[i]) % MOD)
# print(sum_list)

ans = 0
for i in range(len(a)):
	ans += a[i] * (sum_list[-1] - sum_list[i + 1])
	ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD for num in a]

ans = []
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		ans.append((a[i] * a[j]) % MOD)
print(sum(ans) % MOD)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7
a = [num % MOD if num >= MOD else num for num in a]

sum_list = [0]
for i in range(n):
	sum_list.append((a[i] + sum_list[i]) % MOD)
# print(sum_list)

ans = 0
for i in range(len(a)):
	ans += a[i] * (sum_list[-1] - sum_list[i + 1])
	ans %= MOD

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()

total = 0
for i in range(len(n)):
	total += int(n)

if total % 9 == 0:
	print('Yes')
else:
	print('No')

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

total = sum(n)

if total % 9 == 0:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

max_count = 0
for i in range(n):
	a_sum = sum(a[:i + 1])
	for j in range(m):
		b_sum = sum(b[:j + 1])
		if (a_sum + b_sum <= k) && (a_sum + b_sum > max_count):
			max_count = i + j + 2
print(max_count)


Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

acum1=[0]
for i in range(n):
	acum1.append(acum1[-1]+a[i])
acum2=[0]
for i in range(m):
	acum2.append(acum2[-1]+b[i])
ans = 0
j = m
for i in range(n + 1):
	if acum1[i] > k:
		break
	while (j > 0) and (acum1[i] + acum2[j] > k):
		j -= 1
	ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Runtime Error):
inputs = input().split()
a = int(inputs[0])
b = inputs[1]
b = 100 * int(b[0]) + 10 * int(b[1]) + int(b[2])

print(int(a * b / 100))

Fixed submission:
inputs = input().split()
a = int(inputs[0])
b = inputs[1]
b = 100 * int(b[0]) + 10 * int(b[2]) + int(b[3])

print(a * b // 100)
Buggy python submission (verdict: Runtime Error):
s = int(input())
t = int(input())
print(t+s)

Fixed submission:
s  = input().split()
print(s[1]+s[0])
Buggy python submission (verdict: Runtime Error):
t,a,k = [x for x in list(map(int,input().split()))]
if k>=t:
  if abs(t-k) > a:
    t = 0
    a = 0
  else:
    t = 0
    a = a-abs(t-k)
   print(t,a)
else:
  t = t-k
  print(t,a)
  

Fixed submission:
t,a,k = [x for x in list(map(int,input().split()))]
if k>=t:
    if k-t > a:
        t = 0
        a = 0
    else:
        a = a - (k-t)
        t = 0
    print(t,a)
else:
    t = t-k
    print(t,a)
Buggy python submission (verdict: Runtime Error):
s = input()
yymm = False
mmyy = False
first = int(s[:2])
last = int(s[2:])
if first<=12 and first >0:
  mmyy = True
if last <=12 and last>0:
  yymm = True
if mmyy == True and yymm = True:
  print('AMBIGUOUS')
elif mmyy == True and yymm = False:
  print('MMYY')
elif mmyy == False and yymm = True:
  print('YYMM')
else:
  print('NA')

Fixed submission:
s = input()
yymm = False
mmyy = False
first = int(s[:2])
last = int(s[2:])
if first<=12 and first >0:
    mmyy = True
if last <=12 and last>0:
    yymm = True
if mmyy == True and yymm == True:
    print('AMBIGUOUS')
elif mmyy == True and yymm == False:
    print('MMYY')
elif mmyy == False and yymm == True:
    print('YYMM')
else:
    print('NA')
Buggy python submission (verdict: Runtime Error):
import sys
import threading

S = int(input())
A = [-1 for _ in range(S+1)]
A[0] = 0
A[1] = 0
A[2] = 0
A[3] = 1
A[4] = 1
A[5] = 1

for i in range(S+1):
  if A[i] == -1:
    A[i] = A[i-1] + A[i-3]
print(A[S]%(10**9+7))

Fixed submission:
import sys
import threading

S = int(input())
A = [-1 for _ in range(2001)]
A[0] = 0
A[1] = 0
A[2] = 0
A[3] = 1

for i in range(S+1):
  if A[i] == -1:
    A[i] = A[i-1] + A[i-3]

print(A[S]%(10**9+7))

Buggy python submission (verdict: Runtime Error):
import sys
import threading

S = int(input())
A = [-1 for _ in range(S+1)]
A[0] = 0
A[1] = 0
A[2] = 0
A[3] = 1
A[4] = 1
A[5] = 1

for i in range(S+1):
  if A[i] == -1:
    A[i] = A[i-1] + A[i-3]
print(A[S]%(10**9+7))

Fixed submission:
import sys
import threading

S = int(input())
A = [-1 for _ in range(2001)]
A[0] = 0
A[1] = 0
A[2] = 0
A[3] = 1

for i in range(S+1):
  if A[i] == -1:
    A[i] = A[i-1] + A[i-3]

print(A[S]%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
xyi = []
x = np.zeros(N)
y = np.zeros(N)

ans = 0
for i in range(N):
  x[i],y[i] = map(int, input().split())
  if i >0 :
    x_temp = np.abs(x[i] - x[:i])
    y_temp = np.abs(y[i] - y[:i])
    xy_temp = x_temp + y_temp
    temp = np.max(xy_temp)
    if temp > ans:
      ans = temp
  
  
print(int(ans))

Fixed submission:
N = int(input())
z =[]
w = []
for i in range(N):
  x,y = map(int, input().split())
  z.append(x+y)
  w.append(x-y)
print(max(max(z)-min(z),max(w)-min(w)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
xyi = []
xi  = []
yi  = []
ans = 0
for i in range(N):
  xyi.append(list(map(int, input().split())))
  xi.append(xyi[i][0])
  yi.append(xyi[i][1])
  x = np.array(xi)
  y = np.array(yi)
  if i >0 :
    x_temp = np.abs(x[i] - x[:i])
    y_temp = np.abs(y[i] - y[:i])
    xy_temp = x_temp + y_temp
    temp = np.max(xy_temp)
    if temp > ans:
      ans = temp
  
  
print(ans)

Fixed submission:
N = int(input())
z =[]
w = []
for i in range(N):
  x,y = map(int, input().split())
  z.append(x+y)
  w.append(x-y)
print(max(max(z)-min(z),max(w)-min(w)))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
xy = []
x  = []
y  = []

for i in range(N):
  xy.append(list(map(int, input().split())))
  x.append(xy[i][0])
  y.append(xy[i][1])

x = np.array(x)
y = np.array(y)

ans = 0

for i in range(N-1):
  x_temp = np.abs((x[i] - x[i+1:]))
  y_temp = np.abs((y[i] - y[i+1:]))
  xy_temp = x_temp + y_temp
  temp = np.max(xy_temp)
  if temp > ans:
    ans = temp
  
print(ans)

Fixed submission:
N = int(input())
z =[]
w = []
for i in range(N):
  x,y = map(int, input().split())
  z.append(x+y)
  w.append(x-y)
print(max(max(z)-min(z),max(w)-min(w)))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
aa = sorted(A)
ans = [0 for i in range(aa[-1]+1)]
for i in aa:
  ans[i] += 1
  if ans[i] == 1:
    for j in range(i*2,aa[-1]+1,i):
      if j in aa:
	      ans[j] += 1
print(ans.count(1))

Fixed submission:
import numpy as np
N = int(input())
A = list(map(int,input().split()))
aa = sorted(A)
ans = [0 for i in range(aa[-1]+1)]
for i in aa:
  ans[i] += 1
  if ans[i] == 1:
    for j in range(i*2,aa[-1]+1,i):
      ans[j] += 2
print(ans.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
aa = np.array(A)
aa = np.sort(aa)
for i in range(len(aa)):
  judge = True
  j = i+1
  div = []
  while True:
    if len(aa) <= j:
      break
    if aa[j]%aa[i] == 0:
      if aa[j] == aa[i]:
        div.append(i)
      div.append(j)
    j += 1
  aa = np.delete(aa,div,0)

print(len(aa))

Fixed submission:
import numpy as np
N = int(input())
A = list(map(int,input().split()))
aa = sorted(A)
ans = [0 for i in range(aa[-1]+1)]
for i in aa:
  ans[i] += 1
  if ans[i] == 1:
    for j in range(i*2,aa[-1]+1,i):
      ans[j] += 2
print(ans.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
aa = np.array(A)
aa = np.sort(aa)
for i in range(len(aa)):
  div = []
  for j in range(i+1,len(aa)):
    if aa[j]%aa[i] == 0:
      div.append(j)
      if aa[j] == aa[i]:
        div.append(i)
  aa = np.delete(aa,div,0)
print(len(aa))

Fixed submission:
import numpy as np
N = int(input())
A = list(map(int,input().split()))
aa = sorted(A)
ans = [0 for i in range(aa[-1]+1)]
for i in aa:
  ans[i] += 1
  if ans[i] == 1:
    for j in range(i*2,aa[-1]+1,i):
      ans[j] += 2
print(ans.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
aa = np.array(A)
ans = 0
for i in aa:
  b = (i % aa == 0)
  if sum(b) == 1:
    ans += 1
print(ans)

Fixed submission:
import numpy as np
N = int(input())
A = list(map(int,input().split()))
aa = sorted(A)
ans = [0 for i in range(aa[-1]+1)]
for i in aa:
  ans[i] += 1
  if ans[i] == 1:
    for j in range(i*2,aa[-1]+1,i):
      ans[j] += 2
print(ans.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(N):
  ans *= A[i]
if ans > 1e18:
  ans = -1
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
ans = 1
check = (0 in A)
if check:
  print(0)
else:
  for i in range(N):
    ans *= A[i]
    if ans > 1e18:
      ans = -1
      break
  print(ans)
Buggy python submission (verdict: Runtime Error):
A ,B= map(float,input().split())
A = int(A)
C = str(B)
if B == 10.0:
  D = 1000
elif B == 0.0:
  D = 0
else:
  D = int(C[-1]) + int(C[-2])*10 + int(C[-4])*100
ans = A*D
ans = ans//100
print(ans)

Fixed submission:
A ,B= map(float,input().split())
A = int(A)
C = str(B)
if B == 10.0:
  D = 1000
elif B == 0.0:
  D = 0
elif len(C) == 4:
  D = int(C[-1]) + int(C[-2])*10 + int(C[-4])*100
elif len(C) == 3:
  D = int(C[-1])*10 + int(C[-3])*100
  
ans = A*D
ans = ans//100
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
num = len(N)
mod_sum = [0]*2019
mod_sum[0] = 1
ans = 0
a = 0
for i in range(num):
  a += (int(N[-i-1])*10**i)%2019
  mod = a%2019
  mod_sum[mod] += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)

Fixed submission:
N = input()
num = len(N)
mod_sum = [0]*2019
mod_sum[0] = 1
ans = 0
a = 0
d = 1
for i in range(num):
  a = (a + int(N[-i-1])*d)%2019
  d = (d*10)%2019
  mod_sum[a] += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
num = len(N)
mod_sum = [0]*2019
mod_sum[0] = 1
ans = 0
a = 0
for i in range(num):
  a += int(N[-i-1])*10**i
  mod = a%2019
  mod_sum[mod] += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)


Fixed submission:
N = input()
num = len(N)
mod_sum = [0]*2019
mod_sum[0] = 1
ans = 0
a = 0
d = 1
for i in range(num):
  a = (a + int(N[-i-1])*d)%2019
  d = (d*10)%2019
  mod_sum[a] += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
num = len(N)
mod_sum = [0 for i in range(2019)]
ans = 0
for i in range(num):
  a = int(N[i:])
  mod = a%2019
  mod_sum[mod] += 1
  if mod == 0:
    ans += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)


Fixed submission:
N = input()
num = len(N)
mod_sum = [0]*2019
mod_sum[0] = 1
ans = 0
a = 0
d = 1
for i in range(num):
  a = (a + int(N[-i-1])*d)%2019
  d = (d*10)%2019
  mod_sum[a] += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
num = len(N)
mod_sum = [0 for i in range(2019)]
ans = 0
for i in range(num):
  a = int(N[i:])
  mod = a%2019
  mod_sum[mod] += 1
  if mod == 0:
    ans += 1
for i in mod_sum:
  ans += i*(i-1)/2
print(int(ans))

Fixed submission:
N = input()
num = len(N)
mod_sum = [0]*2019
mod_sum[0] = 1
ans = 0
a = 0
d = 1
for i in range(num):
  a = (a + int(N[-i-1])*d)%2019
  d = (d*10)%2019
  mod_sum[a] += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
num = len(N)
ans = 0
for i in range(0,num-3):
  for j in range(i+3,num):
    if j == i + 3:
      s = int(N[i:j+1])
    else:
      s = t*10 + int(N[j])
    t = s% 2019
    if t == 0:
      ans += 1
print(ans)

Fixed submission:
N = input()
num = len(N)
mod_sum = [0]*2019
mod_sum[0] = 1
ans = 0
a = 0
d = 1
for i in range(num):
  a = (a + int(N[-i-1])*d)%2019
  d = (d*10)%2019
  mod_sum[a] += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
num = len(N)
ans = 0
for i in range(0,num-3):
  for j in range(i+3,num):
    s = int(N[i:j+1])
    if s% 2019 == 0:
      ans += 1
print(ans)

Fixed submission:
N = input()
num = len(N)
mod_sum = [0]*2019
mod_sum[0] = 1
ans = 0
a = 0
d = 1
for i in range(num):
  a = (a + int(N[-i-1])*d)%2019
  d = (d*10)%2019
  mod_sum[a] += 1
for i in mod_sum:
  ans += i*(i-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
ans = 0
temp_max = N
temp_min = 0
for i in range(K,N+2):
  temp_max += N-i+1
  temp_min += i-1
  ans += temp_max - temp_min + 1
print(ans%(10**9+7)

Fixed submission:
N,K = map(int,input().split())
ans = 0
temp_max = 0
temp_min = 0
for i in range(1,N+2):
  temp_max += N-i+1
  temp_min += i-1
  if i  >= K:
    ans += (temp_max - temp_min + 1)
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
N = input()
if N[0] != '7' and  N[1] != '7'  N[2] != '7':
  print('No')
else:
  print('Yes')

Fixed submission:
N = input()
if N[0] != '7' and N[1] != '7' and N[2] != '7':
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
ans = (1+N)*N/2
for i in range(1,N+1):
  for j in range(1,i):
    ans += math.gcd(i,j)*3
for i in range(!,N+1):
  for j in range(1,i):
    if i== j:
      break
    for k in range(1,j):
      if i == k or j == k:
        break
      else:
        ans += math.gcd(i,j,k)*6
print(ans)

Fixed submission:
import math
N = int(input())
ans = (1+N)*N/2
for i in range(1,N+1):
  for j in range(1,i):
    ans += math.gcd(i,j)*6
for i in range(1,N+1):
  for j in range(1,i):
    if i== j:
      break
    for k in range(1,j):
      if i == k or j == k:
        break
      else:
        ans += math.gcd(k,math.gcd(i,j))*6
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input()
ans = 0
for i in range(1,N-1):
  for j in range(i+1,N):
    if A[i-1] != A[j-1]:
      for k in range(j+1 ,N+1):
        if A[i -1] != A[k-1] and A[j -1] != A[k-1] and j-i != k-j:
          ans += 1
print(ans)

Fixed submission:
N = int(input())
A = input()
ans = 0
R = 0
G = 0
B = 0
for i in A:
  if i == 'R':
    R += 1
  elif i == 'G':
    G += 1
  elif i == 'B':
    B += 1
ans = R*G*B
for i in range(0,N-2):
  for j in range(i+1,N-1):
    k = 2*j -i
    if k < N:
      if A[i] != A[j] and A[j] != A[k] and A[k] != A[i]:
        ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
20 3
0 5 15

Fixed submission:
K,N = map(int,input().split())
A = list(map(int,input().split()))
B = [0 for i in range(N)]
C = 0
for i in range(N):
  if i == N-1:
    B[i] = A[0] + K - A[i]
  else:
    B[i] = A[i+1] - A[i]
  if B[i] > C:
    C = B[i]
print(K-C)