Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
m = set([a, b, c])
print(len(m)

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

if a == b == c:
    print(1)
elif a == b or b == c or a == c:
    print(2)
else:
    print(3)

Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
m = set([a, b, c])）
print(len(m)

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

if a == b == c:
    print(1)
elif a == b or b == c or a == c:
    print(2)
else:
    print(3)
Buggy python submission (verdict: Runtime Error):
a, b, h = map(int, input().split())

print((a + b) * h / 2)


Fixed submission:
a = int(input())
b = int(input())
h = int(input())

area = int((a + b) * h / 2)
print(area)
Buggy python submission (verdict: Runtime Error):
N, K, X, Y = map(int, input().split())

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)

Fixed submission:
N = int(input())   
K = int(input())   
X = int(input())    
Y = int(input())    

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)

Buggy python submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())

if n <= k:
    print(n * x)
else:
    print(k * x + (n - k) * y)

Fixed submission:
N = int(input())   
K = int(input())   
X = int(input())    
Y = int(input())    

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)

Buggy python submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())

if n <= k:
    print(n * x)
else:
    print(k * x + (n - k) * y)

    

Fixed submission:
N = int(input())   
K = int(input())   
X = int(input())    
Y = int(input())    

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)

Buggy python submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())

if n <= k:
    print(k * x)
else:
    print(k * x + (n - k) * y)


Fixed submission:
N = int(input())   
K = int(input())   
X = int(input())    
Y = int(input())    

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)
Buggy python submission (verdict: Runtime Error):
ame = N * (N + 1) / 2
print(ame)

Fixed submission:
# 入力
n = int(input())
# result初期化
result = 0
# １からNまで繰り返し
for i in range(1,n+1):
    # 等差数列
    count = i
    result = result + count
# 結果を表示
print(result)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from itertools import chain


def max_add_1_to_n(loop, n):
    # print('  max_add_1_to_n', loop, n)
    l = len(loop)
    acc = loop.copy()
    # print('    ', acc)
    max_val = max(acc)
    for i in range(1, n):
        for j in range(0, l):
            acc[j] += loop[(i + j) % l]
        # print("    ", acc)
        max_val = max(max(acc), max_val)
    return max_val


def max_add_0_to_n(loop, n):
    # print('  max_add_0_to_n', loop, n)
    if n >= 1:
        return max(max_add_1_to_n(loop, n), 0)
    else:
        return 0


def max_loop_k(loop, K):
    l = len(loop)
    if K <= 2 * l:
        return max_add_1_to_n(loop, K)
    # K は 2 * l より長い
    l_sum = sum(loop)
    if l_sum <= 0:
        return max_add_1_to_n(loop, l)
    else:
        Kdiv = K // l
        Kmod = K % l
        # print('  l Kdiv Kmod', l, Kdiv, Kmod)
        return max_add_0_to_n(loop, l + Kmod) + l_sum * (Kdiv - 1)


def solve(N: int, K: int, P: "List[int]", C: "List[int]"):
    # 簡単のためインデックスを 0 からにする
    # (使用済みは -1 を入れる)
    P = [i - 1 for i in P]
    answer = -float("inf")
    for i0 in range(N):
        if P[i0] == -1:
            continue
        loop = []
        i = i0
        while P[i] != -1:
            loop.append(C[i])
            i_next = P[i]
            P[i] = -1
            i = i_next
        answer = max(answer, max_loop_k(loop, K))

    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, P, C)
    print(answer)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python
import sys
from itertools import chain

# import numpy as np


def solve(S: str):
    answer = max(list(map(len, S.split("S"))))
    return answer


def main():
    S = input()  # type: str
    print(solve(S))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from itertools import chain
from itertools import combinations as comb
# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter
# import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    answer = min(map(sum, comb(p, K)))
    return answer

def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, K, p = map(int, line.split())
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, p)
    print(answer)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from itertools import chain

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter
# import numpy as np


