Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L.sort()
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[k] < L[i] + L[j]:
                cnt += 1
print(cnt)

Fixed submission:
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()

cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        num = L[i] + L[j]
        third = bisect.bisect_left(L,num)
        if third > j:
            cnt += third - j - 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

if len(set(s)) == 1:
    print(len(S)*K//2)
    exit()

b = [1]
for i in S[:-1]:
    if S[i] == S[i+1]:
        b[-1] += 1
    else:
        b.append(1)

ans = 0
for i in b:
    ans += i//2
ans *= K

if S[0] == S[-1] and b[0]%2 == b[-1]%2 == 1:
    ans += K - 1
print(ans)

Fixed submission:
S = input()
K = int(input())
now,cnt,num = S[0],1,0
for i in S[1:-1]:
    if i == now:
        cnt += 1
    else:
        num += cnt//2
        cnt = 1
        now = i
if S[-1] == now:
    num += (cnt+1)//2
else: num += cnt//2

S = S + S
now,cnt,num2 = S[0],1,0
for i in S[1:-1]:
    if i == now:
        cnt += 1
    else:
        num2 += cnt//2
        cnt = 1
        now = i
if S[-1] == now:
    num2 += (cnt+1)//2
else: num2 += cnt//2

length = len(S)//2
if len(set(S)) == 1 and length%2 == 1:
    print(length//2*K + K//2)
    exit()

if num2 - num*2 == 1:
    ans = K - 1 + num*K
else:
    ans = num*K
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(1,n+1):
  for j in range(n):
    if a[j] == i:
      b[i-1] = j+1
for k in range(n):
  print(b[k],end = " ")

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
ans = [0]*n
for i in range(1,n+1):
  ans[a[i-1]-1] = i
[print(ans[i],end=" ") for i in range(n)]
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int,input().split())
A_list = []
for _ in range(Q):
  A = int(input())
  A_list.append(A)
for i in range(1,N+1):
  print("Yes" if K + A_list.count(i) - Q > 0 else "No")

Fixed submission:
from collections import Counter
N,K,Q = map(int,input().split())
A_list = []
for _ in range(Q):
  A = int(input())
  A_list.append(A)
A_Counter = Counter(A_list)
for i in range(1,N+1):
  print("Yes" if K + A_Counter[i] - Q > 0 else "No")
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if b==1:
  print(0)
  exit()
b -= a
elif b%a == 0:
  print(b//a+1)
else:
  print(b//a + 2)

Fixed submission:
a,b = map(int,input().split())
if b==1:
  print(0)
  exit()
b -= a
if b%(a-1) == 0:
  print(b//(a-1) + 1)
else:
  print(b//(a-1) + 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(int(N*(N-1)//2)

Fixed submission:
N = int(input())
print(N*(N-1)//2)

Buggy python submission (verdict: Runtime Error):
zN = int(input())
print(1/2*14*13)
print(int((1/2)*N*(N-1)))

Fixed submission:
N = int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]
print(A)
B = collections.Counter(s)
print(sum(i*(i-1)//2 for i in B.values()))

Fixed submission:
import collections
N = int(input())
A = []
for i in range(N):
    s = sorted(input())
    A.append(str(s))
B = collections.Counter(A)
print(sum(i*(i-1)//2 for i in B.values()))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
A = []
for i in range(N):
    s = sorted(input())
    A.append(str(s))
cnt = 0
for i in set(A):
    k = collections.Counter(A)[i]
    cnt += k*(k-1)//2
print(cnt)

Fixed submission:
import collections
N = int(input())
A = []
for i in range(N):
    s = sorted(input())
    A.append(str(s))
B = collections.Counter(A)
print(sum(i*(i-1)//2 for i in B.values()))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
cnt = 0
A = []
for i in range(N):
    s = sorted(input())
    s = str(s)
    cnt += collections.Counter(A)[s]
    A.append(s)
print(cnt)

Fixed submission:
import collections
N = int(input())
A = []
for i in range(N):
    s = sorted(input())
    A.append(str(s))
B = collections.Counter(A)
print(sum(i*(i-1)//2 for i in B.values()))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(sa)
if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()

print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(a)

if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()
if len(sa) != 3:
    print("No")
    exit()

if B[sa[0]] == B[sa[1]] == B[sa[2]]:
    print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(a)
if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()

print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(a)

if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()
if len(sa) != 3:
    print("No")
    exit()

if B[sa[0]] == B[sa[1]] == B[sa[2]]:
    print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
B = collections.Counter(a)
sa = list(set(a))
sa.sort()
if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()

print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
if len(set(a)) == 1 and a[0] == 0:
    print("Yes")
    exit()
if N%3 != 0:
    print("No")
    exit()

import collections
sa = list(set(a))
sa.sort()
B = collections.Counter(a)

if len(sa) == 2 and 0 in sa:
    if B[0] == N//3 and B[sa[1]] == N*2//3:
        print("Yes")
    else: print("No")
    exit()
if len(sa) != 3:
    print("No")
    exit()

if B[sa[0]] == B[sa[1]] == B[sa[2]]:
    print("Yes" if sa[0] ^ sa[1] == sa[2] else "No")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
bound = list(map(int,input().split()))
cnt = 0
pos = 0
for i in range(n+1):
  cnt += 1
  pos += bound[i]
  if pos > x:
    break
print(cnt)

Fixed submission:
n,x = map(int,input().split())
bound = list(map(int,input().split()))
cnt = 1
pos = 0
for i in range(n):
  pos += bound[i]
  if pos <= x:
    cnt += 1
  if pos > x:
    break
print(cnt)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for _ in range(M)]
B.sort(key = lambda x:x[1])
B = list(reversed(B))
A.sort()

num = 0
for i in range(M):
    for j in range(B[i][0]):
        if A[num] < B[i][1]:
            A[num] = B[i][1]
            num += 1
        else:
            break
        
print(sum(A))

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = [list(map(int,input().split())) for _ in range(M)]
B.sort(key = lambda x:x[1])
B = list(reversed(B))
A.sort()

num = 0
for i in range(M):
    for j in range(B[i][0]):
        if num > N-1:
            break
        if A[num] < B[i][1]:
            A[num] = B[i][1]
            num += 1
        else:
            break

print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N,Q = map(int,input().split())
T = input()
S = T.replace("AC","WW")

for i in range(Q):
    l,r = map(int,input().split())
    l,r = l-1,r-1
    num = collections.Counter(S[l:r+1])["W"]//2
    if T[l] == "C" and T[r] == "A":
        num -= 1
    print(num)

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

t = [0]*(N+1)
for i in range(N):
    t[i+1] = t[i] + (S[i:i+2] == "AC")
    
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
w = input()
W_list = [w]
for i in range(N-1):
  W = input()
  if w[-1] == W[0] and W not in W.list:
    W_list.append(w)
    w = W
  else:
    print("No")
    exit()
print("Yes")

Fixed submission:
N = int(input())
W = [input() for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i != j:
            if W[i] == W[j]:
                print("No")
                exit()
for k in range(N-1):
    if W[k][-1] != W[k+1][0]:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] == "1" and K == 1:
    print(1)
    exit()
A = S.lstrip("1")
print(A[0])

Fixed submission:
S = input()
K = int(input())
if S[:K].count("1") == K:
    print(1)
    exit()
A = S.lstrip("1")
print(A[0])
Buggy python submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
cost = 0
for i in range (x):
  if a[i] < x:
    cost += 1
print(min(cost,m-cost))

Fixed submission:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
cost = 0
for i in range (m):
  if a[i] < x:
    cost += 1
print(min(cost,m-cost))
Buggy python submission (verdict: Runtime Error):
N = input()
M = N.lstrip("9")
if N != M:
    print((len(M)-1)*9+int(M[0])-1+(len(N)-len(M))*9)
else:
    print((len(N)-1)*9+int(N[0])-1)

Fixed submission:
N = input()
print(max(sum([int(i) for i in N]),(len(N)-1)*9+int(N[0])-1))
Buggy python submission (verdict: Runtime Error):
a,b = input().split()
c = a+b
import math
if int(math.sqrt(c)) ** 2 == c:
  print("Yes")
else:
  print("No")

Fixed submission:
a,b = input().split()
c = a+b
c = int(c)
for i in range (1000):
  if i**2 == c:
    print("Yes")
    exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(max(a)+1):
    ans = max(ans, a.count(i)+a.count(i-1)+a.count(i+1))
print(ans)

Fixed submission:
import collections
N = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
ans = 0
for i in range(max(a)+1):
    ans = max(ans, c[i]+c[i-1]+c[i+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
zero,one,two = 0,0,0
for i in a:
    if i%4 == 0:
        two += 1
    elif i%2 == 0:
        one += 1
    else:
        zero += 1
if one = N:
    print("Yes")
    exit()
print("Yes" if two+int(two>0) >= zero+int(one>0) else "No")

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
zero,one,two = 0,0,0
for i in a:
    if i%4 == 0:
        two += 1
    elif i%2 == 0:
        one += 1
    else:
        zero += 1
if one == N:
    print("Yes")
    exit()
print("Yes" if two+int(two>0) >= zero+int(one>0) else "No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    b.append(a[i])
    b.reverse()
print(*b)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
for i in a[-1::-2]:
    b.append(i)
for i in a[(n%2 == 1)::2]:
    b.append(i)
print(*b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
power = 1
for i in range(1,N+1):
    power *= i
print(power % (10**9 + 7))

Fixed submission:
N = int(input())
power = 1
for i in range(1,N+1):
    power *= i
    if power >= 10**9 + 7:
        power %= 10**9 + 7
print(power % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
h,w,m = map(int,input().split())
H = [0]*(h)
W = [0]*(w)
ls = []
for _ in range(m):
    a,b = map(int,input().split())
    ls.append([a-1,b-1])
    H[a-1] += 1
    W[b-1] += 1
hm = max(H)
wm = max(W)
a = [i for i in range(h) if H[i] == hm]
b = [j for j in range(w) if W[j] == wm]
for i in a:
    for j in b:
        if [i,j] not in ls:
            print(hm+wm)
            sys.exit()
print(hm+wm-1)

Fixed submission:
h,w,m = map(int,input().split())
x = {}
y = {}
dic = {}
for _ in range(m):
    a,b = map(int,input().split())
    dic[(a,b)] = 1
    x[a] = x.get(a,0) + 1
    y[b] = y.get(b,0) + 1
p = max(x.values())
q = max(y.values())
cnt = 1
a = [i for i in x if x[i] == p]
b = [j for j in y if y[j] == q]
for i in a:
    for j in b:
        if dic.get((i,j),-1) == -1:
            cnt = 0
            break
    if not cnt:
        break
print(p+q-cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
h,w,m = map(int,input().split())
H = [0]*(h)
W = [0]*(w)
ls = []
for _ in range(m):
    a,b = map(int,input().split())
    ls.append([a-1,b-1])
    H[a-1] += 1
    W[b-1] += 1
hm = max(H)
wm = max(W)
for i in range(len(H)):
    for j in range(len(W)):
        if W[j] == wm and H[i] == hm and [i,j] not in ls:
            print(hm+wm)
            sys.exit()
print(hm+wm-1)



Fixed submission:
h,w,m = map(int,input().split())
x = {}
y = {}
dic = {}
for _ in range(m):
    a,b = map(int,input().split())
    dic[(a,b)] = 1
    x[a] = x.get(a,0) + 1
    y[b] = y.get(b,0) + 1
p = max(x.values())
q = max(y.values())
cnt = 1
a = [i for i in x if x[i] == p]
b = [j for j in y if y[j] == q]
for i in a:
    for j in b:
        if dic.get((i,j),-1) == -1:
            cnt = 0
            break
    if not cnt:
        break
print(p+q-cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
h,w,m = map(int,input().split())
H = [0]*(h)
W = [0]*(w)
ch = [[False]*w for _ in range(h)]
for _ in range(m):
    a,b = map(int,input().split())
    H[a-1] += 1
    W[b-1] += 1
    ch[a-1][b-1] = True
hm = max(H)
wm = max(W)
for i in range(len(H)):
    if H[i] != hm:
        continue
    for j in range(len(W)):
        if W[j] != wm:
            continue
        if ch[i][j] != True:
            print(hm+wm)
            sys.exit()
print(hm+wm-1)

            
        

Fixed submission:
h,w,m = map(int,input().split())
x = {}
y = {}
dic = {}
for _ in range(m):
    a,b = map(int,input().split())
    dic[(a,b)] = 1
    x[a] = x.get(a,0) + 1
    y[b] = y.get(b,0) + 1
p = max(x.values())
q = max(y.values())
cnt = 1
a = [i for i in x if x[i] == p]
b = [j for j in y if y[j] == q]
for i in a:
    for j in b:
        if dic.get((i,j),-1) == -1:
            cnt = 0
            break
    if not cnt:
        break
print(p+q-cnt)
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = map(int,input().split())
ch = k%2
ans = abs(x)
cnt = 0
while True:
    cnt += 1
    if x == 0:
        if ((cnt-1)%2) == ch:
            print(0)
            break
        else:
            print(abs(d))
            break
    elif x > 0:
        x -= d
        if ans <= abs(x):
            if ch == cnt%2:
                print(abs(x))
                break                
            else:
                print(ans)
                break
        else:
            ans = abs(x)
    else:
        x += d
        if ans <= abs(x):
            if ch == cnt%2:
                print(abs(x))
                break
            else:
                print(ans)
                break
        else:
            ans = abs(x)
    if cnt == k:
        print(ans)
        break

Fixed submission:
x,k,d = map(int,input().split())
ch = k%2
ans = abs(x)
cnt = 0
while True:
    if x == 0:
        if (cnt%2) == ch:
            print(0)
            break
        else:
            print(abs(d))
            break
    if x > 0:
        if x//d > k:
            print(x-k*d)
            break
        cnt += x//d
        x -= d*(x//d)
        xx = x - d
        if cnt%2 == ch:
            print(abs(x))
        else:
            print(abs(xx))
        break
    elif x < 0:
        if abs(x)//d > k:
            print(abs(x+k*d))
            break
        cnt += abs(x)//d
        x += d*(abs(x)//d)
        xx = x + d
        if cnt%2 == ch:
            print(abs(x))
        else:
            print(abs(xx))
        break
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n % 1000 == 0:
  print(0)
else:
  print(2000-int("1"+str(n[:-3])))

Fixed submission:
n = int(input())
if n % 1000 == 0:
  print(0)
else:
  while n > 1000:
    n -= 1000
  print(1000-n)
Buggy python submission (verdict: Runtime Error):
import sys
a,b,n = map(int,input().split())
d = 0
i = 0
for i in range(1,n+1):
    c = int(a*i/b)-a*int(i/b)
    if c >= d:
        d = c
    else:
        j += 1
        if j > 1:
            print(int(a*(j-2)/b)-a*int((j-2)/b))
            sys.exit()
print(d)

Fixed submission:
a,b,n = map(int,input().split())
if n>= b-1:
    print(int(a*(b-1)/b)-a*int((b-1)/b))
else:
    print(int(a*n/b)-a*int(n/b))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
a,b,n = map(int,input().split())
d = 0
i = 0
for i in range(1,n+1):
    c = int(a*i/b)-a*int(i/b)
    if c >= d:
        d = c
    else:
        i += 1
        if i > 1:
            print(int(a*(i-2)/b)-a*int((i-2)/b))
            sys.exit()
print(d)

Fixed submission:
a,b,n = map(int,input().split())
if n>= b-1:
    print(int(a*(b-1)/b)-a*int((b-1)/b))
else:
    print(int(a*n/b)-a*int(n/b))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
a,b,n = map(int,input().split())
d = 0
for i in range(1,n+1):
    c = int(a*i/b)-a*int(i/b)
    if c > d:
        d = c
print(d)

Fixed submission:
a,b,n = map(int,input().split())
if n>= b-1:
    print(int(a*(b-1)/b)-a*int((b-1)/b))
else:
    print(int(a*n/b)-a*int(n/b))

Buggy python submission (verdict: Time Limit Exceeded):
a,b,n = map(int,input().split())
for i in range(n+1):
    c = int(a*i/b)-a*int(i/b)
    if i == 0:
        d = c
    else:
        if c > d:
            d = c
print(d)

Fixed submission:
a,b,n = map(int,input().split())
if n>= b-1:
    print(int(a*(b-1)/b)-a*int((b-1)/b))
else:
    print(int(a*n/b)-a*int(n/b))
Buggy python submission (verdict: Runtime Error):
from tttest import circle
n = int(input())
circle(n)

Fixed submission:
import math
r = int(input())
print(math.pi*2*r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = list(map(int,input().split()))
for i in range(1,n+1):
    print(ls.count(i))

Fixed submission:
n = int(input())
ls = list(map(int,input().split()))
a = [0]*(n)
p = 0
for i in range(n-1):
    p = ls[i] 
    a[p-1] +=1
for j in range(n):
    print(a[j])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = list(map(int,input().split()))
for i in range(1,n+1):
    print(ls.count(i))

Fixed submission:
n = int(input())
ls = list(map(int,input().split()))
a = [0]*(n)
p = 0
for i in range(n-1):
    p = ls[i] 
    a[p-1] +=1
for j in range(n):
    print(a[j])
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
ls = [j for j in range(n+1)]
a = 1
for i in range(k,n+1):
    if (n + 1) -2*i >= 0:
        a += sum(ls[n+1-i:]) - sum(ls[:i]) + 1
    else:
        a += sum(ls[i:]) - sum(ls[:n-i+1]) + 1
print(a)

Fixed submission:
n,k = map(int,input().split())
a = 1
for i in range(k,n+1):
    a += n*i - i**2 + i + 1
print(a%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = list(range(n+1))
x = 0
for i in range(m,n+2):
    b = sum(a[:i])
    c = sum(a[-i:])
    d = c - b + 1
    x += d
print(x)
    


Fixed submission:
n,k = map(int,input().split())
a = 1
for i in range(k,n+1):
    a += n*i - i**2 + i + 1
print(a%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
s = 0
a = []
b = []
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            p = [i,j,l]
            p.sort()
            if (p in a):
                s += b[a.index(p)]
            else:
                a.append(p)
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q
                b.append(q)
print(s)


Fixed submission:
import math
k = int(input())
s = 0
b = []
for i in range(1,k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            p = len(set([i,j,l]))
            if p ==1:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q
                b.append(q)
            elif p ==2:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q*3
                b.append(q)
            else:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q*6
                b.append(q)
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
s = 0
a = []
b = []
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            p = [i,j,l]
            p.sort()
            if (p in a):
                s += b[a.index(p)]
            else:
                a.append(p)
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q
                b.append(q)
print(s)


Fixed submission:
import math
k = int(input())
s = 0
b = []
for i in range(1,k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            p = len(set([i,j,l]))
            if p ==1:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q
                b.append(q)
            elif p ==2:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q*3
                b.append(q)
            else:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q*6
                b.append(q)
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
s = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            t = math.gcd(i,j)
            s += math.gcd(t,l)
print(s)


Fixed submission:
import math
k = int(input())
s = 0
b = []
for i in range(1,k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            p = len(set([i,j,l]))
            if p ==1:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q
                b.append(q)
            elif p ==2:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q*3
                b.append(q)
            else:
                t = math.gcd(i,j)
                q = math.gcd(t,l)
                s += q*6
                b.append(q)
print(s)