Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
c=[0,0,0]
for _ in range(K):
    d=int(input())
    l=list(map(int,input().split()))
    for i in range(d):
        c[l[i]-1]+=1
print(c.count(0))

Fixed submission:
N,K=map(int,input().split())
c=[0]*N
for _ in range(K):
    d=int(input())
    l=list(map(int,input().split()))
    for i in range(d):
        c[l[i]-1]+=1
print(c.count(0))

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
c=[0,0,0]
for i in range(K):
    d=int(input())
    l=list(map(int,input().split()))
    for i in range(d):
        c[l[i]-1]+=1
print(c.count(0))

Fixed submission:
N,K=map(int,input().split())
c=[0]*N
for _ in range(K):
    d=int(input())
    l=list(map(int,input().split()))
    for i in range(d):
        c[l[i]-1]+=1
print(c.count(0))
Buggy python submission (verdict: Runtime Error):
A,B,N=map(int, input().split())
ans=[]
for i in range(1,N+1,B//A):
    ans.append(int(A*i/B)-A*int(i/B))
print(max(ans))

Fixed submission:
A,B,N=map(int, input().split())
if N>=B-1:
    print(int(A*(B-1)/B)-A*int((B-1)/B))
else:
    print(int(A*N/B)-A*int(N/B))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N=map(int, input().split())
ans=[]
for i in range(1,N+1):
    ans.append(int(A*i/B)-A*int(i/B))
print(max(ans))

Fixed submission:
A,B,N=map(int, input().split())
if N>=B-1:
    print(int(A*(B-1)/B)-A*int((B-1)/B))
else:
    print(int(A*N/B)-A*int(N/B))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n=int(input())
a=[]
c=0
for _ in range(n):
    b = input()
    if b not in a:
        a.append(b)
        c+=1
print(c)

Fixed submission:
import collections
n=int(input())
a=[]
for _ in range(n):
    a.append(input())
c = collections.Counter(a)
print(len(c))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
for i in range(1,N+1):
  print(A.count(i))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
c=[0]*N
for i in A:
  c[i-1]+=1
for a in c:
  print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
for i in range(1,N+1):
  print(A.count(i))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
c=[0]*N
for i in A:
  c[i-1]+=1
for a in c:
  print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
s=1
lis=list(range(N+1))
 
def tousa(l,r):
    return((l+r)*(r-l+1)//2)
 
 
for i in range(K,N+1):
    s+=(tousa(lis[-i:][0], lis[-i:][-1])-tousa(lis[:i][0], lis[:i][-1])+1)
# print(s)
print(s%(10**9+7))

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

def tousa(l,r):
    return((l+r)*(r-l+1)//2)

for i in range(K,N+1):
    s+= (tousa(N-i+1, N) - tousa(0, i-1) + 1)
# print(s)
print(s%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
s=1
lis=list(range(N+1))

def tousa(l,r):
    return((l+r)*(r-l+1)//2)


for i in range(K,N+1):
    s+=(tousa(lis[-i:][0], lis[-i:][-1])-tousa(lis[:i][0], lis[:i][-1])+1)
# print(s)
print(s%(10**9+7))

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

def tousa(l,r):
    return((l+r)*(r-l+1)//2)

for i in range(K,N+1):
    s+= (tousa(N-i+1, N) - tousa(0, i-1) + 1)
# print(s)
print(s%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
s=1
lis=list(range(N+1))
for i in range(K,N+1):
    # print(lis[i:])
    # print(lis[:i])
    s+=(sum(lis[-i:])-sum(lis[:i])+1)
# print(s)
print(s%(pow(10,9)+7))

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

def tousa(l,r):
    return((l+r)*(r-l+1)//2)

for i in range(K,N+1):
    s+= (tousa(N-i+1, N) - tousa(0, i-1) + 1)
# print(s)
print(s%(10**9+7))
Buggy python submission (verdict: Runtime Error):
x = int(input())
j = False
for i in range(len(x)):
  if x[i] == 7:
    j = True
if j:
  print('Yes')
else:
  print('No')

Fixed submission:
x = input()
j = False
for i in range(len(x)):
  if x[i] == '7':
    j = True
if j:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
x = int(input())
j = False
for i in range(len(x))
  if x[i] == 7:
    j = True
if j:
  print('Yes')
else:
  print('No')

Fixed submission:
x = input()
j = False
for i in range(len(x)):
  if x[i] == '7':
    j = True
if j:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import math
K=int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      if i == j == k:
        c += i
      elif i == j:
        c += math.gcd(i,k)
      elif i == k:
        c += math.gcd(i,j)
      elif j == k:
        c += math.gcd(i,k)
      else:
        c += math.gcd(math.gcd(i, j), k)
print(c)

Fixed submission:
import math
K=int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    if math.gcd(i,j) == 1:
      c += K
    else:
      for k in range(1,K+1):
        if i == j == k:
          c += i
        elif i == j:
          c += math.gcd(i,k)
        elif i == k:
          c += math.gcd(i,j)
        elif j == k:
          c += math.gcd(i,k)
        else:
          c += math.gcd(math.gcd(i, j), k)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
K=int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      c += gcd(i, j, k)
print(c)

Fixed submission:
import math
K=int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    if math.gcd(i,j) == 1:
      c += K
    else:
      for k in range(1,K+1):
        if i == j == k:
          c += i
        elif i == j:
          c += math.gcd(i,k)
        elif i == k:
          c += math.gcd(i,j)
        elif j == k:
          c += math.gcd(i,k)
        else:
          c += math.gcd(math.gcd(i, j), k)
print(c)

Buggy python submission (verdict: Runtime Error):
import math
K=int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      c += math.gcd(i, j, k)
print(c)

Fixed submission:
import math
K=int(input())
c = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    if math.gcd(i,j) == 1:
      c += K
    else:
      for k in range(1,K+1):
        if i == j == k:
          c += i
        elif i == j:
          c += math.gcd(i,k)
        elif i == k:
          c += math.gcd(i,j)
        elif j == k:
          c += math.gcd(i,k)
        else:
          c += math.gcd(math.gcd(i, j), k)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
n=0
c=0
while 1:
  n+=1
  j=True
  n_str=str(n)
  for i in range(len(n_str)-1):
    if abs(int(n_str[i]) - int(n_str[i+1])) > 1:
      j=False
  if j:
    c+=1
  if c==K:
    print(n)
    break

Fixed submission:
from collections import deque
K=int(input())
Q=deque(list(range(1,10)))
for _ in range(K):
  x=Q.popleft()
  if x%10 != 0:
    Q.append(10*x+x%10-1)
  Q.append(10*x+x%10)
  if x%10 != 9:
    Q.append(10*x+x%10+1)
print(x)

Buggy python submission (verdict: Runtime Error):
K=int(input())
n=0
c=0
while 1:
  j=True
    if len(n_str) > 1 and abs(int(n_str[0]) - int(n_str[1])) > 1:
    n = (int(str(int(n_str[0])+1)+str(int(n_str[0]))))*(10**(len(n_str)-2))
  else:
    n+=1
  n_str=str(n)
  for i in range(len(n_str)-1):
    if abs(int(n_str[i]) - int(n_str[i+1])) > 1:
      j=False
  if j:
    c+=1
  if c==K:
    print(n)
    break


Fixed submission:
from collections import deque
K=int(input())
Q=deque(list(range(1,10)))
for _ in range(K):
  x=Q.popleft()
  if x%10 != 0:
    Q.append(10*x+x%10-1)
  Q.append(10*x+x%10)
  if x%10 != 9:
    Q.append(10*x+x%10+1)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
K=int(input())
n=0
c=0
while 1:
  n+=1
  j=True
  n_str=str(n)
  for i in range(len(n_str)-1):
    if abs(int(n_str[i]) - int(n_str[i+1])) > 1:
      j=False
  if j:
    c+=1
  if c==K:
    print(n)
    break

Fixed submission:
from collections import deque
K=int(input())
Q=deque(list(range(1,10)))
for _ in range(K):
  x=Q.popleft()
  if x%10 != 0:
    Q.append(10*x+x%10-1)
  Q.append(10*x+x%10)
  if x%10 != 9:
    Q.append(10*x+x%10+1)
print(x)
Buggy python submission (verdict: Runtime Error):
S=input()
if S[2] == S[3] & S[4] == S[5]:
  print('Yes')
else:
  print('No')

Fixed submission:
S=input()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
K, N = map(int, input().split())
lis = list(map(int, input().split()))
dis=[]
for _ in range(N):
  p = lis.pop(0)
  lis.append(p)
  d = 0
  for i in range(N-1):
    if lis[i+1] > lis[i]:
      d += (lis[i+1]-lis[i])
    else:
      d += (K - lis[i]) + lis[i+1]
  dis.append(d)
print(min(dis))

Fixed submission:
K, N = map(int, input().split())
lis = list(map(int, input().split()))
dis=[]
lis.append(lis[0])
for i in range(N):
  if lis[i+1] > lis[i]:
    dis.append(lis[i+1]-lis[i])
  else:
    dis.append((K - lis[i]) + lis[i+1])
print(sum(dis)-max(dis))
Buggy python submission (verdict: Time Limit Exceeded):
import queue
N,X,Y=map(int,input().split())
X -= 1
Y -= 1
INF = 1001001001
ans=[0]*N
def push(v, d):
  if dist[v]!= INF:
    return
  dist[v]=d
  q.put(v)

for sv in range(N):
  q=queue.Queue()
  dist=[INF]*N
  push(sv,0)
  while(not q.empty()):
    v=q.get()
    d=dist[v]
    if v-1 >= 0:
      push(v-1, d+1)
    if v+1 < N:
      push(v+1,d+1)
    if v==X:
      push(Y,d+1)
    if v==Y:
      push(X,d+1)
  for i in range(N):
    ans[dist[i]] +=1
for i in range(1,N):
  print(int(ans[i]/2))

Fixed submission:
import queue
N,X,Y=map(int,input().split())
X-=1
Y-=1
ans=[0]*N
for i in range(N-1):
  for j in range(i+1,N):
    ans[min(j-i, abs(X-i)+1+abs(Y-j))]+=1
for i in range(1,N):
  print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
import queue
N,X,Y=map(int,input().split())
X -= 1
Y -= 1
INF = 1001001001
ans=[0]*N
def push(v, d):
  if dist[v]!= INF:
    return
  dist[v]=d
  q.put(v)

for sv in range(N):
  q=queue.Queue()
  dist=[INF]*N
  push(sv,0)
  while(not q.empty()):
    v=q.get()
    d=dist[v]
    if v-1 >= 0:
      push(v-1, d+1)
    if v+1 < N:
      push(v+1,d+1)
    if v==X:
      push(Y,d+1)
    if v==Y:
      push(X,d+1)
  for i in range(N):
    ans[dist[i]] +=1
for i in range(1,N):
  print(int(ans[i]/2))

Fixed submission:
import queue
N,X,Y=map(int,input().split())
X-=1
Y-=1
ans=[0]*N
for i in range(N-1):
  for j in range(i+1,N):
    ans[min(j-i, abs(X-i)+1+abs(Y-j))]+=1
for i in range(1,N):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
A,B=map(int, input().split())
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
print(comb(A,2)+comb(B,2))

Fixed submission:
A,B=map(int, input().split())
import math
def comb(n, r):
  if n < 2:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
print(comb(A,2)+comb(B,2))
Buggy python submission (verdict: Time Limit Exceeded):
N, B, R = map(int, input().split())
sum_B = (N // (B+R)) * B
n = N % (B+R)
if n == 0:
  print(sum_B)
elif n > B:
  sum_B += B
  print(sum_B)
else:
  for _ in range(n):
    sum_B += 1
  print(sum_B)
    

Fixed submission:
N, B, R = map(int, input().split())
sum_B = (N // (B+R)) * B
n = N % (B+R)
if n == 0:
  print(sum_B)
elif n > B:
  sum_B += B
  print(sum_B)
else:
  sum_B += n
  print(sum_B)

Buggy python submission (verdict: Time Limit Exceeded):
N, B, R = map(int, input().split())
sum_B = 0
sum = 0
while 1:
  sum += (B + R)
  sum_B += B
  if sum > N:
    if (sum - N) > R:
      sum_B -= ((sum - N) - R)
      print(sum_B)
      break
    else:
      print(sum_B)
      break
    

Fixed submission:
N, B, R = map(int, input().split())
sum_B = (N // (B+R)) * B
n = N % (B+R)
if n == 0:
  print(sum_B)
elif n > B:
  sum_B += B
  print(sum_B)
else:
  sum_B += n
  print(sum_B)
Buggy python submission (verdict: Runtime Error):
N,R = input().split()
if N > 10:
  print(R)
else:
  print(R + (100 * (10 - N)))

Fixed submission:
N,R = map(int, input().split())
if N > 10:
  print(R)
else:
  print(R + (100 * (10 - N)))

Buggy python submission (verdict: Runtime Error):
N,R = input().split()
if N > 10:
  print(R)
else:
  R + (100 * (10 - N))

Fixed submission:
N,R = map(int, input().split())
if N > 10:
  print(R)
else:
  print(R + (100 * (10 - N)))
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ * K
  if N < K_:
    print(c)
    i=False
  counter += 1

Fixed submission:
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ *K
  if N < K_:
    print(c)
    i=False
  c += 1

Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ *= K
  if N < K_:
    print(c)
    i=False
  counter += 1


Fixed submission:
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ *K
  if N < K_:
    print(c)
    i=False
  c += 1

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
counter = 0
K_ = 1
i=True
while i==True:
  K_ = K_ * K
  if K > K_:
    print(counter)
    i=False
  counter += 1

Fixed submission:
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ *K
  if N < K_:
    print(c)
    i=False
  c += 1

Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
counter = 0
K_ = 1
while i=True:
  K_ = K_ * K
  if K > K_:
    print(counter)
    i=False
  counter += 1
  

Fixed submission:
N,K = map(int, input().split())
c = 1
K_ = 1
i=True
while i==True:
  K_ = K_ *K
  if N < K_:
    print(c)
    i=False
  c += 1
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a = int(input())
judge = True
for i in range(a):
  b = int(input())
  if (b % 2 == 0) and ((b % 3 == 0) or (b % 5 == 0)):
    judge = False
# 出力
if judge:
  print("APPROVED")
else:
  print("DENIED")

Fixed submission:
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
l = [a, b, c]
counter = 0
if a == b:
  counter += 1
if b == c:
  counter += 1
if a == c:
  counter += 1
if counter == 1:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
lis = list(map(int, input().split()))
j = 'YES'
for Nx in range(N):
  for Ax in range(1, N-Nx):
    if lis[Nx] == lis[Nx+Ax]:
      j = 'NO'
      break
    else:
      continue
    break
print(j)

Fixed submission:
N=int(input())
lis = list(map(int, input().split()))
j = 'YES'
if len(lis) != len(set(lis)):
  j = 'NO'
print(j)
Buggy python submission (verdict: Runtime Error):
H,N map(int, input().split())
A = list(map(int, input().split()))
for Ax in A:
  H -= Ax
if H < 0:
  print("Yes")
else:
  print("No")

Fixed submission:
H,N =map(int, input().split())
A = list(map(int, input().split()))
for Ax in A:
  H -= Ax
if H > 0:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
lis = list(map(int, input().split()))
c = 0
if N == 1:
  print(lis[0])
else:
  for i in range(N):
    f = True
    for j in range(i):
      if lis[i] > lis[j]:
        f = False
    if f:
      c += 1
  print(c)

Fixed submission:
N = int(input())
lis = list(map(int, input().split()))
c = 1
j_min = lis[0]
if N == 1:
  print(c)
else:
  for i in range(1,N):
    if j_min > lis[i]:
        c += 1
        j_min = lis[i]
  print(c)
Buggy python submission (verdict: Runtime Error):
C = input()
lis = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
       'p', 'q', 'r', 's', 't'. 'u', 'v', 'w', 'x', 'y', 'z']
for x in range(len(lis)):
  if C == lis[x]:
    print(lis[x+1])
    break

Fixed submission:
C = input()
lis = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
       'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for x in range(len(lis)):
  if C == lis[x]:
    print(lis[x+1])
    break
Buggy python submission (verdict: Runtime Error):
a = (int(x) for x in input().split())

print(a + a*a + a*a*a)

Fixed submission:
a = int(input())
print(a + a*a + a*a*a)
Buggy python submission (verdict: Runtime Error):
l = list(map(int, input().split()))

c = 0
for x in l:
    if x == 0:
        print(c)
    c++

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

c = 1
for x in l:
    if x == 0:
        print(c)
    c += 1
Buggy python submission (verdict: Runtime Error):
S,T = list(input().split())
count=0
for i in range(len(S)):
    if S[i]!=T[i]:
        count+=1
print(count)

Fixed submission:
S= list(input())
T= list(input())
count=0
for i in range(len(S)):
    if S[i]!=T[i]:
        count=count+1
print(count)

Buggy python submission (verdict: Runtime Error):
S,T = list(input().split())
count=0
for i in range(len(S)):
    if S[i]!=T[i]:
        count+=1
print(count)

Fixed submission:
S= list(input())
T= list(input())
count=0
for i in range(len(S)):
    if S[i]!=T[i]:
        count=count+1
print(count)
Buggy python submission (verdict: Runtime Error):
X,Y=map(int,input().split())
var=0
for i in range(2X,4X+1,2):
  if Y==i:
    var=1
if var==1:
  print("Yes")
else:
  print("No")

Fixed submission:
A = list(map(int,input().split()))
ans=0
for i in range(5):
  if A[i]!=i+1:
    ans=i+1
print(ans)
Buggy python submission (verdict: Runtime Error):
print(a+a*a+a*a*a)

Fixed submission:
a=int(input())
print(a+a*a+a*a*a)
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[int(n) for n in input().split()]
a=[0]*n
for i in range(1,n):
  if x[i-1]>=x[i]:
    a[i]=1
m=0
c=0
for i in a:
  if i==1:
    c+=1
  else:
    m=max(c,m)
    c=0
print(m)

Fixed submission:
x=input()
y=input()
c=0
for i in range (len(x)):
  if x[i]==y[i]:
    c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())
 ans = 'No'
for a in range(X + 1):
  b = X - a
  if 2 * a + 4 * b == Y:
    ans = 'Yes'
print(ans)

Fixed submission:
X, Y = map(int, input().split())
ans = 'No'
for a in range(X + 1):
  b = X - a
  if 2 * a + 4 * b == Y:
    ans = 'Yes'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = np.array([int(a) for a in input().split()])
q = int(input())
bc = np.array([[int(a) for a in input().split()] for j in range(q)])

u, c = np.unique(a, return_counts=True)
dica = dict(zip(u, c))
#print(dica)

keys = dica.keys()

for i in range(q):
  t1, t2 = bc[i]
  if not t1 in keys:
    dica[t1] = 0
    
  if not t2 in keys:
    dica[t2] = 0


for i in range(q):
  t1, t2 = bc[i]
  dica[t2] = dica[t1] + dica[t2]
  dica[t1] = 0
  print(sum([ k*dica[k] for k in dica.keys()]))






Fixed submission:
import numpy as np
n = int(input())
a = np.array([int(a) for a in input().split()])
q = int(input())
bc = np.array([[int(a) for a in input().split()] for j in range(q)])

u, c = np.unique(a, return_counts=True)
dica = dict(zip(u, c))
#print(dica)

keys = dica.keys()

tmp = sum([ k*dica[k] for k in dica.keys()])


for i in range(q):
  t1, t2 = bc[i]
  if not t1 in keys:
    dica[t1] = 0
  if not t2 in keys:
    dica[t2] = 0

  tmp += dica[t1] * (t2 - t1)
  print(tmp)
  
  dica[t2] = dica[t1] + dica[t2]
  dica[t1] = 0
Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy as np
x = int(input())
height = list(map(lambda x: int(x), input().split()))  
cands = []


count = 0
for i in range(len(height)):
  tmp = []
  cands.append(tmp)
  
  
for i in range(len(height)):
  if i-height[i] >= 0:
    for j in cands[i-height[i]]:
      count += 1
      
  if i+height[i] < len(height):
    cands[i+height[i]].append(i)

print(count)
	    


Fixed submission:
import math
import numpy as np
x = int(input())
height = list(map(lambda x: int(x), input().split()))  
cands = [0 for i in range(len(height))]


count = 0
  
for i in range(len(height)):
  if i-height[i] >= 0:
    count += cands[i-height[i]]
      
  if i+height[i] < len(height):
    cands[i+height[i]] += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy as np
x = int(input())
height = list(map(lambda x: int(x), input().split()))  
cands = []


results = []
for i in range(len(height)):
  tmp = []
  cands.append(tmp)
  
# j < k
def check(j, k):
  return k - j == height[j]+ height[k]

  
for i in range(len(height)):
  if i-height[i] >= 0:
    for j in cands[i-height[i]]:
      if check(j, i):
        results.append([j, i])
      
  if i+height[i] < len(height):
    cands[i+height[i]].append(i)

if len(results) > 1:
  #results = np.sort(results, axis=1)
  results = np.unique(results, axis=0)
print(len(results))
	    


Fixed submission:
import math
import numpy as np
x = int(input())
height = list(map(lambda x: int(x), input().split()))  
cands = [0 for i in range(len(height))]


count = 0
  
for i in range(len(height)):
  if i-height[i] >= 0:
    count += cands[i-height[i]]
      
  if i+height[i] < len(height):
    cands[i+height[i]] += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy as np
x = int(input())
height = list(map(lambda x: int(x), input().split()))  
cands = []

for i in range(len(height)):
  tmp = []
  cands.append(tmp)
  
for i in range(len(height)):
  if i-height[i] >= 0:
    cands[i-height[i]].append(i)
  if i+height[i] < len(height):
    cands[i+height[i]].append(i)

#print(cands)
results = []
for i in range(len(height)):
  #print(cands[i])
  if len(cands[i]) > 1:
    tmp = cands[i]
    for j in range(len(tmp)):
      for k in range(len(tmp)):
        if tmp[j] != tmp[k] and (tmp[j] - tmp[k] == height[tmp[j]]+ height[tmp[k]] or tmp[k]-tmp[j] == height[tmp[j]]+ height[tmp[k]]):
          #print([tmp[j], tmp[k]])
          results.append([tmp[j], tmp[k]])

if len(results) > 1:
  results = np.sort(results, axis=1)
  results = np.unique(results, axis=0)
print(len(results))
	    


Fixed submission:
import math
import numpy as np
x = int(input())
height = list(map(lambda x: int(x), input().split()))  
cands = [0 for i in range(len(height))]


count = 0
  
for i in range(len(height)):
  if i-height[i] >= 0:
    count += cands[i-height[i]]
      
  if i+height[i] < len(height):
    cands[i+height[i]] += 1

print(count)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import fractions
N, K = [int(i) for i in input().split(' ')]

if K % N == 0:
	result = N
elif N % K == 0:
	result = 0
elif fractions.gcd(N, K) == 1 and N > K:
	result = 1
elif fractions.gcd(N, K) == 1 and K > N:
	result = K-N if N > K - N else N
else:
  result = fractions.gcd(N, K)
  
print("{}".format(result))

#lis = np.array([int(n) for n in input().split(' ')])
#print("{} {}".format(sum(lis) / 4 / int(M), lis[int(M)-1]))

#count = sum(sum(lis) / 4.0 / int(M) <= lis)



Fixed submission:
import numpy as np
import fractions
N, K = [int(i) for i in input().split(' ')]

if N == 0:
	result = 0
elif K == 0:
	result = N
elif N % K == 0:
	result = 0
elif K % N == 0:
	result = K/N if N > K/N else N
elif N > K:
  result = N % K if N % K < K - N % K else K-N%K
elif N < K:
  result = K-N if N > K - N else N
  
print("{}".format(result))

#lis = np.array([int(n) for n in input().split(' ')])
#print("{} {}".format(sum(lis) / 4 / int(M), lis[int(M)-1]))

#count = sum(sum(lis) / 4.0 / int(M) <= lis)
Buggy python submission (verdict: Runtime Error):
import itertools
n, k = map(int, input().split())
a = []
n= map(str, list(range(1,n+1)))
for num in range(k):
    d = int(input())
    a.append(list(input()))
list1 = list(set(list(itertools.chain.from_iterable(a))))
list1.remove(' ')
list1.sort()
result =list(set(n)-set(list1))
print(len(result))

Fixed submission:
n, k = map(int, input().split())
d = [0] * k
sunuke = {}
for i in range(n):
    sunuke.setdefault(str(i), 0)
    #print(sunuke)

for i in range(k):
    d[i] = int(input())
    A = list(map(int,input().split()))
    #print(d[i],A)
    for j in range(d[i]):
        sunuke[str(A[j]-1)] += 1

ans = list(sunuke.values()).count(0)

print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = input().split()
a = list(map(int, input().split()))
print(max(n-sum(a),-1))

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

if int(n)-sum(a) < 0:
    print("-1")
else:
    print(int(n)-sum(a))