Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def fib(n):
    if n == 0: 
        return 0

    if n == 1: 
        return 1

    def matmul(M1, M2):
        a11 = M1[0][0]*M2[0][0] + M1[0][1]*M2[1][0]
        a12 = M1[0][0]*M2[0][1] + M1[0][1]*M2[1][1]
        a21 = M1[1][0]*M2[0][0] + M1[1][1]*M2[1][0]
        a22 = M1[1][0]*M2[0][1] + M1[1][1]*M2[1][1]
        return [[a11, a12], [a21, a22]]

    def matPower(mat, p):
        if p == 1: 
            return mat

        m2 = matPower(mat, p//2)
        if p % 2 == 0:
            return matmul(m2, m2)
        else: 
            return matmul(matmul(m2, m2),mat)

    Q = [[1,1],[1,0]]

    q_final = matPower(Q, n-1)
    return q_final[0][0]

N, M = map(int, input().split())
V = []
for x in range(M):
    V.append(int(input()))

result = 1

for i in range(1, M):
    if(V[i]-V[i-1]==1):
        result = 0

result *= fib(V[0])

for x in range(1, M):
    result *= fib(V[x]-V[x-1]-1)

if(V[M-1]!=N):
    result *= fib(N-V[M-1])

print(result%1000000007)

Fixed submission:
def fib(n):
    if n == 0: 
        return 0

    if n == 1: 
        return 1

    def matmul(M1, M2):
        a11 = M1[0][0]*M2[0][0] + M1[0][1]*M2[1][0]
        a12 = M1[0][0]*M2[0][1] + M1[0][1]*M2[1][1]
        a21 = M1[1][0]*M2[0][0] + M1[1][1]*M2[1][0]
        a22 = M1[1][0]*M2[0][1] + M1[1][1]*M2[1][1]
        return [[a11, a12], [a21, a22]]

    def matPower(mat, p):
        if p == 1: 
            return mat

        m2 = matPower(mat, p//2)
        if p % 2 == 0:
            return matmul(m2, m2)
        else: 
            return matmul(matmul(m2, m2),mat)

    Q = [[1,1],[1,0]]

    q_final = matPower(Q, n-1)
    return q_final[0][0]

N, M = map(int, input().split())
if(M==0):
    print(fib(N+1)%1000000007)
else:
    V = []
    for x in range(M):
        V.append(int(input()))

    result = 1

    for i in range(1, M):
        if(V[i]-V[i-1]==1):
            result = 0

    result *= fib(V[0])

    for x in range(1, M):
        result *= fib(V[x]-V[x-1]-1)

    if(V[M-1]!=N):
        result *= fib(N-V[M-1])

    print(result%1000000007)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
V = list(map(int, input().split()))

ans = -10**9
R = min(N, K)
A = R
for a in range(0, A+1):
    B = R-a
    for b in range(0, B+1):
        if b>0:
            v = V[:a] + V[-b:]
        else:
            v = V[:a]
        
        v.sort()
        
        cnt = 0
        for vv in v:
            if vv<0:
                cnt += 1
            else:
                break
        ans = max(ans, sum(v[min(K-a-b, cnt):]))
        
print(ans)

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

ans = -10**9
R = min(N, K)
A = R
for a in range(0, A+1):
    B = R-a
    for b in range(0, B+1):
        if b>0:
            v = V[:a] + V[-b:]
        else:
            v = V[:a]
        
        v.sort()
        
        cnt = 0
        for vv in v:
            if vv<0:
                cnt += 1
            else:
                break
        ans = max(ans, sum(v[min(K-a-b, cnt):]))
        
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = [0]*10000
a = [1]*3

while (a[0]+1)**2 <= n-2:
    a[1]=1
    while (a[1]+a[0])*(a[1]+1)+a[0]**2<=n-1:
        a[2]=1
        while a[0]**2+a[1]**2+a[2]**2+a[0]*a[1]+a[1]*a[2]+a[2]*a[0] <= n:
            ans[a[0]**2+a[1]**2+a[2]**2+a[0]*a[1]+a[1]*a[2]+a[2]*a[0]] += 1
            a[2] += 1
        a[1]+=1
    a[0]+=1
for i in range(n):
    print(ans[i])




Fixed submission:
n = int(input())

ans = [0]*10001
a = [1,1,1]

while (a[0]+1)**2 <= n-2:
    a[1]=1
    while (a[1]+a[0])*(a[1]+1)+a[0]**2<=n-1:
        a[2]=1
        while a[0]**2+a[1]**2+a[2]**2+a[0]*a[1]+a[1]*a[2]+a[2]*a[0] <= n:
            ans[a[0]**2+a[1]**2+a[2]**2+a[0]*a[1]+a[1]*a[2]+a[2]*a[0]] += 1
            a[2] += 1
        a[1]+=1
    a[0]+=1
for i in range(1,n+1):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ok = list()
ans = 0

for i in range(n):
    if len(ok) == 10:
        break
    same = 0
    for j in range(len(ok)):
        if ok[j] == s[i]:
            same = 1
    if same == 1:
        continue
    ok.append(s[i])
    nd = list()
    for j in range(i+1,n):
        same = 0
        if len(nd) == 10:
            break
        for k in range(len(nd)):
            if nd[k] == s[j]:
                same = 1
        if same == 1:
            continue
        nd.append(s[j])
        rd = list()
        for k in range(j+1, n):
            if len(rd) == 10:
                break
            same = 0
            for l in range(len(rd)):
                if rd[l] == s[k]:
                    same = 1
            if same == 1:
                continue
            rd.append(s[k])
            ans += 1

print(ans)


Fixed submission:
n = int(input())
s = input()

ok = [0,0,0,0,0,0,0,0,0,0]
ans = 0

for i in range(n):
    if sum(ok) == 10:
        break
    if ok[int(s[i])] == 1:
        continue
    ok[int(s[i])] = 1
    nd = [0,0,0,0,0,0,0,0,0,0]
    for j in range(i+1,n):
        if sum(nd) == 10:
            break
        if nd[int(s[j])] == 1:
            continue
        nd[int(s[j])] = 1
        rd = [0,0,0,0,0,0,0,0,0,0]
        for k in range(j+1, n):
            if sum(rd) == 10:
                break
            if rd[int(s[k])] == 1:
                continue
            rd[int(s[k])] = 1
            ans += 1

print(ans)

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

ok = list()
ans = 0

for i in range(n):
    same = 0
    for j in range(len(ok)):
        if ok[j] == s[i]:
            same = 1
    if same == 1:
        continue
    ok.append(s[i])
    nd = list()
    for j in range(i+1,n):
        same = 0
        for k in range(len(nd)):
            if nd[k] == s[j]:
                same = 1
        if same == 1:
            continue
        nd.append(s[j])
        rd = list()
        for k in range(j+1, n):
            same = 0
            for l in range(len(rd)):
                if rd[l] == s[k]:
                    same = 1
            if same == 1:
                continue
            rd.append(s[k])
            ans += 1

print(ans)


Fixed submission:
n = int(input())
s = input()

ok = [0,0,0,0,0,0,0,0,0,0]
ans = 0

for i in range(n):
    if sum(ok) == 10:
        break
    if ok[int(s[i])] == 1:
        continue
    ok[int(s[i])] = 1
    nd = [0,0,0,0,0,0,0,0,0,0]
    for j in range(i+1,n):
        if sum(nd) == 10:
            break
        if nd[int(s[j])] == 1:
            continue
        nd[int(s[j])] = 1
        rd = [0,0,0,0,0,0,0,0,0,0]
        for k in range(j+1, n):
            if sum(rd) == 10:
                break
            if rd[int(s[k])] == 1:
                continue
            rd[int(s[k])] = 1
            ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
i=int(input())
x=[int(x) for x in input().split()]
for i in x:
  if x.count(i)>1:
    c=0
    break
  else:
      c=1
if(c==1):
    print("YES")
elif(c==0):
    print("NO")      

Fixed submission:
i=int(input())
x=[int(x) for x in input().split()]
y=set(x)
if(len(y)==len(x)):
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
i=int(input())
x=[]
for i in range(0,i):
  a=int(input())
  if a in x:
    c=0
    break
  else:
    c=1
if(c==0):
  print("NO")
else: 
  print("YES")

Fixed submission:
i=int(input())
x=[int(x) for x in input().split()]
y=set(x)
if(len(y)==len(x)):
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Time Limit Exceeded):
i=int(input())
x=[int(x) for x in input().split()]
for i in x:
  if x.count(i)>1:
    c=0
    break
  else:
      c=1
if(c==1):
    print("YES")
else:
    print("NO")      

Fixed submission:
i=int(input())
x=[int(x) for x in input().split()]
y=set(x)
if(len(y)==len(x)):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a = input()
l = a.split('S')
while("" in l):
   l.remove("")
print(len(l[0]))

Fixed submission:
a = input()
emp = 0
l = a.split('S')
while("" in l):
   l.remove("")
if not l:
   print(emp)
else:
   print(len(l[0]))
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
emp = []
for i in range(num):
   string = input()
   emp.append(string)
   string = ""
d = {i:emp.count(i) for i in emp}

maximum = max(d.values())
keys = [key for key, value in d.items() if value == maximum]
keys.sort()
for i in keys:
   print(i)


Fixed submission:
from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
num = input()
inp = input().split()
res = []
final = ""
tem = 0
for i in inp:
   tem = inp.count(i)
   res.append(tem)
   tem = 0
for i in res:
   if i >= 2:
      final = "NO"
      break
   else:
      final = "YES"
print(final)


Fixed submission:
num = input()
inp = input().split()
len1 = len(inp)
out = set(inp)
len2 = len(out)
if len1 == len2:
   print("YES")
else:
   print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n >= 30:
  return "Yes"
else:
  return "No"

Fixed submission:
n = int(input())
a = "Yes"
b = "No"
if n >= 30:
  print(a)
else:
  print(b)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                ans+=1
print(ans)

Fixed submission:
k,s = map(int, input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if 0<=z and z<=k:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  priority_queue<double, vector<double>,  greater<double>> q;
  int v;
  for (int i = 0; i < N; i++) {
    cin >> v;
    q.push((double)v);
  }
  while (q.size() > 1) {
    double v1 = q.top();
    q.pop();
    double v2 = q.top();
    q.pop();
    q.push((v1+v2)/2);
  }
  cout << fixed << setprecision(10) << q.top() << endl;
  return 0;
}


Fixed submission:
import heapq

N = int(input())
q = list(map(int, input().split()))

heapq.heapify(q)

while (len(q) > 1):
    v1 = heapq.heappop(q)
    v2 = heapq.heappop(q)
    heapq.heappush(q, (v1+v2)/2.0)

print(heapq.heappop(q))

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  priority_queue<double, vector<double>,  greater<double>> q;
  int v;
  for (int i = 0; i < N; i++) {
    cin >> v;
    q.push((double)v);
  }
  while (q.size() > 1) {
    double v1 = q.top();
    q.pop();
    double v2 = q.top();
    q.pop();
    q.push((v1+v2)/2);
  }
  cout << setprecision(10) << q.top() << endl;
  return 0;
}


