Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#editorial
n,q=map(int,input().split())
*qu,=[tuple(map(int, input().split())) for _ in range(q)]
w=n-2;h=n-2
wwh=[n-2]*(n-2)
hhw=[n-2]*(n-2)
b=0
for t,x in qu:
    if t==1:
        x-=2
        b+=wwh[x]
        if x<w:
            for i in range(h):
                hhw[i]=x
            w=x

    else:
        x-=2
        b+=hhw[x]
        if x<h:
            for i in range(w):
                wwh[i]=x
            h=x
    
    ans=(n-2)*(n-2)-b
#    print(wwh)
#    print(hhw)
#    print(h,w)

ans=(n-2)*(n-2)-b
print(ans)
    


Fixed submission:
#editorial
n,q=map(int,input().split())
*qu,=[tuple(map(int, input().split())) for _ in range(q)]
w=n-2;h=n-2
wwh=[n-2]*(n-2)
hhw=[n-2]*(n-2)
b=0
for t,x in qu:
    x-=2
    if t==1:
        
        if x<w:
            b+=h
            for i in range(x,w):
                wwh[i]=h
            w=x
        else:
            b+=wwh[x]

    else:
        if x<h:
            b+=w
            for i in range(x,h):
                hhw[i]=w
            h=x
        else:
            b+=hhw[x]

ans=(n-2)*(n-2)-b
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys,random
from math import gcd
input=sys.stdin.readline
n=int(input())
*a,=map(int, input().split())
random.shuffle(a)
tmp=a[0]
for i in range(1,n):
    tmp=gcd(tmp,a[i])
if tmp>1:
    print('not coprime')
    exit()

# pairwize coprime なら素因数が2度現れることはない

def f(x):
    res=set()
    for i in range(2,int(x**(1/2))+3):
        if x%i==0:
            while x%i==0:
                x//=i
            res.add(i)
    if x>1:
        res.add(x)
    return res,x
tmp=set()
tmp2=set()
for ai in a:
    for p in tmp:
        if ai%p==0:
            print('setwise coprime')
            exit()
    pp,x=f(ai)
    tmp|=pp 
    if x>1 and x in tmp2:
        print('setwise coprime')
        exit()
    tmp2.add(x)
    
        
print('pairwise coprime')



Fixed submission:
import sys,random
from math import gcd
input=sys.stdin.readline
n=int(input())
*a,=map(int, input().split())
random.shuffle(a)
tmp=a[0]
for i in range(1,n):
    tmp=gcd(tmp,a[i])
if tmp>1:
    print('not coprime')
    exit()

# pairwize coprime なら素因数が2度現れることはない

def f(x):
    res=set()
    for i in range(2,int(x**(1/2))+3):
        if x%i==0:
            while x%i==0:
                x//=i
            res.add(i)
    return res,x
tmp=set()
tmp2=set()
for ai in a:
    for p in tmp:
        if ai%p==0:
            print('setwise coprime')
            exit()
    pp,x=f(ai)
    tmp|=pp 
    if x>1 and x in tmp2:
        print('setwise coprime')
        exit()
    tmp2.add(x)
    
        
print('pairwise coprime')

Buggy python submission (verdict: Time Limit Exceeded):
import sys,random
from math import gcd
input=sys.stdin.readline
n=int(input())
*a,=map(int, input().split())
random.shuffle(a)
tmp=a[0]
for i in range(1,n):
    tmp=gcd(tmp,a[i])
if tmp>1:
    print('not coprime')
    exit()

# pairwize coprime なら素因数が2度現れることはない

def f(x):
    res=set()
    for i in range(2,int(x**(1/2))+3):
        if x%i==0:
            while x%i==0:
                x//=i
            res.add(i)
    if x>1:
        res.add(x)
    return res
tmp=set()
for ai in a:
    for p in tmp:
        if ai%p==0:
            print('setwise coprime')
            exit()
    pp=f(ai)
    tmp|=pp 
print('pairwise coprime')



Fixed submission:
import sys,random
from math import gcd
input=sys.stdin.readline
n=int(input())
*a,=map(int, input().split())
random.shuffle(a)
tmp=a[0]
for i in range(1,n):
    tmp=gcd(tmp,a[i])
if tmp>1:
    print('not coprime')
    exit()

# pairwize coprime なら素因数が2度現れることはない

