Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())

ar_int_a = []
for i in range(int_n):
    ar_int_a.append(int(input()))

numbers = set(ar_int_a)

# written = [i for i in numbers if ar_int_a.count(i) % 2 == 1]

written = 0
for i in numbers:
    if ar_int_a.count(i) % 2 == 1:
        written += 1

# print(len(written))
print(written)

Fixed submission:
from collections import defaultdict


int_n = int(input())

counter = defaultdict(int)

for i in range(int_n):
    counter[int(input())] += 1

written = 0
for c in counter.values():
    if c % 2 == 1:
        written += 1


print(written)

Buggy python submission (verdict: Runtime Error):
int_n = int(input())

ar_int_a = []
for i in range(int_n):
    ar_int_a.append(int(input()))

numbers = set(ar_int_a)

# written = [i for i in numbers if ar_int_a.count(i) % 2 == 1]
written = len((i for i in numbers if ar_int_a.count(i) % 2 == 1))

# print(len(written))
print(written)

Fixed submission:
from collections import defaultdict


int_n = int(input())

counter = defaultdict(int)

for i in range(int_n):
    counter[int(input())] += 1

written = 0
for c in counter.values():
    if c % 2 == 1:
        written += 1


print(written)

Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())

ar_int_a = []
for i in range(int_n):
    ar_int_a.append(int(input()))

numbers = set(ar_int_a)

written = [i for i in numbers if ar_int_a.count(i) % 2 == 1]

print(len(written))

Fixed submission:
from collections import defaultdict


int_n = int(input())

counter = defaultdict(int)

for i in range(int_n):
    counter[int(input())] += 1

written = 0
for c in counter.values():
    if c % 2 == 1:
        written += 1


print(written)
Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())
ar_int_a = list(map(int, input().split()))

st_int_group = set(ar_int_a)
max_count = 0

for i in st_int_group:
    # current = ar_int_a.count(i) + ar_int_a.count(i - 1) + ar_int_a.count(i + 1)
    # max_count = current if max_count <= current else max_count
    max_count = max(ar_int_a.count(i) + ar_int_a.count(i - 1) + ar_int_a.count(i + 1), max_count)

print(max_count)






Fixed submission:
from collections import defaultdict

int_n = int(input())
ar_int_a = list(map(int, input().split()))

d_cnt = defaultdict(int)
for w in ar_int_a:
    d_cnt[w] += 1


st_int_group = set(ar_int_a)
max_count = 0

for i in st_int_group:
    max_count = max(d_cnt[i] + d_cnt[i - 1] + d_cnt[i + 1], max_count)

print(max_count)

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

st_int_group = set(ar_int_a)
max_count = 0

for i in st_int_group:
    # current = ar_int_a.count(i) + ar_int_a.count(i - 1) + ar_int_a.count(i + 1)
    # max_count = current if max_count <= current else max_count
    max_count = max(ar_int_a.count(i) + ar_int_a.count(i - 1) + ar_int_a.count(i + 1), max_count)

print(max_count)






Fixed submission:
from collections import defaultdict

int_n = int(input())
ar_int_a = list(map(int, input().split()))

d_cnt = defaultdict(int)
for w in ar_int_a:
    d_cnt[w] += 1


st_int_group = set(ar_int_a)
max_count = 0

for i in st_int_group:
    max_count = max(d_cnt[i] + d_cnt[i - 1] + d_cnt[i + 1], max_count)

print(max_count)

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

st_int_group = set(ar_int_a)
max_count = 0

for i in st_int_group:
    current = ar_int_a.count(i) + ar_int_a.count(i - 1) + ar_int_a.count(i + 1)
    max_count = current if max_count <= current else max_count

print(max_count)





Fixed submission:
from collections import defaultdict

int_n = int(input())
ar_int_a = list(map(int, input().split()))

d_cnt = defaultdict(int)
for w in ar_int_a:
    d_cnt[w] += 1


st_int_group = set(ar_int_a)
max_count = 0

