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

Fixed submission:
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
L=[]
R=[]
for i in range(m):
  L.append(l[i][0])
  R.append(l[i][1])
print(max(min(R)-max(L)+1,0))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
l=[]
r=[]
for i in range(N):
  a,b=map(int,input().split())
  l.append(a)
  r.append(b)
  
  
ans=min(r)-max(l)+1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
l=[]
r=[]
for i in range(M):
  a,b=map(int,input().split())
  l.append(a)
  r.append(b)
  
  
ans=min(b)-max(a)+1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
l=[]
r=[]
for i in range(N):
  a,b=map(int,input().split())
  l.append(a)
  r.append(b)
  
  
ans=min(b)-max(a)+1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a,b=map(int,input().split())
 
l_=[int(n) for n in range(a,b+1)]
 
for i in range(M-1):
  c,d=map(int,input().split())
  if max(c,d)<= a or min(c,d) => b:
    pass
  else:
    l__=[n for n in range(c,d+1)]
    l_=list(set(l_)&set(l__))
  
  
print(len(l_))
Problem p03043 (python)

Fixed submission:
N, K = map(int, input().split())
cnt = 0
for i in range(1, N+1):
	tmp = i
	x = 0
	while tmp < K:
		tmp *= 2
		x += 1
	cnt += (1 / N) * (0.5 ** x)
print(cnt)

Buggy submission (verdict: Runtime Error):
N,k=map(int,input().split())
ans=0
for i in range(1,N+1):
  cnt=0
  while i < k:
    frag*(1/2)
    cnt+=1
    i*=2
  ans += (1/N)*i*((1/2)**cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
N,k=map(int,input().split())
ans=0
for i in range(1,N+1):
  cnt=0
  while i < k:
    frag*(1/2)
    cnt+=1
    i*=2
  ans += (1/N)*i*(1/2)**cnt
print(ans)
Problem p03068 (python)

Fixed submission:
n = int(input())
s = input()
t = [i for i in s]
k = int(input())
moji = " "
for j in range(len(t)):
  if t[j] != t[k-1]:
    t[j]="*"

for k in t:
  moji+=k
print(moji)

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

t = s.replace(s[k],"*")
    
print(t)
Problem p03071 (python)

Fixed submission:
a,b = map(int,input().split())
 
ans = 0
c = max(a,b)
d = min(a,b)
ans += c
c -= 1
e = max(c,d)
f = min(a,b)
ans += e
 
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())

ans = 0
a = max(a,b)
b = min(a,b)
ans += a
a -= 1
a = max(a,b)
b = min(a,b)
ans += a

print(ans)
Problem p03079 (python)

Fixed submission:
a,b,c = map(int,input().split())
 
if a == b == c:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b c = map(int,input().split())

if a == b == c:
  print("Yes")
else:
  print("No")
Problem p03087 (python)

Fixed submission:
# coding: utf-8
N,Q=map(int,input().split())
S=list(input())
W=[0]*N
W[0]=0

for i in range(1,N):
    if S[i-1]=='A' and S[i]=='C':
        W[i]=W[i-1]+1
    else:
        W[i]=W[i-1]
#print(W)

