ZhenlongDai/ACPR huggingface dataset:
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=input()
a=input().split()
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=i
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
print((ans/2)%(10**9+7))

Failing test case input:
4
2519048 2817 176 11813

Expected output:
332876530


Actual output:
332876530.0


Fixed submission (verdict: Accepted):
n=input()
a=input().split()
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=i
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
print((ans

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A_ls=list(map(int, input().split()))

a=(sum(A_ls))**2
for i in A_ls:
	a-=(i**2)

b=int(0.5+a/2)
print(b%(10**9+7))





Failing test case input:
4
141421356 17320508 22360679 244949

Expected output:
437235829

Actual output:
437235830


Fixed submission (verdict: Accepted):
N = int(input())
A_ls=list(map(int, input().split()))

a=(sum(A_ls))**2
b=0
for i in A_ls:
	b+=(i**2)

c=int((a-b)
print(c%(10**9+7))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))

sum_A = sum(A)

ans = 0
for i in range(N):
  a = A[i]
  sum_A-=a
  ans+=a*sum_A
print(ans)

Failing test case input:
4
141421356 2224125 4405286 29158

Expected output:
57428667


Actual output:
951655064090252


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

sum_A = sum(A)
mod = 10**9+7
ans = 0
for i in range(N-1):
  a = A[i]
  sum_A-=a
  ans+=a*sum_A
print(ans%mod)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A=list(map(int, input().split()))
p=10**9+7
S=sum(A)%p
S2=S**2%p
T=0
for i in range(N):
    T+=(A[i]**2)%p
T=T%p
if S2<T:
    S2+=p
ans=int((S2-T)/2)
print(ans)


Failing test case input:
4
36257838 88697 435150 70292

Expected output:
614213037


Actual output:
114213033


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int, input().split()))
p=10**9+7
S=sum(A)
S2=S**2
T=0
for i in range(N):
    T+=A[i]**2
ans=((S2-T)
print(ans)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
 
ans = 0
total = sum(A)
for i in range(N - 1):
    total -= A[i]
    print(total)
    ans += (A[i] * total) 
    print(ans)
 
print(ans % mod)

Failing test case input:
4
10344776 230 75 33

Expected output:
496561582


Actual output:
338
3496534288
108
3496559128
33
3496561603
496561582


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
 
ans = 0
total = sum(A)
for i in range(N - 1):
    total -= A[i]
    ans += (A[i] * total) 
 
print(ans % mod)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

sum_of_product = (sum(A) ** 2) % (10 ** 9 + 7)

for i in A:
    sum_of_product -= i ** 2
    if sum_of_product < 0:
        sum_of_product += 10 ** 9 + 7

print(sum_of_product)

Failing test case input:
4
141421356 1831213 4405286 176612

Expected output:
304938989


Actual output:
-20022786530281531


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

sum_list = sum(A)
sum_of_product = 0

for i in A:
    sum_list -= i
    sum_of_product = ((sum_list * i) % (10 ** 9 + 7) + sum_of_product) % (10 ** 9 + 7)

print(sum_of_product)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
total=0
for i in range(n):
    for j in range(i+1,n):
        total+=a[i]%mod*a[j]%mod

print(total)


Failing test case input:
4
2519048 2493 176 1307

Expected output:
19661929


Actual output:
1019661936


Fixed submission (verdict: Accepted):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))

A=sum(a)%mod
total=0

for i in range(n-1):
    A-=a[i]
    total+=A*a[i]
    total%=mod

print(total)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):









def solve():
    n = int(input())
    As = list(map(int, input().split()))

    mod = 10**9+7
    _sum = 0
    for a in As:
        _sum += a
        _sum %= mod

    total = 0
    for a in As:
        total += a * (_sum - a)
        total %= mod

    total 

    return total


def main():
    print(solve())


if __name__ == "__main__":
    main()


Failing test case input:
4
2519048 3416 189 862

Expected output:
256340473


Actual output:
512680946


Fixed submission (verdict: Accepted):









def solve():
    n = int(input())
    As = list(map(int, input().split()))

    mod = 10**9+7
    sums = [0] * (n+1)

    tmp = 0
    for i, a in enumerate(As[::-1]):
        tmp += a
        tmp %= mod
        sums[-i-1] = tmp

    total = 0
    for i, a in enumerate(As[:-1]):
        total += a * (sums[i+2])
        total %= mod

    return total


def main():
    print(solve())


if __name__ == "__main__":
    main()

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
tmp = sum(A)
sum_ = 0

for a in A:
    tmp -= a
    sum_ += a * tmp

print(sum_)


Failing test case input:
4
2519048 2493 176 11813

Expected output:
512820549


Actual output:
36512820801


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
tmp = sum(A)
sum_ = 0

for a in A:
    tmp -= a
    sum_ += a * tmp

print(sum_ % (1_000_000_007))
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import itertools
N = int(input())
a = list(map(int,input().split()))
a2 = itertools.accumulate(a)
b = [0]
b += list(a2)
s = 0
for i in range(N):
    s += (a[i] * (b[-1] - b[i+1]))
print(s)

Failing test case input:
4
4602446 4102 176 11813

Expected output:
109216034


Actual output:
74109216552


