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

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
count = 0
for idx,i in enumerate(p):
  if i == idx+1:
    try:
      p[idx],p[idx+1] = p[idx+1],i
      count += 1
    except:
      count += 1
    
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
count = 0
for idx,i in enumerate(p):
  if i == idx+1:
    p[idx],p[idx+1] = p[idx+1],i
    count += 1
    
print(count)
Problem p03068 (python)

Fixed submission:
n = int(input())
s = str(input())
k = int(input())-1

c = s[k]

out = ""

for i in s:
    if i == c:
        out += i
    else:
        out += "*"

print(out)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())
k = int(input())-1

c = s[k]

out = ""

for i in s:
    if i == c:
        out += i
    else:
        out += "*"

print(out

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())
k = int(input())

c = s[k]

out = ""

for i in s:
    if i == c:
        out += i
    else:
        out += "*"

print(out)
Problem p03478 (python)

Fixed submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())

ans = 0

for x in range(N+1):
    sum = 0
    xx = x
    while xx != 0:
        sum += xx % 10
        xx = xx / 10

    if A <= sum and B >= sum:
        ans += x

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
A = int(raw_input())
B = int(raw_input())

ans = 0

for x in range(N+1):
    sum = 0
    xx = x
    while xx != 0:
        sum += xx % 10
        xx = xx / 10

    if A <= sum and B >= sum:
        ans += x

print(ans)
Problem p02675 (python)

Fixed submission:
N = input().strip()

if N[-1] in ['2', '4', '5', '7', '9']:
  print('hon')
elif N[-1] in ['0', '1', '6', '8']:
  print('pon')
elif N[-1] == '3':
  print('bon')

Buggy submission (verdict: Runtime Error):
N = input(),strip()

if N[-1] in ['2', '4', '5', '7', '9']:
  print('hon')
elif N[-1] in ['0', '1', '6', '8']:
  print('pon')
elif N[-1] == '3':
  print('bon')

Buggy submission (verdict: Runtime Error):

N = input(),strip()

if N[len(N)] in ['2', '4', '5', '7', '9']:
  print('hon')
elif N[len(N)] in ['0', '1', '6', '8']:
  print('pon')
elif N[len(N)] in ['3']:
  print('bon')
Problem p02675 (python)

Fixed submission:
#入力を受け取りｎに代入
n=list(input())
#１の位をとってくる

poo=n[-1]

if poo in "24579":
     print("hon")
elif poo in "0168":
    print("pon")
elif poo=="3":
    print("bon")

Buggy submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc168/tasks/abc168_a

while True:
    #入力を受け取りｎに代入
    n=list(input())
    #１の位をとってくる

    poo=n[-1]

    if poo in "24579":
        print("hon")
    elif poo in "0168":
        print("pon")
    elif poo=="3":
        print("bon")

Buggy submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc168/tasks/abc168_a

while True:
    #入力を受け取りｎに代入
    n=list(input())
    #１の位をとってくる

    poo=n[-1]

    if poo in "24579":
        print("hon")
    elif poo in "0168":
        print("pon")
    elif poo=="3":
        print("bon")
Problem p02675 (python)

Fixed submission:
N = int(input())
while N>=100:
    N -= 100
while N>=10:
    N -= 10

if N==3:
    print('bon')
elif N==0 or N==1 or N==6 or N==8:
    print('pon')
else:
    print('hon')

Buggy submission (verdict: Runtime Error):
while True:
    n = input('N = ')
    try:
        n = int(n)
    except ValueError:
        print(n, 'は数値に変換できません。')
        continue
    except:
        print("予期しないエラー")
        exit()
    if (n <=0 or n >999):
        print(n,"は範囲外の数値です。")
        continue

    while n>=100:
        n -= 100
    while n>=10:
        n -= 10

    if n==3:
        print('bon')
    elif n==0 or n==1 or n==6 or n==8:
        print('pon')
    else:
        print('hon')
Problem p02765 (python)

Fixed submission:
x,y = map(int,input().split())	

if x<11:
  r=y+100*(10-x)
else:
  r=y
  
print(r)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())	

if x<10:
  r=y+100(10-x)
else:
  r=y
  
print(r)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())	