for i in range(Q):
    l,r=map(int,input().split())
    print(W[r-1]-W[l-1])

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
s = input()
a = []
b = 0
for i in range(Q+1):
  a.append(map(int,input().split())
for j in range(Q+1):
           for k in range(2):
               if "AC" in a[j,k]:
                   b[j] = a[j,k].count("AC")
               else:
                   b[j] = 0
for l in range(len(b)):
           print(b[i])
Problem p03106 (python)

Fixed submission:
import fractions
a,b,K = map(int,input().split())
g = fractions.gcd(a,b)
cnt = 0
ans = 0
for i in range(g,0,-1):
    if g % i == 0:
        cnt += 1
        if cnt == K:
            ans = i
            break
    else:
        pass
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
n = 0
for i in range(min(a,b)):
  if a%i == 0 and b%i == 0:
    n += 1
    if n ==c:
      print(i)
      break
    else:
      pass

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
n = 0
for i in range(min(a,b)):
  if a%i = 0 and b%i =0:
    n += 1
    if n ==c:
      print(i)
      break
    else:
      pass
Problem p03110 (python)

Fixed submission:
N = int(input())
total = 0
for i in range(N):
  a,b = map(str,input().split())
  if b == "JPY":
    total += float(a)
  else:
    total += float(a) * 380000
print(total)

Buggy submission (verdict: Runtime Error):
N = int(input())
total = 0
for i in range(N):
  a,b = map(int(input()))
  if b = "JPY":
    total += a
  else:
    total += a * 380000
print(total)
Problem p03126 (python)

Fixed submission:
N,M = map(int,input().split())
L = [0]*N
for i in range(N):
    L[i] = list(map(int,input().split()))
for i in range(N):
    del L[i][0]
L.sort() #第一要素でソート

ans = 0
for i in range(1,M+1):
    cnt = 0
    for j in range(N):
        if i in L[j]:
            cnt += 1
    if cnt == N:
        ans += 1
    
print(ans)

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

ans = input().split()

for i in range(N):
  b = input().split()
  c = set(ans) & set(b)
  ans = list(c)
  
print(len(ans))
Problem p03210 (python)

Fixed submission:
x = int(input())
if x == 3 or x == 5 or x == 7:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
x = int(input())
if x == 3,5,7
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
x = int(input())
if x = 3,5,7:
  print("YES")
else:
  print("NO")
Problem p03241 (python)

Fixed submission:
# coding: utf-8
import math
N,M=map(int,input().split())
A=[]
for i in range(1,int(math.sqrt(M))+1):
    if M%i==0:
        if M//i>=N:
            A.append(i)
            if i>=N and M//i>i:
                A.append(M//i)

A.sort()

ans=A[-1]

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math
N,M=map(int,input().split())
A=[]
for i in range(1,int(math.sqrt(M))):
    if M%i==0:
        if M//i>=N:
            A.append(i)
            if i>=N and M//i>i:
                A.append(M//i)

A.sort()

print(A[-1])

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math
N,M=map(int,input().split())

for i in range(1,int(math.sqrt(M))):
    if M%i==0:
        if M//i>=N:
            ans=i
            
print(ans)
Problem p03273 (python)

Fixed submission:
# coding: utf-8
import fractions
#N = int(input())

h, w = map(int,input().split())
h_list = []
w_list = []
F = []
for i in range(h):
    l = list(input())
    F.append(l)
    if list(set(l)) == ['.']:
        w_list.append(i)
        
for i in range(w):
    cnt = 0
    for j in range(h):
        if F[j][i] == '.':
            cnt += 1
        else:
            break
    if cnt == h:
        h_list.append(i)
A = []
#print(h_list,w_list)#ここまでOK
for i in range(h):
    if i not in w_list:
        l = []
        for j in range(w):
            if j not in h_list:
                #print(F[i][j])
                l.append(F[i][j])
        
        A.append(l)

for i in range(len(A)):
    print(''.join(A[i]))

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

h, w = map(int,input().split())
A = []

for i in range(h):
    l = list(input())
    if list(set(l)) == ['.']:
        h -= 1
    else:
        A.append(l)
#for a in A:
    #print(a)
Ans = []
for i in range(w):
    cnt = 0
    for j in range(h):
        if A[j][i] == '.':
            cnt += 1
    if cnt == h:
        Ans.append(i)

for i in Ans:
    for j in range(h):
        del A[j][i]

for a in A:
    print(''.join(a))
Problem p03311 (python)

Fixed submission:
# coding: utf-8
import math
n = int(input())
#x, y = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
B=  []
for i in range(n):
    B.append(A[i]-(i+1))
B.sort()
if n==1:
    m=B[0]
    m2=B[0]
else:
    m = B[n//2]
    m2=B[n//2+1]
tmp1=0
tmp2=0
#print(m,m2)
for i in range(n):
    tmp1 += abs(A[i]-(i+1)-m)
    tmp2 += abs(A[i]-(i+1)-m2)
print(min(tmp1, tmp2))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math
n = int(input())
#x, y = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
B=  []
for i in range(n):
    B.append(A[i]-(i+1))
B.sort()
m = B[n//2]
m2=B[n//2+1]
tmp1=0
tmp2=0
#print(m,m2)
for i in range(n):
    tmp1 += abs(A[i]-(i+1)-m)
    tmp2 += abs(A[i]-(i+1)-m2)
print(min(tmp1, tmp2))
Problem p03427 (python)

Fixed submission:
N = int(input())

if len(str(N)) == 1:
    ans = N
else:
    s = list(str(N))
    S = s[1:]
    #print(S)
    #print(['9']*((len(str(N)))-1))
    if S == ['9']*((len(str(N)))-1):
        ans = int(str(N)[0]) + 9 * (len(str(N))-1)
        #print('YYY')
    else:
        ans = int(str(N)[0]) + 9 * (len(str(N))-1) - 1

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
N=int(input())
ans=0
n=0
sn=str(N)
w=[int(i) for i in sn]
wa=sum(w)

for i in range(N):
    if 10**i>N:
        n=i
        break
n0=int(str(N)[0])
n1=int(str(N)[1])
if n==1 or n==0:
    print(N)
elif n==2:
    ans=max(wa,9+n0)
    print(ans)
else:
    ans=9*(n-1)
    #print(n0,n1)
    if n1==0:
        ans=ans+n0-1
        print(ans)
    else:
        ans=max(ans,ans-9+n1-1+n0,ans+n0-1)
        print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
N=int(input())
ans=0
for i in range(N):
    if 10**i>N:
        n=i
        break
#print(n)
if n==1:
    print(N)
else:
    ans=9*(n-1)
    n0=int(str(N)[0])
    n1=int(str(N)[1])
    #print(n0,n1)
    if n1==0:
        print(ans)
    else:
        ans=max(ans,ans-9+n1-1+n0,ans+n0-1)
        print(ans)
Problem p03448 (python)

Fixed submission:
# coding: utf-8
# Your code here!
l = []

for i in range(4):
    l.append(int(input()))

x = l[3]
ans = 0
for i in range(l[0]+1):
    for j in range(l[1]+1):
        for k in range(l[2]+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
                
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
a=int(input())
b=int(input())
c=int(input())
X=int(input())
l1=X//a
l2=X//b
l3=X//c
ans=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            #p=a*i+b*j+c*k
            #print(p)
            if 500*i+100*j+50*k==X:
                ans+=1
                
print(ans)
Problem p03543 (python)

Fixed submission:
N =input()
a=int(N[0])
b=int(N[1])
c=int(N[2])
d=int(N[3])
if a==b==c:
  print('Yes')
elif b==c==d:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N =int(input())
a=N[0]
b=N[1]
c=N[2]
d=N[3]
if a==b==c:
  print('Yes')
elif b==c==d:
  print('Yes')
else:
  print('No')
Problem p03544 (python)

Fixed submission:
N= int(input())
L=[0]*(N+1)
L[0]=2
L[1]=1
for i in range(2,N+1):
    
    L[i]=L[i-1]+L[i-2]
    
print(L[N])

Buggy submission (verdict: Runtime Error):
N= int(input())
L=[0]*(N+1)
a=2
b=1
​
for i in range(1,N+1):
    L[0]=2
    L[1]=1
    L[i]=L[i-1]+L[i-2]
    
print(L[N])
Problem p03547 (python)

Fixed submission:
x,y = input().split()
 
X=int(x,16)
Y=int(y,16)
 
if X>Y:
  print(">")
elif X<Y:
  print("<")
else:
  print("=")

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

X=int(x,16)
Y=int(y,16)

if X>Y:
  print(">")
elif X<Y:
  print("<")
else:
  print("=")
Problem p03548 (python)

Fixed submission:
# coding: utf-8
# Your code here!
x,y,z=map(int,input().split())
n=1#最初は一人
while True:
    l=y*n+(n+1)*z
    if l>x:
        break
    else:
        n+=1
        ans=n
ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
x,y,z= map(int,input().split())
 
rem=x-y
 
print(int(rem/(y+z)+1)

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

rem=x-y

print(int(rem/(y+z))
Problem p03578 (python)

Fixed submission:
# coding: utf-8
import collections
n=int(input())
D=list(map(int,input().split()))
m=int(input())
T=list(map(int,input().split()))
T_=list(set(T))
c = collections.Counter(D)
c2 = collections.Counter(T)
flg=True
for t in T_:
    #print(c[t], c2[t])
    if c[t] < c2[t]:
        flg=False
if flg:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
n=int(input())
D=list(map(int,input().split()))
m=int(input())
T=list(map(int,input().split()))
d={}
t={}
for d_ in D:
    if str(d_) in d:
        d[str(d_)]+=1
    else:
        d[str(d_)] = 1
for t_ in T:
    if str(t_) in t:
        t[str(t_)]+=1
    else:
        t[str(t_)] = 1

D_=list(set(D))
T_=list(set(T))
flg=True
#print(T_,D_)
if len(T) > len(D) or len(T_) > len(D_):
    flg=False
if flg:
    for t_ in T_:
        #print(t_)
        #print(t[str(t_)], d[str(t_)])
        if t[str(t_)] <= d[str(t_)]:
            pass
        else:
            flg=False
if flg:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
n=int(input())
D=list(map(int,input().split()))
m=int(input())
T=list(map(int,input().split()))
d={}
t={}
for d_ in D:
    if str(d_) in d:
        d[str(d_)]+=1
    else:
        d[str(d_)] = 1
for t_ in T:
    if str(t_) in t:
        t[str(t_)]+=1
    else:
        t[str(t_)] = 1

D_=list(set(D))
T_=list(set(T))
flg=True
if len(T_) > len(D_):
    flg=False
if flg:
    for t_ in T_:
        #print(t_)
        #print(t[str(t_)], d[str(t_)])
        if t[str(t_)] <= d[str(t_)]:
            pass
        else:
            flg=False
if flg:
    print("YES")
else:
    print("NO")
Problem p03633 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import fractions
from functools import reduce
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
    
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
print(lcm_list(L))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import fractions
N=int(input())
t=int(input())
l=[t]
for i in range(N-1):
    t1=int(input())
    l.append(t1)
    g=fractions.gcd(t,t1)
    t=g
ans=1
for i in range(N):
    ans*=l[i]

ans=ans//g

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import fractions
N=int(input())
t=int(input())
for i in range(N-1):
    t1=int(input())
    g=fractions.gcd(t,t1)
    ans=g*t*t1
    t=g
print(ans)
Problem p03673 (python)

Fixed submission:
# coding: utf-8
n=int(input())
A=list(map(int,input().split()))
B=[0]*n
l=n//2
if n%2==0:
    for i in range(n):
        if i%2==0:
            B[l+i]=str(A[i])
            l=l+i
        else:
            B[l-i]=str(A[i])
            l=l-i
else:
    for i in range(n):
        if i%2==0:
            B[l-i]=str(A[i])
            l=l-i
        else:
            B[l+i]=str(A[i])
            l=l+i
print(' '.join(B))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math
from collections import deque
n = int(input())
#x, y = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
B = deque()
if n%2==0:
    for i in range(n):
        a=str(A[i])
        if i%2==1:
            B.appendleft(a)
        else:
            B.append(a)
if n%2==1:
    for i in range(n):
        if i%2==0:
            B.appendleft(a)
        else:
            B.append(a)
print(' '.join(B))
Problem p03730 (python)

Fixed submission:
# coding: utf-8
a,b,c=map(int,input().split())
Flg=False
for i in range(b+1):
    if a*i%b==c:
        Flg=True
        break
    
if Flg:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
# coding: utf-8
a,b,c=map(int,input().split())
if b%2==0:
    if a%2==0:
        if c%2==0:
            print('YES')
        else:
            print('NO')
    else:
        if c%2==0:
            print('NO')
        else:
            print('YES')
else:
    pirnt('YES')
Problem p03738 (python)

Fixed submission:
# coding: utf-8
a=int(input())
b=int(input())
if a>b:
    print('GREATER')
elif a<b:
    print('LESS')
else:
    print('EQUAL')

Buggy submission (verdict: Runtime Error):
# coding: utf-8
a=int(input())
b=int(input())
la=len(str(a))
lb=len(str(b))

if la>lb:
    print('GREATER')
elif la<lb:
    print('LESS')
else:
    for i in range(la):
        if int(str(a)[i])>int(str(b)[i]):
            print('GREATER')
            Flg=False
            break
        elif int(str(a)[i])<int(str(b)[i]):
            print('LESS')
            Flg=False
            break
    if Flg:
        print('EQUAL')
Problem p02619 (python)

Fixed submission:
# coding: utf-8
# Your code here!

import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

d = I()
contest = LI()
mylist = [LI() for i in range(d)]
day = [0] * 26
result = 0

for i in range(d):
    temp = I()
    result += mylist[i][temp-1]
    day = [j+1 for j in day]
    day[temp-1] = 0
    for k in range(26):
        result -= day[k] * contest[k]
    print(result)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

d = I()
contest = LI()
mylist = [LI() for i in range(26)]
day = [0] * 26
result = 0
for i in range(d):
    temp = I()
    result += mylist[i][temp-1]
    day = [j+1 for j in day]
    day[temp-1] = 0
    for k in range(26):
        result -= day[k] * contest[k]
    print(result)
Problem p02621 (python)

Fixed submission:
n = int(input().rstrip())
print(int(n+n**2+n**3))

Buggy submission (verdict: Runtime Error):
n = input().rstrip()
print(int(n+n**2+n**3))
Problem p02628 (python)

Fixed submission:
#関数リスト
import sys
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n, k = MI()
mylist = LI()
mylist.sort()
print(sum(mylist[0:k]))

Buggy submission (verdict: Runtime Error):
#関数リスト
import sys
import numpy as np
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n, k = MI()
mylist = LI()
mylist.sort()
print(sum(mylist[:k+1]))
Problem p02642 (python)

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n = I()
    mylist = list(MI())
    max_a = max(mylist)
    exclude_set = set()
    tlist = [False] * (max_a+1)
    for a in mylist:
        if tlist[a]:
            exclude_set.add(a)
        else:
            tlist[a] = True
    ans = 0
    
    for i in range(1, max_a//2 + 1):
        if not tlist[i]:
            continue
        else:
            for j in range(2*i, max_a+1, i):
                tlist[j]=False
    for i in range(len(tlist)):
        if tlist[i] and not i in exclude_set:
            ans += 1
    print(ans)
                
    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import collections
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n = I()
    mylist = list(MI())
    max_a = max(mylist)
    exlude_list = set()
    tlist = [False] * (max_a+1)
    for a in mylist:
        if tlist[a]:
            exclude_set.add(a)
        else:
            tlist[a] = True
    ans = 0
    
    for i in range(1, max_a//2 + 1):
        if not tlist[i]:
            continue
        else:
            for j in range(2*i, max_a+1, i):
                tlist[j]=False
    for i in range(len(tlist)):
        if tlist[i] and not i in exclue_set:
            ans += 1
    print(ans)
                
    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import collections
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    n = I()
    mylist = sorted(list(MI()))
    max_num = mylist[n-1] // 2
    start = mylist[0]
    input_list = [0] * n
    index = 0

    while len(mylist) >= 1:
        temp = mylist.pop(0)
        if not(temp in mylist):
            index += 1
        for j in set(mylist):
            if j % temp == 0:
                while j in mylist:
                    mylist.remove(j)
        if mylist[0] > max_num:
            break
    print(index+len(mylist)

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

Fixed submission:
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
def end_of_loop():raise StopIteration
    
    
def main():
    N, M = MI()
    Switch = [LI() for i in range(M)]
    P = LI()
    result = 0
    for i in range(2**N):
        result += 1
        for index, swich in enumerate(Switch):
            if swich[0] == 0:
                continue
            temp = 0
            for j in range(swich[0]):
                if i >> (swich[j+1]-1) & 1 == 1:
                    temp += 1
            if temp % 2 != P[index]:
                result-=1
                break
            
    print(result)
                    
                    
            
            
        
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
def end_of_loop():raise StopIteration
    
    
def main():
    N, M = MI()
    Switch = [LI()[1:] for i in range(N)]
    P = LI()
    result = 0
    for i in range(2**N):
        temp = [0]*M
        for j in range(N):
            if i>>j & 1 != 0:
                for k in Switch[j]:
                    temp[k-1] += 1
        result += 1
        for num1, num2 in zip(temp, P):
            if num1 % 2 != num2:
                result -= 1
                break
    print(result)
            
        
if __name__ == "__main__":
    main()
Problem p03475 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import numpy as np

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n = I()
mylist = [list(MI()) for i in range(n-1)]

def main(j):
    time = 0
    for i in range(j,n-1):
        c, s, f = mylist[i]
        if time < s:
            time = s
        if (time - s) % f != 0:
            time += (f - (time - s) % f) #待ち時間を足す
        time += c
    print(time)
    
    
for i in range(n-1):
    main(i)
print(0)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n = I()
mylist = [list(MI()) for i in range(n-1)]

def main(j):
    time = 0
    for i in range(j,n-1):
        c, s, f = mylist[i]
        if time < s:
            time = s
        if (time - s) % f != 0:
            time += (f - (time - s) % f) #待ち時間を足す
        time += c
    print(time)
    
    
for i in range(n-1):
    main(i)
print(0)