Fixed submission (verdict: Accepted):
import itertools
N = int(input())
a = list(map(int,input().split()))
a2 = itertools.accumulate(a)
b = [0]
b += list(a2)
s = 0
for i in range(N):
    s += (a[i] * (b[-1] - b[i+1]))
print(s % (10**9+7))

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list((int(x) for x in input().split()))
ans = 0
for i in range(N-1):
  for j in range(i+1,N):
    ans += A[i]*A[j] % (10**9+7)
print(ans)

Failing test case input:
4
3646424 64145 127 6247

Expected output:
551825856


Actual output:
2551825870


Fixed submission (verdict: Accepted):
N = int(input())
b = 10**9+7
A = list((int(x) for x in input().split()))
sum = 0
for a in A:
  sum += a
ans = 0
for i in range(N-1):
  sum -= A[i]
  ans += A[i]*sum
print(ans % b)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int ,input().split()))
MOD = 10**9+7

sum = 0
for i in range (N):
    sum += A[i] % MOD

ans = 0
for i in range(N):
    sum -= A[i]
    ans += (A[i] * sum) % MOD

print(ans)

Failing test case input:
4
3646424 64145 178 11813

Expected output:
395401127


Actual output:
1395401134


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int ,input().split()))
MOD = 10**9+7

sum = 0
for i in range (N):
    sum += A[i] % MOD

ans = 0
for i in range(N):
    sum -= A[i]
    ans += (A[i] * sum) % MOD

ans = ans % MOD
print(ans)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
mod = 1000000007

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            print(A[i], A[j])
            ans += (A[i] * A[j] % mod)
    print(ans % mod)

if __name__ == "__main__":
    solve()

Failing test case input:
4
141421356 2224125 4405286 176612

Expected output:
735073075


Actual output:
141421356 2224125
141421356 4405286
141421356 176612
2224125 4405286
2224125 176612
4405286 176612
735073075


Fixed submission (verdict: Accepted):
mod = 1000000007

def solve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    s = sum(A)
    for i in range(N - 1):
        s -= A[i]
        ans += A[i] * s
    print(ans % mod)

if __name__ == "__main__":
    solve()
Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
A = list(set(sorted(A)))
ans = 0
for i in range(len(A)-1):
    ans += (A[i] * sum(A[i+1::])) % (10**9+7)
    if ans >= 10**9+7:
        ans = ans % 10**9+7
print(ans)

Failing test case input:
4
3646424 64145 178 11813

Expected output:
395401127


Actual output:
395401141


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
ans = 0
L = A.copy()
for i in range(-2,-len(A)-1,-1):
    L[i] += L[i+1]
for i in range(len(A)-1):
    ans += (A[i] * L[i+1]) % (10**9+7)
    if ans >= 10**9+7:
        ans = ans % (10**9+7)
print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
hoge=list(map(int,input().split()))
ans=0
wa=hoge[0]
for i in range(1,n):
  ans+=wa*hoge[i]
  wa+=hoge[i]
print(ans)

Failing test case input:
4
4932847 3416 189 33

Expected output:
946461856


Actual output:
17946461975


Fixed submission (verdict: Accepted):
n=int(input())
hoge=list(map(int,input().split()))
ans=0
wa=hoge[0]
for i in range(1,n):
  ans+=wa*hoge[i]
  ans=ans%(10**9+7)
  wa+=hoge[i]
print(ans)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
lis = list(map(int,input().split()))
num = sum(lis)% (10 ** 9 + 7)
ans = 0
for i in range(n):
  ans += lis[i] * (num-lis[i])
  ans %= 10 ** 9 + 7
while ans < 0:
  ans += 10 ** 9 + 7
print(ans)

Failing test case input:
4
27651699 119786 3133913 72528

Expected output:
210345254


Actual output:
420690508


Fixed submission (verdict: Accepted):
n = int(input())
lis = list(map(int,input().split()))
li = [0]
for num in lis:
    li.append(li[-1] + num)
ans = 0
mod = 10 ** 9 + 7
for i in range(n):
    ans += (lis[i] * li[i]) % mod
    ans %= mod
print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = [int(a) for a in input().split()]
mod = 10 ** 9 + 7
ans = 0
for i in range(N - 1):
  for j in range(i+1, N):
    a = (A[i] * A[j]) % mod
    ans += a
    ans = ans % mod
  print(a)
print(ans)

Failing test case input:
4
4932847 3416 189 570

Expected output:
597336559


Actual output:
811722776
1947120
107730
597336559


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(a) for a in input().split()]
mod = 10 ** 9 + 7
ans = 0


tot = 0
for i in range(N):
  A[i] %= mod
  tot += A[i]
  tot %= mod
for i in range(N-1):
  tot -= A[i]
  ans += (A[i] * tot) % mod
  ans %= mod
print(ans)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
mod = 10**9 + 7
a = [int(x)%mod for x in input().split()]
allsum = sum(a)
s = 0
for i in range(n):
    allsum = allsum -a[i]
    s += a[i]*allsum
print(s)

Failing test case input:
4
27651699 119786 3133913 72528

Expected output:
210345254


Actual output:
92587210993363


