Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import copy
S=list(input())
N=len(S)
point=0
hand=copy.deepcopy(S)
panum=sum([j=="p" for j in hand])
pamax=N//2#ポイントの上限
for i in range(N):
    if S[i]=="g":
        pa=sum([hand[j]=="p" for j in range(i+1)])#今まで出したパーの数
        if pa<(i+1)//2 and point<pamax-panum:
            hand[i]="p"
            point+=1
    if point>=pamax-panum:
        break
print(point)
        

Fixed submission:
# coding: utf-8
# Your code here!
import copy
S=list(input())
N=len(S)
point=0
hand=copy.deepcopy(S)
panum=sum([j=="p" for j in hand])
pamax=N//2#ポイントの上限
pa=0
for i in range(N):
    if S[i]=="g" and pa<(i+1)//2 and point<pamax-panum:
        hand[i]="p"
        point+=1
    if point>=pamax-panum:
        break
    if hand[i]=="p":
        pa+=1
print(point)

Buggy python submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import copy
S=list(input())
N=len(S)
point=0
hand=copy.deepcopy(S)
panum=sum([j=="p" for j in hand])
pamax=N//2#ポイントの上限
for i in range(N):
    if S[i]=="g":
        pa=sum([hand[j]=="p" for j in range(i+1)])#今まで出したパーの数
        if pa<(i+1)//2 and point<pamax-panum:
            hand[i]="p"
            point+=1
    if point=>pamax-panum:
        break
print(point)
        

Fixed submission:
# coding: utf-8
# Your code here!
import copy
S=list(input())
N=len(S)
point=0
hand=copy.deepcopy(S)
panum=sum([j=="p" for j in hand])
pamax=N//2#ポイントの上限
pa=0
for i in range(N):
    if S[i]=="g" and pa<(i+1)//2 and point<pamax-panum:
        hand[i]="p"
        point+=1
    if point>=pamax-panum:
        break
    if hand[i]=="p":
        pa+=1
print(point)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import copy
S=list(input())
N=len(S)
point=0
hand=copy.deepcopy(S)
panum=sum([j=="p" for j in hand])
pamax=N//2#ポイントの上限
for i in range(N):
    pa=sum([hand[j]=="p" for j in range(i+1)])#今まで出したパーの数
    if pa<(i+1)//2 and point<pamax-panum:
        hand[i]="p"
        point+=1
print(point)
        

Fixed submission:
# coding: utf-8
# Your code here!
import copy
S=list(input())
N=len(S)
point=0
hand=copy.deepcopy(S)
panum=sum([j=="p" for j in hand])
pamax=N//2#ポイントの上限
pa=0
for i in range(N):
    if S[i]=="g" and pa<(i+1)//2 and point<pamax-panum:
        hand[i]="p"
        point+=1
    if point>=pamax-panum:
        break
    if hand[i]=="p":
        pa+=1
print(point)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import copy
S=list(input())
N=len(S)
point=0
hand=copy.deepcopy(S)
panum=sum([j=="p" for j in hand])
pamax=N//2#ポイントの上限
for i in range(N):
    pa=sum([j=="p" for j in hand[:i+1]])#今まで出したパーの数
    if pa<(i+1)//2 and point<pamax-panum:
        hand[i]="p"
        point+=1
print(point)
        

Fixed submission:
# coding: utf-8
# Your code here!
import copy
S=list(input())
N=len(S)
point=0
hand=copy.deepcopy(S)
panum=sum([j=="p" for j in hand])
pamax=N//2#ポイントの上限
pa=0
for i in range(N):
    if S[i]=="g" and pa<(i+1)//2 and point<pamax-panum:
        hand[i]="p"
        point+=1
    if point>=pamax-panum:
        break
    if hand[i]=="p":
        pa+=1
print(point)