Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
a=1
n=input()

s=input()
count=""
#print(len(s))
for i in range(len(s)):
  #print(i,s[i],count)
  if s[i]==" ":
    a*=int(count)
    count=""
    continue
  elif i==len(s)-1:
    if len(count)==0:
      a*=int(s[i])
    else:
      count+=s[i]
      #print("--------")
      a*=int(count)
  else:
    count+=s[i]
if a>10**18:
  print(-1)
else:
  print(a)

Fixed submission:
a=1
n=input()
s=list(map(int,input().split()))

count=0
if 0 in s:
  print(0)
  count=1
else:
  a=1
  for i in s:
    a*=i
    if a>10**18:
      print(-1)
      break
if a<=10**18 and count!=1:
  print(a)

Buggy python submission (verdict: Runtime Error):
a=1
n=input()

s=input()
for i in range(len(s)):
  if i%2==1:
    continue
  a*=int(s[i])
if a>10**18:
  print(-1)
else:
  print(a)

Fixed submission:
a=1
n=input()
s=list(map(int,input().split()))

count=0
if 0 in s:
  print(0)
  count=1
else:
  a=1
  for i in s:
    a*=i
    if a>10**18:
      print(-1)
      break
if a<=10**18 and count!=1:
  print(a)

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

Fixed submission:
a=1
n=input()
s=list(map(int,input().split()))

count=0
if 0 in s:
  print(0)
  count=1
else:
  a=1
  for i in s:
    a*=i
    if a>10**18:
      print(-1)
      break
if a<=10**18 and count!=1:
  print(a)

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

Fixed submission:
a=1
n=input()
s=list(map(int,input().split()))

count=0
if 0 in s:
  print(0)
  count=1
else:
  a=1
  for i in s:
    a*=i
    if a>10**18:
      print(-1)
      break
if a<=10**18 and count!=1:
  print(a)
Buggy python submission (verdict: Runtime Error):
import numpy as np
A=a=int(input())
count=2
samenumcount=0
y=[]

if A==1:
    print(0)
    sys.exit()

while A!=1 and count<np.sqrt(a):
    if A%count==0:
        samenumcount+=1
        y.append(count**samenumcount)
        A=A/count
    else:
        count+=1
        samenumcount=0
y.sort()

count2=0
for i in y:
    if a==1:
      break
    if a%i==0:
        a=a/i
        count2+=1

if count2==0:
    print(1)
else:
    print(count2)

Fixed submission:
import numpy as np
import sys
A=a=int(input())
count=2
samenumcount=0
y=[]
 
if A==1:
    print(0)
    sys.exit()
 
while A!=1 and count<np.sqrt(a):
    if A%count==0:
        samenumcount+=1
        y.append(count**samenumcount)
        A=A/count
    else:
        count+=1
        samenumcount=0
if A!=1:
    y.append(A)
y.sort()
count2=0
for i in y:
    if a==1:
      break
    if a%i==0:
        a=a/i
        count2+=1
 
if count2==0:
    count2+=1

print(count2)

Buggy python submission (verdict: Time Limit Exceeded):
A=a=int(input())
count=2
samenumcount=0
y=[]
while A!=1:
    if A%count==0:
        samenumcount+=1
        y.append(count**samenumcount)
        A=A/count
    else:
        count+=1
        samenumcount=0
y.sort()

count2=0
for i in y:
    if a==1:
      break
    if a%i==0:
        #print(a,i)
        a=a/i
        count2+=1

print(count2)

Fixed submission:
import numpy as np
import sys
A=a=int(input())
count=2
samenumcount=0
y=[]
 
if A==1:
    print(0)
    sys.exit()
 
while A!=1 and count<np.sqrt(a):
    if A%count==0:
        samenumcount+=1
        y.append(count**samenumcount)
        A=A/count
    else:
        count+=1
        samenumcount=0
if A!=1:
    y.append(A)
y.sort()
count2=0
for i in y:
    if a==1:
      break
    if a%i==0:
        a=a/i
        count2+=1
 