if x<11:
  r=y+100(10-x)
else:
  r=y
  
print(r)

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())	

if x<11:
  r=y-100(10-x)
else:
  r=y
  
print(r)
Problem p02675 (python)

Fixed submission:
s = int(input())
n = (s % 10)
 
if n == 3:
	print('bon')
    
if n in {0, 1, 6, 8}:
	print('pon') 
    
if n in {2, 4, 5, 7, 9}:
	print('hon')

Buggy submission (verdict: Runtime Error):
n = int(input())
 
if n == 3:
	print('bon')
elif(n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8"):
     print("pon")
else:
     print("hon")
Problem p02675 (python)

Fixed submission:
n = int(input()) % 10
if n == 3:
  print("bon")
elif n in(0,1,6,8):
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
import math

    a, b, h, m = map(int, input().split())
    h = h * 30 + m/2
    m = m * 6
    degree = abs(h - m)
  
    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(degree))))

Buggy submission (verdict: Runtime Error):
import math

if __name__ =='__main__':
    a, b, h, m = map(int, input().split())
    h = h * 30 + m/2
    m = m * 6
    degree = abs(h - m)
 
    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(degree))))

Buggy submission (verdict: Runtime Error):
n = int(input())
    nStr = str(n)
    number = nStr[len(nStr)-1]
    if number == '3':
        print('bon')
    elif number  == '0'or number=='1'or number =='6'or number =='8':
        print('pon')
    else:
        print('hon')

Buggy submission (verdict: Runtime Error):
 n = int(input())
    nStr = str(n)
    number = nStr[len(nStr)-1]
    if number == '3':
        print('bon')
    elif number  == '0'or number=='1'or number =='6'or number =='8':
        print('pon')
    else:
        print('hon')

Buggy submission (verdict: Runtime Error):
n = int(input())
    nStr = str(n)
    if nStr[len(nStr)-1] == '3':
        print('bon')
    elif nStr[len(nStr)-1]  == {'0','1','6','8'}:
        print('pon')
    else:
        print('hon')

Buggy submission (verdict: Runtime Error):
 n = int(input())
    nStr = str(n)
    print(nStr[len(nStr)-1])
    if nStr[len(nStr)-1] == '3':
        print('bon')
    elif nStr[len(nStr)-1]  == {'0','1','6','8'}:
        print('pon')
    else:
        print('hon')

Buggy submission (verdict: Runtime Error):
n = int(input())
    nStr = str(n)
    if nStr[len(nStr)-1] == 3:
        print('bon')
    elif n == {0,1,6,8}:
        print('pon')
    else:
        print('hon')

Buggy submission (verdict: Runtime Error):
n = int(input())
    nStr = str(n)
    if nStr[len(nStr)-1] == 3:
        print('bon')
    elif n == {0,1,6,8}:
        print('pon')
    else:
        print('hon')
Problem p02677 (python)

Fixed submission:
from math import *
a, b, h, m = map(int, input().split())
h = 30 * h + m / 2
m *= 6
d = (a * sin(radians(h))) - (b * sin(radians(m)))
e = (a * cos(radians(h))) - (b * cos(radians(m)))
print((d * d + e * e)**0.5)

Buggy submission (verdict: Runtime Error):
import math

    a, b, h, m = map(int, input().split())
    h = h * 30 + m/2
    m = m * 6
    degree = abs(h - m)
    if degree > 180:
        degree = 360 - degree
    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(degree))))

Buggy submission (verdict: Runtime Error):
import math

    a, b, h, m = map(int, input().split())
    h = h * 30
    m = m * 6
    degree = abs(h - m)
    if degree > 180:
        degree = 360 - degree
    print(float(math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(degree)))))

Buggy submission (verdict: Runtime Error):
    Hlong = int(input())
    Mlong= int(input())
    h = int(input()) * 30
    m = int(input()) * 6
    degree = abs(h - m)
    if degree > 180:
        degree = 360 - degree
    print(math.sqrt(Hlong*Hlong + Mlong*Mlong - 2*Hlong*Mlong*math.cos(math.radians(degree))))
Problem p02675 (python)

Fixed submission:
n = int(input())%10
if n==0:
    print("pon")
if n==1:
    print("pon")
if n==2:
    print("hon")
