Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# import sys

def main():
    # input = sys.stdin.readline
    s = input()
    t = input()

    res = len(t)
    # 部分文字列の探索
    for i in range(len(s)-len(t)+1):
        diff = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                diff += 1
        res = min(res, diff)
    print(res)
if __name__ == '__main__':
    main()

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    d, t, s = map(int, input().split(" "))

    if s * t < d:
        print("No")
    else:print("Yes")


if __name__ == "__main__":
    main()

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

def main():
    # input = sys.stdin.readline
    s = input()
    t = input()

    res = len(t)
    # 部分文字列の探索
    for i in range(len(s)-len(t)+1):
        diff = 0
        for j in range(len(t)):
            if s[i + j] != t[j]:
                diff += 1
        res = min(res, diff)
    print(res)
if __name__ == '__main__':
    main()

Fixed submission:
import sys

def main():
    input = sys.stdin.readline
    d, t, s = map(int, input().split(" "))

    if s * t < d:
        print("No")
    else:print("Yes")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):

def main():
    x, k, d = map(int, input().split())
    # x > 0
    if x < 0:
        x = -1 * x
    #the number of d in x
    r = abs(x) // d
    k_rest = k - r
    if r > 0 and k_rest < 0:
        print(x - k * d)
        exit()

    x_r = x - d * r
    x_l = x_r - d

    # print(f"xr: {x_r}\nxl: {x_l}\nk: {k_rest}")

    if k_rest % 2 == 0:
        print(abs(x_r))
    else:
        print(abs(x_l))

if __name__ == "__main__":
    main()


Fixed submission:
def main():
    s = input()
    if s == "RSR":
        print(1)
    else:
        cnt = 0
        for i in s:
            if i == "R":
                cnt += 1

        print(cnt)
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n, k = map(int, input().split())
    cnt = [0]*n
    for _ in range(k):
        d = int(input())
        A_i = list(map(int, input().split()))
        for i in range(1, n+1):
            if i not in A_i:
                cnt[i] += 1
    res = 0
    for j in cnt:
        if j == k:
            res += 1
    print(res)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, k = map(int, input().split())
    cnt = [0]*101
    for _ in range(k):
        d = int(input())
        A_i = list(map(int, input().split()))
        for i in range(1, n+1):
            if i not in A_i:
                cnt[i] += 1
    res = 0
    for j in cnt:
        if j == k:
            res += 1
    print(res)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):

def main():
    n, a, b = map(int, input().split())
    
    ball = [0]*n
    count = 0
    flag = True
    if a == 0 :
        print(0)
        exit(0)

    while flag:
        while flag:
            ball[count]="b"
            count += 1
            if count == n:
                flag = False
            if count % a == 0:
                break
    
        while flag:
            ball[count]="r"
            count += 1
            if count == n:
                flag = False
            if count % (a + b) == 0:
                break
            
     

    print(ball.count("b"))


if __name__ == "__main__":
    main()

Fixed submission:

def main():
    S = input()

    flag = False
    for i in range(2):
        tmp = S[i]
        if tmp != S[i+1]:
            flag = True
    if flag : print("Yes")
    else: print("No")

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

def main():
    n, a, b = map(int, input().split())
    flag = True
    res = n
    count = 0
    if a == 0:
        print(0)
        exit(0)
    count = res // (a + b)
    res = n - ( ( a + b ) * count )
    a_count = 0
    while True:
        if a_count == a or res == 0:
            break
        res -= 1
        a_count += 1
           
    print( a_count + a * count)
    
    


if __name__ == "__main__":
    main()

Fixed submission:

def main():
    n, a, b = map(int, input().split())
    res = n
    count = 0
    if a == 0:
        print(0)
        exit(0)
    count = res // (a + b)
    res = n - ( ( a + b ) * count )
    if a < res:
        print(a * (count + 1))
    else:
        print(a * count + res)
    


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):

