Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# 最大公約数GCD(x,y)
def GCD(x,y):
    x,y=max(x,y),min(x,y)
    if x%y==0:
        return y
    else:
        return GCD(y,x%y)

def divide(g,p):
    if g%p!=0:
        return g
    if g%p==0:
        global n
        n+=1
        while g%p==0:
            g//=p
        return g

A,B=map(int,input().split())
g=GCD(A,B)

n=1 # gの素因数の個数

if g>=2:
    g=divide(g,2)
p=3 # 最初の奇素数
while g>1:
    g=divide(g,p)
    p+=2
print(n)

Fixed submission:
# 最大公約数GCD(x,y)
def GCD(x,y):
    x,y=max(x,y),min(x,y)
    if x%y==0:
        return y
    else:
        return GCD(y,x%y)

def divide(g,p):
    if g%p!=0:
        return g
    if g%p==0:
        global n
        n+=1
        while g%p==0:
            g//=p
        return g

A,B=map(int,input().split())
g=GCD(A,B)

n=1 # gの素因数の個数

if g>=2:
    g=divide(g,2)
p=3 # 最初の奇素数
while g>1 and p<1000000:
    g=divide(g,p)
    p+=2
if g>1:
    n+=1
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
def turn(S,l,r):
    S1=S[:l]
    S2=S[l:r+1][::-1]
    S3=S[r+1:]
    S2=S2.replace('L',' ')
    S2=S2.replace('R','L')
    S2=S2.replace(' ','R')
    return S1+S2+S3

def score(S):
    ans=0
    for i in range(N):
        if((i<N-1 and S[i]==S[i+1]=='R') or (i>0 and S[i]==S[i-1]=='L')):
            ans+=1
    return ans

N,K=map(int,input().split())
S=input()

for i in range(K):
    l=r=-1
    for j in range(1,N-1):
        if S[j]!=S[0]:
            l=j
            break
    for k in range(l+1,N-1):
        if S[k]==S[0]:
            r=k-1
            break
    if l==r==-1:
        break
    elif r==-1:
        S=turn(S,l,N-1)
    else:
        S=turn(S,l,r)

print(score(S))

Fixed submission:
import bisect

def turn(S,l,r):
    S1=S[:l]
    S2=S[l:r+1][::-1]
    S3=S[r+1:]
    S2=S2.replace('L',' ')
    S2=S2.replace('R','L')
    S2=S2.replace(' ','R')
    return S1+S2+S3

def score(S):
    ans=0
    for i in range(N):
        if((i<N-1 and S[i]==S[i+1]=='R') or (i>0 and S[i]==S[i-1]=='L')):
            ans+=1
    return ans

N,K=map(int,input().split())
S=input()
L=[];R=[]
c0=S[0]

for i in range(1,N):
    c=S[i]
    if c0!=c=='L':
        L.append(i)
    elif c0!=c=='R':
        R.append(i)
    c0=c

lenL,lenR=len(L),len(R)

for i in range(K):
    if i<min(lenL,lenR):
        S=turn(S,min(L[i],R[i]),max(L[i],R[i])-1)
    elif i==min(lenL,lenR)<max(lenL,lenR):
        if lenL>lenR:
            S=turn(S,L[lenL-1],N-1)
        elif lenL<lenR:
            S=turn(S,R[lenR-1],N-1)
    else:
        break

print(score(S))
Buggy python submission (verdict: Runtime Error):
import math

class Engine:
    def __init__(self,x,y,arg):
        self.x,self.y,self.arg=x,y,arg

    def __str__(self):
        return f'({self.x},{self.y}),arg={self.arg/math.pi*180}'
    
    def __eq__(self,other):
        return self.arg==other.arg
    
    def __lt__(self,other):
        return self.arg<other.arg

    def __gt__(self,other):
        return self.arg>other.arg

N=int(int(input()))

l=[]
for i in range(N):
    x,y=map(int,input().split())
    l.append(Engine(x,y,math.atan2(y,x)))
    l.append(Engine(x,y,math.atan2(y,x)+2*math.pi))
l.sort()

d=[[]for j in range(N)]