if count2==0:
    count2+=1

print(count2)
Buggy python submission (verdict: Runtime Error):
X=int(input())
while(True):
    k=breaknum=0
    for n in range(-118,120):
        x=n**5-(n-k)**5
        if X==x:
            print(n**5)
            breaknum=-1
            break
    k+=1
    if breaknum=-1:
        break

Fixed submission:
X=int(input())
k=breaknum=1
while(True):
    for n in range(-118,120):
        x=n**5-(n-k)**5
        if X==x:
            print("{0} {1}".format(n,n-k))
            breaknum=-1
            break
    k+=1
    if breaknum==-1:
        break
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
pair=0
X2=[]

for i in range(N):
    a=A[i]
    x1=i+1-a
    x2=i+1+a
    pair+=X2.count(x1)
    X2.append(x2)
print(pair)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
pair=0
As={}

for i in range(N):
    a=A[i]
    x1=i+1-a
    x2=i+1+a
    if x1 in As:
        pair+=As[x1]
    if x2 in As:
        As[x2]+=1
    else:
      As[x2]=1
print(pair)
Buggy python submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,max((B/A),1))])

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

for i in range(a,b+1):
  if i%k==0:
    print('OK')
    break
  if i==b:
    print('NG')
Buggy python submission (verdict: Runtime Error):
import itertools
 
N,M,Q=map(int,input().split())
all=[]
for i in range(Q):
  all.append(list(map(int,input().split()))
 
x=[i for i in range(1,M+1)]
maxdsum=0
 
for A in itertools.combinations_with_replacement(x, N):
  dsum=0
  for num in range(Q):
    if A[all[num][1]-1]-A[all[num][0]-1]==all[num][2]:
      dsum+=all[num][3]
  if maxdsum<dsum:
    maxdsum=dsum
print(maxdsum)

Fixed submission:
import itertools
 
N,M,Q=map(int,input().split())
all=[]
 
for i in range(Q):
  all.append(list(map(int,input().split())))
#print(all)
#print(len(all))
#print(all[0][1])
 
x=sorted([i for i in range(1,M+1)])
maxdsum=0
 
 
for A in itertools.combinations_with_replacement(x, N):
  dsum=0
  #print("A=="+str(A))
  for num in range(Q):
    if A[all[num][1]-1]-A[all[num][0]-1]==all[num][2]:
      dsum+=all[num][3]
  if maxdsum<dsum:
    maxdsum=dsum
print(maxdsum)

Buggy python submission (verdict: Runtime Error):
import itertools
 
N,M,Q=map(int,input().split())
all=[]
 
for i in range(Q):
  all.append(list(map(int,input().split())))
#print(all)
#print(len(all))
#print(all[0][1])
 
x=sorted([i for i in range(1,M+1)])
maxdsum=0
 
 
for A in itertools.combinations_with_replacement(x, N):
  dsum=0
  "print("A=="+str(A))
  for num in range(Q):
    if A[all[num][1]-1]-A[all[num][0]-1]==all[num][2]:
      dsum+=all[num][3]
  if maxdsum<dsum:
    maxdsum=dsum
print(maxdsum)

Fixed submission:
import itertools
 
N,M,Q=map(int,input().split())
all=[]
 
for i in range(Q):
  all.append(list(map(int,input().split())))
#print(all)
#print(len(all))
#print(all[0][1])
 
x=sorted([i for i in range(1,M+1)])
maxdsum=0
 
 
for A in itertools.combinations_with_replacement(x, N):
  dsum=0
  #print("A=="+str(A))
  for num in range(Q):
    if A[all[num][1]-1]-A[all[num][0]-1]==all[num][2]:
      dsum+=all[num][3]
  if maxdsum<dsum:
    maxdsum=dsum
print(maxdsum)
Buggy python submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,B/A)]))

Fixed submission:
A,B,N=map(int,input().split())
def f(x):
  return int(A*x/B)-A*int(x/B)

print(f(min(N,B-1)))