if n==3:
    print("bon")
if n==4:
    print("hon")
if n==5:
    print("hon")
if n==6:
    print("pon")
if n==7:
    print("hon")
if n==8:
    print("pon")
if n==9:
    print("hon")

Buggy submission (verdict: Runtime Error):
(base) C:\Users\toshi\AtCorder>python abc.py
2
hon

(base) C:\Users\toshi\AtCorder>
(base) C:\Users\toshi\AtCorder>python abc.py
3
bon

(base) C:\Users\toshi\AtCorder>python abc.py
4
hon

(base) C:\Users\toshi\AtCorder>python abc.py
5
hon

(base) C:\Users\toshi\AtCorder>python abc.py
6
pon

(base) C:\Users\toshi\AtCorder>python abc.py
7
hon

(base) C:\Users\toshi\AtCorder>python abc.py
8
pon

(base) C:\Users\toshi\AtCorder>python abc.py
9
hon

(base) C:\Users\toshi\AtCorder>
Problem p02755 (python)

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

for i in range(1,10100):
    if int(i*0.08)==A and int(i*0.1)==B:
        print(i)
        break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
for i in range(1,10100):
    if int(i*0.08)==A and int(i*0.1)==B:
        print(i)
        break
else:
    print(-1)
Problem p02921 (python)

Fixed submission:
a = input()
b = input()
score = 0

for i in range(3):
  if a[i] == b[i]:
    score+=1

print(score)

Buggy submission (verdict: Runtime Error):
def main():
  n = int(input())
  print(n * (n-1) // 2)
 

main()
Problem p03087 (python)

Fixed submission:
n,q=map(int,input().split())
s=input()
ac=[0]*(n+1)
for i in range(n):
  ac[i]=ac[i-1]+(s[i:i+2]=="AC")
for i in range(q):
  l,r=map(int,input().split())
  print(ac[r-2]-ac[l-2])

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
ac=[0]*(n-1)
for i in range(1,n-1):
  ac[i]=ac[i-1]+(s[i]=="A" and s[i+1]=="C")
for i in range(q):
  l,r=map(int,input().split())
  print(ac[r-1]-ac[l-1])
Problem p03471 (python)

Fixed submission:
def comb(n,y):
    for i in range(n+1):
        for j in range(n+1-i):
            if 10000*i+5000*j+1000*(n-i-j)==y:
                return [i,j,n-i-j]
    return [-1,-1,-1]

n,y=map(int,input().split())
print("{} {} {}".format(*comb(n,y)))

Buggy submission (verdict: Runtime Error):
def ceil(x,y):
    if x%y==0:
        return x//y
    return x//y+1
n,h=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(reverse=True)
max_a=ab[0][0]
ab.sort(key=lambda x:x[1],reverse=True)
c=0
for i in range(n):
    if ab[i][1]>max_a and ab[i][0]!=max_a:
        c+=1
        h-=ab[i][1]
    if h<=0:
        break
if max_a <ab[0][1] and h>0:
   c+=1
   h-=ab[0][1]
c+=ceil(h,max_a) if h>0 else 0
print(c)
Problem p03606 (python)

Fixed submission:
N=int(input())
sl=[]
for i in range(N):
  sl.append(list(map(int,input().split())))
sl.sort()
sl_table = [True for i in range(len(sl))]

for i in range(N):
  for j in range(min(i+1,N),N):
    if sl[j][0]-sl[i][1]>0:
      break
    sl[i]=[min(min(sl[i]),min(sl[j])),max(max(sl[i]),max(sl[j]))]
    sl_table[j]=False

print(sum((s[1]-s[0]+1)*sl_table[i] for i,s in enumerate(sl)))

Buggy submission (verdict: Runtime Error):
N=int(input())
answer=0
for i in range(N):
  l,r = map(input().split())
  answer+=r-l+1
print(answer)

Buggy submission (verdict: Runtime Error):
N=int(input())
sum=0
seats=[False for i in range(100000)]
for i in range(N):
  l,r=map(int,input.split())
  for j in range(l-1,r-1):
    seats[j]=True
print(sum(seats))
Problem p02714 (python)

Fixed submission:
from collections import Counter
from copy import copy

n = int(input())
s = input()

total_cnt = dict(Counter(s))
if len(total_cnt) < 3:
    print(0)
    exit()

cnt = [total_cnt]
for i, c in enumerate(s):
    curr_cnt = copy(cnt[-1])
    curr_cnt[c] -= 1
    cnt.append(curr_cnt)

res = 0
for i, c1 in enumerate(s):
    for j in range(i + 1, n - 1):
        c2 = s[j]
        if c2 == c1:
            continue
        for c3 in "RGB":
            if c3 == c1 or c3 == c2:
                continue
            res += cnt[j + 1][c3]
            k = 2 * j - i
            if k >= n:
                continue
            if s[k] == c3:
                res -= 1
print(res)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from copy import copy

n = int(input())
s = input()

total_cnt = dict(Counter(s))
cnt = [total_cnt]
for i, c in enumerate(s):
    curr_cnt = copy(cnt[-1])
    curr_cnt[c] -= 1
    cnt.append(curr_cnt)

res = 0
for i, c1 in enumerate(s):
    for j in range(i + 1, n - 1):
        c2 = s[j]
        if c2 == c1:
            continue
        for c3 in "RGB":
            if c3 == c1 or c3 == c2:
                continue
            res += cnt[j + 1][c3]
            k = 2 * j - i
            if k >= n:
                continue
            if s[k] == c3:
                res -= 1
print(res)

Buggy submission (verdict: Runtime Error):
from collections import Counter
from copy import copy

n = int(input())
s = input()

total_cnt = dict(Counter(s))
cnt = [total_cnt]
for i, c in enumerate(s):
    curr_cnt = copy(cnt[-1])
    curr_cnt[c] -= 1
    cnt.append(curr_cnt)

res = 0
for i, c1 in enumerate(s):
    for j in range(i + 1, n - 1):
        c2 = s[j]
        if c2 == c1:
            continue
        for c3 in "RGB":
            if c3 == c1 or c3 == c2:
                continue
            res += cnt[j + 1][c3]
            k = 2 * j - i
            if k >= n:
                continue
            if s[k] == c3:
                res -= 1
print(res)
Problem p02756 (python)

Fixed submission:
s = list(input())
q = int(input())

rev = False
head = []
tail = []

for i in range(q):
    query = input()
    if query == "1":
        rev = not rev
    else:
        _, f, c = query.split()
        if (not rev and f == "1") or (rev and f == "2"):
            head.append(c)
        else:
            tail.append(c)

if not rev:
    res = head[::-1] + s + tail
else:
    res = tail[::-1] + s[::-1] + head

print(*res, sep="")

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())

