Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
def gcd(a,b,c):
    a = math.gcd(a, b)
    a = math.gcd(a, c)
    return a

ans=0
K=int(input())
for i in range(1,K+1): 
    for j in range(1,K+1):
        for k in range(1, K+1):
            ans+=gcd(i,j,k)

print(ans)

Fixed submission:
import math
def gcd(a,b,c):
    a = math.gcd(a, b)
    a = math.gcd(a, c)
    return a

ans=0
K=int(input())
for i in range(1,K+1): 
    for j in range(1,K+1):
        for k in range(1, K+1):
            ans+=gcd(i,j,k)

print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(N,2)+combinations_count(M,2))

Fixed submission:
N,M=map(int,input().split())
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

if N>=2:
    a=combinations_count(N,2)
else:
    a=0
if M>=2:
    b=combinations_count(M,2)
else:
    b=0
print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

from collections import Counter
AC=Counter(A)

for a in A:
    ACT=AC.copy()
    ACT[a]-=1
    print(int(sum(map(lambda x: x*(x-1)/2, ACT.values()))))

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

from collections import Counter
AC=Counter(A)
ans=int(sum(map(lambda x: x*(x-1)/2, AC.values())))
for a in A:
    print(max(ans-AC[a]+1,0))
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a + b >=  c:
  print(b + c)
else:
  print(c + b - 1)
a, b, c = map(int, input().split())
if a + b >=  c:
  print(b + c)
else:
  print(b + 2 * c + 1)

Fixed submission:
a, b, c = map(int, input().split())
if a + b >=  c:
  print(b + c)
else:
  print(a + b * 2 + 1)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
    if a == b:
        print("Draw")
    elif a == 1:
        print("Alice")
    elif b == 1:
        print("Bob")
    elif a > b:
        print("Alice")
    else:
        print("Bob")

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

if a == b:
    print("Draw")
elif a == 1:
    print("Alice")
elif b == 1:
    print("Bob")
elif a > b:
    print("Alice")
else:
    print("Bob")
Buggy python submission (verdict: Runtime Error):
num = int(input())
div_sum = defaultdict(int)

p = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]

for j in range(1, num + 1):

    div_num = defaultdict(int)

    for i in p:
        n = j
        while n % i == 0:
            div_num[i] += 1
            n //= i

    for k, v in div_num.items():
        div_sum[k] += v

ans = 1
for k, v in div_sum.items():
    ans *= (v + 1)
print(ans % (10**9 + 7))


Fixed submission:
import math
from collections import defaultdict


def make_prime_list(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num+1, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]


num = int(input())
div_sum = defaultdict(int)

p = make_prime_list(num)
for j in range(2, num+1):

    div_num = defaultdict(int)

    for i in p:
        n = j
        while n % i == 0:
            div_num[i] += 1
            n //= i

    for k, v in div_num.items():
        div_sum[k] += v

ans = 1
for k, v in div_sum.items():
    ans *= (v + 1)
