TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have a grid with 3 rows and N columns. The cell at the i-th row and j-th column is denoted (i, j). Initially, each cell (i, j) contains the integer i+3j-3.    A grid with N=5 columns  Snuke can perform the following operation any number of times:    * Choose a 3×3 subrectangle of the grid. The placement of integers within the subrectangle is now rotated by 180°.    An example sequence of operations (each chosen subrectangle is colored blue)  Snuke's objective is to manipulate the grid so that each cell (i, j) contains the integer a_{i,j}. Determine whether it is achievable.

Submission attempts (in order):
import sys
input = sys.stdin.readline

n = int(input())
a = [list(map(int, input().split())) for _ in range(3)]

for j in range(n):
    if not ((a[0][j] - 1 == a[1][j] and a[2][j] + 1 == a[1][j]) or (a[0][j] + 1 == a[1][j] and a[2][j] - 1 == a[1][j])):
        print("No")
        exit()

for j in range(n):
    if (j % 2) * (((a[0][j] - 1) // 3) % 2) == 1:
        print("No")
        exit()

# BIT
def add(a, w, bit):
    x = a
    while x <= n:
        bit[x] += w
        x += x & -x

def solve(a, bit):
    ret = 0
    x = a
    while x > 0:
        ret += bit[x]
        x -= x & -x
    return ret

bit_odd = [0] * (3*n+1)
inv_odd = 0
flip_even = 0
for j in range(n):
    if j % 2 == 1:
        if a[0][j] > a[1][j]:
            flip_even += 1
    else:
        inv_odd += j - solve(a[0][j], bit_odd)
        add(a[0][j], 1, bit_odd)
if flip_even % 2 != inv_odd % 2:
    print("No")
    exit()


bit_even = [0] * (3*n+1)
inv_even = 0
flip_odd = 0
for j in range(n):
    if j % 2 == 0:
        if a[0][j] > a[1][j]:
            flip_odd += 1
    else:
        inv_even += j - solve(a[0][j], bit_even)
        add(a[0][j], 1, bit_even)
if flip_odd % 2 != inv_even % 2:
    print("No")
    exit()

print("Yes")


import sys
input = sys.stdin.readline

n = int(input())
a = [list(map(int, input().split())) for _ in range(3)]

for j in range(n):
    if not ((a[0][j] - 1 == a[1][j] and a[2][j] + 1 == a[1][j]) or (a[0][j] + 1 == a[1][j] and a[2][j] - 1 == a[1][j])):
        print("No")
        exit()

for j in range(n):
    if (j % 2) ^ (((a[0][j] - 1) // 3) % 2) == 1:
        print("No")
        exit()

# BIT
def add(a, w, bit):
    x = a
    while x <= 3 * n:
        bit[x] += w
        x += x & -x

def solve(a, bit):
    ret = 0
    x = a
    while x > 0:
        ret += bit[x]
        x -= x & -x
    return ret

bit_odd = [0] * (3*n+1)
inv_odd = 0
flip_even = 0
for j in range(n):
    if j % 2 == 1:
        if a[0][j] > a[1][j]:
            flip_even += 1
    else:
        inv_odd += j//2 - solve(a[0][j], bit_odd)
        add(a[0][j], 1, bit_odd)
if flip_even % 2 != inv_odd % 2:
    print("No")
    exit()


bit_even = [0] * (3*n+1)
inv_even = 0
flip_odd = 0
for j in range(n):
    if j % 2 == 0:
        if a[0][j] > a[1][j]:
            flip_odd += 1
    else:
        inv_even += j//2 - solve(a[0][j], bit_even)
        add(a[0][j], 1, bit_even)
if flip_odd % 2 != inv_even % 2:
    print("No")
    exit()

print("Yes")


Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
import math
N = int(input())
x=0
t=0
n=0
pre_t=0
pre_n=0
for i in range(N):
    t,n = map(int,input().split())
    mul = max(math.ceil(pre_t/t),math.ceil(pre_n/n))
    t *= mul
    n *= mul
    pre_t = t
    pre_n = n
    x = t+n
print(x)

import math
N = int(input())
x=0
t=0
n=0
pre_t=1
pre_n=1
for i in range(N):
    t,n = map(int,input().split())
    if(pre_t > t or pre_n > n):
        mul = max(-(-pre_t//t),-(-pre_n//n))
        t *= mul
        n *= mul
    pre_t = t
    pre_n = n
    x = t+n
print(x)

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
N = int(input())
T = [None] * N
A = [None] * N
for i in range(N):
  T[i], A[i] = map(int, input().split())

t, a = 1, 1

for i in range(N):
  if ( t < T[i] and a < A[i]):
    t, a = T[i], A[i]
  else:
    n = max(t // T[i], a // A[i])
    t, a = n * T[i], n * A[i]

print(t + a)

N = int(input())
T = [None] * N
A = [None] * N
for i in range(N):
  T[i], A[i] = map(int, input().split())

t, a = T[0], A[0]

for i in range(1, N):
  if ( t < T[i] and a < A[i]):
    t, a = T[i], A[i]
  else:
    n = max(t // T[i], a // A[i])
    t, a = n * T[i], n * A[i]

print(t + a)

import math
N = int(input())
T = [None] * N
A = [None] * N
for i in range(N):
  T[i], A[i] = map(int, input().split())

t, a = T[0], A[0]

for i in range(1, N):
  if (t < T[i] and a < A[i]):
    t, a = T[i], A[i]
  else:
    n = max((t - 1) // T[i] + 1, (a - 1) // A[i] + 1)
    t, a = n * T[i], n * A[i]

print(t + a)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
import sys
input=sys.stdin.readline


import math
def f(n, m):
    return int(m * math.ceil(n/m))

def main():
    N = int(input())
    T = A = 1
    for _ in range(N):
        t,a = map(int, input().split())
        k = max(f(T,t)//t, f(A,a)//a)
        T = k*t
        A = k*a
        print(T+A)

if __name__ == '__main__':
    main()


import sys
input=sys.stdin.readline

import math

def main():
    N = int(input())
    T = A = 1
    for _ in range(N):
        t,a = map(int, input().split())
        k = max(-(-T//t),-(-A//a))
        T = k*t
        A = k*a
    print(T+A)

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
N = int(input())
ta = [list(map(int, input().split())) for i in range(N)]

t = ta[0][0]
a = ta[0][1]

for i in range(N-1):
  if ta[i][0] <= ta[i+1][0] and ta[i][1] <= ta[i+1][1]:
    t = ta[i+1][0]
    a = ta[i+1][1]
  elif ta[i][0] > ta[i+1][0] and ta[i][1] < ta[i+1][1]:
    k = 1
    while t > ta[i+1][0]*k:
      k+= 1
    t = ta[i+1][0]*k
    a = ta[i+1][1]*k  
  elif ta[i][0] < ta[i+1][0] and ta[i][1] > ta[i+1][1]:
     k = 1
     while a > ta[i+1][1]*k:
       k+= 1
     t = ta[i+1][0]*k
     a = ta[i+1][1]*k
  else:
    k = 1
    while t > ta[i+1][0]*k or a > ta[i+1][1]*k:
      k += 1
    t = ta[i+1][0]*k
    a = ta[i+1][1]*k
print(t+a)

N = int(input())
ta = [list(map(int, input().split())) for i in range(N)]

t = ta[0][0]
a = ta[0][1]

for i in range(N-1):
  print(str(t)+ " " + str(a))
  k = 1
  while t > ta[i+1][0]*k or a > ta[i+1][1]*k:
    k += 1
  t = ta[i+1][0]*k
  a = ta[i+1][1]*k
print(t+a)

N = int(input())
ta = [list(map(int, input().split())) for i in range(N)]

t = 1
a = 1

for i in range(N):
  k = max((t+ta[i][0]-1)//ta[i][0], (a+ta[i][1]-1)//ta[i][1])
  t = ta[i][0]*k
  a = ta[i][1]*k
  
print(t+a)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
N = int(input())
TA = []
for i in range(N):
	TA.append(list(map(int, input().split())))

TA.reverse()
(voteA, voteB) = TA.pop()
while TA:
	(Ti, Ai) = TA.pop()
	tmp = max(int((voteA + Ti -1) / Ti), int((voteB + Ai -1) / Ai))
	voteA = Ti * tmp
	voteB = Ti * tmp
print(voteA + voteB)



N = int(input())
TA = []
for i in range(N):
	TA.append(list(map(int, input().split())))
 
TA.reverse()
(voteA, voteB) = (1,1)
while TA:
	(Ti, Ai) = TA.pop()
	tmp = max((voteA + Ti -1) // Ti, (voteB + Ai -1) // Ai)
	voteA = Ti * tmp
	voteB = Ai * tmp
print(voteA + voteB)

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
N = int(input())
TA = []
AO = []
for i in range(N):
    T, A = map(int, input().split())
    TA += [T]
    AO += [A]

for i in range(N-1):
    D = ((TA[i]-1)//TA[i+1])+1
    E = ((AO[i]-1)//AO[i+1])+1
    F = max(D, E)
ans = int(TA[N-1] + AO[N-1])
print(ans)

N = int(input())
TA = []
AO = []
for i in range(N):
    T, A = map(int, input().split())
    TA += [T]
    AO += [A]

for i in range(N-1):
    D = ((TA[i]-1)//TA[i+1])+1
    E = ((AO[i]-1)//AO[i+1])+1
    F = max(D, E)
    TA[i+1] *= F
    AO[i+1] *= F
ans = int(TA[N-1] + AO[N-1])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
import math

def cceil(x,y):
	res = x //y
	if x % y != 0:res += 1
	return res

def gcd(x, y):
	if(x == 0):return y
	return gcd(y % x, x)
 
def main():
    votes = int(input())
    ratio = [[ int(i) for i in input().split() ] for j in range(votes)]
 
    votesTemp = [0, 0]
    for i in range(votes):
        if i == 0:
            votesTemp = ratio[i]
            continue
        if(gcd(ratio[i][0], ratio[i][1]) != 1):
        	x = 1 / 0
        ceil = [ cceil(votesTemp[j], ratio[i][j]) for j in range(2)]
 
        votesTemp = [ max(ceil) * ratio[i][j] for j in range(2) ]
 
        print("turn: " + str(i))
        print("votes: " + str(ratio[i][0]) + ":" + str(ratio[i][1]) )
        print("Temp: " +str(votesTemp[0])+":"+str(votesTemp[1]))
        
    print(sum(votesTemp))
 
if __name__ == '__main__':
  main()


import math
 
def gcd(x, y):
	if(x == 0):return y
	return gcd(y % x, x)
 
def main():
    votes = int(input())
    ratio = [[ int(i) for i in input().split() ] for j in range(votes)]
 
    votesTemp = [0, 0]
    for i in range(votes):
        if i == 0:
            votesTemp = ratio[i]
            continue
        if(gcd(ratio[i][0], ratio[i][1]) != 1):
        	x = 1 / 0
        ceil = [ math.ceil(votesTemp[j] / ratio[i][j]) for j in range(2)]
 
        votesTemp = [ max(ceil) * ratio[i][j] for j in range(2) ]
 
        print("turn: " + str(i))
        print("votes: " + str(ratio[i][0]) + ":" + str(ratio[i][1]) )
        print("Temp: " +str(votesTemp[0])+":"+str(votesTemp[1]))
        
    print(sum(votesTemp))
 
if __name__ == '__main__':
  main()


import math

def cceil(x,y):
	res = x //y
	if x % y != 0:res += 1
	return res

def gcd(x, y):
	if(x == 0):return y
	return gcd(y % x, x)
 
def main():
    votes = int(input())
    ratio = [[ int(i) for i in input().split() ] for j in range(votes)]
 
    votesTemp = [0, 0]
    for i in range(votes):
        if i == 0:
            votesTemp = ratio[i]
            continue
        if(gcd(ratio[i][0], ratio[i][1]) != 1):
        	x = 1 / 0
        ceil = [ cceil(votesTemp[j], ratio[i][j]) for j in range(2)]
 
        votesTemp = [ max(ceil) * ratio[i][j] for j in range(2) ]
        
        #print("turn: " + str(i))
        #print("votes: " + str(ratio[i][0]) + ":" + str(ratio[i][1]) )
        #print("Temp: " +str(votesTemp[0])+":"+str(votesTemp[1]))
        
    print(sum(votesTemp))
 
if __name__ == '__main__':
  main()


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
from math import ceil
from decimal import *
n=int(input())
prea=1.0
pret=1.0
for i in range(n):
    
    t,a=map(Decimal,input().split())
    i=max(ceil(prea/a),ceil(pret/t))
    pret,prea=t*i,a*i

print(pret+prea)

from math import ceil
from decimal import *
n=int(input())
prea=Decimal("1.0")
pret=Decimal("1.0")
for i in range(n):
    
    t,a=map(Decimal,input().split())
    i=max(ceil(prea/a),ceil(pret/t))
    pret,prea=t*i,a*i

print(pret+prea)

Verdicts: Runtime Error

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
import math
N = int(input())
for i range(N):
  a,t = map(int,input().split())
  if i == 0:
    x,y = a,t
  else:
    xa = math.ceil(x/a)
    yb = math.ceil(y/b)
    c = max(xa,yb)
    x,y = a*c,b*c
print(x+y)

import math
N = int(input())
for i in range(N):
  a,t = map(int,input().split())
  if i == 0:
    x,y = a,t
  else:
    xa = math.ceil(x/a)
    yb = math.ceil(y/b)
    c = max(xa,yb)
    x,y = a*c,b*c
print(x+b)

import math
N = int(input())
for i range(N):
  a,t = map(int,input().split())
  if i == 0:
    x,y = a,t
  else:
    xa = math.ceil(x/a)
    yb = math.ceil(y/b)
    c = max(xa,yb)
    x,y = a*c,b*c
print(x+b)

N = int(input())
for i in range(N):
  a,t = map(int,input().split())
  if i == 0:
    x,y = a,t
  else:
    xa = x//a if x%a==0 else x//a+1
    yt = y//t if y%t==0 else y//t+1
    c = max(xa,yt)
    x,y = a*c,t*c
print(x+y)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
s = input()
hmp = 0
ans = 0
for i in s:
    if i == 'g' and hmp > 0:
        hmp -= 1
        ans += 1
    elif i == 'g':
        hmp += 1
    elif hmp > 0:
        hmp -= 1
    else:
        hmp += 1
        ans -= 1
print(ans)

def inpl(): return [int(i) for i in input().split()]
N = int(input())
t, a = 1, 1
for _ in range(N):
    Ti, Ai = inpl()
    n = max(-(-t//Ti), -(-a//Ai))
    t, a = n*Ti, n*Ai
print(t+a)

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
n=int(input())
c=2
cnt1=1
cnt2=1
for _ in range(n):
  t,a=map(int,input().split())
  i=c
  while i%(t+a)!=0:
    i+=1
  cnt1=i/(t+a)*t
  cnt2=i/(t+a)*a
  c=cnt1+cnt2
print(c)

n = int(input())
mt, ma = 1, 1
for t, a in (map(int, input().split()) for _ in range(n)):
    l = max((mt-1)//t, (ma-1)//a)  + 1
    mt, ma = l*t, l*a
print(mt+ma)
#copy code

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
s = input()

l = len(s)

point = 0
for a, b in zip(s[0::2], s[1::2]):
    if a == 'p':
        point -= 1
    if b == 'g':
        point += 1
print(point)


s = input()

l = len(s)

point = 0
for a, b in zip(s, s[1:]):
    if a == 'p':
        point -= 1
    if b == 'g':
        point += 1
print(point)


N = int(input())
v_T = 1
v_A = 1
for _ in range(N):
    t, a = list(map(int, input().split()))
    d = max(((-v_T)//t)*(-1), ((-v_A)//a)*(-1))
    v_T = d*t
    v_A = d*a


print(v_T+v_A)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
N = int(input())
x, y = 0
for i in range(N):
  a, b = map(int, input().split())
  mul = max((x-1)//a+1, (y-1)//b+1)
  x = mul*a
  y = mul*b
print(x+y)

N = int(input())
x, y = 0, 0
for i in range(N):
  a, b = map(int, input().split())
  mul = max((x-1)//a+1, (y-1)//b+1)
  x = mul*a
  y = mul*b
print(x+y)

N = int(input())
x, y = 1, 1
for i in range(N):
  a, b = map(int, input().split())
  mul = max((x+a-1)//a, (y+b-1)//b)
  x = mul*a
  y = mul*b
print(x+y)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
import math
from decimal import *

N = int(input())
_input = []
for i in range(N):
    _input.append(list(map(int,input().split())))

total_T = 1
total_A = 1

for t,a in _input:
    
    n = max(-(-t//Ti), -(-a//Ai))
    total_T = int(t*n)
    total_A = int(a*n)

print(total_A+total_T)


import math
from decimal import *

N = int(input())
_input = []
for i in range(N):
    _input.append(list(map(int,input().split())))

total_T = 1
total_A = 1

for t,a in _input:
    
    n = max(-(-total_T//t), -(-total_A//a))
    total_T = int(t*n)
    total_A = int(a*n)

print(total_A+total_T)


Verdicts: Runtime Error

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
N = int(input())
ratio = []
for _ in range(N):
    ratio.append(tuple(map(int, input().split())))
ans = 0; total_t = 0; total_a = 0;
for t, a in ratio:
    i = 1
    while total_t > t*i and total_a > a*i:
        i += 1
    ans = (t + a)*i
print(ans)

N = int(input())
ratio = []
for _ in range(N):
    ratio.append(tuple(map(int, input().split())))
ans = 0; total_t = 0; total_a = 0;
for t, a in ratio:
    i = 1
    while total_t > t*i and total_a > a*i:
        i += 1
    total_t = t*i
    total_a = a*i
    ans = total_t + total_a
print(ans)

N = int(input())
ratio = []
for _ in range(N):
    ratio.append(tuple(map(int, input().split())))
ans = 0; total_t = 0; total_a = 0;
for t, a in ratio:
    q = max(total_t  //  t, total_a // a) + 1
    total_t = t*q
    total_a = a*q
    ans = total_t + total_a
print(ans)

N = int(input())
ratio = []
for _ in range(N):
    ratio.append(tuple(map(int, input().split())))
total_t = 1; total_a = 1;
for t, a in ratio:
    q = max((total_t + t - 1) // t, (total_a + a - 1) // a)
    total_t = t*q
    total_a = a*q
ans = total_t + total_a
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
n = int(input())
ts, as = map(int, input().split())
for _ in range(n-1):
  t, a = map(int, input().split())
  m = max((ts-1)//t, (as-1)//a)+1
  ts = m*t
  as = m*a
print(ts+as)

n = int(input())
t2, a2 = map(int, input().split())
for _ in range(n-1):
  t, a = map(int, input().split())
  m = max((t2-1)//t, (a2-1)//a)+1
  t2 = m*t
  a2 = m*a
print(t2+a2)

Verdicts: Runtime Error

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):

def main():
    votes = int(input());
    ratio = [[ int(i) for i in input().split() ] for j in range(votes)]

    tak = aok = 0
    for i in range(votes):
        takTemp,  aokTemp = ratio[i][0], ratio[i][1]

        while tak > takTemp or aok > aokTemp:
            takTemp += ratio[i][0]
            aokTemp += ratio[i][1]

        tak, aok = takTemp, aokTemp

        print("turn:" + str(i))
        print("votes:" + str(ratio[i][0]) + ":" + str(ratio[i][1]) )
        print(tak, aok)


    print(tak + aok)

if __name__ == '__main__':
  main()



def main():
    votes = int(input());
    ratio = [[ int(i) for i in input().split() ] for j in range(votes)]

    tak = aok = 0
    for i in range(votes):
        takTemp,  aokTemp = ratio[i][0], ratio[i][1]

        while tak > takTemp or aok > aokTemp:
            takTemp += ratio[i][0]
            aokTemp += ratio[i][1]

        tak, aok = takTemp, aokTemp

        #print("turn:" + str(i))
        #print("votes:" + str(ratio[i][0]) + ":" + str(ratio[i][1]) )
        print(tak, aok)

if __name__ == '__main__':
  main()



def main():
    votes = int(input());
    ratio = [[ int(i) for i in input().split() ] for j in range(votes)]

    tak = aok = 0
    for i in range(votes):
        takTemp,  aokTemp = ratio[i][0], ratio[i][1]

        while tak > takTemp or aok > aokTemp:
            takTemp += ratio[i][0]
            aokTemp += ratio[i][1]

        tak, aok = takTemp, aokTemp

        #print("turn:" + str(i))
        #print("votes:" + str(ratio[i][0]) + ":" + str(ratio[i][1]) )
        print(tak, aok)


    print(tak + aok)

if __name__ == '__main__':
  main()


import math
from decimal import *

def main():
    votes = int(input())
    ratio = [[ int(i) for i in input().split() ] for j in range(votes)]

    votesTemp = [0, 0]
    for i in range(votes):
        if i == 0:
            votesTemp = ratio[i]
            continue

        ceil = [ math.ceil(Decimal(votesTemp[j]) / Decimal(ratio[i][j])) for j in range(2)]

        votesTemp = [ max(ceil) * ratio[i][j] for j in range(2) ]

        """
        print("turn: " + str(i))
        print("votes: " + str(ratio[i][0]) + ":" + str(ratio[i][1]) )
        print("Temp: " +str(votesTemp[0])+":"+str(votesTemp[1]))
        """
    print(sum(votesTemp))

if __name__ == '__main__':
  main()


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
taka, aoki = 1, 1
for _ in range(int(input())):
    a, b = map(int, input().split())
    ratio = max(-(-taka//a), -(-aoki//b))
    print(ratio)
    taka = ratio * a
    aoki = ratio * b
print(taka + aoki)

taka, aoki = 1, 1
for _ in range(int(input())):
    a, b = map(int, input().split())
    ratio = max(taka//a + [0, 1][taka%a != 0], aoki//b + [0, 1][aoki%b != 0])
    taka = a * ratio
    aoki = b * ratio
    print(taka, aoki)
print(taka + aoki)

T,A=1,1
for _ in range(int(input())):
    a,b=map(int,input().split())
    r=max(-(-T//a),-(-A//b))
    T=r*a
    A=r*b
print(T+A)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
n=int(input())
a,b=map(int,input().split())
for i in range(n-1):
    e,f=map(int,input().split())
    t=e
    k=f
    while e<a or f<b:
        t+=e
        k+=f
    a=t
    b=k
print(a+b)

from itertools import gcd
n=int(input())
a,b=map(int,input().split())
d=a+b
for i in range(n-1):
    e,f=map(int,input().split())
    d=d*(e+f)//gcd(d,e+f)
print(d)

from fractions import gcd
n=int(input())
a,b=map(int,input().split())
d=a+b
for i in range(n-1):
    e,f=map(int,input().split())
    d=d*(e+f)//gcd(d,e+f)
print(d)

n=int(input())
a,b=map(int,input().split())
for i in range(n-1):
    e,f=map(int,input().split())
    if (a//e+(1 if a%e!=0 else 0))*f>=b:
        b=f*(a//e+(1 if a%e!=0 else 0))
        a=e*(a//e+(1 if a%e!=0 else 0))
    else:
        a=e*(b//f+(1 if b%f!=0 else 0))
        b=f*(b//f+(1 if b%f!=0 else 0))
print(a+b)

Verdicts: Time Limit Exceeded

Runtime Error

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
A, B = 1, 1
for _ in range(int(input())):
    x, y = map(int, input().split())
    n = max(-(-A // x), -(-B // y))
    A, B = n * x, n * y

    print(A, B)

print(A + B)


A, B = 1, 1
for _ in range(int(input())):
    x, y = map(int, input().split())
    n = max(-(-A // x), -(-B // y))
    A, B = n * x, n * y

print(A + B)


Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
import math
N = int(input())
t= 1
a= 1

def t_small(t,a,t1,a1):
    gain = -(-t//t1)
    t = gain*t1
    a_tmp=gain*a1
    if a_tmp<a:
        gain_a = -(-a//a_tmp)
        t *= gain_a
        a = a_tmp*gain_a
    else:
        a = a_tmp
    return t,a,t+a

def a_small(t,a,t1,a1):
    gain = -(-a//a1)
    a = gain*a1
    t_tmp=gain*t1
    if t_tmp<t:
        gain_t = -(-t//t_tmp)
        a *= gain_t
        t = t_tmp*gain_t
    else:
        t = t_tmp
    return t,a,t+a

ans = 0
for _ in range(N):
    t1,a1 = map(int,input().split())
    tt1,aa1,sta1 = t_small(t,a,t1,a1)
    tt2,aa2,sta2 = a_small(t,a,t1,a1)
    if sta1<=sta2:
        t=tt1;a=aa1,ans = sta1
    else:
        t=tt2,a=aa2,ans=sta2
print(ans)

import math
N = int(input())
t= 1
a= 1

def t_small(t,a,t1,a1):
    gain = -(-t//t1)
    t = gain*t1
    a_tmp=gain*a1
    if a_tmp<a:
        gain_a = -(-a//a_tmp)
        t *= gain_a
        a = a_tmp*gain_a
    else:
        a = a_tmp
    return t,a,t+a

def a_small(t,a,t1,a1):
    gain = -(-a//a1)
    a = gain*a1
    t_tmp=gain*t1
    if t_tmp<t:
        gain_t = -(-t//t_tmp)
        a *= gain_t
        t = t_tmp*gain_t
    else:
        t = t_tmp
    return t,a,t+a

ans = 0
for _ in range(N):
    t1,a1 = map(int,input().split())
    tt1,aa1,sta1 = t_small(t,a,t1,a1)
    tt2,aa2,sta2 = a_small(t,a,t1,a1)
    if sta1<=sta2:
        t=tt1;a=aa1;ans = sta1
    else:
        t=tt2;a=aa2;ans=sta2
print(ans)


Verdicts: Runtime Error

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
import math
N = int(input())
ans = 2
tp, ap = 0, 0
for i in range(N):
    
    t, a = map(int, input().split())
    k = max(math.ceil(tp/t), math.ceil(ap/a))
    t, a = t*k, a*k
    c = math.ceil(ans/(t+a))
    while True:
        if (t+a)*c >= ans:
            ans = (t+a)*c
            break
        c += 1
    tp, ap = t*c, a*c
print(ans)

n = int(input())
t = []
a = []
for i in range(n):
    c = list(map(int,input().split()))
    t.append(c[0])
    a.append(c[1])
for i in range(n-1):
    d = max(1,-(-t[i]//t[i+1]),-(-a[i]//a[i+1]))
    t[i+1] =t[i+1]*d
    a[i+1] =a[i+1]*d
print(t[-1]+a[-1])

Verdicts: Runtime Error

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
import math
def  results(a,b):
    return (a+b-1//b)
 
n=int(input())
t,a=map(int,input().split())
for i in range(1,n):
    ti,ai=map(int,input().split())
    if ti<=t or ai<=a:
        k=max(results(t,ti),results(a,ai))
        t=k*ti
        a=k*ai
    else:
        t=ti
        a=ai
    #print(t,a)
print(t+a)
 

import math
def  results(a,b):
    return ((a+b-1)//b)
 
n=int(input())
t,a=map(int,input().split())
for i in range(1,n):
    ti,ai=map(int,input().split())
    if ti<=t or ai<=a:
        k=max(results(t,ti),results(a,ai))
        t=k*ti
        a=k*ai
    else:
        t=ti
        a=ai
    #print(t,a)
print(t+a)

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 0,0
for i in range(n):
    tmp = max(p//t[i]+1,q//a[i]+1)
    p = t[i]*tmp 
    q = a[i]*tmp
print(p+q)  

n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 0,0
for x,y in t,a:
    tmp = max(p//x,q//y)
    p = x*tmp 
    q = y*tmp
print(p+q)  

n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 0,0
for zip(x,y) in t,a:
    tmp = max(p//x,q//y)
    p = x*tmp 
    q = y*tmp
print(p+q)  

n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 0,0
for i in range(n):
    tmp = max(p//t[i],q//a[i])
    p = t[i]*tmp 
    q = a[i]*tmp
print(p+q)  

n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 1,1
for i in range(n):
    tmp = max(-(-p//t[i]),-(-q//a[i]))
    p = t[i]*tmp 
    q = a[i]*tmp
print(p+q)  

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
n=int(input())
m=0
for _ in range(n):
  a,b=map(int,input().split())
  m=(m%(a+b)+m%(a+b)>0)*(a+b)
print(m)

n=int(input())
m=2
for _ in range(n):
  a,b=map(int,input().split())
  m=(m%(a+b)+m%(a+b)>0)*(a+b)
print(m)

n=int(input())
m=2
for _ in range(n):
  a,b=map(int,input().split())
  m=(m//(a+b)+m%(a+b)>0)*(a+b)
print(m)

n=int(input())
a0,b0=1,1
for _ in range(n):
  a,b=map(int,input().split())
  k=max(a0//a+a0%a>0,b0//b+b0%b>0)
  a0,b0=a*k,b*k
print(a0+b0)

n=int(input())
a0,b0=1,1
for _ in range(n):
  a,b=map(int,input().split())
  k=max(a0//a+(a0%a>0),b0//b+(b0%b>0))
  a0,b0=a*k,b*k
print(a0+b0)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
import math
n=int(input())
log=[]
H=[]
for i in range(n):
    log.append(tuple(map(int,input().split())))
t,a=1,1
for x,y in log:
    nxt=max((t/x+0.5)//1,(a/y+0.5)//1)
    t=x*nxt
    a=y*nxt
print(t+a)

from decimal import *
n=int(input())
log=[]
H=[]
for i in range(n):
    log.append(tuple(map(int,input().split())))
t,a=1,1
for x,y in log:
    nxt=max(t//x + (1 if t%x else 0),a//y + (1 if a%y else 0))
    t=x*nxt
    a=y*nxt
print(t+a)

Verdicts: Wrong Answer

Accepted
Problem: AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time.  Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.

Submission attempts (in order):
N = int(input())
P = [0,0]

for i in range(N):
  Q = list(map(int,input().split()))
  t = Q[0]
  a = Q[1]
  m = max(P[0]/t,P[1]/a)
  while True:
    t = Q[0] * m
    a = Q[1] * m
    if t >= P[0] and a >= P[1]:
      P[0] = t
      P[1] = a
      break
    m += 1

print(sum(P))

N = int(input())
P = [0,0]

for i in range(N):
  Q = list(map(int,input().split()))
  t = Q[0]
  a = Q[1]
  m = max(P[0]//t,P[1]//a)
  while True:
    t = Q[0] * m
    a = Q[1] * m
    if t >= P[0] and a >= P[1]:
      P[0] = t
      P[1] = a
      break
    m += 1

print(sum(P))

N = int(input())
P = [1,1]

for i in range(N):
  Q = list(map(int,input().split()))
  t = Q[0]
  a = Q[1]
  m = max(P[0]//t,P[1]//a,1)
  while True:
    t = Q[0] * m
    a = Q[1] * m
    if t >= P[0] and a >= P[1]:
      P[0] = t
      P[1] = a
      break
    m += 1

print(sum(P))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition:  (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock).  Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors.  _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_  With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score.  The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn.

Submission attempts (in order):
s = input()

subsg = []
subsp = []

sg = 0
sp = 0
ans = 0
for i in range(N):
    if s[i] == 'g':
        sg += 1
    else:
        sp += 1
    subsg.append(sg)
    subsp.append(sp)

for i in range(N):
    if subsp <= subsg:
        ans += 1
    
print(ans)

s = input()

sg = 0
sp = 0
ans = 0

for i in range(len(s)):
    if sp+1 <= sg and s[i] == 'g':
        sp += 1
        ans += 1
    elif sp+1 > sg and s[i] == 'p':
        sg += 1
        ans -= 1
    elif sp+1 <= sg and s[i] == 'p':
        sp += 1
    else:
        sg += 1
print(ans)


Verdicts: Runtime Error

Accepted