def solve(N: int, K: int, p: "List[int]"):
    p = sorted(p)
    return sum(p[:K])


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N, K, p = map(int, line.split())
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, p)
    print(answer)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

from collections import Counter


def solve(N: int, A: "List[int]", Q: int, BC: "List[(int,int)]"):
    A = Counter(A)
    answers = []
    for b, c in BC:
        if b != c:
            A[c] += A[b]
            del A[b]
        ans = sum((i * n for i, n in A.items()))
        answers.append(ans)
    return answers


def main():
    N = int(input())  # type: int
    A = list(map(int, input().split()))
    Q = int(input())
    BC = [tuple(map(int, input().split())) for _ in range(Q)]
    answer = solve(N, A, Q, BC)
    for ans in answer:
        print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3

from collections import Counter


def solve(N: int, A: "List[int]", Q: int, BC: "List[(int,int)]"):
    A = Counter(A)
    answers = []
    ans = ans = sum((i * n for i, n in A.items()))
    for b, c in BC:
        if b != c:
            ans += (c - b) * A[b]
            A[c] += A[b]
            del A[b]
        answers.append(ans)
    return answers


def main():
    N = int(input())  # type: int
    A = list(map(int, input().split()))
    Q = int(input())
    BC = [tuple(map(int, input().split())) for _ in range(Q)]
    answer = solve(N, A, Q, BC)
    for ans in answer:
        print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):

def solve(S: str):
    if len(S) < 4:
        return 0
    answer = 0
    for l in range(0, len(S) - 3):
        for r in range(l + 4, len(S) + 1):
            answer += int(S[l:r]) % 2019 == 0
    return answer


def main():
    S = input().strip()
    answer = solve(S)
    print(answer)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3

import numpy as np
from collections import Counter

YEAR = 2019


def solve(S: str):
    # S の各桁を modYear 計に修正する
    mod_year = np.arange(1, 10)
    mod_s = []
    for Si in map(int, reversed(S)):
        mod_s.append(mod_year[Si - 1])
        mod_year = (mod_year * 10) % YEAR
    #print(mod_s)
    # mod_s を累積和にする
    cum_sum = 0
    cum_sums = [cum_sum]
    for x in mod_s:
        cum_sum = (cum_sum+x) % YEAR
        cum_sums.append(cum_sum)

    answer = 0
    for _, num in Counter(cum_sums).items():
        answer += (num * (num-1)) // 2   # 1 の時0なので場合分けはいらない
    return answer


def main():
    S = input().strip()
    answer = solve(S)
    print(answer)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3


def solve(S: str):
    if len(S) < 4:
        return 0
    answer = 0
    for l in range(0, len(S) - 3):
        for r in range(l + 4, len(S) + 1):
            answer += int(S[l:r]) % 2019 == 0
    return answer


def main():
    S = input().strip()
    answer = solve(S)
    print(answer)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3

import numpy as np
from collections import Counter

YEAR = 2019


def solve(S: str):
    # S の各桁を modYear 計に修正する
    mod_year = np.arange(1, 10)
    mod_s = []
    for Si in map(int, reversed(S)):
        mod_s.append(mod_year[Si - 1])
        mod_year = (mod_year * 10) % YEAR
    #print(mod_s)
    # mod_s を累積和にする
    cum_sum = 0
    cum_sums = [cum_sum]
    for x in mod_s:
        cum_sum = (cum_sum+x) % YEAR
        cum_sums.append(cum_sum)

    answer = 0
    for _, num in Counter(cum_sums).items():
        answer += (num * (num-1)) // 2   # 1 の時0なので場合分けはいらない
    return answer


def main():
    S = input().strip()
    answer = solve(S)
    print(answer)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

def solve(N, d):
    total = 0
    for i1 in range(len(d)):
        for i2 in range(i1+1, len(d)):
            total += d[i1] * d[i2]
    return total


if __name__ == '__main__':
    N = int(input())
    d = map(int, input().split())

    ans = solve(N, list(d))

    print(ans)


Fixed submission:
#!/usr/bin/env python3