print(ans % (10**9 + 7))
Buggy python submission (verdict: Runtime Error):
s = input()
print(s.replace(',', ' ')

Fixed submission:
print(input().replace(',', ' '))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8

a, op, b = input().split()
if op == '+':
    print(a + b)
else:
    print(a - b)

Fixed submission:
# -*- coding: utf-8

a, op, b = input().split()
if op == '+':
    print(int(a) + int(b))
else:
    print(int(a) - int(b))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8

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

for i in range(int(input())):
    p, x = map(int, input().split())
    print(sum(t) - t[p] + x)

Fixed submission:
# -*- coding: utf-8

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

for i in range(int(input())):
    p, x = map(int, input().split())
    print(sum(t) - t[p- 1] + x)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8

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

for i in range(int(input())):
    p, x = map(int, input().split())
    print(sum(t) - t[p] + x)

Fixed submission:
# -*- coding: utf-8

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

for i in range(int(input())):
    p, x = map(int, input().split())
    print(sum(t) - t[p- 1] + x)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8

n, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0

if a[0] > x:
    count += a[0] - x
    a[0] = x


for i in range(len(a) - 1):

    while a[i] + a[i + 1] > x:
        a[i + 1] -= 1
        count += 1
print(count)


Fixed submission:
# -*- coding: utf-8

n, x = map(int, input().split())
a = list(map(int, input().split()))

count = max(0, a[0] - x)
a[0] = min(a[0], x)

for i in range(len(a) - 1):
    if a[i] + a[i + 1] > x:
        tmp_num = max(0, a[i] + a[i + 1] - x)
        count += tmp_num
        a[i + 1] -= tmp_num
print(count)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8

import sys


def leftside_reverse(s, turn):
    for num in range(len(s)):
        if s[num] == turn:
            break
        else:
            s[num] = turn

    return s


def rightside_reverse(s, turn):
    for num in range(len(s) - 1, -1):
        if s[num] == turn:
            break
        else:
            s[num] = turn

    return s


def function(s, first):
    count = 0
    turn = first

    while True:

        if s.count(first) == len(s):
            break

        if s[0] == turn:
            s = rightside_reverse(s, turn)
            count += 1
        else:
            s = leftside_reverse(s, turn)
            count += 1

        if turn == 'B':
            turn = 'W'
        else:
            turn = 'B'

    return count


if __name__ == '__main__':

    s = list(input())
    b = 'B'
    w = 'W'

    if s.count(b) == len(s) or s.count(w) == len(s):
        print('0')
        sys.exit(1)

    b_count = function(s, b)
    w_count = function(s, w)

    print(min(b_count, w_count))


Fixed submission:
# -*- coding: utf-8

s = list(input())
count = 0

if s.count('W') == len(s) or s.count('B') == len(s):
    print('0')
else:
    turn = s[len(s) - 1]
    s.pop()
    while s:
        if s[len(s) - 1] == turn:
            s.pop()
        else:
            count += 1
            if turn == 'B':
                turn = 'W'
            else:
                turn = 'B'
    print(count)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8

import sys


def leftside_reverse(s, turn):
    for num in len(s):
        if s[num] == turn:
            return s
        else:
            s[num] = turn

    return s


def rightside_reverse(s, turn):
    for num in range(len(s), 0, -1):
        if s[num] == turn:
            return s
        else:
            s[num] = turn

    return s


def function(s, turn):
    count = 0

    while True:
        if s.count(turn) == len(s):
            return count

        if s[0] == turn:
            s = leftside_reverse(s, turn)
            count += 1
        else:
            s = rightside_reverse(s, turn)
            count += 1

        if turn == b:
            turn = w
        else:
            turn = b


if __name__ == '__main__':

    s = list(input())
    b = 'B'
    w = 'W'

    if s.count(b) == len(s) or s.count(w) == len(s):
        print('0')
        sys.exit(1)

    b_count = function(s, b)
    w_count = function(s, w)

    print(min(b_count, w_count))


Fixed submission:
# -*- coding: utf-8

s = list(input())
count = 0

if s.count('W') == len(s) or s.count('B') == len(s):
    print('0')
else:
    turn = s[len(s) - 1]
    s.pop()
    while s:
        if s[len(s) - 1] == turn:
            s.pop()
        else:
            count += 1
            if turn == 'B':
                turn = 'W'
            else:
                turn = 'B'
    print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input))
print((n + 1)*n/2)

Fixed submission:
n = int(input())
print(int((n+1)*n/2))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

s = list(input())
line = []
for w in s:
    if w == '0':
        line.append(w)
    elif w == '1':
        line.append(w)
    elif w == 'B':
        line.pop()

for n in line:
    print('{0}'.format(n), end='')

Fixed submission:
# -*- coding: utf-8 -*-

