Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
A = list(map(int, input().split()))

ans = max(N - sum(A))
print(ans)

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

ans = N - sum(A)
print(max(ans,-1))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations

def check(l1,l2,l3):
    count = 0
    for n2 in l2:
        for n1 in l1:
            if n1 > n2:
                break
            z = 2*n2 - n1
            for n3 in l3[::-1]:
                if n2 > n3:
                    break
                if n3 != z:
                    count += 1
    return count

N = int(input())
S = input()
Rlist, Glist, Blist = [],[],[]
for x in range(N):
    if S[x] == 'R':
        Rlist.append(x)
    elif S[x] == 'G':
        Glist.append(x)
    else:
        Blist.append(x)
    
ans = 0
for p in permutations([Rlist,Glist,Blist]):
    ans += check(p[0],p[1],p[2])
print(ans)

Fixed submission:
N = int(input())
S = 'X' + input()

cnt_R, cnt_G, cnt_B = 0, 0, 0
for s in S[1:]:
    if s == 'R':
        cnt_R += 1
    elif s == 'G':
        cnt_G += 1
    elif s == 'B':
        cnt_B += 1

ans = cnt_R * cnt_G * cnt_B

for i in range(1,N-1):
    for j in range(i+1,N):
        k = 2*j - i
        if k > N:
            break
        
        a = S[i]; b = S[j]; c = S[k]
        if a != b and b != c and c != a:
            ans -= 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
q = int(input())

reverse = False
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        reverse = not reverse
    else:#2
        if query[1] == '1':
            if reverse:
                S = S + query[2]
            else:
                S = query[2] + S
        else:
            if reverse:
                S = query[2] + S
            else:
                S = S + query[2]
print(S[::-1] if reverse else S)

Fixed submission:
from collections import deque

S = deque(input())
q = int(input())

reverse = False
for _ in range(q):
    query = input().split()
    if query[0] == '1':
        reverse = not reverse
    else:#2
        if query[1] == '1':
            if reverse:
                S.append(query[2])
            else:
                S.appendleft(query[2])
        else:
            if reverse:
                S.appendleft(query[2])
            else:
                S.append(query[2])

if reverse:
    while S:
        print(S.pop(), end='')
else:
    while S:
        print(S.popleft(), end='')
Buggy python submission (verdict: Time Limit Exceeded):
def numerator(x):
    return x * (x + 1) // 2

N,K = map(int, input().split())
P = list(map(int, input().split()))

ACC = 1
for p in P:
    ACC *= p

R = 0
for p in P[:K]:
    R += numerator(p) * ACC // p

max_value = R
for i in range(N-K):
    R += numerator(P[i+K]) * ACC // P[i+K] - numerator(P[i]) * ACC // P[i]
    max_value = max(max_value, R)
print(max_value / ACC)


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

#期待値 : (p+1)//2
range_total = sum(P[:K]) + K
max_value = range_total
for i in range(N-K):
    range_total += P[K+i] - P[i]
    max_value = max(max_value, range_total)
print(max_value / 2)

Buggy python submission (verdict: Time Limit Exceeded):
def numerator(x):
    return x * (x + 1) // 2

N,K = map(int, input().split())
P = list(map(int, input().split()))

ACC = 1
for p in P:
    ACC *= p

R = 0
for p in P[:K]:
    R += numerator(p) * ACC // p

max_value = R
for i in range(N-K):
    R += numerator(P[i+K]) * ACC // P[i+K] - numerator(P[i]) * ACC // P[i]
    max_value = max(max_value, R)
print(max_value / ACC)

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

#期待値 : (p+1)//2
range_total = sum(P[:K]) + K
max_value = range_total
for i in range(N-K):
    range_total += P[K+i] - P[i]
    max_value = max(max_value, range_total)
print(max_value / 2)
Buggy python submission (verdict: Time Limit Exceeded):
#2020.07.13
N = int(input())
S = input()
ans = 0
for number in range(1000):
    strnum = str(number).zfill(3)
    a,b,c = list(strnum)
    
    for i in range(N-2):
        if a != S[i]:
            continue
        
        flag = False
        
        for j in range(i+1, N-1):
            if b != S[j]:
                continue
            
            if c in S[j+1:]:
                ans += 1
                flag = True
                break
        
        if flag:
            break
print(ans)

Fixed submission:
N = int(input())
S = input()

count = 0
numberlist = [str(i) for i in range(10)]