Fixed submission (verdict: Accepted):
n = int(input())
mod = 10**9 + 7
a = [int(x)%mod for x in input().split()]
allsum = sum(a)
s = 0
for i in range(n):
    allsum = allsum -a[i]
    s += a[i]*allsum
print(s%mod)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
SUM = 0
for i in range(N-1):
    j=i+1
    for j in range(i+1,N):
        SUM += A[i] * A[j] % MOD
print(SUM)

Failing test case input:
4
2519048 4102 176 11813

Expected output:
585259054


Actual output:
1585259061


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
S = sum(A) % MOD
ans = 0

for x in A:
    S -= x
    S %= MOD
    ans += S * x
    ans %= MOD
ans %= MOD
print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from itertools import accumulate
mod = 1e9 +7
def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans =0
    ac = list(accumulate(a))
    
    for i in range(n):
        ans += a[i]* (ac[-1]-ac[i])
        ans %=mod
    print(ans)

if __name__ == '__main__':
    main()

Failing test case input:
4
2519048 3927 227 749

Expected output:
354895035


Actual output:
354895035.0


Fixed submission (verdict: Accepted):
from itertools import accumulate
mod = 10**9 +7

def main():
    n = int(input())
    a = list(map(int,input().split()))
    ans =0
    ac = list(accumulate(a))

    for i in range(n):
        ans += a[i]* (ac[-1]-ac[i])
        ans %=mod
    print(ans)

if __name__ == '__main__':
    main()

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().strip().split()))

m = 10 ** 9 + 7
def main():
    r = 0
    for nn in range(n):
        r += a[nn]
    print(r)
    return

main()


Failing test case input:
4
2519048 3416 189 862

Expected output:
256340473


Actual output:
2523515


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().strip().split()))


m = 10 ** 9 + 7
def main():
    s = sum(a)
    ss = 0
    r = 0
    for nn in range(n):
        ss += a[nn]
        r += a[nn] * (s - ss)
    print(r % m)
    return

main()

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input(''))
adl = input('')

a = list(map(int,adl.split(' ')))

number = 0

mod0 = 1000000000
mod1 = 7

amari = 0



for i in range(n):
    aa = 0
    for e in range(n-i-1):
        j = i+e+1
        if i != j:
            aa = aa + a[j]
    number = number + (a[i] * aa)
amari0 = number % mod0
amari1 = number % mod1
amari = amari0 + amari1
print(amari)


Failing test case input:
4
3646424 4102 176 11813

Expected output:
725866144


Actual output:
725866551


Fixed submission (verdict: Accepted):
n = int(input(''))
adl = input('')

a = list(map(int,adl.split(' ')))

number = 0

mod = 1000000007

amari = 0

all_a = 0

for i in range(n):
    all_a = all_a + a[i]

for i in range(n):
    all_a = all_a - a[i]
    number = number + (a[i] * all_a)
    number = number % mod
amari = number % mod
print(amari)
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))


def findProductSum(A, n): 
      
    
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
  
    
    
    array_sum_square = array_sum * array_sum 
  
    
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    
    
    return (array_sum_square - 
            individual_square_sum) / 2

print(int(findProductSum(a, n))) 

Failing test case input:
4
6160134 101747 143968 75715

Expected output:
304480850


Actual output:
2013304494941


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

def findProductSum(A, n): 
      
    
    array_sum = 0
    for i in range(0, n, 1): 
        array_sum = array_sum + A[i] 
  
    
    
    array_sum_square = array_sum * array_sum 
  
    
    individual_square_sum = 0
    for i in range(0, n, 1): 
        individual_square_sum += A[i] * A[i] 
  
    
    
    return (array_sum_square - 
            individual_square_sum)
mod = 10**9+7
  
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
  
print(modinv(2)*int(findProductSum(a, n))%mod)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
arr = list(map(int,input().split()))
su = sum(arr)
c = 0
for item in arr:
  c+= item*item
print((su**2 - c)%(10**9 + 7))

Failing test case input:
4
2519048 2493 176 11813

Expected output:
512820549


Actual output:
25641091


Fixed submission (verdict: Accepted):
n = int(input())
arr = list(map(int,input().split()))
su = sum(arr)
c = 0
for item in arr:
  c+= item*item