for i in st_int_group:
    max_count = max(d_cnt[i] + d_cnt[i - 1] + d_cnt[i + 1], max_count)

print(max_count)
Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())
ar_int_a = list(map(int, input().split()))

result = []

ar_int_a.sort(reverse=True)

headers = set(ar_int_a)

counters = [{'number': i, 'count': ar_int_a.count(i)} for i in headers
            if ar_int_a.count(i) >= 2]

for i in sorted(counters, key=lambda x: x['number'], reverse=True):

    if len(result) == 0 and i['count'] >= 4:
        print(i['number'] ** 2)
        exit(0)
    elif len(result) < 2:
        result.append(i['number'])
    else:
        break
if len(result) == 2:
    print(result[0] * result[1])
else:
    print(0)



Fixed submission:
import collections

int_n = int(input())
ar_int_a = list(map(int, input().split()))

c = collections.defaultdict(int)
result = []

for a in ar_int_a:
    c[a] += 1

for k in sorted(c.keys(), key=lambda x: x, reverse=True):
    if len(result) == 0 and c[k] >= 4:
        print(k ** 2)
        exit(0)
    elif len(result) < 2 and c[k] >= 2:
        result.append(k)

    if len(result) == 2:
        print(result[0] * result[1])
        exit(0)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数


def lcm(a, b):
    return (a * b) // math.gcd(a, b)

work = 1

for t in li_t:
    work = lcm(work, t)

print(work)

Fixed submission:
from fractions import gcd


n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数


def lcm(a, b):
    return (a * b) // gcd(a, b)

work = 1

for t in li_t:
    work = lcm(work, t)

print(work)

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

n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数


def lcm(a, b):
    return (a * b) // math.gcd(a, b)


work = li_t.pop(0)

for t in li_t:
    work = lcm(work, t)

print(work)

Fixed submission:
from fractions import gcd


n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数


def lcm(a, b):
    return (a * b) // gcd(a, b)

work = 1

for t in li_t:
    work = lcm(work, t)

print(work)

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

n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数

def lcm(a, b):
    return (a * b) // math.gcd(a, b)

work = li_t.pop(0)

for t in li_t:
    work = lcm(work, t)

print(work)


Fixed submission:
from fractions import gcd


n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数


def lcm(a, b):
    return (a * b) // gcd(a, b)

work = 1

for t in li_t:
    work = lcm(work, t)

print(work)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

li_sorted = sorted(li_t, reverse=True)
t_max = li_sorted.pop(0)


sec = 1
while(True):
    if all(map(lambda x: (t_max * sec) % x == 0, li_sorted)):
        print(sec * t_max)
        exit(0)
    else:
        sec += 1




Fixed submission:
from fractions import gcd


n = int(input())
li_t = list()

for _ in range(n):
    li_t.append(int(input()))

# a * b = 最小公倍数 * 最大公約数


def lcm(a, b):
    return (a * b) // gcd(a, b)

work = 1

for t in li_t:
    work = lcm(work, t)

print(work)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

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

sm = sum(li_a)
result = -1
for c in range(1, len(li_a)):
    x = sum(li_a[0:c])
    a = abs(sm - 2 * x)
    result = min(result, a) if result >= 0 else a

print(result)

Fixed submission:
n = int(input())

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

sm = sum(li_a)

li_ruiseki = list()

for a in li_a:
    if len(li_ruiseki) == 0:
        li_ruiseki.append(a)
    else:
        li_ruiseki.append(li_ruiseki[-1] + a)

result = -1
for x in li_ruiseki[:-1]:
    a = abs(sm - 2 * x)
    result = min(result, a) if result >= 0 else a

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

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

sm = sum(li_a)
result = -1
for c in range(1, len(li_a)):
    x = sum(li_a[0:c])
    y = sm - x
    result = min(result, abs(x - y)) if result >= 0 else abs(x - y)

print(result)

Fixed submission:
n = int(input())

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

sm = sum(li_a)

li_ruiseki = list()

