Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl = list(input())
ans = 0
for i in range(1000):
    try:
        i_zero = str(i)
        i_zero = i_zero.zfill(3)
        for j1,s in  enumerate (sl):
            if s == i_zero[0]:
                for j2,s in enumerate(sl[j1+1:],j1+1):
                    if s == i_zero[1]:
                        for j3,s in enumerate(sl[j2+1:],j2+1):
                            if s == i_zero[2]:
                                ans += 1
                                break
                        break
                break
    except:
        pass
print(ans)

Fixed submission:
n = input()
sl = input()
ans = 0
for i in range(1000):
    i_zero = str(i)
    i_zero = i_zero.zfill(3)
    if i_zero[0] in sl:
        a = sl.index(i_zero[0])+1
        if i_zero[1] in sl[a:]:
            a = sl[a:].index(i_zero[1])+a+1
            if i_zero[2] in sl[a:]:
                ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
syo = -1
dai = 10**9+1
ans = 0
while abs(dai-syo)!=1:
    n = (dai+syo)//2
    en = a*n+b*len(str(int(n)))
    if en > x:
        dai = n
    else:
        ans = syo = n
print(ans)

Fixed submission:
d = {"SUN":1,"MON":2,"TUE":3,"WED":4,"THU":5,"FRI":6,"SAT":7}
print(8-d[input()])

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = ""
for m in input():
    s += chr((ord(m)+n-ord("A"))%26+ord("A"))
print(s)

Fixed submission:
d = {"SUN":1,"MON":2,"TUE":3,"WED":4,"THU":5,"FRI":6,"SAT":7}
print(8-d[input()])
Buggy python submission (verdict: Runtime Error):
n = int(input()) #お札の枚数
p = int(input()) #目標金額

x = p//10000
y = (p - x*10000)//5000
z = int((p - x*10000 - y*5000)/1000)
if x+z+y>n:
    x = y = z = -1
print('{} {} {}'.format(x,y,z))

Fixed submission:
n,p = map(int,input().split())
res10000 = res5000 = res1000 = -1
x = y = 0
end = False
for x in range(n+1):
    if end:
        break
    for y in range(n+1-x):
        if x*10000+y*5000+ (n-(x+y))*1000 == p:
            res10000 = x
            res5000 = y
            res1000 = n-(x+y)
            end = True
print('{} {} {}'.format(res10000,res5000,res1000))
Buggy python submission (verdict: Runtime Error):
k = ["ABC":"ARC","ARC":"ABC"]
print(k[input()])

Fixed submission:
k = {"ABC":"ARC","ARC":"ABC"}
print(k[input()])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def l(): return [int(a) for a in input().split(" ")] 
ka = l()
lis = {}
saku = []
for i,a in zip(range(ka[0]),l()):
  lis[i+1] = a
for _ in range(ka[1]):
  q = l()
  maxindex = []
  a = [[lis[a],a] for a in q if a in lis]
  maxv = max(a)
  for b in a:
    if maxv[0] == b[0]:
      maxindex.append(b)
  q.pop(q.index(maxv[1]))
  if len(maxindex) != 1:
    for m in maxindex:
      q.append(m[1])
  for a in q:
    saku.append(a)
print(len([a for a in lis if a not in saku]))
  
  
  

Fixed submission:
import sys
input = sys.stdin.readline
def l(): return [int(a) for a in input().split(" ")] 
ka = l()
lis = {}
saku = []
for i,a in zip(range(ka[0]),l()):
  lis[i+1] = a
for _ in range(ka[1]):
  q = l()
  maxindex = []
  a = [[lis[a],a] for a in q if a in lis]
  maxv = max(a)
  for b in a:
    if maxv[0] == b[0]:
      maxindex.append(b)
  q.pop(q.index(maxv[1]))
  if len(maxindex) != 1:
    for m in maxindex:
      q.append(m[1])
  for a in q:
    saku.append(a)
saku = set(saku)
print(len([a for a in lis if a not in saku]))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def l(): return [int(a) for a in input().split(" ")] 
ka = l()
lis = {}
saku = []
for i,a in zip(range(ka[0]),l()):
  lis[i+1] = a
for _ in range(ka[1]):
  q = l()
  maxindex = []
  a = [[lis[a],a] for a in q if a in lis]
  maxv = max(a)
  for b in a:
    if maxv[0] == b[0]:
      maxindex.append(b)
  q.pop(q.index(maxv[1]))
  if len(maxindex) != 1:
    for m in maxindex:
      q.append(m[1])
  for a in q:
    saku.append(a)