print(((su**2 - c)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = [int(e) for e in input().split()]

S = [0]
sum =0
for i in range(0, N):
    S.append(S[i] + A[i])
for i in range(N):
    sum = sum + (S[i+1]-A[i]) * A[i]
print(sum)
 

Failing test case input:
4
141421356 15438004 10545868 176612

Expected output:
309796111


Actual output:
3867047336865440


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(e) for e in input().split()]

S = [0]
sum =0
for i in range(0, N):
    S.append(S[i] + A[i])
for i in range(N):
    sum = sum + (S[i+1]-A[i]) * A[i]
print(sum%1000000007)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

sum = 0
for i in a:
    sum += i

sum = sum * sum

for j in a:
    sum = (sum - j*j) % 1000000007

print(int(sum/2))

Failing test case input:
4
1837207 84292 9743 6344

Expected output:
834815154


Actual output:
334815150


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

sum = 0
for i in a:
    sum += i

sum = sum * sum

for j in a:
    sum = sum - j*j

sum = (sum 
print(sum)
Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
L=list(map(int,input().split()))
s=0
t=0
p=10**9+7
x=5*10**4+4
for i in range(0,n):
  s=(s+L[i])%p
  t=(t+L[i]*L[i])%p
ans=(x*(s*s-t))%p
print(ans)


Failing test case input:
4
141421356 15438004 10545868 176612

Expected output:
309796111


Actual output:
89252014


Fixed submission (verdict: Accepted):
n=int(input())
L=list(map(int,input().split()))
s=0
t=0
p=10**9+7
x=5*10**8+4
for i in range(0,n):
	s=(s+L[i])%p
	t=(t+L[i]*L[i])%p

ans=x*(pow(s,2,p)-t)

print(ans%p)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
total = sum(A)
ans = 0
for a in A:
    ans += (total-a)*a
    ans = ans % mod

ans = ans 
print(ans)

Failing test case input:
4
2519048 3416 189 862

Expected output:
256340473


Actual output:
512680946


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
total = sum(A)
ans = (sum(list(map(lambda a: (total-a)*a, A))) 
print(ans)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

A = sum(a)
A *= A
B = 0
for ai in a:
    B += ai * ai
print((A - B)/ 2 % 1000000007)

Failing test case input:
4
4932847 3416 189 862

Expected output:
38780529


Actual output:
38780529.0


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

M = 1000000007
A = sum(a)
A *= A
B = 0
for ai in a:
    B += ai * ai
print(int((A - B)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

import collections
from functools import lru_cache
import bisect

INF = float("inf")
ZERO = 0
ONE = 1


def read():
    return input().strip()


def readInt():
    return int(input().strip())


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


def solve(N, arr):
    s = sum(arr)
    ans = 0
    MOD = 10**9 + 7

    for num in arr:
        ans = (ans + (s-num)*num) % MOD

    return (ans) % MOD 


N = readInt()
arr = readList()

print(solve(N, arr))


Failing test case input:
4
1069110 84292 143968 7257

Expected output:
585411491


Actual output:
170822975


Fixed submission (verdict: Accepted):

import collections
from functools import lru_cache
import bisect

INF = float("inf")
ZERO = 0
ONE = 1


def read():
    return input().strip()


def readInt():
    return int(input().strip())


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


def solve(N, arr):
    ans = 0
    MOD = 10**9 + 7
    prefixSums = [0]

    for num in arr:
        prefixSums.append(prefixSums[-1] + num)

    for i, num in enumerate(arr):
        ans = (ans + num * (prefixSums[-1] - prefixSums[i+1])) % MOD

    return ans % MOD


N = readInt()
arr = readList()

print(solve(N, arr))
Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())

A = list(map(lambda x: int(x), input().split(' ')))

res = (sum(A)**2 - sum(list(map(lambda x: x**2, A)))) % (10**9 + 7) / 2

print(int(res))

Failing test case input:
4
8519677 230 75 33

Expected output:
879678127


Actual output:
379678123


Fixed submission (verdict: Accepted):
N = int(input())

A = list(map(lambda x: int(x), input().split(' ')))

res = ((sum(A)**2 - sum(list(map(lambda x: x**2, A)))) 

print(int(res))

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7
s = 0

for i in a:
    s += i
    s %= mod

s = (s * s) % mod
for i in a:
    s -= i*i
    s %= mod

s = s

print(s%mod)

Failing test case input:
4
2519048 2493 176 11813

Expected output:
512820549


Actual output:
25641091


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

mod = 10**9+7
s = 0

for i in a:
    s += i
    s %= mod

s = (s * s) % mod
for i in a:
    s -= i*i
    s %= mod

s = s*(5*(10**8)+4)

print(s%mod)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7
s = 0

for i in a:
    s += i
    s %= mod

s = (s * s) % mod
for i in a:
    s -= i*i
    s %= mod

s = s

print(s)

Failing test case input:
4
4602446 4102 176 11813

Expected output:
109216034


Actual output:
218432068


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

mod = 10**9+7
s = 0

for i in a:
    s += i
    s %= mod

s = (s * s) % mod
for i in a:
    s -= i*i
    s %= mod

s = s*(5*(10**8)+4)

print(s%mod)

Problem: p02572
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

mod = 10**9+7
sum_a = sum(a)%mod
sum_a2 = sum_a**2%mod

for i in range(n):
    sum_a2 -= (a[i]**2)
    sum_a2 %= mod
    
ans = sum_a2

print(ans)

Failing test case input:
4
2519048 3416 189 985

Expected output:
566626792


Actual output:
133253577


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
 
mod = 10**9+7
sum_a = sum(a)%mod
sum_a2 = sum_a**2%mod
 
for i in range(n):
    sum_a2 -= (a[i]**2)%mod
    sum_a2 %= mod
    
if sum_a2%2 == 0:
    ans = sum_a2
else:
    ans = ((sum_a2+mod)

print(ans)

Problem: p02572
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
count = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
sum = 0

for i in range(len(a)-1):
  for j in range(i+1, len(a)):
    temp = a[i] * a[j]
    sum += temp

answer = sum % mod
print(sum)


  

Failing test case input:
4
141421356 2224125 5164610 29158

Expected output:
658249038


Actual output:
1060750665674288


Fixed submission (verdict: Accepted):
count = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
sum = sum(a)

for i in range(count):
  sum = sum - a[i]
  ans += sum * a[i]
  
answer = ans % mod
print(answer)
Problem: p03063
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(N, S):
    print(S)
    ans = [S.count('.')]
    for i in range(N):
        temp = ans[-1]
        temp += -1 if S[i] == '.' else 1
        ans.append(temp)
    return ans




N = int(input())
S = input()
print(min(solve(N, S)))

Failing test case input:
3
#.#

Expected output:
1

Actual output:
#.#
1


Fixed submission (verdict: Accepted):
def solve(N, S):
    ans = [S.count('.')]
    for i in range(N):
        temp = ans[-1]
        temp += -1 if S[i] == '.' else 1
        ans.append(temp)
    return ans




N = int(input())
S = str(input())
print(min(solve(N, S)))

Problem: p03063
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S =(list(input()))
newS=[]
for i in S:
    if i == ".":
        newS.append(0)
    else:
        newS.append(1)

countW=newS.count(0)
countB=newS.count(1)
ans=min(countW,countB)
countB=0
for s in newS:
    if s ==1:
        
        countB+=1
    else:
      countW-=1
      
        
    ans=min(ans,countB+countW)
    print(countB,countW)

print(ans)

Failing test case input:
3
#.#

Expected output:
1

Actual output:
1 1
1 0
2 0
1


Fixed submission (verdict: Accepted):
N = int(input())
S =(list(input()))
newS=[]
for i in S:
    if i == ".":
        newS.append(0)
    else:
        newS.append(1)

countW=newS.count(0)
countB=newS.count(1)
ans=min(countW,countB)
countB=0
for s in newS:
    if s ==1:
        
        countB+=1
    else:
      countW-=1
      
        
    ans=min(ans,countB+countW)
    

print(ans)

Problem: p03063
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


n = int(input())
line = input()

w = 0
for i in range(n):
    if line[i] == ".":
        w += 1
b = n-w

w_coutner = 0
b_counter = 0
ans = n
for i in range(n):
    if line[i] == ".":
        w_coutner += 1
    b_counter = i+1 - w_coutner
    wtob = b_counter
    btow = w - w_coutner
    ans_i = wtob + btow
    print(i,ans_i)
    ans = min(ans,ans_i)

print(ans)


Failing test case input:
3
#.#

Expected output:
1

Actual output:
0 2
1 1
2 2
1


Fixed submission (verdict: Accepted):


n = int(input())
line = input()

w = 0
for i in range(n):
    if line[i] == ".":
        w += 1
b = n-w

w_coutner = 0
b_counter = 0
ans = n
for i in range(n):
    if line[i] == ".":
        w_coutner += 1
    b_counter = i+1 - w_coutner
    wtob = b_counter
    btow = w - w_coutner
    ans_i = wtob + btow
    
    ans = min(ans,ans_i)

ans = min(w,b,ans)

print(ans)

Problem: p03063
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()

best = n
curr = 0
nblack = 0

for ch in s:
  if ch == '.':
    curr = min(nblack, 1 + curr)
  else:
    nblack += 1
  best = min(best, curr)

print(best)


Failing test case input:
3
#.#

Expected output:
1

Actual output:
0


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

curr = 0
nblack = 0

for ch in s:
  if ch == '.':
    curr = min(nblack, 1 + curr)
  else:
    nblack += 1

print(curr)
Problem: p03063
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S =(list(input()))
newS=[]
for i in S:
    if i == ".":
        newS.append(0)
    else:
        newS.append(1)
before = 0
count = 0
finalS =[]
for i in newS:
    flag = i - before
    if flag < 0:
        finalS.append(1)
        count = count +1
        before = 1
    else:
        finalS.append(i)
        before = i



Failing test case input:
3
#.#

Expected output:
1

Actual output:

Fixed submission (verdict: Accepted):
N = int(input())
S =(list(input()))
newS=[]
for i in S:
    if i == ".":
        newS.append(0)
    else:
        newS.append(1)

countW=newS.count(0)
countB=newS.count(1)
ans=min(countW,countB)
countB=0
for s in newS:
    if s ==1:
        
        countB+=1
    else:
      countW-=1
      
        
    ans=min(ans,countB+countW)
    

print(ans)
Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):





import sys

def input_single_line():
    
    return input()

def input_two_line():
    
    sys.stdin.readline()
    target = sys.stdin.readline()
    target = target.rstrip("\n")
    target = target.split(" ")

    return target


def search_lovers(target_list: list) -> None:
    
    lovers = []
    for i in target_list:
        if target_list[i-1] == i-1:
            lovers.append(i-1)

    print(len(lovers))


if __name__ == "__main__":
    import doctest
    doctest.testmod()

    target = input_two_line()



Failing test case input:
5
4 4 5 1 1

Expected output:
1


Actual output:

Fixed submission (verdict: Accepted):





import sys

def input_single_line():
    
    return input()

def input_two_line():
    
    sys.stdin.readline()
    target = sys.stdin.readline()
    target = target.rstrip("\n")
    target = target.split(" ")

    return target


def search_lovers(target_list: list) -> None:
    
    target_list = [int(i) - 1 for i in target_list]
    lovers = []
    ans = 0
    for i, n in enumerate(target_list):
        if target_list[n] == i:
            ans = ans + 1

    print(int(ans/2))


if __name__ == "__main__":
    import doctest
    doctest.testmod()

    target = input_two_line()

    search_lovers(target)

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
from collections import defaultdict
d = defaultdict(int)
for i, a in enumerate(A):
    t = tuple(sorted([i, a]))
    d[t] += 1
    if d[t] == 2:
        ans += 1
print(ans)


Failing test case input:
5
2 1 5 5 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
from collections import defaultdict
d = defaultdict(int)
for i, a in enumerate(A):
    t = tuple(sorted([i+1, a]))
    d[t] += 1
    if d[t] == 2:
        ans += 1
print(ans)

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
*a, = map(int, input().split())
ans = 0

for i in range(N):
	if a[a[i] - 1] in a[i + 1:] and i == a.index(a[i]):
		ans += 1
print(ans)


Failing test case input:
5
5 5 1 0 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    j = a[i] - 1
    if i < j and a[j] - 1 == i:
        ans += 1
print(ans)

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = [int(i) for i in input().split()]

friends = 0
for i in range(len(a)):
    if a[i] == -1:
        continue
    if a[a[i] - 1] == (i+1):
        friends += 1
        a[i] = -1
        a[a[i] - 1] = -1

print(int(friends))


Failing test case input:
5
5 4 5 2 1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
a = [int(i) for i in input().split()]

friends = 0
for i in range(0,len(a)):
    if a[i] == -1 or a[i] == -2:
        continue
    if a[a[i] - 1] == (i+1) :
        friends += 1
        a[ (a[i] - 1) ] = -1
        a[i] = -1
print(int(friends))
Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]-1]==i+1:
      cnt+=1
      break
    else:
      cnt=cnt
print(cnt)


Failing test case input:
5
5 4 5 2 1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]-1]==i+1:
      cnt+=1
    else:
      cnt=cnt
print(cnt

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
*a, = map(int, input().split())

count = 0
for i in range(N):
    
    if i + 1 == a[a[i]-1]:
        count += 1

print(count)

Failing test case input:
5
0 5 1 1 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
*a, = map(int, input().split())

count = 0
for i in range(N):
    
    if i + 1 == a[a[i]-1]:
        count += 1

print(count

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
jk =0
le = list(map(int,input().split()))

le = [0] + le
for i in range(N):
    print(le[le[i]])
    if le[le[i]] == i:
        jk += 1

print(le[le[i]])


Failing test case input:
5
5 3 5 5 2

Expected output:
0


Actual output:
0
2
5
2
2
2


Fixed submission (verdict: Accepted):
N = int(input())
jk =0
le = list(map(int,input().split()))

le = [0] + le
for i in range(N):
    if le[le[i]] == i:
        jk += 1

print(jk

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

like = {}
ans = 0

for i, r in enumerate(a):
    like[i] = r
    if like.get(r) == i:
        ans += 1

print(ans)


Failing test case input:
5
4 0 5 1 1

Expected output:
1


Actual output:
0


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

like = {}
ans = 0

for i, r in enumerate(a):
    like[i+1] = r
    if r in like and like[r] == i+1:
        ans += 1

print(ans)

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solution():
    size = int(input())
    rabbit_list = input().split()
    rabbits = [int(x) for x in rabbits_input]
    count = 0
    for i in range(size):
        if (rabbits[i] - 1) > i and (rabbits[rabbits[i]-1] - 1) == i:
            count += 1
    print(count)

Failing test case input:
5
5 5 2 1 1

Expected output:
1


Actual output:

Fixed submission (verdict: Accepted):
size = int(input())
rabbits = list(map(int, input().split()))
count = 0
for i in range(size):
    if (rabbits[i] - 1) > i and (rabbits[rabbits[i]-1] - 1) == i:
        count += 1
print(count)

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(0, n-1, 2):
	if a[i] < a[i+1] or a[i] > a[i+1]:
		count += 1

print(count)


Failing test case input:
5
5 3 5 2 0

Expected output:
0


Actual output:
2


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

count = 0
for i in range(0, n):
	if a[a[i]-1]-1 == i:
		count += 1

print(int(count/2))
Problem: p03993
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]

print(a)



count = 0


for i in range(n + 1):
    if(i == a[a[i - 1] - 1]):
        count += 1

print(count/2)



Failing test case input:
5
5 3 4 2 4

Expected output:
0


Actual output:
[5, 3, 4, 2, 4]
0.0


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split()]





count = 0


for i in range(n + 1):
    if(i == a[a[i - 1] - 1]):
        count += 1


print(int(count/2))

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
*a, = map(int, input().split())
ans = 0

for i in range(N):
	if i == a.index(a[i]):
		ans += 1
print(ans)


Failing test case input:
5
3 3 1 0 1

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
    j = a[i] - 1
    if i < j and a[j] - 1 == i:
        ans += 1
print(ans)

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
arr = [sorted([i, j]) for i, j in enumerate(a,1)]
counter = 0
for i in range(n):
    if i == n-1:
        if arr[-1][0] == arr[0][0] and arr[-1][1] == arr[-1][1]:
            counter +=1
    elif arr[i][0] == arr[i+1][0] and arr[i][1] == arr[i+1][1] :
        counter +=1
print(counter)

Failing test case input:
5
2 1 5 5 1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
arr = [sorted([i, j]) for i, j in enumerate(a,1)]
arr = sorted(arr)
counter = 0
for i in range(n-1):
    if arr[i][0] == arr[i+1][0] and arr[i][1] == arr[i+1][1] :
        counter +=1
print(counter)

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[a[i]-1]==i+1:ans+=1
print(ans)


Failing test case input:
5
5 3 5 0 1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[a[i]-1]==i+1:ans+=1
print(ans

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
val = []
s = set()
counter = 0
for i,j in enumerate(a,1):
    val.append(int(i+j))
for i in range(n):
    if val[i] not in s:
        s.add(val[i])
    else:
        counter +=1
print(counter)

Failing test case input:
5
3 5 5 0 1

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
arr = [sorted([i, j]) for i, j in enumerate(a,1)]
arr = sorted(arr)
counter = 0
for i in range(n-1):
    if arr[i][0] == arr[i+1][0] and arr[i][1] == arr[i+1][1] :
        counter +=1
print(counter)
Problem: p03993
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
a = list(map(int,input().split()))
count=0
for i in range(N):
    if i == (a[a[i]-1]-1):
        print(a[a[i]-1]-1)
        count += 1

print(int(count/2))

Failing test case input:
5
-1 3 2 2 4

Expected output:
1


Actual output:
1
2
1


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,input().split()))
count=0
for i in range(N):
    if i == (a[a[i]-1]-1):
        count += 1

print(int(count/2))

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
rs = list(map(int, input().split()))
numpair = 0
for i in range(N):
	if (i+1) == rs[rs[i] - 1]:
		numpair+=1
print(numpair/2)

Failing test case input:
5
0 5 5 0 2

Expected output:
1


Actual output:
1.0


Fixed submission (verdict: Accepted):
N = int(input())
rs = list(map(int, input().split()))
numpair = 0
for i in range(N):
	if (i+1) == rs[rs[i] - 1]:
		numpair+=1
print(numpair

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
used = [False for i in range(N)]
ans = 0
for i in range(len(A)):
    if i + 1 == A[A[i] - 1] and not used[i] and not used[A[i] - 1]:
        ans += 1
        used[i] = True
        used[A[A[i] - 1]] = True
print(ans)

Failing test case input:
5
5 4 5 2 1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
used = [False for i in range(N)]
ans = 0
for i in range(len(A)):
    if i + 1 == A[A[i] - 1] and not used[i] and not used[A[i] - 1]:
        ans += 1
        used[i] = True
        used[A[i] - 1] = True
print(ans)

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):





import sys

def input_single_line():
    
    return input()

def input_two_line():
    
    sys.stdin.readline()
    target = sys.stdin.readline()
    target = target.rstrip("\n")
    target = target.split(" ")

    return target


def search_lovers(target_list: list) -> None:
    
    lovers = []
    for i in target_list:
        pos = int(i)
        if target_list[pos-1] == pos-1:
            lovers.append(pos-1)

    print(len(lovers))


if __name__ == "__main__":
    import doctest
    doctest.testmod()

    target = input_two_line()

    search_lovers(target)



Failing test case input:
5
0 5 5 0 2

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):