for a in li_a:
    if len(li_ruiseki) == 0:
        li_ruiseki.append(a)
    else:
        li_ruiseki.append(li_ruiseki[-1] + a)

result = -1
for x in li_ruiseki[:-1]:
    a = abs(sm - 2 * x)
    result = min(result, a) if result >= 0 else a

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())
ar_int_a = list(map(int, input().split()))
ar_int_b = list()
for i in ar_int_a:
    ar_int_b.append(i)
    ar_int_b = ar_int_b[::-1]

print(" ".join(map(str, ar_int_b)))


Fixed submission:
int_n = int(input())
ar_int_a = list(map(int, input().split()))
ar_int_b = [-1] * int_n


idx = (int_n // 2)
ar_int_b[idx] = ar_int_a[0]

if int_n % 2 == 0:
    # 偶数
    for i in range(1, int_n):
        if i % 2 == 0:
            idx = idx + i
        else:
            idx = idx + (-1 * i)
        ar_int_b[idx] = ar_int_a[i]
else:
    # 奇数
    for i in range(1, int_n):
        if i % 2 == 0:
            idx = idx + (-1 * i)
        else:
            idx = idx + i
        ar_int_b[idx] = ar_int_a[i]


print(" ".join(map(str, ar_int_b)))
Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())
ar_int = list()
for i in range(int_n):
    ar_int.append(int(input()))

target = 2
counter = 0

while counter < int_n:
    if target in ar_int:
        target = ar_int.index(target) + 1
        counter += 1
        if target == 1:
            print(counter)
            exit(0)
print(-1)


Fixed submission:
int_n = int(input())
ar_int = list()
for i in range(int_n):
    ar_int.append(int(input()))

target = 1
counter = 0

while counter < int_n:
    target = ar_int[target - 1]
    counter += 1
    if target == 2: # button 2
        print(counter)
        exit(0)
print(-1)
Buggy python submission (verdict: Runtime Error):
int_n = int(input())

ar_int_s = list()

for i in range(int_n):
    ar_int_s.append(int(input()))

minused = list()

for i in range(int_n):
    if (sum(ar_int_s) - sum(minused)) % 10 != 0:
        break
    else:
        minused.append(sorted(ar_int_s)[i:i])

print(sum(ar_int_s) - sum(minused))



Fixed submission:
int_n = int(input())

ar_int_s = list()

for i in range(int_n):
    ar_int_s.append(int(input()))


if sum(ar_int_s) % 10 != 0:
    print(sum(ar_int_s))
else:
    li_minus = list(filter(lambda x: x % 10 != 0, ar_int_s))
    if len(li_minus) == 0:
        print(0)
    else:
        print(sum(ar_int_s) - min(li_minus))
Buggy python submission (verdict: Time Limit Exceeded):
int_n, int_k = map(int, input().split())

ar_int = list()

for i in range(int_n):
    int_a, int_b = map(int, input().split())
    for x in range(int_b):
        ar_int.append(int_a)

print(sorted(ar_int)[int_k - 1])


Fixed submission:
int_n, int_k = map(int, input().split())

li_wk = list()

for i in range(int_n):
    li_wk.append(list(map(int, input().split())))

li_wk.sort(key=lambda x: x[0])

counter = 1
for l in li_wk:
    if counter <= int_k <= (counter + l[1] - 1):
        print(l[0])
    counter += l[1]
Buggy python submission (verdict: Runtime Error):
from itertools import combinations

int_x = int(input())

answer = int_x

for i in range(1, int_x + 1):
    c = combinations(range(1, int_x + 1), i)
    for w_c in c:
        if sum(w_c) == int_x:
            answer = min(answer, max(w_c))
print(answer)


Fixed submission:
x = int(input())

w = 0
for i in range(1, x + 1):
    w += i
    if w >= x:
        print(i)
        exit(0)

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

int_x = int(input())
answer = int_x
for i in range(1, int_x + 1):
    for v in itertools.combinations(range(1, int_x + 1), i):
        if sum(v) == int_x:
            answer = min(answer, max(v))