rev = False
head = []
tail = []

for i in range(q):
    query = input()
    if query == "1":
        rev = not rev
    else:
        _, f, c = query.split()
        if (not rev and f == "1") or (rev and f == "2"):
            head.append(c)
        else:
            tail.append(c)

if not rev:
    print(*head[::-1], s, *tail, sep="")
else:
    print(*tail[::-1], s, *head, sep="")

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())

rev = False
head = []
tail = []

for _ in range(q):
    query = input()
    if query == "1":
        rev = not rev
    else:
        _, f, c = query.split()
        if (not rev and f == "1") or (rev and f == "2"):
            head.append(c)
        else:
            tail.append(c)

if not rev:
    print(*head[::-1], s, *tail, sep="")
else:
    print(*tail[::-1], s, *head, sep="")
Problem p02995 (python)

Fixed submission:
from fractions import gcd


def lcm(x, y):
    return x * y // gcd(x, y)


a, b, c, d = map(int, input().split())

cnt_b = b // c + b // d - b // lcm(c, d)
cnt_a = (a - 1) // c + (a - 1) // d - (a - 1) // lcm(c, d)

print(b - a + 1 - (cnt_b - cnt_a))

Buggy submission (verdict: Runtime Error):
from math import gcd


def lcm(x, y):
    return x * y // gcd(x, y)


a, b, c, d = map(int, input().split())

cnt_b = b // c + b // d - b // lcm(c, d)
cnt_a = (a - 1) // c + (a - 1) // d - (a - 1) // lcm(c, d)

print(b - a + 1 - (cnt_b - cnt_a))
Problem p03014 (python)

