Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s=input()
for i in range(len(s)):
    if i>=1:
        if s[i]==s[i-1]:
            print(i-1 + ' ' + i)
            exit()
    if i>=2:
        if s[i]==s[i-2]:
            print(i-2 + ' ' + i)
            exit()
print(-1 -1)

Fixed submission:
s=input()
for i in range(len(s)):
    if i>=1:
        if s[i]==s[i-1]:
            print(i, i+1)
            exit()
    if i>=2:
        if s[i]==s[i-2]:
            print(i-1, i+1)
            exit()
print(-1, -1)

Buggy python submission (verdict: Runtime Error):
s=input()
'''
- aa
- aba
'''
for i in range(len(s)):
    if i>=1:
        if s[i]==s[i-1]:
            print(i-1 + ' ' + i)
            exit()
    if i>=2:
        if s[i]==s[i-2]:
            print(i-2 + ' ' + i)
            exit()
print(-1 -1)

Fixed submission:
s=input()
for i in range(len(s)):
    if i>=1:
        if s[i]==s[i-1]:
            print(i, i+1)
            exit()
    if i>=2:
        if s[i]==s[i-2]:
            print(i-1, i+1)
            exit()
print(-1, -1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
mod = 10**9 + 7

if n == 1:
    print(0)
    exit()

dp = [[0]*4 for _ in range(n+1)]

dp[2][0] = 64
dp[2][1] = 17
dp[2][2] = 17
dp[2][3] = 2
for i in range(2, n):
    dp[i+1][3] = ((dp[i][1] + dp[i][2]) % mod + dp[i][3]*10 % mod) % mod

    dp[i+1][1] = (dp[i][0] + dp[i][1]*9 % mod) % mod

    dp[i+1][2] = (dp[i][0] + dp[i][2]*9 % mod) % mod

    dp[i+1][0] = (dp[i][0]*8) % mod
print(dp[n][3])

Fixed submission:
n = int(input())
mod = 10**9 + 7

if n == 1:
    print(0)
    exit()

dp = [[0]*4 for _ in range(n+1)]

dp[2][0] = 64
dp[2][1] = 17
dp[2][2] = 17
dp[2][3] = 2
for i in range(2, n):
    dp[i+1][3] = ((dp[i][1] + dp[i][2]) % mod + dp[i][3]*10 % mod) % mod

    dp[i+1][1] = (dp[i][0] + dp[i][1]*9 % mod) % mod

    dp[i+1][2] = (dp[i][0] + dp[i][2]*9 % mod) % mod

    dp[i+1][0] = (dp[i][0]*8) % mod
print(dp[n][3])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
d = deque()
max_res = -float("inf")
for start in range(n):
    d.append(start)
    count = 0
    res = 0
    while count < k:
        now = d.pop()
        next = p[now]
        d.append(next-1)
        res += c[next-1]
        max_res = max(res, max_res)
        count += 1
print(max_res)


Fixed submission:
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

if max(c) < 0:
    print(max(c))
    exit()

loop_list = []
visited = [False]*n
d = deque()
for start in range(n):
    if visited[start]:
        continue
    loop = [start]
    d.append(start)
    visited[start] = True
    while True:
        now = d.pop()
        next = p[now]
        d.append(next-1)
        if visited[next-1]:
            loop_list.append(loop)
            break
        else:
            visited[next-1] = True
            loop.append(next-1)
#print(loop_list)

ans = 0
for loop in loop_list:
    len_loop = len(loop)
    S = sum(c[v] for v in loop)
    for a in range(len_loop):
        dist_ab = 0
        cost_ab = -c[loop[a]]
        for b in range(a, a+len_loop):
            b %= len_loop
            cost_ab += c[loop[b]]
            max_cost = cost_ab + max(0, S)*((k-dist_ab)//len_loop)
            ans = max(ans, max_cost)
            dist_ab += 1
            if dist_ab > k:
                break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
d = deque()
max_res = -float("inf")
for start in range(n):
    d.append(start)
    count = 0
    res = 0
    while count < k:
        now = d.pop()
        next = p[now]
        d.append(next-1)
        res += c[next-1]
        max_res = max(res, max_res)
        count += 1
print(max_res)


Fixed submission:
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))

if max(c) < 0:
    print(max(c))
    exit()

loop_list = []
visited = [False]*n
d = deque()
for start in range(n):
    if visited[start]:
        continue
    loop = [start]
    d.append(start)
    visited[start] = True
    while True:
        now = d.pop()
        next = p[now]
        d.append(next-1)
        if visited[next-1]:
            loop_list.append(loop)
            break
        else:
            visited[next-1] = True
            loop.append(next-1)