print(len([a for a in lis if a not in saku]))
  
  
  

Fixed submission:
import sys
input = sys.stdin.readline
def l(): return [int(a) for a in input().split(" ")] 
ka = l()
lis = {}
saku = []
for i,a in zip(range(ka[0]),l()):
  lis[i+1] = a
for _ in range(ka[1]):
  q = l()
  maxindex = []
  a = [[lis[a],a] for a in q if a in lis]
  maxv = max(a)
  for b in a:
    if maxv[0] == b[0]:
      maxindex.append(b)
  q.pop(q.index(maxv[1]))
  if len(maxindex) != 1:
    for m in maxindex:
      q.append(m[1])
  for a in q:
    saku.append(a)
saku = set(saku)
print(len([a for a in lis if a not in saku]))
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
for a in range(1000000000000000):
  for b in range(1000000000000000):
    if a ** 5 - b ** 5 == x:
      print(str(a)+" "+str(b))
    

Fixed submission:
x = int(input())
import sys
for a in range(1000):
  for b in range(1000):
    if (a ** 5 - b ** 5) == x:
      print(str(a)+" "+str(b))
      sys.exit()
    elif(a ** 5 - (-b) ** 5) == x:
      print(str(a)+" "+str(-b))
      sys.exit()
    elif((-a) ** 5 - b ** 5) == x:
      print(str(-a)+" "+str(b))
      sys.exit()
    elif((-a) ** 5 - (-b) ** 5) == x:
      print(str(-a)+" "+str(-b))
      sys.exit()
Buggy python submission (verdict: Runtime Error):
a = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(",")
print(a[int(input())])

Fixed submission:
a = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(",")
print(a[int(input())-1])
Buggy python submission (verdict: Runtime Error):
num = input().split(" ")
ki = int(num[1]) - gu
gu = int(num[1]) // 2
sum_kaku = 0
a = 0
while a < int(num[0]):
  if a % 2 == 0:
    sum_kaku += ki
  else:
    sum_kaku += gu
  a += 1
print(sum_kaku)
  

Fixed submission:
num = input().split(" ")
if "1" in num:
  print(1)
else:
	gu = int(num[1]) // 2
	ki = int(num[1]) - int(gu)
	gu2 = int(num[0]) // 2
	ki2 = int(num[0]) - int(gu2)
	print(gu * gu2 + ki * ki2)

Buggy python submission (verdict: Time Limit Exceeded):
num = input().split(" ")
ki = 0
gu = 0
sum_kaku = 0
for a in range(int(num[1])):
  if (a+1) % 2 == 0:
    gu += 1
  else:
    ki += 1
a = 0
while a < int(num[0]):
  if a % 2 == 0:
    sum_kaku += ki
  else:
    sum_kaku += gu
  a += 1
print(sum_kaku)
  

Fixed submission:
num = input().split(" ")
if "1" in num:
  print(1)
else:
	gu = int(num[1]) // 2
	ki = int(num[1]) - int(gu)
	gu2 = int(num[0]) // 2
	ki2 = int(num[0]) - int(gu2)
	print(gu * gu2 + ki * ki2)

Buggy python submission (verdict: Time Limit Exceeded):
num = input().split(" ")
ki = 0
gu = 0
sum_kaku = 0
for a in range(int(num[1])):
  if (a+1) % 2 == 0:
    gu += 1
  else:
    ki += 1
a = 0
while a < int(num[0]):
  if a % 2 == 0:
    sum_kaku += ki
  else:
    sum_kaku += gu
  a += 1
print(sum_kaku)
  

Fixed submission:
num = input().split(" ")
if "1" in num:
  print(1)
else:
	gu = int(num[1]) // 2
	ki = int(num[1]) - int(gu)
	gu2 = int(num[0]) // 2
	ki2 = int(num[0]) - int(gu2)
	print(gu * gu2 + ki * ki2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = int(input())
s = 0
q = 0
while s < n:
    s += (d * 2 + 1)
    q += 1

print(q)

Fixed submission:
m = input()
m = m.split(' ')
n = int(m[0])
d = int(m[1])
s = 0
q = 0
while s < n:
    s += (d * 2 + 1)
    q += 1

print(q)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split(' '))
d = int(input())
lst = [map(int,input().split(' ')) for i in range(K+1)]
lst1 = [0]*N
decision_flag = True
for i in lst:
    if decision_flag == True:
        decision_flag = False
        for i1 in i:
            lst1[i1-1] = 1

    else:
        decision_flag = True