def solv(n, d):
    ll = d * 2 + 1
    ans = (n + ll - 1) // ll
    return ans


if __name__ == '__main__':

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

    ans = solv(n, d)

    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3


import numpy as np


def solv(m, a):
    boxs = np.zeros(m, dtype=np.uint16)

    for i in range(m, 0, -1):
        idx = np.arange(i+i-1, m, i)
        s = np.sum(boxs[idx])
        boxs[i-1] = (s + a[i-1]) % 2

    return boxs


if __name__ == '__main__':

    m = int(input())
    a = np.array(list(map(int, input().split())), dtype=np.uint16)

    ans = solv(m, a)

    print(sum(ans))
    for i in range(m):
        if ans[i]:
            print(i+1)


Fixed submission:
#!/usr/bin/env python3


import numpy as np


def solv(m, a):
    boxs = np.zeros(m, dtype=np.int)

    for i in range(m, 0, -1):
        # idx = np.arange(i+i-1, m, i)
        s = np.count_nonzero(boxs[i+i-1:m:i])
        boxs[i-1] = (s + a[i-1]) % 2

    return boxs


if __name__ == '__main__':

    m = int(input())
    a = np.array(list(map(int, input().split())), dtype=np.int)

    ans = solv(m, a)

    print(sum(ans))
    for i in range(m):
        if ans[i]:
            print(i+1)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3


import numpy as np


def solv(m, a):
    boxs = np.zeros(m, dtype=np.int)

    for i in range(m, 0, -1):
        idx = np.arange(i+i-1, m, i)
        s = np.sum(boxs[idx])
        boxs[i-1] = (s + a[i-1]) % 2

    return boxs


if __name__ == '__main__':

    m = int(input())
    a = np.array(list(map(int, input().split())), dtype=np.int)

    ans = solv(m, a)

    print(sum(ans))
    for i in range(m):
        if ans[i]:
            print(i+1)


Fixed submission:
#!/usr/bin/env python3


import numpy as np


def solv(m, a):
    boxs = np.zeros(m, dtype=np.int)

    for i in range(m, 0, -1):
        # idx = np.arange(i+i-1, m, i)
        s = np.count_nonzero(boxs[i+i-1:m:i])
        boxs[i-1] = (s + a[i-1]) % 2

    return boxs


if __name__ == '__main__':

    m = int(input())
    a = np.array(list(map(int, input().split())), dtype=np.int)

    ans = solv(m, a)

    print(sum(ans))
    for i in range(m):
        if ans[i]:
            print(i+1)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import math


P_NUM = 1000000007


def ncr(n, r):
    return math.factorial(n) // math.factorial(n-r) // math.factorial(r)


def solv(n, k):
    for i in range(1, k+1):
        blue_ptn = ncr(k-1, i-1)
        red_ptn = ncr(n-k+1, i)
        print(blue_ptn * red_ptn % P_NUM)


if __name__ == '__main__':

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

    solv(n, k)


Fixed submission:
#!/usr/bin/env python3

import math


P_NUM = 1000000007


def ncr(n, r):
    return math.factorial(n) // math.factorial(n-r) // math.factorial(r)


def solv(n, k):
    blue = k
    red = n - k
    for i in range(1, k+1):
        # print('blue=', blue, ' i=', i)
        blue_ptn = ncr(blue-1, i-1)
        # print('blue_ptn=', blue_ptn)
        # print('red=', red, ' i=', i)
        if red+1 < i:
            red_ptn = 0
        else:
            red_ptn = ncr(red+1, i)
        # print('red_ptn=', red_ptn)
        print(blue_ptn * red_ptn % P_NUM)


if __name__ == '__main__':

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

    solv(n, k)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3


def solv(a, b):
    if a >= 13:
        return b
    elif a >= 6:
        return b // 2
    else:
        return 0


if __name__ == '__main__':

    a, b = map(int, input().split())

    ans = solv(a, b)

    print(ans)
#!/usr/bin/env python3


