Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

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

ans = 1000000

for i in itertools.permutations(prices, k):
    ans = min(ans, sum(i))

print(ans)

Fixed submission:
import itertools

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

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

prices = sorted(prices)

print(sum(prices[:k]))

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

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

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

ans = 1000000

for i in itertools.permutations(prices, k):
    ans = min(ans, sum(i))

print(ans)

Fixed submission:
import itertools

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

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

prices = sorted(prices)

print(sum(prices[:k]))

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

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

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

ans = 1000000

for i in itertools.combinations(prices, k):
    ans = min(ans, sum(i))

print(ans)

Fixed submission:
import itertools

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

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

prices = sorted(prices)

print(sum(prices[:k]))

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

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

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

ans = 1000000

for i in itertools.combinations(prices, k):
    ans = min(ans, sum(i))

print(ans)

Fixed submission:
import itertools

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

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

prices = sorted(prices)

print(sum(prices[:k]))

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

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

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

ans = 999999999

for i in itertools.combinations(prices, k):
    ans = min(ans, sum(i))

print(ans)

Fixed submission:
import itertools

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

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

prices = sorted(prices)

print(sum(prices[:k]))

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

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

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

ans = 999999999999999

for i in itertools.combinations(prices, k):
    ans = min(ans, sum(i))

print(ans)

Fixed submission:
import itertools

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

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

prices = sorted(prices)

print(sum(prices[:k]))

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

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

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

ans = 9999999999

for i in itertools.combinations(prices, k):
    ans = min(ans, sum(i))

print(ans)

Fixed submission:
import itertools

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

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

prices = sorted(prices)

print(sum(prices[:k]))
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

if is_prime(n):
    print(1)
else:
    count = 0
    nums = []
    while n != 1:
        for i in range(2, 10*12):
            v, m = divmod(n, i)
            if m == 0:
                if i in nums:
                    continue

                nums.append(i)
                n = v
                count += 1
            else:
                pass

    print(count)

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

print(a*b)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
nums = list(map(int, input().split()))
nums = np.array(nums)

if nums.prod() > 10 ** 18:
    print(-1)
else:
    print(nums.prod())


Fixed submission:
n = int(input())
nums = list(map(int, input().split()))

sum = 1
if 0 in nums:
    print(0)
else:
    for num in nums:
        sum *= num
        if sum > 10 ** 18:
            print(-1)
            break
    else:
        print(sum)

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

sum = 1
for num in nums:
    sum *= num

if sum > 10 ** 18:
    print(-1)
else:
    print(sum)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))

sum = 1
if 0 in nums:
    print(0)
else:
    for num in nums:
        sum *= num
        if sum > 10 ** 18:
            print(-1)
            break
    else:
        print(sum)

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

sum = 1
for num in nums:
    sum *= num

if sum > 10 ** 18:
    print(-1)
else:
    print(sum)

Fixed submission:
n = int(input())
nums = list(map(int, input().split()))

sum = 1
if 0 in nums:
    print(0)
else:
    for num in nums:
        sum *= num
        if sum > 10 ** 18:
            print(-1)
            break
    else:
        print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

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

highs = list(map(int, input().split()))
towers = list(range(n))

d = defaultdict(list)

for i in range(m):
    v = list(map(int, input().split()))
    d[v[0]].append(v[1])
    d[v[1]].append(v[0])

count = 0
for k, v in d.items():
    nums = []
    
    if towers.count(k-1) > 0:
        towers.remove(k-1)
    for i in v:
        nums.append(highs[i-1])
    if highs[k-1] > max(nums):
        count += 1

print(count+len(towers))

Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [0]*n

for i in range(m):
    a, b = map(int, input().split())
    l[a-1] = max(l[a-1], h[b-1])
    l[b-1] = max(l[b-1], h[a-1])

count = 0
for i in range(n):
    if h[i] > l[i]:
        count += 1

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

n, m, q = map(int, input().split())