def f(x):
    res=set()
    for i in range(2,int(x**(1/2))+3):
        if x%i==0:
            while x%i==0:
                x//=i
            res.add(i)
    return res,x
tmp=set()
tmp2=set()
for ai in a:
    for p in tmp:
        if ai%p==0:
            print('setwise coprime')
            exit()
    pp,x=f(ai)
    tmp|=pp 
    if x>1 and x in tmp2:
        print('setwise coprime')
        exit()
    tmp2.add(x)
    
        
print('pairwise coprime')
Buggy python submission (verdict: Runtime Error):
d=int(input())
*c,=map(int, input().split())
s=[]
for _ in range(d):
    *si,=map(int, input().split())
    s.append(si)
#t=[int(input())-1 for _ in range(d)]
last=[-1]*26

ss=0
for i in range(d):
    ind=-1
    smx=-10**10
    for j in range(26):
        ssj=ss+s[j][t[j]]
        for j in range(26):
            if k!=j:
                ssj-= c[k]*(i-last[k])
        if smx<ssj:
            smx=max(ss,smx)
            ind=j
    last[ind]=i
    ss=smx        
    print(j)




Fixed submission:
d=int(input())
*c,=map(int, input().split())
s=[]
for _ in range(d):
    *si,=map(int, input().split())
    s.append(si)

for _ in range(d):
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
cnt=np.zeros(n+1,dtype = int)
for i in range(1,n+1):
    cnt[i::i]+=1