print(answer)






Fixed submission:
x = int(input())

w = 0
for i in range(1, x + 1):
    w += i
    if w >= x:
        print(i)
        exit(0)

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

int_x = int(input())
answer = int_x
for i in range(1, int_x):
    for v in itertools.combinations(range(1, int_x + 1), i):
        if sum(v) == int_x:
            answer = min(answer, max(v))
print(answer)






Fixed submission:
x = int(input())

w = 0
for i in range(1, x + 1):
    w += i
    if w >= x:
        print(i)
        exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
int_x = int(input())

li_dist = list()
for i in range(1, int_x + 1):
    if len(li_dist) == 0:
        li_dist = [i, -i, 0]
    else:
        li_dist = [x + y for x in [i, -i, 0] for y in li_dist]

    if int_x in li_dist:
        print(i)
        exit(0)




Fixed submission:
x = int(input())

w = 0
for i in range(1, x + 1):
    w += i
    if w >= x:
        print(i)
        exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
int_n = int(input())

power = 1

for i in range(1, int_n + 1):
    power = power * i

print(power % (10 ** 9 + 7))


Fixed submission:
int_n = int(input())

power = 1

for i in range(1, int_n + 1):
    power = (power * i) % (10 ** 9 + 7)

print(power)
Buggy python submission (verdict: Runtime Error):
int_s = input()
str_sr = int_s[::-1]


str_a = ['dream', 'dreamer', 'erase', 'eraser']

str_r = list(map(lambda x: x[::-1], str_a))

result = True

while len(str_sr):
    currnt_flg = False
    for r in str_r:
        print('r:' + r)
        if len(str_sr) >= len(r) and str_sr[:len(r)] == r:
            print('ok')
            str_sr = str_sr[len(r):]
            print(str_sr)
            current_flg = True
            break
    else:
        result = False
        break

if result:
    print('YES')
else:
    print('NO')


Fixed submission:
int_s = input()
str_sr = int_s[::-1]


str_a = ['dream', 'dreamer', 'erase', 'eraser']

str_r = list(map(lambda x: x[::-1], str_a))

result = True

while len(str_sr):
    currnt_flg = False
    for r in str_r:
        # print('r:' + r)
        if len(str_sr) >= len(r) and str_sr[:len(r)] == r:
            # print('ok')
            str_sr = str_sr[len(r):]
            # print(str_sr)
            current_flg = True
            break
    else:
        result = False
        break

if result:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
int_s = input()
str_sr = int_s[::-1]


str_a = ['dream', 'dreamer', 'erase', 'eraser']

str_r = list(map(lambda x: x[::-1], str_a))

result = True

while len(str_sr):
    currnt_flg = False
    for r in str_r:
        print('r:' + r)
        if len(str_sr) >= len(r) and str_sr[:len(r)] == r:
            print('ok')
            str_sr = str_sr[len(r):]
            print(str_sr)
            current_flg = True
            break
    else:
        result = False
        break

if result:
    print('YES')
else:
    print('No')

Fixed submission:
int_s = input()
str_sr = int_s[::-1]


str_a = ['dream', 'dreamer', 'erase', 'eraser']

str_r = list(map(lambda x: x[::-1], str_a))

result = True

while len(str_sr):
    currnt_flg = False
    for r in str_r:
        # print('r:' + r)
        if len(str_sr) >= len(r) and str_sr[:len(r)] == r:
            # print('ok')
            str_sr = str_sr[len(r):]
            # print(str_sr)
            current_flg = True
            break
    else:
        result = False
        break

if result:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())

s_t = set()
for i in range(n):
    s_t.add(int(input()))

print(len(s_t.difference(set(range(a, b)))))


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

s_t = set()
for i in range(n):
    s_t.add(int(input()))
answer = 0
for s in s_t:
    if a <= s < b:
        pass
    else:
        answer += 1