import sys

def input_single_line():
    
    return input()

def input_two_line():
    
    sys.stdin.readline()
    target = sys.stdin.readline()
    target = target.rstrip("\n")
    target = target.split(" ")

    return target


def search_lovers(target_list: list) -> None:
    
    target_list = [int(i) - 1 for i in target_list]
    lovers = []
    ans = 0
    for i, n in enumerate(target_list):
        if target_list[n] == i:
            ans = ans + 1

    print(int(ans/2))


if __name__ == "__main__":
    import doctest
    doctest.testmod()

    target = input_two_line()

    search_lovers(target)
Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
pair = set()
for i in range(N):
    if a[a[i]-1] == i+1:
        tmp = a[i] + i + 1
        pair.add(tmp)
print(len(pair))


Failing test case input:
5
5 4 5 2 1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
pair = set()
for i in range(N):
    if a[a[i]-1] == i+1:
        pair.add((min(a[a[i]-1], a[i]), max(a[a[i]-1], a[i])))
print(len(pair))

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for i in range(N):
    if A[A[i]-1] == i:
        ans += 1
print(ans)

Failing test case input:
4
4 1 4 3

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
for i in range(N):
    if A[A[i]-1] == i+1:
        ans += 1
print(ans

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())
a = list(map(int,input().split()))
print(a)
ans=0
for i, v in enumerate(a):
    if v != None:
        if a[v-1] == i+1:
            ans+=1
            a[v-1] = None