Fixed submission:
import heapq

N = int(input())
q = list(map(int, input().split()))

heapq.heapify(q)

while (len(q) > 1):
    v1 = heapq.heappop(q)
    v2 = heapq.heappop(q)
    heapq.heappush(q, (v1+v2)/2.0)

print(heapq.heappop(q))
Buggy python submission (verdict: Runtime Error):
z =input()

if z == "A":
    print("T")
else if z == "T":
    print("A")
else if z == "G":
    print("C")
else if z == "G":
    print("G")


Fixed submission:
z =input()

if z == "A":
    print("T")
elif z == "T":
    print("A")
elif z == "G":
    print("C")
elif z == "C":
    print("G")
Buggy python submission (verdict: Runtime Error):
import collections

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

X = []
for i in range(M):
    Aj, Bj = map(int,input().split())
    if H[Aj - 1] < H[Bj - 1]:
       X.append(Aj)
    elif H[Bj - 1] < H[Aj - 1]:
       X.append(Bj)
    elif H[Aj - 1] == H[Bj - 1]:
        X.append(Aj)
        X.append(Bj)

low_H = collections.Counter(X)
ans = N - len(low_H)
print(ans)


Fixed submission:
import collections

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

X = []
for i in range(M):
    Aj, Bj = map(int,input().split())
    if H[Aj - 1] < H[Bj - 1]:
       X.append(Aj)
    elif H[Bj - 1] < H[Aj - 1]:
       X.append(Bj)
    elif H[Aj - 1] == H[Bj - 1]:
        X.append(Aj)
        X.append(Bj)