for a in numberlist:
    idx1 = S.find(a)
    if idx1 == -1 or idx1 >= N - 2:
        continue
    
    for b in numberlist:
        idx2 = S[idx1+1:].find(b)
        if idx2 == -1 or idx2 >= N - 1:
            continue

        count += len(set(S[idx1+idx2+2:]))

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
N = int(input())
S = list(input())
a = set()
for data in combinations(S, 3):
    a.add(''.join(data))
print(len(a))

Fixed submission:
N = int(input())
S = input()

count = 0
numberlist = [str(i) for i in range(10)]

for a in numberlist:
    idx1 = S.find(a)
    if idx1 == -1 or idx1 >= N - 2:
        continue
    
    for b in numberlist:
        idx2 = S[idx1+1:].find(b)
        if idx2 == -1 or idx2 >= N - 1:
            continue

        count += len(set(S[idx1+idx2+2:]))

print(count)
Buggy python submission (verdict: Runtime Error):
N,Q = map(int, input().split())
childlist = [[] for _ in range(N+1)]

for _ in range(N-1):
    a, b = map(int, input().split())
    childlist[a].append(b)

pointlist = [0]*(N+1)
for _ in range(Q):
    p, x = map(int, input().split())
    pointlist[p] += x

def DFS(v):
    if not checkedlist[v]:
        checkedlist[v] = True
        
        global point
        point += pointlist[v]
        for child in childlist[v]:
            DFS(child)
        
        totallist[v] = point
        point -= pointlist[v]
        
totallist = [0]*(N+1)
checkedlist = [False]*(N+1)
point = 0
for i in range(1,N+1):
    if not checkedlist[i]:
        DFS(i)

print(*totallist[1:])

Fixed submission:
from sys import stdin, setrecursionlimit
input = stdin.readline

setrecursionlimit(10**6)

N,Q = map(int, input().split())
neighborlist = [[] for _ in range(N+1)]

for _ in range(N-1):
    a, b = map(int, input().split())
    neighborlist[a].append(b)
    neighborlist[b].append(a)

pointlist = [0]*(N+1)
for _ in range(Q):
    p, x = map(int, input().split())
    pointlist[p] += x

def DFS(v):
    if not checkedlist[v]:
        checkedlist[v] = True
        
        global point
        point += pointlist[v]
        for neighbor in neighborlist[v]:
            DFS(neighbor)
        
        totallist[v] = point
        point -= pointlist[v]
        
totallist = [0]*(N+1)
checkedlist = [False]*(N+1)
point = 0
for i in range(1,N+1):
    if not checkedlist[i]:
        DFS(i)

print(*totallist[1:])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
input = stdin.readline

class Unionfind():
    def __init__(self,n):
        self.n = n
        self.parent = [-1]*n
    
    def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 0
        if self.parent[x] < self.parent[y]:
            x,y = y,x
        
        total_unite_island = self.parent[x] * self.parent[y]
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return total_unite_island

N,M = map(int, input().split())
A = [0]*M; B = [0]*M
for i in range(M):
    A[i], B[i] = map(lambda x: int(x) - 1, input().split())

uf = Unionfind(N)
inconvenience = N * (N-1) // 2
inconvenience_list = [0]*M
inconvenience_list[M-1] = inconvenience
for i in range(M-1,0,-1):
    inconvenience -= uf.union(A[i],B[i])
    inconvenience_list[i-1] = inconvenience
for i in range(M):
    print(inconvenience_list[i])

Fixed submission:
from sys import stdin, setrecursionlimit
input = stdin.readline
setrecursionlimit(10**8)

class Unionfind():
    def __init__(self,n):
        self.n = n
        self.parent = [-1]*n
    
    def find(self,x):
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return 0
        if self.parent[x] < self.parent[y]:
            x,y = y,x
        
        total_unite_island = self.parent[x] * self.parent[y]
        self.parent[x] += self.parent[y]
        self.parent[y] = x
        return total_unite_island

N,M = map(int, input().split())
A = [0]*M; B = [0]*M
for i in range(M):
    A[i], B[i] = map(lambda x: int(x) - 1, input().split())

uf = Unionfind(N)
inconvenience = N * (N-1) // 2
inconvenience_list = [0]*M
inconvenience_list[M-1] = inconvenience
for i in range(M-1,0,-1):
    inconvenience -= uf.union(A[i],B[i])
    inconvenience_list[i-1] = inconvenience
for i in range(M):
    print(inconvenience_list[i])
Buggy python submission (verdict: Runtime Error):
#メモ化再起
N = int(input())
H = list(map(int, input().split()))

INF = 10**4 + 1
minlist = [INF]*N
def minstepsearch(i):
    if i == 0:
        minlist[i] = 0
        return 0
    
    minlist[i] = min(minlist[i], minstepsearch(i-1) + abs(H[i] - H[i-1]))
    if i > 1:
        minlist[i] = min(minlist[i], minstepsearch(i-2) + abs(H[i] - H[i-2]))
    return minlist[i]