#print(loop_list)

ans = 0
for loop in loop_list:
    len_loop = len(loop)
    S = sum(c[v] for v in loop)
    for a in range(len_loop):
        dist_ab = 0
        cost_ab = -c[loop[a]]
        for b in range(a, a+len_loop):
            b %= len_loop
            cost_ab += c[loop[b]]
            max_cost = cost_ab + max(0, S)*((k-dist_ab)//len_loop)
            ans = max(ans, max_cost)
            dist_ab += 1
            if dist_ab > k:
                break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
k_str = str(k)

if k % 2 == 0 or k % 5 == 0:
    print(-1)
else:
    seven = 7
    seven_str = "7"
    while int(seven_str) % k != 0:
        seven_str += "7"
    print(len(seven_str))


Fixed submission:
k = int(input())
count = 1
x = 7
while x % k != 0 and count <= k:
    count += 1
    x = (10 * x + 7) % k

if x % k == 0:
    print(count)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c = map(int, input().split())
k = int(input())
flag = False
if a < b < c:
    flag = True
count = 0
while count < k and not (a < b < c):
    if a > b:
        count += 1
        b = 2*b
    if b > c:
        count += 1
        c = 2*c

if count <= k:
    if a < b < c:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

count = 0
while count < k and not (a < b < c):
    if a >= b:
        count += 1
        b = 2*b
    if b >= c:
        count += 1
        c = 2*c

if count <= k:
    if a < b < c:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c = map(int, input().split())
k = int(input())
flag = False
if a < b < c:
    flag = True
count = 0
if not flag:
    while count < k:

        if a > b:
            count += 1
            b = 2*b
        if b > c:
            count += 1
            c = 2*c

if count <= k:
    if a < b < c:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

count = 0
while count < k and not (a < b < c):
    if a >= b:
        count += 1
        b = 2*b
    if b >= c:
        count += 1
        c = 2*c

if count <= k:
    if a < b < c:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

hyouten = [1]*n
hyouten[0] = a[0]
for i in range(1, n):
    hyouten[i] = hyouten[i-1]*a[i]
#print(hyouten)
for i in range(k+1, n+1):
    hyouten[i-1] //= hyouten[i-k-1]
    if hyouten[i-1] > hyouten[i-2]:
        print("Yes")
    else:
        print("No")
#print(hyouten)

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

for i in range(k+1, n+1):
    if a[i-1] > a[i-k-1]:
        print("Yes")
    else:
        print("No")

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

hyouten = [0]*n
hyouten[k-1] = 1
for i in range(k):
    hyouten[k-1] *= a[i]
#print(hyouten[k-1])
for i in range(k+1, n+1):
    hyouten[i-1] = hyouten[i-2]//a[i-k-1]
    hyouten[i-1] = hyouten[i-1]*a[i-1]
    if hyouten[i-1] > hyouten[i-2]:
        print("Yes")
    else:
        print("No")
#print(hyouten)

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

for i in range(k+1, n+1):
    if a[i-1] > a[i-k-1]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


#nの約数列挙
def divisor(n):
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass  # sortされていない


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

a.sort()
a_max = a[-1]
div = [0]*(a_max+1)
c = Counter(a)
#print(c)
count = 0
already = []
for i in range(n):
    if c[a[i]] != 1:
        div[a[i]] = 1
        continue
    div_a = divisor(a[i])
    for j in div_a:
        if div[j] == 1:
            break
    else:
        count += 1
        div[a[i]] = 1

print(count)

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

a.sort()
a_max = a[-1]
ban = [0]*(a_max+1)

count = 0
for i in range(n):
    if ban[a[i]]:
        continue
    else:
        if i == n-1 or a[i+1] != a[i]:
            count += 1
        x = a[i]
        while x <= a_max:
            ban[x] = 1
            x += a[i]
#print(ban)
print(count)

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


#nの約数列挙
def divisor(n):
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass  # sortされていない


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

a.sort()
a_max = a[-1]
div = [0]*(a_max+1)
c = Counter(a)
#print(c)
count = 0
already = []
for i in range(n):
    if c[a[i]] != 1:
        div[a[i]] = 1
        continue
    div_a = divisor(a[i])
    for j in div_a:
        if div[j] == 1:
            break
    else:
        count += 1
        div[a[i]] = 1

print(count)


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

a.sort()
a_max = a[-1]
ban = [0]*(a_max+1)

count = 0
for i in range(n):
    if ban[a[i]]:
        continue
    else:
        if i == n-1 or a[i+1] != a[i]:
            count += 1
        x = a[i]
        while x <= a_max:
            ban[x] = 1
            x += a[i]
#print(ban)
print(count)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
path = []
path.append(1)
x = a[0]
path.append(x)
for i in range(n-2):
    x = a[x-1]
    path.append(x)
#print(path)
c = Counter(path)
roop1 = 0
for key, v in c.items():
    if v == 2:
        roop1 = key
if roop1 == 0:
    roop1 = 1
roopidx = path.index(roop1)
roopidx2 = path.index(roop1, roopidx+1)
#print(roopidx,roopidx2)
k_mod = (k-roopidx) % (roopidx2-roopidx)
print(path[roopidx+k_mod])


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
path = []
x = 1
path.append(x)
for i in range(n):
    x = a[x-1]
    path.append(x)
#print(path)
count = [0]*n
roop_st = 0
roop_len = 0
for town in path:
    count[town-1] += 1
    if count[town-1] == 2:
        roop_st = town
        break
roop_st_idx = path.index(roop_st)
roop_fin_idx = path.index(roop_st, roop_st_idx+1)
#print(roop_st_idx, roop_fin_idx)
if k >= roop_st_idx:
    k_mod = (k - roop_st_idx) % (roop_fin_idx - roop_st_idx)
    print(path[roop_st_idx + k_mod])
else:
    print(path[k])

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
path = []
path.append(1)
x = a[0]
path.append(x)
for i in range(n-2):
    x = a[x-1]
    path.append(x)
print(path)
c = Counter(path)
roop1 = 0
for k, v in c.items():
    if v == 2:
        roop1 = k
if roop1 == 0:
    roop1 = 1
roopidx = path.index(roop1)
roopidx2 = path.index(roop1, roopidx+1)
print(roopidx,roopidx2)
k_mod = (k-roopidx) % (roopidx2-roopidx)
print(path[k_mod+roopidx-1])


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
path = []
x = 1
path.append(x)
for i in range(n):
    x = a[x-1]
    path.append(x)
#print(path)
count = [0]*n
roop_st = 0
roop_len = 0
for town in path:
    count[town-1] += 1
    if count[town-1] == 2:
        roop_st = town
        break
roop_st_idx = path.index(roop_st)
roop_fin_idx = path.index(roop_st, roop_st_idx+1)
#print(roop_st_idx, roop_fin_idx)
if k >= roop_st_idx:
    k_mod = (k - roop_st_idx) % (roop_fin_idx - roop_st_idx)
    print(path[roop_st_idx + k_mod])
else:
    print(path[k])
Buggy python submission (verdict: Time Limit Exceeded):
n, m, K = map(int, input().split())
mod = 998244353


def comb(n, r):
    res = 1
    for i in range(1, r+1):
        res = res*(n-i+1) % mod
        res = res*pow(i, mod-2, mod) % mod
    return res


def paint(k):
    res = (m * comb(n-1, k) % mod) * pow(m-1, n-1-k, mod)
    res % mod
    return res

ans = 0
for k in range(K+1):
    ans += paint(k)
    ans %= mod
print(ans)

Fixed submission:
n, m, K = map(int, input().split())
mod = 998244353

fac = [1] * (n + 1)
inv = [1] * (n + 1)

for j in range(1, n + 1):
    fac[j] = fac[j - 1] * j % mod

inv[n] = pow(fac[n], mod - 2, mod)
for j in range(n - 1, -1, -1):
    inv[j] = inv[j + 1] * (j + 1) % mod


def comb(n, r):
    if r > n or n < 0 or r < 0:
        return 0
    return fac[n] * inv[n - r] * inv[r] % mod


def paint(k):
    res = (m * comb(n-1, k)) % mod * pow(m-1, n-1-k, mod)
    res %= mod
    return res

ans = 0
for k in range(K+1):
    ans += paint(k)
    ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

def divisor(n):
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass  # sortされていない


x_li = divisor(x)
x_li.sort()
#print(x_li)
for i in range(len(x_li)):
    for j in range(x_li[i]+1):
        a = j
        b = a - x_li[i]
        if a**5 - b**5 == x:
            print(a, b)
            break
    else:
        continue
    break


Fixed submission:
x = int(input())
count =0
for a in range(-200, 200):
    for b in range(-200, 200):
        if a**5 - b**5 == x:
            A = a
            B = b

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

"""ナイーブ
count = 0
for i in range(n-1):
    for j in range(i, n):
        if i != j and abs(i-j) == a[i] + a[j]:
            count += 1
print(count)
"""
# idxとa[idx]で別々にループ回すからO(n**2)になってしまう
# 前処理としてidxとa[idx]の二つの情報をまとめた何かがつくれれば、、ってとこまでは気付けた

a_plus = [0]*n
a_minus = [0]*n
for i in range(n):
    a_plus[i] = i + a[i]
    a_minus[i] = i - a[i]
ans = 0
already_count = []
for i in a_plus:
    if i in already_count:
        continue
    else:
        ans += a_plus.count(i)*a_minus.count(i)
        already_count.append(i)
print(ans)


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

"""ナイーブ
count = 0
for i in range(n-1):
    for j in range(i, n):
        if i != j and abs(i-j) == a[i] + a[j]:
            count += 1
print(count)
"""
# idxとa[idx]で別々にループ回すからO(n**2)になってしまう
# 前処理としてidxとa[idx]の二つの情報をまとめた何かがつくれれば、、ってとこまでは気付けた
from collections import Counter
a_plus = [0]*n
a_minus = [0]*n
for i in range(n):
    a_plus[i] = i + a[i]
    a_minus[i] = i - a[i]
c1 = Counter(a_plus)
c2 = Counter(a_minus)
#print(c1)
#print(c2)
ans = 0
for key in c1.keys():
    if key in c2.keys():
        ans += c1[key]*c2[key]
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
ans = 0
if b > n:
    ans = (a*n)//b
    print(ans)
else:
    c = n//b
    max_c = [0]*(c+1)
    for i in range(1, c):
        max_c[i] = (a * (b*(i+1) - 1))//b - i
    max_c[c] = (a*n)//b - c
    print(max(max_c))

Fixed submission:
a, b, n = map(int, input().split())
ans1 = (a*min(n, b-1))//b
ans2 = a*(min(n, b-1)//b)
print(ans1-ans2)

Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
ans = 0
if b > n:
    ans = (a*n)//b
else:
    c = n//b
    max_c = [0]*(c+1)
    for i in range(1, c):
        max_c[i] = (a * (b*(i+1) - 1))//b - i
    max_c[c] = (a*n)//b - c
    print(max(max_c))

Fixed submission:
a, b, n = map(int, input().split())
ans1 = (a*min(n, b-1))//b
ans2 = a*(min(n, b-1)//b)
print(ans1-ans2)

Buggy python submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
ans = 0
if b > n:
    ans = (a*n)//b
else:
    c = n//b
    max_c = [0]*(c+1)
    for i in range(1, c+1):
        max_c[i] = (a * (b*(i+1) - 1))//b - i
    print(max(max_c))

Fixed submission:
a, b, n = map(int, input().split())
ans1 = (a*min(n, b-1))//b
ans2 = a*(min(n, b-1)//b)
print(ans1-ans2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n+1):
    print(a.count(i))

Fixed submission:
from collections import Counter, deque
n = int(input())
a = deque(list(map(int, input().split())))
c = Counter(a)
for i in range(1, n+1):
    if i in c.keys():
        print(c[i])
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
count = 0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i < j < k:
                a = (s[i], s[j], s[k])
                #print(a)
                a_set = set(a)
                #print(a_set)
                if len(a_set) == 3 and (j - i) != (k - j):
                    count += 1
print(count)

Fixed submission:
n = str(input())
flag = True
for i in range(3):
    if n[i] == "7":
        print("Yes")
        flag = False
        break
if flag:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
n = abs(n-((n-1)*k))
while True:
    if abs(n - k) > n:
        break
    else:
        n = abs(n - k)
print(n)

Fixed submission:
n, k = map(int, input().split())
ans = 0
while True:
    if n > k:
        i = n // k + 1
        n = abs(n - k*i)
        continue
    elif n == k:
        ans = 0
        break
    elif n < k:
        if abs(n - k) > n:
            ans = n
            break
        else:
            ans = k - n
            break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
while True:
    if abs(n - k) > n:
        break
    else:
        n = abs(n - k)
print(n)

Fixed submission:
n, k = map(int, input().split())
ans = 0
while True:
    if n > k:
        i = n // k + 1
        n = abs(n - k*i)
        continue
    elif n == k:
        ans = 0
        break
    elif n < k:
        if abs(n - k) > n:
            ans = n
            break
        else:
            ans = k - n
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [input() for _ in range(n)]
count = []
max_list = []

for item in s:
    count_i = s.count(item)
    count.append(count_i)

for i in range(n):
    if count[i] == max(count) and not (s[i] in max_list):
        max_list.append(s[i])

max_list = sorted(max_list)
for item in max_list:
    print(item)

Fixed submission:
from collections import deque
k = int(input())
q = deque([i for i in range(1, 10)])
if k <= 9:
    print(k)
    quit()

k -= 9

while k > 0:
    a = q.popleft()
    b = a % 10
    if b == 0:
        q.append(10*a)
        q.append(10*a + 1)
        k -= 2
    elif b != 0 and b != 9:
        q.append(10*a + b - 1)
        q.append(10*a + b)
        q.append(10*a + b + 1)
        k -= 3
    elif b == 9:
        q.append(10*a + b-1)
        q.append(10*a + b)
        k -= 2

if k == 0:
    print(q[-1])
elif k == -1:
    print(q[-2])
elif k == -2:
    print(q[-3])
Buggy python submission (verdict: Time Limit Exceeded):
k, n = map(int, input().split())
A = list(map(int, input().split()))
ans = [0]*n
B = [0]*n

for j in range(n):
    for i in range(n):
        B[i] = A[i] - A[j]
        if abs(B[i]) >= k/2:
            B[i] = abs(B[i]) - k
    B.sort()
    #print(B)
    ans[j] = B[n-1] - B[0]
print(min(ans))

Fixed submission:
k, n = map(int, input().split())
a = list(map(int, input().split()))
A_list =[]
for i in range(n-1):
    A_list.append(a[i+1]-a[i])

A_list.append(a[0] + (k - a[n-1]))
print(k - max(A_list))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
for k in range(n):
    b = a[:]
    del b[k]
    #print(b)
    """もっといいやりかたある
    for l in range(n-2):
        for m in range(l+1, n-1):
            if b[l] == b[m]:
                count[k] += 1
    """
    c = Counter(b)  # ｂの要素の数と値の辞書を出してくれる
    #print(c)
    #print(c.keys())
    #print(c.values())
    for m in c.values():  # Counterで出した辞書の値（values)のリストの中身でfor
        ans[k] += int((m*(m-1))/2)  # mC2をしている

for i in range(n):
    print(ans[i])

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
ans = 0
c = Counter(a)  # aの要素の数と値の辞書を出してくれる
#print(c)
#print(c.keys())
#print(c.values())
for m in c.values():  # Counterで出した辞書の値（values)のリストの中身でfor
    ans += int((m*(m-1))/2)  # mC2をしている


for k in range(n):
    #print(c[a[k]])
    print(ans - (c[a[k]] - 1))
    """
    c[a[k]]-1というのはｋ番目のボールを隠す前と隠した後についての差。
    隠す前、aのリストにA_kがｍ個あったとする。隠した後、aのリストにA_kはｍ－１個
    なので、mC2 - (m-1)C2 = m-1 である。ここでｍとはc[a[k]]なので、上が成り立つ。
    """

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
count = [0]*n
for k in range(n):
    b = a[:]
    del b[k]
    #print(b)
    for l in range(n-2):
        for m in range(l+1, n-1):
            if b[l] == b[m]:
                count[k] += 1

    print(count[k])

Fixed submission:
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
ans = 0
c = Counter(a)  # aの要素の数と値の辞書を出してくれる
#print(c)
#print(c.keys())
#print(c.values())
for m in c.values():  # Counterで出した辞書の値（values)のリストの中身でfor
    ans += int((m*(m-1))/2)  # mC2をしている


for k in range(n):
    #print(c[a[k]])
    print(ans - (c[a[k]] - 1))
    """
    c[a[k]]-1というのはｋ番目のボールを隠す前と隠した後についての差。
    隠す前、aのリストにA_kがｍ個あったとする。隠した後、aのリストにA_kはｍ－１個
    なので、mC2 - (m-1)C2 = m-1 である。ここでｍとはc[a[k]]なので、上が成り立つ。
    """
Buggy python submission (verdict: Runtime Error):
s = input()
if s[1] == s[2] == s[3]:
    print("No")
else:
    print("Yes")

Fixed submission:
s = input()
if s[0] == s[1] == s[2]:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(m)]

flag = True

if n == 1 and m == 0:
    print(0)
elif n == 1 and m != 0:
    if len(set(sc)) != 1:
        print(-1)
    else:
        print(sc[0][1])
        
        
elif n > 1 and m == 0:
    print(10**(n-1))
    
elif n > 1 and m != 0:
    for i in range(10**(n-1), 10**n):
        i_str = str(i)
        i_list = list(i_str)
        for item in set(sc):
            if i_list[item[0]-1] != str(item[1]):
                break
        else:
            print(i)
            flag = False
            break
    if flag:
        print(-1)

Fixed submission:
n = int(input())
if n % 2 == 0:
    p = int(n / 2)
else:
    p = int(n/2) + 1
print(p)