print(lst1.count(0))

Fixed submission:
N,K = map(int,input().split(' '))

sunuke = [1] * N

for i in range(K):
    di = int(input())
    tmp = map(int, input().split())
    for t in tmp:
        sunuke[t - 1] = 0

print(sum(sunuke))
Buggy python submission (verdict: Runtime Error):
 = input()
lst = {"MON":0,"TUE":1,"WED":2,"THU":3,"FRI":4,"SAT":5,"SUN":6}

ans = lst[S]
if ans == 6:
    print(7)
else:
    print(7-ans-1)


Fixed submission:
S = input()
lst = {"MON":0,"TUE":1,"WED":2,"THU":3,"FRI":4,"SAT":5,"SUN":6}

ans = lst[S]
if ans == 6:
    print(7)
else:
    print(7-ans-1)
Buggy python submission (verdict: Time Limit Exceeded):
import queue

N = int(input())
stack = queue.Queue()
stack.put([1,1,0])
count = 0
while True:
    point = stack.get()
    point0,point1,point2 = point[0],point[1],point[2]+1
    point_x = [point0+1,point1,point2]
    point_y = [point0,point1+1,point2]
    if point_x[0] * point_x[1] == N:
        print(point_x[2])
        break
    if point_y[0] * point_y[1] == N:
        print(point_y[2])
        break
    stack.put(point_x)
    stack.put(point_y)


Fixed submission:
import math
N = int(input())

for i in range(int(math.sqrt(N))+1,0,-1):
    if N%i == 0:
        j = N//i
        print(j+i-2)
        break
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int,input().split(' ')))
p1 = p.copy()
p1.sort()
for i in range(N):
    for i1 in range(i,N):
        p2 = p.copy()
        p2[i],p2[i1] = p2[i1],p2[i]
        if p2 == p1:
            print("YES")
            exit()
print("NO")


Fixed submission:
N = int(input())
p = list(map(int,input().split(' ')))
p1 = p.copy()
p1.sort()
for i in range(N):
    for i1 in range(i,N):
        p2 = p.copy()
        p2[i],p2[i1] = p2[i1],p2[i]
        if p2 == p1:
            print("YES")
            exit()
print("NO")
Buggy python submission (verdict: Runtime Error):
import bisect
N,M = map(int,input().split())
L_list,M_list = [],[]
for i in range(M):
    l,m = map(int,input().split())
    L_list.append(l)
    M_list.append(m)

L_list.sort()
M_list.sort()
lmax = L_list[-1]
mmin = M_list[0]
min = bisect.bisect_left(n,lmax)
max = bisect.bisect_left(n,mmin)
if min == max:
    ans = 1
else:
    ans = max - min
    ans += 1
print(ans)


Fixed submission:
N,M = map(int,input().split())
lmax,mmin = 0,1000000
for i in range(M):
    l,m = map(int,input().split())
    if lmax < l:
        lmax = l
    if mmin > m:
        mmin = m

if lmax > mmin:
    ans = 0
elif lmax == mmin:
    ans = 1
else:
    ans = mmin-lmax
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = []
n = N
for i in range(2 ** n):
    cost,value = 0,0
    for i1 in range(n):
        if ((i >> i1) & 1):
             cost += C[i1]
             value += V[i1]
    ans.append(value-cost)

print(max(ans))


Fixed submission:
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
cost = []
ans = 0
for i in range(N):
    cost.append(V[i] - C[i])

for i in cost:
    if i > 0:
        ans += i

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int,input().split()))
sum = 1
result = 0
if H[0] <= H[1]:
    result = H[1]
else:
    result = H[0]
for i in range(1,len(H)):
    if H[i-1] <= H[i] and result <= H[i]:
        sum += 1

print(sum)


Fixed submission:
N = int(input())
H = list(map(int,input().split()))
count,ans = 0,0
for i in H:
    if count <= i:
        count = i
        ans = ans + 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = list(map(int,input().split()))
i = 0
while True:
    A.sort()
    for a in range(len(A)-1):
        A[a+1] = A[a+1] - A[a]

    A = [i for i in A if  i > 0]
    if len(A) == 1:
        break

print(A[0])


Fixed submission:
N = int(input())

