Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
H,W,h,w=map(int,input().split())
p=(10**9-1)//(h*w-1)
m=p*(h*w-1)+1
vec=[[p for i in range(W+1)] for j in range(H+1)]
sm=0
for i in range(1,H+1):
  for j in range(1,W+1):
    if i%h==0 and j%w==0:
      vec[i][j]=-m
    sm+=vec[i][j]
if sm<=0:
  print("No")
else:
  print("Yes")
  for i in range(1,H+1):
    for j in range(1,W+1):
      print(vec[i][j],end=" \n"[j==W])

Fixed submission:
H,W,h,w=map(int,input().split())
p=(10**9-1)//(max(h*w-1,1))
m=p*(h*w-1)+1
vec=[[p for i in range(W+1)] for j in range(H+1)]
sm=0
for i in range(1,H+1):
  for j in range(1,W+1):
    if i%h==0 and j%w==0:
      vec[i][j]=-m
    sm+=vec[i][j]
if sm<=0:
  print("No")
else:
  print("Yes")
  for i in range(1,H+1):
    for j in range(1,W+1):
      print(vec[i][j],end=" \n"[j==W])
Buggy python submission (verdict: Runtime Error):
def(a,b,c):
  if a%2+b%2+c%2>0:
    return 0
  if a==b==c:
    return -1
  return f((b+c)//2,(c+a)//2,(a+b)//2)+1

a,b,c=map(int,input().split())
print(f(a,b,c))

Fixed submission:
def f(a,b,c):
  if a%2+b%2+c%2>0:
    return 0
  if a==b==c:
    return -1
  return f((b+c)//2,(c+a)//2,(a+b)//2)+1

a,b,c=map(int,input().split())
print(f(a,b,c))
Buggy python submission (verdict: Runtime Error):
n=int(input())
i=int(sqrt(n))//2
while(i*(i+1)//2<n):
  i+=1
print(i)

Fixed submission:
n=int(input())
i=int(n**0.5)//2
while(i*(i+1)//2<n):
  i+=1
print(i)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input()split())
print(min(abs(a-b),abs(a+b)+1))

Fixed submission:
a,b=map(int,input().split())
print(min(max(b-a,-b+a+2),abs(a+b)+1))
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input().split()))
ans=min(a[0],a[3],a[4])
a[0]-=ans
a[3]-=ans
a[4]-=ans
ans*=3
if(ans>0&&(a[0]%2+a[3]%2+a[4]%2==2)):
  ans+=1
ans+=(a[0]//2*2)+(a[3]//2*2)+(a[4]//2*2)+a[1]
print(ans)


Fixed submission:
a=list(map(int,input().split()))
ans=min(a[0],a[3],a[4])
a[0]-=ans
a[3]-=ans
a[4]-=ans
ans*=3
if(ans>0 and (a[0]%2+a[3]%2+a[4]%2==2)):
  ans+=1
ans+=(a[0]//2*2)+(a[3]//2*2)+(a[4]//2*2)+a[1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  print(sum(a)-a[p]+x)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  print(sum(a)-a[p-1]+x)
Buggy python submission (verdict: Runtime Error):
a=input()
cnt=0
for i in range(len(a)-1):
  if(a[i]==a[i+1]):
    cnt+=1
print(cmt)

Fixed submission:
a=input()
cnt=0
for i in range(len(a)-1):
  if(a[i]!=a[i+1]):
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input()split()))
s=max(a)
print(max(2*s-n-1))

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=max(a)
print(max(2*s-n-1,0))
Buggy python submission (verdict: Runtime Error):
a=map(int(input()))
print(((a[1]-1)**(a[0]-1))*a[1])

Fixed submission:
a=list(map(int,input().split()))
print(((a[1]-1)**(a[0]-1))*a[1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1, N):
    ans += (N-1) // i

print(ans)
N = int(input())
ans = 0
for i in range(1, N):
    ans += (N-1) // i

print(ans)


Fixed submission:
N = int(input())
ans = 0
for i in range(1, N):
    if N % i == 0:
        ans += (N // i) - 1
    else:
        ans += N // i

print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())

if x == 0:
    print(1)
else x == 1:
    print(0)


Fixed submission:
x = int(input())

if x == 0:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7

ans = 0
for i in range(n-1):
    for j in range(i+1, n):
        ans += a[i] * a[j] % mod

print(ans % mod)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7

ans = 0

sum_j = [0] * n
sum_tmp = 0

for i in reversed(range(n)):
    sum_tmp += a[i]
    sum_j[i] = sum_tmp

for i in range(n-1):
    ans += a[i] * sum_j[i+1] % mod

print(ans % mod)
Buggy python submission (verdict: Time Limit Exceeded):
h, w, m = map(int, input().split())
h_cnt = [0] * h
w_cnt = [0] * w

bomb_list = []

for i in range(m):
    h_, w_ = map(int, input().split())
    h_ -= 1
    w_ -= 1
    h_cnt[h_] += 1
    w_cnt[w_] += 1
    bomb_list.append((h_, w_))

max_h = max(h_cnt)
max_h_idx = []
for i in range(h):
    if h_cnt[i] == max_h:
        max_h_idx.append(i)

max_w = max(w_cnt)
max_w_idx = []
for i in range(w):
    if w_cnt[i] == max_w:
        max_w_idx.append(i)

minus = -1
for i in max_h_idx:
    for j in max_w_idx:
        if (i, j) not in bomb_list:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)


Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0] * h
w_cnt = [0] * w

