Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        ms = []
        for _ in range(n):
            m,l = LI()
            a = [LI() for _ in range(m)]
            b = []
            for s,e in a:
                f = 0
                for i in range(s,e):
                    f |= 2**(i-6)
                b.append(f)
            ms.append((l,b))

        d = collections.defaultdict(int)
        d[0] = 0
        for l,b in ms:
            g = collections.defaultdict(int)
            for k,v in d.items():
                for f in b:
                    if f&k > 0:
                        continue
                    if g[f|k] < v + l:
                        g[f|k] = v + l
            for k,v in g.items():
                if d[k] < v:
                    d[k] = v
        rr.append(max(d.values()))

    return '\n'.join(map(str, rr))


print(main())




Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n = I()
        if n == 0:
            break
        ms = []
        for _ in range(n):
            m,l = LI()
            a = [LI() for _ in range(m)]
            b = 0
            for s,e in a:
                for i in range(s,e):
                    b |= 2**(i-6)
            ms.append((l,b))

        d = collections.defaultdict(int)
        d[0] = 0
        for l,b in ms:
            for k,v in list(d.items()):
                if b&k > 0:
                    continue
                if d[b|k] < v + l:
                    d[b|k] = v + l
        rr.append(max(d.values()))

    return '\n'.join(map(str, rr))


print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    a = LI()
    p = LI()
    fm = {}
    def f(k):
        if k in fm:
            return fm[k]
        g = 1
        for i in range(n):
            if k & (1 << i):
                g *= a[i] // fractions.gcd(g, a[i])
        fm[k] = m // g
        return fm[k]

    r = 0
    for k in range(1,1<<n):
        t = []
        b = 1.0
        for i in range(n):
            if k & (1 << i):
                t.append(1 << i)
                b *= p[i]
            else:
                b *= 100 - p[i]
            b /= 100

        c = 0
        tl = len(t)
        for l in range(1,1<<tl):
            o = 0
            lc = 0
            for j in range(tl):
                if l & (1 << j):
                    o |= t[j]
                    lc += 1
            if lc % 2 == 1:
                c += f(o)
            else:
                c -= f(o)
        r += b * c
    # print(fm)

    return '{:0.8f}'.format(r)


print(main())



Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    a = LI()
    p = [c / 100.0 for c in LI()]
    d = collections.defaultdict(lambda: 1.0)
    e = collections.defaultdict(lambda: 1)

    r = 0
    for k in range(1,1<<n):
        t = [i for i in range(n) if k & (1 << i)]
        l = k & (k-1)
        d[k] = d[l] * p[t[0]]
        e[k] = e[l] * a[t[0]] // fractions.gcd(a[t[0]], e[l])
        o = m // e[k]
        if len(t) % 2 == 1:
            r += o * d[k]
        else:
            r -= o * d[k]


    return '{:0.8f}'.format(r)


print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n,m,k = LI()
    d = LI()
    v = [LI() for _ in range(n)]
    u = set()
    ds = set(d)
    u.add(tuple(d))
    q = [(tuple(d), 1)]
    while q:
        qd, qk = q.pop(0)
        for vi in range(k):
            t = set()
            for di in qd:
                t.add(v[di-1][vi])
            t &= ds
            tt = tuple(t)
            if tt in u:
                continue
            if len(tt) == 0:
                return qk
            u.add(tt)
            q.append((tt,qk+1))

    return -1



print(main())




Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n,m,k = LI()
    d = LI_()
    v = [LI_() for _ in range(n)]
    dd = collections.defaultdict(lambda: None)
    for i in range(m):
        dd[d[i]] = i
    ii = [2**_ for _ in range(m)]
    vv = [[ii[dd[v[c][i]]] if not dd[v[c][i]] is None else 0  for c in d] for i in range(k)]
    m2 = 2**m
    u = [None] * m2
    u[-1] = 1
    q = [m2-1]
    r = 0
    while q:
        r += 1
        nq = []
        for qd in q:
            qdi = [di for di in range(m) if qd & ii[di]]
            for vi in range(k):
                t = 0
                vvi = vv[vi]
                for di in qdi:
                    t |= vvi[di]
                if not u[t] is None:
                    continue
                if t == 0:
                    return r
                u[t] = 1
                nq.append(t)
        q = nq

    return -1