s = list(input())
line = []
for w in s:
    if w == '0':
        line.append(w)
    elif w == '1':
        line.append(w)
    elif w == 'B' and line:
        line.pop()

for n in line:
    print('{0}'.format(n), end='')

Buggy python submission (verdict: Runtime Error):
s = list(input())
line = []
for w in s:
  if w == '0':
    line.append(w)
  elif w == '1':
    line.append(w)
  elif w == 'B':
    line.pop()
    
for n in line:
  print('{0}'.format(n), end='')
      

Fixed submission:
# -*- coding: utf-8 -*-

s = list(input())
line = []
for w in s:
    if w == '0':
        line.append(w)
    elif w == '1':
        line.append(w)
    elif w == 'B' and line:
        line.pop()

for n in line:
    print('{0}'.format(n), end='')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ali = list(map(int, input().split()))
q = int(input())

opelates = []
for _ in range(q):
    opelates.append(list(map(int, input().split())))

for op in opelates:
    pre = op[0]
    nex = op[1]
    for i in range(n):
        if ali[i] == pre:
            ali[i] = nex
    print(sum(ali))

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

opelates = []
for _ in range(q):
    opelates.append(list(map(int, input().split())))

numCntList = [0 for _ in range(10**5+1)]
for num in ali:
    numCntList[num] += 1
total = sum(ali)

for op in opelates:
    pre = op[0]
    nex = op[1]
    preCnt = numCntList[pre]
    if preCnt >= 1:
        numCntList[pre] = 0
        numCntList[nex] += preCnt
        total += (nex-pre)*preCnt
    print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ali = list(map(int, input().split()))

for i in range(n):
    ans = 0
    for j in range(n):
        if i==j:
            continue
        ans = ans^ali[j]
    
    if i != (n-1):
        print(ans, end=" ")
    else:
        print(ans)

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

allxor = 0
for ai in ali:
    allxor = allxor ^ ai

for i in range(n):
    ans = allxor ^ ali[i]
    
    if i != (n-1):
        print(ans, end=" ")
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
lp = list(map(int, input().split()))

lp.sort()

distance = 0
try:
    idx = lp.index(x)
    while True:
        distance += 1
        dmin = x-distance
        dmax = x+distance
        if dmin != lp[idx-distance]:
            print(dmin)
            exit()
        if dmax != lp[idx+distance]:
            print(dmax)
            exit()
except ValueError:
    print(x)
    exit()

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

lp.sort()

distance = 0
try:
    idx = lp.index(x)
    while True:
        distance += 1
        dmin = x-distance
        dmax = x+distance
        if (idx-distance) < 0 or dmin != lp[idx-distance]:
            print(dmin)
            exit()
        if (idx+distance) >= len(lp) or  dmax != lp[idx+distance]:
            print(dmax)
            exit()
except ValueError:
    print(x)
    exit()
Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if (a*b) >= 1:
    child = abs(b-a)
else:
    child = abs(a) + abs(b)

try:
    n = child/(v-w)
except ZeroDivisionError:
    n = -1
if n.is_integer() and n>=0 and n <= t:
    print("YES")
else:
    print("NO")

Fixed submission:
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())


if (a*b) < 0:
    child = max(a,b) - min(a,b)
else:
    child = abs(b-a)

mother = v-w
if mother <= 0:
    print('NO')
    exit()

n = child/mother
if n>0 and n<=t:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = input()

nums = list(map(int, input().split()))

MAX = 10**18

ans = 1
for num in nums:
    ans = ans*num

if ans > MAX:
    print(-1)
else:
    print(ans)

Fixed submission:
n = input()
 
nums = list(map(int, input().split()))
 
MAX = 10**18

if min(nums) == 0:
    print(0)
    exit()

ans = 1
for num in nums:
    ans = ans*num 
    if ans > MAX:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):

roomNum, aisleNum = map(int, input().split())
aisles = [ list(map(int, input().split())) for _ in range(aisleNum) ]