Fixed submission:
def main():
    h, w = map(int, input().split())
    grid = [input() for _ in range(h)]
    field = [[0] * w for _ in range(h)]

    for i, row in enumerate(grid):
        row = row + "#"
        cnt = row.count("#")
        idx = -1
        for j in range(cnt + 1):
            idx_next = row.find("#", idx + 1)
            for k in range(idx + 1, idx_next):
                field[i][k] = idx_next - idx - 1
            idx = idx_next

    m = 0
    for i, row in enumerate(zip(*grid)):
        row = "".join(row) + "#"
        cnt = row.count("#")
        idx = -1
        for j in range(cnt + 1):
            idx_next = row.find("#", idx + 1)
            for k in range(idx + 1, idx_next):
                field[k][i] += idx_next - idx - 1
                if field[k][i] > m:
                    m = field[k][i]
            idx = idx_next
    print(m - 1)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np


def main():
    h, w = map(int, input().split())
    grid = [input() for _ in range(h)]
    field = np.array([[0] * w for _ in range(h)])

    for i, row in enumerate(grid):
        row = row + "#"
        cnt = row.count("#")

        idx = -1
        for j in range(cnt + 1):
            idx_next = row.find("#", idx + 1)
            field[i][idx+1:idx_next] = idx_next - idx - 1
            idx = idx_next

    m = 0
    field = field.T
    grid_t = zip(*grid)

    for i, row in enumerate(grid_t):
        row = "".join(row) + "#"
        cnt = row.count("#")

        idx = -1
        for j in range(cnt + 1):
            idx_next = row.find("#", idx + 1)
            field[i][idx+1:idx_next] += idx_next - idx - 1
            idx = idx_next
        if max(field[i]) > m:
            m = max(field[i])

    print(m - 1)


if __name__ == "__main__":
    main()
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

def tree_path():
    # 辺と長さが与えられる
    # 頂点1からの各点の距離を計算する
    # 距離が偶数か奇数かで色分け
    sys.setrecursionlimit(100000)
    n = int(input())
    path = [[] for _ in range(n + 1)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        # 無向グラフ
        path[u].append((v, w))
        path[v].append((u, w))
    # d[0]は使わない
    d = [-1] * (n + 1)

    def walk(i, c):
        if d[i] == -1:
            d[i] = c
            for x, w in path[i]:
                walk(x, c + w)

    walk(1, 0)
    for i in d[1:]:
        print(i % 2)

        
tree_path()

Buggy submission (verdict: Runtime Error):
# 辺と長さが与えられる
# 頂点1からの各点の距離を計算する
sys.setrecursionlimit(100000)
N = int(input())
path = [[] for _ in range(N + 1)]
for _ in range(N - 1):
  u, v, w = map(int, input().split())
  # 無向グラフ
  path[u].append((v, w))
  path[v].append((u, w))
  # d[0]は使わない
  d = [-1] * (N + 1)

  def walk(i, c):
    if d[i] == -1:
      d[i] = c
      for x, w in path[i]:
        walk(x, c + w)

        walk(1, 0)
        for c in d[1:]:
          print(c)

Buggy submission (verdict: Runtime Error):
    sys.setrecursionlimit(100000)
    N = int(input())
    path = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        u, v, w = map(int, input().split())
        # 無向グラフ
        path[u].append((v, w))
        path[v].append((u, w))
    # d[0]は使わない
    d = [-1] * (N + 1)

    def walk(i, c):
        if d[i] == -1:
            d[i] = c
            for x, w in path[i]:
                walk(x, c + w)

    walk(1, 0)
    for c in d[1:]:
        print(c)
Problem p03089 (python)

Fixed submission:
import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        m = len(p)

        for i in range(m-1, -1, -1):
            if p[i] == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])
                break


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)

Buggy submission (verdict: Runtime Error):

import sys
input = sys.stdin.readline

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

from queue import Queue
q = Queue()
ans = Queue()

import numpy as np
n = np.array(n)


def bfs(b):
    q.put(b)
    ans.put([])

    while q.empty() == False:
        p = q.get()
        a = ans.get()

        if p == []:
            break

        if p[0] != 1:
            continue

        for i, pp in enumerate(p):
            if pp == i+1:
                q.put(p[:i]+p[i+1:])
                ans.put(a+[i+1])


    if p == []:
        a = a[::-1]
        for aa in a:
            print(aa)
    else:
        print(-1)