for i in range(N):
    e0=l[i]
    d[i].append(e0)
    for j in range (i+1,N+i):
        e=l[j]
        if e.arg>=e0.arg+math.pi:
            break
        else:
            d[i].append(e)

dis=[]
for i in range(N):
    x=sum(e.x for e in d[i])
    y=sum(e.y for e in d[i])
    dis.append(math.sqrt(x**2+y**2))

print(max(dis))

Fixed submission:
import math

N=int(input())
e=[]
for i in range(N):
    x,y=map(int,input().split())
    t=math.atan2(y,x)
    e.append((x,y,t));e.append((x,y,t+2*math.pi))

e.sort(key=lambda z:z[2])
# print(e) #DB

sqans=0
for i in range(N):
    dx=e[i][0];dy=e[i][1]
    sqans=max(sqans,dx**2+dy**2)
    for j in range(i+1,i+N):
        dx+=e[j][0];dy+=e[j][1]
        sqans=max(sqans,dx**2+dy**2)
ans=math.sqrt(sqans)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
import itertools as it

N=int(input())
l=[]
for i in range(N):
    l.append(tuple(map(int,input().split())))
l.sort()

d=[(c[1][0]-c[0][0],c[1][1]-c[0][1]) for c in it.combinations(l,2)]
ans=N-max(dict(Counter(d)).values())

print(ans)

Fixed submission:
from collections import Counter
import itertools as it

N=int(input())
l=[]
for i in range(N):
    l.append(tuple(map(int,input().split())))
l.sort()

if N==1:
    ans=1
else:
    d=[(c[1][0]-c[0][0],c[1][1]-c[0][1]) for c in it.combinations(l,2)]
    ans=N-max(dict(Counter(d)).values())

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
p=10**9+7
N,M=map(int,input().split())
a=[]
for i in range(M):
    a.append(int(input()))
x=[0 for i in range(N+1)]
x[0]=1
if 1 in a:
    x[1]=0
else:
    x[1]=x[0]
for i in range(2,N+1):
    x[i]=((x[i-1] if i-1 not in a else 0)+(x[i-2] if i-2 not in a else 0))%p

print(x[N])

Fixed submission:
import bisect

p=10**9+7
N,M=map(int,input().split())
a=[]
for i in range(M):
    a.append(int(input()))
x=[0 for i in range(N+1)]
x[0]=1
if 1 in a:
    x[1]=0
else:
    x[1]=x[0]
for i in range(2,N+1):
    if bisect.bisect_right(a,i-1)-bisect.bisect_left(a,i-1)==0: # i-1 not in a
        x[i]+=x[i-1]
    if bisect.bisect_right(a,i-2)-bisect.bisect_left(a,i-2)==0: # i-2 not in a
        x[i]+=x[i-2]
    x[i]%=p

print(x[N])
Buggy python submission (verdict: Runtime Error):
N=int(input())
ba=bx=xa=0
ans=0
for i in range(N):
    s=input()
    ans+=s.count('AB')
    if s.startswith('B') and s.endswith('A'):
        ba+=1
    elif s.startswith('B'):
        bx+=1
    elif s.endswith('A'):
        xa+=1

if ba==0:
    ans+=min(bx,xa)
elif ba>0:
    if bx+xa>0:
        ans+=ba+min(bx,xa)
    else bx+xa==0
        ans+=ba-1

print(ans)

Fixed submission:
N=int(input())
ba=bx=xa=0
ans=0
for i in range(N):
    s=input()
    ans+=s.count('AB')
    if s.startswith('B') and s.endswith('A'):
        ba+=1
    elif s.startswith('B'):
        bx+=1
    elif s.endswith('A'):
        xa+=1

if ba==0:
    ans+=min(bx,xa)
elif ba>0:
    if bx+xa>0:
        ans+=ba+min(bx,xa)
    elif bx+xa==0:
        ans+=ba-1

print(ans)
Buggy python submission (verdict: Runtime Error):
b=input()
if b='A':c='T'
if b='T':c='A'
if b='C':c='G'
if b='G':c='C'
print(c)