nums = []
for _ in range(q):
    nums.append(list(map(int, input().split())))

total = 0

l = [1,2,3,4,5,6,7,8,9,10]
for v in itertools.combinations_with_replacement(l, n):
    scores = []
    for a,b,c,d in nums:
        if v[b-1]-v[a-1] == c:
            scores.append(d)
        else:
            scores.append(0)
    if total <= sum(scores):
        total = sum(scores)

print(total)


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

n = a//k
if a <= (n+1)*k <= b or a <= n * k <=b:
    print("OK")
else:
    print("NG")
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

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

    t = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans = gcd(i, gcd(j, k))
                t += ans

    print(t)

if __name__ == "__main__":
    main()

Fixed submission:
from math import gcd

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

    t = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans = gcd(i, gcd(j, k))
                t += ans

    print(t)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

n = int(input())

t = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            ans = i
            ans = fractions.gcd(ans, j)
            ans = fractions.gcd(ans, k)
            t += ans

print(t)

Fixed submission:
from math import gcd

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

    t = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans = gcd(i, gcd(j, k))
                t += ans

    print(t)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

n = int(input())

t = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            ans = i
            ans = fractions.gcd(ans, j)
            ans = fractions.gcd(ans, k)
            t += ans

print(t)

Fixed submission:
from math import gcd

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

    t = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans = gcd(i, gcd(j, k))
                t += ans

    print(t)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

n = int(input())

nums = []
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            nums.append([i, j, k])

t = 0
for num in nums:
    ans = num[0]
    for i in range(1, 3):
        ans = fractions.gcd(ans, num[i])
    t += ans

print(t)

Fixed submission:
from math import gcd

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

    t = 0
    for i in range(1, n+1):
        for j in range(1, n+1):
            for k in range(1, n+1):
                ans = gcd(i, gcd(j, k))
                t += ans

    print(t)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

m = 10**18
while True:
    n = min(n, abs(n-k)) 
    if n < m:
        m = n
    else:
        break

print(m)

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

m = 10**18
n = n % k
while True:
    n = min(n, abs(n-k)) 
    if n < m:
        m = n
    else:
        break

print(m)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
from operator import mul
from functools import reduce


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


n = int(input())
nums = list(map(int, input().split()))
d = Counter(nums)
# for num in nums:
#     if not d.get(num):
#         d[num] = 1
#     else:
#         d[num] += 1

combination_d = {}

for num in nums:
    counter = 0
    if combination_d.get(num):
        print(combination_d[num])
        continue

    nums.count(num)

    for key in d.keys():
        if key == num:
            if d[key]-1 >= 2:
                counter += cmb(d[key]-1, 2)
        else:
            if d[key] >= 2:
                counter += cmb(d[key], 2)
    
    combination_d[num] = counter
    print(counter)




Fixed submission:
from math import factorial
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, M = map(int, input().split())

if N - 2 >= 0:
    a = cmb(N,2)
else:
    a = 0


if M - 2 >= 0:
    b = cmb(M,2)
else:
    b = 0

print(int(a)+int(b))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

for num in nums:
    if nums.count(num) >= 2:
        print("NO")
        break
else:
    print("YES")

Fixed submission:
N = int(input())

nums = tuple(map(int, input().split()))

if len(nums) == len(set(nums)):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
string = input()

char = ["A", "C", "G", "T"]

count = 0
lengths = []
for s in string:
    if s in char:
        count += 1
    else:
        lengths.append(count)
        count = 0
else:
    print(max(lengths))


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

ans = 0
for i in range(n):
    for j in range(i, n):
        if all("ACGT".count(l) for l in s[i:j + 1]):
            ans = max(ans, j - i + 1)

print(ans)
Buggy python submission (verdict: Runtime Error):
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
pandas = "*"
numpy = "*"

[requires]
python_version = "3.7"


Fixed submission:
import numpy as np

n, m, c = map(int, input().split())
b = list(map(int, input().split()))

b = np.array(b)

