Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
data=[list(map(int,input().split())) for i in range(m)]
for b,c in data:
	a+=[c]*b
a.sort(reverse=True)
ans=sum(a[:n])
print(ans)


Fixed submission:
import sys
input = lambda: sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a0=list(map(int,input().split()))
data=[list(map(int,input().split())) for i in range(m)]
for i in a0:
	data.append([1,i])
data.sort(key=lambda tup:-tup[1])
ans=0
for num,val in data:
	if n>=num:
		n-=num
		ans+=val*num
	else:
		ans+=val*n
		break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys
input = lambda: sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
data=[list(map(int,input().split())) for i in range(m)]
data.sort(key=lambda tup:-tup[1])
a.sort()
for b,c in data:
	point=bisect.bisect_left(a,c)
	if point<=b:
		a[:point]=[c]*point
	else:
		a[:b]=[c]*b
		a[:point]=a[b:point]+a[:b]
print(sum(a))





Fixed submission:
import sys
input = lambda: sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a0=list(map(int,input().split()))
data=[list(map(int,input().split())) for i in range(m)]
for i in a0:
	data.append([1,i])
data.sort(key=lambda tup:-tup[1])
ans=0
for num,val in data:
	if n>=num:
		n-=num
		ans+=val*num
	else:
		ans+=val*n
		break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
data=[list(map(int,input().split())) for i in range(m)]
a.sort()
for b,c in data:
	point=bisect.bisect_left(a,c)
	if point<=b:
		a[:point]=[c]*point
	else:
		a[:b]=[c]*b
		a[:point]=a[b:point]+a[:b]
print(sum(a))





Fixed submission:
import sys
input = lambda: sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a0=list(map(int,input().split()))
data=[list(map(int,input().split())) for i in range(m)]
for i in a0:
	data.append([1,i])
data.sort(key=lambda tup:-tup[1])
ans=0
for num,val in data:
	if n>=num:
		n-=num
		ans+=val*num
	else:
		ans+=val*n
		break
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
from math import gcd
n=int(input())
a=list(map(int,input().split()))
m=[0]*n
L,R=[0]*(n+1),[0]*(n+1)
for i in range(1,n+1):
    L[i]=gcd(L[i-1],a[i-1])
    R[n-i]=gcd(R[n-i+1],a[n-i])
for i in range(n):
    m[i]=gcd(L[i],R[i+1])
print(max(m))

Fixed submission:
#!/usr/bin/env python3
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
m=[0]*n
L,R=[0]*(n+1),[0]*(n+1)
for i in range(1,n+1):
    L[i]=gcd(L[i-1],a[i-1])
    R[n-i]=gcd(R[n-i+1],a[n-i])
for i in range(n):
    m[i]=gcd(L[i],R[i+1])
print(max(m))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n,q=map(int,input().split())
s=input()
td=[]
for i in range(q):
    td.append(input().split())

#左に集まる中でもっとも右の点を探す
ok1=-1
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==-1:
            break
    if tmp==-1:
        left=mid+1
        ok1=max(ok1,mid)
    else:
        right=mid

#右に集まる中でもっとも左の点を探す

ok2=n
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==n:break
    if tmp == n:
        right=mid
        ok2=min(ok2,mid)
    else:
        left=mid+1

print(max(0,ok2-ok1-1))
# print(ok2,ok1)


Fixed submission:
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

n,q=map(int,input().split())
s=input()
td=[]
for i in range(q):
    td.append(input().split())

#左に集まる中でもっとも右の点を探す
ok1=-1
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==-1 or tmp==n:
            break
    if tmp==-1:
        left=mid+1
        ok1=max(ok1,mid)
    else:
        right=mid

#右に集まる中でもっとも左の点を探す

ok2=n
left=0
right=n
while left<right:
    mid=(left+right)//2
    tmp=mid
    for t,d in td:
        if s[tmp]==t:
            tmp=tmp-1 if d=='L' else tmp+1
        if tmp==n or tmp==-1:break
    if tmp == n:
        right=mid
        ok2=min(ok2,mid)
    else:
        left=mid+1

print(max(0,ok2-ok1-1))
# print(ok2,ok1)
Buggy python submission (verdict: Runtime Error):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
def solve_binary(mid,j):
    return pairs[mid][0] >= j
    pass

