Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np


N = int(input())
abc = []
for n in range(N):
    abc.append(list(map(int, input().split())))

# initialize
dp = np.zeros((N+1, 3))

# dp    
for i in range(N+1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            try:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])
            except:
                pass

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


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

dp = [float("inf")] * N
dp[0] = 0
for i in range(N+1):
    try:
        dp[i+1] = min(dp[i+1], dp[i]+abs(H[i+1]-H[i]))
        dp[i+1] = min(dp[i+1], dp[i-1]+abs(H[i+1]-H[i-1]))
    except:
        continue

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
num = list(map(int, input().split()))
H = list(map(int, input().split()))
N = num[0]
K = num[1]

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    try:
        for j in range(K):
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]))
    except:
        continue

print(dp[-1])

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

dp = [float("inf")] * N
dp[0] = 0
for i in range(N+1):
    try:
        dp[i+1] = min(dp[i+1], dp[i]+abs(H[i+1]-H[i]))
        dp[i+1] = min(dp[i+1], dp[i-1]+abs(H[i+1]-H[i-1]))
    except:
        continue

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
num = list(map(int, input().split()))
H = list(map(int, input().split()))
N = num[0]
K = num[1]

dp = [1000000000] * N
dp[0] = 0
for i in range(N):
    try:
        for j in range(K):
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]))
    except:
        continue

print(dp[-1])

Fixed submission:
num = list(map(int, input().split()))
H = list(map(int, input().split()))
N = num[0]
K = num[1]

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    try:
        for j in range(K):
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]))
    except:
        continue

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
num = list(map(int, input().split()))
H = list(map(int, input().split()))
N = num[0]
K = num[1]

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    try:
        for j in range(K):
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]))
    except:
        continue

print(dp[-1])

Fixed submission:
num = list(map(int, input().split()))
H = list(map(int, input().split()))
N = num[0]
K = num[1]

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    try:
        for j in range(K):
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]))
    except:
        continue

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import numpy as np


N = int(input())
abc = []
for n in range(N):
    abc.append(list(map(int, input().split())))

# initialize
dp = np.zeros((N+1, 3))

# dp    
for i in range(N+1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            try:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])
            except:
                pass

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


Fixed submission:
N = int(input())
abc = []
for n in range(N):
    abc.append(list(map(int, input().split())))

# initialize
dp = [[-float("inf")]*3 for i in range(N+1)]
for i in range(3):
    dp[0][i] = 0

# dp    
for i in range(N+1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            try:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])
            except:
                pass

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

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


N = int(input())
abc = []
for n in range(N):
    abc.append(list(map(int, input().split())))

# initialize
dp = np.zeros((N+1, 3))

# dp    
for i in range(N+1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            try:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])
            except:
                pass

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


Fixed submission:
N = int(input())
abc = []
for n in range(N):
    abc.append(list(map(int, input().split())))

# initialize
dp = [[-float("inf")]*3 for i in range(N+1)]
for i in range(3):
    dp[0][i] = 0

# dp    
for i in range(N+1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            try:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])
            except:
                pass

print(int(max(dp[-1])))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
while True:
    for i in range(N):
        if A[i]%2==1:
            break
        A[i] = A[i]//2
    else:
        cnt += 1
        continue
    break

Fixed submission:
vec = str(input())
cnt = 0
for s in vec:
    if s=="1":
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
N = input()

print(1000-N%1000)

Fixed submission:
N = int(input())
n=N%1000
if(n>0):
    print(1000-n)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
N = input()

print(N%1000)


Fixed submission:
N = int(input())
n=N%1000
if(n>0):
    print(1000-n)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
int main() {
	char s[3]
  	scanf("%s",s)
  	if(s[0]=="7" ||s[1]=="7"||s[2]=="7"){
    	printf("Yes")
    }
  	else{
    	printf("No")
    }
}

Fixed submission:
n = input()
if "7" in n:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c = (int(i) for i in input().split())
N = list(map(int, input().split())) 
M = list(map(int, input().split())) 
n = 0
m = 0
e = 0
for i in range(a+b):
  if N[n] < M[m] and n < a:
    c -= N[n]
    e += 1
    print(c)
    n += 1
  elif N[n] > M[m] and m < a:
    c -= M[m]
    e += 1
    m += 1
    print(c)

  if c < 0:
    e -= 1
    break

print(e)

Fixed submission:
a = int(input())
b = a + a**2 + a**3
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
result = 1
for i in range(N):
  result = result * A[i]
if result > 1000000000000000000:
  print(-1)
else:
  print(result)
  

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

def judge(A):
  for i in range(len(A)):
    if A[i] == 0:
      print(0)
      return
  result = 1
  for i in range(N):
    result = result * A[i]
    if result > 1000000000000000000:
      print(-1)
      return
  if result <= 1000000000000000000:
    print(result)
    return
  