def main():
    n, a, b = map(int, input().split())
    
    ball = [0]*n
    count = 0
    flag = True
    if a == 0 :
        print(0)
        exit(0)

    while flag:
        while flag:
            ball[count]="b"
            count += 1
            if count == n:
                flag = False
            if count % a == 0:
                break
    
        while flag:
            ball[count]="r"
            count += 1
            if count == n:
                flag = False
            if count % (a + b) == 0:
                break
            
     

    print(ball.count("b"))


if __name__ == "__main__":
    main()

Fixed submission:

def main():
    n, a, b = map(int, input().split())
    res = n
    count = 0
    if a == 0:
        print(0)
        exit(0)
    count = res // (a + b)
    res = n - ( ( a + b ) * count )
    if a < res:
        print(a * (count + 1))
    else:
        print(a * count + res)
    


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):

def main():
    n, a, b = map(int, input().split())
    
    ball = [0]*n
    count = 0
    flag = True
    if a == 0 :
        print(0)
        exit()

    while flag:
        while flag:
            ball[count]="b"
            count += 1
            if count == n:
                flag = False
            if count % a == 0:
                break
    
        while flag:
            ball[count]="r"
            count += 1
            if count == n:
                flag = False
            if count % (a + b) == 0:
                break
            
     

    print(ball.count("b"))


if __name__ == "__main__":
    main()

Fixed submission:

def main():
    n, a, b = map(int, input().split())
    res = n
    count = 0
    if a == 0:
        print(0)
        exit(0)
    count = res // (a + b)
    res = n - ( ( a + b ) * count )
    if a < res:
        print(a * (count + 1))
    else:
        print(a * count + res)
    


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[0]*3]*3
    for i in range(n):
        for j in range(n):
            card[i][j]  == False
            for k in range(n):
                if a[i][j] == b[k]:
                    card[i][j] = True
    ans = "No"
    for i in range(3): #横に見てる
        if card[i][0] and card[i][1] and card[i][2]:
            ans = "Yes"
    for i in range(3): # 縦に見てる
        if card[0][i] and card[1][i] and card[2][i]:
            ans = "Yes"
    if card[0][0] and card[1][1] and card[2][2]:
        ans = "Yes"
    if card[0][2] and card[1][1] and card[2][0]:
        ans = "Yes"
    print(ans)

    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    card = [[False]*3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                card[i][j] = True

    ans = "No"
    for i in range(3): #横に見てる
        if card[i][0] and card[i][1] and card[i][2]:
            ans = "Yes"
    for i in range(3): # 縦に見てる
        if card[0][i] and card[1][i] and card[2][i]:
            ans = "Yes"
    if card[0][0] and card[1][1] and card[2][2]:
        ans = "Yes"
    if card[0][2] and card[1][1] and card[2][0]:
        ans = "Yes"
    print(ans)

    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n, m = map(int, input().split())
    s, c = []*m, []*m
    for i in range(m):
        a, b = map(int, input())
        s.append(a), c.append(b)
    for i in range(0, 10 ** n):
        loop = True
        string = str(i)
        if len(string) != n:
            continue
        for j in range(m):
            if string[s[j] - 1] != str(c[j]):
                loop = False
        if loop:
            print(string)
            quit()
    print(-1)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, m = map(int, input().split())
    s, c = []*m, []*m
    for i in range(m):
        a, b = map(int, input().split())
        s.append(a), c.append(b)
    for i in range(0, 10 ** n):
        loop = True
        string = str(i)
        if len(string) != n:
            continue
        for j in range(m):
            if string[s[j] - 1] != str(c[j]):
                loop = False
        if loop:
            print(string)
            quit()
    print(-1)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):

def main():
    import math

    H = int(input())
    if H == 1:
        print(1)
    else:
        count = int(math.log(H, 2))
        ans = 0
        for i in range(count+1):
            ans += 2 ** (i)
            print(ans)

if __name__ == "__main__":
    main()

Fixed submission:

def main():
    H, A = map(int, input().split())
    count = 0
    while True:
        H -= A
        count += 1
        if H <= 0:
            break

    print(count)