def binary_search(n,j):
    ok=n
    ng=0
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if solve_binary(mid,j):
            ok=mid
        else:
            ng=mid
    return ok

n = int(input())
C = [int(input()) for i in range(n)]
pairs = []
data = [-1]*(n+1)
for i,ci in enumerate(C):
  if data[ci] != -1 and abs(i-data[ci]) != 1:
    pairs.append((data[ci],i))
  data[ci] = i
pairs.sort()
l = len(pairs)
for i,j in pairs:
  k = binary_search(l,j)
  # print(k,12345)
  ans += l-k+1
  ans %= mod
print(ans+1)
# print(pairs)






Fixed submission:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
C = [int(input()) for i in range(n)]
pairs = [-1]*(n+1)
data = [-1]*(2*10**5+1)
for i,ci in enumerate(C):
  if data[ci] != -1 and abs(i-data[ci]) != 1:
    pairs[data[ci]] = i
  data[ci] = i
imos = [0] * (n+1)
for i in range(n-1,-1,-1):
  # ペアを持たないとき
  if pairs[i] == -1:
    imos[i] = imos[i+1]
    # print(i,imos[i],imos[i+1])
  else:
    j = pairs[i]
    imos[i] = imos[i+1] + imos[j] + 1
    imos[i] %= mod
  # ans += imos[i] + imos[j]
  # ans %= mod
  # imos[i-1] += imos[i]
print((imos[0]+1)%mod)
# print((ans+1)%mod)
# print(imos)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
a,b,c=[input() for i in range(3)]
for i in range(n):
  ans += len(set(a[i],b[i],c[i])) - 1
print(ans)

Fixed submission:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
a=input()
b=input()
c=input()
def f(a,b,c):
  re=2
  if a==b:
    re-=1
  if c==b:
    re-=1
  if a==c:
    re-=1
  return max(0,re)
for i in range(n):
  count += f(a[i],b[i],c[i])
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = [list(map(int,input().split())) for i in range(n)]
dp = [[0]*(1<<n) for i in range(n+1)]
dp[0][0] = 1
for i in range(n):
  for bit in range(1<<n):
    for k in range(n):
      if not (bit & 1<<k)  and A[i][k]:
        dp[i+1][bit|1<<k] += dp[i][bit]
        dp[i+1][bit|1<<k] %= mod
print(dp[n][(1<<n)-1])
# print(*dp,sep="\n")

Fixed submission:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = [list(map(int,input().split())) for i in range(n)]
dp = [[0]*(1<<n) for i in range(n+1)]
dp[0][0] = 1
for i in range(n):
  for bit in range(1<<n):
    if not dp[i][bit]: continue
    for k in range(n):
      if not (bit & 1<<k)  and A[i][k]:
        dp[i+1][bit|1<<k] += dp[i][bit]
        dp[i+1][bit|1<<k] %= mod
print(dp[n][(1<<n)-1])
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**7)

n,k = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
def calc(A,B):
  res = [[0]*n for i in range(n)]
  for i in range(n):
    for j in range(n):
      for k in range(n):
        res[i][j] += A[i][k] * B[k][j]
      res[i][j] %= mod
  return res


