Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
	int n,cnt=0;
	ll ans=0;
	cin >> n;
	ll v[n+1];
	v[0]=0;
	for(int i=1;i<=n;i++){
		cin >> v[i];
		v[i]+=v[i-1];
	}
	sort(v,v+n+1);
	rep(i,n+1){
		cnt++;
		if(v[i]!=v[i+1] || i==n){
			ans+=(cnt*(cnt-1)/2);
			cnt=0;
		}
	}
	cout << ans << endl;
	return 0;
}

Fixed submission:
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
a = [0] + a

ans = 0
d = defaultdict(int)
d[0] += 1

for i in range(n):
    #累積和をとる
    a[i + 1] += a[i]
    #nC2を求める
    ans += d[a[i + 1]]
    #登場した回数を数える
    d[a[i + 1]] += 1

print(ans)
Buggy python submission (verdict: Runtime Error):

#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import collections as col

import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix


# main code
N,M = int_map()
AB = int_mtx(M)

l = np.zeros((N,N))
for i in range(0,M):
    l[AB[i][0]-1,AB[i][1]-1] = 1

n, labels = connected_components(l)

ll = list(labels)
aa = col.Counter(ll)
print(aa.most_common()[0][1])

Fixed submission:

#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import collections as col

import numpy as np
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix


# main code
N,M = int_map()

i = []
j = []

for z in range(0,M):
    a,b = int_map()
    i.append(a-1)
    j.append(b-1)
    
d = [1]*M

csr = csr_matrix((d,(i,j)),(N,N))


n, labels = connected_components(csr)

ll = list(labels)
aa = col.Counter(ll)
print(aa.most_common()[0][1])
Buggy python submission (verdict: Time Limit Exceeded):

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

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

past = 1
now = 1


for j in range(0,K):
    past = past*A[j]

for i in range(K,N):
    now = past/A[i-K]*A[i]
    if now > past:
        print('Yes')
    else:
        print('No')
    
    past = now
    now = 1






Fixed submission:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

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

for i in range(K,N):
    if A[i] > A[i-K]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

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

past = 1
now = 1


for j in range(0,K):
    past = past*A[j]

for i in range(K,N):
    for j in range(i-K+1,i+1):
        now = now*A[j]
    if now > past:
        print('Yes')
    else:
        print('No')
    
    past = now
    now = 1






Fixed submission:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

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

for i in range(K,N):
    if A[i] > A[i-K]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):

#!/usr/bin/python
# -*- coding: utf-8 -*-

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

ans = 1
for i in range(N):
    ans *= A[i]

if ans <= 10**18:
    print(ans)
else:
    print(-1)


Fixed submission:

#!/usr/bin/python
# -*- coding: utf-8 -*-

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

if A.count(0) > 0:
    print(0)
    exit()

ans = 1
for i in range(N):
    ans *= A[i]
    if ans > 10**18:
        print(-1)
        exit()

if ans <= 10**18:
    print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

import numpy as np

# 入力
N, M, X = map(int,input().split()) 
CA = [list(map(int,input().split())) for i in range(N)]

CAarray = np.array(CA)
C = CAarray[:,0]
A = CAarray[:,1:M+2]

if np.count_nonzero(np.sum(A, axis=0) < X) != 0:
    print(-1)
    exit()

Answer = np.sum(C)

for i in range(0,2**N):
    ll = [int(x) for x in list(str(format(i,'b').zfill(N)))]
    l = np.array(ll)

    if np.count_nonzero(np.dot(A.T,l.T) >= X) == M:
        if Answer >= np.dot(C.T,l.T):
            Answer = np.dot(C.T,l.T)

print(Answer)




Fixed submission:
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

import numpy as np

# 入力
N, M, X = map(int,input().split()) 
CA = [list(map(int,input().split())) for i in range(N)]

CAarray = np.array(CA)
C = CAarray[:,0]
A = CAarray[:,1:M+2]

if np.count_nonzero(np.sum(A, axis=0) < X) != 0:
    print(-1)
    exit()

Answer = np.sum(C)

for i in range(0,2**N):
    ll = [int(x) for x in list(str(format(i,'b').zfill(N)))]
    l = np.array(ll)

    if np.count_nonzero(np.dot(A.T,l.T) >= X) == M:
        if Answer >= np.dot(C.T,l.T):
            Answer = np.dot(C.T,l.T)

print(Answer)
Buggy python submission (verdict: Runtime Error):
A,B = (int(x) for x in input().split())

L = [(int((i+1)*0.08),int((i+1)*0.1)) for i in range(1000)]

check = 1

