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


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0

    A.sort(reverse=True)
    A = tuple(A)

    for i in range(N-1):
        flg = True
        for j in range(i+1, N):
            if A[i] % A[j] == 0:
                flg = False
                break
        if flg == True:
            ans += 1

    if A[N-1] != A[N-2]:
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()


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

for i in range(5):
    if X[i] == 0:
        ans = i + 1
        print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 0

A.sort(reverse=True)

for i in range(len(A)-1):
    flg = True
    for j in range(i+1, len(A)):
        if A[i] % A[j] == 0:
            flg = False
            break
    if flg == True:
        print(i)
        ans += 1

print(ans)


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

for i in range(5):
    if X[i] == 0:
        ans = i + 1
        print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter


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

    A_set = set(A)
    A_dict = Counter(A)
    A_dict.sort()

    for key, count in A_dict.items():
        if count > 1:
            A_set.discard(key)
            continue

        k = key * 2

        if key in A_set:
            while k <= max(A):
                A_set.discard(k)
                k += key

    print(len(A_set))


if __name__ == '__main__':
    main()


Fixed submission:

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

    m = max(A) + 1
    dp = [0] * m

    for a in sorted(A):
        if dp[a] != 0:
            dp[a] = 2
            continue
        for i in range(a, m, a):
            dp[i] += 1

    print(sum(dp[i] == 1 for i in A))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


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

    A_set = set(A)
    A_dict = Counter(A)

    for key, count in A_dict.items():
        if count > 1:
            A_set.discard(key)

        k = key * 2
        while k <= max(A):
            A_set.discard(k)
            k += key

    print(len(A_set))


if __name__ == '__main__':
    main()


Fixed submission:

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

    m = max(A) + 1
    dp = [0] * m

    for a in sorted(A):
        if dp[a] != 0:
            dp[a] = 2
            continue
        for i in range(a, m, a):
            dp[i] += 1

    print(sum(dp[i] == 1 for i in A))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
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:
        ans = -1
        break

print(ans)


Fixed submission:
A, B = map(int, input().split())
ans = A*B
print(ans)
Buggy python submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main() {
	var n int
	var ans int = 1
	var t int

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		ans = ans * t
		if ans > 1000000000000000000 {
			ans = -1
		}
	}

	fmt.Println(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:
        ans = -1
        break

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 > 1000000000000000000:
        ans = -1

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:
        ans = -1
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
package main

import "fmt"

func main() {
	var n int
	var ans int = 1
	fmt.Scan(&n)
	t := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])
	}

	for i := 0; i < n; i++ {
		ans = ans * t[i]
	}

	if ans > 1000000000000000000 {
		ans = -1
	}
	fmt.Println(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:
        ans = -1
        break

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 > 1000000000000000000:
    ans = -1

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:
        ans = -1
        break

print(ans)

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

ans = 1

for a in A:
    ans *= a

if ans > 10**(18):
    ans = -1

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:
        ans = -1
        break

print(ans)

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

ans = 1

for a in A:
    ans *= a

if ans > 10**(18):
    ans = -1

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:
        ans = -1
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = input().split()
A = int(A)
B100 = ""

for s in range(len(B)):
    if B[s] != ".":
        B100 += B[s]

B100 = int(B100)

ans = A * B100 // 100

print(ans[0])


Fixed submission:
A, B = input().split()
A = int(A)
B100 = ""

for s in range(len(B)):
    if B[s] != ".":
        B100 += B[s]

B100 = int(B100)

ans = A * B100 // 100

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = []
B = []

good = []
no_good = []

for i in range(M):
    t = list(map(int, input().split()))
    A.append(t[0])
    B.append(t[1])

for i in range(M):
    if H[A[i]-1] > H[B[i]-1]:
        g = A[i]
        n = B[i]
    elif H[A[i]-1] < H[B[i]-1]:
        g = B[i]
        n = A[i]
    else:
        no_good.append(A[i])
        no_good.append(B[i])
        continue

    if (g not in no_good) and (g not in good):
        good.append(g)
    if n in good:
        good.remove(n)
    no_good.append(n)

used = set(A) | set(B)
good_num = len(good)
unused_num = N - len(used)
result = good_num + unused_num
print(result)


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

no_good = []

for i in range(M):
    t = list(map(int, input().split()))
    A.append(t[0])
    B.append(t[1])

for i in range(M):
    if H[A[i]-1] > H[B[i]-1]:
        no_good.append(B[i])
    elif H[A[i]-1] < H[B[i]-1]:
        no_good.append(A[i])
    else:
        no_good.append(A[i])
        no_good.append(B[i])

result = N - len(set(no_good))
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())

ans = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                ans += 1