bomb_set = set()

for i in range(m):
    h_, w_ = map(int, input().split())
    h_ -= 1
    w_ -= 1
    h_cnt[h_] += 1
    w_cnt[w_] += 1
    bomb_set.add((h_, w_))

max_h = max(h_cnt)
max_h_idx = []
for i in range(h):
    if h_cnt[i] == max_h:
        max_h_idx.append(i)

max_w = max(w_cnt)
max_w_idx = []
for i in range(w):
    if w_cnt[i] == max_w:
        max_w_idx.append(i)

minus = -1
for i in max_h_idx:
    for j in max_w_idx:
        if (i, j) not in bomb_set:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)

Buggy python submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
h_cnt = [0] * h
w_cnt = [0] * w

mat = [[0] * w for i in range(h)]

for i in range(m):
    h_, w_ = map(int, input().split())
    h_ -= 1
    w_ -= 1
    h_cnt[h_] += 1
    w_cnt[w_] += 1
    mat[h_][w_] = 1

max_h = max(h_cnt)
max_h_idx = []
for i in range(h):
    if h_cnt[i] == max_h:
        max_h_idx.append(i)

max_w = max(w_cnt)
max_w_idx = []
for i in range(w):
    if w_cnt[i] == max_w:
        max_w_idx.append(i)

for i in max_h_idx:
    for j in max_w_idx:
        if mat[i][j] == 0:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)


Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0] * h
w_cnt = [0] * w

bomb_set = set()

for i in range(m):
    h_, w_ = map(int, input().split())
    h_ -= 1
    w_ -= 1
    h_cnt[h_] += 1
    w_cnt[w_] += 1
    bomb_set.add((h_, w_))

max_h = max(h_cnt)
max_h_idx = []
for i in range(h):
    if h_cnt[i] == max_h:
        max_h_idx.append(i)

max_w = max(w_cnt)
max_w_idx = []
for i in range(w):
    if w_cnt[i] == max_w:
        max_w_idx.append(i)

minus = -1
for i in max_h_idx:
    for j in max_w_idx:
        if (i, j) not in bomb_set:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

money = 1000
stock = 0
for i in range(n):
    money += stock * a[i]
    stock = 0

    if a[i] < a[i + 1]:
        stock = money // a[i]
        money %= a[i]

print(money)


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

money = 1000
stock = 0
for i in range(n):
    # 売る
    money += stock * a[i]
    stock = 0

    # 買う
    if i != n - 1 and a[i] < a[i + 1]:
        stock = money // a[i]
        money %= a[i]