for i in range(1000):
    if L[i] == (A,B):
        print(i+1)
        check = 0
        break
A,B = (int(x) for x in input().split())

L = [(int((i+1)*0.08),int((i+1)*0.1)) for i in range(1010)]

check = 1

for i in range(1010):
    if L[i] == (A,B):
        print(i+1)
        check = 0
        break

if check == 1:
    print(-1)

if check == 1:
    print(-1)

Fixed submission:

import math

# 入力
A,B = (int(x) for x in input().split())

LA = list(range(math.ceil(12.5*A),math.ceil(12.5*(A+1))))
LB = list(range(math.ceil(10*B),math.ceil(10*(B+1))))

intersect = set(LA) & set(LB)

if intersect == set():
    print(-1)
else:
    print(min(intersect))
Buggy python submission (verdict: Time Limit Exceeded):
# 入力
S = input()
Q = int(input())

counter = 0

for i in range(Q):
    # i+1 回目のinput
    proc = input().split()

    if proc[0] == "1":
        counter += 1
    else:
        # 先頭に文字列を足す場合
        if (counter%2 == 0 and proc[1] == "1") or (counter%2 == 1 and proc[1] == "2"):
            S = proc[2] + S
        else:
            S = S + proc[2]

if counter%2 == 0:
    print(S)
else:
    print(S[::-1])



Fixed submission:
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

# 入力
S = input()
Q = int(input())

Change = " "
counter = 0

for i in range(Q):
    # i+1 回目のinput
    proc = input().split()

    if proc[0] == "1":
        counter += 1
    else:
        # 先頭に文字列を足す場合
        if (counter%2 == 0 and proc[1] == "1") or (counter%2 == 1 and proc[1] == "2"):
            Change = proc[2] + Change
        else:
            Change = Change + proc[2]

if counter%2 == 0:
    print(Change.replace(" ",S))
else:
    print(Change.replace(" ",S)[::-1])
Buggy python submission (verdict: Runtime Error):
N = input()

print(N//2 + N%2)

Fixed submission:
N = int(input())

print(N//2 + N%2)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
H = map(int,input().split()).sort()

print(sum(H[0:N-K]))

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

if N >= K:
    print(sum(H[0:N-K]))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
C = input()
print(chr(ord(C+1)))


Fixed submission:
print(chr(ord(input())+1))

Buggy python submission (verdict: Runtime Error):
print(chr(ord(input()+1)))


Fixed submission:
print(chr(ord(input())+1))
Buggy python submission (verdict: Runtime Error):
import fractions

# 入力
A,B = map(int,input().split())

print(int((A * B) // math.fractions(A, B)))

Fixed submission:
import fractions

# 入力
A,B = map(int,input().split())

print(int((A * B) // fractions.gcd(A, B)))

Buggy python submission (verdict: Runtime Error):
import math

# 入力
A,B = map(int,input().split())

print(int((A * B) // math.gcd(A, B)))

Fixed submission:
import fractions

# 入力
A,B = map(int,input().split())

print(int((A * B) // fractions.gcd(A, B)))

Buggy python submission (verdict: Runtime Error):

import math

# 入力
A,B = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(int(lcm(A, B)))

Fixed submission:
import fractions

# 入力
A,B = map(int,input().split())

print(int((A * B) // fractions.gcd(A, B)))

Buggy python submission (verdict: Runtime Error):
import math

# 入力
A,B = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

Fixed submission:
import fractions

# 入力
A,B = map(int,input().split())

print(int((A * B) // fractions.gcd(A, B)))
Buggy python submission (verdict: Runtime Error):

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)


N = int(input())
abc = int_mtx(N)

#f_inf = float("inf")
#dp = [f_inf]*N
dp = np.array([[0,0,0]]*N)

dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0])
    dp[i][1] = max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1])
    dp[i][2] = max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2])

print(max(dp[N-1]))



Fixed submission:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)


N = int(input())
abc = int_mtx(N)

#f_inf = float("inf")
#dp = [f_inf]*N
dp = np.array([[0,0,0]]*N)

dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0])
    dp[i][1] = max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1])
    dp[i][2] = max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2])

print(max(dp[N-1]))
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
h=int(input())
print(((a+b)*h)//2))


Fixed submission:
a=int(input())
b=int(input())
h=int(input())

print(((a+b)*h)//2)

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2))


Fixed submission:
a=int(input())
b=int(input())
h=int(input())

