Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    al=[chr(ord('A')+i) for i in range(26)]
    h,w=map(int, input().split())
    l=[list(input().split()) for i in range(h)]
    for j in range(w):
        for k in range(h):
            if l[k][j]=='snuke':
                print(al[j]+str(k+1))
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    print(s[0]+str(len(s)-2)+s[-1])
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    from itertools import accumulate

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

    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成

    # この問題は長さが1-Nの連続部分の和の最大値を出せというものなので以下の通り
    ans=10**18
    for i in range(1, N):
        snuke=B[i]
        araiguma=sum(A)-B[i]
        ans=min(ans,abs(snuke-araiguma))
    print(ans)
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    from itertools import accumulate

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

    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成

    ans=10**18
    for i in range(1, N):
        snuke=B[i]
        araiguma=B[N]-B[i]
        ans=min(ans,abs(snuke-araiguma))
    print(ans)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    a=list(input().split())
    b=[]
    for i in range(1,n+1):
        if i%2==n%2:
            b.insert(0,a[i-1])
        else:
            b.append(a[i-1])
    print(*b)
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    a=list(input().split())
    akisu=a[0::2]
    agusu=a[1::2][::-1]
    b=agusu+akisu
    if n%2==0:
        print(*b)
    else:
        print(*b[::-1])
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    b=[]
    for i in range(n):
        b.append(a[i])
        b=b[::-1]
    print(*b)
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    a=list(input().split())
    akisu=a[0::2]
    agusu=a[1::2][::-1]
    b=agusu+akisu
    if n%2==0:
        print(*b)
    else:
        print(*b[::-1])
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[int(input()) for i in range(n)]
    light=0
    cnt=0
    while True:
        if l[light]==2:
            cnt+=1
            print(cnt)
            break
        else:
            if cnt>n:
                print(-1)
                break
            else:
                light=l[light]-1
                cnt+=1
            
resolve()


Fixed submission:
def resolve():
    x,a,b=map(int, input().split())
    if b-a>=x+1:
        print('dangerous')
    elif b-a<=0:
        print('delicious')
    else:
        print('safe')
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,a,b=map(int, input().split())
    if n==1 and a==b:
        print(1)
    elif n==1 and a!=b:
        print(0)
    elif b<a:
        print(0)
    else:
        l=list(range(a,b+1))
        c=itertools.combinations_with_replacement(l,n-2)
        check=[]
        cnt=0
        for i in c:
            if sum(i) not in check:
                check.append(sum(i))
                cnt+=1
        print(cnt)
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,a,b=map(int, input().split())
    if n==1 and a==b:
        print(1)
    elif n==1 and a!=b:
        print(0)
    elif b<a:
        print(0)
    else:
        print((a+(n-1)*b)-((n-1)*a+b)+1)
resolve()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,a,b=map(int, input().split())
    if n==1 and a==b:
        print(1)
    elif n==1 and a!=b:
        print(0)
    elif b<a:
        print(0)
    else:
        import itertools
        l=list(range(a,b+1))
        c=itertools.combinations_with_replacement(l,n-2)
        check=[]
        cnt=0
        for i in c:
            if sum(i) not in check:
                check.append(sum(i))
                cnt+=1
        print(cnt)
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,a,b=map(int, input().split())
    if n==1 and a==b:
        print(1)
    elif n==1 and a!=b:
        print(0)
    elif b<a:
        print(0)
    else:
        print((a+(n-1)*b)-((n-1)*a+b)+1)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=[]
    for i in range(n):
        a,b=map(int, input().split())
        for j in range(b):
            l.append(a)
    l.sort()
    print(l[k-1])
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(n)]
    l.sort(key=lambda x:x[0])
    kosu=0
    for i in range(n):
        kosu+=l[i][1]
        if kosu>=k:
            print(l[i][0])
            break
resolve()
Buggy python submission (verdict: Runtime Error):
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    if 'N' in s and 'S' in s and 'W' in s and 'E' in s:
        ans='Yes'
    elif 'N' in s and 'S' in s and 'W' not in s and 'E' not in s:
        ans='Yes'
    elif 'N' not in s and 'S' not in s and 'W' in s and 'E' in s:
        ans='Yes'
    else:
        ans='No'
    print(ans)
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    ans='No'
    if 'N' in s and 'S' in s and 'W' in s and 'E' in s:
        ans='Yes'
    elif 'N' in s and 'S' in s and \
            'W' not in s and 'E' not in s:
        ans='Yes'
    elif 'N' not in s and 'S' not in s and\
            'W' in s and 'E' in s:
        ans='Yes'
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b=map(int, input().split())
    l=list(range(a,b+1))
    seki=1
    for i in l:
        seki=seki*i
    if seki>0:
        print('Positive')
    elif seki==0:
        print('Zero')
    else:
        print('Negative')
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b=map(int, input().split())
    if a>0:
        print('Positive')
    elif a==0 or b==0:
        print('Zero')
    elif a<0 and b>0:
        print('Zero')
    elif b<0 and (b-a)%2==0:
        print('Negative')
    else:
        print('Positive')
