Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
a,b,c=map(int,input().split())
dp=[[a,b,c] for i in range(n)]
for i in range(1,n):
  a,b,c=map(int,input().split()¥
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b
  dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1]))

Fixed submission:
n=int(input())
a,b,c=map(int,input().split())
dp=[[a,b,c] for i in range(n)]
for i in range(1,n):
  a,b,c=map(int,input().split())
  dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b
  dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1]))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(float,input().split()))
dp=[[0]*(n//2+2) for i in range(n)] #dp[i][j]=i番目までに裏がj枚出る確率
dp[0][0]=p[0]
dp[0][1]=1-p[0]
for i in range(1,n):
    dp[i][0]=dp[i-1][0]*p[i]
    for j in range(1,n//2+1):
        dp[i][j]=dp[i-1][j]*p[i]+dp[i-1][j-1]*(1-p[i])
ans=0
for i in range(n//2+1):
    ans+=dp[-1][i]
print(ans)

Fixed submission:
n=int(input())
p=list(map(float,input().split()))
dp=[[0]*(n//2+2) for i in range(n)] #dp[i][j]=i番目までに裏がj枚出る確率
dp[0][0]=p[0]
dp[0][1]=1-p[0]
for i in range(1,n):
    dp[i][0]=dp[i-1][0]*p[i]
    for j in range(1,n//2+1):
        dp[i][j]=dp[i-1][j]*p[i]+dp[i-1][j-1]*(1-p[i])
ans=0
for i in range(n//2+1):
    ans+=dp[-1][i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(float,input().split()))
dp=[[0]*(n+1) for i in range(n)] #dp[i][j]=i番目までに裏がj枚出る確率
dp[0][0]=p[0]
dp[0][1]=1-p[0]
for i in range(1,n):
    dp[i][0]=dp[i-1][0]*p[i]
    for j in range(1,n+1):
        dp[i][j]=dp[i-1][j]*p[i]+dp[i-1][j-1]*(1-p[i])
ans=0
for i in range(n//2+1):
    ans+=dp[-1][i]
print(ans)

Fixed submission:
n=int(input())
p=list(map(float,input().split()))
dp=[[0]*(n//2+2) for i in range(n)] #dp[i][j]=i番目までに裏がj枚出る確率
dp[0][0]=p[0]
dp[0][1]=1-p[0]
for i in range(1,n):
    dp[i][0]=dp[i-1][0]*p[i]
    for j in range(1,n//2+1):
        dp[i][j]=dp[i-1][j]*p[i]+dp[i-1][j-1]*(1-p[i])
ans=0
for i in range(n//2+1):
    ans+=dp[-1][i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# ヒント　dp[i]=(石の個数がi個の時直後の手番の人が勝てるか？)
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(k+1)
for i in range(1,k+1):
    for j in range(n):
        if i-a[j]>=0 and dp[i-a[j]]==0:
            dp[i]=1
print("First" if dp[k] else "Second")

Fixed submission:
# ヒント　dp[i]=(石の個数がi個の時直後の手番の人が勝てるか？)
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[0]*(k+1)
for i in range(1,k+1):
    for j in range(n):
        if i-a[j]>=0 and dp[i-a[j]]==0:
            dp[i]=1
print("First" if dp[k] else "Second")
Buggy python submission (verdict: Time Limit Exceeded):
# dp[i][j]=(区間[i,j]が残っているとき次の手番の得点-そうじゃない人の得点)
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
INF=-10**14
dp=[[-1]*n for i in range(n)]
def memo(i,j):
    if dp[i][j]>=0:
        return dp[i][j]
    if i==j:
        dp[i][j]=a[i]
    else:
        dp[i][j]=max(a[i]-memo(i+1,j),a[j]-memo(i,j-1))
    return dp[i][j]
print(memo(0,n-1))


Fixed submission:
# dp[j][i]=(区間[i,j]が残っているとき次の手番の得点-そうじゃない人の得点)
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
INF=-10**14
dp=[[0]*(i+1) for i in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(1,n):
    for j in range(i-1,-1,-1):
        dp[i][j]=max(a[i]-dp[i-1][j],a[j]-dp[i][j+1])
print(dp[-1][0])

Buggy python submission (verdict: Time Limit Exceeded):
# dp[i][j]=(区間[i,j]が残っているとき次の手番の得点-そうじゃない人の得点)
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
INF=-10**14
dp=[[-1]*n for i in range(n)]
def memo(i,j):
    if dp[i][j]>=0:
        return dp[i][j]
    if i==j:
        dp[i][j]=a[i]
    else:
        dp[i][j]=max(a[i]-memo(i+1,j),a[j]-memo(i,j-1))
    return dp[i][j]
print(memo(0,n-1))

Fixed submission:
# dp[j][i]=(区間[i,j]が残っているとき次の手番の得点-そうじゃない人の得点)
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
INF=-10**14
dp=[[0]*(i+1) for i in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(1,n):
    for j in range(i-1,-1,-1):
        dp[i][j]=max(a[i]-dp[i-1][j],a[j]-dp[i][j+1])
print(dp[-1][0])

Buggy python submission (verdict: Time Limit Exceeded):
# dp[i][j]=(区間[i,j]が残っているとき次の手番の得点-そうじゃない人の得点)
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
INF=-10**14
dp=[[0]*n for i in range(n)]
flag=[[0]*n for i in range(n)]
def memo(i,j):
    if flag[i][j]:
        return dp[i][j]
    flag[i][j]=1
    if i==j:
        dp[i][j]=a[i]
    else:
        dp[i][j]=max(a[i]-memo(i+1,j),a[j]-memo(i,j-1))
    return dp[i][j]
print(memo(0,n-1))

Fixed submission:
# dp[j][i]=(区間[i,j]が残っているとき次の手番の得点-そうじゃない人の得点)
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
INF=-10**14
dp=[[0]*(i+1) for i in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(1,n):
    for j in range(i-1,-1,-1):
        dp[i][j]=max(a[i]-dp[i-1][j],a[j]-dp[i][j+1])
print(dp[-1][0])
Buggy python submission (verdict: Time Limit Exceeded):
# dp[i][j]=(i人目までにj個配る場合の数)
mod=10**9+7
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    dp=[[0]*(k+1) for _ in range(n)]
    for i in range(a[0]+1):
        dp[0][i]=1
    for i in range(1,n):
        dp[i][0]=dp[i-1][0]
        for j in range(1,k+1):
            dp[i][j]=dp[i-1][j]+dp[i][j-1]
            if j-a[i]>0:
                dp[i][j]-=dp[i-1][j-a[i]-1]
            dp[i][j]%=mod
    print(dp[-1][-1])
    # for i in dp:
    #     print(i) 
main()     

Fixed submission:
# dp[i][j]=(i人目までにj個配る場合の数)
mod=10**9+7
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    dp=[[0]*(k+1) for _ in range(n)]
    for i in range(a[0]+1):
        dp[0][i]=1
    for i in range(1,n):
        dp[i][0]=dp[i-1][0]
        for j in range(1,k+1):
            dp[i][j]=dp[i-1][j]+dp[i][j-1]
            if j-a[i]>0:
                dp[i][j]-=dp[i-1][j-a[i]-1]
            dp[i][j]%=mod
    print(dp[-1][-1])
    # for i in dp:
    #     print(i) 
main()
Buggy python submission (verdict: Time Limit Exceeded):
# 大きさがsum(a)のスライムが1匹いる
# dp[l][r]=min(区間[l,r]を分解するための最小コスト)
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline
INF=10**15
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
for i in range(n):
    b[i+1]=b[i]+a[i]
dp=[[-1]*n for i in range(n)]
for i in range(n):
    dp[i][i]=0
def memo(i,j):
    if dp[i][j]>=0:
        return dp[i][j]
    ans=INF
    for k in range(i,j):
        ans=min(ans,memo(i,k)+memo(k+1,j))
    dp[i][j]=ans+b[j+1]-b[i]
    return dp[i][j]
print(memo(0,n-1))

Fixed submission:
# 大きさがsum(a)のスライムが1匹いる
# dp[l][r]=min(区間[l,r]を分解するための最小コスト)
n=int(input())
a=list(map(int,input().split()))
INF=10**15
dp=[[0]*n for i in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(n-1):
    for j in range(i+1,n):
        dp[i][j]=dp[i][j-1]+a[j]

for i in range(n-1):
    for j in range(i+1,n):
        ans=INF
        # print(j-i-1,j)
        for k in range(j-i-1,j):
            ans=min(ans,dp[j-i-1][k]+dp[k+1][j])
        if i<n-2:
            dp[j-i-1][j]+=ans
        else:
            print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# 大きさがsum(a)のスライムが1匹いる
# dp[l][r]=min(区間[l,r]を分解するための最小コスト)
n=int(input())
a=list(map(int,input().split()))
INF=10**15
dp=[[0]*n for i in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(n-1):
    for j in range(i+1,n):
        dp[i][j]=dp[i][j-1]+a[j]

for i in range(n-1):
    for j in range(i+1,n):
        ans=INF
        # print(j-i-1,j)
        for k in range(j-i-1,j):
            ans=min(ans,dp[j-i-1][k]+dp[k+1][j])
        if i<n-2:
            dp[j-i-1][j]+=ans
        else:
            print(ans)

Fixed submission:
# 大きさがsum(a)のスライムが1匹いる
# dp[l][r]=min(区間[l,r]を分解するための最小コスト)
n=int(input())
a=list(map(int,input().split()))
INF=10**15
dp=[[0]*n for i in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(n-1):
    for j in range(i+1,n):
        dp[i][j]=dp[i][j-1]+a[j]

for i in range(n-1):
    for j in range(i+1,n):
        ans=INF
        # print(j-i-1,j)
        for k in range(j-i-1,j):
            ans=min(ans,dp[j-i-1][k]+dp[k+1][j])
        if i<n-2:
            dp[j-i-1][j]+=ans
        else:
            print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#bitDP(集合を数に変換して状態(=添字)として持つようなDPのこと)
# dp[i][S]=(男性はi人目までで、既にペアになった女性の集合がSであるような場合の数)
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
mod=10*9+7
dp=[0]*(1<<n)
dp[0]=1
for i in range(1,1<<n):
    for j in range(n):
        k=bin(i).count("1")
        if i>>j&1 and a[k-1][j]:
            dp[i]=(dp[i]+dp[i^(1<<j)])%mod
print(dp[(1<<n)-1])

Fixed submission:
# bitDP(集合を数に変換して状態(=添字)として持つようなDPのこと)
# dp[i][S]=(男性はi人目までで、既にペアになった女性の集合がSであるような場合の数)
# 「既にペアになった女性の集合がS」なら「bitpopcount(S)人目までをチェックした」ってことになるから、iを状態として持つ必要は無いことがわかる
import sys
input = sys.stdin.readline
mod=10**9+7
def main():
    n=int(input())
    a=[list(map(int,input().split())) for i in range(n)]
    dp=[0]*(1<<n)
    dp[0]=1
    for i in range(1,1<<n):
        k=bin(i).count("1")
        for j in range(n):
            if i>>j&1 and a[k-1][j]:
                dp[i]=(dp[i]+dp[i^(1<<j)])%mod
    print(dp[(1<<n)-1])
main()
Buggy python submission (verdict: Time Limit Exceeded):
# dp[n][i][j]=(頂点iから頂点jへ行く長さnのパスの個数)
# dp[n][i][j]=sum(dp[n-1][i][k]*a[k][j])⇒DP[n]=DP[n-1]*A DP[0]=Eより DP[n]=A^n
n,k=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
dp=[[0]*n for i in range(n)]
mod=10**9+7
for i in range(n):
    for j in range(n):
        dp[i][i]=1
def dot(A,B):
    C=[[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i][j]+=A[i][k]*B[k][j]
            C[i][j]%=mod
    return C
while k:
    if k&1:
        dp=dot(dp,a)
    a=dot(a,a)
    k>>=1
ans=0
for i in dp:
    ans+=sum(i)
print(ans%mod)


Fixed submission:
# dp[n][i][j]=(頂点iから頂点jへ行く長さnのパスの個数)
# dp[n][i][j]=sum(dp[n-1][i][k]*a[k][j])⇒DP[n]=DP[n-1]*A DP[0]=Eより DP[n]=A^n
n,k=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
dp=[[0]*n for i in range(n)]
mod=10**9+7
for i in range(n):
    for j in range(n):
        dp[i][i]=1
def dot(A,B):
    C=[[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i][j]+=A[i][k]*B[k][j]
            C[i][j]%=mod
    return C
while k:
    if k&1:
        dp=dot(dp,a)
    a=dot(a,a)
    k>>=1
ans=0
for i in dp:
    ans+=sum(i)
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
s,d=int(input()),input()
n=[int(i) for i in s]
l=len(s)
mod=10**9+7
dp=[[[0]*d,[0]*d] for i in range(l+1)]
dp[0][0][0]=1
for i in range(l):
    for smaller in range(2):
        for j in range(d):
            for x in range(10 if smaller else n[i]+1):
                dp[i+1][smaller or x<n[i]][(j+x)%d] += dp[i][smaller][j]
                dp[i+1][smaller or x<n[i]][(j+x)%d]%=mod
print((dp[l][0][0]+dp[l][1][0]-1)%mod)

Fixed submission:
s,d=input(),int(input())
n=[int(i) for i in s]
l=len(s)
mod=10**9+7
dp=[[[0]*d,[0]*d] for i in range(l+1)]
dp[0][0][0]=1
for i in range(l):
    for smaller in range(2):
        for j in range(d):
            for x in range(10 if smaller else n[i]+1):
                dp[i+1][smaller or x<n[i]][(j+x)%d] += dp[i][smaller][j]
                dp[i+1][smaller or x<n[i]][(j+x)%d]%=mod
print((dp[l][0][0]+dp[l][1][0]-1)%mod)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
d=[0]*101
def factorization(n):
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i==0:
            while temp%i==0:
                d[i]+=1
                temp //= i
    if temp!=1:
        d[temp]+=1
def cnt(k):
    return len(d[d>=k])
for i in range(2,n+1):
    factorization(i)
d=np.array(list(d.values()))
print(cnt(74)+cnt(24)*(cnt(2)-1)+cnt(14)*(cnt(4)-1)+cnt(4)*(cnt(4)-1)*(cnt(2)-2)//2)

Fixed submission:
from collections import defaultdict
import numpy as np
from itertools import permutations, combinations
n=int(input())
d=defaultdict(int)
def factorization(n):
    temp = n
    for i in range(2, int(n**0.5)+1):
        if temp%i==0:
            while temp%i==0:
                d[i]+=1
                temp //= i

    if temp!=1:
        d[temp]+=1
for i in range(2,n+1):
    factorization(i)
d=np.array(list(d.values()))
ans=0
ans+=len(d[d>=74])
d1=d[d>=2]
d2=d[d>=4]
for x,y in permutations(d1,2):
    if y>=24:
        ans+=1
for x,y in permutations(d2,2):
    if y>=14:
        ans+=1
ans1=0
for x,y,z in permutations(d1,3):
    if y>=4 and z>=4:
        ans1+=1
print(ans+ans1//2)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
d=[]
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    d.append(i,m//i)
d.sort(reverse=True)
for i in d:
  if i*n<=m:
    print(i)
    exit()

Fixed submission:
n,m=map(int,input().split())
d=[]
for i in range(1,int(m**0.5)+1):
  if m%i==0:
    d.append(i)
    d.append(m//i)
d.sort(reverse=True)
for i in d:
  if i*n<=m:
    print(i)
    exit()
Buggy python submission (verdict: Runtime Error):
n,k= map(int, input().split())
x= list(map(int, input().split()))
s=0
cnt=0
while x[s]<0:
    s+=1
a=[]
for i in range(s,min(s+k,n)):
    cnt+=1
    if i-k-1>=0:
        a.append(2*x[i]-x[i-k+1])
    if cnt==k:
        a.append(x[i])
s-=1
cnt=0
for i in range(s,max(s-k,-1),-1):
    cnt+=1
    if i+k-1<n:
        a.append(-2*x[i]+x[i+k-1])
    if cnt==k:
        a.append(-x[i])
print(min(a))

Fixed submission:
n,k= map(int, input().split())
x= list(map(int, input().split()))
s=0
cnt=0
while x[s]<0:
    s+=1
    if n==s+1:
        break
a=[]
if x[s]>=0:
    for i in range(s,min(s+k,n)):
        cnt+=1
        if i-k-1>=0:
            a.append(2*x[i]-x[i-k+1])
        if cnt==k:
            a.append(x[i])
    s-=1
cnt=0
for i in range(s,max(s-k,-1),-1):
    cnt+=1
    if i+k-1<n:
        a.append(-2*x[i]+x[i+k-1])
    if cnt==k:
        a.append(-x[i])
print(min(a))
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
i=0
while True:
  if s[i]=='1' and i<len(s):
    i+=1
  else:
    break
if i<k-1 and len(s)>=2:
  print(s[1])
else:
  print(s[0])


Fixed submission:
s=input()
k=int(input())
i=0
while True:
  if i<len(s) and s[i]=='1':
    i+=1
  else:
    break
if i==0:
  print(s[0])
  exit()
if i<k:
  print(s[i])
else:
  print(s[0])

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
i=0
while True:
  if s[i]=='1' and i<len(s):
    i+=1
  else:
    break
if i<k-1:
  print(s[1])
else:
  print(1)

Fixed submission:
s=input()
k=int(input())
i=0
while True:
  if i<len(s) and s[i]=='1':
    i+=1
  else:
    break
if i==0:
  print(s[0])
  exit()
if i<k:
  print(s[i])
else:
  print(s[0])

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
i=0
while True:
  if s[i]=='1' or i<len(s):
    i+=1
  else:
    break
if i<k-1:
  print(s[1])
else:
  print(1)

Fixed submission:
s=input()
k=int(input())
i=0
while True:
  if i<len(s) and s[i]=='1':
    i+=1
  else:
    break
if i==0:
  print(s[0])
  exit()
if i<k:
  print(s[i])
else:
  print(s[0])

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())-1
i=0
while True:
  if s[i]=='1':
    i+=1
  else:
    break
if i<k:
  print(s[1])
else:
  print(1)

Fixed submission:
s=input()
k=int(input())
i=0
while True:
  if i<len(s) and s[i]=='1':
    i+=1
  else:
    break
if i==0:
  print(s[0])
  exit()
if i<k:
  print(s[i])
else:
  print(s[0])
Buggy python submission (verdict: Runtime Error):
n=int(input())
for i in range(15):
  for j in range(26):
    if i*7+j*4=n:
      print('Yes')
      exit()
print('No')

Fixed submission:
n=int(input())
for i in range(15):
  for j in range(26):
    if i*7+j*4==n:
      print('Yes')
      exit()
print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
m=sum(map(int,list(str(n)))
if n%m==0:
      print('Yes')
      exit()
print("No")


Fixed submission:
n=int(input())
m=list(str(n))
s=0
for i in range(len(m)):
  s+=int(m[i])
if n%s==0:
      print('Yes')
      exit()
print("No")

Buggy python submission (verdict: Runtime Error):
n=int(input())
m=sum(list(map(int,str(n)))
if n%m==0:
      print('Yes')
      exit()
print("No")

Fixed submission:
n=int(input())
m=list(str(n))
s=0
for i in range(len(m)):
  s+=int(m[i])
if n%s==0:
      print('Yes')
      exit()
print("No")
Buggy python submission (verdict: Runtime Error):
print(700+input.count('o')*100)

Fixed submission:
print(700+input().count('o')*100)
Buggy python submission (verdict: Runtime Error):
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
for i in range(25):
    if s[i]>s[i+1]:
        k=i-1

a="z"
for i in range(k+2,26):
    if s[k+1]<s[i]:
        a=min(a,s[i])
print(s[:k]+a)

Fixed submission:
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
a=[]
for i in range(25,-1,-1):
    for j in range(24-(25-i),-1,-1):
        if s[j]<s[i]:
            a.append(s[:j]+s[i])
print(min(a))

Buggy python submission (verdict: Runtime Error):
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
for i in range(25):
    if s[i]>s[i+1]:
        k=i-1

a="z"
for i in range(k+2,26):
    if s[k]<s[i]:
        a=min(a,s[i])
print(s[:k]+a)

Fixed submission:
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
a=[]
for i in range(25,-1,-1):
    for j in range(24-(25-i),-1,-1):
        if s[j]<s[i]:
            a.append(s[:j]+s[i])
print(min(a))

Buggy python submission (verdict: Runtime Error):
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
for i in range(25):
    if s[i]>s[i+1]:
        k=i-1
        break
a="z"
for i in range(k+2,26):
    if s[k]<s[i]:
        a=min(a,s[i])
print(s[:k]+a)

Fixed submission:
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
a=[]
for i in range(25,-1,-1):
    for j in range(24-(25-i),-1,-1):
        if s[j]<s[i]:
            a.append(s[:j]+s[i])
print(min(a))

Buggy python submission (verdict: Runtime Error):
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
for i in range(26):
    if s[i]>s[i+1]:
        k=i-1
        break
a="z"
for i in range(k,26):
    if s[k]<s[i]:
        a=min(a,s[i])
print(s[:k]+a)

Fixed submission:
s=input()
if len(s)<26:
    al=[chr(ord('a') + i) for i in range(26)]
    for i in al:
        if not(i in s):
            print(s+i)
            exit()
if s=="zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()
a=[]
for i in range(25,-1,-1):
    for j in range(24-(25-i),-1,-1):
        if s[j]<s[i]:
            a.append(s[:j]+s[i])
print(min(a))
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n=int(input())
ans=[0]*n
k=0
i=2
while k<n-1:
    if i%2==0 or i%3==0:
        ans[k]=i
        k+=1
    i+=1
x=sum(ans)
ans[-1]=30000+x//6*6-x
if ans[-1]
while gcd(ans[-1],x)==1:
    ans[-1]-=6
print(*ans)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

n=int(input())
ans=[0]*n
k=0
i=2
while k<n-1:
    if i%2==0 or i%3==0:
        ans[k]=i
        k+=1
    i+=1
x=sum(ans)
ans[-1]=30000+x//6*6-x
while gcd(ans[-1],x)==1:
    ans[-1]-=6
print(*ans)
Buggy python submission (verdict: Runtime Error):
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cnt=[0]*(len(s)+1)
for i in range(len(s)):
    cnt[i]=s.count(s[i])-t.count(t[i])
print(max(cnt))



Fixed submission:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cnt=[0]*(len(s)+1)
for i in range(len(s)):
    cnt[i]=s.count(s[i])-t.count(s[i])
print(max(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[0]
cnt=[0]
ans=True
for i in range(n):
    s=input()
    for j in range(len(a)):
        if a[j]==s:
            cnt[j]+=1
            ans=False
        if ans:
            cnt.append(1)
            a.append(s)
    ans=True
m=int(input())
for i in range(m):
    s=input()
    for j in range(len(a)):
        if a[j]==s:
            cnt[j]-=1
print(max(cnt))


Fixed submission:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cnt=[0]*(len(s)+1)
for i in range(len(s)):
    cnt[i]=s.count(s[i])-t.count(s[i])
print(max(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n=int(input())
a=[0]
cnt=[0]
ans=True
for i in range(n):
    s=input()
    for j in range(len(a)):
        if a[j]==s:
            cnt[j]+=1
            ans=False
        if ans:
            cnt.append(1)
            a.append(s)
    ans=True
n=int(input())
for i in range(n):
    s=input()
    for j in range(len(a)):
        if a[j]==s:
            cnt[j]-=1

print(max(cnt))


Fixed submission:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cnt=[0]*(len(s)+1)
for i in range(len(s)):
    cnt[i]=s.count(s[i])-t.count(s[i])
print(max(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
n=int(input())
a=[0]
cnt=[0]
ans=True
for i in range(n):
    s=input()
    for j in range(len(a)):
        if a[j]==s:
            cnt[j]+=1
            ans=False
        if ans:
            cnt.append(1)
            a.append(s)
    ans=True
n=int(input())
for i in range(n):
    s=input()
    for j in range(len(a)):
        if a[j]==s:
            cnt[j]-=1

print(max(cnt))

Fixed submission:
s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
cnt=[0]*(len(s)+1)
for i in range(len(s)):
    cnt[i]=s.count(s[i])-t.count(s[i])
print(max(cnt))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
k=0
for i in range(n):
    if a[i]<b[i]:
        p=b[i]-a[i]
        a[i]+=(p+1)//2*2
        while p>0 and k<n:
            if a[k]-b[k]>p:
                b[k]+=p
                p=0
            elif a[k]-b[k]>0:
                b[k]=a[k]
                p-=a[k]-b[k]
            k+=1
            # print(a,b,k,p,i)

# print(a,b)
if a==b and p==0:
    print("Yes")
else:
    print("No")

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c,d=0,0
for i in range(n):
    if a[i]>b[i]:
        c+=a[i]-b[i]
    else:
        d+=(b[i]-a[i])//2
if d>=c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b=input().split
x=int(a+b)
for i in range(1000):
  if i**2==x:
    print("Yes")
    exit()
print("No")

Fixed submission:
a,b=input().split()
x=int(a+b)
for i in range(1000):
  if i**2==x:
    print("Yes")
    exit()
print("No")