A = list(map(int,input().split()))
i = 0
while True:
    A.sort()
    for a in range(len(A)-1):
        if not(A[a] == 0) and A[a+1] % A[a] == 0:
                A[a+1] = A[a+1] % A[a]
        else:
            A[a+1] = A[a+1] - A[a]

    A = [i for i in A if  i > 0]
    if len(A) == 1:
        break

print(A[0])
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
if N >= M: #設置できるコマが座標よりも大きければ終了
    print(0)
    exit()
diff = []
for i in range(1,len(X)):           #座標の差の最大可
    diff.append()(X[i]-X[i-1])
diff.sort(reverse=True)             
total = sum(diff)
for i in range(N-1):                #移動範囲が広い座標間をショートカット
    total -= diff[i]
print(total)

Fixed submission:
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
if N >= M: #設置できるコマが座標よりも大きければ終了
    print(0)
    exit()
diff = []
for i in range(1,len(X)):           #座標の差の最大可
    diff.append(X[i]-X[i-1])
diff.sort(reverse=True)
total = sum(diff)
for i in range(N-1):                #移動範囲が広い座標間をショートカット
    total -= diff[i]
print(total)
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())

y = x + y / 2
print(f"{y:.0f}")


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

y = x + y / 2

print(math.floor(y))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())

count = []

for i in range(1,N-1):
    sum = 0
    sita = S[0:i]
    usiro = S[i:N]

    #print(sita,usiro)
    sita = list(set(sita))
    usiro = list(set(usiro))

    #print(sita,usiro)
    for x in range(len(sita)):
        if sita[x] in usiro:
            sum += 1

    count.append(sum)

print(max(count))


Fixed submission:
N = int(input())
S = list(input())

count = []

if len(S) == 2:
    if S[0] == S[1]:
        count.append(1)
    else:
        count.append(0)
else:
    for i in range(1,N-1):
        sum = 0
        sita = S[0:i]
        usiro = S[i:N]

        #print(sita,usiro)
        sita = list(set(sita))
        usiro = list(set(usiro))

        #print(sita,usiro)
        for x in range(len(sita)):
            if sita[x] in usiro:
                sum += 1

        count.append(sum)

print(max(count))
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

count = []
if X == 1:
    print(1)
else:
    for i in range(1,X):
        for b in range(2,X):
            factorial = i**b
            if factorial <= X:
                count.append(factorial)

    print(max(count))


Fixed submission:
X = int(input())

count = []
if X == 1:
    print(1)
else:
    for i in range(1,X):
        for b in range(2,10):
            factorial = i**b
            if factorial <= X:
                count.append(factorial)

    print(max(count))
Buggy python submission (verdict: Runtime Error):
import sys
A,B,K = map(int,input().split())

if B-A+1 <= K * 2:
    for i in range(A,B+1):
            print(i)
    else:
        sys.exit(0)


for i in range(A,A+K): #AからB
    print(i)

for i in range(B-K+1,B+1):
    print(i)


Fixed submission:
import sys
S = input()
abc = list("abc")

for i in range(len(abc)):
    if abc[i] in S:
        continue
    else :
        print("No")
        sys.exit(0)

print("Yes")

Buggy python submission (verdict: Runtime Error):
import sys
A,B,K = map(int,input().split())
sum = []
if B-A +1 <= K * 2
    for i in range(A,B+1):
        if i > A+K or B-K < i:
            print(i)
    else:
        sys.exit(0)


for i in range(A,A+K): #AからB
    sum.append(i)

for i in range(B-K-1,B+1):
    sum.append(i)

sum = list(set(sum))
sum.sort()
[print(i) for i in sum]


Fixed submission:
import sys
S = input()
abc = list("abc")

for i in range(len(abc)):
    if abc[i] in S:
        continue
    else :
        print("No")
        sys.exit(0)

print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
for i in range(A,B+1): #AからB
    if i < A+K or B-K < i :
        print(i)


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

if B-A+1 <= K * 2:
    for i in range(A,B+1):
            print(i)

else:
    for i in range(A,A+K): #AからB
        print(i)

    for i in range(B-K+1,B+1):
        print(i)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
for i in range(A,B+1): #AからB
    if i < A+K || B-K < i :
        print(i)


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

if B-A+1 <= K * 2:
    for i in range(A,B+1):
            print(i)

else:
    for i in range(A,A+K): #AからB
        print(i)

    for i in range(B-K+1,B+1):
        print(i)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
