Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02684 (python)

Fixed submission:
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    cnt = [-1] * n
    cnt[0] = 0
    ary = []
    now = 0
    for i in range(n):
        a[i] -= 1

    ary.append(now)
    if k <= n:
        for i in range(1,k+1):
            now = a[now]
            if i == k:
                print(now+1)
                return
    else:
        for i in range(1,k+1):
            now = a[now]
            if cnt[now] != -1:
                break
            else:
                cnt[now] = i
                ary.append(now)
        loop_s = cnt[now]

        print(ary[cnt[now] +((k-cnt[now]) % (i - cnt[now]))] + 1)
        # print(cnt)
        # print(now)
        # print(ary)

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    cnt = [-1] * n
    cnt[0] = 0
    ary = []
    now = 1
    ary.append(now)
    if k <= n:
        for i in range(1,k+1):
            now = a[now-1]
            if i == k:
                print(now)
                return
    else:
        for i in range(1,k+1):
            now = a[now-1]
            if cnt[now-1] != -1:
                break
            else:
                cnt[now-1] = i
                ary.append(a[now-1])


        print(ary[cnt[now-1]+((k-cnt[now-1]) % (i - cnt[now-1]))+1])
        
if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    ary = [0]
    tmp = [0] * n
    tmp[0] = 1
    now = 0
    for cnt in range(1,k+1):
        now = a[now] - 1
        ary.append(now)
        if cnt == k:
            print(now)
            return
        if tmp[now] != 0:
            break
        else:
            tmp[now] = cnt + 1
    m = (k - tmp[now]-1) % (cnt - tmp[now])
    print(ary[m+cnt-tmp[now] -1] + 1 )



if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    ary = [0]
    tmp = [0] * n
    tmp[0] = 1
    now = 0
    for cnt in range(1,k+1):
        now = a[now] - 1
        ary.append(now)
        if tmp[now] != 0:
            break
        else:
            tmp[now] = cnt + 1
    m = (k - tmp[now]-1) % (cnt - tmp[now])
    print(ary[m+cnt-tmp[now] -1] + 1 )



if __name__=='__main__':
    main()
Problem p02690 (python)