Fixed submission:
b=input()
if b=='A':c='T'
if b=='T':c='A'
if b=='C':c='G'
if b=='G':c='C'
print(c)
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())

cnt=0

for i in range(101):
    if A%i==B%i==0:
        cnt+=1
    if cnt==K:
        print(i)
        break

Fixed submission:
A,B,K=map(int,input().split())

cnt=0

for i in range(100,0,-1):
    if A%i==0 and B%i==0:
        cnt+=1
    if cnt==K:
        print(i)
        break
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())

l=[] # 寿司リスト。ただし，「おいしさ」を第1要素にする
dj=[] # 寿司タプルをそのまま入れる
s=set()

for i in range(N):
    t,d=map(int,input().split())
    l.append((d,t))
l.sort(reverse=True) 

ans=K**2
j=0 # 既に食べたことのある種類の寿司を更に食べた回数

for i in range(K): # i番目に食べる寿司について
    while l and l[0][1] in s:
        dj.append(l.pop(0))
    if (l and dj and l[0][0]>=dj[0][0]-(2*K-1-2*j)) or not dj:
        ans+=l[0][0]
        s.add(l[0][1])
        l.pop(0)
    else:
        ans+=dj[0][0]-(2*K-1-2*j)
        dj.pop(0)
        j+=1

print(ans)

Fixed submission:
N,K=map(int,input().split())

l=[] # 寿司リスト。ただし，「おいしさ」を第1要素にする
m=[] # 寿司タプルをそのまま入れる
s=set()

for i in range(N):
    t,d=map(int,input().split())
    l.append((d,t))
l.sort(reverse=True) 

ans=K**2
t=0 # 既に食べたことのある種類の寿司を更に食べた回数

i=0 # l内を走査する際の添字
j=0 # m内を操作する際の添え字

for _ in range(K): # _番目に食べる寿司について
    while i<N and l[i][1] in s:
        m.append(l[i]) # そのままmに追加する
        i+=1 # lの先頭の要素を削除せず，
    if (i<N and (m and j<len(m)) and l[i][0]>=m[j][0]-(2*K-1-2*t)) or (not m or j>=len(m)):
        ans+=l[i][0]
        s.add(l[i][1])
        i+=1
    else:
        ans+=m[j][0]-(2*K-1-2*t)
        j+=1
        t+=1

print(ans)

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

l=[] # 与えられた寿司のリスト。寿司をタプル(ネタti,おいしさdi)で表す。既に食べた種類の寿司は，そのおいしさdiをdjに移す。食べた寿司はリストから削除する。
dj=[] # 既に食べた種類の寿司の「おいしさ基礎ポイント」を格納するリスト。食べた寿司の「おいしさ基礎ポイント」はリストから削除する。
s=set() # 既に食べた寿司の種類を格納するセット

for i in range(N):
    t,d=map(int,input().split())
    l.append((t,d))
l.sort(key=lambda x:x[1],reverse=True) # l内の寿司をおいしさdiで降順にソート

ans=K**2
j=0 # 既に食べたことのある種類の寿司を更に食べた回数

for i in range(K): # i番目に食べる寿司について
    while l and l[0][0] in s: # lが空でなく，先頭の寿司の種類がsに入っている（先頭の寿司が食べたことのある種類である）場合
        dj.append((l.pop(0))[1]) # 食べたことのない種類の寿司がlの先頭に現れるか，lが空になるまで，先頭の寿司のおいしさをdjに格納する
    if not dj or l[0][1]>=dj[0]-(2*K-1-2*j): # djが空である場合，又は，lの先頭の寿司のおいしさと，djの先頭の「寿司のおいしさ」から「種類ボーナスポイント」の差分を減じたものを比較し，前者が勝る場合
        ans+=l[0][1] # lの先頭の寿司のおいしさに「種類ボーナスポイント」の差分を加えたものを答えに加算
        s.add(l[0][0]) # その寿司の種類をsに追加
        l.pop(0) # その寿司をlから削除
    else: #　後者が勝る場合
        ans+=dj[0]-(2*K-1-2*j) # djの先頭の「寿司のおいしさ」を答えに加算
        dj.pop(0) # その「寿司のおいしさ」をdjから削除
        j+=1