aisleTree = [ [] for _ in range(aisleNum+1) ]

for roomA, roomB in aisles:
    aisleTree[roomA].append(roomB)
    aisleTree[roomB].append(roomA)

from collections import deque
que = deque()
distanceFromRoom1 = [-1] * (roomNum+1)
distanceFromRoom1[0] = 0
distanceFromRoom1[1] = 0
for room in aisleTree[1]:
    que.append(room)
    distanceFromRoom1[room] = 1

while que:
    room = que.popleft()
    dist = distanceFromRoom1[room]
    for nextRoom in aisleTree[room]:
        if distanceFromRoom1[nextRoom] == -1:
            que.append(nextRoom)
            distanceFromRoom1[nextRoom] = room

if min(distanceFromRoom1) == -1:
    print('No')
else:
    print('Yes')
    for ans in distanceFromRoom1[2:]:
        print(ans)

Fixed submission:

roomNum, aisleNum = map(int, input().split())
aisles = [ list(map(int, input().split())) for _ in range(aisleNum) ]

aisleTree = [ [] for _ in range(roomNum+1) ]

for roomA, roomB in aisles:
    aisleTree[roomA].append(roomB)
    aisleTree[roomB].append(roomA)

from collections import deque
que = deque()
distanceFromRoom1 = [-1] * (roomNum+1)
distanceFromRoom1[0] = 0
distanceFromRoom1[1] = 0
for room in aisleTree[1]:
    que.append(room)
    distanceFromRoom1[room] = 1

while que:
    room = que.popleft()
    dist = distanceFromRoom1[room]
    for nextRoom in aisleTree[room]:
        if distanceFromRoom1[nextRoom] == -1:
            que.append(nextRoom)
            distanceFromRoom1[nextRoom] = room

if min(distanceFromRoom1) == -1:
    print('No')
else:
    print('Yes')
    for ans in distanceFromRoom1[2:]:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):


k = int(input())

def calcGcd(p, q):
    if p % q == 0:
        return q
    return calcGcd(q, p%q)

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += calcGcd(calcGcd(a, b), c)

print(ans)

Fixed submission:
from math import gcd

k = int(input())


ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(gcd(a, b), c)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):


n = int(input())
_MAX = 200

gcd_result = [ [ [ 0 for _ in range(_MAX+1)] for _ in range(_MAX+1)] for _ in range(_MAX+1) ]

ans = 0


from functools import lru_cache
from math import gcd

@lru_cache(maxsize=1000)
def calc(lst):
    p = 0
    for v in lst:
        if p == 0:
            p = v
        else:
            p = gcd(p, v)

    return p


for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            ls = [i, j, k]
            ans += calc(tuple(set(ls)))

print(ans)

Fixed submission:
from math import gcd

k = int(input())


ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += gcd(gcd(a, b), c)

print(ans)
Buggy python submission (verdict: Runtime Error):


n, k = map(int, input().split())

ans = n % abs(n-k)

ans = min(ans, n, k)

if ans == 1 and k == 1:
    print(0)
else:
    print(ans)

Fixed submission:
import math

n, k = map(int, input().split())

ansa = n % k
ansb = abs(ansa - k)

ans = min(ansa, ansb)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):


s = input()
queNum = int(input())

for _ in range(queNum):
    query = input()

    if query == '1':
        s = s[::-1]
    else:
        num, fi, ci = query.split()
        if fi == '1':
            s = ci + s
        else:
            s = s + ci
    
print(s)

Fixed submission:


s = input()
queNum = int(input())


reverse_cnt = 0
begin_lst = []
end_lst = []
for _ in range(queNum):
    query = input()

    if query == '1':
        reverse_cnt += 1
        begin_lst, end_lst = end_lst, begin_lst
    else:
        num, fi, ci = query.split()
        if fi == '1':
            begin_lst.append(ci)
        else:
            end_lst.append(ci)
    