if __name__ == "__main__":
    main()

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

def main():
    H = int(input())
    if H == 1:
        print(1)
    else:
        count = int(math.log(H, 2))
        ans = 0
        for i in range(count+1):
            ans += 2 ** (i)
            print(ans)

if __name__ == "__main__":
    main()

Fixed submission:

def main():
    H, A = map(int, input().split())
    count = 0
    while True:
        H -= A
        count += 1
        if H <= 0:
            break

    print(count)





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


def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    sort_H = sorted(H, reverse=True)
    count = 0
    top = K
    if K >= N:
        print(0)
    elif K == 0:
        print(sum(H))
    else:
        while True:
            flag = True
            while flag:
                sort_H[top] -= 1
                count += 1
                if sort_H[top]==0:
                    flag=False
                    top += 1
                    break
            if top == N:break
        print(count)


if __name__ == "__main__":
    main()

Fixed submission:


def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H = sorted(H, reverse=True)
    sum_H = 0
    for h in H:
        if K > 0:
            K -= 1
            continue
        sum_H += h
    print(sum_H)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, M= map(int, input().split())
    
    acList = [False] * N
    waList = [0] * N
    waCount = 0

    for _ in range(M):
        p, s = map(str, input().split())
        p = int(p) - 1
        if atList[p]:
            continue
        if s == "WA":
            waList[p] += 1
            continue
        waCount += waList[p]
        acList[p] = True

    print(sum(acList), waCount)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, M= map(int, input().split())
    
    acList = [False] * N
    waList = [0] * N
    waCount = 0

    for _ in range(M):
        p, s = map(str, input().split())
        p = int(p) - 1
        if acList[p]:
            continue
        if s == "WA":
            waList[p] += 1
            continue
        waCount += waList[p]
        acList[p] = True

    print(sum(acList), waCount)

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

def main()->None:
    A, B, K = map(int, input().split())
    range_K = range(K)
    
    for k in range_K:
        if A >= 1:
            A -= 1
        elif B >= 1:
            B -= 1
        if A == 0 and B == 0:
            continue

    print(A, B)





if __name__ == "__main__":
    main()

Fixed submission:

def main()->None:
    A, B, K = map(int, input().split())

    if A > K:
        print(A-K, B)
    else:
        diff = K - A
        if diff < B:
            print(0, B-diff)
        else:
            print(0, 0)





if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):

def is_prime(x: int)->None:
    # 解説見た
    if x <= 1:
        return True
    i: int = 2
    while i * i <= x:
        if x % i == 0:
            return True
        i += 1
    return False


def main()->None:
    X: int = int(input())
    p: int = X
    while is_prime(p):
        p += 1
    print(p)

if __name__ == "__main__":
    main()

Fixed submission:

def is_prime(x):
    # 解説見た
    if x <= 1:
        return True
    i = 2
    while i * i <= x:
        if x % i == 0:
            return True
        i += 1
    return False


def main():
    X = int(input())
    p = X
    while is_prime(p):
        p += 1
    print(p)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):


# 000から９９９まで決め打ちで全探索。計算量はO(1000*N)程度
def solution1():

    # 入力
    n = int(input())
    s = [int(i) for i in input()]
    cnt = 0
    for c in range(1000):
        candidate = [c/100, (c/10)%10, c%10]
        f = 0
        for j in range(n):
            if s[j] == ("0" + candidate[f]):
                f += 1
            if f == 2:
                break
        if f == 2:
            cnt += 1
    print(cnt)
if __name__ == "__main__":
    solution1()