Buggy python submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,max((B/A),1))]))

Fixed submission:
A,B,N=map(int,input().split())
def f(x):
  return int(A*x/B)-A*int(x/B)

print(f(min(N,B-1)))

Buggy python submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,max((B/A),1))])

Fixed submission:
A,B,N=map(int,input().split())
def f(x):
  return int(A*x/B)-A*int(x/B)

print(f(min(N,B-1)))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N=map(int,input().split())
print(max([int(A*x/B)-A*int(x/B) for x in range(1,N+1)]))

Fixed submission:
A,B,N=map(int,input().split())
def f(x):
  return int(A*x/B)-A*int(x/B)

print(f(min(N,B-1)))
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=[]
for i in range(N):
    a.append(input())
print(len(set(a)))

Fixed submission:
a,b=map(int, input().split())
print('unsafe') if a<=b else print('safe')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=[]
for i in range(N):
    a.append(input())
a=sorted(a)
c=0
while c!=len(a)-1:
    if a[c]==a[c+1]:
        a.pop(c+1)
    else:
        c+=1
print(len(a))

Fixed submission:
N=int(input())
a=[]
for i in range(N):
    a.append(input())
print(len(set(a)))
Buggy python submission (verdict: Runtime Error):
def main():
  N = int(input())
  INF = float('inf')
  A = [(i+1, a) for i, a in enumerate(map(int, input().split()))]
  A = sorted(A, key=lambda x: x[1], reverse = True)
 
  dp = [[-INF] * (N+1) for _ in range(N+1)]
  dp[0][0] = 0
 
  for s in range(1, N+1):
    for l in range(s+1):
      r = s - l
      dp[l][r] = max(dp[l-1][r] + A[s-1][1] * abs(A[s-1][0]-l), dp[l][r-1] + A[s-1][1] * abs(N-r+1-A[s-1][0]))
    
  ans = 0
  for m in range(N):
    if(dp[m][N-m] > ans):
      ans = dp[m][N-m]
    
  print(ans)
 
main()

Fixed submission:
import numpy as np
print(float(input())*2*np.pi)

Buggy python submission (verdict: Runtime Error):
N=int(input())
actlist=list(map(int,input().split()))
As = sorted([(A, i) for i, A in enumerate(actlist)])[::-1]

left=1
right=N
sumnum=0

for i in As:
    move=0
    moveleft=abs(i[1]+1-left)
    moveright=abs(i[1]+1-right)
    if moveleft>moveright:
        move=moveleft
        left+=1
    else:
        move=moveright
        right=right-1
    sumnum+=move*i[0]
    
print(sumnum+1)

Fixed submission:
import numpy as np
print(float(input())*2*np.pi)

Buggy python submission (verdict: Runtime Error):
N=int(input())
actlist=list(map(int,input().split()))
As = sorted([(A, i) for i, A in enumerate(actlist)])[::-1]
 
left=1
right=N
sumnum=0
 
for i in As:
    move=0
    moveleft=abs(i[1]+1-left)
    moveright=abs(i[1]+1-right)
    if moveleft>moveright:
        move=moveleft
        left+=1
    else:
        move=moveright
        right=right-1
    sumnum+=move*i[0]
    
print(sumnum+1)

Fixed submission:
import numpy as np
print(float(input())*2*np.pi)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

num=[0]*N
for i in A:
    num[i-1]+=1

for j in range(len(num)):
    print(num[j])

Fixed submission:
import numpy as np
print(float(input())*2*np.pi)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
num=0
for i in range(k,n+2):
    num+=i*(n-i+1)+1
print(num%(10**9+7))

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

num=[0]*N
for i in A:
    num[i-1]+=1

for j in range(len(num)):
    print(num[j])
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
num=0
for i in range(k,n+2):
    minsum=maxsum=0
    for j in range(i):
        minsum+=j
        maxsum+=n-j
    num+=maxsum-minsum+1
print(num)

Fixed submission:
n,k=map(int,input().split())
num=0
for i in range(k,n+2):
    num+=i*(n-i+1)+1