Fixed submission:
import math
def main():
    x = int(input())
    tmp = [0] * 1000
    for i in range(1000):
        tmp[i] = i**5
    for i in range(1000):
        a = x+tmp[i]
        if abs(a) in tmp:

            print(int(a**0.2),i)
            return

        a = x - tmp[i]
        if abs(a) in tmp:

            print(int(a**0.2),-i)
            return

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    x = int(input())
    tmp = [0] * 100
    for i in range(100):
        tmp[i] = i**5
    for i in range(100):
        a = x-tmp[i]
        if abs(a) in tmp:
            print(int(a**0.2),i*(a//abs(a)))
            return
if __name__=='__main__':
    main()
Problem p02696 (python)

Fixed submission:
def main():
    a,b,n = map(int,input().split())
    aa = min(b-1,n)
    ans = a*aa//b  - a * (aa//b)
    print(ans)
if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    a,b,n = map(int,input().split())
    aa = min(b,n)
    for i in range(aa,n):

        ans = max(ans,a*aa//b  - a * (aa//b))
    print(ans)
if __name__=='__main__':
    main()
Problem p02702 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)


S = input()
N = len(S)
P = 2019

if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
    sys.exit()

num = [0] * P
num[0] = 1
now, ans = 0, 0
_10 = 1
for i in range(N-1, -1, -1):
    now = (now + int(S[i]) * _10) % P
    _10 *= 10
    _10 %= P
    ans += num[now]
    num[now] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    s = list(input())
    h = [[] for i in range(10)]
    for i in range(1,100):
        a = 2019 * i
        sa = str(a)
        if '0' in sa:
            continue
        ha = int(sa[0])

        h[ha].append(list(sa))
    ans = 0
    if len(s) < 5:
        print(0)
        return
    for i, s_top in enumerate(s):
        if i > len(s) - 3:
            break
        for j, hh in enumerate(h[int(s_top)]):
            flg = True
            for k, hhs in enumerate(hh):
                if s[i + k] != hhs:
                    flg = False
                    break
            if flg :
                ans += 1
    print(ans)
if __name__=='__main__':
    main()
Problem p02786 (python)

Fixed submission:
import math
def main():
    h = int(input())
    cnt = 0
    ans = 0
    tmp = 1
    a = int(math.log2(h))
    cnt = 2 **a
    ans = (1-2**a)//(1-2)
    print(ans+cnt)
    
if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
def main():
    h = int(input())
    cnt = 0
    ans = 0
    tmp = 1
    a = int(math.log2(h))
    cnt = 2 **a
    ans = (1-2**(a+1))//(1-2)
    print(ans)

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
def main():
    h = int(input())
    cnt = 0
    ans = 0
    tmp = 1
    a = int(math.log2(h))
    cnt = 2 **a
    ans = (1-2**a)//(1-2)
    print(ans+cnt)
    # while True:
    #     h //=2
    #
    #     cnt += tmp
    #     tmp *= 2
    #     if h==1:
    #         break
    #
    # print(cnt+tmp)
if __name__=='__main__':
    main()
Problem p02838 (python)

Fixed submission:
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    cnt1=[0]*60
    for num in a:
        for i in range(60):
            cnt1[i] += (num >> i) & 1
    for i in range(60):
        ans += cnt1[i] * (n - cnt1[i]) * pow(2,i,MOD)
    print(ans % MOD)


if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    temp=0
    MOD=10**9+7
    leng=0
    bin_a=[[0] * n for i in range(60)]
    for i in range(n):
        tmp=str(bin(a[i]))
        # print(a[i])
        # print(len(tmp))
        leng=max(leng,len(tmp))
        for j in range(len(tmp)-2):
            if tmp[len(tmp)-j-1] == 'b':
                break
            # print(tmp[len(tmp)-i-1])
            bin_a[j][i]=int(tmp[len(tmp)-j-1])

    for i in range(leng):
        cnt1=sum(bin_a[i])
        cnt0=n-cnt1
        ans+=cnt1*cnt0*2**i%MOD
    print(ans%MOD)

if __name__=='__main__':
    main()
Problem p02900 (python)

Fixed submission:
def main():
    x,y = map(int,input().split())
    tmp = [1]
    i = 2
    ans = 0
    # if x == y:
    #     ans += 1
    # a = factorization(x)
    # print(a)
    tempx = x

    for i in range(2, int(-(-x**0.5//1))+1):
        if tempx % i == 0:
            tmp.append(i)
            while tempx % i == 0:

                tempx //= i
    if tempx!=1:
        tmp.append(tempx)
    # print(tmp)

    for i,a in enumerate(tmp):
        if y % a == 0:
            tmp[i] = 1
        else:
            tmp[i] = 0
    print(sum(tmp))


if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    x,y = map(int,input().split())
    tmp = []
    i = 2
    ans = 0
    if x == y:
        ans += 1
    for i in range(2,min((-(-x**0.5//1))+1,(-(-y**0.5//1)+1))):


        if i > x or i > y:
            break
        if x % i ==0 and y % i == 0:
            tmp.append(i)
            while True:
                if x % i == 0:
                    x = x//i
                else:
                    break
            while True:
                if y % i == 0:
                    y = y//i
                else:
                    break
        i += 1
    ans += len(tmp) + 1

    print(ans)
    # print(tmp)
if __name__=='__main__':
    main()
Problem p02922 (python)

Fixed submission:
a,b = map(int,input().split())
ans = 0
while True:
  n = ans * a -(ans - 1)
  if n >= b:
    break
  ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
ans = 0
if b % a != 0:
  ans += 1
ans += b // a
print(ans)
Problem p02975 (python)

Fixed submission:
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    aset=set(a)

    if sum(a) == 0:
        print('Yes')
        return
    # if n % 3 != 0:
        # print('No')
        # return
    if len(cnt.most_common()) == 3:
        a1, a2, a3 = aset
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] == cnt.most_common()[2][1]  and a1 ^ a2 == a3:
            # print(cnt.most_common())
            print('Yes')
            return

    if len(cnt.most_common()) == 2:

        tmp_min = cnt.most_common()[1][1]
        tmp_max = cnt.most_common()[0][1]
        if 3 * tmp_min == n and int(cnt.most_common()[1][0]) == 0:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    aset=set(a)
    a1, a2, a3 = aset
    if sum(a) == 0:
        print('Yes')
        return
    # if n % 3 != 0:
        # print('No')
        # return
    if len(cnt.most_common()) == 3:
        if cnt.most_common()[0][1] == cnt.most_common()[1][1] == cnt.most_common()[2][1]  and a1 ^ a2 == a3:
            # print(cnt.most_common())
            print('Yes')
            return

    if len(cnt.most_common()) == 2:

        tmp_min = cnt.most_common()[1][1]
        tmp_max = cnt.most_common()[0][1]
        if 3 * tmp_min == n and int(cnt.most_common()[1][0]) == 0:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if n % 3 != 0:
        print('No')
        return
    if num != 3 and cnt[0][1] !=3 and cnt[-1][1] != 3:
        print('No')
        return
    print('Yes')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections
def main():
    n = int(input())
    a = list(map(int,input().split()))
    cnt = collections.Counter(a)
    num = len(set(a))
    if n % 3 != 0:
        print('No')
        return
    if num != 3 and cnt[0][1] !=3 and cnt[-1][1 != 3]:
        print('No')
        return
    print('Yes')

if __name__ == '__main__':
    main()
Problem p03140 (python)

Fixed submission:
n = int(input())
a = list(input())
b = list(input())
c = list(input())

ans = 0
for i in range(n):
  aa = a[i]
  bb = b[i]
  cc = c[i]
  if len(set([aa,bb,cc])) == 1:
    continue
  elif len(set([aa,bb,cc])) == 2:
    ans += 1
  else:
    ans += 2
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(input())
b = list(input())
c = list(input())

ans = 0
for i in range(n):
  aa = a[i]
  bb = b[i]
  cc = c[i]
  if len(set([a,b,c])) == 1:
    continue
  elif len(set([a,b,c])) == 2:
    ans += 1
  else:
    ans += 2
print(ans)
Problem p03231 (python)

Fixed submission:
import fractions
n,m = map(int,input().split())
s = input()
t = input()

lcm = n*m // fractions.gcd(n,m)
ans = -1
ss = lcm // m
ts = lcm // n
j = 0
flg = True
for i in range(0,n,ss):
    if s[i] == t[j] :
        j += ts
        continue
    else:
        flg = False
        break

if flg :
    ans = lcm
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
n,m = map(int,input().split())
s = input()
t = input()

lcm = n*m // fractions.gcd(n,m)
i = lcm
cnt = 0
while True:
    ans = [''] * i
    ai = 0
    for si in range(0,n):

        ans[ai] = s[si]
        ai += lcm//n
    ai = 0
    flg = True
    for ti in range(m):
        if ans[ai] == '' or t[ti] == ans[ai]:
            ans[ai] = t[ti]
        else:
            flg = False
            break
        ai += lcm//m
    if flg :
        print(i)
        break
    i += lcm
    cnt += 1
    if cnt == 10000:
        print(-1)
        break

Buggy submission (verdict: Runtime Error):
import math
n,m = map(int,input().split())
s = input()
t = input()

lcm = n*m // math.gcd(n,m)
i = lcm
cnt = 0
while True:
    ans = [''] * i
    ai = 0
    for si in range(0,n):

        ans[ai] = s[si]
        ai += lcm//n
    ai = 0
    flg = True
    for ti in range(m):
        if ans[ai] == '' or t[ti] == ans[ai]:
            ans[ai] = t[ti]
        else:
            flg = False
            break
        ai += lcm//m
    if flg :
        print(i)
        break
    i += lcm
    cnt += 1
    if cnt == 10000:
        print(-1)
        break
Problem p03244 (python)

Fixed submission:
import collections
def main():
    n = int(input())
    v = list(map(int,input().split()))

    if len(set(v)) == 1:
        print(n//2)
    elif len(set(v)) == 2:
        cnt1 = 0
        cnt2 = 0
        tmp1 = list(set(v))
        tmp2 = [tmp1[1], tmp1[0]]
        # even = v[::2]
        # odd = v[1::2]
        #
        for i, a in enumerate(v):
            if i % 2 == 0:
                if a == tmp1[0]:
                    cnt1 += 1
                if a == tmp2[0]:
                    cnt2 += 1
            else :
                if a == tmp1[1]:
                    cnt1 += 1
                if a == tmp2[1]:
                    cnt2 += 1
        print(n-max(cnt1,cnt2))
    else:
        even = v[::2]
        odd = v[1::2]
        count_e = collections.Counter(even)
        count_o = collections.Counter(odd)
        ce = count_e.most_common()
        co = count_o.most_common()
        if ce[0][0] != co[0][0]:
            print(n-ce[0][1] - co[0][1])
        else:
            if len(ce) == 1:
                print(n-co[1][1])
            elif len(co) == 1:
                print(n-ce[1][1])
            else:
                print(min(n-ce[0][1]-co[1][1], n-ce[1][1]-co[0][1]))




if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import collections
def main():
    n = int(input())
    v = list(map(int,input().split()))

    odd = v[1::2]
    count_e = collections.Counter(even)
    count_o = collections.Counter(odd)
    ce = count_e.most_common()
    co = count_o.most_common()
    if ce[0][0] != co[0][0]:
        print(n-ce[0][1] - co[0][1])
    else:
        if len(ce) == 1 and len(co) == 1:
            print(n//2)
        elif len(ce) == 1:
            print(n-co[1][1])
        elif len(co) == 1:
            print(n-ce[1][1])
        else:
            print(min(n-ce[0][1]-co[1][1], n-ce[1][1]-co[0][1]))




if __name__ == '__main__':
    main()
Problem p03393 (python)

Fixed submission:
import collections
s = list(input())
sset = set(s)
if len(sset) != 26:
    for i in range(97,123):
        if chr(i) in sset:
            continue
        else:
            tmp = chr(i)
            s.append(tmp)
            break

    print(''.join(s))
    exit()
else:
    tmp = []
    flg = False
    for i in range(1,26):
        if s[i-1] < s[i]:
            tmp.append(i-1)
            continue

    if len(tmp) == 0:
        print(-1)
        exit()
    change_i = max(tmp)
    if change_i == 0:
        print(chr(ord(s[0])+1))
        exit()
    ans = s[:change_i]
    for i in range(97,123):
        if chr(i) in ans:
            continue
        else:
            if ord(s[change_i]) < i:
                ans.append(chr(i))
                break
    print(''.join(ans))

Buggy submission (verdict: Runtime Error):
import collections
s = list(input())
sset = set(s)
if len(sset) != 26:
    for i in range(97,123):
        if chr(i) in sset:
            continue
        else:
            tmp = chr(i)
            s.append(tmp)
            break

    print(''.join(s))
    exit()
else:
    tmp = []
    flg = False
    s = s[::-1]
    for i in range(1,26):
        if ord(s[i-1]) < ord(s[i]) and not flg:
            flg = True
            tmp.append(ord(s[i-1]))
            tmp.append((ord(s[i])))
            continue
        if flg and ord(s[i-1]) > ord(s[i]):
            top = i
            break
        if ord(s[i-1]) < ord(s[i]) and flg:
            tmp.append(ord(s[i]))

    if len(tmp) == 26:
        print(-1)
        exit()
    ans = s[top:]
    ans = ans[::-1]
    ans.append(chr(min(tmp)))
    print(''.join(ans))
Problem p03417 (python)

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

if n == 1 and m == 1:
    print(1)
elif n >= 2 and m >= 2:
    print((n-2)*(m-2))
elif n == 1:
    print(m-2)
else :
    print(n-2)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())

if n == 1 and m == 1:
    print(1)
elif n >= 2 and m >= 2:
    print((n-2)*(m-2))
elif n == 1:
    print(m-2)
else m == 1:
    print(n-2)
Problem p03592 (python)

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

for i in range(n):

    if (n-2*i) != 0 and (k-m*i) % (n-2*i) == 0:
        j = (k - m * i) // (n - 2 * i)
        if 0 <= j <= m:
            print('Yes')
            exit()
print('No')

Buggy submission (verdict: Runtime Error):
n,m,k = map(int,input().split())

for i in range(n):

    if (n-2*i) != 0 and (k-m*i) % (n-2*i) == 0:
        j = (k - m * i) // (n - 2 * i)
        if w*i + (n-2*i)*j == k:
            print('Yes')
            exit()
print('No')
Problem p03633 (python)

Fixed submission:
import fractions

n = int(input())
t = [0] * n
for i in range(n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
    ans = ans * t[i] // fractions.gcd(ans,t[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

n = int(input())
t = [0] * n
for i in range(n):
    t[i] = int(input())

ans = t[0]
for i in range(1,n):
    ans = ans * a[i] // fractions.gcd(ans,a[i])
print(ans)
Problem p03827 (python)

Fixed submission:
def main():
    n = int(input())
    s = list(input())

    ans = 0
    now = 0
    for i, i_d in enumerate(s):
        if i_d == 'I':
            now += 1
            ans = max(ans, now)
        else:
            now -= 1

    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    s = list(input().split())

    ans = 0
    now = 0
    for i, i_d in enumerate(s):
        if i_d == 'I':
            now += 1
            ans = max(ans, now)
        else:
            now -= 1

    print(ans)
if __name__ = '__main__':
    main()
Problem p03854 (python)

Fixed submission:
def main():
    Ss = input()
    S = list(Ss)
    now = 0
    T = ''
    Sr = []
    for i in range(1,len(S)+1):
        Sr.append(S[-i])
    ans = []
    while True:
        tmp5 = Sr[now:now+5]
        tmp6 = Sr[now:now+6]
        tmp7 = Sr[now:now+7]
        if tmp5[0] == 'e' and tmp5 == ['e','s','a','r','e']:
            ans.append('erase')
            now += 5
        elif tmp5[0] == 'm' and tmp5 == ['m','a','e','r','d']:
            ans.append('dream')
            now += 5
        elif tmp6[0] == 'r' and tmp6 == ['r','e','s','a','r','e']:
            ans.append('eraser')
            now += 6
        elif tmp7[0] == 'r' and tmp7 == ['r','e','m','a','e','r','d']:
            ans.append('dreamer')
            now += 7
        else:
            print('NO')
            
            return

        if now >= len(S):
            break
    for i in range(1,len(ans)+1):
        T += ans[-i]
    if Ss == T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    Ss = input()
    S = list(Ss)
    now = 0
    T = ''
    Sr = []
    for i in range(1,len(S)+1):
        Sr[-i] = S[i-1]

    while True:
        tmp5 = Sr[now:now+5]
        tmp6 = Sr[now:now+6]
        tmp7 = Sr[now:now+7]
        if tmp5[0] == 'e' and tmp5 == ['e','s','a','r','e']:
            T += 'erase'
            now += 5
        elif tmp5[0] == 'm' and tmp5 == ['m','a','e','r','d']:
            T += 'dream'
            now += 5
        elif tmp6[0] == 'r' and tmp6 == ['r','e','s','a','r','e']:
            T += 'eraser'
            now += 6
        elif tmp7[0] == 'r' and tmp7 == ['r','e','m','a','e','r','d']:
            T += 'dreamer'
            now += 7
        else:
            print('NO')
            return

        if now >= len(S):
            break
    if Ss == T:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()
Problem p02582 (python)

Fixed submission:
S=input()
ans=0
temp=0
for i in range(3):
    if S[i]=="R":
        temp+=1
    else:
        if ans<temp:
            ans=temp
        temp=0
if ans<temp:
    ans=temp
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
ans=0
temp=0
for i in range(3):
    if S[i]=="R":
        temp+=1
    else:
        ans=temp
        temp=0
print(ans)
S=input()
ans=0
temp=0
for i in range(3):
    if S[i]=="R":
        temp+=1
    else:
        ans=temp
        temp=0
if ans<temp:
    ans=temp
print(ans)
Problem p02606 (python)

Fixed submission:
L,R,D=map(int,input().split())
ans=0
for i in range(L,R+1):
    if i%D==0:
        ans+=1
    else:
        pass

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
import math

for i in range(1,N+1):
    ans=0
    for x in range(1,33):
        x2=x*x
        for y in range(1,x+1):
                    a=-(3*(x2)+3*(y*y)+2*x*y)/4+i
                    if a>0:
                        b=(math.sqrt(a)-(x+y)/2)
                        if b>0 and b%1==0.0:
                            if x==y:
                                ans+=1
                            else:
                                ans+=2

    print(ans)
Problem p02683 (python)

Fixed submission:
N,M,X=map(int,input().split())

li=[]
ans=100000000000000000000000000000000

for j in range(N):
    a=list(map(int,input().split()))
    li.append(a)

for k in range(2**N):
    temp=0
    skill=[0]*M
    k=str(bin(k))
    k=k[2:]
    while len(k)!=N:
        k="0"+k
    for l in range(N):
        if k[l]=="1":
            temp+=li[l][0]
            for m in range(1,M+1):
                skill[m-1]+=li[l][m]
    if min(skill)>=X:
        if ans>temp:
            ans=temp
if ans==100000000000000000000000000000000:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
li=[]
Ans=100001

for i in range(N):
    array=list(map(int,input().split()))
    li.append(array)

for j in range(2**N):
    b=bin(j)
    b=b[2:]
    b="0"*(N-len(b))+b
    
    
    c=0
    x=0
    y=0
    z=0

    for k in range(len(b)):
        if b[k]==str(1):
            c+=li[k][0]
            x+=li[k][1]
            y+=li[k][2]
            z+=li[k][3]
    if x>=X and y>=X and z>=X and Ans>c:
        Ans=c
    else:
        pass

if Ans==100001:
    print("-1")
else:
    print(Ans)

Buggy submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
li=[]
Ans=100001

for i in range(N):
    array=list(map(int,input().split()))
    li.append(array)

for j in range(2**N):
    b=bin(j)
    b=b[2:]
    b="0"*(N-len(b))+b
    
    
    c=0
    x=0
    y=0
    z=0

    for k in range(len(b)):
        if b[k]==str(1):
            c+=li[k][0]
            x+=li[k][1]
            y+=li[k][2]
            z+=li[k][3]
    if x>=X and y>=X and z>=X and Ans>c:
        Ans=c

if Ans==100001:
    print("-1")
else:
    print(Ans)

Buggy submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
li=[]
Ans=100001

for i in range(N):
    array=list(map(int,input().strip().split()))
    li.append(array)

for j in range(2**N):
    b=bin(j)
    b=b[2:]
    b="0"*(N-len(b))+b
    
    
    c=0
    x=0
    y=0
    z=0

    for k in range(len(b)):
        if b[k]==str(1):
            c+=li[k][0]
            x+=li[k][1]
            y+=li[k][2]
            z+=li[k][3]
    if x>=X and y>=X and z>=X and Ans>c:
        Ans=c

if Ans==100001:
    print(-1)
else:
    print(Ans)