count = 0
for _ in range(n):
    a = list(map(int, input().split()))
    a = np.array(a)

    if np.dot(a, b) + c > 0:
        count += 1
else:
    print(count)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    MODULO = 10**9 + 7
    n = int(input())
    A = list(map(int, input().split()))
    total = 0
    for i in range(n):
        for j in range(i+1, n):
            total = (total + A[i] * A[j]) % MODULO
    print(total)


Fixed submission:
if __name__ == '__main__':
    MODULO = 10**9 + 7
    n = int(input())
    A = list(map(int, input().split()))
    total = 0
    sq = 0
    for i in range(n):
        total = (total + A[i]) #% MODULO
        sq = (pow(A[i], 2) + sq) #% MODULO
    total = ((pow(total, 2) - sq) // 2) % MODULO
    print(total )
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
sum = 0
while N > 0:
    sum += N % 10
    N = N // 10
if sum % 9 == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
N = input()
s = [char for char in N]
sum_ = 0
for char in s:
    sum_ += int(char)
if sum_ % 9 == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
H, W, M = map(int, input().split())

freq_w = [ 0 for _ in range(W)]
freq_h = [ 0 for _ in range(H)]
pos = dict()

for _ in range(M):
    h, w = map(int, input().split())
    freq_h[h-1] += 1
    freq_w[w-1] += 1
    pos[(h-1, w-1)] = True


m_w = max(freq_w)
pos_w = [i for i, j in enumerate(freq_w) if j == m_w]

m_h = max(freq_h)
pos_h = [i for i, j in enumerate(freq_h) if j == m_h]

max_ = m_w + m_h - 1
found = False
for i in pos_h:
    for j in pos_w:
        if not((i, j) in pos):
            found = True

print(max_ + int(found))


Fixed submission:
H, W, M = map(int, input().split())

freq_w = [ 0 for _ in range(W)]
freq_h = [ 0 for _ in range(H)]
pos = dict()

for _ in range(M):
    h, w = map(int, input().split())
    freq_h[h-1] += 1
    freq_w[w-1] += 1
    pos[(h-1, w-1)] = True


m_w = max(freq_w)
pos_w = [i for i, j in enumerate(freq_w) if j == m_w]

m_h = max(freq_h)
pos_h = [i for i, j in enumerate(freq_h) if j == m_h]

max_ = m_w + m_h - 1
found = False
#
# for el in pos:
#     i, j = el
#     max_

for i in pos_h:
    for j in pos_w:
        if not((i, j) in pos):
            found = True
            break
    if found == True:
        break

print(max_ + int(found))
Buggy python submission (verdict: Runtime Error):
a = input()
if "RRR" in a:
  print(3)
elif "RR" in a:
  print(2)
elif "R" in a:
  print(1)
else:
  primt(0)

Fixed submission:
a = input()
if "RRR" in a:
  print(3)
elif "RR" in a:
  print(2)
elif "R" in a:
  print(1)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):

a = input()
if "RRR" in a:
  print(3)
  elif "RR" in a:
      print(2)
  elif "R" in a:
      print(1)
  else:
      primt(0)

Fixed submission:
a = input()
if "RRR" in a:
  print(3)
elif "RR" in a:
  print(2)
elif "R" in a:
  print(1)
else:
  print(0)

Buggy python submission (verdict: Runtime Error):
str1 = input()
str2 = 'R'
str3 = 'RR'
str4 = 'RRR'
ans = 0
if str4 in str1
ans = 3
elif str3 in str1
ans = 2
elif str3 in str1
ans = 2
else
ans=0

print(ans)

Fixed submission:
a = input()
if "RRR" in a:
  print(3)
elif "RR" in a:
  print(2)
elif "R" in a:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
a = input()
b = list(map(int,input().split()))
c = b.sort()
d = 0

if a <= 2:
  print("0")
