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

Fixed submission:
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
mod=10**9+7
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
mod=10**9+7
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*i)%mod
print(ans)
Problem p03830 (python)

Fixed submission:
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)
Problem p03860 (python)

Fixed submission:
a=list(map(str,input().split()))
print("A"+a[1][0]+"C")

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
print("A"+a[1][0]+"C")
Problem p03943 (python)

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

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
d=max(a,max(b,c))
if 2*d=(a+b+c):
  print("Yes")
else:
  print("No")
Problem p03951 (python)

Fixed submission:
N=int(input())
s=input()
t=input()
for i in range(1,N+1)[::-1]:
  if s[N-i:]==t[:i]:
    print(2*N-i)
    exit()
print(2*N)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
if x==1 or x==2*n-1:print("No")
else:
  print("Yes")
  b=[0]*n
  b[n//2]=x
  b[n//2-1]=x-1
  b[n//2+1]=x+1
  tor=[i+1 for i in range(n)]
  del tor[x-2:x+1]
  for i in range(n):
    if b[i]==0:
      b[i]=tor.pop()
  for i in b:
    print(i)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
if x==1 or x==n:print("No")
else:
  print("Yes")
  b=[0]*n
  b[n//2]=x
  b[n//2-1]=x-1
  b[n//2+1]=x+1
  tor=[i+1 for i in range(n)]
  del tor[x-2:x+1]
  print(tor)
  for i in range(n):
    if b[i]==0:
      b[i]=tor.pop()
  for i in b:
    print(i)
Problem p03993 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[a[i]-1]==i+1:ans+=1
print(ans//2)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[a[i]-1]=i+1:ans+=1
print(ans)
Problem p03997 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
print(((a+b)*c)//2)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
print(((a+b)*h)//2)
Problem p03999 (python)

Fixed submission:
import itertools
s=input()
ans=0
L=len(s)
for sta in itertools.product(range(2),repeat=L-1):  
  cut=[-1]+[i for i in range(L-1) if sta[i]]+[L-1]
  for i in range(len(cut)-1):
    ans+=int(s[cut[i]+1:cut[i+1]+1])
print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
s=input()
ans=0
L=len(s)
for sta in itertools.product(range(2),L):
  cut=[-1]+[i for i in range(L) if sta[i]]+[L-1]
  for i in range(len(cut)-1):
    ans+=int(s[cut[i]+1:cut[i+1]+1])
print(ans)
Problem p04012 (python)

Fixed submission:
from collections import Counter
s=input()
c=Counter(s)
flag=0
a=list(c.values())
for i in range(len(a)):
  if a[i]%2==1:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from collections import Counter
s=input()
c=Counter(s)
flag=0
a=c.values()
for i in range(len(a)):
  if a[i]%2==1:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from collections import Counter
s=input()
c=Counter(s)
flag=0
for i in range(len(c.value)):
  if c.value[i]%2==1:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")
Problem p04019 (python)

Fixed submission:
s=input()
a =["N","S","W","E"]
flag1=0
flag2=0
if a[0] in s and a[1] in s:
  flag1=1
if a[0] not in s and a[1] not in s:
  flag1=1
if a[2] in s and a[3] in s:
  flag2=1
if a[2] not in s and a[3] not in s:
  flag2=1
if flag1+flag2==2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(input()) for i in range(n)]
ans=0
for i in range(n):
  ans+=(l[i]-l[i]%2)//2
  l[i]%=2
  if l[i]==1
    if i==n-1:break
    ans+=1
    l[i]=0;l[i+1]-=1
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
a =["N","S","W","E"]
flag1=0
flag2=0
if a[0] in s and a[1] in s:
  flag1=1
if a[0] not in s and a[1] not in s:
  flag1=1
if a[2] in s and a[3] in s:
  flag2=1
if a[2] not in s and a[3] not in s:
  flag2=1
if flag1+flag2=2:
  print("Yes")
else:
  print("No")
Problem p04020 (python)

Fixed submission:
n=int(input())
ans=0
check=0
for i in range(n):
  s=int(input())
  if i==n-1:
    check+=s
    ans+=check//2
  elif s!=0:
    check+=s
  else:
    ans+=check//2
    check=0
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(input()) for i in range(n)]
ans=0
for i in range(n):
  ans+=(l[i]-l[i]%2)//2
  l[i]%=2
  if l[i]==1
    ans+=1
    l[i]=0;l[i+1]-=1
print(ans)
Problem p04030 (python)

Fixed submission:
s=list(input())
ans=""
l=len(s)
n=0
for i in range(l):
  if s[i]=="0"or s[i]=="1":
    ans+=s[i]
    n+=1
  elif s[i]=="B" and n==0:
    pass
  else:
    ans= ans[:n-1]
    n-=1
print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())
ans=""
l=len(s)
n=0
for i in range(l):
  if s[i]=="0"or s[i]=="1":
    ans+=s[i]
    n+=1
  elif s[i]=="B" and n==0:
    pass
  else:
    ans-=ans[-1]
    n-=1
print(ans)
Problem p04033 (python)

Fixed submission:
a,b=map(int,input().split())
if a*b<=0:
  print('Zero')
else:
  if a>0 and b>0:
    print('Positive')
  elif (b-a)%2==0:
    print('Negative')
  else:
    print('Positive')

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(n-1):
    if i==tiepoint:continue
    print(i+1)
  print(tiepoint+1)
else:print("Impossible")
Problem p04035 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200000)
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(tiepoint):
    print(i+1)
  for i in range(tiepoint+1,n-1)[::-1]:
      print(i+1)
  print(tiepoint+1)
else:print("Impossible")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionimit(200000)
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(tiepoint-1):
    print(i+1)
  for i in range(tiepoint+1,n)[::-1]:
      print(i+1)
  print(tiepoint+1)
else:print("Impossible")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionimit(200000)
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:
  print("Possible")
  for i in range(n-1):
    if i==tiepoint:continue
    print(i+1)
  print(tiepoint+1)
else:print("Impossible")

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
r=list(map(int,input().split()))
last=0;tiepoint=0
for i in range(n-1):
  if r[i]+r[i+1]>last:
    last=r[i]+r[i+1]
    tiepoint=i
if last>=l:print("Possible")
  for i in range(n):
    if i==tiepoint:continue
    print(i)
else:print("Impossible")
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split())
words=[]
for i in range(n):
  words.append(input())
for i in range(l-1,-1,-1):
  words.sort(key=lambda x:ord(x[i]))
ans=""
for i in range(n):
  ans+=words[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
words=[]
for i in range(n):
  words.append(input())
for i in range(n-1,-1,-1):
  words.sort(key=lambda x:ord(x[i]))
ans=""
for i in range(n):
  ans+=words[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
words=[]
for i in range(n):
  words.append(input())
for i in range(n-1,0,-1):
  words.sort(key=lambda x:ord(x[i]))
ans=""
for i in range(n):
  ans+=words[i]
print(ans)
Problem p02585 (python)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**10
for i in range(n):
	loop=[0]
	now=i
	while True:
		now=p[now]-1
		loop.append(loop[-1]+c[now])
		if now==i:
			break
	L=len(loop)-1
	if k<=L:
		score=max(loop[1:k+1])
		ans=max(score,ans)
	else:
		score=max(loop[-1],0)*(k//L-1)
		ans=max(ans,score)
		for j in range(k%L+L):
			score+=loop[j%L+1]-loop[j%L]
			ans=max(score,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=-10**10
for i in range(n):
	K=k
	score=0
	pre_score=0
	visit=[0]*n
	now=i
	cnt=0
	while visit[now]==0:
		cnt+=1
		visit[now]=1
		now=p[now]-1
		pre_score+=c[now]
		if cnt!=1:
			score=max(score,pre_score)
		else:
			score=pre_score
		K-=1
		if K==0:
			break
	ans=max(score,ans)
	if K==0:
		print(2/0)
		continue
	loop=[0]
	NOW=now
	#NOWはループ元
	for j in range(n):
		now=p[now]-1
		loop.append(loop[-1]+c[now])
		if NOW==now:
			break
	pre_score+=max(loop[-1],0)*(K//(len(loop)-1))
	K%=(len(loop)-1)
	pre_score+=max(loop[:K+1])
	score=max(score,pre_score)
	ans=max(ans,score)
print(ans)
Problem p02609 (python)

Fixed submission:
n=int(input())
x=input()
one=x.count("1")
amari_m=0
amari_p=0
for i in range(n):
	if x[-i-1]=="1":
		amari_p+=pow(2,i,one+1)
		if one==1:
			amari_m=-1
		else:
			amari_m+=pow(2,i,one-1)
		amari_p%=one+1
		if one!=1:
			amari_m%=one-1
for i in range(n):
	cnt=0
	if x[i]=="1":
		if one==1:
			print(0)
			continue
		r=(amari_m-pow(2,(n-i-1),one-1))%(one-1)
	else:
		r=(amari_p+pow(2,(n-i-1),one+1))%(one+1)
	while r:
		r%=bin(r).count("1")
		cnt+=1
	print(cnt+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=input()
one=x.count("1")
amari_m=0
amari_p=0
for i in range(n):
	if x[-i-1]=="1":
		amari_p+=pow(2,i,one+1)
		amari_m+=pow(2,i,one-1)
		amari_p%=one+1
		amari_m%=one-1
for i in range(n):
	cnt=0
	if x[i]=="1":
		r=(amari_m-pow(2,(n-i-1),one-1))%(one-1)
	else:
		r=(amari_p+pow(2,(n-i-1),one+1))%(one+1)
	while r:
		r%=bin(r).count("1")
		cnt+=1
	print(cnt+1)
Problem p02618 (python)

Fixed submission:
d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
	r=list(map(int,input().split()))
	s.append(r)
for i in range(d):
	print(i%26+1)

Buggy submission (verdict: Runtime Error):
for i in range(d):
	print(i%26+1)
Problem p02662 (python)

Fixed submission:
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
dp=[[0]*(s+1) for _ in range(n+1)]
dp[0][0]=1
for i in range(n):
	for j in range(s+1):
		dp[i+1][j]+=2*dp[i][j]
		dp[i+1][j]%=mod
		if j+a[i]<=s:
			dp[i+1][j+a[i]]+=dp[i][j]
			dp[i+1][j+a[i]]%=mod
print(dp[n][s])

Buggy submission (verdict: Runtime Error):
def main():
	import sys
	sys.setrecursionlimit=10**7
	mod=998244353
	n,s=map(int,input().split())
	a=list(map(int,input().split()))
	from functools import lru_cache
	@lru_cache(maxsize=None)
	def dfs(x,y):
		if x==0:
			if y==0:
				return 1
			else:
				return 0
		r=dfs(x-1,y)*2%mod
		if y>0:
			if y-a[x-1]>=0:
				r+=dfs(x-1,y-a[x-1])
		r%=mod
		return r
	print(dfs(n,s))
main()

Buggy submission (verdict: Runtime Error):
def main():
	import sys
	sys.setrecursionlimit=10**6
	mod=998244353
	n,s=map(int,input().split())
	a=list(map(int,input().split()))
	from functools import lru_cache
	@lru_cache(maxsize=None)
	def dfs(x,y):
		if x==0:
			if y==0:
				return 1
			else:
				return 0
		r=dfs(x-1,y)*2%mod
		if y>0:
			if y-a[x-1]>=0:
				r+=dfs(x-1,y-a[x-1])
		r%=mod
		return r
	print(dfs(n,s))
main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit=10**8
mod=998244353
n,s=map(int,input().split())
a=list(map(int,input().split()))
ans=0
l=0
from functools import lru_cache
# @lru_cache(maxsize=None)
def dfs(x,y):
	global l
	global ans
	if y==s:
		ans+=pow(2,n-l,mod)
		ans%=mod
		return
	elif y>s or x==n:
		return
	l+=1
	dfs(x+1,y+a[x])
	l-=1
	dfs(x+1,y)
dfs(0,0)
print(ans)
Problem p02665 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if n==0:
	if a[0]==1:
		print(1)
		exit()
	else:
		print(-1)
		exit()
M=[1]
now=2
r=sum(a)
for i in range(n):
	M.append(now)
	now-=a[i+1]
	if now<0:
		print(-1)
		exit()
	elif now<r:
		now*=2
now=a[-1]
for i in range(n):
	M[-i-1]=min(now,M[-i-1])
	now=min(now,M[-i-1])
	now+=a[-i-2]
if a[0]!=0:
	print(-1)
	exit()
for i in range(n+1):
	if M[i]<=0:
		print(-1)
		exit()
print(sum(M))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if n==0:
	if a[0]==1:
		print(2/0)
		exit()
	else:
		while True:
			print(98236874184)
M=[1]
now=2
for i in range(n):
	M.append(now)
	now-=a[i+1]
	if now<=10**29:
		now*=2
now=a[-1]
for i in range(n):
	M[-i-1]=min(now,M[-i-1])
	now=min(now,M[-i-1])
	now+=a[-i-2]
if a[0]!=0:
	print(-1)
	exit()
for i in range(n+1):
	if M[i]<=0:
		print(-1)
		exit()
print(sum(M))
Problem p02814 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
for i in range(n):
	a[i]//=2
from copy import copy
b=copy(a)
c=[]

for i in range(n):
	cnt=0
	while b[i]%2==0:
		cnt+=1
		b[i]//=2
	c.append(cnt)
for i in range(n-1):
	if c[i]!=c[i+1]:
		print(0)
		exit()

a_gcd=a[0]
for i in range(1,n):
	a_gcd=a_gcd*a[i]//gcd(a_gcd,a[i])
print((m+a_gcd)//(a_gcd*2))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
from math import gcd
for i in range(n):
	a[i]//=2
from copy import copy
b=copy(a)
while True:
	i=0
	for i in range(n):
		if b[i]%2==0:
			b[i]//=2
		else:
			break
	if i==0:
		break
	else:
		print(0)
		exit()
a_gcd=a[0]
for i in range(1,n):
	a_gcd=a_gcd*a[i]//gcd(a_gcd,a[i])
print((m+a_gcd)//(a_gcd*2))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
A=a[0]
B=a[0]//2
from math import gcd
for i in range(n):
	A=A*a[i]//gcd(A,a[i])
	B=B*(a[i]//2)//gcd(B,a[i]//2)
	B//=A
m-=B
print(m//A+1)
Problem p02855 (python)

Fixed submission:
p=1
cnt=1
h,w,k=map(int,input().split())
for i in range(h):
	s=input()
	if s.count("#")==1:
		a=[]
		for j in range(w):
			a.append(p)
		p+=1
		for _ in range(cnt):
			print(*a)
		cnt=1
	elif s.count("#")==0:
		cnt+=1
	else:
		a=[]
		itigo=0
		for j in range(w):
			if s[j]=="#" and itigo==True:
				p+=1
				a.append(p)
			elif s[j]=="#":
				itigo=True
				a.append(p)
			else:
				a.append(p)
		for _ in range(cnt):
			print(*a)
		cnt=1
		p+=1
for i in range(cnt-1):
	print(*a)

Buggy submission (verdict: Runtime Error):
p=1
cnt=1
h,w,k=map(int,input().split())
for i in range(h):
	s=input()
	if s.count("#")==1:
		for j in range(w):
			a.append(p)
		p+=1
		for _ in range(cnt):
			print(*a)
		cnt=1
	elif s.count("#")==0:
		cnt+=1
	else:
		a=[]
		itigo=0
		for j in range(w):
			if s[j]=="#" and itigo==True:
				p+=1
				a.append(p)
			elif s[j]=="#":
				itigo=True
				a.append(p)
			else:
				a.append(p)
		for _ in range(cnt):
			print(*a)
		cnt=1
		p+=1
for i in range(cnt-1):
	print(*a)
Problem p02866 (python)

Fixed submission:
from collections import Counter
mod=998244353
n=int(input())
d=list(map(int,input().split()))
q=Counter(d)
if q[0]!=1 or d[0]!=0:
	print(0)
	exit()
ans=1
for i in range(1,max(d)+1):
    ans*=pow(q[i-1],q[i],mod)
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
mod=998244353
d.sort()

if n==1:
	if d[0]==0:
		print(1)
		exit()
	else:
		print(0)
		exit()
elif n==2:
	if d==[0,1]:
		print(1)
		exit()
	else:
		print(0)
		exit()
if d[0]!=0 or d[1]==0:
	print(0)
	exit()
for i in range(n-1):
	if d[i+1]>d[i]+1:
		print(0)
		exit()
p=[]
cnt=1
for i in range(1,n-1):
	if d[i]==d[i+1]:
		cnt+=1
	elif d[i+1]>=d[i]+1:
		p.append(cnt)
		cnt=1
p.append(cnt)
ans=1
for i in range(len(p)-1):
	ans*=p[i]**p[i+1]
	ans%=mod
print(ans,2/0)
Problem p02937 (python)

Fixed submission:
s=input()
t=input()
s*=2
next=[[-1]*26 for _ in range(len(s))]
alph=[[]for _ in range(26)]
for i in range(len(s)):
	alph[ord(s[i])-ord("a")].append(i)
from bisect import bisect_right
for i in range(len(s)//2):
	for j in range(26):
		if len(alph[j])>bisect_right(alph[j],i):
			next[i][j]=alph[j][bisect_right(alph[j],i)]
ans=1
now=len(s)//2-1
for x in t:
	r=ord(x)-ord("a")
	now=next[now][r]
	if now==-1:
		print(-1)
		exit()
	if now>=len(s)//2:
		ans+=len(s)//2
		now-=len(s)//2
print(ans+now-len(s)//2)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
a=[]
import bisect
for i in range(len(s)):
	a.append([ord(s[i]),i])
a.sort()
c=[]
d=[]
for i in range(len(s)):
	c.append(a[i][0])
	d.append(a[i][1])
b=[]
e=[]
for i in range(len(t)):
	if c[0]<=ord(t[i])<=c[-1]:
		b.append(bisect.bisect_left(c,ord(t[i])))
	else:
		print(-1)
		exit()
for i in range(len(t)):
	e.append(d[b[i]])
ans=e[0]+1
cnt=0
for i in range(len(e)-1):
	if e[i]<e[i+1]:
		ans+=e[i+1]-e[i]
		cnt=0
	elif e[i]==e[i+1] and s[i]==s[i+1]:
		ans+=1
	else:
		ans+=len(s)-e[i]+e[i+1]
		cnt=0
print(ans)
Problem p02975 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
p=[]
cnt=[]
zero=0
for i in range(n):
	if len(p)>=4:
		print("No")
		exit()
	if a[i]==0:
		zero+=1
	elif a[i] not in p:
		p.append(a[i])
		cnt.append(1)
	else:
		for j in range(len(p)):
			if a[i]==p[j]:
				cnt[j]+=1
if n%3!=0 and zero!=n:
	print("No")
	exit()
if len(p)>=4:
	print("No")
	exit()
if len(p)==3:
	if cnt[0]==cnt[1]==cnt[2]==n/3:
		if p[0]^p[1]^p[2]==0:
			print("Yes")
			exit()
	else:
		print("No")
		exit()
elif len(p)==1:
	if cnt[0]==n/3*2:
		print("Yes")
		exit()
elif len(p)==0:
	if sum(a)==0:
		print("Yes")
		exit()
print("No")

Buggy submission (verdict: Runtime Error):
=int(input())
a=list(map(int,input().split()))
p=set()
cnt=[]
zero=0
for i in range(n):
	if a[i]==0:
		zero+=1
	elif a[i] not in p:
		p.add(a[i])
		cnt.append(1)
	else:
		for j in range(len(p)):
			if a[i]==p[j]:
				cnt[j]+=1
p=list(p)
if n%3!=0 and zero!=n:
	print("No")
	exit()
if len(p)>=4:
	print("No")
	exit()
if len(p)==3:
	if cnt[0]==cnt[1]==cnt[2]==n/3:
		if p[0]^p[1]^p[2]==0:
			print("Yes")
			exit()
	else:
		print("No")
		exit()
elif len(p)==1:
	if cnt[0]==n/3*2:
		print("Yes")
		exit()
elif len(p)==0:
	if sum(a)==0:
		print("Yes")
		exit()
print("No")
Problem p03000 (python)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
d=0
ans=1
while d<=x and ans<=n:
 d+=l[ans-1]
 if d>x:
  break
 else:
  ans+=1
print(min(ans,n+1))

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
k=0
ans=1
while k<=x:
 k+=l[ans-1]
 if k<=x:
  ans+=1
print(ans)
Problem p03001 (python)

Fixed submission:
w,h,x,y=map(int,input().split())
ans1=w*h/2
if w/2==x and  h/2==y:
 ans2=1
else:
 ans2=0
print(ans1,ans2)

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())
if x!=0 and x!=w and y!=0 and y!=h:
 a=min(w-x,x)
 b=min(y,h-y)
 ans1=max(a*h,b*w)
 if a*h==b*w:
  ans2=1
 else:
  ans2=0
 print(ans1,ans2)
else:
  break
Problem p03005 (python)

Fixed submission:
n,k=map(int,input().split())
if k==1:
 print(0)
else:
 print(n-k)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
minus=sum(a[0:n//2])
plus=sum(a)-minus
print(plus-minus)
if n%2==0:
 s=a[0]
 for i in range(1,n//2):
  print(a[n-i],s)
  s=a[n-i]-s
  print(a[i],s)
  s=a[i]-s
 print(a[n//2],s)
else:
 s=a[n-1]
 for i in range(n//2):
  print(a[i],s)
  s=a[i]-s
  print(a[n-(i+2)],s)
  s=a[n-(i+2)]-s
Problem p03014 (python)

Fixed submission:
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[]
for i in range(h):
	s.append(input().rstrip())
num=[[0]*w for _ in range(h)]
for i in range(h):
	p=0
	for j in range(w):
		if s[i][j]==".":
			p+=1
			num[i][j]+=p
		else:
			p=0
for i in range(h):
	p=0
	for j in range(w-1,-1,-1):
		if s[i][j]==".":
			p+=1
			num[i][j]+=p
		else:
			p=0
for i in range(w):
	p=0
	for j in range(h):
		if s[j][i]==".":
			p+=1
			num[j][i]+=p
		else:
			p=0
for i in range(w):
	p=0
	for j in range(h-1,-1,-1):
		if s[j][i]==".":
			p+=1
			num[j][i]+=p
		else:
			p=0
ans=0
for i in range(h):
	ans=max(ans,max(num[i])-3)
print(ans)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
d=[]
field=[]
fie=[]
for _ in range(h):
	s=input()
	d.append(s)
	cnt=0
	yoko=[]
	for i in range(w):
		if s[i]=="#":
			yoko.append(cnt)
			cnt=0
		else:
			cnt+=1
	if cnt>0:
		yoko.append(cnt)
	yoko.append(0)
	yoko.append(0)
	field.append(yoko)
for i in range(w):
	tate=[]
	cnt=0
	for j in range(h):
		if d[j][i]=="#":
			tate.append(cnt)
			cnt=0
		else:
			cnt+=1
	if cnt>0:
		tate.append(cnt)
	tate.append(0)
	tate.append(0)
	fie.append(tate)
for i in range(h):
	for j in range(len(field[i])-2):
		if field[i][j]>0 and field[i][j+1]>0:
			field[i].insert(j+1,0)
		elif field[i][j]>=0 and field[i][j+1]==0 and field[i][j+2]==0:
			field[i].insert(j+1,0)
for i in range(w):
	for j in range(len(fie[i])-2):
		if fie[i][j]>0 and fie[i][j+1]>0:
			fie[i].insert(j+1,0)
		elif fie[i][j]>=0 and fie[i][j+1]==0 and fie[i][j+2]==0:
			fie[i].insert(j+1,0)
ans=[[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
	k=0
	cn=0
	for j in range(w):
		if field[i][k]==0:
			k+=1
			continue
		else:
			ans[i][j]+=field[i][k]
			cn+=1
		if cn==field[i][k]:
			cn=0
			k+=1
for i in range(w):
	k=0
	cn=0
	for j in range(h):
		if fie[i][k]==0:
			k+=1
			continue
		else:
			ans[j][i]+=fie[i][k]
			cn+=1
		if cn==fie[i][k]:
			cn=0
			k+=1
M=0
for i in range(h):
	for j in range(w):
		M=max(ans[i][j],M)
print(M-1)