Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n + 1):
    ind = a.count(i)
    print(ind)

Fixed submission:
import bisect
n = int(input())
a = list(map(int, input().split()))
a.sort()
d = {0: 0}
for i in range(1, n + 1):
    d[i] = bisect.bisect_right(a, i)
    print(d[i] - d[i - 1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
r = [i for i, x in enumerate(s) if x == "R"]
g = [i for i, x in enumerate(s) if x == "G"]
b = [i for i, x in enumerate(s) if x == "B"]
ans = len(r) * len(g) * len(b)
if len(b) < len(g):
    g, b = b, g
elif len(b) < len(r):
    r, b = b, r
else:
    pass
for i in r:
    for j in g:
        i_ = min(i, j)
        j_ = max(i, j)
        div = (j_ - i_)
        if i_ - div in b:
            ans -= 1
        if div % 2 == 0:
            k_2 = div // 2 + i_
            if div // 2 + i_ in b:
                ans -= 1
        if div + j_ in b:
            ans -= 1
print(ans)

Fixed submission:
n = int(input())
s = list(input())
r = [i for i, x in enumerate(s) if x == "R"]
g = [i for i, x in enumerate(s) if x == "G"]
b = [i for i, x in enumerate(s) if x == "B"]
ans = len(r) * len(g) * len(b)

for i in r:
    for j in g:
        i_ = min(i, j)
        j_ = max(i, j)
        div = (j_ - i_)
        k_1 = i_ - div
        k_2 = div // 2 + i_
        k_3 = div + j_
        if k_1 >= 0 and s[k_1] == "B":
            ans -= 1
        if div % 2 == 0 and s[k_2] == "B":
            ans -= 1
        if k_3 < n and s[k_3] == "B":
            ans -= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
r = [i for i, x in enumerate(s) if x == "R"]
b = [i for i, x in enumerate(s) if x == "B"]
g = [i for i, x in enumerate(s) if x == "G"]
ans = len(r) * len(b) * len(g)
for i in r:
    for j in g:
        i_ = min(i, j)
        j_ = max(i, j)
        div = (j_ - i_)
        if i_ - div in b:
            ans -= 1
        if div % 2 == 0:
            k_2 = div // 2 + i_
            if div // 2 + i_ in b:
                ans -= 1
        if div + j_ in b:
            ans -= 1
print(ans)

Fixed submission:
n = int(input())
s = list(input())
r = [i for i, x in enumerate(s) if x == "R"]
g = [i for i, x in enumerate(s) if x == "G"]
b = [i for i, x in enumerate(s) if x == "B"]
ans = len(r) * len(g) * len(b)

for i in r:
    for j in g:
        i_ = min(i, j)
        j_ = max(i, j)
        div = (j_ - i_)
        k_1 = i_ - div
        k_2 = div // 2 + i_
        k_3 = div + j_
        if k_1 >= 0 and s[k_1] == "B":
            ans -= 1
        if div % 2 == 0 and s[k_2] == "B":
            ans -= 1
        if k_3 < n and s[k_3] == "B":
            ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
s, _ = list(input().split())
a, b = list(map(int, input().split()))
u = input()
if s == u:
    a -= 1
else:
    b -= u
print(a, end=' ')
print(b)

Fixed submission:
s, _ = list(input().split())
a, b = list(map(int, input().split()))
u = input()
if s == u:
    a -= 1
else:
    b -= 1
print(a, end=' ')
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce
def comb(n, r):
    r = min(n - r, r)
    if r == 0: 
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under
  
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
mi = [0] * n
ma = [0] * n
s_mi = 0
s_ma = 0
for i in range(n):
    nn = n - i - 1
    if nn < k - 1:
        break
    else:
        mi[i] = comb(nn, k - 1)
        ma[-(i + 1)] = mi[i] 
for i, j, k in zip(a, mi, ma):
    s_mi += i * j
    s_ma += i * k
    
print((s_ma - s_mi) % (10 ** 9 + 7))

Fixed submission:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
fac = {0: 1, 1: 1}
finv = {0: 1, 1: 1}
inv = {1: 1}
a.sort()
mi = [0] * n
ma = [0] * n
s_mi = 0
s_ma = 0

def comb_init():
    for i in range(2, n + 1):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod

comb_init()

for i in range(n):
    nn = n - i - 1
    if nn < k - 1:
        break
    else:
        mi[i] = comb(nn, k - 1)
        ma[-(i + 1)] = mi[i] 
    s_mi = (s_mi + mi[i] * a[i]) % mod
    s_ma = (s_ma + ma[-(i + 1)] * a[-(i + 1)]) % mod
print((s_ma - s_mi) % mod)
Buggy python submission (verdict: Runtime Error):
k,  x = list(map(int, input().split()))
if 500 * k < x:
    print(“No”)
else:
    print(“Yes”)

Fixed submission:
k,  x = list(map(int, input().split()))
if 500 * k < x:
    print('No')
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
l = list(range(1, n + 1))
ll = list(itertools.permutations(l, n))

for i in ll:
    if i == p:
        p_n = ll.index(i) + 1
    elif i == q:
        q_n = ll.index(i) + 1
ans = abs(p_n - q_n)
print(ans)

Fixed submission:
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
l = list(range(1, n + 1))
ll = list(itertools.permutations(l, n))
if p == q:
    ans = 0
else:
    for i in ll:
        if i == p:
            p_n = ll.index(i) + 1
        elif i == q:
            q_n = ll.index(i) + 1
    ans = abs(p_n - q_n)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b = list(map(int,input().split()))
g = math.gcd(a, b)
print(a * b // g)

Fixed submission:
a, b = list(map(int, input().split()))
def gcd(a, b):
  if a < b:
    a, b = b, a
  else:
    pass
  if a % b == 0:
    return b
  else:
    return gcd(b, a % b)
  
print(a * b // gcd(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
s = set(a)
ans = 0
l = []
for i in s:
  if i in a:
    ans += 1
    f = a.index(i)
    a = a[f:]
    l.append(i)
  else:
    break
ll = list(range(1, ans + 1))
if l == ll:
  ans = n - ans
else:
  ans = -1
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
x = 1
for i in a:
    if i == x:
        x += 1
    else:
        pass
if x == 1:
    print(-1)
else:
    print(n - x + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = list(map(int, input().split()))
a = [int(input()) for _ in range(q)]
s = k - q
if k <= q:
    for i in range(1, n + 1):
        if s + a.count(i) > 0:
            print('Yes')
        else:
            print('No')
else:
    for _ in range(n):
        print('Yes')

Fixed submission:
n, k, q = list(map(int, input().split()))
a = [int(input()) for _ in range(q)]
l = [0] * n
s = k - q
for i in a:
    l[i - 1] += 1
if s <= 0:
    for i in range(n):
        if s + l[i] > 0:
            print('Yes')
        else:
            print('No')
else:
    for _ in range(n):
        print('Yes')
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, imput().split()))
ans = 0
if b == 1:
  print(ans)
else:
  while a < b:
    ans += 1
    a += a
  print(ans)
 
 

Fixed submission:
a, b = list(map(int, input().split()))
ans = 0
count = 1
if b != 1:
    while count < b:
        count += a - 1
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, imput().split()))
ans = 0
if b == 1:
  print(ans)
else:
  while True:
    ans += 1
    a += a
    if a >= b:
      print(ans)
      break:
 
 

Fixed submission:
a, b = list(map(int, input().split()))
ans = 0
count = 1
if b != 1:
    while count < b:
        count += a - 1
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, imput().split()))
ans = 0
count = 1
if b == 1:
  print(ans)