ans=cnt*np.arange(n+1)
print(sum(ans))

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1):
    k=n//i
    ans+=i*k*(k+1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
cnt=np.zeros(n+1,dtype = int)
for i in range(1,n+1):
    cnt[i::i]+=1
ans=cnt*np.arrange(n+1)
print(ans)

Fixed submission:
n=int(input())
ans=0
for i in range(1,n+1):
    k=n//i
    ans+=i*k*(k+1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
*a,=map(int, input().split())
x=0
for ai in a:
    x^=ai

ans=[ai^x for ai in ans]
print(*ans)

Fixed submission:
n=int(input())
*a,=map(int, input().split())
x=0
for ai in a:
    x^=ai

a=[ai^x for ai in a]
print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
*a,=map(int, input().split())

if k>100:
    ans=[n]*n
    print(*ans)
    exit()

for _ in range(k):
    pre_cum = [0]*(n+1)
    for i,ai in enumerate(a):
        if i-ai>=0:
            pre_cum[i-ai]+=1
        else:
            pre_cum[0]+=1
        if i+ai<n-1:
            pre_cum[i+ai+1]-=1
        else:
            pre_cum[n]-=1
    a=[]
    tmp=0
    for i in range(n):
        tmp+=pre_cum[i]
        a.append(tmp)

print(*a)


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

if k>100:
    ans=[n]*n
    print(*ans)
    exit()

for _ in range(k):
    pre_cum = [0]*(n+1)
    for i,ai in enumerate(a):
        if i-ai>=0:
            pre_cum[i-ai]+=1
        else:
            pre_cum[0]+=1
        if i+ai<n-1:
            pre_cum[i+ai+1]-=1
        else:
            pre_cum[n]-=1
    a=[]
    tmp=0
    for i in range(n):
        tmp+=pre_cum[i]
        a.append(tmp)

print(*a)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n=int(input())
*p,=map(int, input().split())

for i in range(n*n):p[i]-=1
seats=[
    [min(i,j,n-i-1,n-j-1) for i in range(n)] 
    for j in range(n)
    ]

exist=[[1]*n for _ in range(n)]
dxy=[(0,1),(1,0),(-1,0),(0,-1)]

ans=0
q=deque()
for pi in p:
    ans+=seats[pi//n][pi%n]
    exist[pi//n][pi%n]=0
    q.append((pi//n,pi%n))
    while q:
        i,j=q.popleft()
        for dx,dy in dxy:
            idx=i+dx;jdy=j+dy
            if 0<=idx<n and 0<=jdy<n:
                if seats[i][j]+exist[i][j]<seats[idx][jdy]:
                    seats[idx][jdy]=seats[i][j]+exist[i][j]
                    q.append((idx,jdy))


print(ans)

Fixed submission:
from collections import deque
n=int(input())
*p,=map(int, input().split())

for i in range(n*n):p[i]-=1
seats=[min(i//n,i%n,n-(i//n)-1,n-(i%n)-1) for i in range(n*n)] 

exist=[1]*(n*n)
dxy=(n,-n,1,-1)

ans=0
q=deque()
for pi in p:
    ans+=seats[pi]
    exist[pi]=0
    q.append(pi)
    while q:
        i=q.popleft()
        for dx in dxy:
            idx=i+dx
            if 0<=idx<n*n :
                if seats[i]+exist[i]<seats[idx]:
                    seats[idx]=seats[i]+exist[i]
                    q.append(idx)
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
*p,=map(int, input().split())
#n=3
#p=[1, 3, 7, 9, 5, 4, 8, 6, 2]

for i in range(n*n):p[i]-=1
seats=[
    [min(i,j,n-i-1,n-j-1)for i in range(n)] 
    for j in range(n)
    ]

check=[[False]*n for _ in range(n)]
exist=[[1]*n for _ in range(n)]
dxy=[(0,1),(1,0),(-1,0),(0,-1)]
def dfs(pi):
    global check,exist
    i=pi%n
    j=pi//n
    res=seats[i][j]
    check[i][j]=True
    for dx,dy in dxy:
        idx,jdy=i+dx,j+dy
        if 0<=idx<n and 0<=jdy<n and (not check[idx][jdy]):
            res=min(res,dfs(idx+jdy*n)+exist[idx][jdy])
        if res==0:
            return res
    seats[i][j]=res
    return res
ans=0
for pi in p:
    check=[[False]*n for _ in range(n)]
    ans+=dfs(pi)
    exist[pi%n][pi//n]=0
print(ans)

Fixed submission:
from collections import deque
n=int(input())
*p,=map(int, input().split())

for i in range(n*n):p[i]-=1
seats=[min(i//n,i%n,n-(i//n)-1,n-(i%n)-1) for i in range(n*n)] 

exist=[1]*(n*n)
dxy=(n,-n,1,-1)

ans=0
q=deque()
for pi in p:
    ans+=seats[pi]
    exist[pi]=0
    q.append(pi)
    while q:
        i=q.popleft()
        for dx in dxy:
            idx=i+dx
            if 0<=idx<n*n :
                if seats[i]+exist[i]<seats[idx]:
                    seats[idx]=seats[i]+exist[i]
                    q.append(idx)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int, input().split( ))
mod = 998244353

ans=0
if m==1:##コーナー
  	print(1 if k==n-1 else 0)
    exit()
tmp=m*pow(m-1,n-1,mod)
m_inv=pow(m-1,mod-2,mod)
invs=[0]+[pow(i+1,mod-2,mod) for i in range(n)]
for i in range(1,k+2):
    ans+=tmp
    #print(ans)
    tmp*=m_inv
    if i<n:##?
        tmp*=n-i
        tmp*=invs[i]
    tmp%=mod
print(ans%mod)



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

ans=0
if m==1:##コーナー
  	print(1 if k==n-1 else 0)
  	exit()
tmp=m*pow(m-1,n-1,mod)
m_inv=pow(m-1,mod-2,mod)
invs=[0]+[pow(i+1,mod-2,mod) for i in range(n)]
for i in range(1,k+2):
    ans+=tmp
    #print(ans)
    tmp*=m_inv
    if i<n:##?
        tmp*=n-i
        tmp*=invs[i]
    tmp%=mod
print(ans%mod)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n=int(input())
s=[input().strip("\n") for _ in range(n)]
p=[];m=[]
for si in s:
    cnt=0;a=0;b=0
    for i in range(len(si)):
        if si[i]==")":
            cnt+=1
        else:
            cnt-=1
        a=max(a,cnt)
    cnt=0
    for i in range(len(si)-1,-1,-1):
        if si[i]=="(":
            cnt+=1
        else:
            cnt-=1
        b=max(b,cnt)
    if b-a>=0:
        p.append((a,si))
    else:
        m.append((-b,si))
p.sort();m.sort()
ss=""

for _,si in p:
    ss+=si
for _,si in m:
    ss+=si
cnt=0
for i in range(len(ss)):
    if ss[i]=="(":
        cnt+=1
    else:
        cnt-=1
    if cnt<0:
        print("No")
        exit()
if cnt:
    print("No")
else:
    print("Yes")



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

n=int(input())
s=[input().strip("\n") for _ in range(n)]
p=[];m=[]
for si in s:
    cnt=0;a=0;b=0
    for i in range(len(si)):
        if si[i]==")":
            cnt+=1
        else:
            cnt-=1
        a=max(a,cnt)
    cnt=0
    for i in range(len(si)-1,-1,-1):
        if si[i]=="(":
            cnt+=1
        else:
            cnt-=1
        b=max(b,cnt)
    if b-a>=0:
        p.append((a,si))
    else:
        m.append((-b,si))
p.sort();m.sort()
ss=""

for _,si in p:
    ss+=si
for _,si in m:
    ss+=si
cnt=0
for i in range(len(ss)):
    if ss[i]=="(":
        cnt+=1
    else:
        cnt-=1
    if cnt<0:
        print("No")
        exit()
if cnt:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Time Limit Exceeded):
##解説参照
##b,b-aを判定に使うことが困難
n=int(input())
p=[];m=[]
for _ in range(n):
    s=input()
    cnt=0;a=0;b=0
    for i in range(len(s)):
        if s[i]==")":
            cnt+=1
        else:
            cnt-=1
        a=max(a,cnt)
    cnt=0
    for i in range(len(s)-1,-1,-1):
        if s[i]=="(":
            cnt+=1
        else:
            cnt-=1
        b=max(b,cnt)
    if b-a>=0:
        p.append((a,s))
    else:
        m.append((-b,s))
p.sort();m.sort()
ss=""

for _,s in p:
    ss+=s
for _,s in m:
    ss+=s
cnt=0
for i in range(len(ss)):
    if ss[i]=="(":
        cnt+=1
    else:
        cnt-=1
    if cnt<0:
        print("No")
        exit()
if cnt:
    print("No")
else:
    print("Yes")



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

n=int(input())
s=[input().strip("\n") for _ in range(n)]
p=[];m=[]
for si in s:
    cnt=0;a=0;b=0
    for i in range(len(si)):
        if si[i]==")":
            cnt+=1
        else:
            cnt-=1
        a=max(a,cnt)
    cnt=0
    for i in range(len(si)-1,-1,-1):
        if si[i]=="(":
            cnt+=1
        else:
            cnt-=1
        b=max(b,cnt)
    if b-a>=0:
        p.append((a,si))
    else:
        m.append((-b,si))
p.sort();m.sort()
ss=""

for _,si in p:
    ss+=si
for _,si in m:
    ss+=si
cnt=0
for i in range(len(ss)):
    if ss[i]=="(":
        cnt+=1
    else:
        cnt-=1
    if cnt<0:
        print("No")
        exit()
if cnt:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
#保証されている
#分解するとa<10**3となる

x=int(input())

for b in range(10**3):
    a = int((x+b**5)**(1/5))
    for i in range(a-1,a+2):
        if a**5+b**5==x:
            print(a,-b)
            exit()
for b in range(10**3):
    a = int((x-b**5)**(1/5))
    if a<0:
        continue
    for i in range(a-1,a+2):
        if a**5+b**5==x:
            print(a,b)
            exit()


Fixed submission:
#保証されている
#分解するとa<10**3となる...はずだが

x=int(input())

for b in range(10**3):
    a = int((x+b**5)**(1/5))
    for i in range(a-1000,a+1000):#小さい数でも漏れが出ている
        if i**5+b**5==x:
            print(i,-b)
            exit()
for b in range(10**3):
    a2=(x-b**5)
    if a2<0:
        continue
    a = int(a2**(1/5))
    
    for i in range(a-1000,a+1000):
        if i**5-b**5==x:
            print(i,b)
            exit()
Buggy python submission (verdict: Runtime Error):
#dfs試す
n,m,q=map(int, input().split( ))
qs=tuple(tuple(map(int, input().split( ))) for _ in range(q))
def dfs(ll):
    if len(ll)==n+1:
        sm=0
        for ai,bi,ci,di in qs:
            if ll[bi]-ll[ai]==ci:
                sm+=di 
        return sm
    res=[]
    for i in range(ll[-1]+1,m+1):#+1
        ll2=ll+[i]
        res.append(dfs(ll2))
    return(max(res))
l=[0]
print(dfs(l))


Fixed submission:
#20C10のcombinatrics全探索？
#本番でCでこれ見たら凍るw
#少なくとも combinatrics が組込みでなかったら C問題 じゃないな
n,m,q=map(int, input().split( ))
qs=tuple(tuple(map(int, input().split( ))) for _ in range(q))
import itertools
ans=0
for comb in itertools.combinations(range(1,n+m),n):##+1ない?
    tmp=0
    comb2=[comb[i]-i for i in range(n)]
    for ai,bi,ci,di in qs:
        if comb2[bi-1]-comb2[ai-1]==ci:
            tmp+=di 
    ans=max(ans,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
s=input()
s=s[::-1]
md=[0]
ex10=1
tmp=0
mod=2019
for i in range(len(s)):
    tmp+=ex10*int(s[i])
    tmp%=mod
    md.append(tmp)
    ex10*=10
    ex10%=mod
from collections import Counter

sc= Counter(md)
ans=0
for k in sc:
    sck=sc[k]
    ans+= sck*(sck-1)//2
print(ans)


Fixed submission:

s=input()
s=s[::-1]
md=[0]
ex10=1
tmp=0
mod=2019
for i in range(len(s)):
    tmp+=ex10*int(s[i])
    tmp%=mod
    md.append(tmp)
    ex10*=10
    ex10%=mod
from collections import Counter

sc= Counter(md)
ans=0
for k in sc:
    sck=sc[k]
    ans+= sck*(sck-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
s=s[::-1]
md=[0]
ex10=1
tmp=0
mod=2019
for i in range(len(s)):
    tmp+=ex10*int(s[i])
    tmp%=mod
    md.append(tmp)
    ex10*=10
from collections import Counter

sc= Counter(md)
ans=0
for k in sc:
    sck=sc[k]
    ans+= sck*(sck-1)//2
print(ans)

Fixed submission:

s=input()
s=s[::-1]
md=[0]
ex10=1
tmp=0
mod=2019
for i in range(len(s)):
    tmp+=ex10*int(s[i])
    tmp%=mod
    md.append(tmp)
    ex10*=10
    ex10%=mod
from collections import Counter

sc= Counter(md)
ans=0
for k in sc:
    sck=sc[k]
    ans+= sck*(sck-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
#dpより愚直に作るか
k = int(input())
lun = [i for i in range(10)]
while len(lun)<k:
    lun2 = []
    for i in lun:
        lun2.append(i*10+(i%10))
        if i%10:
            lun2.append(i*10+(i%10)-1)
        if (i%10)<9:
            lun2.append(i*10+(i%10)+1)
    lun = list(set(lun+lun2))
lun.sort()
print(lun[k])

Fixed submission:
#dpより愚直に作るか
k = int(input())
lun = [i for i in range(10)]
while len(lun)<k+1:#正の整数
    lun2 = []
    for i in lun:
        lun2.append(i*10+(i%10))
        if i%10:
            lun2.append(i*10+(i%10)-1)
        if (i%10)<9:
            lun2.append(i*10+(i%10)+1)
    lun = list(set(lun+lun2))
lun.sort()
print(lun[k])

Buggy python submission (verdict: Runtime Error):
#dpより愚直に作るか
k = int(input())
lun = [i for i in range(10)]
last = 10
while len(lun)<k:
    lun2 = []
    for i in lun:
        lun2.append(i*10+(i%10))
        if i%10:
            lun2.append(i*10+(i%10)-1)
        if (i%10)<9:
            lun2.append(i*10+(i%10)+1)
    last = len(lun2)
    lun = list(set(lun+lun2))
lun.sort()
print(lun[k])

Fixed submission:
#dpより愚直に作るか
k = int(input())
lun = [i for i in range(10)]
while len(lun)<k+1:#正の整数
    lun2 = []
    for i in lun:
        lun2.append(i*10+(i%10))
        if i%10:
            lun2.append(i*10+(i%10)-1)
        if (i%10)<9:
            lun2.append(i*10+(i%10)+1)
    lun = list(set(lun+lun2))
lun.sort()
print(lun[k])
Buggy python submission (verdict: Time Limit Exceeded):
n,k,c=map(int,input().split())
s=input()
l=len(s)
cand=[]
for i in range(l):
    if s[i]=='o':
        cand.append(i+1)
        cnt1=[0]*(n+c+2)
        cnt2=[0]*(n+c+2)

for i in range(l):
    if s[i]=='o':
        cnt1[i+1]=max(cnt1[i],cnt1[i-c]+1)
    else:
        cnt1[i+1]=cnt1[i]
for i in range(l-1,-1,-1):
    if s[i]=='o':
        cnt2[i+1]=max(cnt2[i+2],cnt2[i+c+2]+1)
    else:
        cnt2[i+1]=cnt2[i+2]
ans=[]
for i in range(len(cand)):##嘘に見える
    tmp=cand[i]
    if cnt1[tmp-1]+cnt2[tmp+1]<k:
        ans.append(tmp)
for val in ans:
    print(val)


Fixed submission:
n,k,c=map(int,input().split())
s=input()
l=len(s)
cand=[]
for i in range(l):
    if s[i]=='o':
        cand.append(i+1)
cnt1=[0]*(n+c+2)
cnt2=[0]*(n+c+2)        

for i in range(l):
    if s[i]=='o':
        cnt1[i+1]=max(cnt1[i],cnt1[i-c]+1)
    else:
        cnt1[i+1]=cnt1[i]
for i in range(l-1,-1,-1):
    if s[i]=='o':
        cnt2[i+1]=max(cnt2[i+2],cnt2[i+c+2]+1)
    else:
        cnt2[i+1]=cnt2[i+2]
ans=[]
for i in range(len(cand)):##嘘に見える
    tmp=cand[i]
    if cnt1[tmp-1]+cnt2[tmp+1]<k:
        print(tmp)

Buggy python submission (verdict: Time Limit Exceeded):
n,k,c=map(int,input().split())
s=input()
l=len(s)
cand=[]
for i in range(l):
    if s[i]=='o':
        cand.append(i+1)
        cnt1=[0]*(n+c+2)
        cnt2=[0]*(n+c+2)

for i in range(l):
    if s[i]=='o':
        cnt1[i+1]=max(cnt1[i],cnt1[i-c]+1)
    else:
        cnt1[i+1]=cnt1[i]
for i in range(l-1,-1,-1):
    if s[i]=='o':
        cnt2[i+1]=max(cnt2[i+2],cnt2[i+c+2]+1)
    else:
        cnt2[i+1]=cnt2[i+2]
ans=[]
for i in range(len(cand)):##嘘に見える
    tmp=cand[i]
    if cnt1[tmp-1]+cnt2[tmp+1]<k:
        ans.append(tmp)
for val in ans:
    print(val)


Fixed submission:
n,k,c=map(int,input().split())
s=input()
l=len(s)
cand=[]
for i in range(l):
    if s[i]=='o':
        cand.append(i+1)
cnt1=[0]*(n+c+2)
cnt2=[0]*(n+c+2)        

for i in range(l):
    if s[i]=='o':
        cnt1[i+1]=max(cnt1[i],cnt1[i-c]+1)
    else:
        cnt1[i+1]=cnt1[i]
for i in range(l-1,-1,-1):
    if s[i]=='o':
        cnt2[i+1]=max(cnt2[i+2],cnt2[i+c+2]+1)
    else:
        cnt2[i+1]=cnt2[i+2]
ans=[]
for i in range(len(cand)):##嘘に見える
    tmp=cand[i]
    if cnt1[tmp-1]+cnt2[tmp+1]<k:
        print(tmp)
Buggy python submission (verdict: Runtime Error):
#nの約数とn-1の約数全部愚直
n = int(input())
fct1 = []
fct2 = []
for i in range(1,int(n**(1/2))+10):
    if n%i==0:
        fct1.append(i)
        fct2.append(n//i)
    if (n-1)%i==0:
        fct1.append(i)
        fct2.append((n-1)//i)

fct = set(fct1+fct2)
if 1 in fct:
    fct.remove(1)
ans = 0
for k in fct:
    n2 = n
    while n2 and n2%k==0:
        n2//=k
        test += 1
    n2%=k
    if n2==1:
        ans += 1
print(ans)

Fixed submission:
#nの約数とn-1の約数全部愚直
n = int(input())
fct1 = []
fct2 = []
for i in range(1,int(n**(1/2))+10):
    if n%i==0:
        fct1.append(i)
        fct2.append(n//i)
    if (n-1)%i==0:
        fct1.append(i)
        fct2.append((n-1)//i)

fct = set(fct1+fct2)
if 1 in fct:
    fct.remove(1)
ans = 0
for k in fct:
    n2 = n
    while n2 and n2%k==0:
        n2//=k
    n2%=k
    if n2==1:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#端から端まで割る
#h<=10に対しては全探索
#wについては極力割らない

h,w,k = map(int, input().split( ))

s= [list(map(int,list(input()))) for i in range(h)]

bit = 1<<h
ans = 10000
for b in range(bit):
    cut = [0]+[j for j in range(1,h) if (b>>j)&1]+[h]
    tmp = len(cut)-2
    white = [0]*h
    for j in range(w):
        for i in range(h): 
            white[i] += (s[i][j])&1
        for u in range(1,len(cut)):
            tmp2 = 0
            for t in range(cut[u-1],cut[u]):
                tmp2 += white[t]
            if tmp2>k:##
                tmp += 1
                white = [s[x][j] for x in range(h)]##
    if ans > tmp:
        ans = tmp
print(ans)
        












Fixed submission:
    #端から端まで割る
#h<=10に対しては全探索
#wについては極力割らない

h,w,k = map(int, input().split( ))

s= [list(map(int,list(input()))) for i in range(h)]

bit = 1<<h
ans = 10000
for b in range(bit):
    cut = [0]+[j for j in range(1,h) if (b>>j)&1]+[h]
    tmp = len(cut)-2
    white = [0]*h
    for j in range(w):
        for i in range(h): 
            white[i] += (s[i][j])&1
        for u in range(1,len(cut)):
            tmp2 = 0
            for t in range(cut[u-1],cut[u]):
                tmp2 += white[t]
            if tmp2>k and j:##
                tmp += 1
                white = [s[x][j] for x in range(h)]##
            
        for u in range(1,len(cut)):###1列でもアウトな場合
            tmp2 = 0
            for t in range(cut[u-1],cut[u]):
                tmp2 += white[t]
            if tmp2>k and j:##
                tmp = 100000
                white = [s[x][j] for x in range(h)]##
                break##    
    if ans > tmp:
        ans = tmp
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n,s = map(int, input().split( ))

a = np.array(list(map(int, input().split( ))))

dp = np.array([[0]*(s+1) for i in range(n)])
dp[0][0] = 1
dp[0][a[0]] = 1

ans = 0

for i in range(1,n):
    dp[i] += dp[i-1]
    dp[i][a[i]:] += dp[i-1][:-a[i]]
    dp[i][0] +=1
    dp[i][a[i]] += 1
    ans += dp[i][s]
print(ans)

Fixed submission:
import numpy as np
n,s = map(int, input().split( ))

a = np.array(list(map(int, input().split( ))))

dp = np.array([[0]*3001 for i in range(n)])
dp[0][0] = 1
dp[0][a[0]] = 1

ans = 0
mod = 998244353
for i in range(1,n):
    dp[i] += dp[i-1]
    dp[i][a[i]:] += dp[i-1][:-a[i]]
    dp[i][0] +=1
    dp[i][a[i]] += 1
    dp[i]%=mod
    ans += dp[i][s]
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
#editorial参照

#偶奇
import numpy as np
import sys
input = sys.stdin.readline
n=int(input())
a_ = list(map(int, list(input())))
a = np.array(a_)
div2=[1]
cnt=0
ex1 = False

if 1 in a:
    ex1 = True
else:
    a//=2
for i in range(1,n):
    cnt += bin(n-i)[::-1].find('1')
    cnt -= bin(i)[::-1].find('1')
    div2.append(cnt)

div2=np.array(div2)

tmp= (a*div2%2).sum()%2
if tmp:
    if ex1:
        print(1)
    else:
        print(2)

else:
    print(0)


Fixed submission:
#editorial参照

#偶奇
import numpy as np
n=int(input())
a_ = list(map(int, list(input())))
a = np.array(a_)-1###
div2=[0]
cnt=0
ex1 = False

if 1 in a:
    ex1 = True
else:
    a//=2
tst=1
tsts=[1]
for i in range(n-1):
    cnt += bin(n-i-1)[::-1].find('1')
    cnt -= bin(i+1)[::-1].find('1')
    #tst*=n-i-1
    #tst//=i+1
    div2.append(cnt)
    tsts.append(tst)

div2=np.array(div2)###これは2で割れる数のカウント
dv2=1-(div2>0)##これが2で割れるか否か
#print(a)
#print(tsts)
#print(dv2)
tmp= (a*dv2).sum()%2
if tmp:
    if ex1:
        print(1)
    else:
        print(2)

else:
    print(0)