print(((a+b)*h)//2)

Buggy python submission (verdict: Runtime Error):
a=int(input())
a=int(input())
a=int(input())
print((a+b)*h/2)


Fixed submission:
a=int(input())
b=int(input())
h=int(input())

print(((a+b)*h)//2)

Buggy python submission (verdict: Runtime Error):
print(int((a+b)*h/2))


Fixed submission:
a=int(input())
b=int(input())
h=int(input())

print(((a+b)*h)//2)

Buggy python submission (verdict: Runtime Error):
int("(a+b)*h/2")

Fixed submission:
a=int(input())
b=int(input())
h=int(input())

print(((a+b)*h)//2)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

l = len(T)

ans = []
for i in range(len(S)-l):
    cnt = 0
    for n in range(l):
        if S[i+n] != T[n]:
            cnt += 1
    ans.append(cnt)
    
print(min(ans))


Fixed submission:
S = input()
T = input()

l = len(T)

if l == len(S):
    cnt = 0
    for i in range(l):
        if S[i] != T[i]:
            cnt += 1
    print(cnt)
    exit()

ans = []
for i in range(len(S)-l):
    cnt = 0
    for n in range(l):
        if S[i+n] != T[n]:
            cnt += 1
    ans.append(cnt)
    
print(min(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

start_v = (sum(A) - A[0])*A[0]

ans = start_v
for i in range(2, N):
    ans += int((start_v - sum(A[1:i])*A[0])*A[i-1]/A[0])

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


Fixed submission:
from itertools import accumulate

n = int(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
sum = 0

for i in range(len(a)):
    sum += a[i]*(b[-1] - b[i])
    sum %= 10**9 + 7

print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c = input()

c = [c[i] for i in range(N)]

cR = c.count('R')
cW = c.count('W')

listR = [i for i, x in enumerate(c) if x == 'R']
listW = [i for i, x in enumerate(c) if x == 'W']

if all([i == 'R' for i in c[:cR]]):
    print(0)
    exit()

if all([i == 'W' for i in c[cR:cR+cW]]):
    print(0)
    exit()

cnt = 0

for i in range(N):
        c[listR[-(i+1)]] = 'W'
        c[listW[i]] = 'R'
        cnt += 1
        if all([i == 'R' for i in c[:cR]]):
            print(cnt)
            break

    


Fixed submission:
N = int(input())
c = input()

cR = c.count('R')
cW = c.count('W')


if all([i == 'R' for i in c[:cR]]):
    print(0)
    exit()

if all([i == 'W' for i in c[cR:cR+cW]]):
    print(0)
    exit()

ans = c[:cR].count('W')

print(ans)
Buggy python submission (verdict: Runtime Error):
x = (1000 - N%1000)%1000

print(x)

Fixed submission:
N = int(input())

x = (1000 - N%1000)%1000

print(x)

Buggy python submission (verdict: Runtime Error):
x = 1000 - N%1000
print(x)

Fixed submission:
N = int(input())

x = (1000 - N%1000)%1000

print(x)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations

N, M, K = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

l = set(permutations('A'*N+'B'*M, N+M))

cnt_list = []

for i in l:
    time = 0
    cnt = 0
    indA = 0
    indB = 0
    for n in range(N+M):
        if i[n] == 'A':
            time += A[indA]
            indA += 1
        else:
            time += B[indB]
            indB += 1
        if time > K:
            break
        cnt += 1
    cnt_list.append(cnt)

print(max(cnt_list))


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

a, b = [0], [0]

for i in range(N):
    a.append(a[i] + A[i])

for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M

for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

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

l = list(combinations(p, K))

ans = []

for i in l:
    ans.append(sum(i))

print(min(ans))

Fixed submission:
import numpy as np

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

p = np.array(p)
p = np.sort(p)

ans = p[:K].sum()

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

N = int(input())
A = np.array(list(map(int, input().split())))
Q = int(input())
BC= [list(map(int,input().split())) for _ in range(Q)]

ans = []

for b,c in BC:
    A[A == b] = c
    ans.append(np.sum(A))

print(*ans, sep='\n')



Fixed submission:
import numpy as np

from collections import defaultdict
N = int(input())
A = tuple(map(int, input().split()))
Q = int(input())
BC= [list(map(int,input().split())) for _ in range(Q)]

counter = defaultdict(int)
for x in A:
    counter[x] += 1

total = sum(A)
for b, c in BC:
    total += (c - b) * counter[b]
    counter[c] += counter[b]
    counter[b] = 0
    print(total)

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

N = int(input())
A = np.array(list(map(int, input().split())))
Q = int(input())
BC= [list(map(int,input().split())) for _ in range(Q)]

for b,c in BC:
    A[A == b] = c
    print(np.sum(A))


Fixed submission:
import numpy as np

from collections import defaultdict
N = int(input())
A = tuple(map(int, input().split()))
Q = int(input())
BC= [list(map(int,input().split())) for _ in range(Q)]

counter = defaultdict(int)
for x in A:
    counter[x] += 1

total = sum(A)
for b, c in BC:
    total += (c - b) * counter[b]
    counter[c] += counter[b]
    counter[b] = 0
    print(total)
Buggy python submission (verdict: Runtime Error):
x1 = int(input())
x2 = int(input())
x3 = int(input())
x4 = int(input())
x5 = int(input())

l = [x1, x2, x3, x4, x5]
print(l.index(0)+1)

Fixed submission:
x1, x2, x3, x4, x5 = map(int, input().split())

l = [x1, x2, x3, x4, x5]

print(l.index(0)+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]

print(ans if ans <= 10**18 else '-1')



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

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 10**18:
            print(-1)
            return
    print(prod)

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

route = [tuple(map(int, input().split())) for _ in range(M)]

ans = [0]*(N+1)
que = [1]

while len(route) > 0 and len(que) > 0:
    temp = []
    del_l = []
    for i, (a, b) in enumerate(route):
        if a in que and b not in que:
            ans[b] = a
            temp.append(b)
            del_l.append(i)
        if b in que and a not in que:
            ans[a] = b
            temp.append(a)
            del_l.append(i)
    route = [r for r in route if route.index(r) not in del_l]
    que = temp

answer = ['Yes'] + ans[2:]

print(*answer, sep='\n')


Fixed submission:
from collections import deque

N, M = map(int, input().split())

G = [[] for _ in range(N+1)]
m = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in m:
    G[a].append(b)
    G[b].append(a)

par = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])

while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        par[w] = v
        q.append(w)
print('Yes')
print(*par[2:], sep='\n')

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

route = [tuple(map(int, input().split())) for _ in range(M)]

ans = [0]*(N+1)
stack = [1]
que = [1]

while len(stack) < N:
    temp = []
    for a, b in route:
        if a in que and b not in stack:
            ans[b] = a
            temp.append(b)
        elif b in que and a not in stack:
            ans[a] = b
            temp.append(a)
    que = temp
    stack += temp

answer = ['Yes'] + ans[2:]

print(*answer, sep='\n')


Fixed submission:
from collections import deque

N, M = map(int, input().split())

G = [[] for _ in range(N+1)]
m = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in m:
    G[a].append(b)
    G[b].append(a)

par = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])

while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        par[w] = v
        q.append(w)
print('Yes')
print(*par[2:], sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

cnt = 0
for n in range(1,N+1):
    adj = []
    adj.append([n])
    for i in AB:
        if n in i:
            adj.append(i)
    adj = set(sum(adj,[]))
    adj_H = [H[s-1] for s in adj]
    if max(adj_H) == H[n-1] and adj_H.count(max(adj_H)) == 1:
        cnt += 1

print(cnt)


Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
g = [[] for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

cnt = 0
for n in range(1,N+1):
    for i in g[n]:
        if H[n-1] <= H[i-1]:
            break
    else:
        cnt += 1

print(cnt)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]

cnt = 0
for n in range(1,N+1):
    adj = []
    adj.append([n])
    for i in AB:
        if n in i:
            adj.append(i)
    adj = set(sum(adj,[]))
    adj_H = [H[s-1] for s in adj]
    if max(adj_H) == H[n-1] and adj_H.count(max(adj_H)) == 1:
        ans.append(n)
        cnt += 1

print(cnt)


Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
g = [[] for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, input().split())
    g[a].append(b)
    g[b].append(a)

cnt = 0
for n in range(1,N+1):
    for i in g[n]:
        if H[n-1] <= H[i-1]:
            break
    else:
        cnt += 1

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

ans = []
start = 0
for i in range(1, N+1):
    cnt = 0
    if i > max(A) :
        ans.append(0)
        continue
    for a in range(start, N-1):
        if A[a] == i:
            cnt += 1
        if A[a] > i:
            start = a
            ans.append(cnt)
            break
    else:
        ans.append(cnt)

print(*ans, sep='\n')


Fixed submission:
import collections

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

ans = collections.Counter(A)

for n in range(N):
    print(ans[n+1])

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

ans = []
for i in range(1, N+1):
    x = A.count(i)
    ans.append(x)

print(*ans, sep='\n')


Fixed submission:
import collections

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

ans = collections.Counter(A)

for n in range(N):
    print(ans[n+1])

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


for i in range(1, N+1):
    x = A.count(i)
    print(x)

    

Fixed submission:
import collections

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

ans = collections.Counter(A)

for n in range(N):
    print(ans[n+1])