def solv(a, b):
    if a >= 13:
        return b
    elif a >= 6:
        return b // 2
    else:
        return 0


if __name__ == '__main__':

    a, b = map(int, input().split())

    ans = solv(a, b)

    print(ans)


Fixed submission:
#!/usr/bin/env python3

def solv(a, b):
    if a >= 13:
        return b
    elif a >= 6:
        return b // 2
    else:
        return 0


if __name__ == '__main__':

    a, b = map(int, input().split())

    ans = solv(a, b)

    print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3



def solv(x, y, z, k, a, b, c):
    a = sorted(a, reverse=True)
    b = sorted(b, reverse=True)
    c = sorted(c, reverse=True)

    m = max(a[0] - a[-1], b[0] - b[-1], c[0] - c[-1])

    while True:
        aa = list(filter(lambda v: v > a[0] - m, a))
        bb = list(filter(lambda v: v > b[0] - m, b))
        cc = list(filter(lambda v: v > c[0] - m, c))

        if len(aa) * len(bb) * len(cc) < 10000:
            break

        m = m * 0.8

    aa = a
    bb = b
    cc = c

    all = []
    for ai in a:
        for bi in b:
            for ci in c:
                all.append(ai+bi+ci)

    all = sorted(all, reverse=True)

    return all[:k]


if __name__ == '__main__':

    x, y, z, k = map(int, input().split())
    a = map(int, input().split())
    b = map(int, input().split())
    c = map(int, input().split())

    ans = solv(x, y, z, k, a, b, c)

    for ans_i in ans:
        print(ans_i)


Fixed submission:
#!/usr/bin/env python3


def solv(a, b, c, d, e, k):
    ants = [a, b, c, d, e]
    for i in range(1, len(ants)):
        for j in range(i):
            if abs(ants[i] - ants[j]) > k:
                return ':('
    return 'Yay!'


if __name__ == '__main__':

    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    ans = solv(a, b, c, d, e, k)

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

    def __init__(self):
        pass

    def solve(self, a, b, k):
        for n in range(min(a,b), 0, -1):
            if (a % n) == 0 and (b % n) ==0:
                k -= 1
                if k == 0:
                    return n
        return 1


if __name__ == '__main__':

    solver = Solver()

    a, b, k = map(int, input().split())

    n = solver.solve(a, b, k)
    print(n)
(atcoder) @lx

Fixed submission:
class Solver:

    def __init__(self):
        pass

    def solve(self, a, b, k):
        for n in range(min(a,b), 0, -1):
            if (a % n) == 0 and (b % n) ==0:
                k -= 1
                if k == 0:
                    return n
        return 1


if __name__ == '__main__':

    solver = Solver()

    a, b, k = map(int, input().split())

    n = solver.solve(a, b, k)
    print(n)
Buggy python submission (verdict: Time Limit Exceeded):
class Solver:

    def __init__(self):
        pass

    def solve(self, s):
        s0 = s
        while True:
            snew = s.replace('01','').replace('10','')
            if snew == s:
                return (len(s0) - len(snew))
            s = snew

if __name__ == '__main__':

    solver = Solver()

    s = input()

    n = solver.solve(s)
    print(n)


Fixed submission:
class Solver:

    def __init__(self):
        pass


    def solve(self, s):
        one = 0
        zero = 0
        for ch in s:
            if ch == '1':
                one += 1
            else:
                zero += 1
        return len(s) - abs(one-zero)


if __name__ == '__main__':

    solver = Solver()
    s = input()
    n = solver.solve(s)
    print(n)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
pareil = True
for i in range(0,len(S)):
	if S[i] != T[i]:
    	pareil = False
if pareil:
	print('Yes')
else:
	print('No')

Fixed submission:
S = input()
T = input()

pareil = True
for i in range(0, len(S)):
    if S[i] != T[i]:
        pareil = False
if pareil:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = input()

print(N*N)


Fixed submission:
N = int(input())

