Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
count = 0
a = [0]*(10**4)
for i in range(1, 41):
  for j in range(1, 41):
    for k in range(1, 41):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(1, n+1):
  print(a[i])

Fixed submission:
n = int(input())
count = 0
a = [0]*(10**5)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(n):
  print(a[i+1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
count = 0
a = [0]*(10**4)
for i in range(1, 41):
  for j in range(1, 41):
    for k in range(1, 41):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(1, n+1):
  print(a[i])

Fixed submission:
n = int(input())
count = 0
a = [0]*(10**5)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(n):
  print(a[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
for l in range(1, n+1):
  for i in range(1, 41):
    for j in range(1, 41):
      if (i+j+i)**2-(i*j+j*i+i*i) == l:
        if i == j:   
          count += 1
        else:
          count += 3  
  print(count)
  count = 0    

Fixed submission:
n = int(input())
count = 0
a = [0]*(10**5)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(n):
  print(a[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
for l in range(1, n+1):
  for i in range(1, 41):
    for j in range(1, 41):
      for k in range(1, 41):
        if (i+j+k)**2-(i*j+j*k+i*k) == l:
          count +=1
  print(count)
  count = 0    

Fixed submission:
n = int(input())
count = 0
a = [0]*(10**5)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(n):
  print(a[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
for l in range(1, n+1):
  for i in range(1, l):
    for j in range(1, l):
      for k in range(1, l):
        if (i+j+k)**2-(i*j+j*k+i*k) == l:
          count +=1
  print(count)
  count = 0    

Fixed submission:
n = int(input())
count = 0
a = [0]*(10**5)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(n):
  print(a[i+1])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
count = 0
for l in range(1, n+1):
  for i in range(1,13):
    for j in range(1, 13):
      for k in range(1, 13):
        if (i+j+k)**2-(i*j+j*k+i*k) == l:
          count +=1
  print(count)
  count = 0    

Fixed submission:
n = int(input())
count = 0
a = [0]*(10**5)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(n):
  print(a[i+1])
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

mS = []
d = len(S) - len(T)


for j in range(d):
    m = 0
    for i in range(len(T)):
        if S[i] != T[i] :
            m += 1

    mS.append(m)
    S = S[1:]
print(min(mS))


Fixed submission:
S = input()
T = input()

mS = []
d = len(S) - len(T)
m = 0

if len(S) == len(T) :
    for i in range(len(T)):
        if S[i] != T[i] :
            m += 1
    print(m)

else :

    for j in range(d):
        m = 0
        for i in range(len(T)):
            if S[i] != T[i] :
                m += 1

        mS.append(m)
        S = S[1:]
    print(min(mS))

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

mS = []
d = len(S) - len(T)

for j in range(d):
    m = 0
    for i in range(len(T)):
        if S[i] == T[i] :
            m += 1

    mS.append(m)
    S = S[1:]
print(len(T) - max(mS))

Fixed submission:
S = input()
T = input()

mS = []
d = len(S) - len(T)
m = 0

if len(S) == len(T) :
    for i in range(len(T)):
        if S[i] != T[i] :
            m += 1
    print(m)

else :

    for j in range(d):
        m = 0
        for i in range(len(T)):
            if S[i] != T[i] :
                m += 1

        mS.append(m)
        S = S[1:]
    print(min(mS))
Buggy python submission (verdict: Runtime Error):
X, Y = map(int,input().split())

for i in range(X) :
    if Y -(4*((i+1) == (X-(i+1))*2 :
        print("Yes")
        exit()
    else :
        if Y==2 or Y==4 :
            print("Yes")
            exit()
print("No")

Fixed submission:
X, Y = map(int,input().split())
XX = X +1
for i in range(XX) :
    if Y -(4*i) == (X-i)*2 :
        print("Yes")
        exit()

print("No")
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
d = int(input())
Ax = [list(map(int,input().split())) for i in range(N + K - d)]

print( N - d)

Fixed submission:
N, K = map(int, input().split())
A = []
for i in range(K) :
    d = int(input())
    a = list(map(int, input().split()))
    A += a

print(N - len(set(A)))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import math

N = int(input())

ans = 0
#N_half = int(math.sqrt(N)+1)
for A in range(1, N):
    for B in range(1, N):
        if A * B < N:
            ans += 1
        else:
            break
    
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import math

N = int(input())

ans = 0
N_half = int(math.sqrt(N))
for A in range(1, N_half+1):
    for B in range(1, N):
        if A * B < N:
            ans += 1
            if B > N_half:
                ans += 1
        else:
            break
    
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

def get_digits_sum(val_str):
    digits_sum = 0
    for i in range(len(val_str)):
        digits_sum += int(val_str[i])

    return digits_sum

N = int(input())


for i in range(2, N, 1):
    A = i
    B = N - i
    a_sum = get_digits_sum(str(A))
    b_sum = get_digits_sum(str(B))
    if i==2:
        sum_min = a_sum + b_sum
    elif sum_min > a_sum + b_sum:
        sum_min = a_sum + b_sum
        
print(sum_min)

Fixed submission:
# -*- coding: utf-8 -*-

def get_digits_sum(val_str):
    digits_sum = 0
    for i in range(len(val_str)):
        digits_sum += int(val_str[i])

    return digits_sum

N = int(input())

if N==2:
    sum_min = 2

for i in range(2, N, 1):
    A = i
    B = N - i
    a_sum = get_digits_sum(str(A))
    b_sum = get_digits_sum(str(B))
    if i==2:
        sum_min = a_sum + b_sum
    elif sum_min > a_sum + b_sum:
        sum_min = a_sum + b_sum
        
print(sum_min)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import numpy as np

# worst order: 101^6 => 10^8

def check(a, b, c):
    flag = True
    for i in range(3):
        for j in range(3):
           if c[i][j]!=a[i]+b[j]:
               flag = False
               return flag

    return flag

c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

arr_c = np.array(c)
a_max = np.amax(arr_c, axis=1)
b_max = np.amax(arr_c, axis=0)

a = []
b = []
for i in range(3):
    if len(list(range(0, a_max[i]+1, 1)))==0:
        a.append([0])
    else:
        a.append(list(range(0, a_max[i]+1, 1)))
    
    if len(list(range(0, b_max[i]+1, 1)))==0:
        b.append([0])
    else:
        b.append(list(range(0, b_max[i]+1, 1)))

ans = 'No'
cnt = 0
for a0 in a[0]:
    for a1 in a[1]:
        for a2 in a[2]:
            for b0 in b[0]:
                for b1 in b[1]:
                    for b2 in b[2]:
                        a_list = [a0, a1, a2]
                        b_list = [b0, b1, b2]
                        flag = check(a_list, b_list, c)
                        if flag == True:
                            print("Yes")
                            exit(0)

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np

# worst order: 101^6 => 10^8

def check(a, b, c):
    flag = True
    for i in range(3):
        for j in range(3):
           if c[i][j]!=a[i]+b[j]:
               flag = False
               return flag

    return flag

c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

arr_c = np.array(c)
a_max = np.amax(arr_c, axis=1)
b_max = np.amax(arr_c, axis=0)

a = []
b = []
for i in range(3):
    if len(list(range(0, a_max[i]+1, 1)))==0:
        a.append([0])
    else:
        a.append(list(range(0, a_max[i]+1, 1)))
    
    if len(list(range(0, b_max[i]+1, 1)))==0:
        b.append([0])
    else:
        b.append(list(range(0, b_max[i]+1, 1)))

ans = 'No'
cnt = 0
for a0 in a[0]:
    for b0 in b[0]:
        if c[0][0] != a0 + b0:
            continue
        for a1 in a[1]:
            if c[1][0] != a1 + b0:
                continue
            for b1 in b[1]:
                if c[0][1] != a0 + b1 or c[1][1] != a1 + b1:
                    continue   
                for a2 in a[2]:
                    if c[2][0] != a2 + b0 or c[2][1] != a2 + b1:
                        continue
                    for b2 in b[2]:
                        if c[0][2] != a0 + b2 or c[1][2] != a1 + b2 or c[2][2] != a2 + b2:
                            continue

                        print("Yes")
                        exit(0)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
A = list(map(int, input().split()))

count = [0] * len(set(A))
labels = set(A)
for val in A:
    for i, label in enumerate(labels):
        if label==val:
            count[i] += 1

ans = 0
diff = len(set(A)) - K
if diff > 0:
    count_sorted = sorted(count)
    for i in range(diff):
        ans += count_sorted[i]

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
A = list(map(int, input().split()))

count = {}
for val in A:
    if val in count:
        count[val] += 1
    else:
        count[val] = 1

ans = 0
diff = len(set(A)) - K
if diff > 0:
    count_sorted = sorted(count.items(), key=lambda x:x[1])
    for k,v in count_sorted:
        ans += v
        diff -= 1
        if diff == 0:
            break

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

def get_count(S, H, W, i, j):
    num = 0
    start_i = start_j = -1
    end_i = end_j = 2
    if i == 0:
        start_i = 0
    elif i == W-1:
        end_i = 1
    if j == 0:
        start_j = 0
    elif j == H-1:
        end_j = 1

    for y in range(start_j, end_j, 1):
        for x in range(start_i, end_i, 1):
            if S[j+y][i+x] == "#":
                num += 1

    return num


H,W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))

for y in range(H):
    for x in range(W):
        if S[y][x] == ".":
            num = get_count(S, H, W, x, y)
            S[y][x] = str(num)

for y in range(H):
    print("".join(S[y]))            


Fixed submission:
# -*- coding: utf-8 -*-

def get_count(S, H, W, i, j):
    num = 0
    start_i = start_j = -1
    end_i = end_j = 2
    if W == 1:
        start_i = 0 
        end_i = 1
    else:
        if i == 0:
            start_i = 0
        elif i == W-1:
            end_i = 1
    if H == 1:
        start_j = 0
        end_j = 1
    else:
        if j == 0:
            start_j = 0
        elif j == H-1:
            end_j = 1

    for y in range(start_j, end_j, 1):
        for x in range(start_i, end_i, 1):
            if S[j+y][i+x] == "#":
                num += 1

    return num


H,W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))

for y in range(H):
    for x in range(W):
        if S[y][x] == ".":
            num = get_count(S, H, W, x, y)
            S[y][x] = str(num)

for y in range(H):
    print("".join(S[y]))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

A,B,C = map(int, input().split())

ans = "NO"
for i in range(B+1)):
    res = A * i % B
    if res == C:
        ans = "YES"
        break

print(ans)

Fixed submission:
# -*- coding: utf-8 -*-

A,B,C = map(int, input().split())

mod = []
for i in range(max(B,C)):
    res = A * i % B
    if res == C:
        ans = "YES"
        break
    if res in mod:
        ans = "NO"
        break
    mod.append(res)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans = 1

for e in map(int, input().split()):
    ans *= e

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


Fixed submission:
n = int(input())

a = [*map(int, input().split())]
for e in a:
    if e == 0:
        print(0)
        exit(0)

ans = 1
for e in a:
    ans *= e
    if ans > 10**18:
        print(-1)
        exit(0)

print(ans)

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

ans = 1

for e in [*map(int, input().split())]:
    ans *= e

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


Fixed submission:
n = int(input())

a = [*map(int, input().split())]
for e in a:
    if e == 0:
        print(0)
        exit(0)

ans = 1
for e in a:
    ans *= e
    if ans > 10**18:
        print(-1)
        exit(0)

print(ans)
Buggy python submission (verdict: Runtime Error):
#B
N=int(input())
cnt=0
flag=False
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt=3:
        flag=True
        break
if flag:
    print("Yes")
else:
    print("No")

Fixed submission:
#B
N=int(input())
cnt=0
flag=False
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag=True
        break
if flag:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
#E
from math import gcd
N=int(input())
A=list(map(int,input().split()))
GCD=A[0]
for i in range(1,N):
    GCD=gcd(GCD,A[i])
    
def Primefact(n):
    Dic={}
    for i in range(2,int(pow(n,0.5))+1):
        if n%i==0:
            Dic[i]=0
            while True:
                n/=i
                Dic[i]+=1
                if n%i!=0:
                    break
        if n==1:
            break
    if n!=1:
        Dic[int(n)]=1
    return Dic

if GCD==1:
    L=[False for i in range(10**6+1)]
    flag=False
    for i in range(N):
        Li=Primefact(A[i])
        for k,v in Li.items():
            if L[k]:
                flag=True
                break
            else:
                L[k]=True
    if flag:
        ans="setwise coprime"
    else:
        ans="pairwise coprime"
else:
    ans="not coprime"
print(ans)

Fixed submission:
#E
from math import gcd
N=int(input())
A=list(map(int,input().split()))
GCD=A[0]
for i in range(1,N):
    GCD=gcd(GCD,A[i])
    
def Fast_PFact(n):
    List=[0 for i in range(n+1)]
    List[1]=1
    for i in range(2,n+1):
        if List[i]==0:
            cnt=1
            while i*cnt<=n:
                List[i*cnt]=i
                cnt+=1
    return List

if GCD==1:
    P=Fast_PFact(10**6)
    L=[False for i in range(10**6+1)]
    flag=False
    for i in range(N):
        a=A[i]
        while a>1:
            if L[P[a]]:
                flag=True
                break
                
            else:
                L[P[a]]=True
                divisor=P[a]
                while divisor==P[a]:
                    a=int(a/divisor)        
    if flag:
        ans="setwise coprime"
    else:
        ans="pairwise coprime"
else:
    ans="not coprime"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#C
N,K=map(int,input().split())
A=list(map(int,input().split()))

max=1
for i in range(K):
    max*=A[i]
for i in range(K,N):
    if max<(max//A[i-K])*A[i]:
        print("Yes")
        max=(max//A[i-K])*A[i]
    else:
        print("No")

Fixed submission:
#C
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))

for i in range(N):
    A[i]=math.log10(A[i])
max=0
for i in range(K):
    max+=A[i]
for i in range(K,N):
    if max<max-A[i-K]+A[i]:
        print("Yes")
        max=max-A[i-K]+A[i]
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
#D
N=int(input())
A=list(map(int,input().split()))
B=[]

for i in range(N-1):
    if A[i+1]>A[i]:
        B.append(["up",i])
    elif A[i+1]<A[i]:
        B.append(["down",i])
        
C=[]
for i in range(len(B)-1):
    if B[i][0]==B[i+1][0]:
        continue
    C.append(B[i])
C.append(B[-1])

while True:
    if C==[]:
        break
    if C[-1][0]=="down":
        C.pop(-1)
    else:
        break
        
kabu=0
money=1000
if C!=[]:
    if C[0][0]=="up":
        kabu+=money//A[0]
        money%=A[0]
for act in C:
    if act[0]=="up":
        money+=A[act[1]+1]*kabu
        kabu=0
    else:
        kabu+=money//A[act[1]+1]
        money%=A[act[1]+1]
print(money)

Fixed submission:
#D
N=int(input())
A=list(map(int,input().split()))
B=[]

for i in range(N-1):
    if A[i+1]>A[i]:
        B.append(["up",i])
    elif A[i+1]<A[i]:
        B.append(["down",i])
        
C=[]
for i in range(len(B)-1):
    if B[i][0]==B[i+1][0]:
        continue
    C.append(B[i])
if B!=[]:
    C.append(B[-1])

while True:
    if C==[]:
        break
    if C[-1][0]=="down":
        C.pop(-1)
    else:
        break
        
kabu=0
money=1000
if C!=[]:
    if C[0][0]=="up":
        kabu+=money//A[0]
        money%=A[0]
for act in C:
    if act[0]=="up":
        money+=A[act[1]+1]*kabu
        kabu=0
    else:
        kabu+=money//A[act[1]+1]
        money%=A[act[1]+1]
print(money)
Buggy python submission (verdict: Runtime Error):
#D
N=int(input())
X=str(input())
   
CNT=0
for i in range(N):
    if X[i]=="1":
        CNT+=1
NUM=int(X,2)

to0_cnt=[0 for i in range(N)]
for i in range(1,N):
    ans=0
    num=i
    while True:
        cnt=0
        for j in bin(num)[2:]:
            if j=="1":
                cnt+=1
        if cnt==0:
            break
        r=num%cnt
        ans+=1
        if r==0:
            break
        num=r
    to0_cnt[i]=ans
                

R=[NUM%(CNT+1),NUM%(CNT-1)]
for i in range(N):
    if X[i]=="0":
        cnt=CNT+1
        r=(R[0]+2**(N-i-1))%cnt
    else:
        cnt=CNT-1
        r=(R[1]-2**(N-i-1))%cnt
    
    ans=1+to0_cnt[r]
    print(ans)

Fixed submission:
#D
N=int(input())
X=str(input())
   
CNT=0
for i in range(N):
    if X[i]=="1":
        CNT+=1
NUM=int(X,2)

to0_cnt=[0 for i in range(N)]
for i in range(1,N):
    ans=0
    num=i
    while True:
        cnt=0
        for j in bin(num)[2:]:
            if j=="1":
                cnt+=1
        if cnt==0:
            break
        r=num%cnt
        ans+=1
        if r==0:
            break
        num=r
    to0_cnt[i]=ans
                
R=[NUM%(CNT+1),NUM%(CNT-1) if CNT!=1 else 0]
for i in range(N):
    if X[i]=="0":
        cnt=CNT+1
        r=(R[0]+pow(2,N-i-1,cnt))%cnt
    else:
        cnt=CNT-1
        if NUM-pow(2,N-i-1)==0:
            print(0)
            continue
        r=(R[1]-pow(2,N-i-1,cnt))%cnt
    
    ans=1+to0_cnt[r]
    print(ans)

Buggy python submission (verdict: Runtime Error):
#D
N=int(input())
X=str(input())
   
CNT=0
for i in range(N):
    if X[i]=="1":
        CNT+=1
NUM=int(X,2)

R=[NUM%(CNT+1),NUM%(CNT-1)]
for i in range(N):
    if X[i]=="0":
        cnt=CNT+1
        r=(R[0]+2**(N-i-1))%cnt
    else:
        cnt=CNT-1
        r=(R[1]-2**(N-i-1))%cnt
    
    ans=1
    while True:
        if r==0:
            print(ans)
            break

        num=r
        cnt=0
        for i in bin(num)[2:]:
            if i=="1":
                cnt+=1
        r=num%cnt
        ans+=1

Fixed submission:
#D
N=int(input())
X=str(input())
   
CNT=0
for i in range(N):
    if X[i]=="1":
        CNT+=1
NUM=int(X,2)

to0_cnt=[0 for i in range(N)]
for i in range(1,N):
    ans=0
    num=i
    while True:
        cnt=0
        for j in bin(num)[2:]:
            if j=="1":
                cnt+=1
        if cnt==0:
            break
        r=num%cnt
        ans+=1
        if r==0:
            break
        num=r
    to0_cnt[i]=ans
                
R=[NUM%(CNT+1),NUM%(CNT-1) if CNT!=1 else 0]
for i in range(N):
    if X[i]=="0":
        cnt=CNT+1
        r=(R[0]+pow(2,N-i-1,cnt))%cnt
    else:
        cnt=CNT-1
        if NUM-pow(2,N-i-1)==0:
            print(0)
            continue
        r=(R[1]-pow(2,N-i-1,cnt))%cnt
    
    ans=1+to0_cnt[r]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#B
N=int(input())
ans=1
for x in input().split():
    ans*=int(x)

if ans>pow(10,18):
    print("-1")
else:
    print(ans)

Fixed submission:
#B
N=int(input())
ans=1
flag=True
A=[]
for x in input().split():
    A.append(int(x))
    if int(x)==0:
        ans=0

for i in range(N):
    x=A[i]
    ans*=x
    if ans>pow(10,18):
        flag=False
        break

if flag:
    print(ans)
else:
    print("-1")

Buggy python submission (verdict: Time Limit Exceeded):
#B
N=int(input())
ans=1
for x in input().split():
    ans*=int(x)

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

Fixed submission:
#B
N=int(input())
ans=1
flag=True
A=[]
for x in input().split():
    A.append(int(x))
    if int(x)==0:
        ans=0

for i in range(N):
    x=A[i]
    ans*=x
    if ans>pow(10,18):
        flag=False
        break

if flag:
    print(ans)
else:
    print("-1")
Buggy python submission (verdict: Time Limit Exceeded):
#B
T=input()
L=["" for i in range(len(T))]
for i in range(len(T)):   
    if T[i]=="?":
        L[i]="D"
    else:
        L[i]=T[i]

ans=""
for i in L:
    ans+=i
print(ans)

Fixed submission:
#B
T=input()
ans=T.replace("?", "D")
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#B

A,B,C,K=map(int,input().split())
cnt=0
Sum=0
while True:
    if cnt==K:
        print(Sum)
        break
        
    if A!=0:
        A+=-1
        Sum+=1
        cnt+=1
        continue
        
    elif B!=0:
        B+=-1
        cnt+=1
        continue
        
    elif C!=0:
        C+=-1
        Sum+=-1
        cnt+=1
        continue

Fixed submission:
#B

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

if K<=A:
    Sum=K
elif K<=A+B:
    Sum=A
else:
    Sum=A-(K-A-B)
    
print(Sum)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
S=str(input())

T=[0 for i in range(len(S))]
T[0]=int(S[-1])

for i in range(1,len(S)):
    T[i]=((10**i)*int(S[len(S)-1-i])+T[i-1])%2019
    
cnt=0
T_di=collections.Counter(T)

for key in T_di.keys():
    x=T_di[key]
    cnt+=x*(x-1)/2
    if key==0:
        cnt+=x

print(int(cnt))

Fixed submission:
import collections
S=str(input())

T=[0 for i in range(len(S))]
T[0]=int(S[-1])

for i in range(1,len(S)):
    T[i]=(pow(10,i,2019)*int(S[len(S)-1-i])+T[i-1])%2019
    
cnt=0
T_di=collections.Counter(T)

for key in T_di.keys():
    x=T_di[key]
    cnt+=x*(x-1)/2
    if key==0:
        cnt+=x

print(int(cnt))