print(minstepsearch(N-1))

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

minlist = [0]*N
minlist[0] = 0
minlist[1] = abs(H[1] - H[0])
for i in range(2,N):
    minlist[i] = min(minlist[i-2] + abs(H[i-2] - H[i]), minlist[i-1] + abs(H[i-1] - H[i]))

print(minlist[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))

INF = 10**10
lis = [INF]*N
lis[0] = 0
for i in range(1, N):
    H_i = H[i]
    for j in range(max(0, i-K), i):
        lis[i] = min(lis[j] + abs(H[j] - H_i), lis[i])
print(lis[N-1])

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

INF = 10**9 + 1
L = [INF]*N
L[0] = 0
for i in range(1, N):
    minLi = L[i]
    H_i = H[i]
    for k in range(1, K+1):
        if i - k >= 0:
            minLi = min(minLi, L[i-k] + abs(H_i - H[i-k]))
    L[i] = minLi
print(L[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))

INF = 10**9 + 1
L = [INF]*N
L[0] = 0
for i in range(1, N):
    minLi = L[i]
    H_i = H[i]
    for k in range(1, K+1):
        if i - k >= 0:
            minLi = min(minLi, L[i-k] + abs(H_i - H[i-k]))
    L[i] = minLi
print(L[N-1])

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

INF = 10**9 + 1
L = [INF]*N
L[0] = 0
for i in range(1, N):
    minLi = L[i]
    H_i = H[i]
    for k in range(1, K+1):
        if i - k >= 0:
            minLi = min(minLi, L[i-k] + abs(H_i - H[i-k]))
    L[i] = minLi
print(L[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H = list(map(int, input().split()))

INF = 10**9 + 1
L = [INF]*N
L[0] = 0
for i in range(1, N):
    for k in range(1, K+1):
        if i - k >= 0:
            L[i] = min(L[i], L[i-k] + abs(H[i] - H[i-k]))
print(L[N-1])

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

INF = 10**9 + 1
L = [INF]*N
L[0] = 0
for i in range(1, N):
    minLi = L[i]
    H_i = H[i]
    for k in range(1, K+1):
        if i - k >= 0:
            minLi = min(minLi, L[i-k] + abs(H_i - H[i-k]))
    L[i] = minLi
print(L[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int, input().split())
w = [0]*(N+1); v = [0]*(N+1);
for i in range(1, N+1):
    w[i], v[i] = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1, N+1):
    dp_i = dp[i]
    dp_i_1 = dp[i-1]
    w_i = w[i]
    v_i = v[i]
    for sum_w in range(1, W+1):
        if sum_w - w_i >= 0:
            dp_i[sum_w] = max(dp_i_1[sum_w - w_i] + v_i, dp_i_1[sum_w])
        else:
            dp_i[sum_w] = dp_i_1[sum_w]
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
v = [0]*(N+1); w = [0]*(N+1)
for i in range(1, N+1):
    a, b = map(int, input().split())
    w[i], v[i] = a, b

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1, N+1):
    row = dp[i]; row_before = dp[i-1]
    v_i = v[i]; w_i = w[i]
    for sum_w in range(1, W+1):
        if sum_w - w_i >= 0:
            row[sum_w] = max(row_before[sum_w - w_i] + v_i, row_before[sum_w])
        else:
            row[sum_w] = row_before[sum_w]
print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
v = [0]*(N+1); w = [0]*(N+1)
for i in range(1, N+1):
    a, b = map(int, input().split())
    w[i], v[i] = a, b

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1, N+1):
    row = dp[i]; row_before = dp[i-1]
    v_i = v[i]; w_i = w[i]
    for sum_w in range(1, W+1):
        if sum_w - w_i >= 0:
            row[sum_w] = max(row_before[sum_w - w_i] + v_i, row_before[sum_w])
        else:
            row[sum_w] = row_before[sum_w]
print(dp[N][W])

Fixed submission:
N, W = map(int, input().split())
v = [0]*(N+1); w = [0]*(N+1)
for i in range(1, N+1):
    a, b = map(int, input().split())
    w[i], v[i] = a, b

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(1, N+1):
    row = dp[i]; row_before = dp[i-1]
    v_i = v[i]; w_i = w[i]
    for sum_w in range(1, W+1):
        if sum_w - w_i >= 0:
            row[sum_w] = max(row_before[sum_w - w_i] + v_i, row_before[sum_w])
        else:
            row[sum_w] = row_before[sum_w]
print(dp[N][W])
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right

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