print(answer)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
ans = [0] * 10
ans[1] = '1'
for i in range(2, 10):
    ans[i] = str(i)
alpha = "0123456789"
def dfs(s):
    if len(s) == N:
        ans.append(s)
        if len(ans) >= 100001:
            return
    else:
        for c in range(int(s[-1])-1,int(s[-1])+2):
            if c >= 0:
                dfs(s+str(c))
            if c == '9':
                break
K = int(input())
N = 2
while len(ans) < 100001:
    for i in range(1, 10):
        dfs(str(i))
        if len(ans) >= 100001:
            break
    N+=1

print(ans[K])

Fixed submission:
#!/usr/bin/env python3
ans = [0] * 10
ans[1] = '1'
for i in range(2, 10):
    ans[i] = str(i)
alpha = "0123456789"
def dfs(s):
    if len(s) == N:
        ans.append(s)
        if len(ans) >= 100001:
            return
    else:
        for c in range(int(s[-1])-1,int(s[-1])+2):
            if c >= 0:
                dfs(s+str(c))
            if c == 9:
                break
K = int(input())
N = 2
while len(ans) < 100001:
    for i in range(1, 10):
        dfs(str(i))
        if len(ans) >= 100001:
            break
    N+=1

print(ans[K])

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
ans = [0] * 10
ans[1] = '1'
for i in range(2, 10):
    ans[i] = str(i)
alpha = "0123456789"
def dfs(s):
    if len(s) == N:
        ans.append(s)
        if len(ans) >= 100001:
            return
    else:
        for c in (int(s[-1])-1,int(s[-1])+2):
            if c >= 0:
                dfs(s+str(c))
            if c == '9':
                break
K = int(input())
N = 2
while len(ans) < 100001:
    for i in range(1, 10):
        dfs(str(i))
        if len(ans) >= 100001:
            break
    N+=1

print(ans[K])

Fixed submission:
#!/usr/bin/env python3
ans = [0] * 10
ans[1] = '1'
for i in range(2, 10):
    ans[i] = str(i)
alpha = "0123456789"
def dfs(s):
    if len(s) == N:
        ans.append(s)
        if len(ans) >= 100001:
            return
    else:
        for c in range(int(s[-1])-1,int(s[-1])+2):
            if c >= 0:
                dfs(s+str(c))
            if c == 9:
                break
K = int(input())
N = 2
while len(ans) < 100001:
    for i in range(1, 10):
        dfs(str(i))
        if len(ans) >= 100001:
            break
    N+=1

print(ans[K])
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))

lcm = A[0]
for i in range(1, N):
    lcm = (lcm*A[i]) // gcd(lcm, A[i])

ans = 0
for i in range(N):
    ans += lcm // A[i]
    ans %= mod
print(ans)

Fixed submission:
from fractions import gcd
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))

lcm = A[0]
for i in range(1, N):
    lcm = (lcm*A[i]) // gcd(lcm, A[i])

ans = 0
for i in range(N):
    ans += lcm // A[i]
ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))

lcm = A[0]
for i in range(1, N):
    lcm = (lcm*A[i]) // gcd(lcm, A[i])

ans = 0
for i in range(N):
    ans += lcm // A[i]
    ans %= mod
print(ans)

Fixed submission:
from fractions import gcd
mod = 10**9 + 7
N = int(input())
A = list(map(int, input().split()))

lcm = A[0]
for i in range(1, N):
    lcm = (lcm*A[i]) // gcd(lcm, A[i])

ans = 0
for i in range(N):
    ans += lcm // A[i]
ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

N = int(input())
x = list(map(int, input().split()))
mod = 10**9 + 7
x_dis = [x[i+1] - x[i] for i in range(N-1)]
ans = 0
m = N-1
fac = factorial(m)
tmp = fac
for i in range(m):
    ans += x_dis[i] * tmp
    ans %= mod
    tmp += fac//(i+2)
print(ans)


Fixed submission:
from math import factorial