resolve()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b=map(int, input().split())
    l=list(range(a,b+1))
    seki=1
    for i in l:
        seki*=i
    if seki>0:
        print('Positive')
    elif seki==0:
        print('Zero')
    else:
        print('Negative')
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b=map(int, input().split())
    if a>0:
        print('Positive')
    elif a==0 or b==0:
        print('Zero')
    elif a<0 and b>0:
        print('Zero')
    elif b<0 and (b-a)%2==0:
        print('Negative')
    else:
        print('Positive')
resolve()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b=map(int, input().split())
    l=list(range(a,b+1))
    seki=1
    for i in l:
        seki*=i
    if seki>0:
        print('Positive')
    elif seki==0:
        print('Zero')
    else:
        print('Negative')
resolve()

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b=map(int, input().split())
    if a>0:
        print('Positive')
    elif a==0 or b==0:
        print('Zero')
    elif a<0 and b>0:
        print('Zero')
    elif b<0 and (b-a)%2==0:
        print('Negative')
    else:
        print('Positive')
resolve()
Buggy python submission (verdict: Runtime Error):
a=input()

x=a+(a*a)+(a*a*a)

print(x)


Fixed submission:
a=int(input())

a=a+(a*a)+(a*a*a)

print(a)
Buggy python submission (verdict: Runtime Error):
import sys


def main():
    a = int(sys.argv[1])
    b = int(sys.argv[2])
    c = int(sys.argv[3])
    bells = [a, b, c]
    bells.sort()
    print(bells[0] + bells[1])


if __name__ == '__main__':
    main()

Fixed submission:

def main():
    arg = input()
    arg = arg.split()
    a = int(arg[0])
    b = int(arg[1])
    c = int(arg[2])
    bells = [a, b, c]
    bells.sort()
    print(bells[0] + bells[1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = input()
a = input()
x = n%500
if x<=a:
  print("YES")
else:
  print("NO")

Fixed submission:
n = input()
a = input()
x = int(n)%500
if x<=int(a):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
n = input()
a = input()
x = N%500
if x<=a:
  print("YES")
else:
  print("NO")

Fixed submission:
n = input()
a = input()
x = int(n)%500
if x<=int(a):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
c = a * b
d = c % 2

if d == 1:
    print("Odd")
else:
    print("Even")

Fixed submission:
a,b = input().split()
c = int(a) * int(b)
d = c % 2
 
if d == 1:
    print("Odd")
else:
    print("Even")

Buggy python submission (verdict: Runtime Error):
a,b = input().split()
c = a * b
d = c % 2

if d == 1:



Fixed submission:
a,b = input().split()
c = int(a) * int(b)
d = c % 2
 
if d == 1:
    print("Odd")
else:
    print("Even")
Buggy python submission (verdict: Runtime Error):
a = int(input())
print(a+a*a)(a*a*a)

Fixed submission:
a = int(input())
print(a+(a*a)+(a*a*a))

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

Fixed submission:
a = int(input())
print(a+(a*a)+(a*a*a))

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

Fixed submission:
a = int(input())
print(a+(a*a)+(a*a*a))

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

Fixed submission:
a = int(input())
print(a+(a*a)+(a*a*a))
Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
    if S >= W:
        print('safe')
    else S < W:
      print('unsafe')

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
    if S >= W:
        print('safe')
    else S < W:
      print('unsafe')

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
    if S >= W:
        print('safe')
    else S < W
      print('unsafe')

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
    if S >= W:
        print('safe')
    else S < W
      print('unsafe')

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
    if S >= W:
        print('safe')
    else:
      S < W
      print('unsafe')

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
    if S >= W:
        print('safe')
    else:
      S < W:
      print('unsafe')

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S,W = int(input())
    if S =< W:
        print('unsafe')
    else:
    S > W:
        print('safe')

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S,W = input()
    if S < W:
        print('unsafe')
    else:
    S > W:
        print('safe')

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S,W = input()
    if S < W
        print('unsafe'):
    else S > W
        print('safe'):

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')

Buggy python submission (verdict: Runtime Error):
S,W = input()
    if S < W
        print('unsafe')
    else S > W
        print('safe')

Fixed submission:
s,w=map(int,input().split())
if s>w:
    print('safe')
else :
    print('unsafe')
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
plist = list(map(int, input().split()))

plist.sort()
ans = 0
for i in rangr(k):
    ans += plist[i]

print(ans)


Fixed submission:
n, k = map(int, input().split())
plist = list(map(int, input().split()))

plist.sort()
ans = 0
for i in range(k):
    ans += plist[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
alist = list(map(int, input().split()))

ans = 1
for i in alist:
    ans *= i
    if 0 in alist:
        ans = 0
        break
    elif ans > 10**18:
        ans = -1
        break

print(ans)

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

ans = 1
if 0 in alist:
    ans = 0
else:
    for i in alist:
        ans *= i
        if ans > 10**18:
            ans = -1
            break

print(ans)

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

ans = 1
for i in alist:
    ans *= i
    
if ans > 10**18:
    ans = -1

print(ans)


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

ans = 1
if 0 in alist:
    ans = 0
else:
    for i in alist:
        ans *= i
        if ans > 10**18:
            ans = -1
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
d = int(input())
print(int(d+d**2+d***3))

Fixed submission:
k = int(input())
print(int(k+k**2+k**3))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
i = list(map(int, input().split()))
ans = 1

for num in range(N):
    ans = ans * i[num]
    if ans > 10**18 and not 0 in i:
        print(-1)
        break
else:
    print(ans)

Fixed submission:
N = int(input())
i = list(map(int, input().split()))
ans = 1

if 0 in i:
    print(0)
else:
    for num in range(N):
        ans = ans * i[num]
        if ans > 10**18:
            print(-1)
            break
    else:
        print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
A = list(map(int,input().split()))
mult = 1
for i in range(N):
  mult *= A[i]
  if mult > 1e18:
    break

if mult > 1e18:
  print(mult)
else:
  print(-1)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
mult = 1
 
if 0 in A:
  mult = 0
  
for i in range(N):
  mult *= A[i]
  if mult > 1e18:
    print(-1)
    break

if mult <= 1e18:
  print(mult)
Buggy python submission (verdict: Runtime Error):
import math

A,B,H,M = map(int,input().split())

radH = 2*math.pi*H/12 + 30/180*math.pi*M/60
radM = 2*math.pi*M/60

L = math.sqrt(A^2+B^2-2*A*B*math.cos(radH-radM))

print(L)

Fixed submission:
import math

A,B,H,M = map(int,input().split())

radH = 2*math.pi*H/12 + 30/180*math.pi*M/60
radM = 2*math.pi*M/60

L = math.sqrt(A**2+B**2-2*A*B*math.cos(radH-radM))

print(L)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().strip())
a = list(map(int, input().split()))
ans = 1

for elem in a:
    ans *= elem
if 10 ** 18 < ans:
    print(-1)
else:
    print(ans)


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

if 0 in a:
    print(0)
else:
    for elem in a:
        ans *= elem
        if 10 ** 18 < ans:
            print(-1)
            exit()
    print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
cnt = 0
loop = 0
cnts = [-1] * n
cnts[now - 1] = cnt
visited = [False] * n
visited[now - 1] = True
li = [now]

while True:
    cnt += 1
    now = a[now - 1]
    li.append(now)

    if cnt == k:
        print(now)
        exit()
    if visited[now - 1]:
        loop = (cnt - cnts[now - 1])
        pre = cnts[now - 1]
        print(li[pre + (k - pre) % loop])
        exit()

    cnts[now - 1] = cnt
    visited[now - 1] = True


Fixed submission:
a, b, c, k = map(int, input().split())
if k <= (a + b):
    print(min(a, k))
else:
    print(a - min(c, (k - a - b)))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(m)]
dic = {}
ban = {}
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    if h[a - 1] < h[b - 1]:
        ban[a] = True
    elif h[a - 1] == h[b - 1]:
        ban[a] = True
        ban[b] = True
    else:
        ban[b] = True

    if dic.get(a):
        dic[a].append(b)
    else:
        dic[a] = [b]

    if dic.get(b):
        dic[b].append(a)
    else:
        dic[b] = [a]
    dic[a] = list(set(dic[a]))
    dic[b] = list(set(dic[b]))
ans = 0
for i in range(n):
    if dic.get(i + 1):
        if ban.get(i + 1):
            if ban[i + 1]:
                continue
        flg = True
        for j in range(len(dic[i + 1])):
            if h[i] <= h[dic[i + 1][j] - 1]:
                flg = False
                break
        if flg:
            ans += 1
    else:
        ans += 1
print(ans)


Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(m)]
dic = {}
ban = {}
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]

    if dic.get(a):
        dic[a] = max(dic[a], h[b - 1])
    else:
        dic[a] = h[b - 1]

    if dic.get(b):
        dic[b] = max(dic[b], h[a - 1])
    else:
        dic[b] = h[a - 1]
ans = 0
for i in range(n):
    if dic.get(i + 1):
        if dic[i + 1] < h[i]:
            ans += 1
    else:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(m)]