print(num%(10**9+7))
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
def main():
    N,Q = map(int, input().split())
    s = input()
    ans = N
    command = []

    # print(char_list)

    for i in range(Q):
        t,d = input().split()
        command.append([t,d])

    r = binary_serch_R(command,s,N)
    #print(r)
    l = binary_serch_L(command,s,N)
    #print(l)
    ans = ans - (N-r) - (l+1)
    if ans < 0:
        ans = 0
    print(ans)

def simulation_R(command,s,now,N):
    for pair in command:
        if pair[0] == s[now]:
            if pair[1] == 'L':
                now -= 1
            elif pair[1] == 'R':
                now += 1
        if now < 0:
            return False
        elif now >= N:
            return True
    return False

def simulation_L(command,s,now,N):
    for pair in command:
        if pair[0] == s[now]:
            if pair[1] == 'L':
                now -= 1
            elif pair[1] == 'R':
                now += 1
        if now < 0:
            return True
        elif now >= N:
            return False
    return False


def binary_serch_R(command,s,N):
    left = 0
    right = N-1
    if simulation_R(command,s,left,N) :
        return -1
    if simulation_R(command,s,right,N) == False:
        return N

    while abs(right - left) > 1:
        mid = int((left+right)/2)
        # print(mid)
        if simulation_R(command,s,mid,N) :
            right = mid
        else :
            left = mid 
    return right

def binary_serch_L(command,s,N):
    left = 0
    right = N-1
    if simulation_L(command,s,left,N) == False :
        return -1
    if simulation_L(command,s,right,N):
        return N
        
    while abs(right-left) > 1:
        mid = int((left+right)/2)
        if simulation_L(command,s,mid,N) :
            left = mid
        else :
            right = mid 
    return left

if __name__ == "__main__":
    main()

Fixed submission:
# coding: utf-8
def main():
    a,b,c = map(int, input().split())
    if a==b and b == c:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding:utf-8

memo = []
DNA = ["A","C","G","T"]
ng3 = ["AGC","ACG","GAC"]
ng4 = ["ACGC","AGGC","ATGC", "AGAC", "AGTC"]
memo2 = []
def main():
    N = int(input())
    # ACGTからなる
    # 部分文字列AGCを持たない
        # AGC
    # 隣接する2文字の入れかえを1回することでうえの条件に違反しない
        # ACG
        # GAC
        # A-GC
        # AG-C

    # 4^N個の通り

    # 動的計画法
        # 違反があったやつの打ち切り
        # すでに組み合わせの通りが分かっているやつの省略
    # 再帰
    # count = pow(4,N)
    string_check("",0,N)
    # print(memo2)
    print(len(memo))


def string_check(nowstr,i,N):
    slen = len(nowstr)
    if slen == 3:
        if nowstr in ng3:
            # memo2.append(nowstr)
            return
        # print(nowstr)
    if slen == 4:
        # print(nowstr)
        # print(nowstr[-3:])
        if nowstr[:3] in ng3:
            # memo2.append(nowstr)
            return
        elif nowstr[-3:] in ng3:
            # memo2.append(nowstr)
            return
        elif nowstr in ng4:
            # memo2.append(nowstr)
            return
    elif slen > 4:
        if nowstr[-3:] in ng3:
            return
        elif nowstr[-4:] in ng4:
            return
    if i == N:
        # print(nowstr)
        memo.append(nowstr)
        return
    else:
        i+=1
        for s in DNA:
            string_check(nowstr+s,i,N)


if __name__ == "__main__":
    main()

Fixed submission:
# coding:utf-8


DNA = ["A","C","G","T"]
ng3 = ["AGC","ACG","GAC"]
ng4 = ["ACGC","AGGC","ATGC", "AGAC","AGTC"]
MOD = 10**9 +7