bfs(b)
Problem p03126 (python)

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

S = set(range(1, m + 1))

for i in range(n):
    K, *a = map(int, input().split())
    S = S & set(a)

print(len(S))

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

a = [list(map(int, input().split())) for i in range(n)]

x = [True] * m

for i in a:
    y = i[0]
    xx = [False] * m
    for j in range(y):
        xx[i[j + 1]] = True
    for j in range(m):
        if xx[j] == False:
            x[j] = False

print(sum(x))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
 
S = set(range(1, m+1))
 
for i in range(n):
  K, *a = map(int, input().split())
  S = S & set(A)
 
print(len(S))

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

a = [list(map(int, input().split())) for i in range(n)]

x = [True] * m

for i in a:
    y = i[0]
    xx = [False] * m
    for j in range(y):
        x[i[j + 1]] = True
    for j in range(m):
        if xx[j] == False:
            x[j] = False

print(sum(x))

Buggy submission (verdict: Runtime Error):
n, m = int(input())
a = [list(map(int, input().split())) for i in range(n)]

x = [True] * m

for i in a:
    y = i[0]
    xx = [False] * m
    for j in range(y):
        x[i[j + 1]] = True
    for j in range(m):
        if xx[j] == False:
            x[j] = False

print(sum(x))

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

S = set(range(1, m+1))

for i in range(n):
  K, *a = map(int, input().split())
  S = S & set(A)

print(len(S))

Buggy submission (verdict: Runtime Error):
n, m = int(input())
a = [list(map(int, input().split())) for i in range(n)]

x = [True] * m

for i in a:
  y = i[0]
  xx = [False] * m
  for j in range(y):
    x[i[j+1]] = True
  for j in range(m):
    if xx[j] = False:
      x[j] = False

print(sum(x))
Problem p03128 (python)

Fixed submission:
n, _ = map(int, input().split())
L = list(map(int, input().split()))
weight = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = [-1] * (n+1)
dp[0] = 0

for i in range(n+1):
    for a in L:
        if i+weight[a] < n+1:
            dp[i+weight[a]] = max(dp[i+weight[a]], dp[i]*10+a)

print(dp[n])

Buggy submission (verdict: Runtime Error):

n, _ = map(int,input().split())
a = list(map(int, input().split()))
dic = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
dp = [0] * (n + 1)


def calc(num, new):
    if num == 0:
        return 0
    num_str = str(num)
    new_str = str(new)
    sstr_list = list(str(num)) + list(str(new))
    sstr_list.sort(reverse=True)
    return int("".join(sstr_list))


s = set()
for x in range(2, 8):
    for i in a:
        if x > dic[i]:
            dp[x] = max(dp[x], calc(dp[x - dic[i]], i))
        elif x == dic[i]:
            dp[x] = max(dp[x], i)
    if dp[x]:
        for num in str(dp[x]):
            s.add(int(num))

for x in range(n + 1):
    for i in s:
        if x > dic[i]:
            dp[x] = max(dp[x], calc(dp[x - dic[i]], i))

print(dp[n])

Buggy submission (verdict: Runtime Error):

n, _ = map(int,input().split())
a = list(map(int, input().split()))
dic = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}
dp = [0] * (n + 1)


def calc(num, new):
    if num == 0:
        return 0
    num_str = str(num)
    new_str = str(new)
    sstr_list = list(str(num)) + list(str(new))
    sstr_list.sort(reverse=True)
    return int("".join(sstr_list))


for i in a:
    dp[dic[i]] = max(dp[dic[i]], i)

for x in range(n + 1):
    for i in a:
        if x >= dic[i]:
            dp[x] = max(dp[x], calc(dp[x - dic[i]], i))

print(dp[n])
Problem p03136 (python)

Fixed submission:
import sys

n = int(input())

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

for i in range(n):
    if l[i] >= sum(l) - l[i]:
        print("No")
        sys.exit()

print("Yes")

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

x.sort()

print("Yes" if x[-1] < sum(x[:-1] else "No")