low_H = collections.Counter(X)
ans = N - len(low_H)
print(ans)
Buggy python submission (verdict: Runtime Error):
cnt = 0
for i in range(L, R+1):
    if i % d == 0:
        cnt += 1
print(cnt)

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

cnt = 0
for i in range(L, R+1):
    if i % d == 0:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.buffer.readline

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)

# テスト
N = int(input())
#print("約数 =", divisors(N))
#print("素因数分解 = ", primeFactor(N)) 

ans = 0
for i in range(1,N+1):
    A = primeFactor(i).values()
    chk = 1
    for a in A:
        chk *= (a+1)
    ans += chk*i

print(ans)

Fixed submission:
#Osa_k法（前処理をした後、素因数分解をO(logN)でできる）

N = int(input())
sieve = [-1] * (N+1)
#prime = []
for i in range(2, N+1):#前処理（各indexについて、割れる最小の素数）
    if sieve[i] == -1:#未探索のとき
        sieve[i] = i
        #prime.append(i)#素数列挙したいとき
        for j in range(i*i, N+1, i):
            if sieve[j] == -1:
                sieve[j] = i
#print(sieve)
#print(prime)

Ans = [1] * (N+1)
for i in range(2, N+1):
    p = sieve[i]
    cur = i
    cnt = 0
    while cur > 1:
        if cur % p == 0:
            cur //= p
            cnt += 1
        else:
            break
    if i == pow(p,cnt):#iの素因数がpのみ
        Ans[i] = i*(cnt+1)
    else:
        Ans[i] = Ans[i//(p**cnt)] * Ans[p**cnt]#それ以外の時、掛算すればOK
#print(Ans)
print(sum(Ans)-1)
Buggy python submission (verdict: Runtime Error):
X,N = map(int, input().split())
A = list(map(int, input().split()))
Min = 101

for i in range(1,101):
    if i in A:
        continue
    if abs(i-X) < Min:
        ans = i
        Min = abs(i-X)
print(ans)

Fixed submission:
#!/usr/bin/env python3

#!/usr/bin/env python3

X,N = map(int, input().split())
if N == 0:
    print(X)
    exit()

A = list(map(int, input().split()))
Min = 101

cnt = -200
for i in range(1,400):
    #print(cnt)
    if cnt in A:
        cnt += 1
        continue
    if abs(cnt-X) < Min:
        ans = cnt
        Min = abs(cnt-X)
    cnt += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if (W-V) == 0:
    print("NO")
elif (A-B) % (V-W) != 0:
    print("NO")
else:
    ans = (A-B)//(V-W)
    #print(ans)
    if 1 <= ans <= T:
        print("YES")
    else:
        print("NO")


Fixed submission:
S = input()
print(S[:3])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

N = int(input())
A = list(map(int,input().split()))
ans = 1
for i in A:
    ans *= i
if ans > 10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
#!/usr/bin/env python3

N = int(input())
A = list(map(int,input().split()))
ans = 1
if 0 in A:
    print(0)
    exit()
else:
    for i in A:
        ans *= i
        if ans > 10**18:
            print(-1)
            exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2]+A[N//2+1])//2
    BB = (B[N//2-1]+B[N//2+1-1])//2
    print(BB-AA+1)


Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2-1]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2-1]+A[N//2])/2
    BB = (B[N//2-1]+B[N//2])/2
    print(int((BB-AA)*2+1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2]+A[N//2+1])/2
    BB = (B[N//2-1]+B[N//2+1-1])/2
    print(BB-AA+1)

Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2-1]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2-1]+A[N//2])/2
    BB = (B[N//2-1]+B[N//2])/2
    print(int((BB-AA)*2+1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
print(A)
print(B)
if N % 2 == 1:
    AA = A[(N+1)//2]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2]+A[N//2+1])/2
    BB = (B[N//2-1]+B[N//2+1-1])/2
    print(BB-AA+1)

Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2-1]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2-1]+A[N//2])/2
    BB = (B[N//2-1]+B[N//2])/2
    print(int((BB-AA)*2+1))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import  itertools
import numpy as np

N,M,X = map(int, input().split())
A = []
for i in range(N):
    A.append(np.array(list(map(int, input().split()))))

#print(A)
l = [1, 0]
ll = list(itertools.product(l, repeat=N))
#print(ll)
ans = float("inf")
for i in ll:
    jdg = np.array([0] * (M+1))
    for k in range(N):
        if i[k] == 1:
             jdg = jdg + A[k]
    #print(jdg)
    if min(jdg[1:]) >= X:
        ans = min(ans,jdg[0])
    #print(min(jdg[1:]))
if ans != float("inf"):
    print(ans)
else:
    print(-1)

Fixed submission:
import  itertools
import numpy as np

N,M,X = map(int, input().split())
A = []
for i in range(N):
    A.append(np.array(list(map(int, input().split()))))

#print(A)
l = [1, 0]
ll = list(itertools.product(l, repeat=N))
#print(ll)
ans = float("inf")
for i in ll:
    jdg = np.array([0] * (M+1))
    for k in range(N):
        if i[k] == 1:
             jdg = jdg + A[k]
    #print(jdg)
    if min(jdg[1:]) >= X:
        ans = min(ans,jdg[0])
    #print(min(jdg[1:]))
if ans != float("inf"):
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import sys
input = sys.stdin.readline


N = int(input())

a = list(map(int, input().split()))
A = np.array([a for i in range(N)])
B = np.array([[a[i]] * N for i in range(N)])
C = A + B
d = [i for i in range(N)]
D = np.array([d for i in range(N)])
E = np.array([[i] * N for i in range(N)])

#print(D)
#print(E)
ind = D - E
#print(ind)
ans = C - ind
#print(ans)
#cnt = np.count_nonzero(ans == 0)
print(cnt)

Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))
B = collections.defaultdict(int)
C = collections.defaultdict(int)

for i in range(N):
    B[i-A[i]] += 1 
    C[i+A[i]] += 1
#print(B)
#print(C)
ans = 0
for i in B:
    #print(i) i=Key
    if i in C:
        ans += B[i]*C[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys
input = sys.stdin.readline


N = int(input())

a = list(map(int, input().split()))
A = np.array([a for i in range(N)])
B = np.array([[a[i]] * N for i in range(N)])
C = A + B
d = [i for i in range(N)]
D = np.array([d for i in range(N)])
E = np.array([[i] * N for i in range(N)])

#print(D)
#print(E)
ind = D - E
#print(ind)
ans = C - ind
#print(ans)
cnt = np.count_nonzero(ans == 0)
print(cnt)

Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))
B = collections.defaultdict(int)
C = collections.defaultdict(int)

for i in range(N):
    B[i-A[i]] += 1 
    C[i+A[i]] += 1
#print(B)
#print(C)
ans = 0
for i in B:
    #print(i) i=Key
    if i in C:
        ans += B[i]*C[i]
print(ans)

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

N = int(input())

a = list(map(int, input().split()))
A = np.array([a for i in range(N)])
B = np.array([[a[i]] * N for i in range(N)])
C = A + B
ind = np.array([[i-j for i in range(N)] for j in range(N)])

D = C - ind
cnt = np.count_nonzero(D == 0)
print(cnt)

Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))
B = collections.defaultdict(int)
C = collections.defaultdict(int)

for i in range(N):
    B[i-A[i]] += 1 
    C[i+A[i]] += 1
#print(B)
#print(C)
ans = 0
for i in B:
    #print(i) i=Key
    if i in C:
        ans += B[i]*C[i]
print(ans)

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

N = int(input())

#A = [(i, a) for i, a in enumerate(map(int, input().split()), start=1)]
A = np.array(list(map(int, input().split())))
ind = [i for i in range(N)]
cnt = 0
for i in range(N):
    B = ind - np.array([i] * N)#マイナスは気にせず
    C = A + np.array(A[i])
    D = B - C
    cnt += np.count_nonzero(D == 0)
    #print(A,B,C,D)
print(cnt)

Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))
B = collections.defaultdict(int)
C = collections.defaultdict(int)

for i in range(N):
    B[i-A[i]] += 1 
    C[i+A[i]] += 1
#print(B)
#print(C)
ans = 0
for i in B:
    #print(i) i=Key
    if i in C:
        ans += B[i]*C[i]
print(ans)