elif :
  for i in len(b):
    for j in (i+1,len(b)):
      for k in (k+1,len(b)):
        if c[i]+c[j] > c[k]:
          d += 1
  print(str(d))         
        

Fixed submission:
a = int(input())
b = list(map(int,input().split()))
b.sort()
d = 0
 
if a <= 2:
  print("0")
else :
  for i in range(len(b)):
    for j in range(i+1,len(b)):
      for k in range(j+1,len(b)):
        if b[i]+b[j] > b[k] and b[i] != b[j] and b[j] != b[k]:
          d += 1
  print(str(d))
Buggy python submission (verdict: Runtime Error):
tem = int.input()
if tem >= 30:
  print("Yes")
else:
  print("No")

Fixed submission:
tem = int(input())
if tem >= 30:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
tem = input()
if tem >= 30:
  print("Yes")
else:
  print("No")

Fixed submission:
tem = int(input())
if tem >= 30:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):

tem = input()
if tem >= 30:
  print("Yes")
else:
  Print("No")

Fixed submission:
tem = int(input())
if tem >= 30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = [0]*n
n1 = int(n/6)+1

for l in range(1,n+1):
  for i in range(1,n1):
    for j in range(1,n1):
      for k in range(1,n1):
        if i**2 + j**2 + k**2 + i*j + j*k + k*i == l:
          ans[(l-1)] += 1
        elif i**2 + j**2 + k**2 + i*j + j*k + k*i > l:
          break 
    if i**2 + j**2 + k**2 + i*j + j*k + k*i > l:
      break 
  if i**2 + j**2 + k**2 + i*j + j*k + k*i > l:
    break 

for l in range(1,n+1):      
   print(ans[(l-1)])

Fixed submission:
n = int(input())
ans = [0]*n

for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      l = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if l <= n:
        ans[l-1] += 1
      
for m in range(n): 
  print(ans[m])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = [0]*n

for l in range(1,n+1):
  for i in range(1,n+1):
    for j in range(1,n+1):
      for k in range(1,n+1):
        if i**2 + j**2 + k**2 + i*j + j*k + k*i == l:
          ans[(l-1)] += 1
        elif i**2 + j**2 + k**2 + i*j + j*k + k*i > l:
          break      
  print(ans[(l-1)])

Fixed submission:
n = int(input())
ans = [0]*n

for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      l = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if l <= n:
        ans[l-1] += 1
      
for m in range(n): 
  print(ans[m])
Buggy python submission (verdict: Runtime Error):
money1 = int(input())
if money1 % 1000 != 0:
    money2 = 1000 - (money1 % 1000)
   else:
    money2 = 0
print(str(money2))

Fixed submission:
money1 = int(input())
if money1 % 1000 != 0:
    money2 = 1000 - (money1 % 1000)
    print(str(money2))
else:
    money2 = 0
    print(str(money2))

Buggy python submission (verdict: Runtime Error):
money1 = int(input())
money2 = money % 1000
print(money2)

Fixed submission:
money1 = int(input())
if money1 % 1000 != 0:
    money2 = 1000 - (money1 % 1000)
    print(str(money2))
else:
    money2 = 0
    print(str(money2))
Buggy python submission (verdict: Runtime Error):
s = input().split()
t = input().split()
c = 0

for i in rangea(len(s)):
  if s[i] != t[i]:
    c += 1

print(str(c))


Fixed submission:
s = input()
t = input()
c = 0
 
for i in range(len(s)):
  if s[i] != t[i]:
    c += 1
 
print(str(c))
Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
print(str(a*b))

Fixed submission:
a,b = map(int,input().split())
print(str(a*b))

Buggy python submission (verdict: Runtime Error):

a,b = int(input().sqlit())
print(str(a*b))