def main():
    N = int(input())
    memo = [{} for i in range(N+1)]
    # ACGTからなる
    # 部分文字列AGCを持たない
        # AGC
    # 隣接する2文字の入れかえを1回することでうえの条件に違反しない
        # ACG
        # GAC
        # A-GC
        # AG-C

    # 4^N個の通り

    # 動的計画法
        # 違反があったやつの打ち切り
        # すでに組み合わせの通りが分かっているやつの省略
    # 再帰
    # count = pow(4,N)
    ans = string_check("",0,N,memo)
    # print(memo)
    print(ans%MOD)

    # print(memo2)
    #print(len(memo))


def string_check(nowstr,i,N,memo):
    # print(nowstr)
    slen = len(nowstr)
    if slen == 3:
        if nowstr in ng3:
            return 0
    if slen == 4:
        if nowstr[-3:] in ng3:
            return 0
        elif nowstr in ng4:
            return 0
    elif slen > 4:
        if nowstr[-3:] in ng3:
            return 0
        elif nowstr[-4:] in ng4:
            return 0
    if nowstr[-3:] in memo[i]:
        return memo[i][nowstr[-3:]]
    elif slen == N:
        return 1
    else:
        count = 0
        for s in DNA:
            count += string_check(nowstr+s,i+1,N,memo)
        if slen >= 4:
            memo[i][nowstr[-3:]] = count
        return count
    


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding:utf-8
def main():
    # print("start")
    A,B = map(int,input().split())
    # print(A%4)
    point_A = A
    point_B = B
    if A%4 > 0:
        point_A = A - (A%4) + 4
    if B%4 > 0:
        point_B = B - (B%4)

    # print(point_A,point_B)
    # print()
    ans = 0
    for i in range(A,B+1):
        if i in range(point_A,point_B):
            continue
        else:
            ans = ans ^ i
    print(ans)
if __name__ == "__main__":
    main()

Fixed submission:
# coding:utf-8
def main():
    # print("start")
    A,B = map(int,input().split())
    # print(A%4)
    point_A = A
    point_B = B
    if A%4 > 0:
        point_A = A - (A%4) + 4
    if B%4 > 0:
        point_B = B - (B%4)

    # print(point_A,point_B)
    # print()
    ans = 0
    for i in range(A,point_A):
        ans = ans ^ i

    for i in range(point_B,B+1):
        ans = ans ^ i
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []
    ans.append(1)
    for i in range(2, max(A, B)):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


if __name__ == "__main__":
    main()