N = int(input())
x = list(map(int, input().split()))
mod = 10**9 + 7
x_dis = [x[i+1] - x[i] for i in range(N-1)]
ans = 0
m = N-1
fac = factorial(m) % mod
tmp = fac
for i in range(m):
    ans += x_dis[i] * tmp
    ans %= mod
    tmp += (fac*pow((i+2),(mod-2), mod))%mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        ans += (A[i] ^ A[j])
        ans %= mod
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7
cnt = [[0,0] for i in range(61)]
for i in range(61):
    for j in range(N):
        if ((A[j] >> i) & 1):
            cnt[i][1] += 1
        else:
            cnt[i][0] += 1

ans = 0
for i in range(61):
    ans += (cnt[i][0] * cnt[i][1]) * (2**i)
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())
ans = 0
k = [3, 2, 1]
if X <= 3:
    ans += k[X-1]
if Y <= 3:
    ans += k[X-1]
if X == 1 and Y == 1:
    ans += 4
print(ans * 100000)

Fixed submission:
X, Y = map(int, input().split())
ans = 0
k = [3, 2, 1]
if X <= 3:
    ans += k[X-1]
if Y <= 3:
    ans += k[Y-1]
if X == 1 and Y == 1:
    ans += 4
print(ans * 100000)
Buggy python submission (verdict: Runtime Error):
S = str(input())
S += "<"
l = 0
r = 0
ans = 0
tmp = ">"
for i in range(len(s)):
    if tmp == ">" and S[i] == "<":
        ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) - 1
        l = 1
        r = 0
        tmp = S[i]
    else:
        if S[i] == ">":
            r += 1
        else:
            l += 1
        tmp = S[i]
print(ans)

Fixed submission:
S = str(input())
l = 0
r = 0
ans = 0
tmp = S[0]
if tmp == ">":
    r = 1
else:
    l = 1
for i in range(1,len(S)):
    if tmp == ">" and S[i] == "<":
        ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) * (min(l, r) - 1) / 2
        l = 1
        r = 0
        tmp = S[i]
    else:
        if S[i] == ">":
            r += 1
        else:
            l += 1
        tmp = S[i]
ans += max(l, r) * (max(l, r) + 1) / 2 + min(l, r) * (min(l, r) - 1) / 2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
S = str(input())
K = int(input())
tmp = 1
cnt = 0
for i in range(1, len(S)):
    if S[i-1] == S[i]:
        tmp += 1
    else:
        cnt += tmp // 2
        tmp = 1
if tmp > 1:
    cnt += tmp//2
if S[0] == S[-1]:
    if S[0] != S[1] and S[-1] != S[-2]:
        print(cnt * K + K - 1)
    else:
        print(cnt * K)
else:
    print(cnt * K)



Fixed submission:
S = str(input())
K = int(input())
tmp = 1
cnt1 = 0
cnt2 = 0
for i in range(1, len(S)):
    if S[i-1] == S[i]:
        tmp += 1
    else:
        cnt1 += tmp // 2
        tmp = 1
if tmp == len(S):
        print(len(S) * K // 2)
        exit()
if tmp > 1:
    cnt1 += tmp//2
S2 = S + S
tmp = 1
for i in range(1, len(S2)):
    if S2[i-1] == S2[i]:
        tmp += 1
    else:
        cnt2 += tmp // 2
        tmp = 1
if tmp > 1:
    cnt2 += tmp//2
if K == 1:
    print(cnt1)
else:
    print((cnt2 - cnt1) * (K-2) + cnt2)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
i = 2
cnt = 0
tmpA, tmpB = A, B
while i**2 <= min(tmpA, tmpB) and i <= min(A,B):
    if A % i == 0 and B % i == 0:
        cnt += 1
        while A % i == 0 and B % i == 0:
            A //= i
            B //= i
    i += 1
if cnt == 0 and min(A, B) != 1:
    cnt += 1
if cnt == 0 and max(A,B) % min(A,B) == 0:
    cnt += 1
print(cnt + 1)

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