A.sort()
B.sort()
C.sort()

cnt = 0
a_left = 0
c_left = 0
for i in range(N):
    b = B[i]
    a_left += bisect_left(A[a_left:], b)
    c_left += bisect_right(C[c_left:], b)
    cnt += a_left * (N - c_left)
print(cnt)

Fixed submission:
from bisect import bisect_left, bisect_right

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

A.sort()
C.sort()

cnt = 0
for b in B:
    cnt += bisect_left(A, b) * (N - bisect_right(C, b))
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right

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

A.sort()
B.sort()
C.sort()

cnt = 0
a_left = 0
c_left = 0
for i in range(N):
    b = B[i]
    a_left += bisect_left(A[a_left:], b)
    c_left += bisect_right(C[c_left:], b)
    cnt += a_left * (N - c_left)
print(cnt)

Fixed submission:
from bisect import bisect_left, bisect_right

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

A.sort()
C.sort()

cnt = 0
for b in B:
    cnt += bisect_left(A, b) * (N - bisect_right(C, b))
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
#import math
N = int(input())
N_C = []
ans = 0

for i in range(1,N):
    N_C.append(N-i)
#print(N_C)

for i in N_C:
    for j in range(1,i+i):
        k=i//j
        if j*k == i:
            ans +=1

print(ans)

Fixed submission:
N = int(input())
ans = 0
for a in range(1,N):
    ans += (N-1)//a
print(ans)
Buggy python submission (verdict: Runtime Error):
print(['0','1'][x==1])

Fixed submission:
x=int(input())
print(['1','0'][x==1])
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
a = []
ans = 0
for i in range(len(S)-2):
    if S[i]==T[0]:
        ans+=1
        if S[i+1]==T[1]:
            ans+=1
            if S[i+2]==T[2]:
                ans+=1
    a.append(ans)
    ans=0
print(len(T)-max(a))

Fixed submission:
S = input()
T = input()
a = []
ans = 0
for i in range(len(S)-len(T)+1):
    C = S[i:i+len(T)]
    for j in range(len(T)):
        if C[j] == T[j]:
            ans+=1
    a.append(ans)
    ans=0
print(len(T)-max(a))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = int(input())
A = list(map(int,input().split()))
#Aa=[]
#for i in A:
    #Aa.append(i%(10**9+7))
#print(Aa)
ans = 0

for i,j in itertools.combinations(A,2):
    #print(i,j)
    ans += i*j
    #print(ans)

print(ans%(10**9+7))

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

MOD = 10**9+7
S = sum(A)
ans = 0

for i in range(N-1):
    S -= A[i]
    ans = (ans + S*A[i])%MOD
    
print(ans)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_right

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
#a,bの累積和
a_sum = [0]
b_sum = [0]
for i in range(N):
    a_sum.append(a_sum[i]+a[i])
for i in range(M):
    b_sum.append(b_sum[i]+b[i])

ans = 0
#Aについて0-N冊読む場合の全探索
for i in range(N+1):
    cntA = i #Aをi冊読む
    rest = K - a_sum[i]#残り時間rest分
    if rest < 0:
        break
    cntB = bisect_right(b_sum,rest)-1 #Bで読むことができる冊数を二分探索で求める
    ans = max(ans,cntA + cntB)
    print(ans)
print(ans)

Fixed submission:
from bisect import bisect_right

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
#a,bの累積和
A_sum = [0]
B_sum = [0]
for i in range(N):
    A_sum.append(A_sum[i]+A[i])
for i in range(M):
    B_sum.append(B_sum[i]+B[i])

ans = 0
#Aについて0-N冊読む場合の全探索
for i in range(N+1):
    cntA = i #Aをi冊読む
    rest = K - A_sum[i] #残り時間rest分
    if rest < 0:
        break
    cntB = bisect_right(B_sum,rest)-1 #Bで読むことができる冊数を二分探索で求める
    ans = max(ans,cntA + cntB)
print(ans)

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_right

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
#a,bの累積和
a_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i]+a[i])
b_sum = [0]
for i in range(n):
    b_sum.append(b_sum[i]+b[i])

ans = 0
#Aについて0-N冊読む場合の全探索
for i in range(n+1):
    cntA = i #Aをi冊読む
    rest = k - a_sum[i]#残り時間rest分
    if rest < 0:
        break
    cntB = bisect_right(b_sum,rest)-1 #Bで読むことができる冊数を二分探索で求める
    ans = max(ans,cntA + cntB)
print(ans)

Fixed submission:
from bisect import bisect_right

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
#a,bの累積和
A_sum = [0]
B_sum = [0]
for i in range(N):
    A_sum.append(A_sum[i]+A[i])