Fixed submission:
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []
    ans.append(1)
    for i in range(2, max(A, B)+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []

    for i in range(1, max(A, B)):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


if __name__ == "__main__":
    main()


Fixed submission:
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []
    ans.append(1)
    for i in range(2, max(A, B)+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []

    for i in range(1, max(A, B)):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        if len(ans) >= K:
            break
    # print(ans)
    print(ans[-1])


if __name__ == "__main__":
    main()


Fixed submission:
# coding:utf-8


def main():
    A, B, K = map(int, input().split())
    ans = []
    ans.append(1)
    for i in range(2, max(A, B)+1):
        if A % i == 0 and B % i == 0:
            ans.append(i)
        # if len(ans) >= K:
        #     break
    # print(ans)
    print(ans[-K])


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

def main():
    N = int(input())
    btc_to_jpy = 380000.0
    ans = 0
    for i in range(N):
        temp_value,unit = input().split()
        value = int(temp_value)
        if unit == "BTC":
            value *= btc_to_jpy
        ans += value
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
# coding: utf-8

def main():
    N = int(input())
    btc_to_jpy = 380000.0
    ans = 0
    for i in range(N):
        temp_value,unit = input().split()
        value = float(temp_value)
        if unit == "BTC":
            value *= btc_to_jpy
        ans += value
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
# coding: utf-8

def main():
    N = int(input())
    btc_to_jpy = 380000.0
    ans = 0
    for i in range(N):
        value,unit = map(int,input().split())
        if unit == "BTC":
            value *= btc_to_jpy
        ans += value
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
# coding: utf-8

def main():
    N = int(input())
    btc_to_jpy = 380000.0
    ans = 0
    for i in range(N):
        temp_value,unit = input().split()
        value = float(temp_value)
        if unit == "BTC":
            value *= btc_to_jpy
        ans += value
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#coding; utf-8


def main():
    N = int(input())
    A = list(map(int, input().split()))
    min_color = 0
    max_color = 0
    rate_criteria = 400
    rate = [0]*9
    for i in range(N):
        diva = A[i]//rate_criteria
        rate[diva] += 1

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

    max_color = min_color + rate[-1]
    # print(rate)
    print(min_color, max_color)


if __name__ == "__main__":
    main()


Fixed submission:
#coding; utf-8


def main():
    N = int(input())
    A = list(map(int, input().split()))
    min_color = 0
    max_color = 0
    rate_criteria = 400
    rate = [0]*9
    for i in range(N):
        diva = A[i]//rate_criteria
        if diva > 8:
            diva = 8
        rate[diva] += 1

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

    if min_color == 0 and rate[-1] > 0:
        min_color = 1
        max_color = rate[-1]
    else:
        max_color = min_color + rate[-1]
    # print(rate)
    print(min_color, max_color)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
import itertools
A,B,C,K = map(int,input().split())

count=0
if A>=K:
    ans=K
else:
    count+=A
    if A+B>=K:
        ans=A

    else:
        for i in range(K-(A+B)):
            count-=(K-(A+B))
            ans=count

print(ans)


Fixed submission:
import math
from functools import reduce
import itertools
A,B,C,K = map(int,input().split())

count=0
if A>=K:
    ans=K
else:
    count+=A
    if A+B>=K:
        ans=A

    else:
        count-=(K-(A+B))
        ans=count

print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
H = list(map(int,input().strip().split()))
xy=[map(int, input().split()) for _ in range(M)]
x, y = [list(i) for i in zip(*xy)]

list=[0]*N
for i in range(M):
    if H[x[i]-1]<H[y[i]-1]:
        list[x[i]-1]+=1
    else:
        list[y[i]-1]+=1
count=0
for i in range(M+1):
    if list[i]==0:
        count+=1

print(count)


Fixed submission:
N,M = map(int,input().split())
H = list(map(int,input().strip().split()))
xy=[map(int, input().split()) for _ in range(M)]
x, y = [list(i) for i in zip(*xy)]

list=[0]*N
for i in range(M):
    if H[x[i]-1]<H[y[i]-1]:
        list[x[i]-1]+=1

    elif  H[x[i]-1]==H[y[i]-1]:
        list[x[i]-1]+=1
        list[y[i]-1]+=1
    else:
        list[y[i]-1]+=1
count=0
for i in range(N):
    if list[i]==0:
        count+=1

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

X=int(input())
flg=False
for A in range(-118,119):
    for B in range(-118,119):
        if A**5-B**5==X:
            print(str(A)+" "+str(B))
            flg=True
            break
    if flg:
        break


Fixed submission:
X=int(input())
flg=False
for A in range(-120,120):
    for B in range(-120,120):
        if A**5-B**5==X:
            print(str(A)+" "+str(B))
            flg=True
            break
    if flg:
        break
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N= map(int,input().split())

list=[]
for i in range(N+1):
    list.append(math.floor((A*i)/B)-A*(math.floor(i/B)))

print(max(list))


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

if B<=N:
    lista=(math.floor((A*(B-1))/B)-A*(math.floor((B-1)/B)))
    print(lista)
else:
    list=(math.floor((A*N)/B)-A*(math.floor(N/B)))
    print(list)
Buggy python submission (verdict: Runtime Error):
S = str(input())

S_list =list(S)


A = 0
for i in range(0,len(S_list)-1):
    for j in range(i+3,len(S_list)+1):
        P = 0
        S_list_P = S_list[i:j]
        for k in range(0,j-i):
            P += int(S_list_P[k])* 10 ** (j-i-k-1)

        if P % 2019== 0:
            A += 1



print(A)


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

if S <= W:
    print("unsafe")

else :
    print("safe")