print(ans)


Fixed submission:
K, S = map(int, input().split())

ans = 0

for x in range(K+1):
    for y in range(K+1):
        z = S - (x + y)
        if 0 <= z and z <= K:
            ans += 1

print(ans)

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

ans = 0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                ans += 1

print(ans)


Fixed submission:
K, S = map(int, input().split())

ans = 0

for x in range(K+1):
    for y in range(K+1):
        z = S - (x + y)
        if 0 <= z and z <= K:
            ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a=1
    l=[int(x) for x in input().split()]
    for i in range(len(l)):
        a=a*l[i]
        
    if a>10**18:
        a=-1
    print(a)
main()

Fixed submission:
def main():
    n = int(input())
    a=1
    l=[int(x) for x in input().split()]
    if not(0 in l):
        for i in range(len(l)):
            a=a*l[i]
            if a>10**18:
                a=-1
                break
    else:
        a=0
    print(a)
main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [x for x in input().split()]
    l = [0] * N
    C = list(set(A))
    for i in C:
        l[int(i)-1] = A.count(i)
    for i in range(N):
        print(l[i])
        
main()

Fixed submission:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = [x for x in input().split()]
    l = [0] * N
    B = set(A)
    C = list(B)
    for i in C:
        l[int(i)-1] = A.count(i)
    for i in range(N):
        print(l[i])
        
main()

Fixed submission:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()

Buggy python submission (verdict: Runtime Error):
import sys
def main():
	input = sys.stdin.readline
    N = int(input())
    A = [x for x in input().split()]
    l = [0] * N
    B = set(A)
    C = list(B)
    for i in C:
        l[int(i)-1] = A.count(i)
    for i in range(N):
        print(l[i])
        
main()

Fixed submission:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [x for x in input().split()]
    for i in range(1, N+1):
        print(A.count(str(i)))
main()


Fixed submission:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [x for x in input().split()]
    l = [0] * N
    B = set(A)
    C = list(B)
    for i in C:
        l[int(i)-1] = A.count(i)
    for i in range(N):
        print(l[i])
        
main()

Fixed submission:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [x for x in input().split()]
    l = [0] * N
    B = set(A)
    C = list(B)
    for i in C:
        l[int(i)-1] = A.count(i)
    for i in range(N):
        print(l[i])
        
main()

Fixed submission:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [x for x in input().split()]
    for i in range(1, N+1):
        print(A.count(str(i)))
main()