print(ans)

Fixed submission:
N,K=map(int,input().split())

l=[] # 寿司リスト。ただし，「おいしさ」を第1要素にする
m=[] # 寿司タプルをそのまま入れる
s=set()

for i in range(N):
    t,d=map(int,input().split())
    l.append((d,t))
l.sort(reverse=True) 

ans=K**2
t=0 # 既に食べたことのある種類の寿司を更に食べた回数

i=0 # l内を走査する際の添字
j=0 # m内を操作する際の添え字

for _ in range(K): # _番目に食べる寿司について
    while i<N and l[i][1] in s:
        m.append(l[i]) # そのままmに追加する
        i+=1 # lの先頭の要素を削除せず，
    if (i<N and (m and j<len(m)) and l[i][0]>=m[j][0]-(2*K-1-2*t)) or (not m or j>=len(m)):
        ans+=l[i][0]
        s.add(l[i][1])
        i+=1
    else:
        ans+=m[j][0]-(2*K-1-2*t)
        j+=1
        t+=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions

N,M=map(int,input().split())
d=N*M//fractions.gcd(N,M)
a=d//N
b=d//M

S=input()
dS={}
for i in range(N):
    dS[a*i]=S[i]

T=input()
dT={}
for i in range(M):
    dT[b*i]=T[i]

f=True
for i in range(d):
    if i in dS and i in dT and dS[i]!=dT[i]:
        f=False
        break

print(d if f else -1)

Fixed submission:
import fractions

N,M=map(int,input().split())
g=fractions.gcd(N,M)

a=N//g;b=M//g

S=input();T=input()

f=True
for k in range(g):
    if S[k*a]!=T[k*b]:
        f=False
        break

print(a*b*g if f else -1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))

dE={};dO={}
for i in range(n):
    dX=dE if i%2==0 else dO
    if v[i] in dX:
        dX[v[i]]+=1
    else:
        dX[v[i]]=1

lE=sorted(list(dE.items()),key=lambda x:x[1],reverse=True)
lO=sorted(list(dO.items()),key=lambda x:x[1],reverse=True)

me=lE[0][1];mo=lO[0][1]
ae=lE[0][0];ao=lO[0][0]
se=0 if len(lE)==0 else lE[1][1]
so=0 if len(lO)==0 else lO[1][1]

if ae==ao:
    ans=n-max(me+so,mo+se)
else:
    ans=n-(me+mo)

print(ans)

Fixed submission:
n=int(input())
v=list(map(int,input().split()))

dE={};dO={}
for i in range(n):
    dX=dE if i%2==0 else dO
    if v[i] in dX:
        dX[v[i]]+=1
    else:
        dX[v[i]]=1

lE=sorted(list(dE.items()),key=lambda x:x[1],reverse=True)
lO=sorted(list(dO.items()),key=lambda x:x[1],reverse=True)

me=lE[0][1];mo=lO[0][1]
ae=lE[0][0];ao=lO[0][0]

se=0 if len(lE)==1 else lE[1][1]
so=0 if len(lO)==1 else lO[1][1]

if ae==ao:
    ans=n-max(me+so,mo+se)
else:
    ans=n-(me+mo)

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N,X=map(int,input().split())
x=list(map(int,input().split()))

ans=0

for xi in x:
    ans=math.gcd(ans,xi-X)

print(ans)