Fixed submission:
def solution1():

    # 入力
    n = int(input())
    s = [int(i) for i in input()]
    cnt = 0
    for c in range(1000):
        # 100の桁、１０の桁、１の桁に分解
        candidate = [c//100, (c//10)%10, c%10]
        f = -1
        for j in range(n):
            if s[j] == candidate[f]:
                f += 1
            if f == 2:
                break
        if f == 2:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    solution1()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

def main():
    n = int(input())
    s = [int(i) for i in input()]
    candidate = []
    for c in combinations(s, 3):
        if c not in candidate:
            candidate.append(c)
    print(len(candidate))
if __name__ == "__main__":
    main()

Fixed submission:
def solution1():

    # 入力
    n = int(input())
    s = [int(i) for i in input()]
    cnt = 0
    for c in range(1000):
        # 100の桁、１０の桁、１の桁に分解
        candidate = [c//100, (c//10)%10, c%10]
        f = -1
        for j in range(n):
            if s[j] == candidate[f]:
                f += 1
            if f == 2:
                break
        if f == 2:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    solution1()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

def main():
    n = int(input())
    s = [int(i) for i in input()]
    candidate = []
    for c in combinations(s, 3):
        if c not in candidate:
            candidate.append(c)
    print(len(candidate))
if __name__ == "__main__":
    main()

Fixed submission:
def solution1():

    # 入力
    n = int(input())
    s = [int(i) for i in input()]
    cnt = 0
    for c in range(1000):
        # 100の桁、１０の桁、１の桁に分解
        candidate = [c//100, (c//10)%10, c%10]
        f = -1
        for j in range(n):
            if s[j] == candidate[f]:
                f += 1
            if f == 2:
                break
        if f == 2:
            cnt += 1
    print(cnt)

if __name__ == "__main__":
    solution1()
Buggy python submission (verdict: Runtime Error):
s = input()

if s == "SUN":
  return 7
if s == "MON":
  return 6
if s == "TUE":
  return 5
if s == "WED":
  return 4
if s == "THU":
  return 3
if s == "FRI":
  return 2
if s == "SAT":
  return 1


Fixed submission:
s = input()


if s == "SUN":
    print(7)
if s == "MON":
    print(6)
if s == "TUE":
    print(5)
if s == "WED":
    print(4)
if s == "THU":
    print(3)
if s == "FRI":
    print(2)
if s == "SAT":
    print(1)
Buggy python submission (verdict: Runtime Error):
r = map(int(), input())
print(r**2)

Fixed submission:
r = int(input())
print(r**2)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split(","))
if a > 2*b :
    print(a-2*b)
print(0)

Fixed submission:
a, b = map(int, input().split(" "))
if a > 2*b :
    print(a-2*b)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split(","))
if a > b :
    print(a-b)
print(0)

Fixed submission:
a, b = map(int, input().split(" "))
if a > 2*b :
    print(a-2*b)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a,b = input().split(',')
if a > b:
  print(a-b)
print(0)


Fixed submission:
a, b = map(int, input().split(" "))
if a > 2*b :
    print(a-2*b)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
a,b = map(int, inpout().split())
if a > b:
  print(a-b)
print(0)

Fixed submission:
a, b = map(int, input().split(" "))
if a > 2*b :
    print(a-2*b)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
def main():
    a = int(input())
    s = input()
    if a >= 3200:
        pritn(s)
    else:print("red")

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    a = int(input())
    s = input()
    if a >= 3200:
        print(s)
    else:print("red")

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    p_l = list(map(int, input().split()))
    cnt = 0
    for i in range(n):
        if p_l[i] == i + 1: continue
        else: cnt += 1
    if cnt > 2: print("NO")
    else: print("YES")
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    r = int(input())
    print( 3 * r ** 2)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):

# chmin can't use
# List in Python create copy by using slice

def main():
    INF = 10 ** 9
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    # memo of cost of i th avalable going range
    dp = [INF] * (N + 10)

    # condition of init
    dp[0] = 0

    #
    for i in range(N):
        for k in range(1, K+1):
            if i + k >= len(h):break
            tmp_cost = dp[i]+ abs(h[i] - h[i + k])
            if tmp_cost < dp[i + k]:
                dp[i + k] = tmp_cost
    print(dp[N-1])

if __name__ == "__main__":
    main()

Fixed submission:

# chmin can't use
# List in Python create copy by using slice