print(ans)

Failing test case input:
5
4 0 5 1 1

Expected output:
1


Actual output:
[4, 0, 5, 1, 1]
1


Fixed submission (verdict: Accepted):

N = int(input())
a = list(map(int,input().split()))
ans=0
for i, v in enumerate(a):
    if v != None:
        if a[v-1] == i+1:
            ans+=1
            a[v-1] = None
print(ans)

Problem: p03993
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a_l = list(map(int, input().split()))
ans = 0
for i,j in enumerate(a_l):
    if i == i:
        ans+= 1
print(int(ans/2))

Failing test case input:
5
0 5 1 1 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a_l = list(map(int, input().split()))

ans = 0
for i,j in enumerate(a_l):
    if i+1 == a_l[j-1]:
        ans+= 1
print(int(ans/2))

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
n = list(map(int,input().split()))
ans  = 0
for i in range(N):
    if n[n[i]-1] == i:
        ans += 1 
print(ans / 2)

Failing test case input:
5
4 0 5 1 1

Expected output:
1


Actual output:
1.0


Fixed submission (verdict: Accepted):
N = int(input())
n = list(map(int,input().split()))
ans  = 0
for i in range(N):
    if n[n[i]-1] == i+1:
        ans += 1 
print(ans

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=[0]+list(map(int,input().split()))
ans=0
for i in range(1,n+1):
  if a[a[i]]==i:
    ans+=1
print(ans)

Failing test case input:
5
5 1 5 5 1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
a=[0]+list(map(int,input().split()))
ans=0
for i in range(1,n+1):
  if a[a[i]]==i:
    ans+=1
print(ans
Problem: p03993
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = list(map(int,input().split()))
ans = 0
for i in range(n):
    if s[s[i]-1] == i+1:
        ans += 1
print(ans)

Failing test case input:
5
5 0 5 1 1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
s = list(map(int,input().split()))
ans = 0
for i in range(n):
    if s[s[i]-1] == i+1:
        ans += 1
print(ans

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
arr = [sorted([i, j]) for i, j in enumerate(a,1)]
counter = 0
for i in range(n):
    if i == n-1:
        if arr[-1][0] == arr[0][0] and arr[-1][1] == arr[0][1]:
            counter +=1
    elif arr[i][0] == arr[i+1][0] and arr[i][1] == arr[i+1][1] :
        counter +=1
print(counter)

Failing test case input:
5
5 4 5 2 1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
arr = [sorted([i, j]) for i, j in enumerate(a,1)]
arr = sorted(arr)
counter = 0
for i in range(n-1):
    if arr[i][0] == arr[i+1][0] and arr[i][1] == arr[i+1][1] :
        counter +=1
print(counter)

Problem: p03993
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]



count = 0


for i in range(n - 1):
    if(i == a[a[i - 1] - 1]):
        count += 1

print(count)



Failing test case input:
5
2 1 5 5 1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split()]





count = 0


for i in range(n + 1):
    if(i == a[a[i - 1] - 1]):
        count += 1


print(int(count/2))

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in a:
  if a[i - 1] == i + 1:
    ans += 1
print(ans)
  

Failing test case input:
5
5 3 4 2 2

Expected output:
0


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
ans = 0
for itr, val in enumerate(a):
  if a[val - 1] == itr + 1:
    ans += 1
print(ans

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  for j in range(n):
    if a[i]==j+1 and a[j]==i+1:
      cnt+=1
    else:
      cnt=cnt
print((cnt-n)/2)
      


Failing test case input:
4
3 0 4 0

Expected output:
0


Actual output:
-2.0


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]-1]==i+1:
      cnt+=1
    else:
      cnt=cnt