if reverse_cnt % 2 == 0:
    pass
else:
    s = s[::-1]

print(''.join(reversed(begin_lst)) + s + ''.join(end_lst))
Buggy python submission (verdict: Time Limit Exceeded):



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


dices = list(map(int, input().split()))

# 制約より
MAX_DICE = 1000*K

# 0-K番目を初期としてK個の値が最大になる範囲を探す
pos = 0
maxpos = pos
maxvalue = sum(dices[maxpos:maxpos+K])

for pos in range(1, N-K+1):
    if sum(dices[pos:pos+K]) > maxvalue:
        maxpos = pos
        maxvalue = sum(dices[pos:pos+K])

        # 上限
        if maxvalue == MAX_DICE:
            break

# 期待値を合計する
ans = 0
for dice in dices[maxpos:maxpos+K]:
    ans += (dice+1)/2


print(ans)

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


# ruisekiwa
ruiseki = [0] * (n+1)

for i, x in enumerate(ary):
    ruiseki[i+1] = ruiseki[i] + x

kmax = 0
for i in range(n+1-k):
    ksum = ruiseki[i+k] - ruiseki[i]
    kmax = max(kmax, ksum)

print((kmax+k) / 2)

Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())


dices = list(map(int, input().split()))

# 制約より
MAX_DICE = 1000*K

# 0-K番目を初期としてK個の値が最大になる範囲を探す
pos = 0
maxpos = pos
maxvalue = sum(dices[maxpos:maxpos+K])

for pos in range(1, N-K+1):
    if sum(dices[pos:pos+K]) > maxvalue):
        maxpos = pos
        maxvalue = sum(dices[pos:pos+K])

        # 上限
        if maxvalue == MAX_DICE:
            break

# 期待値を合計する
ans = 0
for dice in dices[maxpos:maxpos+K]:
    ans += (dice+1)/2


print(ans)

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


# ruisekiwa
ruiseki = [0] * (n+1)

for i, x in enumerate(ary):
    ruiseki[i+1] = ruiseki[i] + x

kmax = 0
for i in range(n+1-k):
    ksum = ruiseki[i+k] - ruiseki[i]
    kmax = max(kmax, ksum)

print((kmax+k) / 2)

Buggy python submission (verdict: Time Limit Exceeded):



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


dices = list(map(int, input().split()))


# 0-K番目を初期としてK個の値が最大になる範囲を探す
pos = 0
maxpos = pos

for pos in range(1, N-K+1):
    if sum(dices[pos:pos+K]) > sum(dices[maxpos:maxpos+K]):
        maxpos = pos


# 期待値を合計する
ans = 0
for dice in dices[maxpos:maxpos+K]:
    ans += (dice+1)/2


print(ans)

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


# ruisekiwa
ruiseki = [0] * (n+1)

for i, x in enumerate(ary):
    ruiseki[i+1] = ruiseki[i] + x

kmax = 0
for i in range(n+1-k):
    ksum = ruiseki[i+k] - ruiseki[i]
    kmax = max(kmax, ksum)

print((kmax+k) / 2)
Buggy python submission (verdict: Time Limit Exceeded):
H = int(input())