def power(A,k):
  if k == 1:
    return A
  elif k % 2 == 0:
    tmp = power(A,k//2)
    return calc(tmp,tmp)
  elif k % 2 == 1:
    return calc(A,power(A,k-1))

result = power(A,k)
print(sum(map(sum,result))%mod)
    


Fixed submission:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,k = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
def calc(A,B):
  res = [[0]*n for i in range(n)]
  for i in range(n):
    for j in range(n):
      for k in range(n):
        res[i][j] += A[i][k] * B[k][j]
      res[i][j] %= mod
  return res


def power(A,k):
  if k == 1:
    return A
  elif k % 2 == 0:
    tmp = power(A,k//2)
    return calc(tmp,tmp)
  elif k % 2 == 1:
    return calc(A,power(A,k-1))

result = power(A,k)
print(sum(map(sum,result))%mod)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
s=input()
q=int(input())
Q=map(int,input().split())
A=[]
data=[0]*(n+1)
for i,si in enumerate(s):
    if si == "D":
        A.append((i,count))
    elif si == "M":
        count+=1
    elif si == "C":
        for ai,ac in A:
            data[i-ai]+=count-ac
for i in range(len(data)-1):
    data[i+1]+=data[i] 
for qi in Q:
    print(data[qi-1])
# print(data)
          



Fixed submission:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
s=input()
q=int(input())
Q=map(int,input().split())
A=[-1]*(n+1)
C=[-1]*(n+1)
data=[0]*(n+1)
for i,si in enumerate(s):
    if si == "D":
        A[i]=count
    elif si == "M":
        count+=1
    elif si == "C":
        C[i]=count
# for i in range(len(data)-1):
#     data[i+1]+=data[i] 
for k in Q:
    count = ans = 0
    a_num=0
    for i in range(n):
        if A[i]!=-1:
            a_num+=1
            count+=A[i]
        if i-k>=0 and A[i-k]!=-1:
            a_num-=1
            count-=A[i-k]
        if C[i]!=-1:
            ans+=a_num*C[i]-count
    print(ans)
# print(A)
# print(C)
    
# print(data)
Buggy python submission (verdict: Runtime Error):
N,T=map(int,input().split())
ct=[tuple(map(int,input().split())) for i in range(n)]
ans=10**9
for c,t in ct:
    if T<t:
        continue
    else:
        ans=min(ans,c)
print(ans if ans!=10**9 else 'TLE')


Fixed submission:
N,T=map(int,input().split())
ct=[tuple(map(int,input().split())) for i in range(N)]
ans=10**9
for c,t in ct:
    if T<t:
        continue
    else:
        ans=min(ans,c)
print(ans if ans!=10**9 else 'TLE')
Buggy python submission (verdict: Runtime Error):
n=input()
l=[1,9]
for i in n:
    print(l[l.index(i)-1],end='')
print()
    n=input()
l=['1','9']
for i in n:
    print(l[l.index(i)-1], end = '')
print()
    

Fixed submission:
#!/usr/bin/env python3
n=input()
l=['1','9']
for i in n:
    print(l[l.index(i)-1], end = '')
print()

Buggy python submission (verdict: Runtime Error):
n=input()
l=[1,9]
for i in n:
    print(l[l.index(i)-1],end='')
print()
    

Fixed submission:
#!/usr/bin/env python3
n=input()
l=['1','9']
for i in n:
    print(l[l.index(i)-1], end = '')
print()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count1 = count2 = 0

n,k=map(int,input().split())
count1+=n//k
if k%2==0:count2+=(n+k//2)//k
# for ii in itertools.product(range(1,n//k+2), repeat=3):
#     print(ii)
# print(count)
a=len(list(itertools.product(range(count1),repeat=3)))
b=len(list(itertools.product(range(count2),repeat=3)))
print(a+b)


Fixed submission:
ans = count1 = count2 = 0
n,k=map(int,input().split())
count1+=n//k
if k%2==0:count2+=(n+k//2)//k
print(count1**3+count2**3)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count1 = count2 = 0

n,k=map(int,input().split())
count1+=n//k
if k%2==0:count2+=(n+k//2)//k
# for ii in itertools.product(range(1,n//k+2), repeat=3):
#     print(ii)
# print(count)
a=len(list(itertools.product(range(count1),repeat=3)))
b=len(list(itertools.product(range(count2),repeat=3)))
print(a+b)


Fixed submission:
ans = count1 = count2 = 0
n,k=map(int,input().split())
count1+=n//k
if k%2==0:count2+=(n+k//2)//k
print(count1**3+count2**3)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count1 = count2 = 0

n,k=map(int,input().split())
count1+=n//k
if k%2==0:count2+=(n+k//2)//k
# for ii in itertools.product(range(1,n//k+2), repeat=3):
#     print(ii)
# print(count)
a=len(list(itertools.product(range(count1),repeat=3)))
b=len(list(itertools.product(range(count2),repeat=3)))
print(a+b)


Fixed submission:
ans = count1 = count2 = 0
n,k=map(int,input().split())
count1+=n//k
if k%2==0:count2+=(n+k//2)//k
print(count1**3+count2**3)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
S = input()
s1 = S[:n];s2 = S[n:][::-1]
C1 = collections.Counter()
C2 = collections.Counter()
for bit in range(2**n):
  tmp10 = ""
  tmp11 = ""
  tmp20 = ""
  tmp21 = ""
  for i in range(n):
    if bit >> i & 1:
      tmp10 += s1[i]
      tmp20 += s2[i]
    else:
      tmp11 += s1[i]
      tmp21 += s2[i]
  C1[(tmp10,tmp11)] += 1
  C2[(tmp21,tmp20)] += 1
for key,item in C1.items():
  ans += C2[key] * item 
print(ans)


Fixed submission:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
S = input()
s1 = S[:n];s2 = S[n:][::-1]
C1 = collections.Counter()
C2 = collections.Counter()
for bit in range(2**n):
  tmp10 = ""
  tmp11 = ""
  tmp20 = ""
  tmp21 = ""
  for i in range(n):
    if bit >> i & 1:
      tmp10 += s1[i]
      tmp20 += s2[i]
    else:
      tmp11 += s1[i]
      tmp21 += s2[i]
  C1[(tmp10,tmp11)] += 1
  C2[(tmp21,tmp20)] += 1
for key,item in C1.items():
  ans += C2[key] * item 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
S = input()
s1 = S[:n];s2 = S[n:][::-1]
C1 = collections.Counter()
C2 = collections.Counter()
for bit in range(2**n):
  tmp10 = ""
  tmp11 = ""
  tmp20 = ""
  tmp21 = ""
  for i in range(n):
    if bit >> i & 1:
      tmp10 += s1[i]
      tmp20 += s2[i]
    else:
      tmp11 += s1[i]
      tmp21 += s2[i]
  C1[(tmp10,tmp11)] += 1
  C2[(tmp21,tmp20)] += 1
for key,item in C1.items():
  ans += C2[key] * item 
print(ans)


Fixed submission:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
S = input()
s1 = S[:n];s2 = S[n:][::-1]
C1 = collections.Counter()
C2 = collections.Counter()
for bit in range(2**n):
  tmp10 = ""
  tmp11 = ""
  tmp20 = ""
  tmp21 = ""
  for i in range(n):
    if bit >> i & 1:
      tmp10 += s1[i]
      tmp20 += s2[i]
    else:
      tmp11 += s1[i]
      tmp21 += s2[i]
  C1[(tmp10,tmp11)] += 1
  C2[(tmp21,tmp20)] += 1
for key,item in C1.items():
  ans += C2[key] * item 
print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
def ceil(x,y):
  return (x-1)//y+1

n,k = map(int,input().split())
A = list(map(int,input().split()))
for i,ai in enumerate(A):
  if ai == 1:
    ind1 = i
print(ceil(n-1,k-1)))

Fixed submission:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
def ceil(x,y):
  return (x-1)//y+1

n,k = map(int,input().split())
A = list(map(int,input().split()))
for i,ai in enumerate(A):
  if ai == 1:
    ind1 = i
print(ceil(n-1,k-1))
Buggy python submission (verdict: Runtime Error):
s=input()
print("2018"+s[4:]

Fixed submission:
s=input()
print("2018"+s[4:])
Buggy python submission (verdict: Runtime Error):
n,y=map(int,input())
for i in range(n):
  for j in range(i,n):
    k=n-i-j
    if i*10000+j*5000+k*1000==y:
      print(i,j,k)
      exit()
print(-1,-1,-1)


Fixed submission:
n,y=map(int,input().split())
for i in range(n+1):
  for j in range(n+1-i):
    k=n-i-j
    if i*10000+j*5000+k*1000==y:
      print(i,j,k)
      exit()
print(-1,-1,-1)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

n=int(input())
C=[];S=[];F=[]
for i in range(n-1):
    c,s,f=map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)
for start in range(n-1):
    i=start
    time=S[start]
    while i < n-1:
        while time % F[i] != 0 or time<S[i]:
            time += 1
        time += C[i]
        i+=1
    print(time)
print(0)


Fixed submission:
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, string
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
ans = inf ;count = 0 ;pro = 1

n=int(input())
C=[];S=[];F=[]
for i in range(n-1):
    c,s,f=map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)
for start in range(n-1):
    i=start
    time=S[start]
    while i < n-1:
        while time % F[i] != 0 or time<S[i]:
            time += 1
        time += C[i]
        i+=1
    print(time)
print(0)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
ans=0
n,a,b=map(int,input().split())
for i in range(1,n):
    count=0
    for j in str(i):
        count+=j
    if a<=count<=b:
        ans+=1
print(ans)

Fixed submission:
#!/usr/bin/env python3
ans=0
n,a,b=map(int,input().split())
for i in range(1,n+1):
    count=0
    for j in str(i):
        count+=int(j)
    if a<=count<=b:
        ans+=i
print(ans)
Buggy python submission (verdict: Runtime Error):
A="AKIHABARA"
s=input()
n=len(s)
na=len(A)
i=0
j=0
while i<n j<na-1:
  if s[i]==A[j]:
    i+=1; j+=1
  elif s[i]!=A[j] and A[j]=="A":
    j+=1
  else:
    break
if j==n-1:
  print("YES")
else:
  print("NO")

Fixed submission:
A="AKIHABARA"
data=[0,4,6,8]
AD=list(A)
S=set(); S.add(A)
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                tmp=AD.copy()
                # print(AD)
                # print(tmp)
                if i: tmp[0]=""
                if j: tmp[4]=""
                if k: tmp[6]=""
                if l: tmp[8]=""
                S.add(''.join(tmp))


s=input()
if s in S:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
A="AKIHABARA"
s=input()
n=len(s)
na=len(A)
i=0
j=0
while i<=n j<=na-1:
  if s[i]==A[j]:
    i+=1; j+=1
  elif s[i]!=A[j] and A[j]=="A":
    j+=1
  else:
    break
if j==n-1:
  print("YES")
else:
  print("NO")

Fixed submission:
A="AKIHABARA"
data=[0,4,6,8]
AD=list(A)
S=set(); S.add(A)
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                tmp=AD.copy()
                # print(AD)
                # print(tmp)
                if i: tmp[0]=""
                if j: tmp[4]=""
                if k: tmp[6]=""
                if l: tmp[8]=""
                S.add(''.join(tmp))


s=input()
if s in S:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=A+op1+B+op2+C+op3+D
      if eval(ans)==7:
        print('{}=7'.format(ans))
        exit()
      else:
        pass

Fixed submission:
import sys
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=a+op1+b+op2+c+op3+d
      if eval(ans)==7:
        print('{}=7'.format(ans))
        sys.exit()
      else:
        pass

Buggy python submission (verdict: Runtime Error):
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=A+op1+B+op2+C+op3+D
      if eval(ans)==7:
        print('{}=7'.format(ans))
        sys.exit()
      else:
        pass

Fixed submission:
import sys
a,b,c,d=[x for x in input()]
op='+-'
for op1 in op:
  for op2 in op:
    for op3 in op:
      ans=a+op1+b+op2+c+op3+d
      if eval(ans)==7:
        print('{}=7'.format(ans))
        sys.exit()
      else:
        pass
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a+b>=10:
  print('error')
else:
  print(a+b

Fixed submission:
a,b=map(int,input().split())
if a+b>=10:
  print('error')
else:
  print(a+b)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
candidate=[0]*4
if h*w%3==0:
	print(0)
	exit()
def solve(a,b,k):
	candidate[k]=a
	if b%2==0:
		cnd=float('inf')
		for i in range(a//2+1):
			cnd=min(abs(b-3*i),cnd)
		candidate[k+1]=(cnd*a//2,i)
	else:
		cnd=float('inf')
		for i in range(a//2+1):
			cnd=min(cnd,max(abs(a//2*(b-i)-a*i),abs(a//2*(b-i)-a*i+b-i),abs(b-i)))
			candidate[k+1]=(cnd,i)
solve(h,w,0)
solve(w,h,2)
print(min(candidate))





Fixed submission:
h,w=map(int,input().split())
candidate=[0]*4
if h*w%3==0:
	print(0)
	exit()

def solve(a,b,k):
	candidate[k]=a
	cnd=float('inf')
	for i in range(a+1):
		c1=b*i
		c2=(a-i)*(b//2)
		c3=(a-i)*(b-b//2)
		cnd=min(cnd,max(c1,c2,c3)-min(c1,c2,c3))
	candidate[k+1]=cnd

solve(h,w,0)
solve(w,h,2)
print(min(candidate))