print(N*N)
Buggy python submission (verdict: Runtime Error):
s=input()
c=0
tmp=0
for i in range(3):
    if s[i]='S':
        tmp+=1
        if c<tmp:
            c=tmp
    else:
        tmp=0
print(c)

Fixed submission:
s=input()
c=0
tmp=0
for i in range(3):
    if s[i]=='R':
        tmp+=1
        if c<tmp:
            c=tmp
    else:
        tmp=0
print(c)

Buggy python submission (verdict: Runtime Error):
s=input()
c=0
tmp=0
for i in range(3):
    if s[i]='s':
        tmp+=1
        if c<tmp:
            c=tmp
    else:
        tmp=0
print(c)

Fixed submission:
s=input()
c=0
tmp=0
for i in range(3):
    if s[i]=='R':
        tmp+=1
        if c<tmp:
            c=tmp
    else:
        tmp=0
print(c)
Buggy python submission (verdict: Runtime Error):
s=input()
f==-1
if s[2]==s[3]:
    if s[4]==s[5]:
        f==1
if f==1:
    print('Yes')
else:
    print('No')

Fixed submission:
s=input()
f=-1
if s[2]==s[3]:
    if s[4]==s[5]:
        f=1
if f==1:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
A=math.ceil((a+1)/0.08)-1
B=math.ceil((b+1)/0.1)-1
A_=math.ceil(a/0.08)
B_=math.ceil(b/0.1)
C=math.floor(B*0.1)-mah.floor(B*0.08)
if b>80 or A<B_ or b-a>C:
    print(-1)
else:
    print(A_)


Fixed submission:
import math
a,b=map(int,input().split())
f=0
for i in range(1,1001):
    if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
        f=i
        break;
if f==0:
    print(-1)
else:
    print(f)
Buggy python submission (verdict: Runtime Error):
s=input()
n=int(input())
r=-1
f=[]
b=[]
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==-1 or t*r==2 :
            f.append(q[2])
        else:
            b.append(q[2])
s=f[::-1]+s+b
if r==1:
    s=s[::-1]
print(s)
            


Fixed submission:
s=input()
n=int(input())
r=-1
f=[]
b=[]
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==-1 or t*r==2 :
            f.append(q[2])
        else:
            b.append(q[2])
f=''.join(f)
b=''.join(b)
s=f[::-1]+s+b
if r==1:
    s=s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=int(input())
r=-1
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==-1 or t*r==2 :
            s=q[2]+s
        else:
            s=s+q[2]
if r==1:
    s=s[::-1]
print(s)
            


Fixed submission:
s=input()
n=int(input())
r=-1
f=[]
b=[]
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==-1 or t*r==2 :
            f.append(q[2])
        else:
            b.append(q[2])
f=''.join(f)
b=''.join(b)
s=f[::-1]+s+b
if r==1:
    s=s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=int(input())
r=-1
for i in range(n):
    q=list(input().split())
    if q[0]=='1':
        r*=-1
    else:
        if q[1]=='1':
            if r==-1:
                s=q[2]+s
            else:
                s=s+q[2]
        else:
            if r==-1:
                s=s+q[2]
            else:
                s=q[2]+s
if r==1:
    s=s[::-1]
print(s)
            


Fixed submission:
s=input()
n=int(input())
r=-1
f=[]
b=[]
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==-1 or t*r==2 :
            f.append(q[2])
        else:
            b.append(q[2])
f=''.join(f)
b=''.join(b)
s=f[::-1]+s+b
if r==1:
    s=s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
n=int(input())
for i in range(n):
    q=list(input().split())
    if q[0]=='1':
        s=s[::-1]
    else:
        if q[1]=='1':
            s=q[2]+s
        else:
            s=s+q[2]
print(s)
            


Fixed submission:
s=input()
n=int(input())
r=-1
f=[]
b=[]
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==-1 or t*r==2 :
            f.append(q[2])
        else:
            b.append(q[2])
f=''.join(f)
b=''.join(b)
s=f[::-1]+s+b
if r==1:
    s=s[::-1]
print(s)