Fixed submission:
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()
Buggy python submission (verdict: Runtime Error):
def main():
    a,b = map(int, input().split())
    if a>=13:
        print(b)
    elif 6<=a<=12:
        print(int(b/2)
    else:
        print(0)
main()

Fixed submission:
def main():
    a,b = map(int, input().split())
    if a>=13:
        print(b)
    elif 6<=a<=12:
        print(int(b/2))
    else:
        print(0)
main()
Buggy python submission (verdict: Time Limit Exceeded):

import sys
n = int(input())
aa = input()
a = aa.split()

result = 1
for i in range(n):
    if(a[i] == 0):
        print(0)
        sys.exit()
    result *= int(a[i])

if(result > 1000000000000000000):
    print(-1)
    sys.exit()

print(result)


Fixed submission:

import sys
n = int(input())
aa = input()
a = aa.split()

for i in range(n):
    if(int(a[i]) == 0):
        print(0)
        sys.exit()

result = 1
for i in range(n):
    result *= int(a[i])
    if(result > 1000000000000000000):
        print(-1)
        sys.exit()

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

n = int(input())
aa = input()
for i in range(n):
    a = aa.split()

result = 1
for i in range(n):
    result *= int(a[i])

if(result > 1000000000000000000):
    print(-1)
else:
    print(result)


Fixed submission:

import sys
n = int(input())
aa = input()
a = aa.split()

for i in range(n):
    if(int(a[i]) == 0):
        print(0)
        sys.exit()

result = 1
for i in range(n):
    result *= int(a[i])
    if(result > 1000000000000000000):
        print(-1)
        sys.exit()

print(result)
Buggy python submission (verdict: Runtime Error):
n = input()
n %= 10
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if n in hon:
    print("hon")
elif n in pon:
    print("pon")
else:
    print("bon")

Fixed submission:
n = int(input())
n %= 10
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if n in hon:
    print("hon")
elif n in pon:
    print("pon")
else:
    print("bon")
Buggy python submission (verdict: Runtime Error):
import bisect
import sys

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_accumulated = [0] * n
b_accumulated = [0] * m

for idx, a in enumerate(A):
    a_accumulated[idx] += a_accumulated[idx - 1] + a # idx == 0の場合はa_accumulated[-1]を参照するが、それは0初期化されているので問題ない。

for idx, b in enumerate(B):
    b_accumulated[idx] += b_accumulated[idx - 1] + b

a_limit = bisect.bisect_right(a_accumulated, k)
if a_limit == 0:
    position = bisect.bisect_right(b_accumulated, k - a_accumulated[i])
    print(position)
    sys.exit(0)

best_num = 0
for i in reversed(range(0, a_limit)):
    position = bisect.bisect_right(b_accumulated, k - a_accumulated[i])
    best_num = max(best_num, i + position + 1)
print(best_num)



Fixed submission:
import bisect
import sys

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_accumulated = [0] * (n + 1)
b_accumulated = [0] * (m + 1)

for idx, a in enumerate(A):
    a_accumulated[idx + 1] = a_accumulated[idx] + a # idx == 0の場合はa_accumulated[-1]を参照するが、それは0初期化されているので問題ない。

for idx, b in enumerate(B):
    b_accumulated[idx + 1] = b_accumulated[idx] + b

a_limit = bisect.bisect(a_accumulated, k)
if a_limit == 0:
    position = bisect.bisect(b_accumulated, k)
    print(position - 1)
    sys.exit(0)

best_num = 0
for i in reversed(range(0, a_limit)):
    position = bisect.bisect_right(b_accumulated, k - a_accumulated[i])
    best_num = max(best_num, i + position - 1)
print(best_num)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
 
result = 0
for i in range(1, n + 1):
    for j in range(1, (n // i) + 1):
        result += i * j
print(result)

Fixed submission:
n = int(input())

result = 0
for i in range(1, n + 1):
    for j in range(1, (n // i) + 1):
        result += i * j
print(result)
Buggy python submission (verdict: Runtime Error):
import copy

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

target = A[0] ^ A[1] ^ A[2] ^ A[3]

results = [''] * n

for i in range(n):
    results[i] = str(target ^ A[i])

print(" ".join(results))


Fixed submission:
import copy

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

target = 0
for i in range(n):
    target ^= A[i]

results = [''] * n

for i in range(n):
    results[i] = str(target ^ A[i])

print(" ".join(results))

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

n = int(input())
A = list(map(int, input().split()))
B = copy.deepcopy(A)
results = [''] * n
maxvalue = max(A)
maxvalue2 = max(A)
targetValue = ''
while maxvalue > 0:
    mod = 0
    maxvalue = maxvalue >> 1
    for idx, a in enumerate(A):
        mod += a % 2
        A[idx] = a >> 1
    targetValue = str(mod % 2) + targetValue
for i in range(n):
    maxvalue2 = max(B)
    tmpValue = int(targetValue, 2)
    while maxvalue2 > 0:
        results[i] = str((tmpValue % 2 + B[i] % 2) % 2) + results[i]
        tmpValue = tmpValue >> 1
        B[i] = B[i] >> 1
        maxvalue2 = maxvalue2 >> 1
answers = [''] * n
for idx, res in enumerate(results):
    answers[idx] = str(int(res, 2))
print(" ".join(answers))


Fixed submission:
import copy

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

target = 0
for i in range(n):
    target ^= A[i]

results = [''] * n

for i in range(n):
    results[i] = str(target ^ A[i])

print(" ".join(results))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

A.sort()
count = 0
for i in range(n - 1):
    if A[i] % A[i + 1] == 0:
        count += 1
        continue
    for j in range(i):
        if A[i] % A[j] == 0:
            count += 1
            break
i = n - 1
for j in range(i):
    if A[i] % A[j] == 0:
        count += 1
        break
print(n - count)


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

dp = [False] * (A[-1] + 1)
for a in A:
    dp[a] = True

for idx, a in enumerate(A):
    if A[idx] == A[idx - 1]:
        if idx == 0:
            None
        else:
            dp[a] = False
    for j in range(2, A[-1]//a + 1):
        dp[a * j] = False

count = 0
for d in dp:
    if d:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
n, m, x = map(int, input().split())
C = [0] * n
A = [[0] * m for i in range(n)]


sumlist = [0] * m
for i in range(n):
    books = list(map(int, input().split()))
    C[i] = books[0]
    for j in range(m):
        A[i][j] = books[j + 1]
        sumlist[j] += books[j + 1]

# print(n, m, x)
# print(C)
# print(A)
# print(sumlist)

if min(sumlist) < x:
    print("-1")
    sys.exit(0)

def python_list_add(in1, in2):
    return [a + b for a, b in zip(in1, in2)]

min_cost = sys.maxsize
for comb in itertools.permutations(range(n), n):
    learnlist = [0] * n
    cost = 0
    for i in comb:
        learnlist = python_list_add(learnlist, A[i])
        cost += C[i]
        if min(learnlist) >= x:
            if cost < min_cost:
                min_cost = cost
print(min_cost)


Fixed submission:
import sys
import itertools
n, m, x = map(int, input().split())
C = [0] * n
A = [[0] * m for i in range(n)]

mlist = [0] * m
for i in range(n):
    books = list(map(int, input().split()))
    C[i] = books[0]
    for j in range(m):
        A[i][j] = books[j + 1]

mincost = sys.maxsize
for i in range(2**n):
    sumlist = [0] * m
    currentcost = 0
    for j in range(n):
        if ((i >> j) % 2) == 1:
            for k in range(m):
                sumlist[k] += A[j][k]
            currentcost += C[j]
    if min(sumlist) >= x:
        if currentcost < mincost:
            mincost = currentcost

if mincost == sys.maxsize:
    print("-1")
else:
    print(mincost)
Buggy python submission (verdict: Time Limit Exceeded):
import math
import itertools

N, K = map(int, input().strip().split())

all_combination = 0
less_than_K_combination = 0
for num in range(K, N + 2): # 選ぶ個数を1 から N + 1個までずらす
    targetList = []
    for each_num in range(num):
        targetList.append(each_num)
    min = sum(targetList)
    targetList = []
    for each_num in range(N + 1 - num, N + 1):
        targetList.append(each_num)
    max = sum(targetList)
    all_combination += max - min + 1

#for num in range(1, K): # 選ぶ個数を1 から K - 1個までずらす
#    targetList = []
#    for each_num in range(num):
#        targetList.append(each_num)
#    min = sum(targetList)
#    targetList = []
#    for each_num in range(N + 1 - num, N + 1):
#        targetList.append(each_num)
#    max = sum(targetList)
#    less_than_K_combination += max - min + 1

print(all_combination)

Fixed submission:
import math
import itertools

N, K = map(int, input().strip().split())

all_combination = 0
for num in range(K, N + 2): # 選ぶ個数を1 から N + 1個までずらす
    min = (0 + num - 1) * num / 2
    max = (N - (num - 1) + N) * num / 2
    possiblility = (int(max) - int(min) + 1)
    all_combination += possiblility

print(all_combination % (1000000007))

Buggy python submission (verdict: Time Limit Exceeded):
import math
import itertools

N, K = map(int, input().strip().split())
L = math.pow(10, 10)

values = [0] * (N + 1)
for i in range(N + 1):
    values[i] = i

amount = 0
each_combination = []
for comb_no in range(K, N + 2):
    possible_values = set()
    for combination in itertools.combinations(values, comb_no):
        possible_values.add(sum(combination))
    each_combination.append(len(possible_values))
print(sum(each_combination))

Fixed submission:
import math
import itertools

N, K = map(int, input().strip().split())

all_combination = 0
for num in range(K, N + 2): # 選ぶ個数を1 から N + 1個までずらす
    min = (0 + num - 1) * num / 2
    max = (N - (num - 1) + N) * num / 2
    possiblility = (int(max) - int(min) + 1)
    all_combination += possiblility

print(all_combination % (1000000007))

Buggy python submission (verdict: Time Limit Exceeded):
import math
import itertools

N, K = map(int, input().strip().split())
L = math.pow(10, 10)

values = [0] * (N + 1)
for i in range(N + 1):
    values[i] = L + i

amount = 0
possible_values = set()
for comb_no in range(K, N + 2):
    for combination in itertools.combinations(values, comb_no):
        possible_values.add(sum(combination))
print(len(possible_values))

Fixed submission:
import math
import itertools

N, K = map(int, input().strip().split())

all_combination = 0
for num in range(K, N + 2): # 選ぶ個数を1 から N + 1個までずらす
    min = (0 + num - 1) * num / 2
    max = (N - (num - 1) + N) * num / 2
    possiblility = (int(max) - int(min) + 1)
    all_combination += possiblility

print(all_combination % (1000000007))
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input().strip())
gcdsum = 0

for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            gcdsum += math.gcd(math.gcd(a, b), c)
print(gcdsum)

Fixed submission:
import math
import itertools

k = int(input().strip())
gcdsum = 0

for a, b, c in itertools.combinations_with_replacement(range(1, k + 1), 3):
    if a == b and b == c:
        gcdsum += math.gcd(math.gcd(a, b), c) * 1
    elif a != b and b == c:
        gcdsum += math.gcd(math.gcd(a, b), c) * 3
    elif a == b and b != c:
        gcdsum += math.gcd(math.gcd(a, b), c) * 3
    elif a != b and b != c:
        gcdsum += math.gcd(math.gcd(a, b), c) * 6
print(gcdsum)