for i in range(M):
    B_sum.append(B_sum[i]+B[i])

ans = 0
#Aについて0-N冊読む場合の全探索
for i in range(N+1):
    cntA = i #Aをi冊読む
    rest = K - A_sum[i] #残り時間rest分
    if rest < 0:
        break
    cntB = bisect_right(B_sum,rest)-1 #Bで読むことができる冊数を二分探索で求める
    ans = max(ans,cntA + cntB)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
chars = 'Xabcdefghijklmnopqrstuvwxyz'
res = ''
while True:
    x = n%26 #最下位の位の文字を求める(係数が26でない最下位の位が余りとして出せる)
    if x == 0:#Xが26のときのみ余り0で対応させるため26に書き換え
        x = 26
    res += chars[x]#文字を正解リストに追加
    n -= x　#xを左辺に持っていって右辺で10の位以上の数値を調べる
    if n == 0 :
        break
    n //= 26 #n-xは必ず26の倍数になっている。(xを移項しているから自明)
    #最下位の位を余りとして扱うために26で割って係数を消している。
print(res[::-1])#resには1の位が一番初めに入っているので、反転させて表示

Fixed submission:
n = int(input())
chars = 'Xabcdefghijklmnopqrstuvwxyz'
res = ''
while True:
    x = n%26
    if x == 0:
        x = 26
    res += chars[x]
    n -= x
    if n == 0 :
        break
    n //= 26
print(res[::-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
al = list(map(int,input().split()))
al_p = 1

for i in range(n):
    al_p *= al[i]
    if al_p > 10**18:
        print(-1)
        return
        
print(al_p)
    

Fixed submission:

def main():
    n = int(input())
    al = list(map(int,input().split()))
    al_p = 1

    if 0 in al:
        print(0)
        return

    for i in range(n):
        al_p *= al[i]
        if al_p > 10**18:
            print(-1)
            return
        
    print(al_p)

main()

Buggy python submission (verdict: Runtime Error):
n = int(input())
al = list(map(int,input().split()))
al_p = 1

for i in range(n):
    al_p *= al[i]
    if al_p > 10*18:
        print(-1)
        return
        
print(al_p)

Fixed submission:

def main():
    n = int(input())
    al = list(map(int,input().split()))
    al_p = 1

    if 0 in al:
        print(0)
        return

    for i in range(n):
        al_p *= al[i]
        if al_p > 10**18:
            print(-1)
            return
        
    print(al_p)

main()

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
al = list(map(int,input().split()))
al_p = 1

for i in range(n):
    al_p *= al[i]
print(['-1',al_p][al_p <= 10**18])
    

Fixed submission:

def main():
    n = int(input())
    al = list(map(int,input().split()))
    al_p = 1

    if 0 in al:
        print(0)
        return

    for i in range(n):
        al_p *= al[i]
        if al_p > 10**18:
            print(-1)
            return
        
    print(al_p)

main()
Buggy python submission (verdict: Runtime Error):
s,t = input().split()
if s == t[:-1]:
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s,t = input().split()
if s in t and len(t) == len(s) + 1:
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s,t = input().split()
if s in t:
    print('Yes')
else:
    print('No')
    

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s,t = list(input().split())
if s in t:
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
cnt = []
for j in range(1,N+1):
    print(A.count(j))



Fixed submission:
N = int(input())
A = list(map(int,input().split()))
cnt = [0]*N

for a in A:
    cnt[a-1] += 1
print('\n'.join(map(str,cnt)))
#count()ではTLE

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
cnt = []
for j in range(1,N+1):
        cnt.append(A.count(j))
for ko in cnt:
    print(ko)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
cnt = [0]*N

for a in A:
    cnt[a-1] += 1
print('\n'.join(map(str,cnt)))
#count()ではTLE
Buggy python submission (verdict: Time Limit Exceeded):
import math
ans = 0
c = 0
K = int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        for m in range(1,K+1):
            c = math.gcd(i,j)
            ans += math.gcd(c,m) 
print(ans)
            

Fixed submission:
import math
ans = 0
c = 0
K = int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        c = math.gcd(i,j)
        for m in range(1,K+1):
            ans += math.gcd(c,m) 
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
l = []

def append():
    for i in range(a):
        l.append("b")
        if len(l)==n:
            return
    for k in range(b):
        l.append("r")
        if len(l)==n:
            return
    if len(l)<n:
        append()
    return
append()

#print(l)
print(l.count('b'))
    

Fixed submission:
n,a,b = map(int,input().split())
print(n//(a+b)*a+min(n%(a+b),a))