for i in range(A,B+1): #AからB
    if i < A+K:
        print(i)
    elif B-K < i <= B:
        print(i)


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

if B-A+1 <= K * 2:
    for i in range(A,B+1):
            print(i)

else:
    for i in range(A,A+K): #AからB
        print(i)

    for i in range(B-K+1,B+1):
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x + y + z == s:
                ans += 1
print(ans)


Fixed submission:
k,s = map(int,input().split())
ans = 0
i = list(range(k+1))

for x in i:
    for y in i:
        z = s-x-y
        if 0 <= z <= k:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C, K =map(input().split())
if A <= K:
    print(K)
    
elif A+B <= K:
    print(A)
    
elif A+B+C <= K:
    print(A-C)

Fixed submission:
A,B,C,K = map(int,input().split())
sum = 0;
if A <= K:
	sum += A;
	K -= A
else:
	sum += K;
	K -= K
if B <= K:
	K -= B
else:
	K -= K
if C <= K:
	sum -= C
	K -= C
else:
	sum -= K
	K -= K
print(sum)

Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
K = input()
if A+B+C <= K:
    print(A-C)

elif A+B <= K:
    print(A)

elif A <= K:
    print(K)

Fixed submission:
A,B,C,K = map(int,input().split())
sum = 0;
if A <= K:
	sum += A;
	K -= A
else:
	sum += K;
	K -= K
if B <= K:
	K -= B
else:
	K -= K
if C <= K:
	sum -= C
	K -= C
else:
	sum -= K
	K -= K
print(sum)

Buggy python submission (verdict: Runtime Error):
if A+B+C <= K:
    print(A-C)

elif A+B <= K:
    print(A)

elif A <= K:
    print(K)

Fixed submission:
A,B,C,K = map(int,input().split())
sum = 0;
if A <= K:
	sum += A;
	K -= A
else:
	sum += K;
	K -= K
if B <= K:
	K -= B
else:
	K -= K
if C <= K:
	sum -= C
	K -= C
else:
	sum -= K
	K -= K
print(sum)

Buggy python submission (verdict: Runtime Error):
if A+B+C <= K:
    print(A-C)

elif A+B <= K:
    print(A)

elif A <= K:
    print(K)

Fixed submission:
A,B,C,K = map(int,input().split())
sum = 0;
if A <= K:
	sum += A;
	K -= A
else:
	sum += K;
	K -= K
if B <= K:
	K -= B
else:
	K -= K
if C <= K:
	sum -= C
	K -= C
else:
	sum -= K
	K -= K
print(sum)
Buggy python submission (verdict: Runtime Error):
moji = ["dream", "dreamer", "erase", "eraser"]

for i in range(len(moji)):
  moji[i] = moji[i][::-1]

s = input()[::-1]

for i in range(0, 3):
  tmp = s.replace(moji[i], "")
  if tmp != s:
    for j in range(1, 3):
      ans = tmp.replace(moji[j], "")
      if ans != tmp:
        flg = "YES"

if flg == "YES":
  print("YES")
else:
  print("NO")

Fixed submission:
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$",input()) else "NO")
Buggy python submission (verdict: Runtime Error):
|AB| * |BC| / 2

Fixed submission:
ab, bc, ca = map(int, input().split())

print(int(ab*bc/2))
Buggy python submission (verdict: Runtime Error):
k = int(input('k: '))
a, b = int(input('a: ')), int(input('b: '))

res = False

for i in range(a, b + 1):
    if i % k == 0:
        res = True
        break

if res == True:
    print('OK')
else:
    print('NG')

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

flag = False

for i in range(a, b + 1):
    if i % k == 0:
        flag = True
        break

if flag:
    print('OK')
else:
    print('NG')

Buggy python submission (verdict: Runtime Error):
k = int(input('k = '))
a = int(input('a = ')); b = int(input('b = '))

res = False

for i in range(a, b + 1):
    if i % k == 0:
        res = True
        break

if res == True:
    print('OK')
else:
    print('NG')

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

flag = False

for i in range(a, b + 1):
    if i % k == 0:
        flag = True
        break

if flag:
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Runtime Error):
print(sorted([int(input()) for i in range(3)]) == [5,5,7])

Fixed submission:
print('YES' if sorted(input().split()) == ['5','5','7'] else 'NO')
Buggy python submission (verdict: Runtime Error):
abck = input().split(" ")
a = abck[0]
b = abck[1]
c = abck[2]
k = abck[3]