dic = {}
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    if dic.get(a):
        dic[a].append(b)
    else:
        dic[a] = [b]

    if dic.get(b):
        dic[b].append(a)
    else:
        dic[b] = [a]
    dic[a] = list(set(dic[a]))
    dic[b] = list(set(dic[b]))
ans = 0
for i in range(n):
    if dic.get(i + 1):
        flg = True
        for j in range(len(dic[i + 1])):
            if h[i] <= h[dic[i + 1][j] - 1]:
                flg = False
                break
        if flg:
            ans += 1
    else:
        ans += 1
print(ans)


Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [tuple(map(int, input().split())) for _ in range(m)]
dic = {}
ban = {}
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]

    if dic.get(a):
        dic[a] = max(dic[a], h[b - 1])
    else:
        dic[a] = h[b - 1]

    if dic.get(b):
        dic[b] = max(dic[b], h[a - 1])
    else:
        dic[b] = h[a - 1]
ans = 0
for i in range(n):
    if dic.get(i + 1):
        if dic[i + 1] < h[i]:
            ans += 1
    else:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().strip())
a = list(map(int, input().split()))
left = {}
for i in range(len(a)):
    if left.get(a[i] + i):
        left[a[i] + i].append(i)
    else:
        left[a[i] + i] = [i]
ans = 0
for i in range(len(a)):
    if left.get(i - a[i]):
        ans += len(list(filter(lambda x: x < i, left[i - a[i]])))
print(ans)


Fixed submission:
n = int(input().strip())
a = list(map(int, input().split()))
dic = {}
ans = 0
for i in range(len(a)):
    if dic.get(i - a[i]):
        ans += dic[i - a[i]]
    if dic.get(a[i] + i):
        dic[a[i] + i] += 1
    else:
        dic[a[i] + i] = 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy

n = int(input().strip())
a = list(map(int, input().split()))
b = deepcopy(a)
counts = {}
tmp = b[0]
for elem in b:
    if str(elem) in counts:
        counts[str(elem)] += 1
    else:
        counts[str(elem)] = 1
    if tmp != elem:
        tmp = elem
c = deepcopy(counts)
for k, v in counts.items():
    c[k] = v * (v - 1) // 2
for elem in a:
    print(sum(c.values()) - c[str(elem)] + ((counts[str(elem)] - 1) * (counts[str(elem)] - 2) // 2))


Fixed submission:
from copy import deepcopy

n = int(input().strip())
a = list(input().split())
b = deepcopy(a)
counts = {}
tmp = b[0]
for elem in b:
    if elem in counts:
        counts[elem] += 1
    else:
        counts[elem] = 1
    if tmp != elem:
        tmp = elem
c = deepcopy(counts)
for k, v in counts.items():
    c[k] = v * (v - 1) // 2
su = sum(c.values())
for elem in a:
    print(su - c[elem] + ((counts[elem] - 1) * (counts[elem] - 2) // 2))

Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy

n = int(input().strip())
a = list(map(int, input().split()))
b = deepcopy(a)
b.sort()
counts = {}
tmp = b[0]
for elem in b:
    if str(elem) in counts:
        counts[str(elem)] += 1
    else:
        counts[str(elem)] = 1
    if tmp != elem:
        tmp = elem
c = deepcopy(counts)
for k, v in c.items():
    c[k] = v * (v - 1) // 2
for elem in a:
    print(sum(c.values()) - c[str(elem)] + ((counts[str(elem)] - 1) * (counts[str(elem)] - 2) // 2))


Fixed submission:
from copy import deepcopy

n = int(input().strip())
a = list(input().split())
b = deepcopy(a)
counts = {}
tmp = b[0]
for elem in b:
    if elem in counts:
        counts[elem] += 1
    else:
        counts[elem] = 1
    if tmp != elem:
        tmp = elem
c = deepcopy(counts)
for k, v in counts.items():
    c[k] = v * (v - 1) // 2
su = sum(c.values())
for elem in a:
    print(su - c[elem] + ((counts[elem] - 1) * (counts[elem] - 2) // 2))
Buggy python submission (verdict: Runtime Error):
a, b, m = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
crr = [[0] * b for _ in range(a)]
xycs = [tuple(map(int, input().split())) for _ in range(m)]
ans = min(arr) + min(brr)

for elem in xycs:
    x = elem[0]
    y = elem[1]
    c = elem[2]
    ans = min(arr[x - 1] + arr[y - 1] - c, ans)

print(ans)


Fixed submission:
a, b, m = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
xycs = [tuple(map(int, input().split())) for _ in range(m)]
ans = min(arr) + min(brr)

for elem in xycs:
    x = elem[0]
    y = elem[1]
    c = elem[2]
    ans = min((arr[x - 1] + brr[y - 1] - c), ans)

print(ans)