print(cnt
Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]-1]==i+1:
      cnt+=1
    else:
      cnt=cnt
print(cnt)


Failing test case input:
4
3 1 4 3

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[a[i]-1]==i+1:
      cnt+=1
    else:
      cnt=cnt
print(cnt

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())

usa = list(map(int, input().split()))
count = 0
for i, j in enumerate(usa):
    if(usa[j-1]-1 == i):
        count+=1
    if(count >= N/2):
        break

print (count)


Failing test case input:
5
5 5 5 -2 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
usa = list(map(int, input().split()))
flag = [0 for x in range(N)]
count = 0
for i, ai in enumerate(usa):
    if(flag[i]):
        continue
    if(usa[ai-1]-1 == i):
        count+=1
        flag[ai - 1] = 1

print (count)

Problem: p03993
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
  if a[a[i]-1] == i+1:
    ans += 1
print(ans)

Failing test case input:
5
5 5 5 -1 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(N):
  if a[a[i]-1] == i+1:
    ans += 1
print(ans

Problem: p03993
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
arr = [sorted([i, j]) for i, j in enumerate(a, 1)]
counter = 0

for i in range(n-1):
    if arr[i][0] == arr[i+1][0] and arr[i][1] == arr[i+1][1] :
        counter +=1
print(counter)

Failing test case input:
5
5 5 2 1 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
arr = [sorted([i, j]) for i, j in enumerate(a,1)]
arr = sorted(arr)
counter = 0
for i in range(n-1):
    if arr[i][0] == arr[i+1][0] and arr[i][1] == arr[i+1][1] :
        counter +=1
print(counter)

Problem: p03993
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))

ans = 0
cnt = 0

for a in A:
    cnt += 1
    if A[a-1] == cnt:
        ans += 1

print(ans/2)


Failing test case input:
5
5 3 4 2 1

Expected output:
1


Actual output:
1.0


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))

ans = 0
cnt = 0

for a in A:
    cnt += 1
    if A[a-1] == cnt:
        ans += 1

print(ans