print(money)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    K = int(input())

    if K % 2 == 0:
        print(-1)
        exit()

    ans = 1
    X = 7
    while True:
        mod = X % K
        if mod == 0:
            break
        else:
            ans += 1
            X = mod * 10 + 7
    print(ans)
        

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    K = int(input())

    if K % 2 == 0:
        print(-1)
        exit()

    ans = 1
    X = 7
    count = K
    while count > 0:
        mod = X % K
        if mod == 0:
            break
        else:
            ans += 1
            X = mod * 10 + 7
            count -= 1
    print(ans if count > 0 else -1)
        

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1,N+1):
    cnt = 0
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                check = x*x + y*y + z*z + x*y + y*z + z*x
                if check == n:
                    cnt += 1
                elif check > n:
                    break
    print(cnt)

Fixed submission:
N = int(input())
cnt = [0] * (N + 1)

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            check = x*x + y*y + z*z + x*y + y*z + z*x
            if check <= N:
                cnt[check] += 1

for i in range(1,N+1):
    print(cnt[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for n in range(1,N+1):
    cnt = 0
    for x in range(1,100):
        for y in range(1,100):
            for z in range(1,100):
                check = x*x + y*y + z*z + x*y + y*z + z*x
                if check == n:
                    cnt += 1
                elif check > n:
                    break
    print(cnt)

Fixed submission:
N = int(input())
cnt = [0] * (N + 1)

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            check = x*x + y*y + z*z + x*y + y*z + z*x
            if check <= N:
                cnt[check] += 1

for i in range(1,N+1):
    print(cnt[i])
Buggy python submission (verdict: Runtime Error):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    K = int(input())
    S = input()

    mod = 10 ** 9 + 7
    n = len(S)
    ans = 0

    fact =[1]*(K+n)
    factinv = [1]*(K+n)


    for i in range(2,K+n):
        fact[i] = (fact[i-1] * i) % mod
        factinv[i] = pow(fact[i],mod-2,mod)

    def nCr(n,r):
        return (fact[n] * factinv[r] * factinv[n-r]) % mod

    for i in range(K+1):
        #ans += ((25 ** i * nCr(i+n-1,n-1)) * (26 ** (K - i))) % mod
        ans += ((25 ** i * fact[i+n-1] * factinv[n-1] * factinv[i] ) * (26 ** (K - i))) % mod
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
a = input()

if a.isupper():
    print('A')
else:
    print('a')
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    N = int(input())
    A = sorted(list(map(int,input().split())))
    check = [0] * N
    ans = 0

    for i in range(N):
        if check[i] == 1:
            continue
        elif check[i] == 0 and A.count(A[i]) == 1:
            ans += 1
        for j in range(i+1,N):
            if A[j] % A[i] == 0:
                check[j] = 1
            else:
                continue
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    N = int(input())
    A = sorted(list(map(int,input().split())))
    A_max = A[-1] + 1
    dp = [0] * A_max

    for i in A:
        dp[i] += 1
        if dp[i] == 1:
            for j in range(i*2,A_max,i):
                dp[j] = 2
    print(dp.count(1))

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    N = int(input())
    A = sorted(list(map(int,input().split())))
    check = [0] * N
    ans = 0

    for i in range(N):
        if check[i] == 1:
            continue
        elif check[i] == 0 and A.count(A[i]) == 1:
            ans += 1
        for j in range(i+1,N):
            if A[j] % A[i] == 0:
                check[j] = 1
            else:
                continue
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    N = int(input())
    A = sorted(list(map(int,input().split())))
    A_max = A[-1] + 1
    dp = [0] * A_max

    for i in A:
        dp[i] += 1
        if dp[i] == 1:
            for j in range(i*2,A_max,i):
                dp[j] = 2
    print(dp.count(1))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
from itertools import accumulate
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    for _ in range(K):
        data = [0] * len(A)
        for i in range(N):
            range_mai = math.ceil(i - A[i] - 0.5)
            range_pura = math.floor(i + A[i] + 0.5)
            if range_mai < 0:
                range_mai = 0
            if range_pura > N - 1:
                range_pura = N - 1
            data[range_mai] += 1
            if range_pura + 1 != N:
                data[range_pura + 1] -= 1
            
        ruiseki = list(accumulate(data))
        A = ruiseki
        if min(A) == N:
            break
    print(*A)

if __name__ == "__main__":
    main()

Fixed submission:
from itertools import accumulate
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    for _ in range(K):
        data = [0] * len(A)
        for i in range(N):
            range_mai = i - A[i]
            range_pura = i + A[i]
            if range_mai < 0:
                range_mai = 0
            if range_pura > N - 1:
                range_pura = N - 1
            data[range_mai] += 1
            if range_pura + 1 != N:
                data[range_pura + 1] -= 1

        A = list(accumulate(data))
        if min(A) == N:
            break
    print(*A)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def input():
    return sys.stdin.readline().strip()

def trial_division(n):
    prime_factors = list()
    while n % 2 == 0:
        prime_factors.append(2)
        n //= 2
    p = 3
    while p * p <= n:
        if n % p == 0:
            prime_factors.append(p)
            n //= p
        else:
            p += 2
    if n != 1:
        prime_factors.append(n)
    return prime_factors

def keisan(A,B):
    return A**4 + A**3 * B + A**2 * B**2 + A * B ** 3 + B**4

def main():
    X = int(input())
    if X == 1:
        print(1,0)
        exit()
    soinsu = trial_division(X)
    A = 0
    while True:
        A += 1
        B = A - soinsu[0]
        if A**5 - B**5 == X:
            print(A,B)
            exit()


if __name__ == "__main__":
    main()

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    X = int(input())
    for A in range(-118,120):
        for B in range(-119,119):
            if A**5 - B**5 == X:
                print(A,B)
                exit()

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def nCr(n,r):
    if r*2>n:
        return nCr(n,n-r)
    mod = 10 ** 9 + 7
    a = b = 1
    for i in range(r):
        a = (a * (n - i)) % mod
        b = (b * (r - i)) % mod
    return (a * pow(b,mod-2,mod))%mod

N,K = map(int,input().split())
cnt = 0
tmp = [i for i in range(N+1)]
for i in range(K,N+2):
    cnt += sum(tmp[-i:])-sum(tmp[:i])+1

print(cnt)

Fixed submission:
def main():
    N,K = map(int,input().split())
    ans = 0
    souwa = N*(N+1)//2
    mod = 10 ** 9 + 7

    for i in range(K,N+2):
        mi = (i-1)*i//2
        ma = souwa - (N-i)*(N-i+1)//2
        ans += ma-mi+1

    print(ans%mod)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
ans = 0

for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += math.gcd(math.gcd(a,b),c)
print(ans)

Fixed submission:
import math
K = int(input())
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        t = math.gcd(a,b)
        for c in range(1,K+1):
            ans += math.gcd(t,c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if S[i] == S[j] or S[j] == S[k] or S[k] == S[i]:
                continue
            elif j-i == k-j:
                continue
            else:
                ans += 1
print(ans)

Fixed submission:
N = int(input())
S = input()
ans = S.count("R")*S.count("G")*S.count("B")

for i in range(N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N == 1:
    a = 0
else:
    a = cmb(N,2)
if M == 1:
    b = 0
else:
    b = cmb(M,2)
print(a+b)

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N == 1 or N == 0:
    a = 0
else:
    a = cmb(N,2)
if M == 1 or M == 0:
    b = 0
else:
    b = cmb(M,2)
print(a+b)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
countdic = Counter(A)
nCrdic = {}

for key,value in countdic.items():
    nCrdic[key] = (value*(value-1))//2 if value > 1 else 0
for i in A:
    if countdic[i] > 2:
        ans = sum(nCrdic.values()) - nCrdic[i] + ((countdic[i]-1)*(countdic[i]-2))//2
    else: ans = sum(nCrdic.values()) - nCrdic[i]
    print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
countdic = Counter(A)
goukei = 0
ans = ''
for key,value in countdic.items():
    goukei += (value*(value-1))//2
for i in A:
    ans = goukei -(countdic[i]*(countdic[i]-1))//2 + ((countdic[i]-1)*(countdic[i]-2))//2
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
checklist = list(set(A))
countdic = {}
nCrdic = {}

for i in checklist:
    countdic[i] = A.count(i)
for key,value in countdic.items():
    nCrdic[key] = (value*(value-1))//2 if value > 1 else 0
for i in A:
    if countdic[i] > 2:
        ans = sum(nCrdic.values()) - nCrdic[i] + ((countdic[i]-1)*(countdic[i]-2))//2
    else: ans = sum(nCrdic.values()) - nCrdic[i]
    print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
countdic = Counter(A)
goukei = 0
ans = ''
for key,value in countdic.items():
    goukei += (value*(value-1))//2
for i in A:
    ans = goukei -(countdic[i]*(countdic[i]-1))//2 + ((countdic[i]-1)*(countdic[i]-2))//2
    print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
checklist = list(set(A))
dic = {}
nCrdic = {}
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in checklist:
    dic[i] = A.count(i)
for key,value in dic.items():
    nCrdic[key] = cmb(value,2) if value > 1 else 0
for i in A:
    if dic[i] > 2:
        ans = sum(nCrdic.values()) - nCrdic[i] + cmb(dic[i]-1,2)
    else: ans = sum(nCrdic.values()) - nCrdic[i]
    print(ans)

Fixed submission:
from collections import Counter

N = int(input())
A = list(map(int,input().split()))
countdic = Counter(A)
goukei = 0
ans = ''
for key,value in countdic.items():
    goukei += (value*(value-1))//2
for i in A:
    ans = goukei -(countdic[i]*(countdic[i]-1))//2 + ((countdic[i]-1)*(countdic[i]-2))//2
    print(ans)
Buggy python submission (verdict: Runtime Error):
from decimal import Decimal
import math
a,b,c = map(int,input().split())
routeA = pow(a,0.5)
routeB = pow(b,0.5)
routeC = pow(c,0.5)

if Decimal(pow(a,0.5)) + Decimal(pow(b,0.5)) > Decimal(pow(c,0.5)) or math.isclose(routeA+routeB,routeC):
    print('No')
else:
    print('Yes')

Fixed submission:
from decimal import Decimal
import math
a,b,c = map(int,input().split())
d = c - a - b
if d >0 and pow(d,2) > 4 * a * b:
    print('Yes')
else:print('No')
Buggy python submission (verdict: Runtime Error):
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = []

waribiki = [[0] * A for i in range(B)]
for _ in range(M):
    x,y,c = map(int,input().split())
    waribiki[x-1][y-1]=c

for numA,i in enumerate(a):
    for numB,j in enumerate(b):
        ans.append(i+j-waribiki[numB][numA])

print(min(ans)) 

Fixed submission:
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = []
waribiki = []

for _ in range(M):
    x,y,c = map(int,input().split())
    waribiki.append(a[x-1]+b[y-1]-c)
a_min=min(a)
b_min=min(b)
ab_min = a_min+b_min
waribiki_min = min(waribiki)
print(min(waribiki_min,ab_min))
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())

Blue='b'*A
Red='r'*B
BlueRed=Blue+Red
ans = ''
time = (N // len(BlueRed))+1
ans= BlueRed*time
ans2=ans[:N]
print(ans2.count('b'))

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

ans = N // (A+B) * A
rem = N % (A+B)
ans += min(rem,A)

print(ans)

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

Blue='b'*A
Red='r'*B
BlueRed=Blue+Red
ans = ''
time = (N // 7)+1
ans= BlueRed*time
ans2=ans[:N]
print(ans2.count('b'))

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

ans = N // (A+B) * A
rem = N % (A+B)
ans += min(rem,A)

print(ans)

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

Blue='b'*A
Red='r'*B
ans = ''
for i in range(1,N):
    ans = ans + Blue + Red
    if N <= len(ans):
        ans2=ans[:N]
        print(ans2.count('b'))
        break

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

ans = N // (A+B) * A
rem = N % (A+B)
ans += min(rem,A)

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

for _ in range(Q):
    Query = input().split()
    if Query[0] == '1':
        S = S[::-1]
    else:
        if Query[1] == '1':
            S = Query[2] + S
        else:
            S = S + Query[2]
print(S)

Fixed submission:
from collections import deque

S = deque(input())
Q = int(input())
Flag = False

for _ in range(Q):
    Query = input().split()
    if Query[0] == '1':
        if Flag == False:
            Flag = True
        else:Flag = False
    else:
        if Query[1] == '1':
            if Flag == False:S.appendleft(Query[2])
            else:S.append(Query[2])
        else:
            if Flag == False:S.append(Query[2])
            else:S.appendleft(Query[2])
l = list(S)
if Flag:print(''.join(l[::-1]))
else:print(''.join(l))