judge(A)
Buggy python submission (verdict: Runtime Error):
length, width = map(input().split())
print((length-1)*(width-1))

Fixed submission:
length, width = map(int, input().split())
print((length-1)*(width-1))
Buggy python submission (verdict: Runtime Error):
a, b, c = input().split(,)
print(a, b, c)

Fixed submission:
a, b, c = input().split(",")
print(a, b, c)

Buggy python submission (verdict: Runtime Error):
a, b, c = map(input().split(,))
print(a, b, c)

Fixed submission:
a, b, c = input().split(",")
print(a, b, c)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
Q = int(input())
ans = []
for q in range(Q):
    b, c = map(int, input().split())
    a = np.where(a==b, c, a)
    ans.append(sum(a))
for q in range(Q):
    print(ans[q])


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MX = 100005
cnt = [0]*MX
for i in a:
    cnt[i] += 1
tot = 0
for i in range(1, MX):
    tot += cnt[i] * i
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    tot += (c - b) * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(tot)

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())
ans = []
for q in range(Q):
    b, c = map(int, input().split())
    a = np.where(a==b, c, a)
    ans.append(sum(a))
for q in range(Q):
    print(ans[q])


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
MX = 100005
cnt = [0]*MX
for i in a:
    cnt[i] += 1
tot = 0
for i in range(1, MX):
    tot += cnt[i] * i
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    tot += (c - b) * cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(tot)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
M = 100000
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] != 0:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = max(A)+1
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] != 0:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)

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


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = max(A)+1
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] != 0:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
M = 100005
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] == 1:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = max(A)+1
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] != 0:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
import sympy
from collections import Counter
ans = 0
for i in range(n):
    if len(set(a) & set(sympy.divisors(a[i])))-1 == 0:
        ans += 1
cnt = Counter(a)
for i in cnt.values():
    if i > 1:
        ans -= i

print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = max(A)+1
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] != 0:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
import sympy
from collections import Counter
ans = 0
for i in range(n):
    if len(set(a) & set(sympy.divisors(a[i])))-1 == 0:
        ans += 1
for i in Counter(a).values():
    if i > 1:
        ans -= i

print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
M = max(A)+1
cnt = [0]*M
ans = 0
for a in A:
    if cnt[a] != 0:
        cnt[a] = 2
    else:
        for i in range(a, M, a):
            cnt[i] += 1
for a in A:
    if cnt[a] == 1:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    ans *= a[i]
if ans > 10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
a, b = map(float, input().split())
print(fractions.floor(a*b))


Fixed submission:
from decimal import Decimal
a, b = map(Decimal, input().split())
print(int(a*b))
Buggy python submission (verdict: Runtime Error):
import pandas as pd
n = int(input())
s = [input() for _ in range(n)]
x = set(s)
print(len(x))


Fixed submission:
n = int(input())
s = [input() for _ in range(n)]
x = set(s)
print(len(x))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
mod = 2019
cnt = [0] * mod
x = 1
cnt[0] = 1
total = 0
for s in s:
    total += int(s) * x
    total %= mod
    cnt[total] += 1
    x *= 10