else:
  while True:
    ans += 1
    count += a
    if count >= b:
      print(ans)
      break:
 

Fixed submission:
a, b = list(map(int, input().split()))
ans = 0
count = 1
if b != 1:
    while count < b:
        count += a - 1
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = int(input())
x1 = 10 ** 9
y2 = s // x1
if s % x1 != 0:
    y2 += 1
    y1 = y2 * x1 - s
print(0, 0, x1, y1, 1, y2)

Fixed submission:
s = int(input())
x1 = 10 ** 9
if s < x1:
    print(0, 0, s, 0, 0, 1)
else:
    y2 = s // x1
    if s % x1 == 0:
        print(0, 0, x1, 0, 0, y2)
    else:
        y2 += 1
        y1 = y2 * x1 - s
        print(0, 0, x1, y1, 1, y2)

Buggy python submission (verdict: Runtime Error):
s = int(input())
x1 = 10 ** 9

if s < x1:
    print(0, 0, s, 0, 0, 1)
elif a - int(a) == 0:
    print(0, 0, i, 0, 0, i)
else:
    y2 = s // x1
    if s % x1 == 0:
        print(0, 0, x1, 0, 0, y2)
    else:
        y2 += 1
        y1 = y2 * x1 - s
        print(0, 0, x1, y1, 1, y2)