print(main())
Buggy python submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        s = S()
        t = S()
        def f(s):
            return '.*'.join(['']+[c for c in s]+[''])
        if re.match(f(s[0::2]), t) or re.match(f(s[1::2]), t):
            rr.append('Yes')
        else:
            rr.append('No')

        break



    return '\n'.join(map(str, rr))


print(main())




Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        s = S()
        t = S()
        l = len(t)
        def f(s):
            i = 0
            for c in s:
                while i < l and t[i] != c:
                    i += 1
                if i == l:
                    return False
                i += 1
            return True

        if f(s[0::2]) or f(s[1::2]):
            rr.append('Yes')
        else:
            rr.append('No')

        break



    return '\n'.join(map(str, rr))


print(main())
Buggy python submission (verdict: Runtime Error):
hs = []
for i in xrange(11):
    hs.append(int(raw_input()))

hs.sort()

print hs[9]
print hs[8]
print hs[7]

Fixed submission:
hs = []
for i in xrange(10):
    hs.append(int(raw_input()))

hs.sort()

print hs[9]
print hs[8]
print hs[7]
Buggy python submission (verdict: Runtime Error):
timel = int(raw_input())
for gomi in xrange(timel):
 a,b,c = map(lambda x: int(x)**2, raw_input().split())
 if a+b==c or b+c==a or c+a==b:
  print "YES"
 else
  print "NO"

Fixed submission:
timel = int(raw_input())
for gomi in xrange(timel):
 a,b,c = map(lambda x: int(x)**2, raw_input().split())
 if a+b==c or b+c==a or c+a==b:
  print "YES"
 else:
  print "NO"
Buggy python submission (verdict: Runtime Error):
from math import sqrt
cheeze = map(float,raw_input().split())
cheeze.sort()
supk = sqrt((cheeze[0]/2)**2 + (cheeze[1]/2)**2)
while True:
	k = raw_input()
	if k == "0 0 0": break
	else:
		k = int(k)
		if k < supk: print "OK"
		else: print "NA"

Fixed submission:
from math import sqrt

while True:
    inp = raw_input()
    if inp == "0 0 0": break
    cs = map(int,inp.split())
    cs.sort()
    c = sqrt(cs[0]**2 + cs[1]**2)/2

    n=int(raw_input())

    for gomi in xrange(n):
        r = int(raw_input())
        if c<r: print "OK"
        else: print "NA"

Buggy python submission (verdict: Runtime Error):
import sys
from math import sqrt

nyu = sys.stdin.read()
nyu = nyu.split("\n")
cheese = map(float,nyu[0].split())
cheese.sort()
supk = sqrt((cheese[0]/2)**2 + (cheese[1]/2)**2)
nyu = map(int,nyu[2:])
try:
	for k in nyu:
		if k < supk: print "OK"
		else: print "NA"
except:
	pass

Fixed submission:
from math import sqrt

while True:
    inp = raw_input()
    if inp == "0 0 0": break
    cs = map(int,inp.split())
    cs.sort()
    c = sqrt(cs[0]**2 + cs[1]**2)/2

    n=int(raw_input())

    for gomi in xrange(n):
        r = int(raw_input())
        if c<r: print "OK"
        else: print "NA"

Buggy python submission (verdict: Runtime Error):
import sys
from math import sqrt

nyu = sys.stdin.read()
nyu = nyu.split("\n")
cheese = map(float,nyu[0].split())
cheese.sort()
supk = sqrt((cheese[0]/2)**2 + (cheese[1]/2)**2)
nyu = map(int,nyu[2:-1])
try:
	for k in nyu:
		if k < supk: print "OK"
		else: print "NA"
except:
	pass

Fixed submission:
from math import sqrt

while True:
    inp = raw_input()
    if inp == "0 0 0": break
    cs = map(int,inp.split())
    cs.sort()
    c = sqrt(cs[0]**2 + cs[1]**2)/2

    n=int(raw_input())

    for gomi in xrange(n):
        r = int(raw_input())
        if c<r: print "OK"
        else: print "NA"