ans = sum(i*(i-1)//2 for i in cnt)
print(ans)


Fixed submission:
s = input()[::-1]
m = 2019
ans = 0
x = 1
tot = 0
cnt = [0] * m
cnt[0] = 1
for s in s:
    tot += int(s) * x
    tot %= m
    #ans += cnt[tot]
    x *= 10
    x %= m
    cnt[tot] += 1

print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
m = 2019
ans = 0
x = 1
tot = 0
cnt = [0] * m
for s in s:
    cnt[tot] += 1
    tot += int(s) * x % m
    tot %= m
    ans += cnt[tot % m]
    x *= 10 % m
print(ans)


Fixed submission:
s = input()[::-1]
m = 2019
ans = 0
x = 1
tot = 0
cnt = [0] * m
cnt[0] = 1
for s in s:
    tot += int(s) * x
    tot %= m
    #ans += cnt[tot]
    x *= 10
    x %= m
    cnt[tot] += 1

print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
m = 2019
ans = 0
x = 1
tot = 0
cnt = [0] * m
for s in s:
    cnt[tot] += 1
    tot += int(s) * x
    tot %= m
    ans += cnt[tot]
    x *= 10
print(ans)


Fixed submission:
s = input()[::-1]
m = 2019
ans = 0
x = 1
tot = 0
cnt = [0] * m
cnt[0] = 1
for s in s:
    tot += int(s) * x
    tot %= m
    #ans += cnt[tot]
    x *= 10
    x %= m
    cnt[tot] += 1

print(sum(i*(i-1)//2 for i in cnt))

Buggy python submission (verdict: Runtime Error):
s = input()
num = ['2019', '4038', '6057', '8076', '10095', '12114', '14133', '16152', '18171']
ans = 0
for n in num:
    a += s.count(n)
print(ans)


Fixed submission:
s = input()[::-1]
m = 2019
ans = 0
x = 1
tot = 0
cnt = [0] * m
cnt[0] = 1
for s in s:
    tot += int(s) * x
    tot %= m
    #ans += cnt[tot]
    x *= 10
    x %= m
    cnt[tot] += 1

print(sum(i*(i-1)//2 for i in cnt))

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


Fixed submission:
s = input()[::-1]
m = 2019
ans = 0
x = 1
tot = 0
cnt = [0] * m
cnt[0] = 1
for s in s:
    tot += int(s) * x
    tot %= m
    #ans += cnt[tot]
    x *= 10
    x %= m
    cnt[tot] += 1

print(sum(i*(i-1)//2 for i in cnt))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(gcd(a, b), c)
print(ans)


Fixed submission:
from math import gcd
k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        d = gcd(a, b)
        for c in range(1, k+1):
            ans += gcd(d, c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
x = 10**9 + 7
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += math.gcd(math.gcd(a, b), c)
            ans = ans % x
print(ans)


Fixed submission:
from math import gcd
k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        d = gcd(a, b)
        for c in range(1, k+1):
            ans += gcd(d, c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += math.gcd(math.gcd(a, b), c)
print(ans)


Fixed submission:
from math import gcd
k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        d = gcd(a, b)
        for c in range(1, k+1):
            ans += gcd(d, c)
print(ans)
Buggy python submission (verdict: Runtime Error):
k = int(input())
a = [i for i in range(1, 10)]
while True:z
    if k <= len(a):
        print(a[k-1])
        exit()
    k -= len(a)
    old = []
    old, a = a, old
    for i in range(len(old)):
        for j in range(-1, 2):
            d = old[i]%10+j
            if d >= 0 and d <= 9:
                a.append(old[i]*10+d)


Fixed submission:
k = int(input())
a = [i for i in range(1, 10)]
while True:
    if k <= len(a):
        print(a[k-1])
        exit()
    k -= len(a)
    old = []
    old, a = a, old
    for i in range(len(old)):
        for j in range(-1, 2):
            d = old[i]%10+j
            if d >= 0 and d <= 9:
                a.append(old[i]*10+d)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import queue

n, x, y = map(int, input().split())
x -= 1
y -= 1
INF = 10010101010101
ans = [0]*n
def put(v, d):
    if dist[v] != INF:
        return
    dist[v] = d
    q.put(v)
for sv in range(n):
    q = queue.Queue()
    dist = [INF for _ in range(n)]
    put(sv, 0)
    while not q.empty():
        v = q.get()
        d = dist[v]
        if v-1 >= 0:
            put(v-1, d+1)
        if v+1 < n:
            put(v+1, d+1)
        if v == x:
            put(y, d+1)
        if v == y:
            put(x, d+1)
    for i in range(n):
        ans[dist[i]] += 1
for i in range(n):
    ans[i] = int(ans[i] / 2)

print(*ans[1:], sep='\n')

Fixed submission:
# -*- coding: utf-8 -*-
s = input()
x = list(s)
if x[2] == x[3]:
    if x[4] == x[5]:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
cnt = [0]*n
for i in a:
    cnt[i] += 1
total = 0
for i in cnt:
    total += i * (i-1) // 2
for i in a:
    print(total - (cnt[i] - 1)

          

Fixed submission:
n, m = list(map(int, input().split()))
def factorial(x):
    f = 1
    for i in range(1, x+1):
        f *= i
    return f
ans = 0
if n < 2 and m < 2:
    ans = 0
    print(ans)
elif n < 2:
    ans = int(factorial(m) / (factorial(2) * factorial(m - 2)))
    print(ans)
elif m < 2:
    ans = int(factorial(n) / (factorial(2) * factorial(n - 2)))
    print(ans)
else:
    ans = int(factorial(m) / (factorial(2) * factorial(m - 2)) + factorial(n) / (factorial(2) * factorial(n - 2)))
    print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
def choose2(n):
    return n * (n - 1) // 2
total = 0
for i in range(1,n+1):
    total += choose2(a.count(i))
for i in range(n):
    ans[i] = total
    ans[i] -= a.count(a[i]) - 1
print(*ans[:], sep='\n')


Fixed submission:
n, m = list(map(int, input().split()))
def factorial(x):
    f = 1
    for i in range(1, x+1):
        f *= i
    return f
ans = 0
if n < 2 and m < 2:
    ans = 0
    print(ans)
elif n < 2:
    ans = int(factorial(m) / (factorial(2) * factorial(m - 2)))
    print(ans)
elif m < 2:
    ans = int(factorial(n) / (factorial(2) * factorial(n - 2)))
    print(ans)
else:
    ans = int(factorial(m) / (factorial(2) * factorial(m - 2)) + factorial(n) / (factorial(2) * factorial(n - 2)))
    print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
ans = True
def isPalindrome(string):
    return s == s[::-1]
if not isPalindrome(s):
    ans = Flase
if not isPalindrome(s[:len(s)//2]):
    ans = False
if not isPalindrome(s[len(s)//2+1:]):
    ans = False
if ans:
    print('Yes')
else:
    print('No')


Fixed submission:
n, m = list(map(int, input().split()))
def factorial(x):
    f = 1
    for i in range(1, x+1):
        f *= i
    return f
ans = 0
if n < 2 and m < 2:
    ans = 0
    print(ans)
elif n < 2:
    ans = int(factorial(m) / (factorial(2) * factorial(m - 2)))
    print(ans)
elif m < 2:
    ans = int(factorial(n) / (factorial(2) * factorial(n - 2)))
    print(ans)
else:
    ans = int(factorial(m) / (factorial(2) * factorial(m - 2)) + factorial(n) / (factorial(2) * factorial(n - 2)))
    print(ans)
Buggy python submission (verdict: Runtime Error):
 = input()
def isPalindrome(string):
    return s == s[::-1]
if isPalindrome(s) and isPalindrome(s[:len(s)//2]) and isPalindrome(s[len(s)//2+1:]):
    print('Yes')
else:
    print('No')


Fixed submission:
s = input()
n = len(s)
a = s[:n//2]
b = s[n//2+1:]
def circular(string):
    return string == "".join(reversed(list(string)))

if circular(s) and circular(a) and circular(b):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
cnt = [0]*n
for i in a:
    cnt[i] += 1
total = 0
for i in cnt:
    total += i * (i-1) // 2
for i in a:
    print(total - (cnt[i] - 1))


Fixed submission:
n = int(input())
a = [int(a)-1 for a in input().split()]
cnt = [0]*n
for i in a:
    cnt[i] += 1
total = 0
for i in cnt:
    total += i * (i-1) // 2
for i in a:
    print(total - (cnt[i] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
def choose2(n):
    return n * (n - 1) // 2
total = 0
for i in range(1,n+1):
    total += choose2(a.count(i))
for i in range(n):
    ans[i] = total
    ans[i] -= a.count(a[i]) - 1
print(*ans[:], sep='\n')


Fixed submission:
n = int(input())
a = [int(a)-1 for a in input().split()]
cnt = [0]*n
for i in a:
    cnt[i] += 1
total = 0
for i in cnt:
    total += i * (i-1) // 2
for i in a:
    print(total - (cnt[i] - 1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
for k in range(n):
    b = a[:]
    b.pop(k)
    l = len(b)
    for i in range(1,l):
        if b.count(i) >= 2:
            ans[k] += (b.count(i) * (b.count(i) - 1 )) // 2

print(*ans[:], sep='\n')


Fixed submission:
n = int(input())
a = [int(a)-1 for a in input().split()]
cnt = [0]*n
for i in a:
    cnt[i] += 1
total = 0
for i in cnt:
    total += i * (i-1) // 2
for i in a:
    print(total - (cnt[i] - 1))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))
mx = 0
mx_list = []
for i in range(N-K+1):
    if sum(p[i:i+K]) > mx:
        mx = sum(p[i:i+K])
        mx_list = p[i:i+K]
ans = 0
for i in mx_list:
    ans += (i+1)/2
print('{:.20f}'.format(ans))


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
S = [0]
for i in range(N):
    S.append(S[i] + (p[i]+1)/2)
ans = 0
for i in range(N-K+1):
    tmp = S[i+K] - S[i]
    ans = max(ans, tmp)
print('{:.20f}'.format(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(N-K+1):
    kitaichi = 0
    for j in range(i, i+K):
        kitaichi += (p[j]+1)/2
    ans = max(ans, kitaichi)
print("{:.20f}".format(ans))


Fixed submission:
N, K = map(int, input().split())
p = list(map(int, input().split()))
S = [0]
for i in range(N):
    S.append(S[i] + (p[i]+1)/2)
ans = 0
for i in range(N-K+1):
    tmp = S[i+K] - S[i]
    ans = max(ans, tmp)
print('{:.20f}'.format(ans))
Buggy python submission (verdict: Runtime Error):
import numpy as np
a, b = map(int, input().split())
p =np.gcd(a, b)
print(b * (a // p))


Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
p = gcd(a, b)
print(b * (a // p))

Buggy python submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
p = math.gcd(a, b)
print(b * (a // p))


Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
p = gcd(a, b)
print(b * (a // p))

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
import math
p = math.gcd(a, b)
print(b * (a // p))


Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
p = gcd(a, b)
print(b * (a // p))