Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

balls = ""
while True:
    for i in range(A):
        balls += "b"
    for i in range(B):
        balls += "r"
    if len(balls) >= N:
        break

print(balls[:N].count("b"))


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

ans = A * (N // (A + B))
if N % (A + B) > A:
    ans += A
else:
    ans += N % (A + B)

print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    s = [0] * M
    c = [0] * M
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    for i in range(M):
        if s[i] == 1 and c[i] == 0 and N > 1:
            print(-1)
            exit()

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    for i in range(M - 1):
        if s[i] == s[i + 1]:
            if c[i] != c[i + 1]:
                print(-1)
                exit()

    for i in range(1, N + 1):
        if i not in s:
            s.append(i)
            if i == 1:
                c.append(1)
            else:
                c.append(0)

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    k = 1
    ans = ''
    for i in range(len(s)):
        if s[i] == k:
            ans += str(c[i])
            k += 1
    print(ans)




if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    s = [0] * M
    c = [0] * M
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    if M == 0:
        if N == 1:
            print(0)
            exit()
        elif N == 2:
            print(10)
            exit()
        elif N == 3:
            print(100)
            exit()

    for i in range(M):
        if s[i] == 1 and c[i] == 0 and N > 1:
            print(-1)
            exit()

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    for i in range(M - 1):
        if s[i] == s[i + 1]:
            if c[i] != c[i + 1]:
                print(-1)
                exit()

    for i in range(1, N + 1):
        if i not in s:
            s.append(i)
            if i == 1:
                c.append(1)
            else:
                c.append(0)

    z = zip(s, c)
    z = sorted(z)
    s, c = zip(*z)
    s = list(s)
    c = list(c)

    k = 1
    ans = ''
    for i in range(len(s)):
        if s[i] == k:
            ans += str(c[i])
            k += 1
    print(ans)




if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    T = sorted(list(set(S)))
    C = []
    for i in T:
        C.append(S.count(i))

    for i in range(len(C)):
        if C[i] == max(C):
            print(T[i])

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    T = sorted((set(S)))
    l = len(T)

    D = {}
    for i in range(l):
        D[T[i]] = 0
    for i in range(N):
        D[S[i]] += 1

    m = max(D.values())
    for i in range(l):
        if D[T[i]] == m:
            print(T[i])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    T = list(set(sorted(S)))
    C = []
    for i in T:
        C.append(S.count(i) * -1)

    Z = zip(C, T)
    Z = sorted(Z)
    C, T = zip(*Z)

    for i in range(len(C)):
        if C[i] == min(C):
            print(T[i])

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    T = sorted((set(S)))
    l = len(T)

    D = {}
    for i in range(l):
        D[T[i]] = 0
    for i in range(N):
        D[S[i]] += 1

    m = max(D.values())
    for i in range(l):
        if D[T[i]] == m:
            print(T[i])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    T = list(set(sorted(S)))
    C = []
    for i in T:
        C.append(S.count(i) * -1)

    Z = zip(C, T)
    Z = sorted(Z)
    C, T = zip(*Z)

    for i in range(len(C)):
        if C[i] == min(C):
            print(T[i])

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    T = sorted((set(S)))
    l = len(T)

    D = {}
    for i in range(l):
        D[T[i]] = 0
    for i in range(N):
        D[S[i]] += 1

    m = max(D.values())
    for i in range(l):
        if D[T[i]] == m:
            print(T[i])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    ans = 1
    for i in range(1, N):
        if min(P[:i]) >= P[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    ans = 1
    m = P[0]
    for i in range(1, N):
        if P[i - 1] < m:
            m = P[i - 1]
        if m >= P[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

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

ans = 1
for i in range(1, N):
    if min(P[0:i]) >= P[i]:
        ans += 1
print(ans)


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    ans = 1
    m = P[0]
    for i in range(1, N):
        if P[i - 1] < m:
            m = P[i - 1]
        if m >= P[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

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

ans = 1
for i in range(1, N):
    count = 0
    for j in range(i):
        if P[i] <= P[j]:
            count += 1
    if count == i:
        ans += 1
print(ans)

Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    ans = 1
    m = P[0]
    for i in range(1, N):
        if P[i - 1] < m:
            m = P[i - 1]
        if m >= P[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    X = int(input())

    for i in range(10**5):
        num = X + i
        list = get_sieve_of_eratosthenes(num)
        if num in list:
            print(num)
            exit()


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

#引数nが素数かどうかを判定
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1

def main():
    X = int(input())
    for i in range(X, 10**8):
        if is_prime(i):
            print(i)
            exit()

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from itertools import product
def input():
    return sys.stdin.readline()[:-1]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def main():
    N = int(input())

    arr = factorization(N)
    l = []
    for i in arr:
        for j in range(i[1]):
            l.append(i[0])

    A = 10**13
    B = 10**13
    for i in product([0, 1], repeat=len(l)):
        a = 1
        b = 1
        for k in range(len(l)):
            if i[k] == 0:
                a *= l[k]
            if i[k] == 1:
                b *= l[k]
        if a + b < A + B:
            A = a
            B = b
    print(A + B - 2)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

def main():
    N = int(input())

    ans = 1e18
    for i in range(1, N + 1):
        if i * i > N:
            break
        if N % i != 0:
            continue
        j = N // i
        ans = min(ans, i + j - 2)
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = ''
for i in range(N):
    ans += str(A.index(i + 1) + 1) + ' '

print(ans.strip())


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

arr = [0] * N
for i in range(N):
    arr[A[i] - 1] = i + 1

print(*arr)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

maximum = max(A)
for i in range(N):
    if A[i] != maximum:
        print(maximum)
    else:
        num = A[i]
        A[i] = 0
        print(max(A))
        A[i] = num
        

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

maximum = max(A)
count_max = A.count(maximum)
if count_max > 1:
    for i in range(N):
        print(maximum)
else:
    for i in range(N):
        if A[i] != maximum:
            print(maximum)
        else:
            num = A[i]
            A[i] = 0
            print(max(A))
            A[i] = num

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    num = A[i]
    A[i] = 0
    print(max(A))
    A[i] = num


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

maximum = max(A)
count_max = A.count(maximum)
if count_max > 1:
    for i in range(N):
        print(maximum)
else:
    for i in range(N):
        if A[i] != maximum:
            print(maximum)
        else:
            num = A[i]
            A[i] = 0
            print(max(A))
            A[i] = num
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

r = []

if A%10 != 0:
    r.append(10 - A%10)
    A += 10 - A%10
if B%10 != 0:
    r.append(10 - B%10)
    B += 10 - B%10
if C%10 != 0:
    r.append(10 - C%10)
    C += 10 - C%10
if D%10 != 0:
    r.append(10 - D%10)
    D += 10 - D%10
if E%10 != 0:
    r.append(10 - E%10)
    E += 10 - E % 10

print(A+B+C+D+E-max(r))


Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

r = []

if A%10 != 0:
    r.append(10 - A%10)
    A += 10 - A%10
if B%10 != 0:
    r.append(10 - B%10)
    B += 10 - B%10
if C%10 != 0:
    r.append(10 - C%10)
    C += 10 - C%10
if D%10 != 0:
    r.append(10 - D%10)
    D += 10 - D%10
if E%10 != 0:
    r.append(10 - E%10)
    E += 10 - E % 10

if r:
    print(A+B+C+D+E-max(r))
else:
    print(A+B+C+D+E)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()

    ans = 0

    for i in range(10**4):
        if '0011' in S:
            ans += 4 * S.count('0011')
            S = S.replace('0011', '')
        if '1010' in S:
            ans += 4 * S.count('1010')
            S = S.replace('1010', '')
        if '0101' in S:
            ans += 4 * S.count('0101')
            S = S.replace('0101', '')
        if '1100' in S:
            ans += 4 * S.count('1100')
            S = S.replace('1100', '')
    for i in range(10**4):
        if '01' in S:
            ans += 2 * S.count('01')
            S = S.replace('01', '')
        if '10' in S:
            ans += 2 * S.count('10')
            S = S.replace('10', '')
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()

    ans = min(S.count('0'), S.count('1'))
    print(ans * 2)


if __name__ == '__main__':
    main()

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

ans = 0
while True:
    if '0011' in S:
        ans += 2
        i = S.index('0011')
        S = S[: i + 1] + S[i+3:]
    elif '1010' in S:
        ans += 2
        i = S.index('1010')
        S = S[: i + 1] + S[i+3:]
    elif '0101' in S:
        ans += 2
        i = S.index('0101')
        S = S[: i + 1] + S[i+3:]
    elif '1100' in S:
        ans += 2
        i = S.index('1100')
        S = S[: i + 1] + S[i+3:]
    else:
        break

while True:
    if '01' in S:
        ans += 2
        i = S.index('01')
        S = S[: i] + S[i+2:]
    elif '10' in S:
        ans += 2
        i = S.index('10')
        S = S[: i] + S[i+2:]
    else:
        break

print(ans)


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()

    ans = min(S.count('0'), S.count('1'))
    print(ans * 2)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()
    K = int(input())

    T = ''
    for i in range(len(S)):
        if S[i] == '1':
            T += '1'
        else:
            T += S[i] * K

        if S[i] != '1':
            break

    print(T[K - 1])


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()
    K = int(input())

    if K >= 1e3:
        K = 105

    T = ''
    for i in range(len(S)):
        if S[i] == '1':
            T += '1'
        else:
            T += S[i] * K

        if S[i] != '1':
            break

    print(T[K - 1])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()
    K = int(input())

    c = 0
    for i in range(len(S)):
        if S[i] == '1':
            c += 1
        else:
            break
    if c >= 1 and K <= c:
        print(1)

    T = S.replace('1', '')
    print(T[0])


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()
    K = int(input())

    if K >= 1e3:
        K = 105

    T = ''
    for i in range(len(S)):
        if S[i] == '1':
            T += '1'
        else:
            T += S[i] * K

        if S[i] != '1':
            break

    print(T[K - 1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr

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

    ans = 0
    for i in a:
        arr = factorization(i)
        for j in range(len(arr)):
            if arr[j][0] == 2:
                ans += arr[j][1]
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    ans = 0
    for i in range(N):
        while a[i] % 2 == 0:
            a[i] = a[i] // 2
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a*b % 2 == 0:
  print('Even')
else:
  print('Odd)

Fixed submission:
a, b = map(int, input().split())
if int(a*b) % 2 == 0:
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
64145 123 456

Fixed submission:
x, y, z = map(int, input().split())

x -= z
y += z
print(x // y)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

A = set(a)

ans = 0
for i in A:
    cnt = 0
    J = [i, i - 1, i + 1]
    for j in J:
        if j in a:
            cnt += a.count(j)
    ans = max(ans, cnt)
print(ans)


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

cnt = [0] * (10**5 + 2)

for i in a:
    cnt[i] += 1
    cnt[i + 1] += 1
    cnt[i + 2] += 1

print(max(cnt))

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

A = set(a)

ans = 0
for i in A:
    cnt = 0
    for j in a:
        if j == i or j == i + 1 or j == i - 1:
            cnt += 1
    ans = max(ans, cnt)
print(ans)


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

cnt = [0] * (10**5 + 2)

for i in a:
    cnt[i] += 1
    cnt[i + 1] += 1
    cnt[i + 2] += 1

print(max(cnt))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    l = [0] * 9
    for i in range(N):
        l[a[i] // 400] += 1

    ans_min = 0
    for i in range(8):
        if l[i] > 0:
            ans_min += 1

    gold = l[8]
    if gold > 8:
        gold = 8

    if ans_min == 0:
        ans_min = 1

    ans_max = ans_min
    non_color = l.count(0)
    if gold >= non_color:
        ans_max = 8
    else:
        ans_max += gold

    print(ans_min, ans_max)


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    l = [0] * 9
    for i in range(N):
        n = a[i] // 400
        if n > 8:
            n = 8
        l[n] += 1

    ans_min = 0
    for i in range(8):
        if l[i] > 0:
            ans_min += 1



    gold = l[8]

    ans_max = ans_min
    ans_max += gold

    if ans_min == 0:
        ans_min = 1

    print(ans_min, ans_max)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
N = int(input())
a = list(map(int, input().split()))

c = [0] * 9
for i in a:
    c[i // 400] += + 1

ans_min = 0
for i in range(8):
    if c[i] > 0:
        ans_min += 1

ans_max = ans_min
if c[-1] == 0:
    pass
else:
    f = c[-1]
    g = c.count(0)
    ans_max += min(f, g)

print(ans_min, ans_max)


Fixed submission:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    l = [0] * 9
    for i in range(N):
        n = a[i] // 400
        if n > 8:
            n = 8
        l[n] += 1

    ans_min = 0
    for i in range(8):
        if l[i] > 0:
            ans_min += 1



    gold = l[8]

    ans_max = ans_min
    ans_max += gold

    if ans_min == 0:
        ans_min = 1

    print(ans_min, ans_max)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=512
while b:
  b-=1;r=t=j=0;d=[0]*h
  while w-j:
    i=c=0
    while h-i:
      d[c]+=s[i][j]>'0';f=d[c]>k
      if(t<j)&f: r+=1;t=j;d[0]*h;break
      r+=h*w*f;c+=b>>i&1;i+=1
    else:j+=1;v=c
  m+=r+v
print(min(m))

Fixed submission:
h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=w
while b:
 b-=1;r=0;t=j=w;d=[0]*h
 while j:
  i=c=0;j-=1
  while h-i:
   d[c]+=s[i][j]>'0';c+=b>>i&1;i+=1
   if max(d)>k:d=[0]*h;r+=1;t,j=j,j+(t>j);i=h
 m+=r+c,
print(min(m))

Buggy python submission (verdict: Runtime Error):
x,*s=open(0)
h,w,k,*m=map(int,x.split())
for b in range(512):
  r=t=j=0;d[0]*h
  while w-j:
    i=c=0
    while(h-i):
      d[c]+=s[i][j]>'0'; x=d[c]>k
      if(t<j)&x:r+=1;t=j;d=[0]*h;break
      r+=h*w*x;c+=b>>i&1;i+=1
      else:j+=1
  m+=r+bin(b).count('1'),
print(min(m))

Fixed submission:
h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=w
while b:
 b-=1;r=0;t=j=w;d=[0]*h
 while j:
  i=c=0;j-=1
  while h-i:
   d[c]+=s[i][j]>'0';c+=b>>i&1;i+=1
   if max(d)>k:d=[0]*h;r+=1;t,j=j,j+(t>j);i=h
 m+=r+c,
print(min(m))
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K = map(int,input().split())
result = 0
#A分引く
if (K - A) < 0:
    for i in range(A):
        if K <= 0:
            break
        result = result + 1
        K  -= 1
else:
    K -= A
    result += 1*A

if (K-B) < 0:
    for i in range(B):
        if K <= 0:
            break
        K -= 1
else:
    K -= B

if (K-C) < 0:
    for i in range(C):
        if K <= 0:
            break
        K -= 1
        result -= 1
else:
    K -= C
    result -= C
print(result)
    


Fixed submission:
A,B,C,K = map(int,input().split())

def abc(A,B,C,K):
    result = 0
    #A分引く
    K = K - A
    result = A + result
    if K < 0:
        K = K + A
        result -= abs(abs(K)-A)
        return result
    K -= B
    if K < 0:
        return result
    K -= C
    result -= C
    if K < 0:
        K += C
        result += abs(abs(K)-C)
    return result
print(abc(A,B,C,K))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
for i in range(1, 1001):
  if floor(i * 0.08) == a and floor(i * 0.1) == b:
    print(i)
else:
  print('-1')


Fixed submission:
s = input()
for i in range(0,2):
  if s[i] != s[i+1]:
    print('Yes')
    break
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
ans = int(n / (a + b))
rem = n % (a + b)
if rem > a:
    print(ans * a + a)
else:
    print(ans * a + rem)

Fixed submission:
s = input()
for i in range(0,2):
  if s[i] != s[i+1]:
    print('Yes')
    break
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
f = False
if s[0] != s[1]:
  f = True
elif s[1] != s[2]:
  f = True
  
if f == True:
  print('Yes')
else
  print('No')

Fixed submission:
s = input()
for i in range(0,2):
  if s[i] != s[i+1]:
    print('Yes')
    break
else:
  print('No')