lst = [0]
for i in range(1, 10**12):
    if i == 1:
        lst.append(1)
    else:
        tmp = lst[i//2]*2 + 1
        lst.append( tmp )
    
    if i == H:
        print(lst[i])
        exit()

Fixed submission:
H = int(input())

ans = 1

if H == 1:
    print(1)
    exit()

while True:
    tmp = ans*2 + 1
    if H > ans and H <= tmp:
        print(tmp)
        exit()
    else:
        ans = tmp
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0

N = N - int(str(N)[-1])

while True:
    if N < 10:
        break
    ans += str(N).count('0')
    N = N-10

print(ans)

Fixed submission:
N = int(input())

if N%2 != 0:
    print(0)
    exit()

ans = 0

denom = 10
while True:
    if denom > N:
        break

    ans += N//denom
    denom = denom*5

print(ans)

Buggy python submission (verdict: Runtime Error):

N = int(input())

def func(num):
    if num < 2:
        return 1
    else:
        return num * func(num-2)

res = func(N)

ans = 0
while True:
    if res % 10 == 0:
        ans += 1
        res = res//10
    else:
        break
print(ans)

Fixed submission:
N = int(input())

if N%2 != 0:
    print(0)
    exit()

ans = 0

denom = 10
while True:
    if denom > N:
        break

    ans += N//denom
    denom = denom*5

print(ans)
Buggy python submission (verdict: Runtime Error):
X = int(input().split())
N = int(X[0])
K = int(X[1])
S = list(str(input()))

if S[K]=="A":
    S[K] = "a"
elif S[K]=="B":
    S[K] = "b"
elif S[K]=="C":
    S[K] = "c"
for i in S:
  print(i, end ="")

Fixed submission:
X = input().split()
N = int(X[0])
K = int(X[1]) - 1
S = list(str(input()))

if S[K]=="A":
    S[K] = "a"
elif S[K]=="B":
    S[K] = "b"
elif S[K]=="C":
    S[K] = "c"
for i in S:
  print(i, end ="")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(str(input()))
K = int(input())

SK = str(S[K])
for i in range(0,N):
    if S[i] == SK:
        pass
    else:
        S[i] = '*'
print(S, end="")

Fixed submission:
x = input().split()
A = int(x[0])
B = int(x[1])
C = int(x[2])

if A < B:
    if C in range(A, B):
        print("Yes")
    else:
        print("No")
else:
    if C in range(B, A):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(str(input()))
K = int(input())

SK = str(S[K])
for i in range(0,N):
    if S[i] == SK:
        pass
    else:
        S[i] = '*'
print(S, end="")

Fixed submission:
N = int(input())
S = list(str(input()))
K = int(input())

SK = str(S[K-1])
for i in range(0,N):
    if S[i] == SK:
        pass
    else:
        S[i] = '*'
for j in S:
  print(j, end ="")

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(str(input()))
K = int(input())

SK = str(S[K])
for i in range(0,N):
    if S[i] == SK:
        pass
    else:
        S[i] = '*'
print(*S)

Fixed submission:
N = int(input())
S = list(str(input()))
K = int(input())

SK = str(S[K-1])
for i in range(0,N):
    if S[i] == SK:
        pass
    else:
        S[i] = '*'
for j in S:
  print(j, end ="")
Buggy python submission (verdict: Runtime Error):
a = input().split()
b = int(d[0])
c = int(d[1])
if b > c:
	first = b
    b = b - 1
else:
	first = c
	c = c - 1
if b > c:
	second = b
else:
	second = c
answer = first + second
print(str(answer))


Fixed submission:
a = input().split()
b = int(a[0])
c = int(a[1])
if b > c:
	first = b
	b = b-1
else:
	first = c
	c = c-1
if b > c:
	second = b
else:
	second = c
answer = first + second
print(str(answer))
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC=[list(map(int,input().split())) for _ in range(Q)]

cnt=[0]*(10**5)
for a in A:
  cnt[a]+=1
total=sum(A)
for b,c in BC:
  total+=c*cnt[b]
  total-=b*cnt[b]
  cnt[c]+=cnt[b]
  cnt[b]=0
  print(total)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
Q=int(input())
BC=[list(map(int,input().split())) for _ in range(Q)]

cnt=[0]*(10**5+1)
for a in A:
  cnt[a]+=1
total=sum(A)
for b,c in BC:
  total+=(c-b)*cnt[b]
  cnt[c]+=cnt[b]
  cnt[b]=0
  print(total)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

for n in range(N):
  print(A.count(n+1))

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

ans = [0]*n
for a in A:
  ans[a-1]+=1
for a in ans:
  print(a)