Fixed submission:
def GCD(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if y==0:
        return x
    elif x%y==0:
        return y
    else:
        return GCD(y,x%y)

N,X=map(int,input().split())
x=list(map(int,input().split()))

ans=0

for xi in x:
    ans=GCD(ans,xi-X)

print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
print(f"ABC{N:03}" if N<=999 else f"ABD{N-999:03}")

Fixed submission:
N=int(input())
print('ABC' if N<=999 else 'ABD')
Buggy python submission (verdict: Runtime Error):
import numpy as np

N=int(input())
S=input()

W=[0 for i in range(N)] # W[i]=(S[i]より西で西を向いている人の数)
E=[0 for i in range(N)] # E[i]=(S[i]より東で東を向いている人の数)

for i in range(1,N):
    if S[i-1]=='W':
        W[i]=W[i-1]+1
    else:
        W[i]=W[i-1]
for i in reversed(range(N-1)):
    if S[i+1]=='E':
        E[i]=E[i+1]+1
    else:
        E[i]=E[i+1]

print(min([x for x in np.array(W)+np.array(E)]))

Fixed submission:
import numpy as np

N=int(input())
S=input()

W=[0 for i in range(N)] # W[i]=(S[i]より西で西を向いている人の数)
E=[0 for i in range(N)] # E[i]=(S[i]より東で東を向いている人の数)

for i in range(1,N):
    if S[i-1]=='W':
        W[i]=W[i-1]+1
    else:
        W[i]=W[i-1]
for i in reversed(range(N-1)):
    if S[i+1]=='E':
        E[i]=E[i+1]+1
    else:
        E[i]=E[i+1]

print(min([x for x in np.array(W)+np.array(E)]))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
K=int(input())

N=len(s)
S=set()
for i in range(N):
    for j in range(i+1,N+1):
        S.add(s[i:j])
l=sorted(list(S))
print(l[K-1])

Fixed submission:
s=input()
K=int(input())

N=len(s)
S=set()
for i in range(N):
    for j in range(i+1,min(i+6,N+1)):
        S.add(s[i:j])
l=sorted(list(S))
print(l[K-1])
Buggy python submission (verdict: Runtime Error):
import copy

N=int(input())
X=list(map(int,input().split()))

Y=sorted(X.copy())

a=Y[N//2-1]
b=Y[N//2]

for i in range(N):
    if X[i]<=a:
        print(b)
    else:
        print(a)

Fixed submission:
import copy

N=int(input())
X=list(map(int,input().split()))

Y=sorted(X.copy())

a=Y[N//2-1]
b=Y[N//2]

for i in range(N):
    if X[i]<=a:
        print(b)
    else:
        print(a)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K=map(int,input().split())
l=[x for x in range(A,B+1) if x-A<=K-1 or B-x<=K-1]
for x in l:
    print(x)

Fixed submission:
A,B,K=map(int,input().split())
if B-A+1<=2*K:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(A,A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)
Buggy python submission (verdict: Runtime Error):
_=int(input())
print('Yes' if sum(list(map(int,input().split()))<=sum(list(map(int,input().split()))) else 'No')

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=sorted([a[i]-b[i] for i in range(N)])
k=-sum(c)
# print(c,k)
cp=[ci for ci in c if ci>0]
cn=[ci for ci in c if ci<0]

# 必要な「1増やす回数」
p=sum(cp)+sum([cni%2 for cni in cn])
# 必要な「2減らす回数」
n=sum([(-cni+1)//2 for cni in cn])

f=k>=0 and p<=k and n<=k

print('Yes' if f else 'No')
Buggy python submission (verdict: Runtime Error):
print(replace(input(),'7','8',1))

Fixed submission:
print(input().replace('7','8',1))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect as bi

N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=0
for i in range(N):
    for j in range(bi.bisect_left(B,C[i])):
        ans+=bi.bisect_left(A,B[j])

print(ans)

Fixed submission:
import bisect as bi

N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

ans=0
for Bi in B:
    a=bi.bisect_left(A,Bi)
    c=N-bi.bisect_right(C,Bi)
    ans+=a*c

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

f=True
for Ti in T:
    if D.count(Ti)<T.count(Ti):
        f=False
        break

print('YES' if f else 'NO')

Fixed submission:
from collections import Counter

N=int(input())
D=list(map(int,input().split()))
CD=Counter(D)
# print(CD) #DB
M=int(input())
T=list(map(int,input().split()))
CT=Counter(T)
# print(CT) #DB

f=True
for Ti in CT.keys():
    if CD[Ti]<CT[Ti]:
        f=False
        break

print('YES' if f else 'NO')
Buggy python submission (verdict: Time Limit Exceeded):
def ans(p,k):
    if k==1:
        return 1 # 便宜上
    elif k==2:
        if p[-1]==2:
            return 1
        else:
            return 0
    else:
        if p[-1]==k:
            return 1+ans(p[:-2],k-2)
        else:
            return ans(p[:-1],k-1)

N=int(input())
p=list(map(int,input().split()))

print(ans(p,N))

Fixed submission:
N=int(input())
p=list(map(int,input().split()))

ans=0
i=0
while i <N:
    if p[i]==i+1:
        ans+=1
        i+=2
    else:
        i+=1

print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N<2:
    x=1
elif N<4:
    x=2
elif N<8:
    x=4
elif N<16:
    x=8
elif n<32:
    x=16
elif n<64:
    x=32
else:
    x=64
print(x)

Fixed submission:
N=int(input())
if N<2:
    x=1
elif N<4:
    x=2
elif N<8:
    x=4
elif N<16:
    x=8
elif N<32:
    x=16
elif N<64:
    x=32
else:
    x=64
print(x)

Buggy python submission (verdict: Runtime Error):
N=int(input())
p=0
while N%==0:
    p+=1
    N//=2
print(2**p)

Fixed submission:
N=int(input())
if N<2:
    x=1
elif N<4:
    x=2
elif N<8:
    x=4
elif N<16:
    x=8
elif N<32:
    x=16
elif N<64:
    x=32
else:
    x=64
print(x)
Buggy python submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
if N==1:
    if A==B:
        ans=1
    else:
        ans=0
elif:
    if A>B:
        ans=0
    else:
        ans=(B-A)*(N-2)+1
print(ans)

Fixed submission:
N,A,B=map(int,input().split())
if N==1:
    if A==B:
        ans=1
    else:
        ans=0
else:
    if A>B:
        ans=0
    else:
        ans=(B-A)*(N-2)+1
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B,C=map(int,input().split())
print('Yes' if a<=C<=B else 'No')

Fixed submission:
A,B,C=map(int,input().split())
print('Yes' if A<=C<=B else 'No')
Buggy python submission (verdict: Runtime Error):
import math
A,B,C=map(int,input().split())
f=C%math.gcd(A,B)==0
print('YES' if f else 'NO')

Fixed submission:
import fractions

A,B,C=map(int,input().split())
f=C%fractions.gcd(A,B)==0
print('YES' if f else 'NO')
Buggy python submission (verdict: Time Limit Exceeded):
p=10**9+7

n,m=map(int,input().split())
x=list(map(int,input().split()))
w=[x[i+1]-x[i] for i in range(n-1)]
y=list(map(int,input().split()))
h=[y[k+1]-y[k] for k in range(m-1)]

ans=0

for i in range (n-1):
    for k in range(m-1):
        ans=(ans+w[i]*h[k]*(1+i)*(n-i-1)*(1+k)*(m-k-1))%p

print(ans)

Fixed submission:
p=10**9+7

n,m=map(int,input().split())
x=list(map(int,input().split()))
w=[((x[i+1]-x[i])*(1+i)*(n-i-1))%p for i in range(n-1)]
y=list(map(int,input().split()))
h=[((y[k+1]-y[k])*(1+k)*(m-k-1))%p for k in range(m-1)]

print(((sum(w)%p)*(sum(h)%p)%p))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
K=int(input())
ans=''
for c in s:
    if c!='a' and ord('z')+1-ord(c)<=K:
        ans+='a'
        K-=ord('z')+1-ord(c)
    else:
        ans+=c
if K>0:
    ans=ans[:-1]+chr(ord(ans[-1])+K%26)

print(ans)

Fixed submission:
s=input()
K=int(input())
ans=''
for c in s:
    if c!='a' and ord('z')+1-ord(c)<=K:
        ans+='a'
        K-=ord('z')+1-ord(c)
    else:
        ans+=c
if K>0:
    ans=ans[:-1]+chr(ord(ans[-1])+K%26)

print(ans)

Buggy python submission (verdict: Runtime Error):
a=[ord(c)-ord('a') for c in input()]
K=int(input())

for i in range(len(a)):
    if a[i]>0 and 26-a[i]<=K:
        K-=26-a[i]
        a[i]=0
a[-1]+=K
l=[chr(ord('a')+ai) for ai in a]

print(''.join(l))

Fixed submission:
s=input()
K=int(input())
ans=''
for c in s:
    if c!='a' and ord('z')+1-ord(c)<=K:
        ans+='a'
        K-=ord('z')+1-ord(c)
    else:
        ans+=c
if K>0:
    ans=ans[:-1]+chr(ord(ans[-1])+K%26)

print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
K=int(input())

for i,c in enumerate(s):
    if c!='a' and ord('z')+1-ord(c)<=K:
        K-=ord('z')+1-ord(c)
        s=s[:i]+'a'+s[i+1:]
s=s[:-1]+chr(ord(s[-1])+K)

print(s)

Fixed submission:
s=input()
K=int(input())
ans=''
for c in s:
    if c!='a' and ord('z')+1-ord(c)<=K:
        ans+='a'
        K-=ord('z')+1-ord(c)
    else:
        ans+=c
if K>0:
    ans=ans[:-1]+chr(ord(ans[-1])+K%26)

print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
a=[ord(c)-ord('a') for c in s]
K=int(input())

# print(a) #DB

for i in range(len(s)):
    if 26-a[i]>K or a[i]==0:
        continue
    else:
        K-=26-a[i]
        a[i]=0

a[-1]+=K

print(''.join([chr(ord('a')+ai) for ai in a]))

Fixed submission:
s=input()
K=int(input())
ans=''
for c in s:
    if c!='a' and ord('z')+1-ord(c)<=K:
        ans+='a'
        K-=ord('z')+1-ord(c)
    else:
        ans+=c
if K>0:
    ans=ans[:-1]+chr(ord(ans[-1])+K%26)

print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
a=[ord(c)-ord('a') for c in s]
K=int(input())

# print(a) #DB

for i in range(len(s)):
    if 26-a[i]>K:
        continue
    else:
        K-=26-a[i]
        a[i]=0

a[-1]+=K

print(''.join([chr(ord('a')+ai) for ai in a]))

Fixed submission:
s=input()
K=int(input())
ans=''
for c in s:
    if c!='a' and ord('z')+1-ord(c)<=K:
        ans+='a'
        K-=ord('z')+1-ord(c)
    else:
        ans+=c
if K>0:
    ans=ans[:-1]+chr(ord(ans[-1])+K%26)

print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
w=int(input())
n=len(S)
T=""
for i in range (0,n+1,w):
  T+=S[i]
print(T)

Fixed submission:
S=input()
w=int(input())
n=len(S)
T=""
for i in range (0,n,w):
  T+=S[i]
print(T)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(input().split())
s=a[0]+b[0]+c[0]
print(s.upper())

Fixed submission:
a,b,c=input().split()
s=a[0]+b[0]+c[0]
print(s.upper())
Buggy python submission (verdict: Runtime Error):

#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);

  return 0;
}


Fixed submission:

import numpy as np

N = int(input())
A = [int(x) for x in input().split()]
a = np.array(A)

#mask = a%6==0 or a%10==0 or a%2==1 
mask = np.logical_or.reduce( (a%6==0 , a%10==0, a%2==1) )
if mask.all() : 
    print("APPROVED")
else :
    print("DENIED")
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python

N = 1
a = []

def sol(x, cnt) : 

    cnt+=1
    if a[x-1] == 2 :
        return cnt
    if cnt > N :
        return -1

    return sol(a[x-1], cnt)


if __name__ == '__main__' : 
    N = int(input())

    for i in range(N) : 
        a.append(int(input()))

    print( sol(1,0) )




Fixed submission:
#!/usr/bin/env python

import sys
sys.setrecursionlimit(1000000)

N = 1
a = []

def sol(x, cnt) : 
    cnt+=1
    if a[x-1] == 2 :
        return cnt
    if cnt > N :
        return -1

    return sol(a[x-1], cnt)


if __name__ == '__main__' : 
    N = int(input())

    for i in range(N) : 
        a.append(int(input()))

    print( sol(1,0) )