def main():
    INF = 10 ** 9
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    # memo of cost of i th avalable going range
    dp = [INF] * (N + 10)

    # condition of init
    dp[0] = 0

    #
    for i in range(N):
        for k in range(1, K+1):
            if i + k >= len(h):break
            tmp_cost = dp[i]+ abs(h[i] - h[i + k])
            if tmp_cost < dp[i + k]:
                dp[i + k] = tmp_cost
    print(dp[N-1])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):

# chmin can't use
# List in Python create copy by using slice

def main():
    INF = 10 ** 9
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    # memo of cost of i th avalable going range
    dp = [INF] * (N + 10)

    # condition of init
    dp[0] = 0

    for i in range(N):
        for k in range(1, K+1):
            if i + k >= len(h):continue
            if dp[i]+ abs(h[i] - h[i + k]) < dp[i + k]:
                dp[i + k] = dp[i]+abs(h[i] - h[i + k])

    print(dp[N-1])



if __name__ == "__main__":
    main()

Fixed submission:

# chmin can't use
# List in Python create copy by using slice

def main():
    INF = 10 ** 9
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    # memo of cost of i th avalable going range
    dp = [INF] * (N + 10)

    # condition of init
    dp[0] = 0

    #
    for i in range(N):
        for k in range(1, K+1):
            if i + k >= len(h):break
            tmp_cost = dp[i]+ abs(h[i] - h[i + k])
            if tmp_cost < dp[i + k]:
                dp[i + k] = tmp_cost
    print(dp[N-1])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits

N = int(input())
range_A = range(2,100001)
min_total = 1000
for a in range_A:
	b = N - a
    if b < 1:continue
	sum_a = findSumOfDigits(a)
	sum_b = findSumOfDigits(b)
	total = sum_a + sum_b
	if total < min_total:
	min_total = total
print(min_total)

Fixed submission:


#　各桁の和を計算する
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits


def main()->None:
    N = int(input())
    # AとBの各桁の和を求める。
    range_A = range(1,N+1)
    min_total = 100000
    for a in range_A:
        b = N - a
        if b < 1 : continue
        sum_a = findSumOfDigits(a)
        sum_b = findSumOfDigits(b)
        total = sum_a + sum_b
        if total < min_total:
            min_total = total
    print(min_total)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
N = int(input())
range_A = range(2,100001)
min_total = 1000
for a in range_A:
	b = N - a
	if b < 1:continue
	sum_a = findSumOfDigits(a)
	sum_b = findSumOfDigits(b)
	total = sum_a + sum_b
    if total < min_total:
		min_total = total
print(min_total)



Fixed submission:


#　各桁の和を計算する
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits


def main()->None:
    N = int(input())
    # AとBの各桁の和を求める。
    range_A = range(1,N+1)
    min_total = 100000
    for a in range_A:
        b = N - a
        if b < 1 : continue
        sum_a = findSumOfDigits(a)
        sum_b = findSumOfDigits(b)
        total = sum_a + sum_b
        if total < min_total:
            min_total = total
    print(min_total)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
N = int(input())
range_A = range(2,50)
min_total = 1000
for a in range_A:
	b = abs(N - a)
	sum_a = findSumOfDigits(a)
	sum_b = findSumOfDigits(b)
	total = sum_a + sum_b
	if total < min_total:
		min_total = total
print(min_total)

Fixed submission:


#　各桁の和を計算する
def findSumOfDigits(n):
    sum_digits = 0
    while n > 0 :
        sum_digits += n % 10
        n //= 10
    return sum_digits


def main()->None:
    N = int(input())
    # AとBの各桁の和を求める。
    range_A = range(1,N+1)
    min_total = 100000
    for a in range_A:
        b = N - a
        if b < 1 : continue
        sum_a = findSumOfDigits(a)
        sum_b = findSumOfDigits(b)
        total = sum_a + sum_b
        if total < min_total:
            min_total = total
    print(min_total)


if __name__ == "__main__":
    main()