Buggy python submission (verdict: Runtime Error):
for s in sys.stdin:
	s = map(int, s.split())
	if len(s)==1:
		continue
	else:
		(pm,pe,pj) = tuple(s)
		if 100 in (pm,pe,pj): c = "A"
		elif pm+pe>=180: c = "A"
		elif pm+pe+pj>=240: c = "A"
		elif pm+pe+pj>=240: c = "B"
		elif pm+pe+pj>=150 and (pm>=80 or pe>=80): c = "B"
		else: c = "C"
	print c

Fixed submission:
import sys
for s in sys.stdin:
	s = map(int, s.split())
	if len(s) == 1:
		continue
	else:
		(pm, pe, pj) = tuple(s)
		if 100 in (pm, pe, pj): c = "A"
		elif pm + pe >= 180: c = "A"
		elif pm + pe + pj >= 240: c = "A"
		elif pm + pe + pj >= 210: c = "B"
		elif pm + pe + pj >= 150 and (pm >= 80 or pe >= 80): c = "B"
		else: c = "C"
	print c
Buggy python submission (verdict: Time Limit Exceeded):
def solve(s, t):
    n, m = len(s), len(t)

    ans, dp = 0, [0] * (m + 1)
    for i in xrange(n):
        for j in xrange(m, 0, -1):
            if s[i] == t[j - 1]:
                dp[j] = 1 + dp[j - 1]
            else:
                dp[j] = 0
            ans = max(ans, dp[j])
    return ans

while True:
    try:
        s = raw_input().strip()
        t = raw_input().strip()
    except EOFError:
        break

    print solve(s, t)

Fixed submission:
# coding:utf-8
from __future__ import division, print_function
try:
    input = raw_input
    range = xrange
except NameError:
    pass

p, q = 10 ** 9 + 7, 0xffffffff
pow_p = [1]
for i in range(4010):
    pow_p.append(pow_p[-1] * p & q)


def exists(a, b, k):
    n, m = len(a), len(b)

    s = [a[k + i] - a[i] * pow_p[k] & q for i in range(n - k)]
    t = [b[k + i] - b[i] * pow_p[k] & q for i in range(m - k)]
    return len(set(s).intersection(set(t))) > 0


def hash(s):
    t = 0
    yield t
    for c in s:
        t = t * p + ord(c) & q
        yield t
    return


def solve(s, t):
    n, m = len(s), len(t)
    a, b = list(hash(s)), list(hash(t))

    l, r = 0, min(n, m) + 1
    while l + 1 < r:
        m = (l + r) // 2
        if exists(a, b, m):
            l = m
        else:
            r = m
    return l


while True:
    try:
        s = input().strip()
        t = input().strip()
    except EOFError:
        break

    print(solve(s, t))
Buggy python submission (verdict: Runtime Error):
def calc_inverse_polish_notation_string(s):
    tokens = [token for token in s.split(' ') if token != '']
    stack = []
    for token in tokens:
        if token in ['+', '-', '*', '/']:
            val2 = stack.pop()
            val1 = stack.pop()
            result = eval("%s %s %s" % (val1, token, val2))
            stack.append(result)
        else:
            stack.append(token)

    return stack[0]  # if len(stack) != 1, it should throw an exception


def main():
    for line in sys.stdin.readlines():
        print(calc_inverse_polish_notation_string(line))

if __name__ == "__main__":
    main()

Fixed submission:
import sys


def calc_inverse_polish_notation_string(s):
    tokens = [token for token in s.split(' ') if token != '']
    stack = []
    for token in tokens:
        if token in ['+', '-', '*', '/']:
            val2 = stack.pop()
            val1 = stack.pop()
            result = eval("%s %s %s" % (val1, token, val2))
            stack.append(result)
        else:
            stack.append(token)

    return stack[0]  # if len(stack) != 1, it should throw an exception


def main():
    for line in sys.stdin.readlines():
        print(calc_inverse_polish_notation_string(line.strip()))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys


def main():
    lines = sys.stdin.readlines()
    (_, quantum) = lines[0].split(' ')
    quantum = int(quantum)

    processes = []
    for line in lines[1:]:
        if line.strip() == '':
            break

        (k, v) = line.strip().split(' ')
        processes.append((k, int(v)))

    time = 0
    result = []
    while True:
        (process, process_time) = processes.pop(0)  # Dequeue

        if process_time <= quantum:
            time += process_time
            result.append((process, time))
        else:
            time += quantum
            processes.append((process, process_time - quantum))

        if len(processes) == 0:
            break

    for item in result:
        print("%s %s" % (item[0], item[1]))

if __name__ == "__main__":
    main()

Fixed submission:
import sys


def calc_inverse_polish_notation_string(s):
    tokens = [token for token in s.split(' ') if token != '']
    stack = []
    for token in tokens:
        if token in ['+', '-', '*', '/']:
            val2 = stack.pop()
            val1 = stack.pop()
            result = eval("%s %s %s" % (val1, token, val2))
            stack.append(result)
        else:
            stack.append(token)

    return stack[0]  # if len(stack) != 1, it should throw an exception


def main():
    for line in sys.stdin.readlines():
        print(calc_inverse_polish_notation_string(line.strip()))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys


def search_combination(elements, target):
    if len(elements) == 0:
        if target == 0:
            return True
        else:
            return False

    return search_combination(elements[1:], target - elements[0]) or search_combination(elements[1:], target)

if __name__ == "__main__":
    lines = sys.stdin.readlines()
    elements = [int(x) for x in lines[1].strip().split(" ")]
    targets = [int(x) for x in lines[3].strip().split(" ")]

    for target in targets:
        result = "yes" if search_combination(elements, target) else "no"
        print(result)

Fixed submission:
import sys


def main():
    orders = sys.stdin.readlines()[1:]
    dna_set = set()
    for order in orders:
        command, dna = order.split(" ")
        if command == "insert":
            dna_set.add(dna)
        elif command == "find":
            if dna in dna_set:
                print("yes")
            else:
                print("no")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
score = []
while True:
    line = raw_input()
    if line == "":
        break
    (a, b) = map(int, line.strip().split())
    score.append(a + b)
for i in score:
    print i

Fixed submission:
import sys
score = []
for line in sys.stdin: 
    (a, b) = map(int, line.strip().split())
    score.append(a + b)
for i in score:
    print i
Buggy python submission (verdict: Runtime Error):
S288C_reference_genome_R64-1-1_20110203

Fixed submission:
x = input()
print x * x * x
Buggy python submission (verdict: Time Limit Exceeded):
from __future__ import division
import itertools

def exp(a,b,c,d):
    L=["(%d%c%d)%c(%d%c%d)","%d%c(%d%c(%d%c%d))","((%d%c%d)%c%d)%c%d","%d%c((%d%c%d)%c%\
d)","(%d%c(%d%c%d))%c%d"]
    opr=["+","-","*","/","+","-","*","/","+","-","*","/"]
    for i,j,k,l in itertools.permutations([a,b,c,d]):
        for o1,o2,o3 in itertools.permutations(opr,3):
            for st in L:
                r=st%(i,o1,j,o2,k,o3,l)
                try:
                    t=eval(r)
                    if t==10:
                        return r
                except ZeroDivisionError:
                    pass
    return 0

while True:
    a,b,c,d=map(int,raw_input().split())
    if a==b==c==d==0:break
    print exp(a,b,c,d)

Fixed submission:
from __future__ import division
import itertools

def exp(a,b,c,d):
    L=["((%d%c%d)%c(%d%c%d))","(%d%c(%d%c(%d%c%d)))","((%d%c(%d%c%d))%c%d)","(%d%c((%d%\
c%d)%c%d))","((%d%c(%d%c%d))%c%d)"]
    opr=["+","-","*"]
    for i,j,k,l in itertools.permutations([a,b,c,d]):
        for o1,o2,o3 in itertools.product(opr,repeat=3):
            for st in L:
                r=st%(i,o1,j,o2,k,o3,l)
                try:
                    t=eval(r)
                    if t==10:
                        return r
                except ZeroDivisionError:
                    pass
    return 0

while True:
    a,b,c,d=sorted(map(int,raw_input().split()),reverse=True)
    if a==b==c==d==0:break
    print exp(a,b,c,d)