if k < a:
	print(a)
elif k < a + b:
	print(a)
else:
	print(a - (k - (a + b)))

 

Fixed submission:
abck = input().split(" ")
a = int(abck[0])
b = int(abck[1])
k = int(abck[3])

if k < a:
	print(k)
elif k <= a + b:
	print(a)
else:
	c = k - (a + b)
	print(a - c)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, k = map(int, input().split(' '))

cnt_a = 0
cnt_b = 0
cnt_c = 0

while k != 0:
    if a > 0:
        cnt_a += 1
        a -= 1
        k -= 1
    elif b > 0:
        cnt_b += 1
        b -= 1
        k -= 1
    else:
        cnt_c += 1
        c -= 1
        k -= 1

result = cnt_a * 1 + cnt_b * 0 + cnt_c * (-1)
print(result)


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

cnt_a = 0
cnt_b = 0
cnt_c = 0

if (a > 0) & (a > k):
    cnt_a = k
    k = 0
else:
    cnt_a = a
    k = k - cnt_a

if (b > 0) & (b > k):
    cnt_b = k
    k = 0
else:
    cnt_b = b
    k = k - cnt_b

if c > 0:
    cnt_c = k

result = cnt_a * 1 + cnt_b * 0 + cnt_c * (-1)
print(result)

Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split(' '))

li_a = [1] * a
li_b = [0] * b
li_c = [-1] * c

li_a.extend(li_b)
li_a.extend(li_c)
li_k = li_a.copy()

print(sum(li_k[:k]))

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

cnt_a = 0
cnt_b = 0
cnt_c = 0

if (a > 0) & (a > k):
    cnt_a = k
    k = 0
else:
    cnt_a = a
    k = k - cnt_a

if (b > 0) & (b > k):
    cnt_b = k
    k = 0
else:
    cnt_b = b
    k = k - cnt_b

if c > 0:
    cnt_c = k

result = cnt_a * 1 + cnt_b * 0 + cnt_c * (-1)
print(result)
Buggy python submission (verdict: Runtime Error):
    total = 0

Fixed submission:
s = input()
n = len(s)

ans = 0

for bit in range(1 << (n - 1)):
    f = s[0]

    for i in range(n - 1):
        # ここのif文の判定基準が理解できていません。
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[]
cnt=1
for i in range(n):
	a.append(input())
for i in range(0,n):
	for j in range(i+1,n):
		if a[i]==a[j]:
			break
		elif j == n-1:
			cnt+=1
print(cnt)

Fixed submission:
n=int(input())
a=list(input() for i in range(n))
print(len(set(a)))
Buggy python submission (verdict: Runtime Error):
r=input()
print(2*r*3.1415)

Fixed submission:
r=int(input())
print(2*r*3.1415)
Buggy python submission (verdict: Time Limit Exceeded):
k,n=map(int,input().split())
a=list(map(int,input().split()))
for j in range(n-1):
	a.append(a[j]+k)
sum=[0]*n
for I in range(n):
	for i in range(n-1):
		sum[I]=sum[I]+a[I+i+1]-a[I+i]
print(min(sum))

Fixed submission:
k,n=map(int,input().split())
a=list(map(int,input().split()))
a.append(a[0]+k)
dist=[0]*n
for i in range(1,len(a)):
	dist[i-1]=a[i]-a[i-1]
print(sum(dist)-max(dist))

Buggy python submission (verdict: Time Limit Exceeded):
k,n=map(int,input().split())
a=list(map(int,input().split()))
for j in range(n-1):
	a.append(a[j]+k)
sum=[0]*n
for I in range(n):
	for i in range(n-1):
		sum[I]=sum[I]+a[I+i+1]-a[I+i]
print(min(sum))

Fixed submission:
k,n=map(int,input().split())
a=list(map(int,input().split()))
a.append(a[0]+k)
dist=[0]*n
for i in range(1,len(a)):
	dist[i-1]=a[i]-a[i-1]
print(sum(dist)-max(dist))
Buggy python submission (verdict: Runtime Error):
K = int(input())
A,B = map(int,input().split())

if K - A % K <= B-A:
    print("OK")
elif k == 1:
    print("OK")
else:
    print("NG")


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

for i in range(A,B+1):
    if i % K == 0:
        print("OK")
        exit()
print("NG")
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

Fixed submission:

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

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