Fixed submission:
s = int(input())
x1 = 10 ** 9
if s < x1:
    print(0, 0, s, 0, 0, 1)
else:
    y2 = s // x1
    if s % x1 == 0:
        print(0, 0, x1, 0, 0, y2)
    else:
        y2 += 1
        y1 = y2 * x1 - s
        print(0, 0, x1, y1, 1, y2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.appen([s, -int(p), i + 1])

l.sort()
for i in l:
    print(i[2])

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

ans = (a * 3 + p) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.appen([s, -int(p), i + 1])

l.sort()
for i in l:
    print(i[2])

Fixed submission:
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append((s, -int(p), i + 1))

l.sort()
for i in l:
    print(i[2])

Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append[(s, -int(p), i + 1])

l.sort()
for i in l:
    print(i[2])

Fixed submission:
n = int(input())
l = []
for i in range(n):
    s, p = input().split()
    l.append((s, -int(p), i + 1))

l.sort()
for i in l:
    print(i[2])
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [
    b - a, c - a, d - a, e - a, c - b, d - b, e - b, d - c, e - c, e - d
]


for i in l:
    if l[i] > k:
        print(":(")
        break
else:
    print("Yay!")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [
    b - a, c - a, d - a, e - a, c - b, d - b, e - b, d - c, e - c, e - d
]

for i in l:
    if i > k:
        print(":(")
        break
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [
    b - a, c - a, d - a, e - a, c - b, d - b, e - b, d - c, e - c, e - d
]


for i in l:
    if l[i] > k:
        print(":(")
        break
else:
    print("Yay!")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [
    b - a, c - a, d - a, e - a, c - b, d - b, e - b, d - c, e - c, e - d
]

for i in l:
    if i > k:
        print(":(")
        break
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [
    b - a, c - a, d - a, e - a, c - b, d - b, e - b, d - c, e - c, e - d
]


for i in l:
    print(i)
    if l[i] > k:
        print(":(")
        break
else:
    print("Yay!")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [
    b - a, c - a, d - a, e - a, c - b, d - b, e - b, d - c, e - c, e - d
]

for i in l:
    if i > k:
        print(":(")
        break
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [
    b - a, c - a, d - a, e - a, c - b, d - b, e - b, d - c, e - c, e - d
]


for i in l:
    if l[i] > 15:
        print(":(")
        break
else:
    print("Yay!")

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [
    b - a, c - a, d - a, e - a, c - b, d - b, e - b, d - c, e - c, e - d
]

for i in l:
    if i > k:
        print(":(")
        break
else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

l = [a, b, c, d, e]
s = []
for i in l:
    if i % 10 > 0:
        s.append(10 - (i % 10))    
s.sort()
del s[-1]
ans = sum(l) + sum(s)
print(ans)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

l = [a, b, c, d, e]
s = []

for i in l:
    if i % 10 > 0:
        s.append(10 - (i % 10))
if len(s) > 0:
    s.sort()
    del s[-1]

ans = sum(l) + sum(s)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(1,n+1):
	x=math.floor(n/i)
	ans+=(x*(x+1)*i)/2
print(int(ans))

Fixed submission:
import math
n=int(input())
ans=0
for i in range(1,n+1):
	x=math.floor(n/i)
	ans+=(x*(x+1)*i)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
ans=0
for i in range(1,n+1):
	ans+=((math.floor(n/i)*(math.floor(n/i)+1))/2)*i
print(int(ans))

Fixed submission:
import math
n=int(input())
ans=0
for i in range(1,n+1):
	x=math.floor(n/i)
	ans+=(x*(x+1)*i)/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
print(int(360/math.gcd(n,360)))

Fixed submission:
import math
n=int(input())
print(int(360/math.gcd(n,360)))

Buggy python submission (verdict: Runtime Error):
n=int(input())
print(int(360/math.gcd(n,360)))

Fixed submission:
import math
n=int(input())
print(int(360/math.gcd(n,360)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))

Ans = 0

for i in range(len(L)):
    for j in range(i+1,len(L)):
        #print(L[i] * L[j])
        Ans += (L[i] * L[j])%(10**9+7)
        #Ans += L[i] * L[j]
        #if Ans >= 10**9+7:
            #Ans = Ans%(10**9+7)
Ans = Ans%(10**9+7)
print(Ans)

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

Ans = 0

sum_L = L[0]

l = len(L)

for i in L[1:]:
    Ans += sum_L*i%(10**9+7)
    sum_L += i
Ans = Ans%(10**9+7)
print(Ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import itertools
H, W, K = map(int, input().split())
L = np.array([list(input()) for i in range(H)])
Ans = 0
for h in range(H):
    for w in range(W):
        if L[h,w] == '.':
            L[h,w] = '0'
        else:
            L[h,w] = '1'
L = L.astype("int64")

def del_w(w):#w列目
    if w != 0:
        for h1 in range(H):
            L1[h1,w-1] =  0   

def del_h(h):#h行目
    if h != 0:
        for w1 in range(W):
            L1[h-1,w1] =  0
            
H_list = []
for h in range(H+1):
    H_list += list(itertools.combinations(range(1,H+1),h))

W_list = []
for w in range(W+1):
    W_list += list(itertools.combinations(range(1,W+1),w))
    
for h_list in H_list:
    for w_list in W_list:
        
        L1 = L.copy()
        
        for w1 in w_list :
            for h in range(H):
                L1[h,w1-1] =  0
                
        for h1 in h_list :
            for w in range(W):
                L1[h1-1,w] =  0 
                
        if np.sum(L1) == K:
            #print(L1,h_list,w_list)
            Ans += 1
            
print(Ans)

Fixed submission:
import numpy as np
import itertools
H, W, K = map(int, input().split())
L = np.array([list(input()) for i in range(H)])
Ans = 0
for h in range(H):
    for w in range(W):
        if L[h,w] == '.':
            L[h,w] = '0'
        else:
            L[h,w] = '1'
L = L.astype("int64")

def del_w(w):#w列目
    if w != 0:
        for h1 in range(H):
            L1[h1,w-1] =  0   

def del_h(h):#h行目
    if h != 0:
        for w1 in range(W):
            L1[h-1,w1] =  0
            
H_list = []
for h in range(H+1):
    H_list += list(itertools.combinations(range(1,H+1),h))

W_list = []
for w in range(W+1):
    W_list += list(itertools.combinations(range(1,W+1),w))
    
for h_list in H_list:
    for w_list in W_list:
        
        L1 = L.copy()
        
        for w1 in w_list :
            for h in range(H):
                L1[h,w1-1] =  0
                
        for h1 in h_list :
            for w in range(W):
                L1[h1-1,w] =  0 
                
        if np.sum(L1) == K:
            #print(L1,h_list,w_list)
            Ans += 1
            
print(Ans)
Buggy python submission (verdict: Runtime Error):
s = input()
c=0
for i in range(len(s)):
  if s[i] != t[i]:
    c += 1
print(c)

Fixed submission:
s = input()
t = input()
c=0
for i in range(len(s)):
  if s[i] != t[i]:
    c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
L=list(map(int,input().split()))
L = [abs(i - A) for i in L]
L +=[0]
L=sorted(L)
x=0
i,j=0,1
while True:
    if L[i] == x and L[j] == x :
        i,j = i+2,j+2
        x += 1
    else:
        break
print(A+x)

Fixed submission:
L=list(map(int,input().split()))
for i in range(5):
    if L[i] == 0 and i == 0:
        print(L[i+1] - 1)
    elif L[i] == 0 and i != 0:
        print(L[i-1] +1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
 
pn=[2];A=100000
for L in range(3,A):
    chk=True
    for L2 in pn:
        if L%L2 == 0:chk=False
    if chk==True:pn.append(L)
        
A246655 = []
for p in pn:
    pe = p
    while pe < A:
        A246655.append(pe)
        pe *= p
A246655 = sorted(A246655)
 
c=0
for i in range(len(A246655)):
    if N%A246655[i]==0:
        N = N//A246655[i]
        c+=1
print(c)

Fixed submission:
A, B = map(int, input().split())
print(A*B)
Buggy python submission (verdict: Runtime Error):
A,B = input().split()
A = int(A)
C1 = A*int(B[0])
C2 = A*int(B[2])*0.1
C3 = A*int(B[3])*0.01
Ans = C1+C2+C3
#print(C1)
#print(C2)
#print(C3)
Ans = math.floor(Ans)
print(Ans)

Fixed submission:
import math
A,B = input().split()
A = int(A)
C1 = A*int(B[0])*100
C2 = A*int(B[2])*10
C3 = A*int(B[3])
Ans = C1+C2+C3
Ans = math.floor(Ans//100)
print(Ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
def main():
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    A = [int(x) for x in stdin.readline().rstrip().split()]
    K = K % N
    X = 1
    C = 0
    Log = [1]
    while C <= K:
        X = A[X-1]
        C += 1
        if (X in Log) == True:
            break
      
        Log += [X]
    
    K = (K - C)%(C - Log.index(X))
 
    print(Log[Log.index(X)+K])
    
main()

Fixed submission:
from sys import stdin
def main():
    N1 = stdin.readline().rstrip()
    N2 = stdin.readline().rstrip()
    if N1 == N2[:-1]:
        print('Yes')
    else:
        print('No')
    
main()
Buggy python submission (verdict: Runtime Error):
import numpy as np
N=int(input())
A = np.array(list(map(int, input().split())))
X = A+np.arange(N)+1
S = A*(-1)+np.arange(N)+1
Ans=0
for i in range(N):
    Ans += np.count_nonzero(S[i:] == X[i])
print(Ans)

Fixed submission:
S=input()
if S=='ABC':
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
N,K=map(int, input().split())
s=[]
for i in range(K):
    d=int(input())
    for j in range(d):
        s+=[int(input())]
s=set(s)
#print(s)
s=list(s)
#print(s)
s.sort()
#print(s)
print(N-len(s))

Fixed submission:
N,K=map(int, input().split())
s=[]
for i in range(K):
    d=int(input())
    a=list(map(int, input().split()))
    for j in range(len(a)):
        s+=[a[j]]
s=set(s)
#print(s)
s=list(s)
#print(s)
s.sort()
#print(s)
print(N-len(s))

Buggy python submission (verdict: Runtime Error):
N,K=map(int, input().split())
s=[]
for i in range(K):
    d=int(input())
    for j in range(d):
        s+=[int(input())]
s=set(s)
print(N-len(s))

Fixed submission:
N,K=map(int, input().split())
s=[]
for i in range(K):
    d=int(input())
    a=list(map(int, input().split()))
    for j in range(len(a)):
        s+=[a[j]]
s=set(s)
#print(s)
s=list(s)
#print(s)
s.sort()
#print(s)
print(N-len(s))
Buggy python submission (verdict: Time Limit Exceeded):
import math

def gcd3(a,b,c):
    return math.gcd(math.gcd(a,b),c)

K = int(input())

A = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            A += gcd3(i+1, j+1, k+1)

print(A)

Fixed submission:
import math

K = int(input())

A = 0

#3つとも同じ数字
for i in range(K):
    A += i+1
    
#2つ同じ数字
for i in range(K):
    for j in range(K):
        if i > j:
            A += 6*math.gcd(i+1, j+1)

#全部違う数字
for i in range(K):
    for j in range(K):
        for k in range(K):
            if i > j and j > k:
                A += 6*math.gcd(math.gcd(i+1, j+1), k+1)

print(A)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
if N == 0:
    print(0)
else:
    while True:
        if N > K*10000:
            N = N-(K*10000)
        elif N > K*1000:
            N = N-(K*1000)
        elif N > K*100:
            N = N-(K*100)
        else:
            break

    x0 = N #7
    x1 = abs(x0-K) #3
    while True:
        if x0 < x1:
            print(x0)
            break
        else:
            x0,x1 = x1,abs(x0-K)
            continue

Fixed submission:
N,K = map(int, input().split())
if N == 0:
    print(0)
else:
    for i in range(18):
        while True:
            if N > K*10**(18-i):
                N = N-(K*10**(18-i))
            else:
                break

    x0 = N #7
    x1 = abs(x0-K) #3
    while True:
        if x0 < x1:
            print(x0)
            break
        else:
            x0,x1 = x1,abs(x0-K)
            continue

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
x0 = N #7
x1 = abs(x0-K) #3
while True:
    if x0 < x1:
        print(x0)
        break
    else:
        x0,x1 = x1,abs(x0-K)
        continue

Fixed submission:
N,K = map(int, input().split())
if N == 0:
    print(0)
else:
    for i in range(18):
        while True:
            if N > K*10**(18-i):
                N = N-(K*10**(18-i))
            else:
                break

    x0 = N #7
    x1 = abs(x0-K) #3
    while True:
        if x0 < x1:
            print(x0)
            break
        else:
            x0,x1 = x1,abs(x0-K)
            continue
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
A = input().split()
for i in range(N):
    A[i] = int(A[i])
#print(A)
for i in range(N):
    B = A.copy()
    del B[i]
    #print(B)
    C = collections.Counter(B)
    #print(C)
    D = list(C.values())
    #print(D)
    E=0
    for j in range(len(D)):
        E+=int(D[j]*(D[j]-1)/2)
    print(E)

Fixed submission:
N, M = map(int, input().split())
print(int(N*(N-1)/2+M*(M-1)/2))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
i=0
while True:
    if K**i<N<K**(i+1):
        break
    else:
        i+=1
print(i+1)

Fixed submission:
import math
N,K=map(int,input().split())
A=math.log(N,K)
print(int(A)+1)
Buggy python submission (verdict: Runtime Error):
N,K=map(int, input().split())
A = list(map(int, input().split()))
B=0
for i in range(N-K+1):
    S = (sum(A[i:i+K])+K)/2
    if B<S:
        B=S
print(B)

Fixed submission:
S,T=input().split()
A,B=map(int, input().split())
U=input()
if U==S:
    A -= 1
else:
    B -= 1
print(A,B)