Fixed submission:
a,b = map(int,input().split())
print(str(a*b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int,input().split())
a.sort()
t = 1
 
for i in range(len(a)):
  t *= a[i]
  if t > 10**18:
    break

if t > 10**18 :
  print("-1")
else:
  print(str(t))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
t = 1
 
for i in range(len(a)):
  t *= a[i]
  if t > 10**18:
    break
 
if t > 10**18 :
  print("-1")
else:
  print(str(t))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = map(int,input().split())
t = 1
 
for i in a:
  t *= i
 
if t >10**18:
  print("-1")
else:
  print(str(t))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
t = 1
 
for i in range(len(a)):
  t *= a[i]
  if t > 10**18:
    break
 
if t > 10**18 :
  print("-1")
else:
  print(str(t))

Buggy python submission (verdict: Runtime Error):
n = int.input()
a = map(int,input().split())
t = 1

for i in a:
  t *= i

if t >10**18:
  print("-1")
else:
  print(str(t))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
t = 1
 
for i in range(len(a)):
  t *= a[i]
  if t > 10**18:
    break
 
if t > 10**18 :
  print("-1")
else:
  print(str(t))

Buggy python submission (verdict: Runtime Error):
n = int.input()
a = map(int,input().split())
t = 1

for i in a:
  t *= a[i]

print(str(t))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
t = 1
 
for i in range(len(a)):
  t *= a[i]
  if t > 10**18:
    break
 
if t > 10**18 :
  print("-1")
else:
  print(str(t))
Buggy python submission (verdict: Runtime Error):
k = int(input())
s = input()
 
if len(s) < k :
  print(s)
else:
  print(substr(s,0,k)+"...")

Fixed submission:
k = int(input())
s = input()
 
if len(s) <= k :
  print(s)
else:
  print(s[0:k]+"...")

Buggy python submission (verdict: Runtime Error):
k = int(inpout())
s = input()

if len(s) < k :
  print(s)
else:
  print(substr(s,0,k)+"...")

Fixed submission:
k = int(input())
s = input()
 
if len(s) <= k :
  print(s)
else:
  print(s[0:k]+"...")
Buggy python submission (verdict: Runtime Error):
a,b = [input() for i in range(2)]

if a = b[:-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
a,b = [input() for i in range(2)]
 
if a == b[:-1]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a = [input() for i in range(2)]
b = a[0]
c = a[1]
if b = c[:-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
a,b = [input() for i in range(2)]
 
if a == b[:-1]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
if a = b[:-1]:
  print("Yes")
else:
  print("No")

Fixed submission:
a,b = [input() for i in range(2)]
 
if a == b[:-1]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
if a = b[:-1]:
  print("yes")
else:
  print("No")

Fixed submission:
a,b = [input() for i in range(2)]
 
if a == b[:-1]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())

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

Fixed submission:
a,b,c,k = map(int,input().split())
 
if k < a:
  print(str(k))
elif k < (a + b):
  print(str(a))
else:
  print(str(2*a + b - k))
Buggy python submission (verdict: Runtime Error):
k = int(input())
a,b = [input() for i in range(2)]
if (b-a+1 >= k):
  print("OK")
else:
  print("NG")

Fixed submission:
k = int(input())
a,b = map(int,input().split())
if ((b//k)*k >= a):
  print("OK")
else:
  print("NG")
Buggy python submission (verdict: Runtime Error):

a = list.map(int,input().split())
if a[1] >= a[0]:
  print("unsafe")
else:
  print("safe")

Fixed submission:
a = list(map(int,input().split()))
if a[1] >= a[0]:
  print("unsafe")
else:
  print("safe")
Buggy python submission (verdict: Runtime Error):
import math
a = int(input())
print(str(2a*math.pi))

Fixed submission:
import math
a = int(input())
print(str(2*a*math.pi))

Buggy python submission (verdict: Runtime Error):
import math
a = input()
print(str(2a*math.pi))

Fixed submission:
import math
a = int(input())
print(str(2*a*math.pi))
Buggy python submission (verdict: Runtime Error):
a = input()
if "7" in a:
  print(Yes)
else:
  print(No)


Fixed submission:
a = input()
if "7" in a:
  print("Yes")
else:
  print("No")